]> git.karo-electronics.de Git - karo-tx-linux.git/commit
cifs: prevent cifs_writepages() from skipping unwritten pages
authorDave Kleikamp <shaggy@linux.vnet.ibm.com>
Fri, 21 Nov 2008 08:54:20 +0000 (14:24 +0530)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 5 Dec 2008 18:55:36 +0000 (10:55 -0800)
commit23f64b234abbbe0ce104e43bb5150b1cf2fd50ef
treee7ab991fc59c27ffa51b655c6d0b5fefe8e00f42
parent13859b1be3243f98d2c00d349dd0f85f24219b0e
cifs: prevent cifs_writepages() from skipping unwritten pages

commit b066a48c9532243894f93a06ca5a0ee2cc21a8dc upstream

prevent cifs_writepages() from skipping unwritten pages

Fixes a data corruption under heavy stress in which pages could be left
dirty after all open instances of a inode have been closed.

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 next returned page so
that none get skipped.

Signed-off-by: Dave Kleikamp <shaggy@linux.vnet.ibm.com>
Acked-by: Jeff Layton <jlayton@redhat.com>
Cc: Shirish S Pargaonkar <shirishp@us.ibm.com>
Signed-off-by: Steve French <sfrench@us.ibm.com>
Cc: Suresh Jayaraman <sjayaraman@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
fs/cifs/file.c