]> git.baikalelectronics.ru Git - kernel.git/commit
nfs: Fix cache_validity check in nfs_write_pageuptodate()
authorScott Mayhew <smayhew@redhat.com>
Fri, 20 Jun 2014 12:44:42 +0000 (08:44 -0400)
committerTrond Myklebust <trond.myklebust@primarydata.com>
Tue, 24 Jun 2014 22:46:56 +0000 (18:46 -0400)
commit4deca3b56f8d7bfc89e64db902bfdedf177dd082
treee29440876bda67032adab33b12d5f9bba2cbe5ea
parenta0d800ddb2172f2da92426d4d78913597ff42e77
nfs: Fix cache_validity check in nfs_write_pageuptodate()

NFS_INO_INVALID_DATA cannot be ignored, even if we have a delegation.

We're still having some problems with data corruption when multiple
clients are appending to a file and those clients are being granted
write delegations on open.

To reproduce:

Client A:
vi /mnt/`hostname -s`
while :; do echo "XXXXXXXXXXXXXXX" >>/mnt/file; sleep $(( $RANDOM % 5 )); done

Client B:
vi /mnt/`hostname -s`
while :; do echo "YYYYYYYYYYYYYYY" >>/mnt/file; sleep $(( $RANDOM % 5 )); done

What's happening is that in nfs_update_inode() we're recognizing that
the file size has changed and we're setting NFS_INO_INVALID_DATA
accordingly, but then we ignore the cache_validity flags in
nfs_write_pageuptodate() because we have a delegation.  As a result,
in nfs_updatepage() we're extending the write to cover the full page
even though we've not read in the data to begin with.

Signed-off-by: Scott Mayhew <smayhew@redhat.com>
Cc: <stable@vger.kernel.org> # v3.11+
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
fs/nfs/write.c