diff options
author | Miklos Szeredi <mszeredi@redhat.com> | 2018-12-03 12:14:43 +0300 |
---|---|---|
committer | Miklos Szeredi <mszeredi@redhat.com> | 2018-12-03 12:14:43 +0300 |
commit | a9c2d1e82fc2937baf43c0d400f0c9e87dcf035d (patch) | |
tree | 31886a807776ec79f0f82b16cd76268c37894e35 /fs/fuse/dir.c | |
parent | 4fc4bb796b0c75067fd65292dfd874869ff7c9dc (diff) | |
download | linux-a9c2d1e82fc2937baf43c0d400f0c9e87dcf035d.tar.xz |
fuse: fix fsync on directory
Commit ab2257e9941b ("fuse: reduce size of struct fuse_inode") moved parts
of fields related to writeback on regular file and to directory caching
into a union. However fuse_fsync_common() called from fuse_dir_fsync()
touches some writeback related fields, resulting in a crash.
Move writeback related parts from fuse_fsync_common() to fuse_fysnc().
Reported-by: Brett Girton <btgirton@gmail.com>
Tested-by: Brett Girton <btgirton@gmail.com>
Fixes: ab2257e9941b ("fuse: reduce size of struct fuse_inode")
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Diffstat (limited to 'fs/fuse/dir.c')
-rw-r--r-- | fs/fuse/dir.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index 47395b0c3b35..56931dfdcc46 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -1249,7 +1249,25 @@ static int fuse_dir_release(struct inode *inode, struct file *file) static int fuse_dir_fsync(struct file *file, loff_t start, loff_t end, int datasync) { - return fuse_fsync_common(file, start, end, datasync, 1); + struct inode *inode = file->f_mapping->host; + struct fuse_conn *fc = get_fuse_conn(inode); + int err; + + if (is_bad_inode(inode)) + return -EIO; + + if (fc->no_fsyncdir) + return 0; + + inode_lock(inode); + err = fuse_fsync_common(file, start, end, datasync, FUSE_FSYNCDIR); + if (err == -ENOSYS) { + fc->no_fsyncdir = 1; + err = 0; + } + inode_unlock(inode); + + return err; } static long fuse_dir_ioctl(struct file *file, unsigned int cmd, |