Skip to content

Commit

Permalink
fuse: clean up fsync
Browse files Browse the repository at this point in the history
Don't need to start I/O twice (once without i_mutex and one within).

Also make sure that even if the userspace filesystem doesn't support FSYNC
we do all the steps other than sending the message.

Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
  • Loading branch information
Miklos Szeredi committed Apr 28, 2014
1 parent 93d2269 commit 22401e7
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions fs/fuse/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -490,21 +490,14 @@ int fuse_fsync_common(struct file *file, loff_t start, loff_t end,
if (is_bad_inode(inode))
return -EIO;

err = filemap_write_and_wait_range(inode->i_mapping, start, end);
if (err)
return err;

if ((!isdir && fc->no_fsync) || (isdir && fc->no_fsyncdir))
return 0;

mutex_lock(&inode->i_mutex);

/*
* Start writeback against all dirty pages of the inode, then
* wait for all outstanding writes, before sending the FSYNC
* request.
*/
err = write_inode_now(inode, 0);
err = filemap_write_and_wait_range(inode->i_mapping, start, end);
if (err)
goto out;

Expand All @@ -515,6 +508,8 @@ int fuse_fsync_common(struct file *file, loff_t start, loff_t end,
if (err)
goto out;
}
if ((!isdir && fc->no_fsync) || (isdir && fc->no_fsyncdir))
goto out;

req = fuse_get_req_nopages(fc);
if (IS_ERR(req)) {
Expand Down

0 comments on commit 22401e7

Please sign in to comment.