From: Trond Myklebust <trond.myklebust@primarydata.com>
To: Olga Kornievskaia <aglo@umich.edu>
Cc: linux-nfs <linux-nfs@vger.kernel.org>
Subject: [PATCH 1/2] NFSv4: Deal with atomic upgrades of an existing delegation
Date: Fri, 19 Dec 2014 13:10:40 -0500 [thread overview]
Message-ID: <1419012641-8564-1-git-send-email-trond.myklebust@primarydata.com> (raw)
In-Reply-To: <CAN-5tyHAckqJoAbD02rmW1jRiGDK_4_oDvm8eDosZwvd_jc3CQ@mail.gmail.com>
Ensure that we deal correctly with the case where the server sends us a
newer instance of the same delegation. If the stateids match, but the
sequence numbers differ, then treat the new delegation as if it were
an atomic upgrade.
Signed-off-by: Trond Myklebust <Trond.Myklebust@primarydata.com>
---
fs/nfs/delegation.c | 20 +++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-)
diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c
index 7f3f60641344..90413cdbf254 100644
--- a/fs/nfs/delegation.c
+++ b/fs/nfs/delegation.c
@@ -301,6 +301,18 @@ nfs_inode_detach_delegation(struct inode *inode)
return nfs_detach_delegation(nfsi, delegation, server);
}
+static void
+nfs_update_inplace_delegation(struct nfs_delegation *delegation,
+ struct nfs_delegation *update)
+{
+ if (nfs4_stateid_is_newer(&update->stateid, &delegation->stateid))
+ return;
+ delegation->stateid.seqid = update->stateid.seqid;
+ smp_wmb();
+ delegation->type == update->type;
+ nfsi->delegation_state = update->type;
+}
+
/**
* nfs_inode_set_delegation - set up a delegation on an inode
* @inode: inode to which delegation applies
@@ -334,9 +346,11 @@ int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred, struct
old_delegation = rcu_dereference_protected(nfsi->delegation,
lockdep_is_held(&clp->cl_lock));
if (old_delegation != NULL) {
- if (nfs4_stateid_match(&delegation->stateid,
- &old_delegation->stateid) &&
- delegation->type == old_delegation->type) {
+ /* Is this an update of the existing delegation? */
+ if (nfs4_stateid_match_other(&old_delegation->stateid,
+ &delegation->stateid)) {
+ nfs_update_inplace_delegation(old_delegation,
+ delegation);
goto out;
}
/*
--
2.1.0
next prev parent reply other threads:[~2014-12-19 18:11 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-19 15:11 question about code in delegation.c Olga Kornievskaia
2014-12-19 15:37 ` Trond Myklebust
2014-12-19 16:01 ` Olga Kornievskaia
2014-12-19 18:10 ` Trond Myklebust [this message]
2014-12-19 18:51 ` [PATCH 1/2] NFSv4: Deal with atomic upgrades of an existing delegation Trond Myklebust
2014-12-19 18:52 ` [PATCH v2 " Trond Myklebust
2014-12-19 20:16 ` Olga Kornievskaia
2014-12-19 20:31 ` Trond Myklebust
2014-12-19 20:39 ` Olga Kornievskaia
2014-12-19 20:46 ` Trond Myklebust
2014-12-19 20:44 ` [PATCH v3 " Trond Myklebust
2014-12-19 20:44 ` [PATCH v3 2/2] NFSv4: Remove incorrect check in can_open_delegated() Trond Myklebust
2015-08-18 20:38 ` Olga Kornievskaia
2015-08-18 21:07 ` Trond Myklebust
2015-08-18 21:13 ` Olga Kornievskaia
2015-08-18 21:18 ` Trond Myklebust
2014-12-19 18:52 ` [PATCH v2 " Trond Myklebust
2014-12-19 18:10 ` [PATCH " Trond Myklebust
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=1419012641-8564-1-git-send-email-trond.myklebust@primarydata.com \
--to=trond.myklebust@primarydata.com \
--cc=aglo@umich.edu \
--cc=linux-nfs@vger.kernel.org \
/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