Linux NFS development
 help / color / mirror / Atom feed
From: Anna Schumaker <anna@kernel.org>
To: linux-nfs@vger.kernel.org, trond.myklebust@hammerspace.com
Cc: anna@kernel.org
Subject: [PATCH v2 05/14] NFS: Split out the nfs40_mig_recovery_ops to nfs40proc.c
Date: Mon, 26 Jan 2026 15:39:29 -0500	[thread overview]
Message-ID: <20260126203938.450304-6-anna@kernel.org> (raw)
In-Reply-To: <20260126203938.450304-1-anna@kernel.org>

From: Anna Schumaker <anna.schumaker@oracle.com>

Signed-off-by: Anna Schumaker <anna.schumaker@oracle.com>
---
 fs/nfs/nfs40.h     |   1 +
 fs/nfs/nfs40proc.c | 101 +++++++++++++++++++++++++++++++++++++++
 fs/nfs/nfs4_fs.h   |   6 +++
 fs/nfs/nfs4proc.c  | 115 +++------------------------------------------
 4 files changed, 114 insertions(+), 109 deletions(-)

diff --git a/fs/nfs/nfs40.h b/fs/nfs/nfs40.h
index fd606b4a044a..a04fb2390fa7 100644
--- a/fs/nfs/nfs40.h
+++ b/fs/nfs/nfs40.h
@@ -8,6 +8,7 @@ extern const struct rpc_call_ops nfs40_call_sync_ops;
 extern const struct nfs4_state_recovery_ops nfs40_reboot_recovery_ops;
 extern const struct nfs4_state_recovery_ops nfs40_nograce_recovery_ops;
 extern const struct nfs4_state_maintenance_ops nfs40_state_renewal_ops;
+extern const struct nfs4_mig_recovery_ops nfs40_mig_recovery_ops;
 
 /* nfs40state.c */
 int nfs40_discover_server_trunking(struct nfs_client *clp,
diff --git a/fs/nfs/nfs40proc.c b/fs/nfs/nfs40proc.c
index 96ce463c951b..736e782a27e1 100644
--- a/fs/nfs/nfs40proc.c
+++ b/fs/nfs/nfs40proc.c
@@ -126,6 +126,102 @@ static int nfs4_proc_renew(struct nfs_client *clp, const struct cred *cred)
 	return 0;
 }
 
