[linux-cifs-client] [PATCH] cifs: prevent cifs_writepages() from skipping unwritten pages

Dave Kleikamp shaggy at linux.vnet.ibm.com
Mon Nov 17 13:02:47 GMT 2008


cifs: prevent cifs_writepages() from skipping unwritten pages

In order to write contiguous pages whenever possible, cifs_writepages()
asks pagevec_lookup_tag() for more pages than it may write at one time.
Normally, it then resets index just past the last page written before calling
pagevec_lookup_tag() again.

If cifs_writepages() can't write the first page returned, it wasn't resetting
index, and the next call to pagevec_lookup_tag() resulted in skipping all of
the pages it previously returned, even though cifs_writepages() did nothing
with them.  This can result in data loss when the file descriptor is about
to be closed.

This patch ensures that index gets set back to the first returned page so
that none get skipped.

Signed-off-by: Dave Kleikamp <shaggy at linux.vnet.ibm.com>
Cc: Shirish S Pargaonkar <shirishp at us.ibm.com>
Cc: Steve French <sfrench at us.ibm.com>
Cc: Jeff Layton <jlayton at redhat.com>

diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 1540ada..9815e03 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -1404,7 +1404,10 @@ retry:
 			if ((wbc->nr_to_write -= n_iov) <= 0)
 				done = 1;
 			index = next;
-		}
+		} else
+			/* Need to re-find the pages we skipped */
+			index = pvec.pages[0]->index;
+
 		pagevec_release(&pvec);
 	}
 	if (!scanned && !done) {

-- 
David Kleikamp
IBM Linux Technology Center



More information about the linux-cifs-client mailing list