From 0ebe655bd033fd84e312980c9eba199604631e7e Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Wed, 7 Jan 2026 08:27:13 +0100 Subject: NFS: add a separate delegation return list Searching for returnable delegations in the per-server delegations list can be very expensive. While commit e04bbf6b1bbe ("NFS: Avoid quadratic search when freeing delegations.") reduced the overhead a bit, the fact that all the non-returnable delegations have to be searched limits the amount of optimizations that can be done. Fix this by introducing a separate list that only contains delegations scheduled for return. Signed-off-by: Christoph Hellwig Signed-off-by: Anna Schumaker --- include/linux/nfs_fs_sb.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'include/linux') diff --git a/include/linux/nfs_fs_sb.h b/include/linux/nfs_fs_sb.h index c58b870f31ee..e377b8c7086e 100644 --- a/include/linux/nfs_fs_sb.h +++ b/include/linux/nfs_fs_sb.h @@ -259,6 +259,8 @@ struct nfs_server { struct list_head state_owners_lru; struct list_head layouts; struct list_head delegations; + spinlock_t delegations_lock; + struct list_head delegations_return; atomic_long_t nr_active_delegations; unsigned int delegation_hash_mask; struct hlist_head *delegation_hash_table; @@ -266,9 +268,8 @@ struct nfs_server { struct list_head ss_src_copies; unsigned long delegation_flags; -#define NFS4SERV_DELEGRETURN (1) -#define NFS4SERV_DELEGATION_EXPIRED (2) -#define NFS4SERV_DELEGRETURN_DELAYED (3) +#define NFS4SERV_DELEGATION_EXPIRED (1) +#define NFS4SERV_DELEGRETURN_DELAYED (2) unsigned long delegation_gen; unsigned long mig_gen; unsigned long mig_status; -- cgit v1.2.3 From 300ca8123c901605eda5eba33c83dc6eb03d0a3c Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Wed, 7 Jan 2026 08:27:14 +0100 Subject: NFS: return delegations from the end of a LRU when over the watermark Directly returning delegations on close when over the watermark is rather suboptimal as these delegations are much more likely to be reused than those that have been unused for a long time. Switch to returning unused delegations from a new LRU list when we are above the threshold and there are reclaimable delegations instead. Pass over referenced delegations during the first pass to give delegations that aren't in active used by frequently used for stat() or similar another chance to not be instantly reclaimed. This scheme works the same as the referenced flags in the VFS inode and dentry caches. Signed-off-by: Christoph Hellwig Signed-off-by: Anna Schumaker --- fs/nfs/client.c | 1 + fs/nfs/delegation.c | 61 ++++++++++++++++++++++++++++++++++++++++++++--- include/linux/nfs_fs_sb.h | 1 + 3 files changed, 60 insertions(+), 3 deletions(-) (limited to 'include/linux') diff --git a/fs/nfs/client.c b/fs/nfs/client.c index 65b3de91b441..62aece00f810 100644 --- a/fs/nfs/client.c +++ b/fs/nfs/client.c @@ -1062,6 +1062,7 @@ struct nfs_server *nfs_alloc_server(void) INIT_LIST_HEAD(&server->delegations); spin_lock_init(&server->delegations_lock); INIT_LIST_HEAD(&server->delegations_return); + INIT_LIST_HEAD(&server->delegations_lru); INIT_LIST_HEAD(&server->layouts); INIT_LIST_HEAD(&server->state_owners_lru); INIT_LIST_HEAD(&server->ss_copies); diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c index d2d2dd745466..848cb55073fc 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -660,6 +660,60 @@ static int nfs_server_return_marked_delegations(struct nfs_server *server, return err; } +static inline bool nfs_delegations_over_limit(struct nfs_server *server) +{ + return !list_empty_careful(&server->delegations_lru) && + atomic_long_read(&server->nr_active_delegations) > + nfs_delegation_watermark; +} + +static void nfs_delegations_return_from_lru(struct nfs_server *server) +{ + struct nfs_delegation *d, *n; + unsigned int pass = 0; + bool moved = false; + +retry: + spin_lock(&server->delegations_lock); + list_for_each_entry_safe(d, n, &server->delegations_lru, entry) { + if (!nfs_delegations_over_limit(server)) + break; + if (pass == 0 && test_bit(NFS_DELEGATION_REFERENCED, &d->flags)) + continue; + list_move_tail(&d->entry, &server->delegations_return); + moved = true; + } + spin_unlock(&server->delegations_lock); + + /* + * If we are still over the limit, try to reclaim referenced delegations + * as well. + */ + if (pass == 0 && nfs_delegations_over_limit(server)) { + pass++; + goto retry; + } + + if (moved) { + set_bit(NFS4CLNT_DELEGRETURN, &server->nfs_client->cl_state); + nfs4_schedule_state_manager(server->nfs_client); + } +} + +static void nfs_delegation_add_lru(struct nfs_server *server, + struct nfs_delegation *delegation) +{ + spin_lock(&server->delegations_lock); + if (list_empty(&delegation->entry)) { + list_add_tail(&delegation->entry, &server->delegations_lru); + refcount_inc(&delegation->refcount); + } + spin_unlock(&server->delegations_lock); + + if (nfs_delegations_over_limit(server)) + nfs_delegations_return_from_lru(server); +} + static bool nfs_server_clear_delayed_delegations(struct nfs_server *server) { struct nfs_delegation *d; @@ -825,6 +879,7 @@ out_unlock: */ void nfs4_inode_return_delegation_on_close(struct inode *inode) { + struct nfs_server *server = NFS_SERVER(inode); struct nfs_delegation *delegation; bool return_now = false; @@ -832,9 +887,7 @@ void nfs4_inode_return_delegation_on_close(struct inode *inode) if (!delegation) return; - if (test_bit(NFS_DELEGATION_RETURN_IF_CLOSED, &delegation->flags) || - atomic_long_read(&NFS_SERVER(inode)->nr_active_delegations) >= - nfs_delegation_watermark) { + if (test_bit(NFS_DELEGATION_RETURN_IF_CLOSED, &delegation->flags)) { spin_lock(&delegation->lock); if (delegation->inode && list_empty(&NFS_I(inode)->open_files) && @@ -848,6 +901,8 @@ void nfs4_inode_return_delegation_on_close(struct inode *inode) if (return_now) { nfs_clear_verifier_delegated(inode); nfs_end_delegation_return(inode, delegation, 0); + } else { + nfs_delegation_add_lru(server, delegation); } nfs_put_delegation(delegation); } diff --git a/include/linux/nfs_fs_sb.h b/include/linux/nfs_fs_sb.h index e377b8c7086e..bb13a294b69e 100644 --- a/include/linux/nfs_fs_sb.h +++ b/include/linux/nfs_fs_sb.h @@ -261,6 +261,7 @@ struct nfs_server { struct list_head delegations; spinlock_t delegations_lock; struct list_head delegations_return; + struct list_head delegations_lru; atomic_long_t nr_active_delegations; unsigned int delegation_hash_mask; struct hlist_head *delegation_hash_table; -- cgit v1.2.3 From 9c54afc10611638cca9997f472283985b9ca8e42 Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Thu, 20 Nov 2025 15:14:30 -0500 Subject: 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 --- 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(-) (limited to 'include/linux') 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 34cdbf42b865..a5dd4a837769 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 574ebefcb4fa..c621294e3f0f 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 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 */ -- cgit v1.2.3 From 7537db24806fdc3d3ec4fef53babdc22c9219e75 Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Thu, 4 Dec 2025 15:44:33 -0500 Subject: NFS: Merge CONFIG_NFS_V4_1 with CONFIG_NFS_V4 Compiling the NFSv4 module without any minorversion support doesn't make much sense, so this patch sets NFS v4.1 as the default, always enabled NFS version allowing us to replace all the CONFIG_NFS_V4_1s scattered throughout the code with CONFIG_NFS_V4. Signed-off-by: Anna Schumaker --- fs/nfs/Kconfig | 27 +++++---------- fs/nfs/Makefile | 3 +- fs/nfs/callback.c | 13 +------ fs/nfs/callback.h | 3 -- fs/nfs/callback_proc.c | 3 -- fs/nfs/callback_xdr.c | 21 ------------ fs/nfs/client.c | 8 ++--- fs/nfs/internal.h | 12 +++---- fs/nfs/netns.h | 4 +-- fs/nfs/nfs4_fs.h | 36 +------------------- fs/nfs/nfs4client.c | 23 ------------- fs/nfs/nfs4proc.c | 55 ------------------------------ fs/nfs/nfs4session.c | 4 --- fs/nfs/nfs4session.h | 23 ------------- fs/nfs/nfs4state.c | 17 --------- fs/nfs/nfs4trace.c | 2 -- fs/nfs/nfs4trace.h | 16 --------- fs/nfs/nfs4xdr.c | 87 ----------------------------------------------- fs/nfs/pnfs.h | 6 ++-- fs/nfs/read.c | 4 +-- fs/nfs/super.c | 16 ++------- fs/nfs/sysfs.c | 10 +++--- fs/nfs/write.c | 2 +- include/linux/nfs_fs_sb.h | 2 -- include/linux/nfs_xdr.h | 6 +--- 25 files changed, 35 insertions(+), 368 deletions(-) (limited to 'include/linux') diff --git a/fs/nfs/Kconfig b/fs/nfs/Kconfig index 058ed67b98cc..12cb0ca738af 100644 --- a/fs/nfs/Kconfig +++ b/fs/nfs/Kconfig @@ -78,9 +78,10 @@ config NFS_V4 tristate "NFS client support for NFS version 4" depends on NFS_FS select KEYS + select SUNRPC_BACKCHANNEL help - This option enables support for version 4 of the NFS protocol - (RFC 3530) in the kernel's NFS client. + This option enables support for version 4.1 of the NFS protocol + (RFC 5661) in the kernel's NFS client. To mount NFS servers using NFSv4, you also need to install user space programs which can be found in the Linux nfs-utils package, @@ -105,19 +106,9 @@ config NFS_V4_0 If unsure, say N. -config NFS_V4_1 - bool "NFS client support for NFSv4.1" - depends on NFS_V4 - select SUNRPC_BACKCHANNEL - help - This option enables support for minor version 1 of the NFSv4 protocol - (RFC 5661) in the kernel's NFS client. - - If unsure, say N. - config NFS_V4_2 bool "NFS client support for NFSv4.2" - depends on NFS_V4_1 + depends on NFS_V4 help This option enables support for minor version 2 of the NFSv4 protocol in the kernel's NFS client. @@ -126,22 +117,22 @@ config NFS_V4_2 config PNFS_FILE_LAYOUT tristate - depends on NFS_V4_1 + depends on NFS_V4 default NFS_V4 config PNFS_BLOCK tristate - depends on NFS_V4_1 && BLK_DEV_DM + depends on NFS_V4 && BLK_DEV_DM default NFS_V4 config PNFS_FLEXFILE_LAYOUT tristate - depends on NFS_V4_1 + depends on NFS_V4 default NFS_V4 config NFS_V4_1_IMPLEMENTATION_ID_DOMAIN string "NFSv4.1 Implementation ID Domain" - depends on NFS_V4_1 + depends on NFS_V4 default "kernel.org" help This option defines the domain portion of the implementation ID that @@ -153,7 +144,7 @@ config NFS_V4_1_IMPLEMENTATION_ID_DOMAIN config NFS_V4_1_MIGRATION bool "NFSv4.1 client support for migration" - depends on NFS_V4_1 + depends on NFS_V4 default n help This option makes the NFS client advertise to NFSv4.1 servers that diff --git a/fs/nfs/Makefile b/fs/nfs/Makefile index 6a9aaf2f913b..c895521f27f3 100644 --- a/fs/nfs/Makefile +++ b/fs/nfs/Makefile @@ -27,11 +27,10 @@ CFLAGS_nfs4trace.o += -I$(src) nfsv4-y := nfs4proc.o nfs4xdr.o nfs4state.o nfs4renewd.o nfs4super.o nfs4file.o \ delegation.o nfs4idmap.o callback.o callback_xdr.o callback_proc.o \ nfs4namespace.o nfs4getroot.o nfs4client.o nfs4session.o \ - dns_resolve.o nfs4trace.o + dns_resolve.o nfs4trace.o pnfs.o pnfs_dev.o pnfs_nfs.o nfsv4-$(CONFIG_NFS_USE_LEGACY_DNS) += cache_lib.o nfsv4-$(CONFIG_SYSCTL) += nfs4sysctl.o nfsv4-$(CONFIG_NFS_V4_0) += nfs40client.o nfs40proc.o -nfsv4-$(CONFIG_NFS_V4_1) += pnfs.o pnfs_dev.o pnfs_nfs.o nfsv4-$(CONFIG_NFS_V4_2) += nfs42proc.o nfs42xattr.o obj-$(CONFIG_PNFS_FILE_LAYOUT) += filelayout/ diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c index fabda0f6ec1a..6af67bdf0e40 100644 --- a/fs/nfs/callback.c +++ b/fs/nfs/callback.c @@ -87,7 +87,6 @@ nfs4_callback_svc(void *vrqstp) return 0; } -#if defined(CONFIG_NFS_V4_1) static inline void nfs_callback_bc_serv(u32 minorversion, struct rpc_xprt *xprt, struct svc_serv *serv) { @@ -98,12 +97,6 @@ static inline void nfs_callback_bc_serv(u32 minorversion, struct rpc_xprt *xprt, */ xprt->bc_serv = serv; } -#else -static inline void nfs_callback_bc_serv(u32 minorversion, struct rpc_xprt *xprt, - struct svc_serv *serv) -{ -} -#endif /* CONFIG_NFS_V4_1 */ static int nfs_callback_start_svc(int minorversion, struct rpc_xprt *xprt, struct svc_serv *serv) @@ -157,7 +150,7 @@ static int nfs_callback_up_net(int minorversion, struct svc_serv *serv, } ret = 0; - if (!IS_ENABLED(CONFIG_NFS_V4_1) || minorversion == 0) + if (minorversion == 0) ret = nfs4_callback_up_net(serv, net); else if (xprt->ops->bc_setup) set_bc_enabled(serv); @@ -198,10 +191,6 @@ static struct svc_serv *nfs_callback_create_svc(int minorversion) cb_info->users); threadfn = nfs4_callback_svc; -#if !defined(CONFIG_NFS_V4_1) - if (minorversion) - return ERR_PTR(-ENOTSUPP); -#endif serv = svc_create(&nfs4_callback_program, NFS4_CALLBACK_BUFSIZE, threadfn); if (!serv) { diff --git a/fs/nfs/callback.h b/fs/nfs/callback.h index 8809f93d82c0..2a721c422d48 100644 --- a/fs/nfs/callback.h +++ b/fs/nfs/callback.h @@ -65,8 +65,6 @@ struct cb_recallargs { uint32_t truncate; }; -#if defined(CONFIG_NFS_V4_1) - struct referring_call { uint32_t rc_sequenceid; uint32_t rc_slotid; @@ -168,7 +166,6 @@ struct cb_notify_lock_args { extern __be32 nfs4_callback_notify_lock(void *argp, void *resp, struct cb_process_state *cps); -#endif /* CONFIG_NFS_V4_1 */ #ifdef CONFIG_NFS_V4_2 struct cb_offloadargs { struct nfs_fh coa_fh; diff --git a/fs/nfs/callback_proc.c b/fs/nfs/callback_proc.c index 57550020c819..805eb3764186 100644 --- a/fs/nfs/callback_proc.c +++ b/fs/nfs/callback_proc.c @@ -126,8 +126,6 @@ out: return res; } -#if defined(CONFIG_NFS_V4_1) - /* * Lookup a layout inode by stateid * @@ -698,7 +696,6 @@ __be32 nfs4_callback_notify_lock(void *argp, void *resp, return htonl(NFS4_OK); } -#endif /* CONFIG_NFS_V4_1 */ #ifdef CONFIG_NFS_V4_2 static void nfs4_copy_cb_args(struct nfs4_copy_state *cp_state, struct cb_offloadargs *args) diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c index 4254ba3ee7c5..c2fa4a91db26 100644 --- a/fs/nfs/callback_xdr.c +++ b/fs/nfs/callback_xdr.c @@ -30,7 +30,6 @@ (2 + 2 + 3 + 3 + 3 + 3 + 3) * 4) #define CB_OP_RECALL_RES_MAXSZ (CB_OP_HDR_RES_MAXSZ) -#if defined(CONFIG_NFS_V4_1) #define CB_OP_LAYOUTRECALL_RES_MAXSZ (CB_OP_HDR_RES_MAXSZ) #define CB_OP_DEVICENOTIFY_RES_MAXSZ (CB_OP_HDR_RES_MAXSZ) #define CB_OP_SEQUENCE_RES_MAXSZ (CB_OP_HDR_RES_MAXSZ + \ @@ -39,7 +38,6 @@ #define CB_OP_RECALLANY_RES_MAXSZ (CB_OP_HDR_RES_MAXSZ) #define CB_OP_RECALLSLOT_RES_MAXSZ (CB_OP_HDR_RES_MAXSZ) #define CB_OP_NOTIFY_LOCK_RES_MAXSZ (CB_OP_HDR_RES_MAXSZ) -#endif /* CONFIG_NFS_V4_1 */ #ifdef CONFIG_NFS_V4_2 #define CB_OP_OFFLOAD_RES_MAXSZ (CB_OP_HDR_RES_MAXSZ) #endif /* CONFIG_NFS_V4_2 */ @@ -205,7 +203,6 @@ static __be32 decode_recall_args(struct svc_rqst *rqstp, return decode_fh(xdr, &args->fh); } -#if defined(CONFIG_NFS_V4_1) static __be32 decode_layout_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid) { stateid->type = NFS4_LAYOUT_STATEID_TYPE; @@ -521,7 +518,6 @@ static __be32 decode_notify_lock_args(struct svc_rqst *rqstp, return decode_lockowner(xdr, args); } -#endif /* CONFIG_NFS_V4_1 */ #ifdef CONFIG_NFS_V4_2 static __be32 decode_write_response(struct xdr_stream *xdr, struct cb_offloadargs *args) @@ -747,8 +743,6 @@ out: return status; } -#if defined(CONFIG_NFS_V4_1) - static __be32 encode_sessionid(struct xdr_stream *xdr, const struct nfs4_sessionid *sid) { @@ -846,19 +840,6 @@ static void nfs4_cb_free_slot(struct cb_process_state *cps) } } -#else /* CONFIG_NFS_V4_1 */ - -static __be32 -preprocess_nfs41_op(int nop, unsigned int op_nr, struct callback_op **op) -{ - return htonl(NFS4ERR_MINOR_VERS_MISMATCH); -} - -static void nfs4_cb_free_slot(struct cb_process_state *cps) -{ -} -#endif /* CONFIG_NFS_V4_1 */ - #ifdef CONFIG_NFS_V4_2 static __be32 preprocess_nfs42_op(int nop, unsigned int op_nr, struct callback_op **op) @@ -1051,7 +1032,6 @@ static struct callback_op callback_ops[] = { .decode_args = decode_recall_args, .res_maxsize = CB_OP_RECALL_RES_MAXSZ, }, -#if defined(CONFIG_NFS_V4_1) [OP_CB_LAYOUTRECALL] = { .process_op = nfs4_callback_layoutrecall, .decode_args = decode_layoutrecall_args, @@ -1083,7 +1063,6 @@ static struct callback_op callback_ops[] = { .decode_args = decode_notify_lock_args, .res_maxsize = CB_OP_NOTIFY_LOCK_RES_MAXSZ, }, -#endif /* CONFIG_NFS_V4_1 */ #ifdef CONFIG_NFS_V4_2 [OP_CB_OFFLOAD] = { .process_op = nfs4_callback_offload, diff --git a/fs/nfs/client.c b/fs/nfs/client.c index 62aece00f810..6b9a65615a51 100644 --- a/fs/nfs/client.c +++ b/fs/nfs/client.c @@ -1266,11 +1266,9 @@ void nfs_clients_init(struct net *net) INIT_LIST_HEAD(&nn->nfs_volume_list); #if IS_ENABLED(CONFIG_NFS_V4) idr_init(&nn->cb_ident_idr); -#endif -#if IS_ENABLED(CONFIG_NFS_V4_1) INIT_LIST_HEAD(&nn->nfs4_data_server_cache); spin_lock_init(&nn->nfs4_data_server_lock); -#endif +#endif /* CONFIG_NFS_V4 */ spin_lock_init(&nn->nfs_client_lock); nn->boot_time = ktime_get_real(); memset(&nn->rpcstats, 0, sizeof(nn->rpcstats)); @@ -1287,9 +1285,9 @@ void nfs_clients_exit(struct net *net) nfs_cleanup_cb_ident_idr(net); WARN_ON_ONCE(!list_empty(&nn->nfs_client_list)); WARN_ON_ONCE(!list_empty(&nn->nfs_volume_list)); -#if IS_ENABLED(CONFIG_NFS_V4_1) +#if IS_ENABLED(CONFIG_NFS_V4) WARN_ON_ONCE(!list_empty(&nn->nfs4_data_server_cache)); -#endif +#endif /* CONFIG_NFS_V4 */ } #ifdef CONFIG_PROC_FS diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h index e99998e515c0..63e09dfc27a8 100644 --- a/fs/nfs/internal.h +++ b/fs/nfs/internal.h @@ -334,17 +334,13 @@ extern int nfs3_decode_dirent(struct xdr_stream *, #if IS_ENABLED(CONFIG_NFS_V4) extern int nfs4_decode_dirent(struct xdr_stream *, struct nfs_entry *, bool); -#endif -#ifdef CONFIG_NFS_V4_1 extern const u32 nfs41_maxread_overhead; extern const u32 nfs41_maxwrite_overhead; extern const u32 nfs41_maxgetdevinfo_overhead; -#endif /* nfs4proc.c */ -#if IS_ENABLED(CONFIG_NFS_V4) extern const struct rpc_procinfo nfs4_procedures[]; -#endif +#endif /* CONFIG_NFS_V4 */ #ifdef CONFIG_NFS_V4_SECURITY_LABEL extern struct nfs4_label *nfs4_label_alloc(struct nfs_server *server, gfp_t flags); @@ -639,7 +635,7 @@ void nfs_pageio_stop_mirroring(struct nfs_pageio_descriptor *pgio); int nfs_filemap_write_and_wait_range(struct address_space *mapping, loff_t lstart, loff_t lend); -#ifdef CONFIG_NFS_V4_1 +#ifdef CONFIG_NFS_V4 static inline void pnfs_bucket_clear_pnfs_ds_commit_verifiers(struct pnfs_commit_bucket *buckets, unsigned int nbuckets) @@ -660,12 +656,12 @@ void nfs_clear_pnfs_ds_commit_verifiers(struct pnfs_ds_commit_info *cinfo) array->nbuckets); rcu_read_unlock(); } -#else +#else /* CONFIG_NFS_V4 */ static inline void nfs_clear_pnfs_ds_commit_verifiers(struct pnfs_ds_commit_info *cinfo) { } -#endif +#endif /* CONFIG_NFS_V4 */ #ifdef CONFIG_MIGRATION int nfs_migrate_folio(struct address_space *, struct folio *dst, diff --git a/fs/nfs/netns.h b/fs/nfs/netns.h index 6ba3ea39e928..36658579100d 100644 --- a/fs/nfs/netns.h +++ b/fs/nfs/netns.h @@ -31,11 +31,9 @@ struct nfs_net { unsigned short nfs_callback_tcpport; unsigned short nfs_callback_tcpport6; int cb_users[NFS4_MAX_MINOR_VERSION + 1]; -#endif /* CONFIG_NFS_V4 */ -#if IS_ENABLED(CONFIG_NFS_V4_1) struct list_head nfs4_data_server_cache; spinlock_t nfs4_data_server_lock; -#endif /* CONFIG_NFS_V4_1 */ +#endif /* CONFIG_NFS_V4 */ struct nfs_netns_client *nfs_client; spinlock_t nfs_client_lock; ktime_t boot_time; diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h index 5a6728acb589..783df6901b84 100644 --- a/fs/nfs/nfs4_fs.h +++ b/fs/nfs/nfs4_fs.h @@ -18,10 +18,8 @@ #if defined(CONFIG_NFS_V4_2) #define NFS4_MAX_MINOR_VERSION 2 -#elif defined(CONFIG_NFS_V4_1) -#define NFS4_MAX_MINOR_VERSION 1 #else -#define NFS4_MAX_MINOR_VERSION 0 +#define NFS4_MAX_MINOR_VERSION 1 #endif #if IS_ENABLED(CONFIG_NFS_V4) @@ -383,7 +381,6 @@ extern bool nfs4_match_stateid(const nfs4_stateid *s1, const nfs4_stateid *s2); extern int nfs4_find_root_sec(struct nfs_server *server, struct nfs_fh *fhandle, struct nfs_fattr *fattr); -#if defined(CONFIG_NFS_V4_1) extern int nfs41_sequence_done(struct rpc_task *, struct nfs4_sequence_res *); extern int nfs4_proc_create_session(struct nfs_client *, const struct cred *); extern int nfs4_proc_destroy_session(struct nfs4_session *, const struct cred *); @@ -461,31 +458,6 @@ nfs4_state_protect_write(struct nfs_client *clp, struct rpc_clnt **clntp, !test_bit(NFS_SP4_MACH_CRED_COMMIT, &clp->cl_sp4_flags)) hdr->args.stable = NFS_FILE_SYNC; } -#else /* CONFIG_NFS_v4_1 */ -static inline bool -is_ds_only_client(struct nfs_client *clp) -{ - return false; -} - -static inline bool -is_ds_client(struct nfs_client *clp) -{ - return false; -} - -static inline void -nfs4_state_protect(struct nfs_client *clp, unsigned long sp4_flags, - struct rpc_clnt **clntp, struct rpc_message *msg) -{ -} - -static inline void -nfs4_state_protect_write(struct nfs_client *clp, struct rpc_clnt **clntp, - struct rpc_message *msg, struct nfs_pgio_header *hdr) -{ -} -#endif /* CONFIG_NFS_V4_1 */ extern const struct nfs4_minor_version_ops *nfs_v4_minor_ops[]; @@ -518,18 +490,12 @@ int nfs4_discover_server_trunking(struct nfs_client *clp, struct nfs_client **); int nfs40_discover_server_trunking(struct nfs_client *clp, struct nfs_client **, const struct cred *); -#if defined(CONFIG_NFS_V4_1) int nfs41_discover_server_trunking(struct nfs_client *clp, struct nfs_client **, const struct cred *); extern void nfs4_schedule_session_recovery(struct nfs4_session *, int); extern void nfs41_notify_server(struct nfs_client *); bool nfs4_check_serverowner_major_id(struct nfs41_server_owner *o1, struct nfs41_server_owner *o2); -#else -static inline void nfs4_schedule_session_recovery(struct nfs4_session *session, int err) -{ -} -#endif /* CONFIG_NFS_V4_1 */ extern struct nfs4_state_owner *nfs4_get_state_owner(struct nfs_server *, const struct cred *, gfp_t); extern void nfs4_put_state_owner(struct nfs4_state_owner *); diff --git a/fs/nfs/nfs4client.c b/fs/nfs/nfs4client.c index 00b57e55aba8..51cf4a37d652 100644 --- a/fs/nfs/nfs4client.c +++ b/fs/nfs/nfs4client.c @@ -44,7 +44,6 @@ static int nfs_get_cb_ident_idr(struct nfs_client *clp, int minorversion) return ret < 0 ? ret : 0; } -#ifdef CONFIG_NFS_V4_1 /* * Per auth flavor data server rpc clients */ @@ -187,7 +186,6 @@ void nfs41_shutdown_client(struct nfs_client *clp) } } -#endif /* CONFIG_NFS_V4_1 */ struct nfs_client *nfs4_alloc_client(const struct nfs_client_initdata *cl_init) { @@ -217,9 +215,7 @@ struct nfs_client *nfs4_alloc_client(const struct nfs_client_initdata *cl_init) clp->cl_mvops = nfs_v4_minor_ops[cl_init->minorversion]; clp->cl_mig_gen = 1; clp->cl_last_renewal = jiffies; -#if IS_ENABLED(CONFIG_NFS_V4_1) init_waitqueue_head(&clp->cl_lock_waitq); -#endif INIT_LIST_HEAD(&clp->pending_cb_stateids); if (cl_init->minorversion != 0) @@ -332,8 +328,6 @@ static int nfs4_init_callback(struct nfs_client *clp) return 0; } -#if defined(CONFIG_NFS_V4_1) - /** * nfs41_init_client - nfs_client initialization tasks for NFSv4.1+ * @clp: nfs_client to initialize @@ -365,8 +359,6 @@ int nfs41_init_client(struct nfs_client *clp) return 0; } -#endif /* CONFIG_NFS_V4_1 */ - /* * Initialize the minor version specific parts of an NFS4 client record */ @@ -508,7 +500,6 @@ int nfs4_match_client(struct nfs_client *pos, struct nfs_client *new, return 0; } -#ifdef CONFIG_NFS_V4_1 /* * Returns true if the server major ids match */ @@ -637,7 +628,6 @@ out: nfs_put_client(prev); return status; } -#endif /* CONFIG_NFS_V4_1 */ static void nfs4_destroy_server(struct nfs_server *server) { @@ -669,7 +659,6 @@ nfs4_find_client_ident(struct net *net, int cb_ident) return clp; } -#if defined(CONFIG_NFS_V4_1) /* Common match routine for v4.0 and v4.1 callback services */ static bool nfs4_cb_match_client(const struct sockaddr *addr, struct nfs_client *clp, u32 minorversion) @@ -727,16 +716,6 @@ nfs4_find_client_sessionid(struct net *net, const struct sockaddr *addr, return NULL; } -#else /* CONFIG_NFS_V4_1 */ - -struct nfs_client * -nfs4_find_client_sessionid(struct net *net, const struct sockaddr *addr, - struct nfs4_sessionid *sid, u32 minorversion) -{ - return NULL; -} -#endif /* CONFIG_NFS_V4_1 */ - /* * Set up an NFS4 client */ @@ -878,7 +857,6 @@ EXPORT_SYMBOL_GPL(nfs4_set_ds_client); */ static void nfs4_session_limit_rwsize(struct nfs_server *server) { -#ifdef CONFIG_NFS_V4_1 struct nfs4_session *sess; u32 server_resp_sz; u32 server_rqst_sz; @@ -895,7 +873,6 @@ static void nfs4_session_limit_rwsize(struct nfs_server *server) server->rsize = server_resp_sz; if (server->wsize > server_rqst_sz) server->wsize = server_rqst_sz; -#endif /* CONFIG_NFS_V4_1 */ } /* diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 3ee5394aca72..405f3fdbc1f0 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -99,7 +99,6 @@ static int _nfs4_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle, static int nfs4_do_setattr(struct inode *inode, const struct cred *cred, struct nfs_fattr *fattr, struct iattr *sattr, struct nfs_open_context *ctx, struct nfs4_label *ilabel); -#ifdef CONFIG_NFS_V4_1 static struct rpc_task *_nfs41_proc_sequence(struct nfs_client *clp, const struct cred *cred, struct nfs4_slot *slot, @@ -108,7 +107,6 @@ static int nfs41_test_stateid(struct nfs_server *, const nfs4_stateid *, const struct cred *); static int nfs41_free_stateid(struct nfs_server *, nfs4_stateid *, const struct cred *, bool); -#endif #ifdef CONFIG_NFS_V4_SECURITY_LABEL static inline struct nfs4_label * @@ -569,7 +567,6 @@ static int nfs4_do_handle_exception(struct nfs_server *server, case -NFS4ERR_LEASE_MOVED: nfs4_schedule_lease_moved_recovery(clp); goto wait_on_recovery; -#if defined(CONFIG_NFS_V4_1) case -NFS4ERR_BADSESSION: case -NFS4ERR_BADSLOT: case -NFS4ERR_BAD_HIGH_SLOT: @@ -579,7 +576,6 @@ static int nfs4_do_handle_exception(struct nfs_server *server, case -NFS4ERR_SEQ_MISORDERED: /* Handled in nfs41_sequence_process() */ goto wait_on_recovery; -#endif /* defined(CONFIG_NFS_V4_1) */ case -NFS4ERR_FILE_OPEN: if (exception->timeout > HZ) { /* We have retried a decent amount, time to @@ -783,8 +779,6 @@ void nfs4_init_sequence(struct nfs_client *clp, res->sr_slot_ops = clp->cl_mvops->sequence_slot_ops; } -#if defined(CONFIG_NFS_V4_1) - static void nfs41_release_slot(struct nfs4_slot *slot) { struct nfs4_session *session; @@ -1022,8 +1016,6 @@ static const struct rpc_call_ops nfs41_call_sync_ops = { }; -#endif /* !CONFIG_NFS_V4_1 */ - static void nfs41_sequence_res_init(struct nfs4_sequence_res *res) { res->sr_timestamp = jiffies; @@ -1589,7 +1581,6 @@ static void update_open_stateflags(struct nfs4_state *state, fmode_t fmode) nfs4_state_set_mode_locked(state, state->state | fmode); } -#ifdef CONFIG_NFS_V4_1 static bool nfs_open_stateid_recover_openmode(struct nfs4_state *state) { if (state->n_rdonly && !test_bit(NFS_O_RDONLY_STATE, &state->flags)) @@ -1600,7 +1591,6 @@ static bool nfs_open_stateid_recover_openmode(struct nfs4_state *state) return true; return false; } -#endif /* CONFIG_NFS_V4_1 */ static void nfs_state_log_update_open_stateid(struct nfs4_state *state) { @@ -2837,7 +2827,6 @@ void nfs_finish_clear_delegation_stateid(struct nfs4_state *state, nfs_state_clear_delegation(state); } -#if defined(CONFIG_NFS_V4_1) static int nfs41_test_and_free_expired_stateid(struct nfs_server *server, nfs4_stateid *stateid, const struct cred *cred) { @@ -3022,7 +3011,6 @@ static int nfs41_open_expired(struct nfs4_state_owner *sp, struct nfs4_state *st status = nfs4_open_expired(sp, state); return status; } -#endif /* * on an EXCLUSIVE create, the server should send back a bitmask with FATTR4-* @@ -4384,7 +4372,6 @@ out: return status; } -#if IS_ENABLED(CONFIG_NFS_V4_1) static bool should_request_dir_deleg(struct inode *inode) { if (!directory_delegations) @@ -4401,12 +4388,6 @@ static bool should_request_dir_deleg(struct inode *inode) return false; return true; } -#else -static bool should_request_dir_deleg(struct inode *inode) -{ - return false; -} -#endif /* CONFIG_NFS_V4_1 */ static void nfs4_call_getattr_prepare(struct rpc_task *task, void *calldata) { @@ -7552,7 +7533,6 @@ out: return err; } -#if defined(CONFIG_NFS_V4_1) static int nfs41_lock_expired(struct nfs4_state *state, struct file_lock *request) { struct nfs4_lock_state *lsp; @@ -7567,7 +7547,6 @@ static int nfs41_lock_expired(struct nfs4_state *state, struct file_lock *reques return 0; return nfs4_lock_expired(state, request); } -#endif static int _nfs4_proc_setlk(struct nfs4_state *state, int cmd, struct file_lock *request) { @@ -7641,7 +7620,6 @@ nfs4_retry_setlk_simple(struct nfs4_state *state, int cmd, return status; } -#ifdef CONFIG_NFS_V4_1 struct nfs4_lock_waiter { struct inode *inode; struct nfs_lowner owner; @@ -7709,13 +7687,6 @@ nfs4_retry_setlk(struct nfs4_state *state, int cmd, struct file_lock *request) return status; } -#else /* !CONFIG_NFS_V4_1 */ -static inline int -nfs4_retry_setlk(struct nfs4_state *state, int cmd, struct file_lock *request) -{ - return nfs4_retry_setlk_simple(state, cmd, request); -} -#endif static int nfs4_proc_lock(struct file *filp, int cmd, struct file_lock *request) @@ -7848,7 +7819,6 @@ static bool nfs4_xattr_list_nfs4_acl(struct dentry *dentry) return nfs4_server_supports_acls(NFS_SB(dentry->d_sb), NFS4ACL_ACL); } -#if defined(CONFIG_NFS_V4_1) #define XATTR_NAME_NFSV4_DACL "system.nfs4_dacl" static int nfs4_xattr_set_nfs4_dacl(const struct xattr_handler *handler, @@ -7895,8 +7865,6 @@ static bool nfs4_xattr_list_nfs4_sacl(struct dentry *dentry) return nfs4_server_supports_acls(NFS_SB(dentry->d_sb), NFS4ACL_SACL); } -#endif - #ifdef CONFIG_NFS_V4_SECURITY_LABEL static int nfs4_xattr_set_nfs4_label(const struct xattr_handler *handler, @@ -8156,8 +8124,6 @@ int nfs4_proc_fs_locations(struct rpc_clnt *client, struct inode *dir, return err; } -#ifdef CONFIG_NFS_V4_1 - /* * This operation also signals the server that this client is * performing migration recovery. The server can stop asserting @@ -8220,8 +8186,6 @@ static int _nfs41_proc_get_locations(struct nfs_server *server, return status; } -#endif /* CONFIG_NFS_V4_1 */ - /** * nfs4_proc_get_locations - discover locations for a migrated FSID * @server: pointer to nfs_server to process @@ -8269,8 +8233,6 @@ int nfs4_proc_get_locations(struct nfs_server *server, return status; } -#ifdef CONFIG_NFS_V4_1 - /* * This operation also signals the server that this client is * performing "lease moved" recovery. The server can stop asserting @@ -8309,8 +8271,6 @@ static int _nfs41_proc_fsid_present(struct inode *inode, const struct cred *cred return status; } -#endif /* CONFIG_NFS_V4_1 */ - /** * nfs4_proc_fsid_present - Is this FSID present or absent on server? * @inode: inode on FSID to check @@ -8439,7 +8399,6 @@ int nfs4_proc_secinfo(struct inode *dir, const struct qstr *name, return err; } -#ifdef CONFIG_NFS_V4_1 /* * Check the exchange flags returned by the server for invalid flags, having * both PNFS and NON_PNFS flags set, and not having one of NON_PNFS, PNFS, or @@ -9052,8 +9011,6 @@ out: return ret; } -#endif /* CONFIG_NFS_V4_1 */ - struct nfs4_get_lease_time_data { struct nfs4_get_lease_time_args *args; struct nfs4_get_lease_time_res *res; @@ -9130,8 +9087,6 @@ int nfs4_proc_get_lease_time(struct nfs_client *clp, struct nfs_fsinfo *fsinfo) return nfs4_call_sync_custom(&task_setup); } -#ifdef CONFIG_NFS_V4_1 - /* * Initialize the values to be used by the client in CREATE_SESSION * If nfs4_init_session set the fore channel request and response sizes, @@ -10470,8 +10425,6 @@ static bool nfs41_match_stateid(const nfs4_stateid *s1, return s1->seqid == 0 || s2->seqid == 0; } -#endif /* CONFIG_NFS_V4_1 */ - bool nfs4_match_stateid(const nfs4_stateid *s1, const nfs4_stateid *s2) { @@ -10481,7 +10434,6 @@ 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, @@ -10548,7 +10500,6 @@ static const struct nfs4_minor_version_ops nfs_v4_1_minor_ops = { .state_renewal_ops = &nfs41_state_renewal_ops, .mig_recovery_ops = &nfs41_mig_recovery_ops, }; -#endif #if defined(CONFIG_NFS_V4_2) static const struct nfs4_minor_version_ops nfs_v4_2_minor_ops = { @@ -10594,9 +10545,7 @@ const struct nfs4_minor_version_ops *nfs_v4_minor_ops[] = { #if defined(CONFIG_NFS_V4_0) [0] = &nfs_v4_0_minor_ops, #endif /* CONFIG_NFS_V4_0 */ -#if defined(CONFIG_NFS_V4_1) [1] = &nfs_v4_1_minor_ops, -#endif #if defined(CONFIG_NFS_V4_2) [2] = &nfs_v4_2_minor_ops, #endif @@ -10775,7 +10724,6 @@ static const struct xattr_handler nfs4_xattr_nfs4_acl_handler = { .set = nfs4_xattr_set_nfs4_acl, }; -#if defined(CONFIG_NFS_V4_1) static const struct xattr_handler nfs4_xattr_nfs4_dacl_handler = { .name = XATTR_NAME_NFSV4_DACL, .list = nfs4_xattr_list_nfs4_dacl, @@ -10789,7 +10737,6 @@ static const struct xattr_handler nfs4_xattr_nfs4_sacl_handler = { .get = nfs4_xattr_get_nfs4_sacl, .set = nfs4_xattr_set_nfs4_sacl, }; -#endif #ifdef CONFIG_NFS_V4_2 static const struct xattr_handler nfs4_xattr_nfs4_user_handler = { @@ -10801,10 +10748,8 @@ static const struct xattr_handler nfs4_xattr_nfs4_user_handler = { const struct xattr_handler * const nfs4_xattr_handlers[] = { &nfs4_xattr_nfs4_acl_handler, -#if defined(CONFIG_NFS_V4_1) &nfs4_xattr_nfs4_dacl_handler, &nfs4_xattr_nfs4_sacl_handler, -#endif #ifdef CONFIG_NFS_V4_SECURITY_LABEL &nfs4_xattr_nfs4_label_handler, #endif diff --git a/fs/nfs/nfs4session.c b/fs/nfs/nfs4session.c index 5db460476bf2..a2fdd4b80dc4 100644 --- a/fs/nfs/nfs4session.c +++ b/fs/nfs/nfs4session.c @@ -408,8 +408,6 @@ void nfs41_wake_slot_table(struct nfs4_slot_table *tbl) } } -#if defined(CONFIG_NFS_V4_1) - static void nfs41_set_max_slotid_locked(struct nfs4_slot_table *tbl, u32 target_highest_slotid) { @@ -653,5 +651,3 @@ int nfs4_init_ds_session(struct nfs_client *clp, unsigned long lease_time) return 0; } EXPORT_SYMBOL_GPL(nfs4_init_ds_session); - -#endif /* defined(CONFIG_NFS_V4_1) */ diff --git a/fs/nfs/nfs4session.h b/fs/nfs/nfs4session.h index f9c291e2165c..d2569f599977 100644 --- a/fs/nfs/nfs4session.h +++ b/fs/nfs/nfs4session.h @@ -111,7 +111,6 @@ static inline struct nfs4_session *nfs4_get_session(const struct nfs_client *clp return clp->cl_session; } -#if defined(CONFIG_NFS_V4_1) extern void nfs41_set_target_slotid(struct nfs4_slot_table *tbl, u32 target_highest_slotid); extern void nfs41_update_target_slotid(struct nfs4_slot_table *tbl, @@ -154,28 +153,6 @@ static inline void nfs4_copy_sessionid(struct nfs4_sessionid *dst, */ #define nfs_session_id_hash(sess_id) \ (~crc32_le(0xFFFFFFFF, &(sess_id)->data[0], sizeof((sess_id)->data))) -#else /* defined(CONFIG_NFS_V4_1) */ -static inline int nfs4_init_session(struct nfs_client *clp) -{ - return 0; -} - -/* - * Determine if sessions are in use. - */ -static inline int nfs4_has_session(const struct nfs_client *clp) -{ - return 0; -} - -static inline int nfs4_has_persistent_session(const struct nfs_client *clp) -{ - return 0; -} - -#define nfs_session_id_hash(session) (0) - -#endif /* defined(CONFIG_NFS_V4_1) */ #endif /* IS_ENABLED(CONFIG_NFS_V4) */ #endif /* __LINUX_FS_NFS_NFS4SESSION_H */ diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c index 3330a188e1a5..3de1fb242c15 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c @@ -259,8 +259,6 @@ static int nfs4_begin_drain_session(struct nfs_client *clp) return nfs4_drain_slot_tbl(&ses->fc_slot_table); } -#if defined(CONFIG_NFS_V4_1) - static void nfs41_finish_session_reset(struct nfs_client *clp) { clear_bit(NFS4CLNT_LEASE_CONFIRM, &clp->cl_state); @@ -339,8 +337,6 @@ int nfs41_discover_server_trunking(struct nfs_client *clp, return status; } -#endif /* CONFIG_NFS_V4_1 */ - /** * nfs4_get_clid_cred - Acquire credential for a setclientid operation * @clp: client state handle @@ -2310,7 +2306,6 @@ out_unlock: return status; } -#ifdef CONFIG_NFS_V4_1 void nfs4_schedule_session_recovery(struct nfs4_session *session, int err) { struct nfs_client *clp = session->clp; @@ -2517,18 +2512,6 @@ static void nfs4_layoutreturn_any_run(struct nfs_client *clp) set_bit(NFS4CLNT_RUN_MANAGER, &clp->cl_state); } } -#else /* CONFIG_NFS_V4_1 */ -static int nfs4_reset_session(struct nfs_client *clp) { return 0; } - -static int nfs4_bind_conn_to_session(struct nfs_client *clp) -{ - return 0; -} - -static void nfs4_layoutreturn_any_run(struct nfs_client *clp) -{ -} -#endif /* CONFIG_NFS_V4_1 */ static void nfs4_state_manager(struct nfs_client *clp) { diff --git a/fs/nfs/nfs4trace.c b/fs/nfs/nfs4trace.c index 987c92d6364b..3fdc013f56d8 100644 --- a/fs/nfs/nfs4trace.c +++ b/fs/nfs/nfs4trace.c @@ -14,7 +14,6 @@ #define CREATE_TRACE_POINTS #include "nfs4trace.h" -#ifdef CONFIG_NFS_V4_1 EXPORT_TRACEPOINT_SYMBOL_GPL(nfs4_pnfs_read); EXPORT_TRACEPOINT_SYMBOL_GPL(nfs4_pnfs_write); EXPORT_TRACEPOINT_SYMBOL_GPL(nfs4_pnfs_commit_ds); @@ -39,4 +38,3 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(bl_pr_key_unreg); EXPORT_TRACEPOINT_SYMBOL_GPL(bl_pr_key_unreg_err); EXPORT_TRACEPOINT_SYMBOL_GPL(fl_getdevinfo); -#endif diff --git a/fs/nfs/nfs4trace.h b/fs/nfs/nfs4trace.h index 8ff6396bc206..a598d94d4536 100644 --- a/fs/nfs/nfs4trace.h +++ b/fs/nfs/nfs4trace.h @@ -71,7 +71,6 @@ DEFINE_NFS4_CLIENTID_EVENT(nfs4_setclientid); DEFINE_NFS4_CLIENTID_EVENT(nfs4_setclientid_confirm); DEFINE_NFS4_CLIENTID_EVENT(nfs4_renew); DEFINE_NFS4_CLIENTID_EVENT(nfs4_renew_async); -#ifdef CONFIG_NFS_V4_1 DEFINE_NFS4_CLIENTID_EVENT(nfs4_exchange_id); DEFINE_NFS4_CLIENTID_EVENT(nfs4_create_session); DEFINE_NFS4_CLIENTID_EVENT(nfs4_destroy_session); @@ -302,8 +301,6 @@ TRACE_EVENT(pnfs_ds_connect, ) ); -#endif /* CONFIG_NFS_V4_1 */ - TRACE_EVENT(nfs4_setup_sequence, TP_PROTO( const struct nfs4_session *session, @@ -1068,7 +1065,6 @@ TRACE_EVENT(nfs4_delegreturn_exit, ) ); -#ifdef CONFIG_NFS_V4_1 DECLARE_EVENT_CLASS(nfs4_test_stateid_event, TP_PROTO( const struct nfs4_state *state, @@ -1123,7 +1119,6 @@ DECLARE_EVENT_CLASS(nfs4_test_stateid_event, DEFINE_NFS4_TEST_STATEID_EVENT(nfs4_test_delegation_stateid); DEFINE_NFS4_TEST_STATEID_EVENT(nfs4_test_open_stateid); DEFINE_NFS4_TEST_STATEID_EVENT(nfs4_test_lock_stateid); -#endif /* CONFIG_NFS_V4_1 */ DECLARE_EVENT_CLASS(nfs4_lookup_event, TP_PROTO( @@ -1626,12 +1621,8 @@ DEFINE_NFS4_IDMAP_EVENT(nfs4_map_group_to_gid); DEFINE_NFS4_IDMAP_EVENT(nfs4_map_uid_to_name); DEFINE_NFS4_IDMAP_EVENT(nfs4_map_gid_to_group); -#ifdef CONFIG_NFS_V4_1 #define NFS4_LSEG_LAYOUT_STATEID_HASH(lseg) \ (lseg ? nfs_stateid_hash(&lseg->pls_layout->plh_stateid) : 0) -#else -#define NFS4_LSEG_LAYOUT_STATEID_HASH(lseg) (0) -#endif DECLARE_EVENT_CLASS(nfs4_read_event, TP_PROTO( @@ -1703,9 +1694,7 @@ DECLARE_EVENT_CLASS(nfs4_read_event, ), \ TP_ARGS(hdr, error)) DEFINE_NFS4_READ_EVENT(nfs4_read); -#ifdef CONFIG_NFS_V4_1 DEFINE_NFS4_READ_EVENT(nfs4_pnfs_read); -#endif /* CONFIG_NFS_V4_1 */ DECLARE_EVENT_CLASS(nfs4_write_event, TP_PROTO( @@ -1778,9 +1767,7 @@ DECLARE_EVENT_CLASS(nfs4_write_event, ), \ TP_ARGS(hdr, error)) DEFINE_NFS4_WRITE_EVENT(nfs4_write); -#ifdef CONFIG_NFS_V4_1 DEFINE_NFS4_WRITE_EVENT(nfs4_pnfs_write); -#endif /* CONFIG_NFS_V4_1 */ DECLARE_EVENT_CLASS(nfs4_commit_event, TP_PROTO( @@ -1840,7 +1827,6 @@ DECLARE_EVENT_CLASS(nfs4_commit_event, ), \ TP_ARGS(data, error)) DEFINE_NFS4_COMMIT_EVENT(nfs4_commit); -#ifdef CONFIG_NFS_V4_1 DEFINE_NFS4_COMMIT_EVENT(nfs4_pnfs_commit_ds); TRACE_EVENT(nfs4_layoutget, @@ -2874,8 +2860,6 @@ DEFINE_NFS4_XATTR_EVENT(nfs4_removexattr); DEFINE_NFS4_INODE_EVENT(nfs4_listxattr); #endif /* CONFIG_NFS_V4_2 */ -#endif /* CONFIG_NFS_V4_1 */ - #endif /* _TRACE_NFS4_H */ #undef TRACE_INCLUDE_PATH diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c index 85ddcee51162..c23c2eee1b5c 100644 --- a/fs/nfs/nfs4xdr.c +++ b/fs/nfs/nfs4xdr.c @@ -308,7 +308,6 @@ static int decode_layoutget(struct xdr_stream *xdr, struct rpc_rqst *req, #define encode_secinfo_maxsz (op_encode_hdr_maxsz + nfs4_name_maxsz) #define decode_secinfo_maxsz (op_decode_hdr_maxsz + 1 + ((NFS_MAX_SECFLAVORS * (16 + GSS_OID_MAX_LEN)) / 4)) -#if defined(CONFIG_NFS_V4_1) #define NFS4_MAX_MACHINE_NAME_LEN (64) #define IMPL_NAME_LIMIT (sizeof(utsname()->sysname) + sizeof(utsname()->release) + \ sizeof(utsname()->version) + sizeof(utsname()->machine) + 8) @@ -455,16 +454,6 @@ static int decode_layoutget(struct xdr_stream *xdr, struct rpc_rqst *req, #define encode_free_stateid_maxsz (op_encode_hdr_maxsz + 1 + \ XDR_QUADLEN(NFS4_STATEID_SIZE)) #define decode_free_stateid_maxsz (op_decode_hdr_maxsz) -#else /* CONFIG_NFS_V4_1 */ -#define encode_sequence_maxsz 0 -#define decode_sequence_maxsz 0 -#define encode_get_dir_deleg_maxsz 0 -#define decode_get_dir_deleg_maxsz 0 -#define encode_layoutreturn_maxsz 0 -#define decode_layoutreturn_maxsz 0 -#define encode_layoutget_maxsz 0 -#define decode_layoutget_maxsz 0 -#endif /* CONFIG_NFS_V4_1 */ #define NFS4_enc_compound_sz (1024) /* XXX: large enough? */ #define NFS4_dec_compound_sz (1024) /* XXX: large enough? */ @@ -838,7 +827,6 @@ static int decode_layoutget(struct xdr_stream *xdr, struct rpc_rqst *req, decode_putfh_maxsz + \ decode_getfh_maxsz + \ decode_renew_maxsz) -#if defined(CONFIG_NFS_V4_1) #define NFS4_enc_bind_conn_to_session_sz \ (compound_encode_hdr_maxsz + \ encode_bind_conn_to_session_maxsz) @@ -871,7 +859,6 @@ static int decode_layoutget(struct xdr_stream *xdr, struct rpc_rqst *req, #define NFS4_dec_sequence_sz \ (compound_decode_hdr_maxsz + \ decode_sequence_maxsz) -#endif #define NFS4_enc_get_lease_time_sz (compound_encode_hdr_maxsz + \ encode_sequence_maxsz + \ encode_putrootfh_maxsz + \ @@ -880,7 +867,6 @@ static int decode_layoutget(struct xdr_stream *xdr, struct rpc_rqst *req, decode_sequence_maxsz + \ decode_putrootfh_maxsz + \ decode_fsinfo_maxsz) -#if defined(CONFIG_NFS_V4_1) #define NFS4_enc_reclaim_complete_sz (compound_encode_hdr_maxsz + \ encode_sequence_maxsz + \ encode_reclaim_complete_maxsz) @@ -958,7 +944,6 @@ const u32 nfs41_maxgetdevinfo_overhead = ((RPC_MAX_REPHEADER_WITH_AUTH + decode_sequence_maxsz) * XDR_UNIT); EXPORT_SYMBOL_GPL(nfs41_maxgetdevinfo_overhead); -#endif /* CONFIG_NFS_V4_1 */ static const umode_t nfs_type2fmt[] = { [NF4BAD] = 0, @@ -1834,7 +1819,6 @@ static void encode_secinfo(struct xdr_stream *xdr, const struct qstr *name, stru encode_string(xdr, name->len, name->name); } -#if defined(CONFIG_NFS_V4_1) /* NFSv4.1 operations */ static void encode_bind_conn_to_session(struct xdr_stream *xdr, const struct nfs41_bind_conn_to_session_args *args, @@ -1986,13 +1970,11 @@ static void encode_reclaim_complete(struct xdr_stream *xdr, encode_op_hdr(xdr, OP_RECLAIM_COMPLETE, decode_reclaim_complete_maxsz, hdr); encode_uint32(xdr, args->one_fs); } -#endif /* CONFIG_NFS_V4_1 */ static void encode_sequence(struct xdr_stream *xdr, const struct nfs4_sequence_args *args, struct compound_hdr *hdr) { -#if defined(CONFIG_NFS_V4_1) struct nfs4_session *session; struct nfs4_slot_table *tp; struct nfs4_slot *slot = args->sa_slot; @@ -2023,10 +2005,8 @@ static void encode_sequence(struct xdr_stream *xdr, *p++ = cpu_to_be32(slot->slot_nr); *p++ = cpu_to_be32(tp->highest_used_slotid); *p = cpu_to_be32(args->sa_cache_this); -#endif /* CONFIG_NFS_V4_1 */ } -#ifdef CONFIG_NFS_V4_1 static void encode_get_dir_delegation(struct xdr_stream *xdr, struct compound_hdr *hdr) { @@ -2188,26 +2168,6 @@ static void encode_free_stateid(struct xdr_stream *xdr, encode_op_hdr(xdr, OP_FREE_STATEID, decode_free_stateid_maxsz, hdr); encode_nfs4_stateid(xdr, &args->stateid); } -#else -static inline void -encode_get_dir_delegation(struct xdr_stream *xdr, struct compound_hdr *hdr) -{ -} - -static inline void -encode_layoutreturn(struct xdr_stream *xdr, - const struct nfs4_layoutreturn_args *args, - struct compound_hdr *hdr) -{ -} - -static void -encode_layoutget(struct xdr_stream *xdr, - const struct nfs4_layoutget_args *args, - struct compound_hdr *hdr) -{ -} -#endif /* CONFIG_NFS_V4_1 */ /* * END OF "GENERIC" ENCODE ROUTINES. @@ -2215,11 +2175,9 @@ encode_layoutget(struct xdr_stream *xdr, static u32 nfs4_xdr_minorversion(const struct nfs4_sequence_args *args) { -#if defined(CONFIG_NFS_V4_1) struct nfs4_session *session = args->sa_slot->table->session; if (session) return session->clp->cl_mvops->minor_version; -#endif /* CONFIG_NFS_V4_1 */ return 0; } @@ -2977,7 +2935,6 @@ static void nfs4_xdr_enc_fsid_present(struct rpc_rqst *req, encode_nops(&hdr); } -#if defined(CONFIG_NFS_V4_1) /* * BIND_CONN_TO_SESSION request */ @@ -3079,8 +3036,6 @@ static void nfs4_xdr_enc_sequence(struct rpc_rqst *req, struct xdr_stream *xdr, encode_nops(&hdr); } -#endif - /* * a GET_LEASE_TIME request */ @@ -3101,8 +3056,6 @@ static void nfs4_xdr_enc_get_lease_time(struct rpc_rqst *req, encode_nops(&hdr); } -#ifdef CONFIG_NFS_V4_1 - /* * a RECLAIM_COMPLETE request */ @@ -3265,7 +3218,6 @@ static void nfs4_xdr_enc_free_stateid(struct rpc_rqst *req, encode_free_stateid(xdr, args, &hdr); encode_nops(&hdr); } -#endif /* CONFIG_NFS_V4_1 */ static int decode_opaque_inline(struct xdr_stream *xdr, unsigned int *len, char **string) { @@ -5764,7 +5716,6 @@ static int decode_secinfo(struct xdr_stream *xdr, struct nfs4_secinfo_res *res) return decode_secinfo_common(xdr, res); } -#if defined(CONFIG_NFS_V4_1) static int decode_secinfo_no_name(struct xdr_stream *xdr, struct nfs4_secinfo_res *res) { int status = decode_op_hdr(xdr, OP_SECINFO_NO_NAME); @@ -5976,13 +5927,11 @@ static int decode_reclaim_complete(struct xdr_stream *xdr, void *dummy) { return decode_op_hdr(xdr, OP_RECLAIM_COMPLETE); } -#endif /* CONFIG_NFS_V4_1 */ static int decode_sequence(struct xdr_stream *xdr, struct nfs4_sequence_res *res, struct rpc_rqst *rqstp) { -#if defined(CONFIG_NFS_V4_1) struct nfs4_session *session; struct nfs4_sessionid id; u32 dummy; @@ -6042,12 +5991,8 @@ out_err: out_overflow: status = -EIO; goto out_err; -#else /* CONFIG_NFS_V4_1 */ - return 0; -#endif /* CONFIG_NFS_V4_1 */ } -#if defined(CONFIG_NFS_V4_1) static int decode_layout_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid) { stateid->type = NFS4_LAYOUT_STATEID_TYPE; @@ -6310,27 +6255,6 @@ static int decode_free_stateid(struct xdr_stream *xdr, res->status = decode_op_hdr(xdr, OP_FREE_STATEID); return res->status; } -#else -static int decode_get_dir_delegation(struct xdr_stream *xdr, - struct nfs4_getattr_res *res) -{ - return 0; -} - -static inline -int decode_layoutreturn(struct xdr_stream *xdr, - struct nfs4_layoutreturn_res *res) -{ - return 0; -} - -static int decode_layoutget(struct xdr_stream *xdr, struct rpc_rqst *req, - struct nfs4_layoutget_res *res) -{ - return 0; -} - -#endif /* CONFIG_NFS_V4_1 */ /* * END OF "GENERIC" DECODE ROUTINES. @@ -7359,7 +7283,6 @@ out: return status; } -#if defined(CONFIG_NFS_V4_1) /* * Decode BIND_CONN_TO_SESSION response */ @@ -7456,8 +7379,6 @@ static int nfs4_xdr_dec_sequence(struct rpc_rqst *rqstp, return status; } -#endif - /* * Decode GET_LEASE_TIME response */ @@ -7479,8 +7400,6 @@ static int nfs4_xdr_dec_get_lease_time(struct rpc_rqst *rqstp, return status; } -#ifdef CONFIG_NFS_V4_1 - /* * Decode RECLAIM_COMPLETE response */ @@ -7668,7 +7587,6 @@ static int nfs4_xdr_dec_free_stateid(struct rpc_rqst *rqstp, out: return status; } -#endif /* CONFIG_NFS_V4_1 */ /** * nfs4_decode_dirent - Decode a single NFSv4 directory entry stored in @@ -7774,13 +7692,8 @@ int nfs4_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry, STUB(proc) #endif /* CONFIG_NFS_V4_0 */ -#if defined(CONFIG_NFS_V4_1) #define PROC41(proc, argtype, restype) \ PROC(proc, argtype, restype) -#else -#define PROC41(proc, argtype, restype) \ - STUB(proc) -#endif #if defined(CONFIG_NFS_V4_2) #define PROC42(proc, argtype, restype) \ diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h index 3db8f13d8fe4..eb39859c216c 100644 --- a/fs/nfs/pnfs.h +++ b/fs/nfs/pnfs.h @@ -84,7 +84,7 @@ enum pnfs_try_status { PNFS_TRY_AGAIN = 2, }; -#ifdef CONFIG_NFS_V4_1 +#if IS_ENABLED(CONFIG_NFS_V4) #define LAYOUT_NFSV4_1_MODULE_PREFIX "nfs-layouttype4" @@ -704,7 +704,7 @@ static inline void nfs4_print_deviceid(const struct nfs4_deviceid *dev_id) } #endif /* NFS_DEBUG */ -#else /* CONFIG_NFS_V4_1 */ +#else /* CONFIG_NFS_V4 */ static inline bool nfs_have_layout(struct inode *inode) { @@ -913,7 +913,7 @@ static inline bool pnfs_layout_is_valid(const struct pnfs_layout_hdr *lo) return false; } -#endif /* CONFIG_NFS_V4_1 */ +#endif /* CONFIG_NFS_V4 */ #if IS_ENABLED(CONFIG_NFS_V4_2) int pnfs_report_layoutstat(struct inode *inode, gfp_t gfp_flags); diff --git a/fs/nfs/read.c b/fs/nfs/read.c index 3c1fa320b3f1..e1fe78d7b8d0 100644 --- a/fs/nfs/read.c +++ b/fs/nfs/read.c @@ -68,10 +68,10 @@ void nfs_pageio_init_read(struct nfs_pageio_descriptor *pgio, struct nfs_server *server = NFS_SERVER(inode); const struct nfs_pageio_ops *pg_ops = &nfs_pgio_rw_ops; -#ifdef CONFIG_NFS_V4_1 +#if IS_ENABLED(CONFIG_NFS_V4) if (server->pnfs_curr_ld && !force_mds) pg_ops = server->pnfs_curr_ld->pg_read_ops; -#endif +#endif /* CONFIG_NFS_V4 */ nfs_pageio_init(pgio, inode, pg_ops, compl_ops, &nfs_rw_read_ops, server->rsize, 0); } diff --git a/fs/nfs/super.c b/fs/nfs/super.c index e74164d9c081..7a318581f85b 100644 --- a/fs/nfs/super.c +++ b/fs/nfs/super.c @@ -589,18 +589,13 @@ static void show_lease(struct seq_file *m, struct nfs_server *server) seq_printf(m, ",lease_expired=%ld", time_after(expire, jiffies) ? 0 : (jiffies - expire) / HZ); } -#ifdef CONFIG_NFS_V4_1 + static void show_sessions(struct seq_file *m, struct nfs_server *server) { if (nfs4_has_session(server->nfs_client)) seq_puts(m, ",sessions"); } -#else -static void show_sessions(struct seq_file *m, struct nfs_server *server) {} -#endif -#endif -#ifdef CONFIG_NFS_V4_1 static void show_pnfs(struct seq_file *m, struct nfs_server *server) { seq_printf(m, ",pnfs="); @@ -620,16 +615,11 @@ static void show_implementation_id(struct seq_file *m, struct nfs_server *nfss) impl_id->date.seconds, impl_id->date.nseconds); } } -#else -#if IS_ENABLED(CONFIG_NFS_V4) -static void show_pnfs(struct seq_file *m, struct nfs_server *server) -{ -} -#endif +#else /* CONFIG_NFS_V4 */ static void show_implementation_id(struct seq_file *m, struct nfs_server *nfss) { } -#endif +#endif /* CONFIG_NFS_V4 */ int nfs_show_devname(struct seq_file *m, struct dentry *root) { diff --git a/fs/nfs/sysfs.c b/fs/nfs/sysfs.c index ea6e6168092b..7bf650fda1cb 100644 --- a/fs/nfs/sysfs.c +++ b/fs/nfs/sysfs.c @@ -293,7 +293,7 @@ out: static struct kobj_attribute nfs_sysfs_attr_shutdown = __ATTR_RW(shutdown); -#if IS_ENABLED(CONFIG_NFS_V4_1) +#if IS_ENABLED(CONFIG_NFS_V4) static ssize_t implid_domain_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) @@ -323,7 +323,7 @@ implid_name_show(struct kobject *kobj, struct kobj_attribute *attr, static struct kobj_attribute nfs_sysfs_attr_implid_name = __ATTR_RO(implid_name); -#endif /* IS_ENABLED(CONFIG_NFS_V4_1) */ +#endif /* IS_ENABLED(CONFIG_NFS_V4) */ #define RPC_CLIENT_NAME_SIZE 64 @@ -362,7 +362,7 @@ static struct kobj_type nfs_sb_ktype = { .child_ns_type = nfs_netns_object_child_ns_type, }; -#if IS_ENABLED(CONFIG_NFS_V4_1) +#if IS_ENABLED(CONFIG_NFS_V4) static void nfs_sysfs_add_nfsv41_server(struct nfs_server *server) { int ret; @@ -382,11 +382,11 @@ static void nfs_sysfs_add_nfsv41_server(struct nfs_server *server) pr_warn("NFS: sysfs_create_file_ns for server-%d failed (%d)\n", server->s_sysfs_id, ret); } -#else /* CONFIG_NFS_V4_1 */ +#else /* CONFIG_NFS_V4 */ static inline void nfs_sysfs_add_nfsv41_server(struct nfs_server *server) { } -#endif /* CONFIG_NFS_V4_1 */ +#endif /* CONFIG_NFS_V4 */ #if IS_ENABLED(CONFIG_NFS_LOCALIO) diff --git a/fs/nfs/write.c b/fs/nfs/write.c index bf412455e8ed..2d0e4a765aeb 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c @@ -1402,7 +1402,7 @@ void nfs_pageio_init_write(struct nfs_pageio_descriptor *pgio, struct nfs_server *server = NFS_SERVER(inode); const struct nfs_pageio_ops *pg_ops = &nfs_pgio_rw_ops; -#ifdef CONFIG_NFS_V4_1 +#if IS_ENABLED(CONFIG_NFS_V4) if (server->pnfs_curr_ld && !force_mds) pg_ops = server->pnfs_curr_ld->pg_write_ops; #endif diff --git a/include/linux/nfs_fs_sb.h b/include/linux/nfs_fs_sb.h index bb13a294b69e..89826c3e15a2 100644 --- a/include/linux/nfs_fs_sb.h +++ b/include/linux/nfs_fs_sb.h @@ -115,9 +115,7 @@ struct nfs_client { #define NFS_SP4_MACH_CRED_WRITE 5 /* WRITE */ #define NFS_SP4_MACH_CRED_COMMIT 6 /* COMMIT */ #define NFS_SP4_MACH_CRED_PNFS_CLEANUP 7 /* LAYOUTRETURN */ -#if IS_ENABLED(CONFIG_NFS_V4_1) wait_queue_head_t cl_lock_waitq; -#endif /* CONFIG_NFS_V4_1 */ #endif /* CONFIG_NFS_V4 */ /* Our own IP address, as a null-terminated string. diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h index 2aa4e38af57a..437e6f4af7e0 100644 --- a/include/linux/nfs_xdr.h +++ b/include/linux/nfs_xdr.h @@ -1324,10 +1324,6 @@ struct nfs4_fsid_present_res { unsigned char renew:1; }; -#endif /* CONFIG_NFS_V4 */ - -#ifdef CONFIG_NFS_V4_1 - struct pnfs_commit_bucket { struct list_head written; struct list_head committing; @@ -1467,7 +1463,7 @@ struct nfs41_free_stateid_res { struct pnfs_ds_commit_info { }; -#endif /* CONFIG_NFS_V4_1 */ +#endif /* CONFIG_NFS_V4 */ #ifdef CONFIG_NFS_V4_2 struct nfs42_falloc_args { -- cgit v1.2.3 From b1cb730e847d9766b7fb416e623454a5cba57dc4 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Wed, 28 Jan 2026 05:46:04 +0100 Subject: NFS: return void from ->return_delegation The caller doesn't check the return value, so drop it. Signed-off-by: Christoph Hellwig Signed-off-by: Anna Schumaker --- fs/nfs/delegation.c | 8 +++----- fs/nfs/delegation.h | 2 +- fs/nfs/nfs3proc.c | 3 +-- fs/nfs/proc.c | 3 +-- include/linux/nfs_xdr.h | 2 +- 5 files changed, 7 insertions(+), 11 deletions(-) (limited to 'include/linux') diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c index c77c7b2d5877..fe1f57ec326c 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -814,23 +814,21 @@ void nfs_inode_evict_delegation(struct inode *inode) * * Returns zero on success, or a negative errno value. */ -int nfs4_inode_return_delegation(struct inode *inode) +void nfs4_inode_return_delegation(struct inode *inode) { struct nfs_inode *nfsi = NFS_I(inode); struct nfs_delegation *delegation; - int err; delegation = nfs_start_delegation_return(nfsi); if (!delegation) - return 0; + return; /* Synchronous recall of any application leases */ break_lease(inode, O_WRONLY | O_RDWR); if (S_ISREG(inode->i_mode)) nfs_wb_all(inode); - err = nfs_end_delegation_return(inode, delegation, 1); + nfs_end_delegation_return(inode, delegation, 1); nfs_put_delegation(delegation); - return err; } /** diff --git a/fs/nfs/delegation.h b/fs/nfs/delegation.h index d30f19a28077..eda39fcb032b 100644 --- a/fs/nfs/delegation.h +++ b/fs/nfs/delegation.h @@ -47,7 +47,7 @@ int nfs_inode_set_delegation(struct inode *inode, const struct cred *cred, void nfs_inode_reclaim_delegation(struct inode *inode, const struct cred *cred, fmode_t type, const nfs4_stateid *stateid, unsigned long pagemod_limit, u32 deleg_type); -int nfs4_inode_return_delegation(struct inode *inode); +void nfs4_inode_return_delegation(struct inode *inode); void nfs4_inode_return_delegation_on_close(struct inode *inode); void nfs4_inode_set_return_delegation_on_close(struct inode *inode); int nfs_async_inode_return_delegation(struct inode *inode, const nfs4_stateid *stateid); diff --git a/fs/nfs/nfs3proc.c b/fs/nfs/nfs3proc.c index 1181f9cc6dbd..d3d2fbeba89d 100644 --- a/fs/nfs/nfs3proc.c +++ b/fs/nfs/nfs3proc.c @@ -1027,11 +1027,10 @@ static int nfs3_have_delegation(struct inode *inode, fmode_t type, int flags) return 0; } -static int nfs3_return_delegation(struct inode *inode) +static void nfs3_return_delegation(struct inode *inode) { if (S_ISREG(inode->i_mode)) nfs_wb_all(inode); - return 0; } static const struct inode_operations nfs3_dir_inode_operations = { diff --git a/fs/nfs/proc.c b/fs/nfs/proc.c index 39df80e4ae6f..0e440ebf5335 100644 --- a/fs/nfs/proc.c +++ b/fs/nfs/proc.c @@ -697,11 +697,10 @@ static int nfs_have_delegation(struct inode *inode, fmode_t type, int flags) return 0; } -static int nfs_return_delegation(struct inode *inode) +static void nfs_return_delegation(struct inode *inode) { if (S_ISREG(inode->i_mode)) nfs_wb_all(inode); - return 0; } static const struct inode_operations nfs_dir_inode_operations = { diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h index 437e6f4af7e0..ff1f12aa73d2 100644 --- a/include/linux/nfs_xdr.h +++ b/include/linux/nfs_xdr.h @@ -1846,7 +1846,7 @@ struct nfs_rpc_ops { struct iattr *iattr, int *); int (*have_delegation)(struct inode *, fmode_t, int); - int (*return_delegation)(struct inode *); + void (*return_delegation)(struct inode *); struct nfs_client *(*alloc_client) (const struct nfs_client_initdata *); struct nfs_client *(*init_client) (struct nfs_client *, const struct nfs_client_initdata *); -- cgit v1.2.3 From 4039fbedcbcb022704ff45533aa7860ce036ee6b Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Wed, 28 Jan 2026 05:46:09 +0100 Subject: NFS: fix delayed delegation return handling Rework this code that was totally busted at least as of my most recent changes. Introduce a separate list for delayed delegations so that they can't get lost and don't clutter up the returns list. Add a missing spin_unlock in the helper marking it as a regular pending return. Fixes: 0ebe655bd033 ("NFS: add a separate delegation return list") Reported-by: Chris Mason Signed-off-by: Christoph Hellwig Signed-off-by: Anna Schumaker --- fs/nfs/client.c | 1 + fs/nfs/delegation.c | 30 ++++++++++++------------------ fs/nfs/delegation.h | 1 - fs/nfs/nfs4trace.h | 3 +-- include/linux/nfs_fs_sb.h | 2 +- 5 files changed, 15 insertions(+), 22 deletions(-) (limited to 'include/linux') diff --git a/fs/nfs/client.c b/fs/nfs/client.c index 6b9a65615a51..fd15731cf361 100644 --- a/fs/nfs/client.c +++ b/fs/nfs/client.c @@ -1063,6 +1063,7 @@ struct nfs_server *nfs_alloc_server(void) spin_lock_init(&server->delegations_lock); INIT_LIST_HEAD(&server->delegations_return); INIT_LIST_HEAD(&server->delegations_lru); + INIT_LIST_HEAD(&server->delegations_delayed); INIT_LIST_HEAD(&server->layouts); INIT_LIST_HEAD(&server->state_owners_lru); INIT_LIST_HEAD(&server->ss_copies); diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c index cff49a934c9e..94103f8d3f21 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -336,10 +336,8 @@ nfs_start_delegation_return(struct nfs_inode *nfsi) spin_lock(&delegation->lock); if (delegation->inode && - !test_and_set_bit(NFS_DELEGATION_RETURNING, &delegation->flags)) { - clear_bit(NFS_DELEGATION_RETURN_DELAYED, &delegation->flags); + !test_and_set_bit(NFS_DELEGATION_RETURNING, &delegation->flags)) return_now = true; - } spin_unlock(&delegation->lock); if (!return_now) { @@ -586,8 +584,11 @@ static int nfs_end_delegation_return(struct inode *inode, out_return: return nfs_do_return_delegation(inode, delegation, issync); delay: - set_bit(NFS_DELEGATION_RETURN_DELAYED, &delegation->flags); - set_bit(NFS4SERV_DELEGRETURN_DELAYED, &server->delegation_flags); + spin_lock(&server->delegations_lock); + if (list_empty(&delegation->entry)) + refcount_inc(&delegation->refcount); + list_move_tail(&delegation->entry, &server->delegations_return); + spin_unlock(&server->delegations_lock); set_bit(NFS4CLNT_DELEGRETURN_DELAYED, &server->nfs_client->cl_state); abort: clear_bit(NFS_DELEGATION_RETURNING, &delegation->flags); @@ -616,22 +617,16 @@ static int nfs_return_one_delegation(struct nfs_server *server) spin_unlock(&delegation->lock); goto out_put_delegation; } - if (test_bit(NFS_DELEGATION_RETURN_DELAYED, &delegation->flags) || - test_bit(NFS_DELEGATION_REVOKED, &delegation->flags) || + if (test_bit(NFS_DELEGATION_REVOKED, &delegation->flags) || test_and_set_bit(NFS_DELEGATION_RETURNING, &delegation->flags)) { spin_unlock(&delegation->lock); goto out_put_inode; } - clear_bit(NFS_DELEGATION_RETURN_DELAYED, &delegation->flags); spin_unlock(&delegation->lock); nfs_clear_verifier_delegated(inode); err = nfs_end_delegation_return(inode, delegation, false); - if (err) { - nfs_mark_return_delegation(server, delegation); - goto out_put_inode; - } out_put_inode: iput(inode); @@ -708,19 +703,18 @@ static void nfs_delegation_add_lru(struct nfs_server *server, static bool nfs_server_clear_delayed_delegations(struct nfs_server *server) { - struct nfs_delegation *d; bool ret = false; - if (!test_and_clear_bit(NFS4SERV_DELEGRETURN_DELAYED, - &server->delegation_flags)) + if (list_empty_careful(&server->delegations_delayed)) return false; spin_lock(&server->delegations_lock); - list_for_each_entry_rcu(d, &server->delegations_return, entry) { - if (test_bit(NFS_DELEGATION_RETURN_DELAYED, &d->flags)) - clear_bit(NFS_DELEGATION_RETURN_DELAYED, &d->flags); + if (!list_empty(&server->delegations_delayed)) { + list_splice_tail_init(&server->delegations_delayed, + &server->delegations_return); ret = true; } + spin_unlock(&server->delegations_lock); return ret; } diff --git a/fs/nfs/delegation.h b/fs/nfs/delegation.h index eda39fcb032b..fba4699952b8 100644 --- a/fs/nfs/delegation.h +++ b/fs/nfs/delegation.h @@ -37,7 +37,6 @@ enum { NFS_DELEGATION_RETURNING, NFS_DELEGATION_REVOKED, NFS_DELEGATION_TEST_EXPIRED, - NFS_DELEGATION_RETURN_DELAYED, NFS_DELEGATION_DELEGTIME, }; diff --git a/fs/nfs/nfs4trace.h b/fs/nfs/nfs4trace.h index a598d94d4536..c939533b9881 100644 --- a/fs/nfs/nfs4trace.h +++ b/fs/nfs/nfs4trace.h @@ -991,8 +991,7 @@ DEFINE_NFS4_SET_DELEGATION_EVENT(nfs4_detach_delegation); { BIT(NFS_DELEGATION_REFERENCED), "REFERENCED" }, \ { BIT(NFS_DELEGATION_RETURNING), "RETURNING" }, \ { BIT(NFS_DELEGATION_REVOKED), "REVOKED" }, \ - { BIT(NFS_DELEGATION_TEST_EXPIRED), "TEST_EXPIRED" }, \ - { BIT(NFS_DELEGATION_RETURN_DELAYED), "RETURN_DELAYED" }) + { BIT(NFS_DELEGATION_TEST_EXPIRED), "TEST_EXPIRED" }) DECLARE_EVENT_CLASS(nfs4_delegation_event, TP_PROTO( diff --git a/include/linux/nfs_fs_sb.h b/include/linux/nfs_fs_sb.h index 89826c3e15a2..4daee27fa5eb 100644 --- a/include/linux/nfs_fs_sb.h +++ b/include/linux/nfs_fs_sb.h @@ -260,6 +260,7 @@ struct nfs_server { spinlock_t delegations_lock; struct list_head delegations_return; struct list_head delegations_lru; + struct list_head delegations_delayed; atomic_long_t nr_active_delegations; unsigned int delegation_hash_mask; struct hlist_head *delegation_hash_table; @@ -268,7 +269,6 @@ struct nfs_server { unsigned long delegation_flags; #define NFS4SERV_DELEGATION_EXPIRED (1) -#define NFS4SERV_DELEGRETURN_DELAYED (2) unsigned long delegation_gen; unsigned long mig_gen; unsigned long mig_status; -- cgit v1.2.3 From 728bea264883031c377fcc9c465b650dbfd1bbf5 Mon Sep 17 00:00:00 2001 From: Ben Dooks Date: Tue, 6 Jan 2026 17:37:45 +0000 Subject: sunrpc: rpc_debug and others are defined even if CONFIG_SUNRPC_DEBUG unset The rpc_debug, nfs_debug, nfsd_debug and nlm_debug are exported even if CONFIG_SUNRPC_DEBUG is not set. This means that the debug header should also define these to remove the following sparse warnings: net/sunrpc/sysctl.c:29:17: warning: symbol 'rpc_debug' was not declared. Should it be static? net/sunrpc/sysctl.c:32:17: warning: symbol 'nfs_debug' was not declared. Should it be static? net/sunrpc/sysctl.c:35:17: warning: symbol 'nfsd_debug' was not declared. Should it be static? net/sunrpc/sysctl.c:38:17: warning: symbol 'nlm_debug' was not declared. Should it be static? Signed-off-by: Ben Dooks Signed-off-by: Anna Schumaker --- include/linux/sunrpc/debug.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'include/linux') diff --git a/include/linux/sunrpc/debug.h b/include/linux/sunrpc/debug.h index 891f6173c951..eb4bd62df319 100644 --- a/include/linux/sunrpc/debug.h +++ b/include/linux/sunrpc/debug.h @@ -14,12 +14,10 @@ /* * Debugging macros etc */ -#if IS_ENABLED(CONFIG_SUNRPC_DEBUG) extern unsigned int rpc_debug; extern unsigned int nfs_debug; extern unsigned int nfsd_debug; extern unsigned int nlm_debug; -#endif #define dprintk(fmt, ...) \ dfprintk(FACILITY, fmt, ##__VA_ARGS__) -- cgit v1.2.3