From: Scott Mayhew <smayhew@redhat.com>
To: trond.myklebust@primarydata.com
Cc: linux-nfs@vger.kernel.org
Subject: [PATCH RFC] nfs: ensure cached data is correct before using delegation
Date: Fri, 13 Jun 2014 14:18:07 -0400 [thread overview]
Message-ID: <1402683488-23725-1-git-send-email-smayhew@redhat.com> (raw)
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
next reply other threads:[~2014-06-13 18:18 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-13 18:18 Scott Mayhew [this message]
2014-06-13 18:18 ` [PATCH RFC] nfs: ensure cached data is correct before using delegation 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1402683488-23725-1-git-send-email-smayhew@redhat.com \
--to=smayhew@redhat.com \
--cc=linux-nfs@vger.kernel.org \
--cc=trond.myklebust@primarydata.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox