From: Anna Schumaker Date: Thu, 20 Nov 2025 20:14:30 +0000 (-0500) Subject: NFS: Move sequence slot operations into minorversion operations X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9c54afc10611638cca9997f472283985b9ca8e42;p=thirdparty%2Fkernel%2Flinux.git NFS: Move sequence slot operations into minorversion operations 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 --- diff --git a/fs/nfs/nfs40proc.c b/fs/nfs/nfs40proc.c index 9b5b571704714..32a2a1a2b2165 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 34cdbf42b8650..a5dd4a8377695 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 574ebefcb4fab..c621294e3f0f4 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) { @@ -10529,6 +10482,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, @@ -10583,6 +10542,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, @@ -10619,6 +10579,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 79fe2dfb470fc..2aa4e38af57a7 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 */