linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "J. Bruce Fields" <bfields@redhat.com>
To: linux-nfs@vger.kernel.org
Cc: "J. Bruce Fields" <bfields@redhat.com>
Subject: [PATCH 08/11] nfsd4: allow removing clients not holding state
Date: Wed, 16 May 2012 08:48:36 -0400	[thread overview]
Message-ID: <1337172519-17335-9-git-send-email-bfields@redhat.com> (raw)
In-Reply-To: <1337172519-17335-1-git-send-email-bfields@redhat.com>

From: "J. Bruce Fields" <bfields@redhat.com>

RFC 5661 actually says we should allow an exchange_id to remove a
matching client, even if the exchange_id comes from a different
principal, *if* the victim client lacks any state.

Signed-off-by: J. Bruce Fields <bfields@redhat.com>
---
 fs/nfsd/nfs4state.c |   21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 0c553af..e7f61d3 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -1471,6 +1471,19 @@ nfsd4_set_ex_flags(struct nfs4_client *new, struct nfsd4_exchange_id *clid)
 	clid->flags = new->cl_exchange_flags;
 }
 
+static bool client_has_state(struct nfs4_client *clp)
+{
+	/*
+	 * Note clp->cl_openowners check isn't quite right: there's no
+	 * need to count owners without stateid's.
+	 *
+	 * Also note we should probably be using this in 4.0 case too.
+	 */
+	return list_empty(&clp->cl_openowners)
+		&& list_empty(&clp->cl_delegations)
+		&& list_empty(&clp->cl_sessions);
+}
+
 __be32
 nfsd4_exchange_id(struct svc_rqst *rqstp,
 		  struct nfsd4_compound_state *cstate,
@@ -1539,8 +1552,11 @@ nfsd4_exchange_id(struct svc_rqst *rqstp,
 			goto out_copy;
 		}
 		if (!creds_match) { /* case 3 */
-			status = nfserr_clid_inuse;
-			goto out;
+			if (client_has_state(conf)) {
+				status = nfserr_clid_inuse;
+				goto out;
+			}
+			goto expire_client;
 		}
 		if (verfs_match) { /* case 2 */
 			exid->flags |= EXCHGID4_FLAG_CONFIRMED_R;
@@ -1548,6 +1564,7 @@ nfsd4_exchange_id(struct svc_rqst *rqstp,
 			goto out_copy;
 		}
 		/* case 5, client reboot */
+expire_client:
 		expire_client(conf);
 		goto out_new;
 	}
-- 
1.7.9.5


  parent reply	other threads:[~2012-05-16 12:48 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-16 12:48 exchange_id changes for 3.5 J. Bruce Fields
2012-05-16 12:48 ` [PATCH 01/11] nfsd4: exchange_id has a pointless copy J. Bruce Fields
2012-05-16 12:48 ` [PATCH 02/11] nfsd4: exchange_id error cleanup J. Bruce Fields
2012-05-16 12:48 ` [PATCH 03/11] nfsd4: exchange_id: check creds before killing confirmed client J. Bruce Fields
2012-05-16 12:48 ` [PATCH 04/11] nfsd4: allow an EXCHANGE_ID to kill a 4.0 client J. Bruce Fields
2012-05-16 12:48 ` [PATCH 05/11] nfsd4: exchange_id cleanup: local shorthands for repeated tests J. Bruce Fields
2012-05-16 12:48 ` [PATCH 06/11] nfsd4: exchange_id cleanup: comments J. Bruce Fields
2012-05-16 12:48 ` [PATCH 07/11] nfsd4: rearrange exchange_id logic to simplify J. Bruce Fields
2012-05-16 12:48 ` J. Bruce Fields [this message]
2012-05-16 12:48 ` [PATCH 09/11] nfsd4: move principal name into svc_cred J. Bruce Fields
2012-05-16 12:48 ` [PATCH 10/11] nfsd4: stricter cred comparison for setclientid/exchange_id J. Bruce Fields
2012-05-16 12:48 ` [PATCH 11/11] nfsd4: move rq_flavor into svc_cred 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=1337172519-17335-9-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).