1
0
Fork 0

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>
wifi-calibration
Jeff Layton 2010-10-15 15:34:07 -04:00 committed by Steve French
parent 5f6dbc9e4a
commit d3f1322af8
1 changed files with 7 additions and 14 deletions

View File

@ -1688,20 +1688,13 @@ int cifs_flush(struct file *file, fl_owner_t id)
struct inode *inode = file->f_path.dentry->d_inode; struct inode *inode = file->f_path.dentry->d_inode;
int rc = 0; int rc = 0;
/* Rather than do the steps manually: if (file->f_mode & FMODE_WRITE) {
lock the inode for writing rc = filemap_write_and_wait(inode->i_mapping);
loop through pages looking for write behind data (dirty pages) /* reset wb rc if we were able to write out dirty pages */
coalesce into contiguous 16K (or smaller) chunks to write to server if (!rc) {
send to server (prefer in parallel) rc = CIFS_I(inode)->write_behind_rc;
deal with writebehind errors CIFS_I(inode)->write_behind_rc = 0;
unlock inode for writing }
filemapfdatawrite appears easier for the time being */
rc = filemap_fdatawrite(inode->i_mapping);
/* reset wb rc if we were able to write out dirty pages */
if (!rc) {
rc = CIFS_I(inode)->write_behind_rc;
CIFS_I(inode)->write_behind_rc = 0;
} }
cFYI(1, "Flush inode %p file %p rc %d", inode, file, rc); cFYI(1, "Flush inode %p file %p rc %d", inode, file, rc);