All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chuck Lever <chuck.lever@oracle.com>
To: Trond.Myklebust@netapp.com
Cc: linux-nfs@vger.kernel.org
Subject: [PATCH 09/20] NFS: Force server to drop NFSv4 state
Date: Mon, 23 Apr 2012 16:54:28 -0400	[thread overview]
Message-ID: <20120423205427.11446.1552.stgit@degas.1015granger.net> (raw)
In-Reply-To: <20120423205312.11446.67081.stgit@degas.1015granger.net>

A SETCLIENTID boot verifier is nothing more than a boot timestamp.
An NFSv4 server is obligated to wipe all NFSv4 state for an NFS client
when the client presents an updated SETCLIENTID boot verifier.  This
is how servers detect client reboots.

nfs4_reset_all_state() forces a boot verifier refresh to cause a
server to wipe state as part of recovering from a server reporting
that it has revoked some or all of a client's NFSv4 state.  This wipes
the slate for full state recovery.

Soon we want to get rid of the per-nfs_client cl_boot_time field,
however.  Without cl_boot_time, the NFS client will need to find a
different way to force the server to purge the client's NFSv4 state.

Because these verifiers are opaque (ie, the server doesn't know or
care that they are timestamps), we can do this by using the same
trick we use now, but then afterwards establish a fresh client ID
using the old boot verifier again.

Hopefully there are no extra paranoid server implementations that keep
track of the client's boot verifiers and prevent clients from reusing
a previous one.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---

 fs/nfs/nfs4_fs.h   |    1 +
 fs/nfs/nfs4proc.c  |    9 +++++++--
 fs/nfs/nfs4state.c |    7 ++++++-
 3 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h
