Linux NFS development
 help / color / mirror / Atom feed
* [PATCH RFC] nfs:  ensure cached data is correct before using delegation
@ 2014-06-13 18:18 Scott Mayhew
  2014-06-13 18:18 ` Scott Mayhew
  0 siblings, 1 reply; 11+ messages in thread
From: Scott Mayhew @ 2014-06-13 18:18 UTC (permalink / raw)
  To: trond.myklebust; +Cc: linux-nfs

Hi Trond,

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

The resulting data looks something like this:

XXXXXXXXXXXXXXX
XXXXXXXXXXXXXXX
^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@XXXXXXXXXXXXXXX
^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@XXXXXXXXXXXXXXX
^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@XXXXXXXXXXXXXXX
^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@XXXXXXXXXXXXXXX
^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@XXXXXXXXXXXXXXX
^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@XXXXXXXXXXXXXXX
^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@XXXXXXXXXXXXXXX
^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@XXXXXXXXXXXXXXX
^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@XXXXXXXXXXXXXXX
YYYYYYYYYYYYYYY
YYYYYYYYYYYYYYY

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.

The attached patch fixes the issue by calling nfs_revalidate_mapping() whenever
we attach a delegation to an nfs_inode.  However, I'm not entirely sure that
calling nfs_revalidate_inode() in those places won't cause some other issues.  I
tested the change with all of the stock workloads in nfsometer except for
bonnie++.

An alternative would be to just revert c7559663 (NFS: Allow nfs_updatepage to
extend a write under additional circumstances), but then we'd lose the
performance benefits of that patch... which I'd like to avoid if possible.

-Scott

Scott Mayhew (1):
  nfs:  ensure cached data is correct before using delegation

 fs/nfs/delegation.c | 1 +
 fs/nfs/inode.c      | 1 +
 fs/nfs/nfs4proc.c   | 5 +++--
 3 files changed, 5 insertions(+), 2 deletions(-)

-- 
1.9.3


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2014-06-23 13:55 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-13 18:18 [PATCH RFC] nfs: ensure cached data is correct before using delegation Scott Mayhew
2014-06-13 18:18 ` Scott Mayhew
2014-06-13 21:19   ` Trond Myklebust
2014-06-17 21:04     ` Scott Mayhew
2014-06-17 21:37       ` Trond Myklebust
2014-06-20 12:51         ` Scott Mayhew
2014-06-20 17:41           ` [PATCH 0/3] " Trond Myklebust
2014-06-20 17:41             ` [PATCH 1/3] NFS: Clear NFS_INO_REVAL_PAGECACHE when we update the file size Trond Myklebust
2014-06-20 17:41               ` [PATCH 2/3] NFS: Don't mark the data cache as invalid if it has been flushed Trond Myklebust
2014-06-20 17:41                 ` [PATCH 3/3] nfs: Fix cache_validity check in nfs_write_pageuptodate() Trond Myklebust
2014-06-23 13:55             ` [PATCH 0/3] nfs: ensure cached data is correct before using delegation Scott Mayhew

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox