Skip to contentSkip to conversation

NFSv4 migration

PATCH In review Chuck Lever 2 participants 31 messages Jul 12, 2013 – Jul 24, 2013

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover NFSv4 migration

I hope to get basic NFSv4 migration support into 3.12. This is the patch series, still based on 3.10, posted here for review. See also

  http://git.linux-nfs.org/?p=cel/cel-2.6.git;a=commit;
	h=8aa9aa847fdd073abe24789c5acb28b853755616

- Patch roadmap -

The first two patches are bug fixes.

Patches "NFS: Refactor nfs4_call_data_sequence()" through "NFS:
Implement a transport blocking scheme for migration" introduce a mechanism that can plug and uncork an NFS transport. NFSv4.0 migration uses this mechanism to block forward NFS operations while migration recovery is occurring. NFSv4.1 and following will use session draining to accomplish the same.

Patch "NFS: Add functions to swap transports during migration recovery" moves an nfs_server from one nfs_client to another, and swaps out the nfs_server's RPC transport at the same time. This mechanism probably still needs some work.

Patches "NFS: Add method to retrieve fs_locations during migration recovery" through "NFS: Add migration recovery callouts in nfs4proc.c" add the bulk of support for recovering from NFS4ERR_MOVED.

Patches "NFS: Add method to detect whether an FSID is still on the server" through "NFS: Implement support for NFS4ERR_LEASE_MOVED" add support for recovering from NFS4ERR_LEASE_MOVED.

Patch "NFS: Set EXCHGID4_FLAG_SUPP_MOVED_MIGR" advertises migration support for NFSv4.1.

- Merge criteria -

I have three criteria for determining whether I believe this work is ready to merge:

1. The series doesn't regress any non-migration related functionality

2. Everyone is happy with the architecture and APIs, such that subsequent patches will amount to bug fixes and enhancements rather than reworking anything

3. The series is ported to the tip of Linus' master (3.11-rc1 as of this writing)

I'd like to merge sooner rather than later so others can start to build on this functionality, and so I don't have to keep forward porting for another two years.

In addition, this is something that distributions want yesterday. Including it now and then fixing it makes it easier for them to include it in their kernels.

I expect bug fixes and enhancements after merge. Enhancements might include:

Optimize LEASE_MOVED recovery by performing the fsid_present checks asynchronously

Introduce support for fs_locations_info

Finish NFSv4.1 migration support

One thing that hasn't been tested yet is NFSv4.1 migration. There are no server implementations yet, and we believe there may be some (IETF) protocol work to do to get NFSv4.1 migration working reliably.

We could drop that patch, or we could change it to add a CONFIG option, default N, marked EXPERIMENTAL so that the flag can be enabled conveniently for testing.

- Test plan -

This implementation still needs a lot of testing. I've done some of this list, plan to do more.

* Single filesystem migration with TSM
* Single filesystem migration without TSM
* Active filesystem A while B is migrated (lease-moved recovery)
* Active filesystem A while active filesystem B is migrated
* Migrate filesystem A, reboot destination server, migrate B
* Migration during lock-intensive workload
* What happens when migration recovery fails?
* How about migration with a Kerberos 5 mount?

---

Chuck Lever (18):
NFS: Never use user credentials for lease renewal
NFS: Fix return type of nfs4_end_drain_session() stub
NFS: Introduce a vector of migration recovery ops
NFS: Refactor nfs4_call_data_sequence()
NFS: Rename nfs41_call_sync_data as a common data structure
NFS: Clean up nfs4_setup_sequence()
NFS: Fix compiler warning in nfs_setup_sequence()
NFS: Use RPC callouts to start NFSv4.0 synchronous requests
NFS: Add a "struct nfs_server *" argument to nfs4_sequence_done()
NFS: Implement a transport blocking scheme for migration
NFS: Add a super_block backpointer to the nfs_server struct
NFS: Add functions to swap transports during migration recovery
NFS: Add method to retrieve fs_locations during migration recovery
NFS: Add basic migration support to state manager thread
NFS: Add migration recovery callouts in nfs4proc.c
NFS: Add method to detect whether an FSID is still on the server
NFS: Implement support for NFS4ERR_LEASE_MOVED
NFS: Set EXCHGID4_FLAG_SUPP_MOVED_MIGR

Trond Myklebust (1):
SUNRPC: Add a helper to switch the transport of an rpc_clnt

 fs/nfs/client.c             |    3 
 fs/nfs/internal.h           |    3 
 fs/nfs/nfs4_fs.h            |   36 +--
 fs/nfs/nfs4client.c         |   83 ++++++
 fs/nfs/nfs4namespace.c      |  114 +++++++++
 fs/nfs/nfs4proc.c           |  554 +++++++++++++++++++++++++++++++++++++------
 fs/nfs/nfs4session.c        |    2 
 fs/nfs/nfs4state.c          |  318 +++++++++++++++++++++----
 fs/nfs/nfs4xdr.c            |  115 ++++++++-
 fs/nfs/super.c              |    1 
 include/linux/nfs4.h        |    1 
 include/linux/nfs_fs_sb.h   |   11 +
 include/linux/nfs_xdr.h     |   17 +
 include/linux/sunrpc/clnt.h |    4 
 net/sunrpc/clnt.c           |   83 ++++++
 15 files changed, 1183 insertions(+), 162 deletions(-)
Signature · 1 line
Chuck Lever
#1 lore raw

PATCH 1/19 NFS: Never use user credentials for lease renewal

Don't try to use a non-UID-0 user credential for lease management, as that credential can change out from under us. The server will block NFSv4 lease recovery with NFS4ERR_CLID_INUSE.

Replace minor version-specific callouts with a single function.

---
 fs/nfs/nfs4_fs.h     |    4 +---
 fs/nfs/nfs4proc.c    |    6 +----
 fs/nfs/nfs4session.c |    2 +-
 fs/nfs/nfs4state.c   |   55 ++++++--------------------------------------------
 4 files changed, 10 insertions(+), 57 deletions(-)