index d8c2d39..2953f2c 100644
--- a/fs/nfs/nfs4_fs.h
+++ b/fs/nfs/nfs4_fs.h
@@ -24,6 +24,7 @@ enum nfs4_client_state {
 	NFS4CLNT_RECALL_SLOT,
 	NFS4CLNT_LEASE_CONFIRM,
 	NFS4CLNT_SERVER_SCOPE_MISMATCH,
+	NFS4CLNT_PURGE_STATE,
 };
 
 enum nfs4_session_state {
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 84a26d9..b19cf81 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -3878,8 +3878,13 @@ static void nfs4_construct_boot_verifier(struct nfs_client *clp,
 {
 	__be32 verf[2];
 
-	verf[0] = (__be32)clp->cl_boot_time.tv_sec;
-	verf[1] = (__be32)clp->cl_boot_time.tv_nsec;
+	if (test_bit(NFS4CLNT_PURGE_STATE, &clp->cl_state)) {
+		verf[0] = (__be32)CURRENT_TIME.tv_sec;
+		verf[1] = (__be32)CURRENT_TIME.tv_nsec;
+	} else {
+		verf[0] = (__be32)clp->cl_boot_time.tv_sec;
+		verf[1] = (__be32)clp->cl_boot_time.tv_nsec;
+	}
 	memcpy(bootverf->data, verf, sizeof(bootverf->data));
 }
 
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
index cbef366..7f56502 100644
--- a/fs/nfs/nfs4state.c
+++ b/fs/nfs/nfs4state.c
@@ -1612,7 +1612,7 @@ void nfs41_handle_recall_slot(struct nfs_client *clp)
 static void nfs4_reset_all_state(struct nfs_client *clp)
 {
 	if (test_and_set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state) == 0) {
-		clp->cl_boot_time = CURRENT_TIME;
+		set_bit(NFS4CLNT_PURGE_STATE, &clp->cl_state);
 		nfs4_state_start_reclaim_nograce(clp);
 		nfs4_schedule_state_manager(clp);
 	}
@@ -1759,6 +1759,11 @@ static void nfs4_state_manager(struct nfs_client *clp)
 
 	/* Ensure exclusive access to NFSv4 state */
 	do {
+		if (test_bit(NFS4CLNT_PURGE_STATE, &clp->cl_state)) {
+			nfs4_reclaim_lease(clp);
+			clear_bit(NFS4CLNT_PURGE_STATE, &clp->cl_state);
+		}
+
 		if (test_and_clear_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state)) {
 			/* We're going to have to re-establish a clientid */
 			status = nfs4_reclaim_lease(clp);


  parent reply	other threads:[~2012-04-23 20:54 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-23 20:53 [PATCH 01/20] NFS: Fix comment misspelling in struct nfs_client definition Chuck Lever
2012-04-23 20:53 ` [PATCH 02/20] NFS: Use proper naming conventions for NFSv4.1 server scope fields Chuck Lever
2012-04-23 20:53 ` [PATCH 03/20] NFS: Use proper naming conventions for nfs_client.impl_id field Chuck Lever
2012-04-23 20:53 ` [PATCH 04/20] NFS: Use proper naming conventions for the nfs_client.net field Chuck Lever
2012-04-23 20:53 ` [PATCH 05/20] NFS: Clean up return code checking in nfs4_proc_exchange_id() Chuck Lever
2012-04-23 21:07   ` Myklebust, Trond
2012-04-23 20:54 ` [PATCH 06/20] NFS: Remove nfs_unique_id Chuck Lever
2012-04-23 20:54 ` [PATCH 07/20] NFS: Don't swap bytes in nfs4_construct_boot_verifier() Chuck Lever
2012-04-23 20:54 ` [PATCH 08/20] NFS: Fix NFSv4 BAD_SEQID recovery Chuck Lever
2012-04-23 20:54 ` Chuck Lever [this message]
2012-04-23 21:13   ` [PATCH 09/20] NFS: Force server to drop NFSv4 state Myklebust, Trond
2012-04-23 21:18     ` Chuck Lever
2012-04-23 20:54 ` [PATCH 10/20] NFS: Always use the same SETCLIENTID boot verifier Chuck Lever
2012-04-23 20:54 ` [PATCH 11/20] NFS: Refactor nfs_get_client(): add nfs_found_client() Chuck Lever
2012-04-23 20:54 ` [PATCH 12/20] NFS: Refactor nfs_get_client(): initialize nfs_client Chuck Lever
2012-04-23 20:55 ` [PATCH 13/20] NFS: Fix recovery from NFS4ERR_CLID_INUSE Chuck Lever
2012-04-26 16:24   ` Chuck Lever
2012-04-26 16:55     ` Myklebust, Trond
2012-04-26 18:43       ` Chuck Lever
2012-04-26 18:53         ` Myklebust, Trond
2012-04-26 18:57           ` Myklebust, Trond
2012-04-26 19:04           ` Chuck Lever
2012-04-26 19:14             ` Myklebust, Trond
2012-04-26 19:46               ` Chuck Lever
2012-04-26 19:57                 ` Myklebust, Trond
2012-04-23 20:55 ` [PATCH 14/20] NFS: Add nfs_client behavior flags Chuck Lever
2012-04-23 20:55 ` [PATCH 15/20] NFS: Introduce "migration" mount option Chuck Lever
2012-04-23 20:55 ` [PATCH 16/20] NFS: Use the same nfs_client_id4 for every server Chuck Lever
2012-04-23 20:55 ` [PATCH 17/20] NFS: EXCHANGE_ID should save the server major and minor ID Chuck Lever
2012-04-23 20:55 ` [PATCH 18/20] NFS: Detect NFSv4 server trunking when mounting Chuck Lever
2012-04-23 21:27   ` Myklebust, Trond
2012-04-23 21:43     ` Chuck Lever
2012-04-23 21:47     ` Chuck Lever
2012-04-23 21:56       ` Myklebust, Trond
2012-04-23 20:56 ` [PATCH 19/20] NFS: Add nfs4_unique_id boot parameter Chuck Lever
2012-04-23 20:56 ` [PATCH 20/20] NFS: Clean up debugging messages in fs/nfs/client.c Chuck Lever
2012-04-23 21:23   ` Malahal Naineni

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=20120423205427.11446.1552.stgit@degas.1015granger.net \
    --to=chuck.lever@oracle.com \
    --cc=Trond.Myklebust@netapp.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.