From: "J. Bruce Fields" <bfields@redhat.com>
To: linux-nfs@vger.kernel.org
Cc: "J. Bruce Fields" <bfields@redhat.com>
Subject: [PATCH 09/10] nfsd4: simpler ordering of setclientid_confirm checks
Date: Wed, 23 May 2012 17:40:39 -0400 [thread overview]
Message-ID: <1337809240-15770-10-git-send-email-bfields@redhat.com> (raw)
In-Reply-To: <1337809240-15770-1-git-send-email-bfields@redhat.com>
From: "J. Bruce Fields" <bfields@redhat.com>
The cases here divide into two main categories:
- if there's an uncomfirmed record with a matching verifier,
then this is a "normal", succesful case: we're either creating
a new client, or updating an existing one.
- otherwise, this is a weird case: a replay, or a server reboot.
Reordering to reflect that makes the code a bit more concise and the
logic a lot easier to understand.
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
---
fs/nfsd/nfs4state.c | 24 +++++++++++-------------
1 file changed, 11 insertions(+), 13 deletions(-)
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index e8e3ce0..72bc277 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -2245,18 +2245,21 @@ nfsd4_setclientid_confirm(struct svc_rqst *rqstp,
if (conf && !same_creds(&conf->cl_cred, &rqstp->rq_cred))
goto out;
/* cases below refer to rfc 3530 section 14.2.34: */
- if (conf && unconf && same_verf(&confirm, &unconf->cl_confirm)) {
- /* case 1: callback update */
+ if (!unconf || !same_verf(&confirm, &unconf->cl_confirm)) {
+ if (conf && !unconf) /* case 2: probable retransmit */
+ status = nfs_ok;
+ else /* case 4: client hasn't noticed we rebooted yet? */
+ status = nfserr_stale_clientid;
+ goto out;
+ }
+ status = nfs_ok;
+ if (conf) { /* case 1: callback update */
nfsd4_change_callback(conf, &unconf->cl_cb_conn);
nfsd4_probe_callback(conf);
expire_client(unconf);
- status = nfs_ok;
- } else if (conf && !unconf) {
- status = nfs_ok;
- } else if (!conf && unconf
- && same_verf(&unconf->cl_confirm, &confirm)) {
- /* case 3: normal case; new or rebooted client */
+ } else { /* case 3: normal case; new or rebooted client */
unsigned int hash = clientstr_hashval(unconf->cl_recdir);
+
conf = find_confirmed_client_by_str(unconf->cl_recdir, hash);
if (conf) {
nfsd4_client_record_remove(conf);
@@ -2264,11 +2267,6 @@ nfsd4_setclientid_confirm(struct svc_rqst *rqstp,
}
move_to_confirmed(unconf);
nfsd4_probe_callback(unconf);
- status = nfs_ok;
- } else if ((!conf || !same_verf(&conf->cl_confirm, &confirm))
- && (!unconf || !same_verf(&unconf->cl_confirm, &confirm))) {
- /* case 4: client hasn't noticed we rebooted yet? */
- status = nfserr_stale_clientid;
}
out:
nfs4_unlock_state();
--
1.7.9.5
next prev parent reply other threads:[~2012-05-23 21:40 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-23 21:40 mainly setclientid/confirm cleanup J. Bruce Fields
2012-05-23 21:40 ` [PATCH 01/10] nfsd4: setclientid remove unnecessary terms from a logical expression J. Bruce Fields
2012-05-23 21:40 ` [PATCH 02/10] nfsd4: setclientid/confirm comment cleanup J. Bruce Fields
2012-05-23 21:40 ` [PATCH 03/10] nfsd4: merge last two setclientid cases J. Bruce Fields
2012-05-23 21:40 ` [PATCH 04/10] nfsd4: pull out common code from " J. Bruce Fields
2012-05-23 21:40 ` [PATCH 05/10] nfsd4: merge 3 setclientid cases to 2 J. Bruce Fields
2012-05-23 21:40 ` [PATCH 06/10] nfsd4: fix setclientid_confirm same_cred check J. Bruce Fields
2012-05-23 21:40 ` [PATCH 07/10] nfsd4: fix error return in non-matching-creds case J. Bruce Fields
2012-05-23 21:40 ` [PATCH 08/10] nfsd4: setclientid: remove pointless assignment J. Bruce Fields
2012-05-23 21:40 ` J. Bruce Fields [this message]
2012-05-23 21:40 ` [PATCH 10/10] nfsd4: clarify that renewing expired client is a bug J. Bruce Fields
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=1337809240-15770-10-git-send-email-bfields@redhat.com \
--to=bfields@redhat.com \
--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;
as well as URLs for NNTP newsgroup(s).