From: Anna Schumaker <anna@kernel.org>
To: linux-nfs@vger.kernel.org, trond.myklebust@hammerspace.com
Cc: anna@kernel.org
Subject: [PATCH v2 12/14] NFS: Move sequence slot operations into minorversion operations
Date: Mon, 26 Jan 2026 15:39:36 -0500 [thread overview]
Message-ID: <20260126203938.450304-13-anna@kernel.org> (raw)
In-Reply-To: <20260126203938.450304-1-anna@kernel.org>
From: Anna Schumaker <anna.schumaker@oracle.com>
At the same time, I move the NFS v4.0 functions into nfs40proc.c to keep
v4.0 features together in their own files.
Signed-off-by: Anna Schumaker <anna.schumaker@oracle.com>
---
fs/nfs/nfs40proc.c | 30 ++++++++++++
fs/nfs/nfs4_fs.h | 8 +++-
fs/nfs/nfs4proc.c | 103 +++++++++++++---------------------------
include/linux/nfs_xdr.h | 1 +
4 files changed, 70 insertions(+), 72 deletions(-)
diff --git a/fs/nfs/nfs40proc.c b/fs/nfs/nfs40proc.c
index 9b5b57170471..32a2a1a2b216 100644
--- a/fs/nfs/nfs40proc.c
+++ b/fs/nfs/nfs40proc.c
@@ -6,6 +6,7 @@
#include "internal.h"
#include "nfs4_fs.h"
#include "nfs40.h"
+#include "nfs4session.h"
#include "nfs4trace.h"
static void nfs40_call_sync_prepare(struct rpc_task *task, void *calldata)
@@ -21,6 +22,28 @@ static void nfs40_call_sync_done(struct rpc_task *task, void *calldata)
nfs4_sequence_done(task, data->seq_res);
}
+static void nfs40_sequence_free_slot(struct nfs4_sequence_res *res)
+{
+ struct nfs4_slot *slot = res->sr_slot;
+ struct nfs4_slot_table *tbl;
+
+ tbl = slot->table;
+ spin_lock(&tbl->slot_tbl_lock);
+ if (!nfs41_wake_and_assign_slot(tbl, slot))
+ nfs4_free_slot(tbl, slot);
+ spin_unlock(&tbl->slot_tbl_lock);
+
+ res->sr_slot = NULL;
+}
+
+static int nfs40_sequence_done(struct rpc_task *task,
+ struct nfs4_sequence_res *res)
+{
+ if (res->sr_slot != NULL)
+ nfs40_sequence_free_slot(res);
+ return 1;
+}
+
static void nfs40_clear_delegation_stateid(struct nfs4_state *state)
{
if (rcu_access_pointer(NFS_I(state->inode)->delegation) != NULL)
@@ -317,6 +340,12 @@ static const struct rpc_call_ops nfs40_call_sync_ops = {
.rpc_call_done = nfs40_call_sync_done,
};
+static const struct nfs4_sequence_slot_ops nfs40_sequence_slot_ops = {
+ .process = nfs40_sequence_done,
+ .done = nfs40_sequence_done,
+ .free_slot = nfs40_sequence_free_slot,
+};
+
static const struct nfs4_state_recovery_ops nfs40_reboot_recovery_ops = {
.owner_flag_bit = NFS_OWNER_RECLAIM_REBOOT,
.state_flag_bit = NFS_STATE_RECLAIM_REBOOT,
@@ -358,6 +387,7 @@ const struct nfs4_minor_version_ops nfs_v4_0_minor_ops = {
.test_and_free_expired = nfs40_test_and_free_expired_stateid,
.alloc_seqid = nfs_alloc_seqid,
.call_sync_ops = &nfs40_call_sync_ops,
+ .sequence_slot_ops = &nfs40_sequence_slot_ops,
.reboot_recovery_ops = &nfs40_reboot_recovery_ops,
.nograce_recovery_ops = &nfs40_nograce_recovery_ops,
.state_renewal_ops = &nfs40_state_renewal_ops,
diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h
index c7c466fa5434..6cb2c1d9d691 100644
--- a/fs/nfs/nfs4_fs.h
+++ b/fs/nfs/nfs4_fs.h
@@ -73,6 +73,7 @@ struct nfs4_minor_version_ops {
void (*session_trunk)(struct rpc_clnt *clnt,
struct rpc_xprt *xprt, void *data);
const struct rpc_call_ops *call_sync_ops;
+ const struct nfs4_sequence_slot_ops *sequence_slot_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;
@@ -256,6 +257,12 @@ struct nfs4_add_xprt_data {
const struct cred *cred;
};
+struct nfs4_sequence_slot_ops {
+ int (*process)(struct rpc_task *, struct nfs4_sequence_res *);
+ int (*done)(struct rpc_task *, struct nfs4_sequence_res *);
+ void (*free_slot)(struct nfs4_sequence_res *);
+};
+
struct nfs4_state_maintenance_ops {
int (*sched_state_renewal)(struct nfs_client *, const struct cred *, unsigned);
const struct cred * (*get_state_renewal_cred)(struct nfs_client *);
@@ -311,7 +318,6 @@ extern int nfs4_call_sync_sequence(struct rpc_clnt *clnt,
struct nfs4_sequence_res *res);
extern void nfs4_init_sequence(struct nfs_client *clp, struct nfs4_sequence_args *,
struct nfs4_sequence_res *, int, int);
-extern int nfs40_sequence_done(struct rpc_task *task, struct nfs4_sequence_res *res);
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);
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index a8cc3d1b9416..eaf2e5f5cf55 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -780,28 +780,7 @@ void nfs4_init_sequence(struct nfs_client *clp,
args->sa_privileged = privileged;
res->sr_slot = NULL;
-}
-
-static void nfs40_sequence_free_slot(struct nfs4_sequence_res *res)
-{
- struct nfs4_slot *slot = res->sr_slot;
- struct nfs4_slot_table *tbl;
-
- tbl = slot->table;
- spin_lock(&tbl->slot_tbl_lock);
- if (!nfs41_wake_and_assign_slot(tbl, slot))
- nfs4_free_slot(tbl, slot);
- spin_unlock(&tbl->slot_tbl_lock);
-
- res->sr_slot = NULL;
-}
-
-int nfs40_sequence_done(struct rpc_task *task,
- struct nfs4_sequence_res *res)
-{
- if (res->sr_slot != NULL)
- nfs40_sequence_free_slot(res);
- return 1;
+ res->sr_slot_ops = clp->cl_mvops->sequence_slot_ops;
}
#if defined(CONFIG_NFS_V4_1)
@@ -1020,35 +999,6 @@ int nfs41_sequence_done(struct rpc_task *task, struct nfs4_sequence_res *res)
}
EXPORT_SYMBOL_GPL(nfs41_sequence_done);
-static int nfs4_sequence_process(struct rpc_task *task, struct nfs4_sequence_res *res)
-{
- if (res->sr_slot == NULL)
- return 1;
- if (res->sr_slot->table->session != NULL)
- return nfs41_sequence_process(task, res);
- return nfs40_sequence_done(task, res);
-}
-
-static void nfs4_sequence_free_slot(struct nfs4_sequence_res *res)
-{
- if (res->sr_slot != NULL) {
- if (res->sr_slot->table->session != NULL)
- nfs41_sequence_free_slot(res);
- else
- nfs40_sequence_free_slot(res);
- }
-}
-
-int nfs4_sequence_done(struct rpc_task *task, struct nfs4_sequence_res *res)
-{
- if (res->sr_slot == NULL)
- return 1;
- if (!res->sr_slot->table->session)
- return nfs40_sequence_done(task, res);
- return nfs41_sequence_done(task, res);
-}
-EXPORT_SYMBOL_GPL(nfs4_sequence_done);
-
static void nfs41_call_sync_prepare(struct rpc_task *task, void *calldata)
{
struct nfs4_call_sync_data *data = calldata;
@@ -1071,25 +1021,6 @@ static const struct rpc_call_ops nfs41_call_sync_ops = {
.rpc_call_done = nfs41_call_sync_done,
};
-#else /* !CONFIG_NFS_V4_1 */
-
-static int nfs4_sequence_process(struct rpc_task *task, struct nfs4_sequence_res *res)
-{
- return nfs40_sequence_done(task, res);
-}
-
-static void nfs4_sequence_free_slot(struct nfs4_sequence_res *res)
-{
- if (res->sr_slot != NULL)
- nfs40_sequence_free_slot(res);
-}
-
-int nfs4_sequence_done(struct rpc_task *task,
- struct nfs4_sequence_res *res)
-{
- return nfs40_sequence_done(task, res);
-}
-EXPORT_SYMBOL_GPL(nfs4_sequence_done);
#endif /* !CONFIG_NFS_V4_1 */
@@ -1113,6 +1044,28 @@ void nfs4_sequence_attach_slot(struct nfs4_sequence_args *args,
res->sr_slot = slot;
}
+static void nfs4_sequence_free_slot(struct nfs4_sequence_res *res)
+{
+ if (res->sr_slot != NULL)
+ res->sr_slot_ops->free_slot(res);
+}
+
+static int nfs4_sequence_process(struct rpc_task *task, struct nfs4_sequence_res *res)
+{
+ if (res->sr_slot == NULL)
+ return 1;
+ return res->sr_slot_ops->process(task, res);
+}
+
+int nfs4_sequence_done(struct rpc_task *task, struct nfs4_sequence_res *res)
+{
+ if (res->sr_slot == NULL)
+ return 1;
+ return res->sr_slot_ops->done(task, res);
+}
+EXPORT_SYMBOL_GPL(nfs4_sequence_done);
+
+
int nfs4_setup_sequence(struct nfs_client *client,
struct nfs4_sequence_args *args,
struct nfs4_sequence_res *res,
@@ -2447,7 +2400,7 @@ static void nfs4_open_confirm_done(struct rpc_task *task, void *calldata)
{
struct nfs4_opendata *data = calldata;
- nfs40_sequence_done(task, &data->c_res.seq_res);
+ data->c_res.seq_res.sr_slot_ops->done(task, &data->c_res.seq_res);
data->rpc_status = task->tk_status;
if (data->rpc_status == 0) {
@@ -10508,6 +10461,12 @@ bool nfs4_match_stateid(const nfs4_stateid *s1,
#if defined(CONFIG_NFS_V4_1)
+static const struct nfs4_sequence_slot_ops nfs41_sequence_slot_ops = {
+ .process = nfs41_sequence_process,
+ .done = nfs41_sequence_done,
+ .free_slot = nfs41_sequence_free_slot,
+};
+
static const struct nfs4_state_recovery_ops nfs41_reboot_recovery_ops = {
.owner_flag_bit = NFS_OWNER_RECLAIM_REBOOT,
.state_flag_bit = NFS_STATE_RECLAIM_REBOOT,
@@ -10562,6 +10521,7 @@ static const struct nfs4_minor_version_ops nfs_v4_1_minor_ops = {
.alloc_seqid = nfs_alloc_no_seqid,
.session_trunk = nfs4_test_session_trunk,
.call_sync_ops = &nfs41_call_sync_ops,
+ .sequence_slot_ops = &nfs41_sequence_slot_ops,
.reboot_recovery_ops = &nfs41_reboot_recovery_ops,
.nograce_recovery_ops = &nfs41_nograce_recovery_ops,
.state_renewal_ops = &nfs41_state_renewal_ops,
@@ -10598,6 +10558,7 @@ static const struct nfs4_minor_version_ops nfs_v4_2_minor_ops = {
.find_root_sec = nfs41_find_root_sec,
.free_lock_state = nfs41_free_lock_state,
.call_sync_ops = &nfs41_call_sync_ops,
+ .sequence_slot_ops = &nfs41_sequence_slot_ops,
.test_and_free_expired = nfs41_test_and_free_expired_stateid,
.alloc_seqid = nfs_alloc_no_seqid,
.session_trunk = nfs4_test_session_trunk,
diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h
index 79fe2dfb470f..2aa4e38af57a 100644
--- a/include/linux/nfs_xdr.h
+++ b/include/linux/nfs_xdr.h
@@ -209,6 +209,7 @@ struct nfs4_sequence_args {
};
struct nfs4_sequence_res {
+ const struct nfs4_sequence_slot_ops *sr_slot_ops;
struct nfs4_slot *sr_slot; /* slot used to send request */
unsigned long sr_timestamp;
int sr_status; /* sequence operation status */
--
2.52.0
next prev 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 ` [PATCH v2 05/14] NFS: Split out the nfs40_mig_recovery_ops to nfs40proc.c Anna Schumaker
2026-01-26 20:39 ` [PATCH v2 06/14] NFS: Move the NFS v4.0 minor version ops into nfs40proc.c 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 ` Anna Schumaker [this message]
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-13-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