+/*
+ * This operation also signals the server that this client is
+ * performing migration recovery.  The server can stop returning
+ * NFS4ERR_LEASE_MOVED to this client.  A RENEW operation is
+ * appended to this compound to identify the client ID which is
+ * performing recovery.
+ */
+static int _nfs40_proc_get_locations(struct nfs_server *server,
+				     struct nfs_fh *fhandle,
+				     struct nfs4_fs_locations *locations,
+				     struct page *page, const struct cred *cred)
+{
+	struct rpc_clnt *clnt = server->client;
+	u32 bitmask[2] = {
+		[0] = FATTR4_WORD0_FSID | FATTR4_WORD0_FS_LOCATIONS,
+	};
+	struct nfs4_fs_locations_arg args = {
+		.clientid	= server->nfs_client->cl_clientid,
+		.fh		= fhandle,
+		.page		= page,
+		.bitmask	= bitmask,
+		.migration	= 1,		/* skip LOOKUP */
+		.renew		= 1,		/* append RENEW */
+	};
+	struct nfs4_fs_locations_res res = {
+		.fs_locations	= locations,
+		.migration	= 1,
+		.renew		= 1,
+	};
+	struct rpc_message msg = {
+		.rpc_proc	= &nfs4_procedures[NFSPROC4_CLNT_FS_LOCATIONS],
+		.rpc_argp	= &args,
+		.rpc_resp	= &res,
+		.rpc_cred	= cred,
+	};
+	unsigned long now = jiffies;
+	int status;
+
+	nfs_fattr_init(locations->fattr);
+	locations->server = server;
+	locations->nlocations = 0;
+
+	nfs4_init_sequence(&args.seq_args, &res.seq_res, 0, 1);
+	status = nfs4_call_sync_sequence(clnt, server, &msg,
+					&args.seq_args, &res.seq_res);
+	if (status)
+		return status;
+
+	renew_lease(server, now);
+	return 0;
+}
+
+/*
+ * This operation also signals the server that this client is
+ * performing "lease moved" recovery.  The server can stop
+ * returning NFS4ERR_LEASE_MOVED to this client.  A RENEW operation
+ * is appended to this compound to identify the client ID which is
+ * performing recovery.
+ */
+static int _nfs40_proc_fsid_present(struct inode *inode, const struct cred *cred)
+{
+	struct nfs_server *server = NFS_SERVER(inode);
+	struct nfs_client *clp = NFS_SERVER(inode)->nfs_client;
+	struct rpc_clnt *clnt = server->client;
+	struct nfs4_fsid_present_arg args = {
+		.fh		= NFS_FH(inode),
+		.clientid	= clp->cl_clientid,
+		.renew		= 1,		/* append RENEW */
+	};
+	struct nfs4_fsid_present_res res = {
+		.renew		= 1,
+	};
+	struct rpc_message msg = {
+		.rpc_proc	= &nfs4_procedures[NFSPROC4_CLNT_FSID_PRESENT],
+		.rpc_argp	= &args,
+		.rpc_resp	= &res,
+		.rpc_cred	= cred,
+	};
+	unsigned long now = jiffies;
+	int status;
+
+	res.fh = nfs_alloc_fhandle();
+	if (res.fh == NULL)
+		return -ENOMEM;
+
+	nfs4_init_sequence(&args.seq_args, &res.seq_res, 0, 1);
+	status = nfs4_call_sync_sequence(clnt, server, &msg,
+						&args.seq_args, &res.seq_res);
+	nfs_free_fhandle(res.fh);
+	if (status)
+		return status;
+
+	do_renew_lease(clp, now);
+	return 0;
+}
+
 const struct rpc_call_ops nfs40_call_sync_ops = {
 	.rpc_call_prepare = nfs40_call_sync_prepare,
 	.rpc_call_done = nfs40_call_sync_done,
@@ -153,3 +249,8 @@ const struct nfs4_state_maintenance_ops nfs40_state_renewal_ops = {
 	.get_state_renewal_cred = nfs4_get_renew_cred,
 	.renew_lease = nfs4_proc_renew,
 };
+
+const struct nfs4_mig_recovery_ops nfs40_mig_recovery_ops = {
+	.get_locations = _nfs40_proc_get_locations,
+	.fsid_present = _nfs40_proc_fsid_present,
+};
diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h
index eb89d57a9289..7f1fde3023a5 100644
--- a/fs/nfs/nfs4_fs.h
+++ b/fs/nfs/nfs4_fs.h
@@ -304,9 +304,15 @@ extern int nfs4_async_handle_error(struct rpc_task *task,
 extern int nfs4_call_sync(struct rpc_clnt *, struct nfs_server *,
 			  struct rpc_message *, struct nfs4_sequence_args *,
 			  struct nfs4_sequence_res *, int);
+extern int nfs4_call_sync_sequence(struct rpc_clnt *clnt,
+				   struct nfs_server *server,
+				   struct rpc_message *msg,
+				   struct nfs4_sequence_args *args,
+				   struct nfs4_sequence_res *res);
 extern void nfs4_init_sequence(struct nfs4_sequence_args *, struct nfs4_sequence_res *, int, int);
 extern int nfs4_proc_setclientid(struct nfs_client *, u32, unsigned short, const struct cred *, struct nfs4_setclientid_res *);
 extern int nfs4_proc_setclientid_confirm(struct nfs_client *, struct nfs4_setclientid_res *arg, const struct cred *);
+extern void renew_lease(const struct nfs_server *server, unsigned long timestamp);
 extern int nfs4_proc_get_rootfh(struct nfs_server *, struct nfs_fh *,
 				struct nfs_fattr *, bool);
 extern int nfs4_proc_bind_conn_to_session(struct nfs_client *, const struct cred *cred);
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index a52e985149bf..68c2925c404f 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -762,7 +762,7 @@ void do_renew_lease(struct nfs_client *clp, unsigned long timestamp)
 	spin_unlock(&clp->cl_lock);
 }
 
-static void renew_lease(const struct nfs_server *server, unsigned long timestamp)
+void renew_lease(const struct nfs_server *server, unsigned long timestamp)
 {
 	struct nfs_client *clp = server->nfs_client;
 
@@ -1207,11 +1207,11 @@ static int nfs4_do_call_sync(struct rpc_clnt *clnt,
 	return nfs4_call_sync_custom(&task_setup);
 }
 
-static int nfs4_call_sync_sequence(struct rpc_clnt *clnt,
-				   struct nfs_server *server,
-				   struct rpc_message *msg,
-				   struct nfs4_sequence_args *args,
-				   struct nfs4_sequence_res *res)
+int nfs4_call_sync_sequence(struct rpc_clnt *clnt,
+			    struct nfs_server *server,
+			    struct rpc_message *msg,
+			    struct nfs4_sequence_args *args,
+			    struct nfs4_sequence_res *res)
 {
 	unsigned short task_flags = 0;
 
@@ -8258,58 +8258,6 @@ int nfs4_proc_fs_locations(struct rpc_clnt *client, struct inode *dir,
 	return err;
 }
 
-/*
- * This operation also signals the server that this client is
- * performing migration recovery.  The server can stop returning
- * NFS4ERR_LEASE_MOVED to this client.  A RENEW operation is
- * appended to this compound to identify the client ID which is
- * performing recovery.
- */
-static int _nfs40_proc_get_locations(struct nfs_server *server,
-				     struct nfs_fh *fhandle,
-				     struct nfs4_fs_locations *locations,
-				     struct page *page, const struct cred *cred)
-{
-	struct rpc_clnt *clnt = server->client;
-	u32 bitmask[2] = {
-		[0] = FATTR4_WORD0_FSID | FATTR4_WORD0_FS_LOCATIONS,
-	};
-	struct nfs4_fs_locations_arg args = {
-		.clientid	= server->nfs_client->cl_clientid,
-		.fh		= fhandle,
-		.page		= page,
-		.bitmask	= bitmask,
-		.migration	= 1,		/* skip LOOKUP */
-		.renew		= 1,		/* append RENEW */
-	};
-	struct nfs4_fs_locations_res res = {
-		.fs_locations	= locations,
-		.migration	= 1,
-		.renew		= 1,
-	};
-	struct rpc_message msg = {
-		.rpc_proc	= &nfs4_procedures[NFSPROC4_CLNT_FS_LOCATIONS],
-		.rpc_argp	= &args,
-		.rpc_resp	= &res,
-		.rpc_cred	= cred,
-	};
-	unsigned long now = jiffies;
-	int status;
-
-	nfs_fattr_init(locations->fattr);
-	locations->server = server;
-	locations->nlocations = 0;
-
-	nfs4_init_sequence(&args.seq_args, &res.seq_res, 0, 1);
-	status = nfs4_call_sync_sequence(clnt, server, &msg,
-					&args.seq_args, &res.seq_res);
-	if (status)
-		return status;
-
-	renew_lease(server, now);
-	return 0;
-}
-
 #ifdef CONFIG_NFS_V4_1
 
 /*
@@ -8422,50 +8370,6 @@ int nfs4_proc_get_locations(struct nfs_server *server,
 	return status;
 }
 
-/*
- * This operation also signals the server that this client is
- * performing "lease moved" recovery.  The server can stop
- * returning NFS4ERR_LEASE_MOVED to this client.  A RENEW operation
- * is appended to this compound to identify the client ID which is
- * performing recovery.
- */
-static int _nfs40_proc_fsid_present(struct inode *inode, const struct cred *cred)
-{
-	struct nfs_server *server = NFS_SERVER(inode);
-	struct nfs_client *clp = NFS_SERVER(inode)->nfs_client;
-	struct rpc_clnt *clnt = server->client;
-	struct nfs4_fsid_present_arg args = {
-		.fh		= NFS_FH(inode),
-		.clientid	= clp->cl_clientid,
-		.renew		= 1,		/* append RENEW */
-	};
-	struct nfs4_fsid_present_res res = {
-		.renew		= 1,
-	};
-	struct rpc_message msg = {
-		.rpc_proc	= &nfs4_procedures[NFSPROC4_CLNT_FSID_PRESENT],
-		.rpc_argp	= &args,
-		.rpc_resp	= &res,
-		.rpc_cred	= cred,
-	};
-	unsigned long now = jiffies;
-	int status;
-
-	res.fh = nfs_alloc_fhandle();
-	if (res.fh == NULL)
-		return -ENOMEM;
-
-	nfs4_init_sequence(&args.seq_args, &res.seq_res, 0, 1);
-	status = nfs4_call_sync_sequence(clnt, server, &msg,
-						&args.seq_args, &res.seq_res);
-	nfs_free_fhandle(res.fh);
-	if (status)
-		return status;
-
-	do_renew_lease(clp, now);
-	return 0;
-}
-
 #ifdef CONFIG_NFS_V4_1
 
 /*
@@ -10701,14 +10605,7 @@ static const struct nfs4_state_maintenance_ops nfs41_state_renewal_ops = {
 	.get_state_renewal_cred = nfs4_get_machine_cred,
 	.renew_lease = nfs4_proc_sequence,
 };
-#endif
 
-static const struct nfs4_mig_recovery_ops nfs40_mig_recovery_ops = {
-	.get_locations = _nfs40_proc_get_locations,
-	.fsid_present = _nfs40_proc_fsid_present,
-};
-
-#if defined(CONFIG_NFS_V4_1)
 static const struct nfs4_mig_recovery_ops nfs41_mig_recovery_ops = {
 	.get_locations = _nfs41_proc_get_locations,
 	.fsid_present = _nfs41_proc_fsid_present,
-- 
2.52.0


  parent reply	other threads:[~2026-01-26 20:39 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-26 20:39 [PATCH v2 00/14] NFS: Make NFS v4.0 KConfig-urable Anna Schumaker
2026-01-26 20:39 ` [PATCH v2 01/14] NFS: Move nfs40_call_sync_ops into nfs40proc.c Anna Schumaker
2026-01-26 20:39 ` [PATCH v2 02/14] NFS: Split out the nfs40_reboot_recovery_ops into nfs40client.c Anna Schumaker
2026-01-26 20:39 ` [PATCH v2 03/14] NFS: Split out the nfs40_nograce_recovery_ops into nfs40proc.c Anna Schumaker
2026-01-26 20:39 ` [PATCH v2 04/14] NFS: Split out the nfs40_state_renewal_ops " Anna Schumaker
2026-01-26 20:39 ` Anna Schumaker [this message]
2026-01-26 20:39 ` [PATCH v2 06/14] NFS: Move the NFS v4.0 minor version ops " Anna Schumaker
2026-01-26 20:39 ` [PATCH v2 07/14] NFS: Make the various NFS v4.0 operations static again Anna Schumaker
2026-01-26 20:39 ` [PATCH v2 08/14] NFS: Move nfs40_shutdown_client into nfs40client.c Anna Schumaker
2026-01-26 20:39 ` [PATCH v2 09/14] NFS: Move nfs40_init_client " Anna Schumaker
2026-01-26 20:39 ` [PATCH v2 10/14] NFS: Move NFS v4.0 pathdown recovery " Anna Schumaker
2026-01-26 20:39 ` [PATCH v2 11/14] NFS: Pass a struct nfs_client to nfs4_init_sequence() Anna Schumaker
2026-01-26 20:39 ` [PATCH v2 12/14] NFS: Move sequence slot operations into minorversion operations Anna Schumaker
2026-01-26 20:39 ` [PATCH v2 13/14] NFS: Add a way to disable NFS v4.0 via KConfig Anna Schumaker
2026-01-26 20:39 ` [PATCH v2 14/14] NFS: Merge CONFIG_NFS_V4_1 with CONFIG_NFS_V4 Anna Schumaker
2026-02-13  8:58   ` Re; " Geert Uytterhoeven

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=20260126203938.450304-6-anna@kernel.org \
    --to=anna@kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=trond.myklebust@hammerspace.com \
    /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