aboutsummaryrefslogtreecommitdiffstats
path: root/fs/gfs2
diff options
context:
space:
mode:
authorJosef Bacik <josef@redhat.com>2011-07-16 20:44:56 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2011-07-20 20:47:59 -0400
commit02c24a82187d5a628c68edfe71ae60dc135cd178 (patch)
treec8dbaba4d82e2b20ed4335910a564a1f7d90fcf6 /fs/gfs2
parent22735068d53c7115e384bc88dea95b17e76a6839 (diff)
fs: push i_mutex and filemap_write_and_wait down into ->fsync() handlers
Btrfs needs to be able to control how filemap_write_and_wait_range() is called in fsync to make it less of a painful operation, so push down taking i_mutex and the calling of filemap_write_and_wait() down into the ->fsync() handlers. Some file systems can drop taking the i_mutex altogether it seems, like ext3 and ocfs2. For correctness sake I just pushed everything down in all cases to make sure that we keep the current behavior the same for everybody, and then each individual fs maintainer can make up their mind about what to do from there. Thanks, Acked-by: Jan Kara <jack@suse.cz> Signed-off-by: Josef Bacik <josef@redhat.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/gfs2')
-rw-r--r--fs/gfs2/file.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c
index 89c39e53760d..f82cb5e1cb6b 100644
--- a/fs/gfs2/file.c
+++ b/fs/gfs2/file.c
@@ -544,7 +544,9 @@ static int gfs2_close(struct inode *inode, struct file *file)
544 544
545/** 545/**
546 * gfs2_fsync - sync the dirty data for a file (across the cluster) 546 * gfs2_fsync - sync the dirty data for a file (across the cluster)
547 * @file: the file that points to the dentry (we ignore this) 547 * @file: the file that points to the dentry
548 * @start: the start position in the file to sync
549 * @end: the end position in the file to sync
548 * @datasync: set if we can ignore timestamp changes 550 * @datasync: set if we can ignore timestamp changes
549 * 551 *
550 * The VFS will flush data for us. We only need to worry 552 * The VFS will flush data for us. We only need to worry
@@ -553,23 +555,32 @@ static int gfs2_close(struct inode *inode, struct file *file)
553 * Returns: errno 555 * Returns: errno
554 */ 556 */
555 557
556static int gfs2_fsync(struct file *file, int datasync) 558static int gfs2_fsync(struct file *file, loff_t start, loff_t end,
559 int datasync)
557{ 560{
558 struct inode *inode = file->f_mapping->host; 561 struct inode *inode = file->f_mapping->host;
559 int sync_state = inode->i_state & (I_DIRTY_SYNC|I_DIRTY_DATASYNC); 562 int sync_state = inode->i_state & (I_DIRTY_SYNC|I_DIRTY_DATASYNC);
560 struct gfs2_inode *ip = GFS2_I(inode); 563 struct gfs2_inode *ip = GFS2_I(inode);
561 int ret; 564 int ret;
562 565
566 ret = filemap_write_and_wait_range(inode->i_mapping, start, end);
567 if (ret)
568 return ret;
569 mutex_lock(&inode->i_mutex);
570
563 if (datasync) 571 if (datasync)
564 sync_state &= ~I_DIRTY_SYNC; 572 sync_state &= ~I_DIRTY_SYNC;
565 573
566 if (sync_state) { 574 if (sync_state) {
567 ret = sync_inode_metadata(inode, 1); 575 ret = sync_inode_metadata(inode, 1);
568 if (ret) 576 if (ret) {
577 mutex_unlock(&inode->i_mutex);
569 return ret; 578 return ret;
579 }
570 gfs2_ail_flush(ip->i_gl); 580 gfs2_ail_flush(ip->i_gl);
571 } 581 }
572 582
583 mutex_unlock(&inode->i_mutex);
573 return 0; 584 return 0;
574} 585}
575 586