fs/nfs/nfs4_fs.h +1 -3
index a1dd768..3bc554e 100644
@@ -193,7 +193,6 @@ struct nfs4_state_recovery_ops {
 	int (*recover_open)(struct nfs4_state_owner *, struct nfs4_state *);
 	int (*recover_lock)(struct nfs4_state *, struct file_lock *);
 	int (*establish_clid)(struct nfs_client *, struct rpc_cred *);
-	struct rpc_cred * (*get_clid_cred)(struct nfs_client *);
 	int (*reclaim_complete)(struct nfs_client *);
 	int (*detect_trunking)(struct nfs_client *, struct nfs_client **,
 		struct rpc_cred *);
@@ -319,7 +318,7 @@ extern void nfs4_kill_renewd(struct nfs_client *);
 extern void nfs4_renew_state(struct work_struct *);
 
 /* nfs4state.c */
-struct rpc_cred *nfs4_get_setclientid_cred(struct nfs_client *clp);
+struct rpc_cred *nfs4_get_clid_cred(struct nfs_client *clp);
 struct rpc_cred *nfs4_get_machine_cred_locked(struct nfs_client *clp);
 struct rpc_cred *nfs4_get_renew_cred_locked(struct nfs_client *clp);
 int nfs4_discover_server_trunking(struct nfs_client *clp,
@@ -327,7 +326,6 @@ int nfs4_discover_server_trunking(struct nfs_client *clp,
 int nfs40_discover_server_trunking(struct nfs_client *clp,
 			struct nfs_client **, struct rpc_cred *);
 #if defined(CONFIG_NFS_V4_1)
-struct rpc_cred *nfs4_get_exchange_id_cred(struct nfs_client *clp);
 int nfs41_discover_server_trunking(struct nfs_client *clp,
 			struct nfs_client **, struct rpc_cred *);
 extern void nfs4_schedule_session_recovery(struct nfs4_session *, int);
fs/nfs/nfs4proc.c +1 -5
index d7ba561..d74a2b5 100644
@@ -5643,7 +5643,7 @@ int nfs4_destroy_clientid(struct nfs_client *clp)
 		goto out;
 	if (clp->cl_preserve_clid)
 		goto out;
-	cred = nfs4_get_exchange_id_cred(clp);
+	cred = nfs4_get_clid_cred(clp);
 	ret = nfs4_proc_destroy_clientid(clp, cred);
 	if (cred)
 		put_rpccred(cred);
@@ -6919,7 +6919,6 @@ static const struct nfs4_state_recovery_ops nfs40_reboot_recovery_ops = {
 	.recover_open	= nfs4_open_reclaim,
 	.recover_lock	= nfs4_lock_reclaim,
 	.establish_clid = nfs4_init_clientid,
-	.get_clid_cred	= nfs4_get_setclientid_cred,
 	.detect_trunking = nfs40_discover_server_trunking,
 };
 
@@ -6930,7 +6929,6 @@ static const struct nfs4_state_recovery_ops nfs41_reboot_recovery_ops = {
 	.recover_open	= nfs4_open_reclaim,
 	.recover_lock	= nfs4_lock_reclaim,
 	.establish_clid = nfs41_init_clientid,
-	.get_clid_cred	= nfs4_get_exchange_id_cred,
 	.reclaim_complete = nfs41_proc_reclaim_complete,
 	.detect_trunking = nfs41_discover_server_trunking,
 };
@@ -6942,7 +6940,6 @@ static const struct nfs4_state_recovery_ops nfs40_nograce_recovery_ops = {
 	.recover_open	= nfs4_open_expired,
 	.recover_lock	= nfs4_lock_expired,
 	.establish_clid = nfs4_init_clientid,
-	.get_clid_cred	= nfs4_get_setclientid_cred,
 };
 
 #if defined(CONFIG_NFS_V4_1)
@@ -6952,7 +6949,6 @@ static const struct nfs4_state_recovery_ops nfs41_nograce_recovery_ops = {
 	.recover_open	= nfs41_open_expired,
 	.recover_lock	= nfs41_lock_expired,
 	.establish_clid = nfs41_init_clientid,
-	.get_clid_cred	= nfs4_get_exchange_id_cred,
 };
 #endif /* CONFIG_NFS_V4_1 */
 
fs/nfs/nfs4session.c +1 -1
index c4e225e..d35b816 100644
@@ -441,7 +441,7 @@ void nfs4_destroy_session(struct nfs4_session *session)
 	struct rpc_xprt *xprt;
 	struct rpc_cred *cred;
 
-	cred = nfs4_get_exchange_id_cred(session->clp);
+	cred = nfs4_get_clid_cred(session->clp);
 	nfs4_proc_destroy_session(session, cred);
 	if (cred)
 		put_rpccred(cred);
fs/nfs/nfs4state.c +7 -48

104 lines not on this page · raw message

#2 lore raw

Re: [PATCH v1 01/19] NFS: Never use user credentials for lease renewal

T24gRnJpLCAyMDEzLTA3LTEyIGF0IDEyOjMxIC0wNDAwLCBDaHVjayBMZXZlciB3cm90ZToNCj4g RG9uJ3QgdHJ5IHRvIHVzZSBhIG5vbi1VSUQtMCB1c2VyIGNyZWRlbnRpYWwgZm9yIGxlYXNlIG1h bmFnZW1lbnQsDQo+IGFzIHRoYXQgY3JlZGVudGlhbCBjYW4gY2hhbmdlIG91dCBmcm9tIHVuZGVy IHVzLiAgVGhlIHNlcnZlciB3aWxsDQo+IGJsb2NrIE5GU3Y0IGxlYXNlIHJlY292ZXJ5IHdpdGgg TkZTNEVSUl9DTElEX0lOVVNFLg0KPiANCj4gUmVwbGFjZSBtaW5vciB2ZXJzaW9uLXNwZWNpZmlj IGNhbGxvdXRzIHdpdGggYSBzaW5nbGUgZnVuY3Rpb24uDQo+IA0KPiBTaWduZWQtb2ZmLWJ5OiBD aHVjayBMZXZlciA8Y2h1Y2subGV2ZXJAb3JhY2xlLmNvbT4NCj4gLS0tDQo+ICBmcy9uZnMvbmZz NF9mcy5oICAgICB8ICAgIDQgKy0tLQ0KPiAgZnMvbmZzL25mczRwcm9jLmMgICAgfCAgICA2ICst LS0tDQo+ICBmcy9uZnMvbmZzNHNlc3Npb24uYyB8ICAgIDIgKy0NCj4gIGZzL25mcy9uZnM0c3Rh dGUuYyAgIHwgICA1NSArKysrKystLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLQ0KPiAgNCBmaWxlcyBjaGFuZ2VkLCAxMCBpbnNlcnRpb25zKCspLCA1NyBkZWxldGlv bnMoLSkNCg0KVGhpcyB3b24ndCBhcHBseSB0byB1cHN0cmVhbSBrZXJuZWxzLg0KDQotLSANClRy b25kIE15a2xlYnVzdA0KTGludXggTkZTIGNsaWVudCBtYWludGFpbmVyDQoNCk5ldEFwcA0KVHJv bmQuTXlrbGVidXN0QG5ldGFwcC5jb20NCnd3dy5uZXRhcHAuY29tDQo=

#3 lore raw

Re: [PATCH v1 01/19] NFS: Never use user credentials for lease renewal

Quoted 15 lines · Trond
Quoted 6 lines · Chuck Lever

Don't try to use a non-UID-0 user credential for lease management, as that credential can change out from under us. The server will block NFSv4 lease recovery with NFS4ERR_CLID_INUSE.

Replace minor version-specific callouts with a single function.

Quoted 7 lines

---

fs/nfs/nfs4_fs.h     |    4 +---
fs/nfs/nfs4proc.c    |    6 +----
fs/nfs/nfs4session.c |    2 +-
fs/nfs/nfs4state.c   |   55 ++++++--------------------------------------------
4 files changed, 10 insertions(+), 57 deletions(-)
Quoted 1 line

This won't apply to upstream kernels.

Thanks for having a look... As the cover letter stated, this series applies to 3.10.

Now that 3.11-rc2 is available, I'm porting the series to the latest upstream, with appropriate adjustments for NFSv4.2 support. I hope to post the new series tomorrow or Wednesday.

Signature · 2 lines
Chuck Lever
chuck[dot]lever[at]oracle[dot]com
#4 lore raw

RE: [PATCH v1 01/19] NFS: Never use user credentials for lease renewal

Quoted 27 lines

-----Original Message-----
From: Chuck Lever [mailto:[email protected]]
Sent: Monday, July 22, 2013 2:52 PM
To: Myklebust, Trond
Cc: [email protected]
Subject: Re: [PATCH v1 01/19] NFS: Never use user credentials for lease renewal

Quoted 15 lines · Trond
Quoted 13 lines · Chuck Lever

Don't try to use a non-UID-0 user credential for lease management, as that credential can change out from under us. The server will block NFSv4 lease recovery with NFS4ERR_CLID_INUSE.

Replace minor version-specific callouts with a single function.

---

fs/nfs/nfs4_fs.h     |    4 +---
fs/nfs/nfs4proc.c    |    6 +----
fs/nfs/nfs4session.c |    2 +-
fs/nfs/nfs4state.c   |   55 ++++++--------------------------------------------
4 files changed, 10 insertions(+), 57 deletions(-)
Quoted 9 lines
Quoted 1 line

This won't apply to upstream kernels.

Thanks for having a look... As the cover letter stated, this series applies to 3.10.

Now that 3.11-rc2 is available, I'm porting the series to the latest upstream, with appropriate adjustments for NFSv4.2 support. I hope to post the new series tomorrow or Wednesday.

OK. Please note that I've already applied 02/19 as that seems to be unrelated to anything else.

Thanks
Trond

#5 lore raw

Re: [PATCH v1 01/19] NFS: Never use user credentials for lease renewal

Quoted 29 lines · Trond
Quoted 29 lines

-----Original Message-----
From: Chuck Lever [mailto:[email protected]]
Sent: Monday, July 22, 2013 2:52 PM
To: Myklebust, Trond
Cc: [email protected]
Subject: Re: [PATCH v1 01/19] NFS: Never use user credentials for lease renewal

Quoted 16 lines · Trond
Quoted 6 lines · Chuck Lever

Don't try to use a non-UID-0 user credential for lease management, as that credential can change out from under us. The server will block NFSv4 lease recovery with NFS4ERR_CLID_INUSE.

Replace minor version-specific callouts with a single function.

Quoted 7 lines

---

fs/nfs/nfs4_fs.h     |    4 +---
fs/nfs/nfs4proc.c    |    6 +----
fs/nfs/nfs4session.c |    2 +-
fs/nfs/nfs4state.c   |   55 ++++++--------------------------------------------
4 files changed, 10 insertions(+), 57 deletions(-)

This won't apply to upstream kernels.

Quoted 8 lines
Quoted 7 lines

Thanks for having a look... As the cover letter stated, this series applies to 3.10.

Now that 3.11-rc2 is available, I'm porting the series to the latest upstream, with appropriate adjustments for NFSv4.2 support. I hope to post the new series tomorrow or Wednesday.

OK. Please note that I've already applied 02/19 as that seems to be unrelated to anything else.

I'll drop 02/19 from my resend. Thanks.

Signature · 2 lines
Chuck Lever
chuck[dot]lever[at]oracle[dot]com
#6 lore raw

PATCH 2/19 NFS: Fix return type of nfs4_end_drain_session() stub

In reply to Chuck Lever

Clean up: when NFSv4.1 support is compiled out, nfs4_end_drain_session() becomes a stub. Make the synopsis of the stub match the synopsis of the real version of the function.

---
 fs/nfs/nfs4state.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfs/nfs4state.c +1 -1
index 15fde8c..71fc85d 100644
@@ -2087,7 +2087,7 @@ static int nfs4_bind_conn_to_session(struct nfs_client *clp)
 }
 #else /* CONFIG_NFS_V4_1 */
 static int nfs4_reset_session(struct nfs_client *clp) { return 0; }
-static int nfs4_end_drain_session(struct nfs_client *clp) { return 0; }
+static void nfs4_end_drain_session(struct nfs_client *clp) { }
 
 static int nfs4_bind_conn_to_session(struct nfs_client *clp)
 {
#7 lore raw

PATCH 3/19 NFS: Introduce a vector of migration recovery ops

In reply to Chuck Lever

The differences between minor version 0 and minor version 1 migration will be abstracted by the addition of a set of migration recovery ops.

---
 fs/nfs/nfs4_fs.h  |    4 ++++
 fs/nfs/nfs4proc.c |   10 ++++++++++
 2 files changed, 14 insertions(+)
fs/nfs/nfs4_fs.h +4 -0
index 3bc554e..40457e2 100644
@@ -52,6 +52,7 @@ struct nfs4_minor_version_ops {
 	const struct nfs4_state_recovery_ops *reboot_recovery_ops;
 	const struct nfs4_state_recovery_ops *nograce_recovery_ops;
 	const struct nfs4_state_maintenance_ops *state_renewal_ops;
+	const struct nfs4_mig_recovery_ops *mig_recovery_ops;
 };
 
 #define NFS_SEQID_CONFIRMED 1
@@ -204,6 +205,9 @@ struct nfs4_state_maintenance_ops {
 	int (*renew_lease)(struct nfs_client *, struct rpc_cred *);
 };
 
+struct nfs4_mig_recovery_ops {
+};
+
 extern const struct dentry_operations nfs4_dentry_operations;
 
 /* dir.c */
fs/nfs/nfs4proc.c +10 -0
index d74a2b5..2f6f3b9 100644
@@ -6966,6 +6966,14 @@ static const struct nfs4_state_maintenance_ops nfs41_state_renewal_ops = {
 };
 #endif
 
+static const struct nfs4_mig_recovery_ops nfs40_mig_recovery_ops = {
+};
+
+#if defined(CONFIG_NFS_V4_1)
+static const struct nfs4_mig_recovery_ops nfs41_mig_recovery_ops = {
+};
+#endif	/* CONFIG_NFS_V4_1 */
+
 static const struct nfs4_minor_version_ops nfs_v4_0_minor_ops = {
 	.minor_version = 0,
 	.init_caps = NFS_CAP_READDIRPLUS
@@ -6979,6 +6987,7 @@ static const struct nfs4_minor_version_ops nfs_v4_0_minor_ops = {
 	.reboot_recovery_ops = &nfs40_reboot_recovery_ops,
 	.nograce_recovery_ops = &nfs40_nograce_recovery_ops,
 	.state_renewal_ops = &nfs40_state_renewal_ops,
+	.mig_recovery_ops = &nfs40_mig_recovery_ops,
 };
 
 #if defined(CONFIG_NFS_V4_1)
@@ -6997,6 +7006,7 @@ static const struct nfs4_minor_version_ops nfs_v4_1_minor_ops = {
 	.reboot_recovery_ops = &nfs41_reboot_recovery_ops,
 	.nograce_recovery_ops = &nfs41_nograce_recovery_ops,
 	.state_renewal_ops = &nfs41_state_renewal_ops,
+	.mig_recovery_ops = &nfs41_mig_recovery_ops,
 };
 #endif
 
#8 lore raw

PATCH 4/19 NFS: Refactor nfs4_call_data_sequence()

In reply to Chuck Lever

Pull main logic out of nfs4_call_data_sequence() so it can eventually be shared with the NFSv4.0 call_sync path. The new helper function is left behind the NFSv4.1 CONFIG switch for now to keep compiler warning noise at a minimum.

---
 fs/nfs/nfs4proc.c |   28 ++++++++++++++++++----------
 1 file changed, 18 insertions(+), 10 deletions(-)
fs/nfs/nfs4proc.c +18 -10
index 2f6f3b9..e52d2b3 100644
@@ -393,6 +393,23 @@ static void renew_lease(const struct nfs_server *server, unsigned long timestamp
 
 #if defined(CONFIG_NFS_V4_1)
 
+static int nfs4_run_rpc_task(struct rpc_clnt *clnt,
+			     struct rpc_message *msg,
+			     struct rpc_task_setup *task_setup)
+{
+	struct rpc_task *task;
+	int ret;
+
+	task = rpc_run_task(task_setup);
+	if (IS_ERR(task))
+		ret = PTR_ERR(task);
+	else {
+		ret = task->tk_status;
+		rpc_put_task(task);
+	}
+	return ret;
+}
+
 static void nfs41_sequence_free_slot(struct nfs4_sequence_res *res)
 {
 	struct nfs4_session *session;
@@ -674,8 +691,6 @@ static int nfs4_call_sync_sequence(struct rpc_clnt *clnt,
 				   struct nfs4_sequence_args *args,
 				   struct nfs4_sequence_res *res)
 {
-	int ret;
-	struct rpc_task *task;
 	struct nfs41_call_sync_data data = {
 		.seq_server = server,
 		.seq_args = args,
@@ -688,14 +703,7 @@ static int nfs4_call_sync_sequence(struct rpc_clnt *clnt,
 		.callback_data = &data
 	};
 
-	task = rpc_run_task(&task_setup);
-	if (IS_ERR(task))
-		ret = PTR_ERR(task);
-	else {
-		ret = task->tk_status;
-		rpc_put_task(task);
-	}
-	return ret;
+	return nfs4_run_rpc_task(clnt, msg, &task_setup);
 }
 
 #else
#9 lore raw

Re: [PATCH v1 04/19] NFS: Refactor nfs4_call_data_sequence()

T24gRnJpLCAyMDEzLTA3LTEyIGF0IDEyOjMyIC0wNDAwLCBDaHVjayBMZXZlciB3cm90ZToNCj4g UHVsbCBtYWluIGxvZ2ljIG91dCBvZiBuZnM0X2NhbGxfZGF0YV9zZXF1ZW5jZSgpIHNvIGl0IGNh bg0KPiBldmVudHVhbGx5IGJlIHNoYXJlZCB3aXRoIHRoZSBORlN2NC4wIGNhbGxfc3luYyBwYXRo LiAgVGhlIG5ldw0KPiBoZWxwZXIgZnVuY3Rpb24gaXMgbGVmdCBiZWhpbmQgdGhlIE5GU3Y0LjEg Q09ORklHIHN3aXRjaCBmb3Igbm93IHRvDQo+IGtlZXAgY29tcGlsZXIgd2FybmluZyBub2lzZSBh dCBhIG1pbmltdW0uDQo+IA0KPiBTaWduZWQtb2ZmLWJ5OiBDaHVjayBMZXZlciA8Y2h1Y2subGV2 ZXJAb3JhY2xlLmNvbT4NCj4gLS0tDQo+ICBmcy9uZnMvbmZzNHByb2MuYyB8ICAgMjggKysrKysr KysrKysrKysrKysrLS0tLS0tLS0tLQ0KPiAgMSBmaWxlIGNoYW5nZWQsIDE4IGluc2VydGlvbnMo Kyks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gJnRhc2tfc2V0dXApOw0KPiAgfQ0KPiAgDQo+ICAjZWxzZQ0KPiANCj4gLS0NCj4g VG8gdW5zdWJzY3JpYmUgZnJvbSB0aGlzIGxpc3Q6IHNlbmQgdGhlIGxpbmUgInVuc3Vic2NyaWJl IGxpbnV4LW5mcyIgaW4NCj4gdGhlIGJvZHkgb2YgYSBtZXNzYWdlIHRvIG1ham9yZG9tb0B2Z2Vy Lmtlcm5lbC5vcmcNCj4gTW9yZSBtYWpvcmRvbW8gaW5mbyBhdCAgaHR0cDovL3ZnZXIua2VybmVs Lm9yZy9tYWpvcmRvbW8taW5mby5odG1sDQoNCi0tIA0KVHJvbmQgTXlrbGVidXN0DQpMaW51eCBO RlMgY2xpZW50IG1haW50YWluZXINCg0KTmV0QXBwDQpUcm9uZC5NeWtsZWJ1c3RAbmV0YXBwLmNv bQ0Kd3d3Lm5ldGFwcC5jb20NCg==

#10 lore raw

PATCH 5/19 NFS: Rename nfs41_call_sync_data as a common data structure

In reply to Chuck Lever

Clean up: rename nfs41_call_sync_data for use as a data structure common to all NFSv4 minor versions.

---
 fs/nfs/nfs4proc.c |   18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
fs/nfs/nfs4proc.c +9 -9
index e52d2b3..d7b2c85 100644
@@ -391,6 +391,12 @@ static void renew_lease(const struct nfs_server *server, unsigned long timestamp
 	do_renew_lease(server->nfs_client, timestamp);
 }
 
+struct nfs4_call_sync_data {
+	const struct nfs_server *seq_server;
+	struct nfs4_sequence_args *seq_args;
+	struct nfs4_sequence_res *seq_res;
+};
+
 #if defined(CONFIG_NFS_V4_1)
 
 static int nfs4_run_rpc_task(struct rpc_clnt *clnt,
@@ -657,15 +663,9 @@ out:
 	return ret;
 }
 
-struct nfs41_call_sync_data {
-	const struct nfs_server *seq_server;
-	struct nfs4_sequence_args *seq_args;
-	struct nfs4_sequence_res *seq_res;
-};
-
 static void nfs41_call_sync_prepare(struct rpc_task *task, void *calldata)
 {
-	struct nfs41_call_sync_data *data = calldata;
+	struct nfs4_call_sync_data *data = calldata;
 	struct nfs4_session *session = nfs4_get_session(data->seq_server);
 
 	dprintk("--> %s data->seq_server %p\n", __func__, data->seq_server);
@@ -675,7 +675,7 @@ static void nfs41_call_sync_prepare(struct rpc_task *task, void *calldata)
 
 static void nfs41_call_sync_done(struct rpc_task *task, void *calldata)
 {
-	struct nfs41_call_sync_data *data = calldata;
+	struct nfs4_call_sync_data *data = calldata;
 
 	nfs41_sequence_done(task, data->seq_res);
 }
@@ -691,7 +691,7 @@ static int nfs4_call_sync_sequence(struct rpc_clnt *clnt,
 				   struct nfs4_sequence_args *args,
 				   struct nfs4_sequence_res *res)
 {
-	struct nfs41_call_sync_data data = {
+	struct nfs4_call_sync_data data = {
 		.seq_server = server,
 		.seq_args = args,
 		.seq_res = res,
#11 lore raw

PATCH 6/19 NFS: Clean up nfs4_setup_sequence()

In reply to Chuck Lever

The NFSv4.0-only version of nfs4_setup_sequence() is a static inline function defined in a header file. We're about to add a little more to the NFSv4.0-only version, so move the NFSv4.0-only version into nfs4proc.c next to the NFSv4.1 version.

There are no callsites outside of nfs4proc.c, so I removed the header declarations.

---
 fs/nfs/nfs4_fs.h  |   11 -----------
 fs/nfs/nfs4proc.c |   16 ++++++++++++----
 2 files changed, 12 insertions(+), 15 deletions(-)
fs/nfs/nfs4_fs.h +0 -11
index 40457e2..419fc87 100644
@@ -251,9 +251,6 @@ static inline struct nfs4_session *nfs4_get_session(const struct nfs_server *ser
 	return server->nfs_client->cl_session;
 }
 
-extern int nfs4_setup_sequence(const struct nfs_server *server,
-		struct nfs4_sequence_args *args, struct nfs4_sequence_res *res,
-		struct rpc_task *task);
 extern int nfs41_setup_sequence(struct nfs4_session *session,
 		struct nfs4_sequence_args *args, struct nfs4_sequence_res *res,
 		struct rpc_task *task);
@@ -282,14 +279,6 @@ static inline struct nfs4_session *nfs4_get_session(const struct nfs_server *ser
 	return NULL;
 }
 
-static inline int nfs4_setup_sequence(const struct nfs_server *server,
-		struct nfs4_sequence_args *args, struct nfs4_sequence_res *res,
-		struct rpc_task *task)
-{
-	rpc_call_start(task);
-	return 0;
-}
-
 static inline bool
 is_ds_only_client(struct nfs_client *clp)
 {
fs/nfs/nfs4proc.c +12 -4
index d7b2c85..7b2e008 100644
@@ -640,10 +640,10 @@ out_sleep:
 }
 EXPORT_SYMBOL_GPL(nfs41_setup_sequence);
 
-int nfs4_setup_sequence(const struct nfs_server *server,
-			struct nfs4_sequence_args *args,
-			struct nfs4_sequence_res *res,
-			struct rpc_task *task)
+static int nfs4_setup_sequence(const struct nfs_server *server,
+			       struct nfs4_sequence_args *args,
+			       struct nfs4_sequence_res *res,
+			       struct rpc_task *task)
 {
 	struct nfs4_session *session = nfs4_get_session(server);
 	int ret = 0;
@@ -717,6 +717,14 @@ static void nfs4_set_sequence_privileged(struct nfs4_sequence_args *args)
 {
 }
 
+static int nfs4_setup_sequence(const struct nfs_server *server,
+			       struct nfs4_sequence_args *args,
+			       struct nfs4_sequence_res *res,
+			       struct rpc_task *task)
+{
+	rpc_call_start(task);
+	return 0;
+}
 
 static int nfs4_sequence_done(struct rpc_task *task,
 			       struct nfs4_sequence_res *res)
#12 lore raw

PATCH 7/19 NFS: Fix compiler warning in nfs_setup_sequence()

In reply to Chuck Lever

Clean up. Squelch compiler warning:

linux/fs/nfs/nfs4proc.c: In function ‘nfs4_setup_sequence’:
linux/fs/nfs/nfs4proc.c:703:2: warning: signed and unsigned type in
conditional expression [-Wsign-compare]

---
 fs/nfs/nfs4proc.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfs/nfs4proc.c +1 -1
index 7b2e008..5913e1d 100644
@@ -655,7 +655,7 @@ static int nfs4_setup_sequence(const struct nfs_server *server,
 
 	dprintk("--> %s clp %p session %p sr_slot %d\n",
 		__func__, session->clp, session, res->sr_slot ?
-			res->sr_slot->slot_nr : -1);
+			(int)res->sr_slot->slot_nr : -1);
 
 	ret = nfs41_setup_sequence(session, args, res, task);
 out:
#13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zaW9uLCByZXMtPnNyX3Nsb3QgPw0KPiAtCQkJcmVzLT5zcl9zbG90LT5zbG90 X25yIDogLTEpOw0KPiArCQkJKGludClyZXMtPnNyX3Nsb3QtPnNsb3RfbnIgOiAtMSk7DQo+ICAN Cg0KUGxlYXNlIGNvbnZlcnQgdG8gbWFrZSBpdCB1bnNpZ25lZCwgYW5kIHRvIHVzZSBORlM0X05P X1NMT1QgaW5zdGVhZCBvZg0KJy0xJy4NCg0KLS0gDQpUcm9uZCBNeWtsZWJ1c3QNCkxpbnV4IE5G UyBjbGllbnQgbWFpbnRhaW5lcg0KDQpOZXRBcHANClRyb25kLk15a2xlYnVzdEBuZXRhcHAuY29t DQp3d3cubmV0YXBwLmNvbQ0K

#14 lore raw

Re: [PATCH v1 07/19] NFS: Fix compiler warning in nfs_setup_sequence()

Quoted 18 lines · Trond
Quoted 17 lines · Chuck Lever

Clean up. Squelch compiler warning:

linux/fs/nfs/nfs4proc.c: In function ‘nfs4_setup_sequence’:
linux/fs/nfs/nfs4proc.c:703:2: warning: signed and unsigned type in
conditional expression [-Wsign-compare]

---
fs/nfs/nfs4proc.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfs/nfs4proc.c +0 -0
index 7b2e008..5913e1d 100644
@@ -655,7 +655,7 @@ static int nfs4_setup_sequence(const struct nfs_server *server,
 
Quoted 8 lines

fs/nfs/nfs4proc.c static int nfs4_setup_sequence(const struct nfs_server *server, · line 659

Quoted 5 lines
fs/nfs/nfs4proc.c +1 -1
 	dprintk("--> %s clp %p session %p sr_slot %d\n",
 		__func__, session->clp, session, res->sr_slot ?
-			res->sr_slot->slot_nr : -1);
+			(int)res->sr_slot->slot_nr : -1);
 

Please convert to make it unsigned, and to use NFS4_NO_SLOT instead of '-1'.

NFS4_NO_SLOT makes sense, but I'm not clear on "make it unsigned".

Leaving the format as "%d" allows NFS4_NO_SLOT to be displayed as "-1". So, something like the following one-liner will address the compiler warning, and leave behavior unchanged:

- res->sr_slot->slot_nr : -1);
+ res->sr_slot->slot_nr : NFS4_NO_SLOT);

That is, unless you prefer NFS4_NO_SLOT displayed in some other way?

Signature · 2 lines
Chuck Lever
chuck[dot]lever[at]oracle[dot]com
#15 lore raw

Re: [PATCH v1 07/19] NFS: Fix compiler warning in nfs_setup_sequence()

T24gTW9uLCAyMDEzLTA3LTIyIGF0IDE2OjE2IC0wNDAwLCBDaHVjayBMZXZlciB3cm90ZToNCj4g T24gSnVsIDIyLCAyMDEzLCBhdCAzOjAzIFBNLCAiTXlrbGVidXN0LCBUcm9uZCIgPFRyb25kLk15 a2xlYnVzdEBuZXRhcHAuY29tPiB3cm90ZToNCj4gDQo+ID4gT24gRnJpLCAyMDEzLTA3LTEyIGF0 IDEyOjMyIC0wNDAwLCBDaHVjayBMZXZlciB3cm90ZToNCj4gPj4gQ2xlYW4gdXAuICBTcXVlbGNo IGNvbXBpbGVyIHdhcm5pbmc6DQo+ID4+IA0KPiA+PiBsaW51eC9mcy9uZnMvbmZzNHByb2MuYzog SW4gZnVuY3Rpb24g4oCYbmZzNF9zZXR1cF9zZXF1ZW5jZeKAmToNCj4gPj4gbGludXgvZnMvbmZz L25mczRwcm9jLmM6NzAzOjI6IHdhcm5pbmc6IHNpZ25lZCBhbmQgdW5zaWduZWQgdHlwZSBpbg0K PiA+PiAJY29uZGl0aW9uYWwgZXhwcmVzc2lvbiBbLVdzaWduLWNvbXBhcmVdDQo+ID4+IA0KPiA+ PiBTaWduZWQtb2ZmLWJ5OiBDaHVjayBMZXZlciA8Y2h1Y2subGV2ZXJAb3JhY2xlLmNvbT4NCj4g Pj4gLS0tDQo+ID4+IGZzL25mcy9uZnM0cHJvYy5jIHwgICAgMiArLQ0KPiA+PiAxIGZpbGUgY2hh bmdlZCwgMSBpbnNlcnRpb24oKyksIDEgZGVsZXRpb24oLSkNCj4gPj4gDQo+ID4+IGRpZmYgLS1n aXQgYS9mcy9uZnMvbmZzNHByb2MuYyBiL2ZzL25mcy9uZnM0cHJvYy5jDQ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iArCQkJcmVzLT5zcl9zbG90LT5z bG90X25yIDogTkZTNF9OT19TTE9UKTsNCj4gDQo+IFRoYXQgaXMsIHVubGVzcyB5b3UgcHJlZmVy IE5GUzRfTk9fU0xPVCBkaXNwbGF5ZWQgaW4gc29tZSBvdGhlciB3YXk/DQoNCkJvdGggdGhlIHNs b3QgaWQgYW5kIE5GUzRfTk9fU0xPVCBhcmUgZGVmaW5lZCBhcyBiZWluZyBvZiB0eXBlIHUzMiwg c28NCml0IG1ha2VzIG5vIHNlbnNlIHRvIGRpc3BsYXkgYSAiLTEiLiBKdXN0IGRpc3BsYXlpbmcg aXQgYXMgMl4zMiBzaG91bGQNCmJlIGdvb2QgZW5vdWdoIHNpbmNlIHRoaXMgaXMgYW4gb2J2aW91 cyAiZGV2ZWxvcGVyIG9ubHkiIGRwcmludGsuDQoNCi0tIA0KVHJvbmQgTXlrbGVidXN0DQpMaW51 eCBORlMgY2xpZW50IG1haW50YWluZXINCg0KTmV0QXBwDQpUcm9uZC5NeWtsZWJ1c3RAbmV0YXBw LmNvbQ0Kd3d3Lm5ldGFwcC5jb20NCg==

#16 lore raw

Re: [PATCH v1 07/19] NFS: Fix compiler warning in nfs_setup_sequence()

Quoted 34 lines · Trond
Quoted 33 lines · Chuck Lever
Quoted 18 lines · Trond
Quoted 17 lines · Chuck Lever

Clean up. Squelch compiler warning:

linux/fs/nfs/nfs4proc.c: In function ‘nfs4_setup_sequence’:
linux/fs/nfs/nfs4proc.c:703:2: warning: signed and unsigned type in
conditional expression [-Wsign-compare]

---
fs/nfs/nfs4proc.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfs/nfs4proc.c +0 -0
index 7b2e008..5913e1d 100644
@@ -655,7 +655,7 @@ static int nfs4_setup_sequence(const struct nfs_server *server,
 
Quoted 8 lines

fs/nfs/nfs4proc.c static int nfs4_setup_sequence(const struct nfs_server *server, · line 659

Quoted 5 lines
fs/nfs/nfs4proc.c +1 -1
 	dprintk("--> %s clp %p session %p sr_slot %d\n",
 		__func__, session->clp, session, res->sr_slot ?
-			res->sr_slot->slot_nr : -1);
+			(int)res->sr_slot->slot_nr : -1);
 

Please convert to make it unsigned, and to use NFS4_NO_SLOT instead of '-1'.

NFS4_NO_SLOT makes sense, but I'm not clear on "make it unsigned".

Leaving the format as "%d" allows NFS4_NO_SLOT to be displayed as "-1". So, something like the following one-liner will address the compiler warning, and leave behavior unchanged:

Quoted 8 lines
Quoted 4 lines
(quoted diff) +1 -1
-			res->sr_slot->slot_nr : -1);
+			res->sr_slot->slot_nr : NFS4_NO_SLOT);

That is, unless you prefer NFS4_NO_SLOT displayed in some other way?

Both the slot id and NFS4_NO_SLOT are defined as being of type u32, so it makes no sense to display a "-1". Just displaying it as 2^32 should be good enough since this is an obvious "developer only" dprintk.

OK, clear. Thanks.

Signature · 2 lines
Chuck Lever
chuck[dot]lever[at]oracle[dot]com
#17 lore raw

PATCH 8/19 NFS: Use RPC callouts to start NFSv4.0 synchronous requests

In reply to Chuck Lever

In preparation for adding a transport blocking mechanism for NFSv4.0, replace _nfs4_call_sync() with a common function that handles synchronous RPC calls for all minor versions using RPC callouts.

---
 fs/nfs/nfs4_fs.h  |    6 +-----
 fs/nfs/nfs4proc.c |   47 ++++++++++++++++++++++++++++++++++-------------
 2 files changed, 35 insertions(+), 18 deletions(-)
fs/nfs/nfs4_fs.h +1 -5
index 419fc87..ae05978 100644
@@ -38,17 +38,13 @@ struct nfs4_minor_version_ops {
 	u32	minor_version;
 	unsigned init_caps;
 
-	int	(*call_sync)(struct rpc_clnt *clnt,
-			struct nfs_server *server,
-			struct rpc_message *msg,
-			struct nfs4_sequence_args *args,
-			struct nfs4_sequence_res *res);
 	bool	(*match_stateid)(const nfs4_stateid *,
 			const nfs4_stateid *);
 	int	(*find_root_sec)(struct nfs_server *, struct nfs_fh *,
 			struct nfs_fsinfo *);
 	int	(*free_lock_state)(struct nfs_server *,
 			struct nfs4_lock_state *);
+	const struct rpc_call_ops *call_sync_ops;
 	const struct nfs4_state_recovery_ops *reboot_recovery_ops;
 	const struct nfs4_state_recovery_ops *nograce_recovery_ops;
 	const struct nfs4_state_maintenance_ops *state_renewal_ops;
fs/nfs/nfs4proc.c +34 -13

93 lines not on this page · raw message

#18 lore raw

PATCH 9/19 NFS: Add a "struct nfs_server *" argument to nfs4_sequence_done()

In reply to Chuck Lever

For NFSv4.1, a session slot table reference is passed to nfs4_sequence_done().

For NFSv4.0, transport state is managed in the nfs_client that owns this nfs_server. The nfs_server struct must be passed to nfs4_sequence_done() to make it available to the functions dealing with transport blocking.

---
 fs/nfs/nfs4proc.c |   46 ++++++++++++++++++++++++++--------------------
 1 file changed, 26 insertions(+), 20 deletions(-)
fs/nfs/nfs4proc.c +26 -20
index 0c1fa13..20768e8 100644
@@ -553,8 +553,9 @@ out_retry:
 	return 0;
 }
 
-static int nfs4_sequence_done(struct rpc_task *task,
-			       struct nfs4_sequence_res *res)
+static int nfs4_sequence_done(const struct nfs_server *server,
+			      struct rpc_task *task,
+			      struct nfs4_sequence_res *res)
 {
 	if (res->sr_slot == NULL)
 		return 1;
@@ -726,8 +727,9 @@ static int nfs4_setup_sequence(const struct nfs_server *server,
 	return 0;
 }
 
-static int nfs4_sequence_done(struct rpc_task *task,
-			       struct nfs4_sequence_res *res)
+static int nfs4_sequence_done(const struct nfs_server *server,
+			      struct rpc_task *task,
+			      struct nfs4_sequence_res *res)
 {
 	return 1;
 }
@@ -745,7 +747,7 @@ static void nfs40_call_sync_done(struct rpc_task *task, void *calldata)
 {
 	struct nfs4_call_sync_data *data = calldata;
 
-	nfs4_sequence_done(task, data->seq_res);
+	nfs4_sequence_done(data->seq_server, task, data->seq_res);
 }
 
 static const struct rpc_call_ops nfs40_call_sync_ops = {
@@ -1622,7 +1624,7 @@ unlock_no_action:
 out_no_action:
 	task->tk_action = NULL;
 out_wait:
-	nfs4_sequence_done(task, &data->o_res.seq_res);
+	nfs4_sequence_done(data->o_arg.server, task, &data->o_res.seq_res);
 }
 
 static void nfs4_open_done(struct rpc_task *task, void *calldata)
@@ -1631,7 +1633,7 @@ static void nfs4_open_done(struct rpc_task *task, void *calldata)
 
 	data->rpc_status = task->tk_status;
 
-	if (!nfs4_sequence_done(task, &data->o_res.seq_res))
+	if (!nfs4_sequence_done(data->o_arg.server, task, &data->o_res.seq_res))
 		return;
 
 	if (task->tk_status == 0) {
@@ -2294,7 +2296,7 @@ static void nfs4_close_done(struct rpc_task *task, void *data)
 	struct nfs_server *server = NFS_SERVER(calldata->inode);
 
 	dprintk("%s: begin!\n", __func__);
-	if (!nfs4_sequence_done(task, &calldata->res.seq_res))
+	if (!nfs4_sequence_done(server, task, &calldata->res.seq_res))
 		return;
         /* hmm. we are done with the inode, and in the process of freeing
 	 * the state_owner. we keep this around to process errors
@@ -2381,7 +2383,7 @@ static void nfs4_close_prepare(struct rpc_task *task, void *data)
 out_no_action:
 	task->tk_action = NULL;
 out_wait:
-	nfs4_sequence_done(task, &calldata->res.seq_res);
+	nfs4_sequence_done(NFS_SERVER(inode), task, &calldata->res.seq_res);
 }
 
 static const struct rpc_call_ops nfs4_close_ops = {
@@ -3149,7 +3151,7 @@ static int nfs4_proc_unlink_done(struct rpc_task *task, struct inode *dir)
 {
 	struct nfs_removeres *res = task->tk_msg.rpc_resp;
 
-	if (!nfs4_sequence_done(task, &res->seq_res))
+	if (!nfs4_sequence_done(res->server, task, &res->seq_res))
 		return 0;
 	if (nfs4_async_handle_error(task, res->server, NULL) == -EAGAIN)
 		return 0;
@@ -3181,7 +3183,7 @@ static int nfs4_proc_rename_done(struct rpc_task *task, struct inode *old_dir,
 {
 	struct nfs_renameres *res = task->tk_msg.rpc_resp;
 
-	if (!nfs4_sequence_done(task, &res->seq_res))
+	if (!nfs4_sequence_done(res->server, task, &res->seq_res))
 		return 0;
 	if (nfs4_async_handle_error(task, res->server, NULL) == -EAGAIN)
 		return 0;
@@ -3705,10 +3707,11 @@ static bool nfs4_read_stateid_changed(struct rpc_task *task,
 
 static int nfs4_read_done(struct rpc_task *task, struct nfs_read_data *data)
 {
+	struct nfs_server *server = NFS_SERVER(data->header->inode);
 
 	dprintk("--> %s\n", __func__);
 
-	if (!nfs4_sequence_done(task, &data->res.seq_res))
+	if (!nfs4_sequence_done(server, task, &data->res.seq_res))
 		return -EAGAIN;
 	if (nfs4_read_stateid_changed(task, &data->args))
 		return -EAGAIN;
@@ -3753,7 +3756,6 @@ static int nfs4_write_done_cb(struct rpc_task *task, struct nfs_write_data *data
 static bool nfs4_write_stateid_changed(struct rpc_task *task,
 		struct nfs_writeargs *args)
 {
-
 	if (!nfs4_error_stateid_expired(task->tk_status) ||
 		nfs4_stateid_is_current(&args->stateid,
 				args->context,
@@ -3766,7 +3768,9 @@ static bool nfs4_write_stateid_changed(struct rpc_task *task,
 
 static int nfs4_write_done(struct rpc_task *task, struct nfs_write_data *data)
 {
-	if (!nfs4_sequence_done(task, &data->res.seq_res))
+	struct nfs_server *server = NFS_SERVER(data->header->inode);
+
+	if (!nfs4_sequence_done(server, task, &data->res.seq_res))
 		return -EAGAIN;
 	if (nfs4_write_stateid_changed(task, &data->args))
 		return -EAGAIN;
@@ -3839,7 +3843,9 @@ static int nfs4_commit_done_cb(struct rpc_task *task, struct nfs_commit_data *da
 
 static int nfs4_commit_done(struct rpc_task *task, struct nfs_commit_data *data)
 {
-	if (!nfs4_sequence_done(task, &data->res.seq_res))
+	struct nfs_server *server = NFS_SERVER(data->inode);
+
+	if (!nfs4_sequence_done(server, task, &data->res.seq_res))
 		return -EAGAIN;
 	return data->commit_done_cb(task, data);
 }
@@ -4439,7 +4445,7 @@ static void nfs4_delegreturn_done(struct rpc_task *task, void *calldata)
 {
 	struct nfs4_delegreturndata *data = calldata;
 
-	if (!nfs4_sequence_done(task, &data->res.seq_res))
+	if (!nfs4_sequence_done(data->res.server, task, &data->res.seq_res))
 		return;
 
 	switch (task->tk_status) {
@@ -4690,7 +4696,7 @@ static void nfs4_locku_done(struct rpc_task *task, void *data)
 {
 	struct nfs4_unlockdata *calldata = data;
 
-	if (!nfs4_sequence_done(task, &calldata->res.seq_res))
+	if (!nfs4_sequence_done(calldata->server, task, &calldata->res.seq_res))
 		return;
 	switch (task->tk_status) {
 		case 0:
@@ -4730,7 +4736,7 @@ static void nfs4_locku_prepare(struct rpc_task *task, void *data)
 out_no_action:
 	task->tk_action = NULL;
 out_wait:
-	nfs4_sequence_done(task, &calldata->res.seq_res);
+	nfs4_sequence_done(calldata->server, task, &calldata->res.seq_res);
 }
 
 static const struct rpc_call_ops nfs4_locku_ops = {
@@ -4905,7 +4911,7 @@ out_release_open_seqid:
 out_release_lock_seqid:
 	nfs_release_seqid(data->arg.lock_seqid);
 out_wait:
-	nfs4_sequence_done(task, &data->res.seq_res);
+	nfs4_sequence_done(data->server, task, &data->res.seq_res);
 	dprintk("%s: done!, ret = %d\n", __func__, data->rpc_status);
 }
 
@@ -4915,7 +4921,7 @@ static void nfs4_lock_done(struct rpc_task *task, void *calldata)
 
 	dprintk("%s: begin!\n", __func__);
 
-	if (!nfs4_sequence_done(task, &data->res.seq_res))
+	if (!nfs4_sequence_done(data->server, task, &data->res.seq_res))
 		return;
 
 	data->rpc_status = task->tk_status;
#19 lore raw

Re: [PATCH v1 09/19] NFS: Add a "struct nfs_server *" argument to nfs4_sequence_done()

T24gRnJpLCAyMDEzLTA3LTEyIGF0IDEyOjMyIC0wNDAwLCBDaHVjayBMZXZlciB3cm90ZToNCj4g Rm9yIE5GU3Y0LjEsIGEgc2Vzc2lvbiBzbG90IHRhYmxlIHJlZmVyZW5jZSBpcyBwYXNzZWQgdG8N Cj4gbmZzNF9zZXF1ZW5jZV9kb25lKCkuDQo+IA0KPiBGb3IgTkZTdjQuMCwgdHJhbnNwb3J0IHN0 YXRlIGlzIG1hbmFnZWQgaW4gdGhlIG5mc19jbGllbnQgdGhhdCBvd25zDQo+IHRoaXMgbmZzX3Nl cnZlci4gIFRoZSBuZnNfc2VydmVyIHN0cnVjdCBtdXN0IGJlIHBhc3NlZCB0bw0KPiBuZnM0X3Nl cXVlbmNlX2RvbmUoKSB0byBtYWtlIGl0IGF2YWlsYWJsZSB0byB0aGUgZnVuY3Rpb25zIGRlYWxp bmcNCj4gd2l0aCB0cmFuc3BvcnQgYmxvY2tpbmcuDQoNCldoeT8gQ2FuJ3QgNC4wIGp1c3QgcmV1 c2UgdGhlIGV4aXN0aW5nIHY0LjEgc2Vzc2lvbiBzbG90IHRhYmxlIGZvciB0aGlzPw0KDQotLSAN ClRyb25kIE15a2xlYnVzdA0KTGludXggTkZTIGNsaWVudCBtYWludGFpbmVyDQoNCk5ldEFwcA0K VHJvbmQuTXlrbGVidXN0QG5ldGFwcC5jb20NCnd3dy5uZXRhcHAuY29tDQo=

#20 lore raw

Re: [PATCH v1 09/19] NFS: Add a "struct nfs_server *" argument to nfs4_sequence_done()

Quoted 10 lines · Trond
Quoted 7 lines · Chuck Lever

For NFSv4.1, a session slot table reference is passed to nfs4_sequence_done().

For NFSv4.0, transport state is managed in the nfs_client that owns this nfs_server. The nfs_server struct must be passed to nfs4_sequence_done() to make it available to the functions dealing with transport blocking.

Why? Can't 4.0 just reuse the existing v4.1 session slot table for this?

Before commit 774d5f14 "NFSv4.1 Fix a pNFS session draining deadlock," Mon May 20 14:13:50 2013, the DRAINING bit was in nfs4_session, not in nfs4_slot_table. Before that commit, I would have had to enable most of the NFSv4.1 sessions code to re-use it for NFSv4.0 transport blocking.

(And btw, thanks Andy! 774d5f14 is a very useful refactoring).

I spent the last couple of days re-implementing my NFSv4.0 transport blocking mechanism based on the slot table abstraction, rather than adding similar fields to the nfs_client. At this point, it looks like a workable approach, but I won't get it finished and tested before I head to Berlin. I may have some time to continue work while I'm there.

Since our town hall meeting is cancelled this week, let me report on progress with migration support.

I was hoping to publish my 3.11-rc port of the migration patches today for another round of review, but I'm not going to make it due to the complexity of rebasing the transport blocking mechanism directly on struct nfs4_slot_table. It will be at the top of my list when I get back.

I was able to check off some of the test cases I mentioned in the cover letter for the v1 patch series:

Migration with no TSM: identified and fixed a client bug, then was able to witness state recovery during a successful migration. The server prototype currently reports NFS4ERR_EXPIRED, so state recovery in this case involves OPEN(CLAIM_NULL) - the server is not in a grace period, and it is possible for clients to lose their locks.

Migration during a lock-intensive workload: the server prototype is still attempting to put off client requests without using NFS4ERR_DELAY, which causes the client workload to terminate; waiting for that to be addressed, then will try again.

Migration recovery failure: identified the need for more infrastructure to communicate state manager failure back to forward NFS processes. That infrastructure has been added, but not yet tested.

The idea is that all I/O on the mount should fail after a migration, but an admin should be able to unmount cleanly. In other words, manual recovery by remounting the FSID on the destination server, which is what would happen in the pre-migration world.

Migration with Kerberos: exploring KDC resources available for testing my client with the server prototypes that are located in our Austin lab.

Signature · 2 lines
Chuck Lever
chuck[dot]lever[at]oracle[dot]com
#21 lore raw

PATCH 10/19 NFS: Implement a transport blocking scheme for migration

In reply to Chuck Lever

When an NFSv4 migration event occurs, an NFS client must redirect a mount point's underlying RPC transport to a different NFS server.

Before performing this redirection, the client must plug the RPC transport to prevent the initiation of new requests, and allow any pending requests or the migrating FSID to complete.

Only then is it safe to swap in a transport to the destination server. This is like NFSv4.1 session draining, so we adopt a similar approach.

---
 fs/nfs/nfs4_fs.h          |    1 +
 fs/nfs/nfs4client.c       |    4 ++++
 fs/nfs/nfs4proc.c         |   43 ++++++++++++++++++++++++++++++++++++++-----
 fs/nfs/nfs4state.c        |   19 +++++++++++++++++++
 include/linux/nfs_fs_sb.h |    4 ++++
 5 files changed, 66 insertions(+), 5 deletions(-)
fs/nfs/nfs4_fs.h +1 -0
index ae05978..b9c839e 100644
@@ -29,6 +29,7 @@ enum nfs4_client_state {
 	NFS4CLNT_SERVER_SCOPE_MISMATCH,
 	NFS4CLNT_PURGE_STATE,
 	NFS4CLNT_BIND_CONN_TO_SESSION,
+	NFS4CLNT_BLOCK_XPRT,
 };
 
 #define NFS4_RENEW_TIMEOUT		0x01
fs/nfs/nfs4client.c +4 -0
index 3aec2de..4d208e0 100644
@@ -72,6 +72,10 @@ struct nfs_client *nfs4_alloc_client(const struct nfs_client_initdata *cl_init)
 	clp->cl_state = 1 << NFS4CLNT_LEASE_EXPIRED;
 	clp->cl_minorversion = cl_init->minorversion;
 	clp->cl_mvops = nfs_v4_minor_ops[cl_init->minorversion];
+	if (clp->cl_minorversion == 0) {
+		init_completion(&clp->cl_xpcomplete);
+		rpc_init_wait_queue(&clp->cl_xpwaitq, "NFSv4.0 xprt");
+	}
 	return clp;
 
 error:
fs/nfs/nfs4proc.c +38 -5

73 lines not on this page · raw message

fs/nfs/nfs4state.c +19 -0
index 71fc85d..ae482b2 100644
@@ -355,6 +355,25 @@ int nfs41_discover_server_trunking(struct nfs_client *clp,
 
 #endif /* CONFIG_NFS_V4_1 */
 
+static void nfs4_end_drain_xprt(struct nfs_client *clp)
+{
+	if (test_and_clear_bit(NFS4CLNT_BLOCK_XPRT, &clp->cl_state))
+		rpc_wake_up(&clp->cl_xpwaitq);
+}
+
+static int nfs4_begin_drain_xprt(struct nfs_client *clp)
+{
+	set_bit(NFS4CLNT_BLOCK_XPRT, &clp->cl_state);
+	spin_lock(&clp->cl_lock);
+	if (atomic_read(&clp->cl_xppending)) {
+		INIT_COMPLETION(clp->cl_xpcomplete);
+		spin_unlock(&clp->cl_lock);
+		return wait_for_completion_interruptible(&clp->cl_xpcomplete);
+	}
+	spin_unlock(&clp->cl_lock);
+	return 0;
+}
+
 /**
  * nfs4_get_clid_cred - Acquire credential for a setclientid operation
  * @clp: client state handle
include/linux/nfs_fs_sb.h +4 -0
index 3b7fa2a..ad47c90 100644
@@ -78,6 +78,10 @@ struct nfs_client {
 	u32			cl_cb_ident;	/* v4.0 callback identifier */
 	const struct nfs4_minor_version_ops *cl_mvops;
 
+	atomic_t		cl_xppending;
+	struct completion	cl_xpcomplete;
+	struct rpc_wait_queue	cl_xpwaitq;
+
 	/* The sequence id to use for the next CREATE_SESSION */
 	u32			cl_seqid;
 	/* The flags used for obtaining the clientid during EXCHANGE_ID */
#22 lore raw

PATCH 11/19 SUNRPC: Add a helper to switch the transport of an rpc_clnt

In reply to Chuck Lever

From: Trond Myklebust <[email protected]>

[ cel: forward ported to 3.10 ]
---
 include/linux/sunrpc/clnt.h |    4 ++
 net/sunrpc/clnt.c           |   83 ++++++++++++++++++++++++++++++++++++++++---
 2 files changed, 81 insertions(+), 6 deletions(-)
include/linux/sunrpc/clnt.h +4 -0
index bfe11be..29bb018 100644
@@ -134,6 +134,10 @@ void rpc_task_reset_client(struct rpc_task *task, struct rpc_clnt *clnt);
 struct rpc_clnt *rpc_clone_client(struct rpc_clnt *);
 struct rpc_clnt *rpc_clone_client_set_auth(struct rpc_clnt *,
 				rpc_authflavor_t);
+int		rpc_switch_client_transport(struct rpc_clnt *,
+				struct xprt_create *,
+				const struct rpc_timeout *);
+
 void		rpc_shutdown_client(struct rpc_clnt *);
 void		rpc_release_client(struct rpc_clnt *);
 void		rpc_task_release_client(struct rpc_task *);
net/sunrpc/clnt.c +77 -6

124 lines not on this page · raw message

#23 lore raw

PATCH 12/19 NFS: Add a super_block backpointer to the nfs_server struct

In reply to Chuck Lever

NFS_SB() gives the pointer to an nfs_server struct, given a pointer to a super_block. But we have no way to go back the other way.

Add a super_block backpointer pointer so that, given an nfs_server struct, it is easy to get to the root dentry, or access the list of inodes, associated with an nfs_server.

---
 fs/nfs/super.c            |    1 +
 include/linux/nfs_fs_sb.h |    1 +
 2 files changed, 2 insertions(+)
fs/nfs/super.c +1 -0
index 2d7525f..455d56a 100644
@@ -2463,6 +2463,7 @@ struct dentry *nfs_fs_mount_common(struct nfs_server *server,
 			mntroot = ERR_PTR(error);
 			goto error_splat_bdi;
 		}
+		server->super = s;
 	}
 
 	if (!s->s_root) {
include/linux/nfs_fs_sb.h +1 -0
index ad47c90..84d8f0c 100644
@@ -138,6 +138,7 @@ struct nfs_server {
 	__u64			maxfilesize;	/* maximum file size */
 	struct timespec		time_delta;	/* smallest time granularity */
 	unsigned long		mount_time;	/* when this fs was mounted */
+	struct super_block	*super;		/* VFS super block */
 	dev_t			s_dev;		/* superblock dev numbers */
 
 #ifdef CONFIG_NFS_FSCACHE
#24 lore raw

PATCH 13/19 NFS: Add functions to swap transports during migration recovery

In reply to Chuck Lever

Introduce functions that can walk through an array of returned fs_locations information and connect a transport to one of the destination servers listed therein.

Note that NFS minor version 1 introduces "fs_locations_info" which extends the locations array sorting criteria available to clients. This is not supported yet.

---
 fs/nfs/client.c        |    3 +
 fs/nfs/internal.h      |    3 +
 fs/nfs/nfs4_fs.h       |    2 +
 fs/nfs/nfs4client.c    |   78 +++++++++++++++++++++++++++++++++
 fs/nfs/nfs4namespace.c |  114 ++++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 199 insertions(+), 1 deletion(-)
fs/nfs/client.c +2 -1
index dbb65fb..5b7c60a 100644
@@ -945,7 +945,7 @@ void nfs_server_insert_lists(struct nfs_server *server)
 }
 EXPORT_SYMBOL_GPL(nfs_server_insert_lists);
 
-static void nfs_server_remove_lists(struct nfs_server *server)
+void nfs_server_remove_lists(struct nfs_server *server)
 {
 	struct nfs_client *clp = server->nfs_client;
 	struct nfs_net *nn;
@@ -962,6 +962,7 @@ static void nfs_server_remove_lists(struct nfs_server *server)
 
 	synchronize_rcu();
 }
+EXPORT_SYMBOL_GPL(nfs_server_remove_lists);
 
 /*
  * Allocate and initialise a server record
fs/nfs/internal.h +3 -0
index 91e59a3..3de40da 100644
@@ -153,6 +153,7 @@ struct nfs_client *nfs_get_client(const struct nfs_client_initdata *,
 				  rpc_authflavor_t);
 int nfs_probe_fsinfo(struct nfs_server *server, struct nfs_fh *, struct nfs_fattr *);
 void nfs_server_insert_lists(struct nfs_server *);
+void nfs_server_remove_lists(struct nfs_server *);
 void nfs_init_timeout_values(struct rpc_timeout *, int, unsigned int, unsigned int);
 int nfs_init_server_rpcclient(struct nfs_server *, const struct rpc_timeout *t,
 		rpc_authflavor_t);
@@ -173,6 +174,8 @@ extern struct nfs_server *nfs4_create_server(
 					struct nfs_subversion *);
 extern struct nfs_server *nfs4_create_referral_server(struct nfs_clone_mount *,
 						      struct nfs_fh *);
+extern int nfs4_update_server(struct nfs_server *server, const char *hostname,
+					struct sockaddr *sap, size_t salen);
 extern void nfs_free_server(struct nfs_server *server);
 extern struct nfs_server *nfs_clone_server(struct nfs_server *,
 					   struct nfs_fh *,
fs/nfs/nfs4_fs.h +2 -0
index b9c839e..4b83ffc 100644
@@ -219,6 +219,8 @@ rpc_authflavor_t nfs_find_best_sec(struct nfs4_secinfo_flavors *);
 struct rpc_clnt *nfs4_create_sec_client(struct rpc_clnt *, struct inode *, struct qstr *);
 struct vfsmount *nfs4_submount(struct nfs_server *, struct dentry *,
 			       struct nfs_fh *, struct nfs_fattr *);
+int nfs4_replace_transport(struct nfs_server *server,
+				const struct nfs4_fs_locations *locations);
 
 /* nfs4proc.c */
 extern int nfs4_proc_setclientid(struct nfs_client *, u32, unsigned short, struct rpc_cred *, struct nfs4_setclientid_res *);
fs/nfs/nfs4client.c +78 -0

81 lines not on this page · raw message

fs/nfs/nfs4namespace.c +114 -0

117 lines not on this page · raw message

#25 lore raw

PATCH 14/19 NFS: Add method to retrieve fs_locations during migration recovery

In reply to Chuck Lever

The nfs4_proc_fs_locations() function is invoked during referral processing to perform a GETATTR(fs_locations) on an object's parent directory in order to discover the target of the referral. It performs a LOOKUP in the compound, so the client needs to know the parent's file handle a priori.

Unfortunately this function is not adequate for handling migration recovery. We need to probe fs_locations information on an FSID's root directory, but the "parent" of a root directory is not available for a LOOKUP operation. Fortunately we already know the FSID's root FH, as it is now saved at mount time.

Another subtlety: recovering from NFS4ERR_LEASE_MOVED is a process of walking over a list of known FSIDs that reside on the server, and probing whether they have migrated. Once the server has detected that the client has probed all migrated file systems, it stops returning NFS4ERR_LEASE_MOVED.

A minor version zero server needs to know what client ID is requesting fs_locations information so it can clear the flag that forces it to continue returning NFS4ERR_LEASE_MOVED. This flag is set per client ID and per FSID. However, the client ID is not an argument of either the PUTFH or GETATTR operations. Later minor versions have client ID information embedded in the compound's SEQUENCE operation.

Therefore, by convention, minor version zero clients send a RENEW operation in the same compound as the GETATTR(fs_locations), since RENEW's one argument is a clientid4. This allows a minor version zero server to identify correctly the client that is probing for a migration.

(Needing to send a RENEW in the mv0 case by itself might not be a strong justification for separate get_locations methods for mv0 and mv1. But eventually, fs_locations_info support can be plumbed into the mv1 method without disturbing the mv0 method).

---
 fs/nfs/nfs4_fs.h        |    2 +
 fs/nfs/nfs4proc.c       |  147 +++++++++++++++++++++++++++++++++++++++++++++++
 fs/nfs/nfs4xdr.c        |   46 +++++++++++----
 include/linux/nfs_xdr.h |    4 +
 4 files changed, 188 insertions(+), 11 deletions(-)
fs/nfs/nfs4_fs.h +2 -0
index 4b83ffc..66c34c4 100644
@@ -203,6 +203,7 @@ struct nfs4_state_maintenance_ops {
 };
 
 struct nfs4_mig_recovery_ops {
+	int (*get_locations)(struct inode *, struct nfs4_fs_locations *, struct page *);
 };
 
 extern const struct dentry_operations nfs4_dentry_operations;
@@ -235,6 +236,7 @@ extern int nfs4_do_close(struct nfs4_state *state, gfp_t gfp_mask, int wait);
 extern int nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *fhandle);
 extern int nfs4_proc_fs_locations(struct rpc_clnt *, struct inode *, const struct qstr *,
 				  struct nfs4_fs_locations *, struct page *);
+extern int nfs4_proc_get_locations(struct inode *, struct nfs4_fs_locations *, struct page *page);
 extern struct rpc_clnt *nfs4_proc_lookup_mountpoint(struct inode *, struct qstr *,
 			    struct nfs_fh *, struct nfs_fattr *);
 extern int nfs4_proc_secinfo(struct inode *, const struct qstr *, struct nfs4_secinfo_flavors *);
fs/nfs/nfs4proc.c +147 -0

163 lines not on this page · raw message

fs/nfs/nfs4xdr.c +35 -11

72 lines not on this page · raw message

include/linux/nfs_xdr.h +4 -0
index 104b62f..db5a1bc 100644
@@ -1040,14 +1040,18 @@ struct nfs4_fs_locations {
 struct nfs4_fs_locations_arg {
 	struct nfs4_sequence_args	seq_args;
 	const struct nfs_fh *dir_fh;
+	const struct nfs_fh *fh;
 	const struct qstr *name;
 	struct page *page;
 	const u32 *bitmask;
+	clientid4 clientid;
+	unsigned char migration:1, renew:1;
 };
 
 struct nfs4_fs_locations_res {
 	struct nfs4_sequence_res	seq_res;
 	struct nfs4_fs_locations       *fs_locations;
+	unsigned char			migration:1, renew:1;
 };
 
 struct nfs4_secinfo4 {
#26 lore raw

PATCH 15/19 NFS: Add basic migration support to state manager thread

In reply to Chuck Lever

Migration recovery and state recovery must be serialized, so handle both in the state manager thread.

---
 fs/nfs/nfs4_fs.h          |    2 
 fs/nfs/nfs4client.c       |    1 
 fs/nfs/nfs4state.c        |  186 +++++++++++++++++++++++++++++++++++++++++++++
 include/linux/nfs_fs_sb.h |    6 +
 4 files changed, 195 insertions(+)
fs/nfs/nfs4_fs.h +2 -0
index 66c34c4..6391b94 100644
@@ -30,6 +30,7 @@ enum nfs4_client_state {
 	NFS4CLNT_PURGE_STATE,
 	NFS4CLNT_BIND_CONN_TO_SESSION,
 	NFS4CLNT_BLOCK_XPRT,
+	NFS4CLNT_MOVED,
 };
 
 #define NFS4_RENEW_TIMEOUT		0x01
@@ -348,6 +349,7 @@ extern int nfs4_client_recover_expired_lease(struct nfs_client *clp);
 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(struct inode *);
 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 **);
fs/nfs/nfs4client.c +1 -0
index dadd118..5050349 100644
@@ -76,6 +76,7 @@ struct nfs_client *nfs4_alloc_client(const struct nfs_client_initdata *cl_init)
 		init_completion(&clp->cl_xpcomplete);
 		rpc_init_wait_queue(&clp->cl_xpwaitq, "NFSv4.0 xprt");
 	}
+	clp->cl_mig_gen = 1;
 	return clp;
 
 error:
fs/nfs/nfs4state.c +186 -0

204 lines not on this page · raw message

include/linux/nfs_fs_sb.h +6 -0
index 84d8f0c..4cfc58a 100644
@@ -77,6 +77,7 @@ struct nfs_client {
 	char			cl_ipaddr[48];
 	u32			cl_cb_ident;	/* v4.0 callback identifier */
 	const struct nfs4_minor_version_ops *cl_mvops;
+	unsigned long		cl_mig_gen;
 
 	atomic_t		cl_xppending;
 	struct completion	cl_xpcomplete;
@@ -174,6 +175,11 @@ struct nfs_server {
 	struct list_head	state_owners_lru;
 	struct list_head	layouts;
 	struct list_head	delegations;
+
+	unsigned long		mig_gen;
+	unsigned long		mig_status;
+#define NFS_MIG_IN_TRANSITION		(1)
+
 	void (*destroy)(struct nfs_server *);
 
 	atomic_t active; /* Keep trace of any activity to this server */
#27 lore raw

PATCH 16/19 NFS: Add migration recovery callouts in nfs4proc.c

In reply to Chuck Lever

When the server returns NFS4ERR_MOVED, trigger the new migration recovery logic in the state manager.

---
 fs/nfs/nfs4proc.c |   56 +++++++++++++++++++++++++++++++++++++++++++----------
 1 file changed, 45 insertions(+), 11 deletions(-)
fs/nfs/nfs4proc.c +45 -11
index c849721..b75629a 100644
@@ -275,10 +275,17 @@ static int nfs4_delay(struct rpc_clnt *clnt, long *timeout)
 	return res;
 }
 
-/* This is the error handling routine for processes that are allowed
- * to sleep.
+/**
+ * nfs4_handle_exception - Common error handling for callers allowed to sleep
+ *
+ * @server: local state context for the server
+ * @errorcode: NFS4ERR value returned from the server
+ * @exception: exception handling state
+ *
+ * Returns zero on success, or a negative errno value.
  */
-static int nfs4_handle_exception(struct nfs_server *server, int errorcode, struct nfs4_exception *exception)
+static int nfs4_handle_exception(struct nfs_server *server, int errorcode,
+				 struct nfs4_exception *exception)
 {
 	struct nfs_client *clp = server->nfs_client;
 	struct nfs4_state *state = exception->state;
@@ -338,6 +345,11 @@ static int nfs4_handle_exception(struct nfs_server *server, int errorcode, struc
 			nfs4_schedule_session_recovery(clp->cl_session, errorcode);
 			goto wait_on_recovery;
 #endif /* defined(CONFIG_NFS_V4_1) */
+		case -NFS4ERR_MOVED:
+			ret = nfs4_schedule_migration_recovery(inode);
+			if (ret < 0)
+				break;
+			goto wait_on_recovery;
 		case -NFS4ERR_FILE_OPEN:
 			if (exception->timeout > HZ) {
 				/* We have retried a decent amount, time to
@@ -2763,11 +2775,16 @@ static int nfs4_get_referral(struct rpc_clnt *client, struct inode *dir,
 	status = nfs4_proc_fs_locations(client, dir, name, locations, page);
 	if (status != 0)
 		goto out;
-	/* Make sure server returned a different fsid for the referral */
+
+	/*
+	 * If the fsid didn't change, this is a migration event, not a
+	 * referral.  Cause us to drop into the exception handler, which
+	 * will kick off migration recovery.
+	 */
 	if (nfs_fsid_equal(&NFS_SERVER(dir)->fsid, &locations->fattr.fsid)) {
 		dprintk("%s: server did not return a different fsid for"
 			" a referral at %s\n", __func__, name->name);
-		status = -EIO;
+		status = -NFS4ERR_MOVED;
 		goto out;
 	}
 	/* Fixup attributes for the nfs_lookup() call to nfs_fhget() */
@@ -4263,8 +4280,18 @@ static int nfs4_proc_set_acl(struct inode *inode, const void *buf, size_t buflen
 	return err;
 }
 
-static int
-nfs4_async_handle_error(struct rpc_task *task, const struct nfs_server *server, struct nfs4_state *state)
+/**
+ * nfs4_async_handle_error - Common error handling for callers who cannot sleep
+ *
+ * @task: active RPC task
+ * @server: local state for the server
+ * @state: NFSv4 state for active operation
+ *
+ * Returns zero on success, or a negative errno value.
+ */
+static int nfs4_async_handle_error(struct rpc_task *task,
+				   const struct nfs_server *server,
+				   struct nfs4_state *state)
 {
 	struct nfs_client *clp = server->nfs_client;
 
@@ -4306,16 +4333,22 @@ nfs4_async_handle_error(struct rpc_task *task, const struct nfs_server *server,
 			task->tk_status = 0;
 			return -EAGAIN;
 #endif /* CONFIG_NFS_V4_1 */
+		case -NFS4ERR_MOVED:
+			rpc_sleep_on(&clp->cl_rpcwaitq, task, NULL);
+			if (nfs4_schedule_migration_recovery(state->inode) < 0)
+				goto stateid_invalid;
+			if (test_bit(NFS4CLNT_MANAGER_RUNNING,
+							&clp->cl_state) == 0)
+				rpc_wake_up_queued_task(&clp->cl_rpcwaitq,
+									task);
+			goto restart_call;
 		case -NFS4ERR_DELAY:
 			nfs_inc_server_stats(server, NFSIOS_DELAY);
 		case -NFS4ERR_GRACE:
 			rpc_delay(task, NFS4_POLL_RETRY_MAX);
-			task->tk_status = 0;
-			return -EAGAIN;
 		case -NFS4ERR_RETRY_UNCACHED_REP:
 		case -NFS4ERR_OLD_STATEID:
-			task->tk_status = 0;
-			return -EAGAIN;
+			goto restart_call;
 	}
 	task->tk_status = nfs4_map_errors(task->tk_status);
 	return 0;
@@ -4326,6 +4359,7 @@ wait_on_recovery:
 	rpc_sleep_on(&clp->cl_rpcwaitq, task, NULL);
 	if (test_bit(NFS4CLNT_MANAGER_RUNNING, &clp->cl_state) == 0)
 		rpc_wake_up_queued_task(&clp->cl_rpcwaitq, task);
+restart_call:
 	task->tk_status = 0;
 	return -EAGAIN;
 }
#28 lore raw

PATCH 17/19 NFS: Add method to detect whether an FSID is still on the server

In reply to Chuck Lever

Introduce a mechanism for probing a server to determine if an FSID is present or absent.

The on-the-wire is different between minor version 0 and 1. Minor version 0 appends a RENEW operation to identify which client ID is probing. Minor version 1 has a SEQUENCE operation in the compound which effectively does the same.

---
 fs/nfs/nfs4_fs.h        |    2 +
 fs/nfs/nfs4proc.c       |  117 +++++++++++++++++++++++++++++++++++++++++++++++
 fs/nfs/nfs4xdr.c        |   69 +++++++++++++++++++++++++++-
 include/linux/nfs4.h    |    1 
 include/linux/nfs_xdr.h |   13 +++++
 5 files changed, 200 insertions(+), 2 deletions(-)
fs/nfs/nfs4_fs.h +2 -0
index 6391b94..77313db 100644
@@ -205,6 +205,7 @@ struct nfs4_state_maintenance_ops {
 
 struct nfs4_mig_recovery_ops {
 	int (*get_locations)(struct inode *, struct nfs4_fs_locations *, struct page *);
+	int (*fsid_present)(struct inode *);
 };
 
 extern const struct dentry_operations nfs4_dentry_operations;
@@ -238,6 +239,7 @@ extern int nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *fh
 extern int nfs4_proc_fs_locations(struct rpc_clnt *, struct inode *, const struct qstr *,
 				  struct nfs4_fs_locations *, struct page *);
 extern int nfs4_proc_get_locations(struct inode *, struct nfs4_fs_locations *, struct page *page);
+extern int nfs4_proc_fsid_present(struct inode *);
 extern struct rpc_clnt *nfs4_proc_lookup_mountpoint(struct inode *, struct qstr *,
 			    struct nfs_fh *, struct nfs_fattr *);
 extern int nfs4_proc_secinfo(struct inode *, const struct qstr *, struct nfs4_secinfo_flavors *);
fs/nfs/nfs4proc.c +117 -0

134 lines not on this page · raw message

fs/nfs/nfs4xdr.c +67 -2

108 lines not on this page · raw message

include/linux/nfs4.h +1 -0
index 7b8fc73..043d009 100644
@@ -438,6 +438,7 @@ enum {
 	NFSPROC4_CLNT_FS_LOCATIONS,
 	NFSPROC4_CLNT_RELEASE_LOCKOWNER,
 	NFSPROC4_CLNT_SECINFO,
+	NFSPROC4_CLNT_FSID_PRESENT,
 
 	/* nfs41 */
 	NFSPROC4_CLNT_EXCHANGE_ID,
include/linux/nfs_xdr.h +13 -0
index db5a1bc..9f1867b 100644
@@ -1075,6 +1075,19 @@ struct nfs4_secinfo_res {
 	struct nfs4_secinfo_flavors	*flavors;
 };
 
+struct nfs4_fsid_present_arg {
+	struct nfs4_sequence_args	seq_args;
+	const struct nfs_fh		*fh;
+	clientid4			clientid;
+	unsigned char			renew:1;
+};
+
+struct nfs4_fsid_present_res {
+	struct nfs4_sequence_res	seq_res;
+	struct nfs_fh			*fh;
+	unsigned char			renew:1;
+};
+
 #endif /* CONFIG_NFS_V4 */
 
 struct nfstime4 {
#29 lore raw

PATCH 18/19 NFS: Implement support for NFS4ERR_LEASE_MOVED

In reply to Chuck Lever

To recover from NFS4ERR_LEASE_MOVED, walk the cl_superblocks list and invoke nfs4_try_migration() on each server's root file handle if that FSID is no longer present on the server. The FSID presence check also informs servers that this client has recognized the LEASE_MOVED condition and therefore should no longer receive NFS4ERR_LEASE_MOVED.

Minor version 1 servers set a bit flag to signal LEASE_MOVED rather than returning an NFS4ERR status code, as minor version 0 servers do. Our client must recognize this flag and kick off migration recovery. The flag is detected when processing the SEQUENCE reply in each mv1 compound.

Note also that with minor version 0, the asynchronous lease RENEW heartbeat can return NFS4ERR_LEASE_MOVED. Error recovery logic for async RENEW is a separate code path from the generic NFS proc paths, so it must be updated to handle LEASE_MOVED as well.

---
 fs/nfs/nfs4_fs.h   |    2 +
 fs/nfs/nfs4proc.c  |   19 +++++++++++++-
 fs/nfs/nfs4state.c |   70 ++++++++++++++++++++++++++++++++++++++++++++++++++--
 3 files changed, 87 insertions(+), 4 deletions(-)
fs/nfs/nfs4_fs.h +2 -0
index 77313db..9f2fe35 100644
@@ -31,6 +31,7 @@ enum nfs4_client_state {
 	NFS4CLNT_BIND_CONN_TO_SESSION,
 	NFS4CLNT_BLOCK_XPRT,
 	NFS4CLNT_MOVED,
+	NFS4CLNT_LEASE_MOVED,
 };
 
 #define NFS4_RENEW_TIMEOUT		0x01
@@ -352,6 +353,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(struct inode *);
+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 **);
fs/nfs/nfs4proc.c +18 -1
index a870a59..80afb9f 100644
@@ -350,6 +350,9 @@ static int nfs4_handle_exception(struct nfs_server *server, int errorcode,
 			if (ret < 0)
 				break;
 			goto wait_on_recovery;
+		case -NFS4ERR_LEASE_MOVED:
+			nfs4_schedule_lease_moved_recovery(clp);
+			goto wait_on_recovery;
 		case -NFS4ERR_FILE_OPEN:
 			if (exception->timeout > HZ) {
 				/* We have retried a decent amount, time to
@@ -3937,7 +3940,13 @@ static void nfs4_renew_done(struct rpc_task *task, void *calldata)
 	struct nfs_client *clp = data->client;
 	unsigned long timestamp = data->timestamp;
 
-	if (task->tk_status < 0) {
+	switch (task->tk_status) {
+	case 0:
+		break;
+	case -NFS4ERR_LEASE_MOVED:
+		nfs4_schedule_lease_moved_recovery(clp);
+		break;
+	default:
 		/* Unless we're shutting down, schedule state recovery! */
 		if (test_bit(NFS_CS_RENEWD, &clp->cl_res_state) == 0)
 			return;
@@ -4342,6 +4351,14 @@ static int nfs4_async_handle_error(struct rpc_task *task,
 				rpc_wake_up_queued_task(&clp->cl_rpcwaitq,
 									task);
 			goto restart_call;
+		case -NFS4ERR_LEASE_MOVED:
+			rpc_sleep_on(&clp->cl_rpcwaitq, task, NULL);
+			nfs4_schedule_lease_moved_recovery(clp);
+			if (test_bit(NFS4CLNT_MANAGER_RUNNING,
+							&clp->cl_state) == 0)
+				rpc_wake_up_queued_task(&clp->cl_rpcwaitq,
+									task);
+			goto restart_call;
 		case -NFS4ERR_DELAY:
 			nfs_inc_server_stats(server, NFSIOS_DELAY);
 		case -NFS4ERR_GRACE:
fs/nfs/nfs4state.c +67 -3

102 lines not on this page · raw message

#30 lore raw

PATCH 19/19 NFS: Set EXCHGID4_FLAG_SUPP_MOVED_MIGR

In reply to Chuck Lever

We have all the pieces in place to support NFSv4 minor version 1 migration in our client. The client should advertise its support for migration.

Note that v4.1 migration is untested. There are no servers in the wild that support NFSv4.1 migration.

---
 fs/nfs/nfs4proc.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
fs/nfs/nfs4proc.c +6 -3
index 80afb9f..8d0fab7 100644
@@ -5876,8 +5876,10 @@ out:
 	return status;
 }
 
-/*
- * nfs4_proc_exchange_id()
+/**
+ * nfs4_proc_exchange_id - Instantiate client ID
+ * @clp: server state
+ * @cred: RPC credential to use for this call
  *
  * Returns zero, a negative errno, or a negative NFS4ERR status code.
  *
@@ -5892,7 +5894,8 @@ int nfs4_proc_exchange_id(struct nfs_client *clp, struct rpc_cred *cred)
 	struct nfs41_exchange_id_args args = {
 		.verifier = &verifier,
 		.client = clp,
-		.flags = EXCHGID4_FLAG_SUPP_MOVED_REFER,
+		.flags = EXCHGID4_FLAG_SUPP_MOVED_REFER |
+			 EXCHGID4_FLAG_SUPP_MOVED_MIGR,
 	};
 	struct nfs41_exchange_id_res res = {
 		0