aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs
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/cifs
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/cifs')
-rw-r--r--fs/cifs/cifsfs.h4
-rw-r--r--fs/cifs/file.c18
2 files changed, 18 insertions, 4 deletions
diff --git a/fs/cifs/cifsfs.h b/fs/cifs/cifsfs.h
index 036ca83e5f46..fbd050c8d52a 100644
--- a/fs/cifs/cifsfs.h
+++ b/fs/cifs/cifsfs.h
@@ -91,8 +91,8 @@ extern ssize_t cifs_user_writev(struct kiocb *iocb, const struct iovec *iov,
91extern ssize_t cifs_strict_writev(struct kiocb *iocb, const struct iovec *iov, 91extern ssize_t cifs_strict_writev(struct kiocb *iocb, const struct iovec *iov,
92 unsigned long nr_segs, loff_t pos); 92 unsigned long nr_segs, loff_t pos);
93extern int cifs_lock(struct file *, int, struct file_lock *); 93extern int cifs_lock(struct file *, int, struct file_lock *);
94extern int cifs_fsync(struct file *, int); 94extern int cifs_fsync(struct file *, loff_t, loff_t, int);
95extern int cifs_strict_fsync(struct file *, int); 95extern int cifs_strict_fsync(struct file *, loff_t, loff_t, int);
96extern int cifs_flush(struct file *, fl_owner_t id); 96extern int cifs_flush(struct file *, fl_owner_t id);
97extern int cifs_file_mmap(struct file * , struct vm_area_struct *); 97extern int cifs_file_mmap(struct file * , struct vm_area_struct *);
98extern int cifs_file_strict_mmap(struct file * , struct vm_area_struct *); 98extern int cifs_file_strict_mmap(struct file * , struct vm_area_struct *);
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index bb71471a4d9d..cef584451113 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -1401,7 +1401,8 @@ static int cifs_write_end(struct file *file, struct address_space *mapping,
1401 return rc; 1401 return rc;
1402} 1402}
1403 1403
1404int cifs_strict_fsync(struct file *file, int datasync) 1404int cifs_strict_fsync(struct file *file, loff_t start, loff_t end,
1405 int datasync)
1405{ 1406{
1406 int xid; 1407 int xid;
1407 int rc = 0; 1408 int rc = 0;
@@ -1410,6 +1411,11 @@ int cifs_strict_fsync(struct file *file, int datasync)
1410 struct inode *inode = file->f_path.dentry->d_inode; 1411 struct inode *inode = file->f_path.dentry->d_inode;
1411 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); 1412 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
1412 1413
1414 rc = filemap_write_and_wait_range(inode->i_mapping, start, end);
1415 if (rc)
1416 return rc;
1417 mutex_lock(&inode->i_mutex);
1418
1413 xid = GetXid(); 1419 xid = GetXid();
1414 1420
1415 cFYI(1, "Sync file - name: %s datasync: 0x%x", 1421 cFYI(1, "Sync file - name: %s datasync: 0x%x",
@@ -1428,16 +1434,23 @@ int cifs_strict_fsync(struct file *file, int datasync)
1428 rc = CIFSSMBFlush(xid, tcon, smbfile->netfid); 1434 rc = CIFSSMBFlush(xid, tcon, smbfile->netfid);
1429 1435
1430 FreeXid(xid); 1436 FreeXid(xid);
1437 mutex_unlock(&inode->i_mutex);
1431 return rc; 1438 return rc;
1432} 1439}
1433 1440
1434int cifs_fsync(struct file *file, int datasync) 1441int cifs_fsync(struct file *file, loff_t start, loff_t end, int datasync)
1435{ 1442{
1436 int xid; 1443 int xid;
1437 int rc = 0; 1444 int rc = 0;
1438 struct cifs_tcon *tcon; 1445 struct cifs_tcon *tcon;
1439 struct cifsFileInfo *smbfile = file->private_data; 1446 struct cifsFileInfo *smbfile = file->private_data;
1440 struct cifs_sb_info *cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); 1447 struct cifs_sb_info *cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
1448 struct inode *inode = file->f_mapping->host;
1449
1450 rc = filemap_write_and_wait_range(inode->i_mapping, start, end);
1451 if (rc)
1452 return rc;
1453 mutex_lock(&inode->i_mutex);
1441 1454
1442 xid = GetXid(); 1455 xid = GetXid();
1443 1456
@@ -1449,6 +1462,7 @@ int cifs_fsync(struct file *file, int datasync)
1449 rc = CIFSSMBFlush(xid, tcon, smbfile->netfid); 1462 rc = CIFSSMBFlush(xid, tcon, smbfile->netfid);
1450 1463
1451 FreeXid(xid); 1464 FreeXid(xid);
1465 mutex_unlock(&inode->i_mutex);
1452 return rc; 1466 return rc;
1453} 1467}
1454 1468