aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/file.c
diff options
context:
space:
mode:
authorJeff Layton <jlayton@redhat.com>2010-10-15 15:34:07 -0400
committerSteve French <sfrench@us.ibm.com>2010-10-24 20:18:59 -0400
commitd3f1322af8f866be54ea79a4002fc30c98290411 (patch)
treeb043a2c269a0e2b8b64c34644dfe8586f114ead9 /fs/cifs/file.c
parent5f6dbc9e4afe4d1d39e85de3ac2720a2042ad191 (diff)
cifs: wait for writeback to complete in cifs_flush
The f_op->flush operation is the last chance to return a writeback related error when closing a file. Ensure that we don't miss reporting any errors by waiting for writeback to complete in cifs_flush before proceeding. There's no reason to do this when the file isn't open for write however. Signed-off-by: Jeff Layton <jlayton@redhat.com> Reviewed-by: Suresh Jayaraman <sjayaraman@suse.de> Reviewed-by: David Kleikamp <shaggy@linux.vnet.ibm.com> Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'fs/cifs/file.c')
-rw-r--r--fs/cifs/file.c21
1 files changed, 7 insertions, 14 deletions
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index baf4b5067ff9..128e07b85d6c 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -1688,20 +1688,13 @@ int cifs_flush(struct file *file, fl_owner_t id)
1688 struct inode *inode = file->f_path.dentry->d_inode; 1688 struct inode *inode = file->f_path.dentry->d_inode;
1689 int rc = 0; 1689 int rc = 0;
1690 1690
1691 /* Rather than do the steps manually: 1691 if (file->f_mode & FMODE_WRITE) {
1692 lock the inode for writing 1692 rc = filemap_write_and_wait(inode->i_mapping);
1693 loop through pages looking for write behind data (dirty pages) 1693 /* reset wb rc if we were able to write out dirty pages */
1694 coalesce into contiguous 16K (or smaller) chunks to write to server 1694 if (!rc) {
1695 send to server (prefer in parallel) 1695 rc = CIFS_I(inode)->write_behind_rc;
1696 deal with writebehind errors 1696 CIFS_I(inode)->write_behind_rc = 0;
1697 unlock inode for writing 1697 }
1698 filemapfdatawrite appears easier for the time being */
1699
1700 rc = filemap_fdatawrite(inode->i_mapping);
1701 /* reset wb rc if we were able to write out dirty pages */
1702 if (!rc) {
1703 rc = CIFS_I(inode)->write_behind_rc;
1704 CIFS_I(inode)->write_behind_rc = 0;
1705 } 1698 }
1706 1699
1707 cFYI(1, "Flush inode %p file %p rc %d", inode, file, rc); 1700 cFYI(1, "Flush inode %p file %p rc %d", inode, file, rc);