Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion fs/fuse/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ obj-$(CONFIG_FUSE_FS) += fuse.o
obj-$(CONFIG_CUSE) += cuse.o
obj-$(CONFIG_VIRTIO_FS) += virtiofs.o

fuse-y := dev.o dir.o file.o inode.o control.o xattr.o acl.o readdir.o ioctl.o
fuse-y := dev.o dir.o file.o inode.o control.o xattr.o acl.o readdir.o ioctl.o fuse_dlm_cache.o
fuse-y += iomode.o
fuse-$(CONFIG_FUSE_DAX) += dax.o
fuse-$(CONFIG_FUSE_IO_URING) += dev_uring.o
Expand Down
6 changes: 6 additions & 0 deletions fs/fuse/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
See the file COPYING.
*/

#include "fuse_dlm_cache.h"
#include "fuse_i.h"

#include <linux/pagemap.h>
Expand Down Expand Up @@ -1924,6 +1925,8 @@ int fuse_do_setattr(struct dentry *dentry, struct iattr *attr,
* truncation has already been done by OPEN. But still
* need to truncate page cache.
*/
if (fc->dlm && fc->writeback_cache)
fuse_dlm_cache_release_locks(fi);
i_size_write(inode, 0);
truncate_pagecache(inode, 0);
goto out;
Expand Down Expand Up @@ -2029,6 +2032,9 @@ int fuse_do_setattr(struct dentry *dentry, struct iattr *attr,
*/
if ((is_truncate || !is_wb) &&
S_ISREG(inode->i_mode) && oldsize != outarg.attr.size) {
if (fc->dlm && fc->writeback_cache)
fuse_dlm_unlock_range(fi, outarg.attr.size & PAGE_MASK, -1);

truncate_pagecache(inode, outarg.attr.size);
invalidate_inode_pages2(mapping);
}
Expand Down
13 changes: 13 additions & 0 deletions fs/fuse/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

#include "fuse_i.h"
#include "fuse_dlm_cache.h"

#include <linux/pagemap.h>
#include <linux/slab.h>
Expand Down Expand Up @@ -1423,6 +1424,17 @@ static ssize_t fuse_cache_write_iter(struct kiocb *iocb, struct iov_iter *from)
goto writethrough;
}

/* if we have dlm support acquire the lock for the area
* we are writing into */
if (fc->dlm) {
/* note that a file opened with O_APPEND will have relative values
* in ki_pos. This code is here for convenience and for libfuse overlay test.
* Filesystems should handle O_APPEND with 'direct io' to additionally
* get the performance benefits of 'parallel direct writes'. */
loff_t pos = file->f_flags & O_APPEND ? i_size_read(inode) + iocb->ki_pos : iocb->ki_pos;
size_t length = iov_iter_count(from);
fuse_get_dlm_write_lock(file, pos, length);
}
return generic_file_write_iter(iocb, from);
}

Expand Down Expand Up @@ -3336,6 +3348,7 @@ void fuse_init_file_inode(struct inode *inode, unsigned int flags)

INIT_LIST_HEAD(&fi->write_files);
INIT_LIST_HEAD(&fi->queued_writes);
fuse_dlm_cache_init(fi);
fi->writectr = 0;
fi->iocachectr = 0;
init_waitqueue_head(&fi->page_waitq);
Expand Down
Loading