From: Chuck Lever <chuck.lever@oracle.com>
To: linux-nfs@vger.kernel.org
Subject: [PATCH 15/21] NFS: Support NFS4ERR_LEASE_MOVED recovery in state manager
Date: Thu, 17 Oct 2013 14:13:35 -0400 [thread overview]
Message-ID: <20131017181335.1073.50738.stgit@nfsvm18.us.oracle.com> (raw)
In-Reply-To: <20131017180630.1073.18400.stgit@nfsvm18.us.oracle.com>
A migration on the FSID in play for the current NFS operation
is reported via the error status code NFS4ERR_MOVED.
"Lease moved" means that a migration has occurred on some other
FSID than the one for the current operation. It's a signal that
the client should take action immediately to handle a migration
that it may not have noticed otherwise. This is so that the
client's lease does not expire unnoticed on the destination server.
In NFSv4.0, a moved lease is reported with the NFS4ERR_LEASE_MOVED
error status code.
To recover from NFS4ERR_LEASE_MOVED, check each FSID for that server
to see if it is still present. Invoke nfs4_try_migration() if the
FSID is no longer present on the server.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
fs/nfs/nfs4_fs.h | 2 +
fs/nfs/nfs4state.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 74 insertions(+), 1 deletion(-)
diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h
index 2f0f8c2..210e44e 100644
--- a/fs/nfs/nfs4_fs.h
+++ b/fs/nfs/nfs4_fs.h
@@ -30,6 +30,7 @@ enum nfs4_client_state {
NFS4CLNT_PURGE_STATE,
NFS4CLNT_BIND_CONN_TO_SESSION,
NFS4CLNT_MOVED,
+ NFS4CLNT_LEASE_MOVED,
};
#define NFS4_RENEW_TIMEOUT 0x01
@@ -425,6 +426,7 @@ extern void nfs4_schedule_state_manager(struct nfs_client *);
extern void nfs4_schedule_path_down_recovery(struct nfs_client *clp);
extern int nfs4_schedule_stateid_recovery(const struct nfs_server *, struct nfs4_state *);
extern int nfs4_schedule_migration_recovery(const struct nfs_server *);
+extern void nfs4_schedule_lease_moved_recovery(struct nfs_client *);
extern void nfs41_handle_sequence_flag_errors(struct nfs_client *clp, u32 flags);
extern void nfs41_handle_server_scope(struct nfs_client *,
struct nfs41_server_scope **);
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
index b66163f..3fbce1f 100644
--- a/fs/nfs/nfs4state.c
+++ b/fs/nfs/nfs4state.c
@@ -1233,6 +1233,22 @@ int nfs4_schedule_migration_recovery(const struct nfs_server *server)
}
EXPORT_SYMBOL_GPL(nfs4_schedule_migration_recovery);
+/**
+ * nfs4_schedule_lease_moved_recovery - start lease-moved recovery
+ *
+ * @clp: server to check for moved leases
+ *
+ */
+void nfs4_schedule_lease_moved_recovery(struct nfs_client *clp)
+{
+ dprintk("%s: scheduling lease-moved recovery for client ID %llx on %s\n",
+ __func__, clp->cl_clientid, clp->cl_hostname);
+
+ set_bit(NFS4CLNT_LEASE_MOVED, &clp->cl_state);
+ nfs4_schedule_state_manager(clp);
+}
+EXPORT_SYMBOL_GPL(nfs4_schedule_lease_moved_recovery);
+
int nfs4_wait_clnt_recover(struct nfs_client *clp)
{
int res;
@@ -1664,7 +1680,6 @@ static int nfs4_recovery_handle_error(struct nfs_client *clp, int error)
nfs4_state_end_reclaim_reboot(clp);
break;
case -NFS4ERR_STALE_CLIENTID:
- case -NFS4ERR_LEASE_MOVED:
set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state);
nfs4_state_clear_reclaim_reboot(clp);
nfs4_state_start_reclaim_reboot(clp);
@@ -1978,6 +1993,55 @@ restart:
return 0;
}
+/*
+ * Test each nfs_server on the clp's cl_superblocks list to see
+ * if it's moved to another server. Stop when the server no longer
+ * returns NFS4ERR_LEASE_MOVED.
+ */
+static int nfs4_handle_lease_moved(struct nfs_client *clp)
+{
+ const struct nfs4_state_maintenance_ops *ops =
+ clp->cl_mvops->state_renewal_ops;
+ struct nfs_server *server;
+ struct rpc_cred *cred;
+
+ dprintk("%s: lease moved reported on \"%s\"\n", __func__,
+ clp->cl_hostname);
+
+ spin_lock(&clp->cl_lock);
+ cred = ops->get_state_renewal_cred_locked(clp);
+ spin_unlock(&clp->cl_lock);
+ if (cred == NULL)
+ return -NFS4ERR_NOENT;
+
+ clp->cl_mig_gen++;
+restart:
+ rcu_read_lock();
+ list_for_each_entry_rcu(server, &clp->cl_superblocks, client_link) {
+ struct inode *inode;
+ int status;
+
+ if (server->mig_gen == clp->cl_mig_gen)
+ continue;
+ server->mig_gen = clp->cl_mig_gen;
+
+ rcu_read_unlock();
+
+ inode = server->super->s_root->d_inode;
+ status = nfs4_proc_fsid_present(inode, cred);
+ if (status != -NFS4ERR_MOVED)
+ goto restart; /* wasn't this one */
+ if (nfs4_try_migration(server, cred) == -NFS4ERR_LEASE_MOVED)
+ goto restart; /* there are more */
+ goto out;
+ }
+ rcu_read_unlock();
+
+out:
+ put_rpccred(cred);
+ return 0;
+}
+
/**
* nfs4_discover_server_trunking - Detect server IP address trunking
*
@@ -2315,6 +2379,13 @@ static void nfs4_state_manager(struct nfs_client *clp)
goto out_error;
}
+ if (test_and_clear_bit(NFS4CLNT_LEASE_MOVED, &clp->cl_state)) {
+ section = "lease moved";
+ status = nfs4_handle_lease_moved(clp);
+ if (status < 0)
+ goto out_error;
+ }
+
/* First recover reboot state... */
if (test_bit(NFS4CLNT_RECLAIM_REBOOT, &clp->cl_state)) {
section = "reclaim reboot";
next prev parent reply other threads:[~2013-10-17 18:13 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-17 18:12 [PATCH 00/21] Basic NFSv4 migration support Chuck Lever
2013-10-17 18:12 ` [PATCH 01/21] SUNRPC: Modify synopsis of rpc_client_register() Chuck Lever
2013-10-17 18:12 ` [PATCH 02/21] SUNRPC: Add a helper to switch the transport of an rpc_clnt Chuck Lever
2013-10-17 18:12 ` [PATCH 03/21] NFS: Add nfs4_update_server Chuck Lever
2013-10-17 18:12 ` [PATCH 04/21] NFS: Add functions to swap transports during migration recovery Chuck Lever
2013-10-17 18:12 ` [PATCH 05/21] NFS: Introduce a vector of migration recovery ops Chuck Lever
2013-10-17 18:12 ` [PATCH 06/21] NFS: Export _nfs_display_fhandle() Chuck Lever
2013-10-17 18:12 ` [PATCH 07/21] NFS: Add method to retrieve fs_locations during migration recovery Chuck Lever
2013-10-17 18:12 ` [PATCH 08/21] NFS: Add a super_block backpointer to the nfs_server struct Chuck Lever
2013-10-17 18:13 ` [PATCH 09/21] NFS: Add basic migration support to state manager thread Chuck Lever
2013-10-17 18:13 ` [PATCH 10/21] NFS: Re-use exit code in nfs4_async_handle_error() Chuck Lever
2013-10-17 18:13 ` [PATCH 11/21] NFS: Rename "stateid_invalid" label Chuck Lever
2013-10-17 18:13 ` [PATCH 12/21] NFS: Add migration recovery callouts in nfs4proc.c Chuck Lever
2013-10-17 18:13 ` [PATCH 13/21] NFS: Handle NFS4ERR_MOVED during delegation recall Chuck Lever
2013-10-17 18:13 ` [PATCH 14/21] NFS: Add method to detect whether an FSID is still on the server Chuck Lever
2013-10-17 18:13 ` Chuck Lever [this message]
2013-10-17 18:13 ` [PATCH 16/21] NFS: Implement support for NFS4ERR_LEASE_MOVED Chuck Lever
2013-10-17 18:13 ` [PATCH 17/21] NFS: Migration support for RELEASE_LOCKOWNER Chuck Lever
2013-10-17 18:13 ` [PATCH 18/21] NFS: Handle NFS4ERR_LEASE_MOVED during async RENEW Chuck Lever
2013-10-17 18:13 ` [PATCH 19/21] NFS: Handle SEQ4_STATUS_LEASE_MOVED Chuck Lever
2013-10-17 18:14 ` [PATCH 20/21] NFS: Set EXCHGID4_FLAG_SUPP_MOVED_MIGR Chuck Lever
2013-10-17 18:14 ` [PATCH 21/21] NFS: Fix possible endless state recovery wait Chuck Lever
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=20131017181335.1073.50738.stgit@nfsvm18.us.oracle.com \
--to=chuck.lever@oracle.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).