* [PATCH v2 00/14] NFS: Make NFS v4.0 KConfig-urable
@ 2026-01-26 20:39 Anna Schumaker
2026-01-26 20:39 ` [PATCH v2 01/14] NFS: Move nfs40_call_sync_ops into nfs40proc.c Anna Schumaker
` (13 more replies)
0 siblings, 14 replies; 16+ messages in thread
From: Anna Schumaker @ 2026-01-26 20:39 UTC (permalink / raw)
To: linux-nfs, trond.myklebust; +Cc: anna
From: Anna Schumaker <anna.schumaker@oracle.com>
A desire to deprecate NFS v4.0 came up as a discussion topic during the
October Bake-a-thon last year. This patchset takes the first step by
moving NFS v4.0 only code into new files prefixed with "nfs40" and
introducing a KConfig option to compile without NFS v4.0 support.
At the same time, I promote NFS v4.1 to be the default NFSv4
minorversion included in the kernel to prevent the situation where we
have NFS v4 enabled without any minor versions.
Changes in v2:
- KConfig-out NFS v4.0-only operations from nfs4xdr.c
- Fix a kernel test robot build warning
Thoughts?
Anna
Anna Schumaker (14):
NFS: Move nfs40_call_sync_ops into nfs40proc.c
NFS: Split out the nfs40_reboot_recovery_ops into nfs40client.c
NFS: Split out the nfs40_nograce_recovery_ops into nfs40proc.c
NFS: Split out the nfs40_state_renewal_ops into nfs40proc.c
NFS: Split out the nfs40_mig_recovery_ops to nfs40proc.c
NFS: Move the NFS v4.0 minor version ops into nfs40proc.c
NFS: Make the various NFS v4.0 operations static again
NFS: Move nfs40_shutdown_client into nfs40client.c
NFS: Move nfs40_init_client into nfs40client.c
NFS: Move NFS v4.0 pathdown recovery into nfs40client.c
NFS: Pass a struct nfs_client to nfs4_init_sequence()
NFS: Move sequence slot operations into minorversion operations
NFS: Add a way to disable NFS v4.0 via KConfig
NFS: Merge CONFIG_NFS_V4_1 with CONFIG_NFS_V4
fs/nfs/Kconfig | 26 +-
fs/nfs/Makefile | 4 +-
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/fs_context.c | 3 +-
fs/nfs/internal.h | 15 +-
fs/nfs/netns.h | 4 +-
fs/nfs/nfs40.h | 19 ++
fs/nfs/nfs40client.c | 247 ++++++++++++++
fs/nfs/nfs40proc.c | 395 ++++++++++++++++++++++
fs/nfs/nfs42proc.c | 13 +-
fs/nfs/nfs4_fs.h | 83 ++---
fs/nfs/nfs4client.c | 193 +----------
fs/nfs/nfs4proc.c | 682 +++++++-------------------------------
fs/nfs/nfs4session.c | 4 -
fs/nfs/nfs4session.h | 23 --
fs/nfs/nfs4state.c | 91 +----
fs/nfs/nfs4trace.c | 2 -
fs/nfs/nfs4trace.h | 16 -
fs/nfs/nfs4xdr.c | 109 ++----
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 | 7 +-
30 files changed, 902 insertions(+), 1122 deletions(-)
create mode 100644 fs/nfs/nfs40.h
create mode 100644 fs/nfs/nfs40client.c
create mode 100644 fs/nfs/nfs40proc.c
--
2.52.0
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v2 01/14] NFS: Move nfs40_call_sync_ops into nfs40proc.c
2026-01-26 20:39 [PATCH v2 00/14] NFS: Make NFS v4.0 KConfig-urable Anna Schumaker
@ 2026-01-26 20:39 ` Anna Schumaker
2026-01-26 20:39 ` [PATCH v2 02/14] NFS: Split out the nfs40_reboot_recovery_ops into nfs40client.c Anna Schumaker
` (12 subsequent siblings)
13 siblings, 0 replies; 16+ messages in thread
From: Anna Schumaker @ 2026-01-26 20:39 UTC (permalink / raw)
To: linux-nfs, trond.myklebust; +Cc: anna
From: Anna Schumaker <anna.schumaker@oracle.com>
This is the first step in extracting NFS v4.0 into its own set of files
that can be disabled through Kconfig.
Signed-off-by: Anna Schumaker <anna.schumaker@oracle.com>
---
fs/nfs/Makefile | 2 +-
fs/nfs/nfs40.h | 8 ++++++++
fs/nfs/nfs40proc.c | 24 ++++++++++++++++++++++++
fs/nfs/nfs4_fs.h | 6 ++++++
fs/nfs/nfs4proc.c | 25 +------------------------
5 files changed, 40 insertions(+), 25 deletions(-)
create mode 100644 fs/nfs/nfs40.h
create mode 100644 fs/nfs/nfs40proc.c
diff --git a/fs/nfs/Makefile b/fs/nfs/Makefile
index 9fb2f2cac87e..937c775a04a3 100644
--- a/fs/nfs/Makefile
+++ b/fs/nfs/Makefile
@@ -27,7 +27,7 @@ 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 nfs40proc.o
nfsv4-$(CONFIG_NFS_USE_LEGACY_DNS) += cache_lib.o
nfsv4-$(CONFIG_SYSCTL) += nfs4sysctl.o
nfsv4-$(CONFIG_NFS_V4_1) += pnfs.o pnfs_dev.o pnfs_nfs.o
diff --git a/fs/nfs/nfs40.h b/fs/nfs/nfs40.h
new file mode 100644
index 000000000000..58a59109987a
--- /dev/null
+++ b/fs/nfs/nfs40.h
@@ -0,0 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __LINUX_FS_NFS_NFS4_0_H
+#define __LINUX_FS_NFS_NFS4_0_H
+
+
+extern const struct rpc_call_ops nfs40_call_sync_ops;
+
+#endif /* __LINUX_FS_NFS_NFS4_0_H */
diff --git a/fs/nfs/nfs40proc.c b/fs/nfs/nfs40proc.c
new file mode 100644
index 000000000000..6d27dedad055
--- /dev/null
+++ b/fs/nfs/nfs40proc.c
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#include <linux/nfs4.h>
+#include <linux/nfs.h>
+#include <linux/sunrpc/sched.h>
+#include <linux/nfs_fs.h>
+#include "nfs4_fs.h"
+
+static void nfs40_call_sync_prepare(struct rpc_task *task, void *calldata)
+{
+ struct nfs4_call_sync_data *data = calldata;
+ nfs4_setup_sequence(data->seq_server->nfs_client,
+ data->seq_args, data->seq_res, task);
+}
+
+static void nfs40_call_sync_done(struct rpc_task *task, void *calldata)
+{
+ struct nfs4_call_sync_data *data = calldata;
+ nfs4_sequence_done(task, data->seq_res);
+}
+
+const struct rpc_call_ops nfs40_call_sync_ops = {
+ .rpc_call_prepare = nfs40_call_sync_prepare,
+ .rpc_call_done = nfs40_call_sync_done,
+};
diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h
index 44cf167f65c6..1b4b32d1b0ef 100644
--- a/fs/nfs/nfs4_fs.h
+++ b/fs/nfs/nfs4_fs.h
@@ -286,6 +286,12 @@ int nfs4_replace_transport(struct nfs_server *server,
size_t nfs_parse_server_name(char *string, size_t len, struct sockaddr_storage *ss,
size_t salen, struct net *net, int port);
/* nfs4proc.c */
+struct nfs4_call_sync_data {
+ const struct nfs_server *seq_server;
+ struct nfs4_sequence_args *seq_args;
+ struct nfs4_sequence_res *seq_res;
+};
+
extern int nfs4_handle_exception(struct nfs_server *, int, struct nfs4_exception *);
extern int nfs4_async_handle_error(struct rpc_task *task,
struct nfs_server *server,
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 85cf577cf957..0f9494eb02e6 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -67,6 +67,7 @@
#include "nfs4idmap.h"
#include "nfs4session.h"
#include "fscache.h"
+#include "nfs40.h"
#include "nfs42.h"
#include "nfs4trace.h"
@@ -769,12 +770,6 @@ static void renew_lease(const struct nfs_server *server, unsigned long timestamp
do_renew_lease(clp, timestamp);
}
-struct nfs4_call_sync_data {
- const struct nfs_server *seq_server;
- struct nfs4_sequence_args *seq_args;
- struct nfs4_sequence_res *seq_res;
-};
-
void nfs4_init_sequence(struct nfs4_sequence_args *args,
struct nfs4_sequence_res *res, int cache_reply,
int privileged)
@@ -1174,24 +1169,6 @@ int nfs4_setup_sequence(struct nfs_client *client,
}
EXPORT_SYMBOL_GPL(nfs4_setup_sequence);
-static void nfs40_call_sync_prepare(struct rpc_task *task, void *calldata)
-{
- struct nfs4_call_sync_data *data = calldata;
- nfs4_setup_sequence(data->seq_server->nfs_client,
- data->seq_args, data->seq_res, task);
-}
-
-static void nfs40_call_sync_done(struct rpc_task *task, void *calldata)
-{
- struct nfs4_call_sync_data *data = calldata;
- nfs4_sequence_done(task, data->seq_res);
-}
-
-static const struct rpc_call_ops nfs40_call_sync_ops = {
- .rpc_call_prepare = nfs40_call_sync_prepare,
- .rpc_call_done = nfs40_call_sync_done,
-};
-
static int nfs4_call_sync_custom(struct rpc_task_setup *task_setup)
{
int ret;
--
2.52.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v2 02/14] NFS: Split out the nfs40_reboot_recovery_ops into nfs40client.c
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 ` Anna Schumaker
2026-01-26 20:39 ` [PATCH v2 03/14] NFS: Split out the nfs40_nograce_recovery_ops into nfs40proc.c Anna Schumaker
` (11 subsequent siblings)
13 siblings, 0 replies; 16+ messages in thread
From: Anna Schumaker @ 2026-01-26 20:39 UTC (permalink / raw)
To: linux-nfs, trond.myklebust; +Cc: anna
From: Anna Schumaker <anna.schumaker@oracle.com>
Signed-off-by: Anna Schumaker <anna.schumaker@oracle.com>
---
fs/nfs/Makefile | 2 +-
fs/nfs/internal.h | 3 -
fs/nfs/nfs40.h | 7 ++
fs/nfs/nfs40client.c | 188 +++++++++++++++++++++++++++++++++++++++++++
fs/nfs/nfs40proc.c | 9 +++
fs/nfs/nfs4_fs.h | 7 ++
fs/nfs/nfs4client.c | 132 +-----------------------------
fs/nfs/nfs4proc.c | 13 +--
fs/nfs/nfs4state.c | 49 -----------
9 files changed, 216 insertions(+), 194 deletions(-)
create mode 100644 fs/nfs/nfs40client.c
diff --git a/fs/nfs/Makefile b/fs/nfs/Makefile
index 937c775a04a3..d05e69c00fe1 100644
--- a/fs/nfs/Makefile
+++ b/fs/nfs/Makefile
@@ -27,7 +27,7 @@ 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 nfs40proc.o
+ dns_resolve.o nfs4trace.o nfs40proc.o nfs40client.o
nfsv4-$(CONFIG_NFS_USE_LEGACY_DNS) += cache_lib.o
nfsv4-$(CONFIG_SYSCTL) += nfs4sysctl.o
nfsv4-$(CONFIG_NFS_V4_1) += pnfs.o pnfs_dev.o pnfs_nfs.o
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index 2e596244799f..e99998e515c0 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -739,9 +739,6 @@ extern ssize_t nfs_dreq_bytes_left(struct nfs_direct_req *dreq, loff_t offset);
/* nfs4proc.c */
extern struct nfs_client *nfs4_init_client(struct nfs_client *clp,
const struct nfs_client_initdata *);
-extern int nfs40_walk_client_list(struct nfs_client *clp,
- struct nfs_client **result,
- const struct cred *cred);
extern int nfs41_walk_client_list(struct nfs_client *clp,
struct nfs_client **result,
const struct cred *cred);
diff --git a/fs/nfs/nfs40.h b/fs/nfs/nfs40.h
index 58a59109987a..ad57172b49a3 100644
--- a/fs/nfs/nfs40.h
+++ b/fs/nfs/nfs40.h
@@ -3,6 +3,13 @@
#define __LINUX_FS_NFS_NFS4_0_H
+/* nfs40proc.c */
extern const struct rpc_call_ops nfs40_call_sync_ops;
+extern const struct nfs4_state_recovery_ops nfs40_reboot_recovery_ops;
+
+/* nfs40state.c */
+int nfs40_discover_server_trunking(struct nfs_client *clp,
+ struct nfs_client **result,
+ const struct cred *cred);
#endif /* __LINUX_FS_NFS_NFS4_0_H */
diff --git a/fs/nfs/nfs40client.c b/fs/nfs/nfs40client.c
new file mode 100644
index 000000000000..bab073b6506b
--- /dev/null
+++ b/fs/nfs/nfs40client.c
@@ -0,0 +1,188 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#include <linux/nfs_fs.h>
+#include "nfs4_fs.h"
+#include "callback.h"
+#include "internal.h"
+#include "netns.h"
+#include "nfs40.h"
+
+#define NFSDBG_FACILITY NFSDBG_CLIENT
+
+/*
+ * SETCLIENTID just did a callback update with the callback ident in
+ * "drop," but server trunking discovery claims "drop" and "keep" are
+ * actually the same server. Swap the callback IDs so that "keep"
+ * will continue to use the callback ident the server now knows about,
+ * and so that "keep"'s original callback ident is destroyed when
+ * "drop" is freed.
+ */
+static void nfs4_swap_callback_idents(struct nfs_client *keep,
+ struct nfs_client *drop)
+{
+ struct nfs_net *nn = net_generic(keep->cl_net, nfs_net_id);
+ unsigned int save = keep->cl_cb_ident;
+
+ if (keep->cl_cb_ident == drop->cl_cb_ident)
+ return;
+
+ dprintk("%s: keeping callback ident %u and dropping ident %u\n",
+ __func__, keep->cl_cb_ident, drop->cl_cb_ident);
+
+ spin_lock(&nn->nfs_client_lock);
+
+ idr_replace(&nn->cb_ident_idr, keep, drop->cl_cb_ident);
+ keep->cl_cb_ident = drop->cl_cb_ident;
+
+ idr_replace(&nn->cb_ident_idr, drop, save);
+ drop->cl_cb_ident = save;
+
+ spin_unlock(&nn->nfs_client_lock);
+}
+
+static bool nfs4_same_verifier(nfs4_verifier *v1, nfs4_verifier *v2)
+{
+ return memcmp(v1->data, v2->data, sizeof(v1->data)) == 0;
+}
+
+/**
+ * nfs40_walk_client_list - Find server that recognizes a client ID
+ *
+ * @new: nfs_client with client ID to test
+ * @result: OUT: found nfs_client, or new
+ * @cred: credential to use for trunking test
+ *
+ * Returns zero, a negative errno, or a negative NFS4ERR status.
+ * If zero is returned, an nfs_client pointer is planted in "result."
+ *
+ * NB: nfs40_walk_client_list() relies on the new nfs_client being
+ * the last nfs_client on the list.
+ */
+static int nfs40_walk_client_list(struct nfs_client *new,
+ struct nfs_client **result,
+ const struct cred *cred)
+{
+ struct nfs_net *nn = net_generic(new->cl_net, nfs_net_id);
+ struct nfs_client *pos, *prev = NULL;
+ struct nfs4_setclientid_res clid = {
+ .clientid = new->cl_clientid,
+ .confirm = new->cl_confirm,
+ };
+ int status = -NFS4ERR_STALE_CLIENTID;
+
+ spin_lock(&nn->nfs_client_lock);
+ list_for_each_entry(pos, &nn->nfs_client_list, cl_share_link) {
+
+ if (pos == new)
+ goto found;
+
+ status = nfs4_match_client(pos, new, &prev, nn);
+ if (status < 0)
+ goto out_unlock;
+ if (status != 0)
+ continue;
+ /*
+ * We just sent a new SETCLIENTID, which should have
+ * caused the server to return a new cl_confirm. So if
+ * cl_confirm is the same, then this is a different
+ * server that just returned the same cl_confirm by
+ * coincidence:
+ */
+ if ((new != pos) && nfs4_same_verifier(&pos->cl_confirm,
+ &new->cl_confirm))
+ continue;
+ /*
+ * But if the cl_confirm's are different, then the only
+ * way that a SETCLIENTID_CONFIRM to pos can succeed is
+ * if new and pos point to the same server:
+ */
+found:
+ refcount_inc(&pos->cl_count);
+ spin_unlock(&nn->nfs_client_lock);
+
+ nfs_put_client(prev);
+ prev = pos;
+
+ status = nfs4_proc_setclientid_confirm(pos, &clid, cred);
+ switch (status) {
+ case -NFS4ERR_STALE_CLIENTID:
+ break;
+ case 0:
+ nfs4_swap_callback_idents(pos, new);
+ pos->cl_confirm = new->cl_confirm;
+ nfs_mark_client_ready(pos, NFS_CS_READY);
+
+ prev = NULL;
+ *result = pos;
+ goto out;
+ case -ERESTARTSYS:
+ case -ETIMEDOUT:
+ /* The callback path may have been inadvertently
+ * changed. Schedule recovery!
+ */
+ nfs4_schedule_path_down_recovery(pos);
+ goto out;
+ default:
+ goto out;
+ }
+
+ spin_lock(&nn->nfs_client_lock);
+ }
+out_unlock:
+ spin_unlock(&nn->nfs_client_lock);
+
+ /* No match found. The server lost our clientid */
+out:
+ nfs_put_client(prev);
+ return status;
+}
+
+/**
+ * nfs40_discover_server_trunking - Detect server IP address trunking (mv0)
+ *
+ * @clp: nfs_client under test
+ * @result: OUT: found nfs_client, or clp
+ * @cred: credential to use for trunking test
+ *
+ * Returns zero, a negative errno, or a negative NFS4ERR status.
+ * If zero is returned, an nfs_client pointer is planted in
+ * "result".
+ *
+ * Note: The returned client may not yet be marked ready.
+ */
+int nfs40_discover_server_trunking(struct nfs_client *clp,
+ struct nfs_client **result,
+ const struct cred *cred)
+{
+ struct nfs4_setclientid_res clid = {
+ .clientid = clp->cl_clientid,
+ .confirm = clp->cl_confirm,
+ };
+ struct nfs_net *nn = net_generic(clp->cl_net, nfs_net_id);
+ unsigned short port;
+ int status;
+
+ port = nn->nfs_callback_tcpport;
+ if (clp->cl_addr.ss_family == AF_INET6)
+ port = nn->nfs_callback_tcpport6;
+
+ status = nfs4_proc_setclientid(clp, NFS4_CALLBACK, port, cred, &clid);
+ if (status != 0)
+ goto out;
+ clp->cl_clientid = clid.clientid;
+ clp->cl_confirm = clid.confirm;
+
+ status = nfs40_walk_client_list(clp, result, cred);
+ if (status == 0) {
+ /* Sustain the lease, even if it's empty. If the clientid4
+ * goes stale it's of no use for trunking discovery. */
+ nfs4_schedule_state_renewal(*result);
+
+ /* If the client state need to recover, do it. */
+ if (clp->cl_state)
+ nfs4_schedule_state_manager(clp);
+ }
+out:
+ return status;
+}
+
+
diff --git a/fs/nfs/nfs40proc.c b/fs/nfs/nfs40proc.c
index 6d27dedad055..b2cc7519b226 100644
--- a/fs/nfs/nfs40proc.c
+++ b/fs/nfs/nfs40proc.c
@@ -22,3 +22,12 @@ const struct rpc_call_ops nfs40_call_sync_ops = {
.rpc_call_prepare = nfs40_call_sync_prepare,
.rpc_call_done = nfs40_call_sync_done,
};
+
+const struct nfs4_state_recovery_ops nfs40_reboot_recovery_ops = {
+ .owner_flag_bit = NFS_OWNER_RECLAIM_REBOOT,
+ .state_flag_bit = NFS_STATE_RECLAIM_REBOOT,
+ .recover_open = nfs4_open_reclaim,
+ .recover_lock = nfs4_lock_reclaim,
+ .establish_clid = nfs4_init_clientid,
+ .detect_trunking = nfs40_discover_server_trunking,
+};
diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h
index 1b4b32d1b0ef..50e4a4deea48 100644
--- a/fs/nfs/nfs4_fs.h
+++ b/fs/nfs/nfs4_fs.h
@@ -277,6 +277,11 @@ int nfs_atomic_open(struct inode *, struct dentry *, struct file *,
/* fs_context.c */
extern struct file_system_type nfs4_fs_type;
+/* nfs4client.c */
+struct nfs_net;
+int nfs4_match_client(struct nfs_client *pos, struct nfs_client *new,
+ struct nfs_client **prev, struct nfs_net *nn);
+
/* nfs4namespace.c */
struct rpc_clnt *nfs4_negotiate_security(struct rpc_clnt *, struct inode *,
const struct qstr *);
@@ -345,6 +350,8 @@ extern void nfs4_update_changeattr(struct inode *dir,
unsigned long cache_validity);
extern int nfs4_buf_to_pages_noslab(const void *buf, size_t buflen,
struct page **pages);
+extern int nfs4_open_reclaim(struct nfs4_state_owner *, struct nfs4_state *);
+extern int nfs4_lock_reclaim(struct nfs4_state *state, struct file_lock *request);
#if defined(CONFIG_NFS_V4_1)
extern int nfs41_sequence_done(struct rpc_task *, struct nfs4_sequence_res *);
diff --git a/fs/nfs/nfs4client.c b/fs/nfs/nfs4client.c
index 96bccefbe2cb..517cf8af2943 100644
--- a/fs/nfs/nfs4client.c
+++ b/fs/nfs/nfs4client.c
@@ -490,37 +490,6 @@ struct nfs_client *nfs4_init_client(struct nfs_client *clp,
return ERR_PTR(error);
}
-/*
- * SETCLIENTID just did a callback update with the callback ident in
- * "drop," but server trunking discovery claims "drop" and "keep" are
- * actually the same server. Swap the callback IDs so that "keep"
- * will continue to use the callback ident the server now knows about,
- * and so that "keep"'s original callback ident is destroyed when
- * "drop" is freed.
- */
-static void nfs4_swap_callback_idents(struct nfs_client *keep,
- struct nfs_client *drop)
-{
- struct nfs_net *nn = net_generic(keep->cl_net, nfs_net_id);
- unsigned int save = keep->cl_cb_ident;
-
- if (keep->cl_cb_ident == drop->cl_cb_ident)
- return;
-
- dprintk("%s: keeping callback ident %u and dropping ident %u\n",
- __func__, keep->cl_cb_ident, drop->cl_cb_ident);
-
- spin_lock(&nn->nfs_client_lock);
-
- idr_replace(&nn->cb_ident_idr, keep, drop->cl_cb_ident);
- keep->cl_cb_ident = drop->cl_cb_ident;
-
- idr_replace(&nn->cb_ident_idr, drop, save);
- drop->cl_cb_ident = save;
-
- spin_unlock(&nn->nfs_client_lock);
-}
-
static bool nfs4_match_client_owner_id(const struct nfs_client *clp1,
const struct nfs_client *clp2)
{
@@ -529,13 +498,8 @@ static bool nfs4_match_client_owner_id(const struct nfs_client *clp1,
return strcmp(clp1->cl_owner_id, clp2->cl_owner_id) == 0;
}
-static bool nfs4_same_verifier(nfs4_verifier *v1, nfs4_verifier *v2)
-{
- return memcmp(v1->data, v2->data, sizeof(v1->data)) == 0;
-}
-
-static int nfs4_match_client(struct nfs_client *pos, struct nfs_client *new,
- struct nfs_client **prev, struct nfs_net *nn)
+int nfs4_match_client(struct nfs_client *pos, struct nfs_client *new,
+ struct nfs_client **prev, struct nfs_net *nn)
{
int status;
@@ -578,98 +542,6 @@ static int nfs4_match_client(struct nfs_client *pos, struct nfs_client *new,
return 0;
}
-/**
- * nfs40_walk_client_list - Find server that recognizes a client ID
- *
- * @new: nfs_client with client ID to test
- * @result: OUT: found nfs_client, or new
- * @cred: credential to use for trunking test
- *
- * Returns zero, a negative errno, or a negative NFS4ERR status.
- * If zero is returned, an nfs_client pointer is planted in "result."
- *
- * NB: nfs40_walk_client_list() relies on the new nfs_client being
- * the last nfs_client on the list.
- */
-int nfs40_walk_client_list(struct nfs_client *new,
- struct nfs_client **result,
- const struct cred *cred)
-{
- struct nfs_net *nn = net_generic(new->cl_net, nfs_net_id);
- struct nfs_client *pos, *prev = NULL;
- struct nfs4_setclientid_res clid = {
- .clientid = new->cl_clientid,
- .confirm = new->cl_confirm,
- };
- int status = -NFS4ERR_STALE_CLIENTID;
-
- spin_lock(&nn->nfs_client_lock);
- list_for_each_entry(pos, &nn->nfs_client_list, cl_share_link) {
-
- if (pos == new)
- goto found;
-
- status = nfs4_match_client(pos, new, &prev, nn);
- if (status < 0)
- goto out_unlock;
- if (status != 0)
- continue;
- /*
- * We just sent a new SETCLIENTID, which should have
- * caused the server to return a new cl_confirm. So if
- * cl_confirm is the same, then this is a different
- * server that just returned the same cl_confirm by
- * coincidence:
- */
- if ((new != pos) && nfs4_same_verifier(&pos->cl_confirm,
- &new->cl_confirm))
- continue;
- /*
- * But if the cl_confirm's are different, then the only
- * way that a SETCLIENTID_CONFIRM to pos can succeed is
- * if new and pos point to the same server:
- */
-found:
- refcount_inc(&pos->cl_count);
- spin_unlock(&nn->nfs_client_lock);
-
- nfs_put_client(prev);
- prev = pos;
-
- status = nfs4_proc_setclientid_confirm(pos, &clid, cred);
- switch (status) {
- case -NFS4ERR_STALE_CLIENTID:
- break;
- case 0:
- nfs4_swap_callback_idents(pos, new);
- pos->cl_confirm = new->cl_confirm;
- nfs_mark_client_ready(pos, NFS_CS_READY);
-
- prev = NULL;
- *result = pos;
- goto out;
- case -ERESTARTSYS:
- case -ETIMEDOUT:
- /* The callback path may have been inadvertently
- * changed. Schedule recovery!
- */
- nfs4_schedule_path_down_recovery(pos);
- goto out;
- default:
- goto out;
- }
-
- spin_lock(&nn->nfs_client_lock);
- }
-out_unlock:
- spin_unlock(&nn->nfs_client_lock);
-
- /* No match found. The server lost our clientid */
-out:
- nfs_put_client(prev);
- return status;
-}
-
#ifdef CONFIG_NFS_V4_1
/*
* Returns true if the server major ids match
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 0f9494eb02e6..54f61b34e372 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -2331,7 +2331,7 @@ static int nfs4_do_open_reclaim(struct nfs_open_context *ctx, struct nfs4_state
return err;
}
-static int nfs4_open_reclaim(struct nfs4_state_owner *sp, struct nfs4_state *state)
+int nfs4_open_reclaim(struct nfs4_state_owner *sp, struct nfs4_state *state)
{
struct nfs_open_context *ctx;
int ret;
@@ -7649,7 +7649,7 @@ static int _nfs4_do_setlk(struct nfs4_state *state, int cmd, struct file_lock *f
return ret;
}
-static int nfs4_lock_reclaim(struct nfs4_state *state, struct file_lock *request)
+int nfs4_lock_reclaim(struct nfs4_state *state, struct file_lock *request)
{
struct nfs_server *server = NFS_SERVER(state->inode);
struct nfs4_exception exception = {
@@ -10783,15 +10783,6 @@ static bool nfs4_match_stateid(const nfs4_stateid *s1,
}
-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,
- .recover_open = nfs4_open_reclaim,
- .recover_lock = nfs4_lock_reclaim,
- .establish_clid = nfs4_init_clientid,
- .detect_trunking = nfs40_discover_server_trunking,
-};
-
#if defined(CONFIG_NFS_V4_1)
static const struct nfs4_state_recovery_ops nfs41_reboot_recovery_ops = {
.owner_flag_bit = NFS_OWNER_RECLAIM_REBOOT,
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
index cd4b30b79dcf..5edc11cb2de0 100644
--- a/fs/nfs/nfs4state.c
+++ b/fs/nfs/nfs4state.c
@@ -142,55 +142,6 @@ int nfs4_init_clientid(struct nfs_client *clp, const struct cred *cred)
return status;
}
-/**
- * nfs40_discover_server_trunking - Detect server IP address trunking (mv0)
- *
- * @clp: nfs_client under test
- * @result: OUT: found nfs_client, or clp
- * @cred: credential to use for trunking test
- *
- * Returns zero, a negative errno, or a negative NFS4ERR status.
- * If zero is returned, an nfs_client pointer is planted in
- * "result".
- *
- * Note: The returned client may not yet be marked ready.
- */
-int nfs40_discover_server_trunking(struct nfs_client *clp,
- struct nfs_client **result,
- const struct cred *cred)
-{
- struct nfs4_setclientid_res clid = {
- .clientid = clp->cl_clientid,
- .confirm = clp->cl_confirm,
- };
- struct nfs_net *nn = net_generic(clp->cl_net, nfs_net_id);
- unsigned short port;
- int status;
-
- port = nn->nfs_callback_tcpport;
- if (clp->cl_addr.ss_family == AF_INET6)
- port = nn->nfs_callback_tcpport6;
-
- status = nfs4_proc_setclientid(clp, NFS4_CALLBACK, port, cred, &clid);
- if (status != 0)
- goto out;
- clp->cl_clientid = clid.clientid;
- clp->cl_confirm = clid.confirm;
-
- status = nfs40_walk_client_list(clp, result, cred);
- if (status == 0) {
- /* Sustain the lease, even if it's empty. If the clientid4
- * goes stale it's of no use for trunking discovery. */
- nfs4_schedule_state_renewal(*result);
-
- /* If the client state need to recover, do it. */
- if (clp->cl_state)
- nfs4_schedule_state_manager(clp);
- }
-out:
- return status;
-}
-
const struct cred *nfs4_get_machine_cred(struct nfs_client *clp)
{
return get_cred(rpc_machine_cred());
--
2.52.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v2 03/14] NFS: Split out the nfs40_nograce_recovery_ops into nfs40proc.c
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 ` Anna Schumaker
2026-01-26 20:39 ` [PATCH v2 04/14] NFS: Split out the nfs40_state_renewal_ops " Anna Schumaker
` (10 subsequent siblings)
13 siblings, 0 replies; 16+ messages in thread
From: Anna Schumaker @ 2026-01-26 20:39 UTC (permalink / raw)
To: linux-nfs, trond.myklebust; +Cc: anna
From: Anna Schumaker <anna.schumaker@oracle.com>
Signed-off-by: Anna Schumaker <anna.schumaker@oracle.com>
---
fs/nfs/nfs40.h | 1 +
fs/nfs/nfs40proc.c | 22 ++++++++++++++++++++++
fs/nfs/nfs4_fs.h | 6 ++++++
fs/nfs/nfs4proc.c | 34 +++++-----------------------------
4 files changed, 34 insertions(+), 29 deletions(-)
diff --git a/fs/nfs/nfs40.h b/fs/nfs/nfs40.h
index ad57172b49a3..c64e5ff6c9ff 100644
--- a/fs/nfs/nfs40.h
+++ b/fs/nfs/nfs40.h
@@ -6,6 +6,7 @@
/* nfs40proc.c */
extern const struct rpc_call_ops nfs40_call_sync_ops;
extern const struct nfs4_state_recovery_ops nfs40_reboot_recovery_ops;
+extern const struct nfs4_state_recovery_ops nfs40_nograce_recovery_ops;
/* nfs40state.c */
int nfs40_discover_server_trunking(struct nfs_client *clp,
diff --git a/fs/nfs/nfs40proc.c b/fs/nfs/nfs40proc.c
index b2cc7519b226..867afdf4ecf4 100644
--- a/fs/nfs/nfs40proc.c
+++ b/fs/nfs/nfs40proc.c
@@ -18,6 +18,20 @@ static void nfs40_call_sync_done(struct rpc_task *task, void *calldata)
nfs4_sequence_done(task, data->seq_res);
}
+static void nfs40_clear_delegation_stateid(struct nfs4_state *state)
+{
+ if (rcu_access_pointer(NFS_I(state->inode)->delegation) != NULL)
+ nfs_finish_clear_delegation_stateid(state, NULL);
+}
+
+static int nfs40_open_expired(struct nfs4_state_owner *sp, struct nfs4_state *state)
+{
+ /* NFSv4.0 doesn't allow for delegation recovery on open expire */
+ nfs40_clear_delegation_stateid(state);
+ nfs_state_clear_open_state_flags(state);
+ return nfs4_open_expired(sp, state);
+}
+
const struct rpc_call_ops nfs40_call_sync_ops = {
.rpc_call_prepare = nfs40_call_sync_prepare,
.rpc_call_done = nfs40_call_sync_done,
@@ -31,3 +45,11 @@ const struct nfs4_state_recovery_ops nfs40_reboot_recovery_ops = {
.establish_clid = nfs4_init_clientid,
.detect_trunking = nfs40_discover_server_trunking,
};
+
+const struct nfs4_state_recovery_ops nfs40_nograce_recovery_ops = {
+ .owner_flag_bit = NFS_OWNER_RECLAIM_NOGRACE,
+ .state_flag_bit = NFS_STATE_RECLAIM_NOGRACE,
+ .recover_open = nfs40_open_expired,
+ .recover_lock = nfs4_lock_expired,
+ .establish_clid = nfs4_init_clientid,
+};
diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h
index 50e4a4deea48..b56113b70d88 100644
--- a/fs/nfs/nfs4_fs.h
+++ b/fs/nfs/nfs4_fs.h
@@ -351,7 +351,13 @@ extern void nfs4_update_changeattr(struct inode *dir,
extern int nfs4_buf_to_pages_noslab(const void *buf, size_t buflen,
struct page **pages);
extern int nfs4_open_reclaim(struct nfs4_state_owner *, struct nfs4_state *);
+extern int nfs4_open_expired(struct nfs4_state_owner *, struct nfs4_state *);
extern int nfs4_lock_reclaim(struct nfs4_state *state, struct file_lock *request);
+extern int nfs4_lock_expired(struct nfs4_state *state, struct file_lock *request);
+extern void nfs_state_clear_delegation(struct nfs4_state *state);
+extern void nfs_finish_clear_delegation_stateid(struct nfs4_state *state,
+ const nfs4_stateid *stateid);
+extern void nfs_state_clear_open_state_flags(struct nfs4_state *state);
#if defined(CONFIG_NFS_V4_1)
extern int nfs41_sequence_done(struct rpc_task *, struct nfs4_sequence_res *);
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 54f61b34e372..00a92e6653a1 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -1848,7 +1848,7 @@ static void nfs_state_set_open_stateid(struct nfs4_state *state,
write_sequnlock(&state->seqlock);
}
-static void nfs_state_clear_open_state_flags(struct nfs4_state *state)
+void nfs_state_clear_open_state_flags(struct nfs4_state *state)
{
clear_bit(NFS_O_RDWR_STATE, &state->flags);
clear_bit(NFS_O_WRONLY_STATE, &state->flags);
@@ -1870,7 +1870,7 @@ static void nfs_state_set_delegation(struct nfs4_state *state,
write_sequnlock(&state->seqlock);
}
-static void nfs_state_clear_delegation(struct nfs4_state *state)
+void nfs_state_clear_delegation(struct nfs4_state *state)
{
write_seqlock(&state->seqlock);
nfs4_stateid_copy(&state->stateid, &state->open_stateid);
@@ -2862,7 +2862,7 @@ static int nfs4_do_open_expired(struct nfs_open_context *ctx, struct nfs4_state
return err;
}
-static int nfs4_open_expired(struct nfs4_state_owner *sp, struct nfs4_state *state)
+int nfs4_open_expired(struct nfs4_state_owner *sp, struct nfs4_state *state)
{
struct nfs_open_context *ctx;
int ret;
@@ -2875,27 +2875,13 @@ static int nfs4_open_expired(struct nfs4_state_owner *sp, struct nfs4_state *sta
return ret;
}
-static void nfs_finish_clear_delegation_stateid(struct nfs4_state *state,
+void nfs_finish_clear_delegation_stateid(struct nfs4_state *state,
const nfs4_stateid *stateid)
{
nfs_remove_bad_delegation(state->inode, stateid);
nfs_state_clear_delegation(state);
}
-static void nfs40_clear_delegation_stateid(struct nfs4_state *state)
-{
- if (rcu_access_pointer(NFS_I(state->inode)->delegation) != NULL)
- nfs_finish_clear_delegation_stateid(state, NULL);
-}
-
-static int nfs40_open_expired(struct nfs4_state_owner *sp, struct nfs4_state *state)
-{
- /* NFSv4.0 doesn't allow for delegation recovery on open expire */
- nfs40_clear_delegation_stateid(state);
- nfs_state_clear_open_state_flags(state);
- return nfs4_open_expired(sp, state);
-}
-
static int nfs40_test_and_free_expired_stateid(struct nfs_server *server,
nfs4_stateid *stateid, const struct cred *cred)
{
@@ -7669,7 +7655,7 @@ int nfs4_lock_reclaim(struct nfs4_state *state, struct file_lock *request)
return err;
}
-static int nfs4_lock_expired(struct nfs4_state *state, struct file_lock *request)
+int nfs4_lock_expired(struct nfs4_state *state, struct file_lock *request)
{
struct nfs_server *server = NFS_SERVER(state->inode);
struct nfs4_exception exception = {
@@ -10793,17 +10779,7 @@ static const struct nfs4_state_recovery_ops nfs41_reboot_recovery_ops = {
.reclaim_complete = nfs41_proc_reclaim_complete,
.detect_trunking = nfs41_discover_server_trunking,
};
-#endif /* CONFIG_NFS_V4_1 */
-static const struct nfs4_state_recovery_ops nfs40_nograce_recovery_ops = {
- .owner_flag_bit = NFS_OWNER_RECLAIM_NOGRACE,
- .state_flag_bit = NFS_STATE_RECLAIM_NOGRACE,
- .recover_open = nfs40_open_expired,
- .recover_lock = nfs4_lock_expired,
- .establish_clid = nfs4_init_clientid,
-};
-
-#if defined(CONFIG_NFS_V4_1)
static const struct nfs4_state_recovery_ops nfs41_nograce_recovery_ops = {
.owner_flag_bit = NFS_OWNER_RECLAIM_NOGRACE,
.state_flag_bit = NFS_STATE_RECLAIM_NOGRACE,
--
2.52.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v2 04/14] NFS: Split out the nfs40_state_renewal_ops into nfs40proc.c
2026-01-26 20:39 [PATCH v2 00/14] NFS: Make NFS v4.0 KConfig-urable Anna Schumaker
` (2 preceding siblings ...)
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 ` Anna Schumaker
2026-01-26 20:39 ` [PATCH v2 05/14] NFS: Split out the nfs40_mig_recovery_ops to nfs40proc.c Anna Schumaker
` (9 subsequent siblings)
13 siblings, 0 replies; 16+ messages in thread
From: Anna Schumaker @ 2026-01-26 20:39 UTC (permalink / raw)
To: linux-nfs, trond.myklebust; +Cc: anna
From: Anna Schumaker <anna.schumaker@oracle.com>
Signed-off-by: Anna Schumaker <anna.schumaker@oracle.com>
---
fs/nfs/nfs40.h | 1 +
fs/nfs/nfs40proc.c | 100 ++++++++++++++++++++++++++++++++++++++++++++
fs/nfs/nfs4_fs.h | 1 +
fs/nfs/nfs4proc.c | 102 +--------------------------------------------
4 files changed, 103 insertions(+), 101 deletions(-)
diff --git a/fs/nfs/nfs40.h b/fs/nfs/nfs40.h
index c64e5ff6c9ff..fd606b4a044a 100644
--- a/fs/nfs/nfs40.h
+++ b/fs/nfs/nfs40.h
@@ -7,6 +7,7 @@
extern const struct rpc_call_ops nfs40_call_sync_ops;
extern const struct nfs4_state_recovery_ops nfs40_reboot_recovery_ops;
extern const struct nfs4_state_recovery_ops nfs40_nograce_recovery_ops;
+extern const struct nfs4_state_maintenance_ops nfs40_state_renewal_ops;
/* nfs40state.c */
int nfs40_discover_server_trunking(struct nfs_client *clp,
diff --git a/fs/nfs/nfs40proc.c b/fs/nfs/nfs40proc.c
index 867afdf4ecf4..96ce463c951b 100644
--- a/fs/nfs/nfs40proc.c
+++ b/fs/nfs/nfs40proc.c
@@ -3,7 +3,9 @@
#include <linux/nfs.h>
#include <linux/sunrpc/sched.h>
#include <linux/nfs_fs.h>
+#include "internal.h"
#include "nfs4_fs.h"
+#include "nfs4trace.h"
static void nfs40_call_sync_prepare(struct rpc_task *task, void *calldata)
{
@@ -32,6 +34,98 @@ static int nfs40_open_expired(struct nfs4_state_owner *sp, struct nfs4_state *st
return nfs4_open_expired(sp, state);
}
+struct nfs4_renewdata {
+ struct nfs_client *client;
+ unsigned long timestamp;
+};
+
+/*
+ * nfs4_proc_async_renew(): This is not one of the nfs_rpc_ops; it is a special
+ * standalone procedure for queueing an asynchronous RENEW.
+ */
+static void nfs4_renew_release(void *calldata)
+{
+ struct nfs4_renewdata *data = calldata;
+ struct nfs_client *clp = data->client;
+
+ if (refcount_read(&clp->cl_count) > 1)
+ nfs4_schedule_state_renewal(clp);
+ nfs_put_client(clp);
+ kfree(data);
+}
+
+static void nfs4_renew_done(struct rpc_task *task, void *calldata)
+{
+ struct nfs4_renewdata *data = calldata;
+ struct nfs_client *clp = data->client;
+ unsigned long timestamp = data->timestamp;
+
+ trace_nfs4_renew_async(clp, task->tk_status);
+ switch (task->tk_status) {
+ case 0:
+ break;
+ case -NFS4ERR_LEASE_MOVED:
+ nfs4_schedule_lease_moved_recovery(clp);
+ break;
+ default:
+ /* Unless we're shutting down, schedule state recovery! */
+ if (test_bit(NFS_CS_RENEWD, &clp->cl_res_state) == 0)
+ return;
+ if (task->tk_status != NFS4ERR_CB_PATH_DOWN) {
+ nfs4_schedule_lease_recovery(clp);
+ return;
+ }
+ nfs4_schedule_path_down_recovery(clp);
+ }
+ do_renew_lease(clp, timestamp);
+}
+
+static const struct rpc_call_ops nfs4_renew_ops = {
+ .rpc_call_done = nfs4_renew_done,
+ .rpc_release = nfs4_renew_release,
+};
+
+static int nfs4_proc_async_renew(struct nfs_client *clp, const struct cred *cred, unsigned renew_flags)
+{
+ struct rpc_message msg = {
+ .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_RENEW],
+ .rpc_argp = clp,
+ .rpc_cred = cred,
+ };
+ struct nfs4_renewdata *data;
+
+ if (renew_flags == 0)
+ return 0;
+ if (!refcount_inc_not_zero(&clp->cl_count))
+ return -EIO;
+ data = kmalloc(sizeof(*data), GFP_NOFS);
+ if (data == NULL) {
+ nfs_put_client(clp);
+ return -ENOMEM;
+ }
+ data->client = clp;
+ data->timestamp = jiffies;
+ return rpc_call_async(clp->cl_rpcclient, &msg, RPC_TASK_TIMEOUT,
+ &nfs4_renew_ops, data);
+}
+
+static int nfs4_proc_renew(struct nfs_client *clp, const struct cred *cred)
+{
+ struct rpc_message msg = {
+ .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_RENEW],
+ .rpc_argp = clp,
+ .rpc_cred = cred,
+ };
+ unsigned long now = jiffies;
+ int status;
+
+ status = rpc_call_sync(clp->cl_rpcclient, &msg, RPC_TASK_TIMEOUT);
+ if (status < 0)
+ return status;
+ do_renew_lease(clp, now);
+ return 0;
+}
+
const struct rpc_call_ops nfs40_call_sync_ops = {
.rpc_call_prepare = nfs40_call_sync_prepare,
.rpc_call_done = nfs40_call_sync_done,
@@ -53,3 +147,9 @@ const struct nfs4_state_recovery_ops nfs40_nograce_recovery_ops = {
.recover_lock = nfs4_lock_expired,
.establish_clid = nfs4_init_clientid,
};
+
+const struct nfs4_state_maintenance_ops nfs40_state_renewal_ops = {
+ .sched_state_renewal = nfs4_proc_async_renew,
+ .get_state_renewal_cred = nfs4_get_renew_cred,
+ .renew_lease = nfs4_proc_renew,
+};
diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h
index b56113b70d88..eb89d57a9289 100644
--- a/fs/nfs/nfs4_fs.h
+++ b/fs/nfs/nfs4_fs.h
@@ -358,6 +358,7 @@ extern void nfs_state_clear_delegation(struct nfs4_state *state);
extern void nfs_finish_clear_delegation_stateid(struct nfs4_state *state,
const nfs4_stateid *stateid);
extern void nfs_state_clear_open_state_flags(struct nfs4_state *state);
+extern void do_renew_lease(struct nfs_client *clp, unsigned long timestamp);
#if defined(CONFIG_NFS_V4_1)
extern int nfs41_sequence_done(struct rpc_task *, struct nfs4_sequence_res *);
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 00a92e6653a1..a52e985149bf 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -754,7 +754,7 @@ static bool _nfs4_is_integrity_protected(struct nfs_client *clp)
return (flavor == RPC_AUTH_GSS_KRB5I) || (flavor == RPC_AUTH_GSS_KRB5P);
}
-static void do_renew_lease(struct nfs_client *clp, unsigned long timestamp)
+void do_renew_lease(struct nfs_client *clp, unsigned long timestamp)
{
spin_lock(&clp->cl_lock);
if (time_before(clp->cl_last_renewal,timestamp))
@@ -5971,98 +5971,6 @@ int nfs4_proc_commit(struct file *dst, __u64 offset, __u32 count, struct nfs_com
return status;
}
-struct nfs4_renewdata {
- struct nfs_client *client;
- unsigned long timestamp;
-};
-
-/*
- * nfs4_proc_async_renew(): This is not one of the nfs_rpc_ops; it is a special
- * standalone procedure for queueing an asynchronous RENEW.
- */
-static void nfs4_renew_release(void *calldata)
-{
- struct nfs4_renewdata *data = calldata;
- struct nfs_client *clp = data->client;
-
- if (refcount_read(&clp->cl_count) > 1)
- nfs4_schedule_state_renewal(clp);
- nfs_put_client(clp);
- kfree(data);
-}
-
-static void nfs4_renew_done(struct rpc_task *task, void *calldata)
-{
- struct nfs4_renewdata *data = calldata;
- struct nfs_client *clp = data->client;
- unsigned long timestamp = data->timestamp;
-
- trace_nfs4_renew_async(clp, task->tk_status);
- switch (task->tk_status) {
- case 0:
- break;
- case -NFS4ERR_LEASE_MOVED:
- nfs4_schedule_lease_moved_recovery(clp);
- break;
- default:
- /* Unless we're shutting down, schedule state recovery! */
- if (test_bit(NFS_CS_RENEWD, &clp->cl_res_state) == 0)
- return;
- if (task->tk_status != NFS4ERR_CB_PATH_DOWN) {
- nfs4_schedule_lease_recovery(clp);
- return;
- }
- nfs4_schedule_path_down_recovery(clp);
- }
- do_renew_lease(clp, timestamp);
-}
-
-static const struct rpc_call_ops nfs4_renew_ops = {
- .rpc_call_done = nfs4_renew_done,
- .rpc_release = nfs4_renew_release,
-};
-
-static int nfs4_proc_async_renew(struct nfs_client *clp, const struct cred *cred, unsigned renew_flags)
-{
- struct rpc_message msg = {
- .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_RENEW],
- .rpc_argp = clp,
- .rpc_cred = cred,
- };
- struct nfs4_renewdata *data;
-
- if (renew_flags == 0)
- return 0;
- if (!refcount_inc_not_zero(&clp->cl_count))
- return -EIO;
- data = kmalloc(sizeof(*data), GFP_NOFS);
- if (data == NULL) {
- nfs_put_client(clp);
- return -ENOMEM;
- }
- data->client = clp;
- data->timestamp = jiffies;
- return rpc_call_async(clp->cl_rpcclient, &msg, RPC_TASK_TIMEOUT,
- &nfs4_renew_ops, data);
-}
-
-static int nfs4_proc_renew(struct nfs_client *clp, const struct cred *cred)
-{
- struct rpc_message msg = {
- .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_RENEW],
- .rpc_argp = clp,
- .rpc_cred = cred,
- };
- unsigned long now = jiffies;
- int status;
-
- status = rpc_call_sync(clp->cl_rpcclient, &msg, RPC_TASK_TIMEOUT);
- if (status < 0)
- return status;
- do_renew_lease(clp, now);
- return 0;
-}
-
static bool nfs4_server_supports_acls(const struct nfs_server *server,
enum nfs4_acl_type type)
{
@@ -10787,15 +10695,7 @@ static const struct nfs4_state_recovery_ops nfs41_nograce_recovery_ops = {
.recover_lock = nfs41_lock_expired,
.establish_clid = nfs41_init_clientid,
};
-#endif /* CONFIG_NFS_V4_1 */
-static const struct nfs4_state_maintenance_ops nfs40_state_renewal_ops = {
- .sched_state_renewal = nfs4_proc_async_renew,
- .get_state_renewal_cred = nfs4_get_renew_cred,
- .renew_lease = nfs4_proc_renew,
-};
-
-#if defined(CONFIG_NFS_V4_1)
static const struct nfs4_state_maintenance_ops nfs41_state_renewal_ops = {
.sched_state_renewal = nfs41_proc_async_sequence,
.get_state_renewal_cred = nfs4_get_machine_cred,
--
2.52.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v2 05/14] NFS: Split out the nfs40_mig_recovery_ops to nfs40proc.c
2026-01-26 20:39 [PATCH v2 00/14] NFS: Make NFS v4.0 KConfig-urable Anna Schumaker
` (3 preceding siblings ...)
2026-01-26 20:39 ` [PATCH v2 04/14] NFS: Split out the nfs40_state_renewal_ops " Anna Schumaker
@ 2026-01-26 20:39 ` Anna Schumaker
2026-01-26 20:39 ` [PATCH v2 06/14] NFS: Move the NFS v4.0 minor version ops into nfs40proc.c Anna Schumaker
` (8 subsequent siblings)
13 siblings, 0 replies; 16+ messages in thread
From: Anna Schumaker @ 2026-01-26 20:39 UTC (permalink / raw)
To: linux-nfs, trond.myklebust; +Cc: anna
From: Anna Schumaker <anna.schumaker@oracle.com>
Signed-off-by: Anna Schumaker <anna.schumaker@oracle.com>
---
fs/nfs/nfs40.h | 1 +
fs/nfs/nfs40proc.c | 101 +++++++++++++++++++++++++++++++++++++++
fs/nfs/nfs4_fs.h | 6 +++
fs/nfs/nfs4proc.c | 115 +++------------------------------------------
4 files changed, 114 insertions(+), 109 deletions(-)
diff --git a/fs/nfs/nfs40.h b/fs/nfs/nfs40.h
index fd606b4a044a..a04fb2390fa7 100644
--- a/fs/nfs/nfs40.h
+++ b/fs/nfs/nfs40.h
@@ -8,6 +8,7 @@ extern const struct rpc_call_ops nfs40_call_sync_ops;
extern const struct nfs4_state_recovery_ops nfs40_reboot_recovery_ops;
extern const struct nfs4_state_recovery_ops nfs40_nograce_recovery_ops;
extern const struct nfs4_state_maintenance_ops nfs40_state_renewal_ops;
+extern const struct nfs4_mig_recovery_ops nfs40_mig_recovery_ops;
/* nfs40state.c */
int nfs40_discover_server_trunking(struct nfs_client *clp,
diff --git a/fs/nfs/nfs40proc.c b/fs/nfs/nfs40proc.c
index 96ce463c951b..736e782a27e1 100644
--- a/fs/nfs/nfs40proc.c
+++ b/fs/nfs/nfs40proc.c
@@ -126,6 +126,102 @@ static int nfs4_proc_renew(struct nfs_client *clp, const struct cred *cred)
return 0;
}
+/*
+ * This operation also signals the server that this client is
+ * performing migration recovery. The server can stop returning
+ * NFS4ERR_LEASE_MOVED to this client. A RENEW operation is
+ * appended to this compound to identify the client ID which is
+ * performing recovery.
+ */
+static int _nfs40_proc_get_locations(struct nfs_server *server,
+ struct nfs_fh *fhandle,
+ struct nfs4_fs_locations *locations,
+ struct page *page, const struct cred *cred)
+{
+ struct rpc_clnt *clnt = server->client;
+ u32 bitmask[2] = {
+ [0] = FATTR4_WORD0_FSID | FATTR4_WORD0_FS_LOCATIONS,
+ };
+ struct nfs4_fs_locations_arg args = {
+ .clientid = server->nfs_client->cl_clientid,
+ .fh = fhandle,
+ .page = page,
+ .bitmask = bitmask,
+ .migration = 1, /* skip LOOKUP */
+ .renew = 1, /* append RENEW */
+ };
+ struct nfs4_fs_locations_res res = {
+ .fs_locations = locations,
+ .migration = 1,
+ .renew = 1,
+ };
+ struct rpc_message msg = {
+ .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_FS_LOCATIONS],
+ .rpc_argp = &args,
+ .rpc_resp = &res,
+ .rpc_cred = cred,
+ };
+ unsigned long now = jiffies;
+ int status;
+
+ nfs_fattr_init(locations->fattr);
+ locations->server = server;
+ locations->nlocations = 0;
+
+ nfs4_init_sequence(&args.seq_args, &res.seq_res, 0, 1);
+ status = nfs4_call_sync_sequence(clnt, server, &msg,
+ &args.seq_args, &res.seq_res);
+ if (status)
+ return status;
+
+ renew_lease(server, now);
+ return 0;
+}
+
+/*
+ * This operation also signals the server that this client is
+ * performing "lease moved" recovery. The server can stop
+ * returning NFS4ERR_LEASE_MOVED to this client. A RENEW operation
+ * is appended to this compound to identify the client ID which is
+ * performing recovery.
+ */
+static int _nfs40_proc_fsid_present(struct inode *inode, const struct cred *cred)
+{
+ struct nfs_server *server = NFS_SERVER(inode);
+ struct nfs_client *clp = NFS_SERVER(inode)->nfs_client;
+ struct rpc_clnt *clnt = server->client;
+ struct nfs4_fsid_present_arg args = {
+ .fh = NFS_FH(inode),
+ .clientid = clp->cl_clientid,
+ .renew = 1, /* append RENEW */
+ };
+ struct nfs4_fsid_present_res res = {
+ .renew = 1,
+ };
+ struct rpc_message msg = {
+ .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_FSID_PRESENT],
+ .rpc_argp = &args,
+ .rpc_resp = &res,
+ .rpc_cred = cred,
+ };
+ unsigned long now = jiffies;
+ int status;
+
+ res.fh = nfs_alloc_fhandle();
+ if (res.fh == NULL)
+ return -ENOMEM;
+
+ nfs4_init_sequence(&args.seq_args, &res.seq_res, 0, 1);
+ status = nfs4_call_sync_sequence(clnt, server, &msg,
+ &args.seq_args, &res.seq_res);
+ nfs_free_fhandle(res.fh);
+ if (status)
+ return status;
+
+ do_renew_lease(clp, now);
+ return 0;
+}
+
const struct rpc_call_ops nfs40_call_sync_ops = {
.rpc_call_prepare = nfs40_call_sync_prepare,
.rpc_call_done = nfs40_call_sync_done,
@@ -153,3 +249,8 @@ const struct nfs4_state_maintenance_ops nfs40_state_renewal_ops = {
.get_state_renewal_cred = nfs4_get_renew_cred,
.renew_lease = nfs4_proc_renew,
};
+
+const struct nfs4_mig_recovery_ops nfs40_mig_recovery_ops = {
+ .get_locations = _nfs40_proc_get_locations,
+ .fsid_present = _nfs40_proc_fsid_present,
+};
diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h
index eb89d57a9289..7f1fde3023a5 100644
--- a/fs/nfs/nfs4_fs.h
+++ b/fs/nfs/nfs4_fs.h
@@ -304,9 +304,15 @@ extern int nfs4_async_handle_error(struct rpc_task *task,
extern int nfs4_call_sync(struct rpc_clnt *, struct nfs_server *,
struct rpc_message *, struct nfs4_sequence_args *,
struct nfs4_sequence_res *, int);
+extern int nfs4_call_sync_sequence(struct rpc_clnt *clnt,
+ struct nfs_server *server,
+ struct rpc_message *msg,
+ struct nfs4_sequence_args *args,
+ struct nfs4_sequence_res *res);
extern void nfs4_init_sequence(struct nfs4_sequence_args *, struct nfs4_sequence_res *, int, int);
extern int nfs4_proc_setclientid(struct nfs_client *, u32, unsigned short, const struct cred *, struct nfs4_setclientid_res *);
extern int nfs4_proc_setclientid_confirm(struct nfs_client *, struct nfs4_setclientid_res *arg, const struct cred *);
+extern void renew_lease(const struct nfs_server *server, unsigned long timestamp);
extern int nfs4_proc_get_rootfh(struct nfs_server *, struct nfs_fh *,
struct nfs_fattr *, bool);
extern int nfs4_proc_bind_conn_to_session(struct nfs_client *, const struct cred *cred);
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index a52e985149bf..68c2925c404f 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -762,7 +762,7 @@ void do_renew_lease(struct nfs_client *clp, unsigned long timestamp)
spin_unlock(&clp->cl_lock);
}
-static void renew_lease(const struct nfs_server *server, unsigned long timestamp)
+void renew_lease(const struct nfs_server *server, unsigned long timestamp)
{
struct nfs_client *clp = server->nfs_client;
@@ -1207,11 +1207,11 @@ static int nfs4_do_call_sync(struct rpc_clnt *clnt,
return nfs4_call_sync_custom(&task_setup);
}
-static int nfs4_call_sync_sequence(struct rpc_clnt *clnt,
- struct nfs_server *server,
- struct rpc_message *msg,
- struct nfs4_sequence_args *args,
- struct nfs4_sequence_res *res)
+int nfs4_call_sync_sequence(struct rpc_clnt *clnt,
+ struct nfs_server *server,
+ struct rpc_message *msg,
+ struct nfs4_sequence_args *args,
+ struct nfs4_sequence_res *res)
{
unsigned short task_flags = 0;
@@ -8258,58 +8258,6 @@ int nfs4_proc_fs_locations(struct rpc_clnt *client, struct inode *dir,
return err;
}
-/*
- * This operation also signals the server that this client is
- * performing migration recovery. The server can stop returning
- * NFS4ERR_LEASE_MOVED to this client. A RENEW operation is
- * appended to this compound to identify the client ID which is
- * performing recovery.
- */
-static int _nfs40_proc_get_locations(struct nfs_server *server,
- struct nfs_fh *fhandle,
- struct nfs4_fs_locations *locations,
- struct page *page, const struct cred *cred)
-{
- struct rpc_clnt *clnt = server->client;
- u32 bitmask[2] = {
- [0] = FATTR4_WORD0_FSID | FATTR4_WORD0_FS_LOCATIONS,
- };
- struct nfs4_fs_locations_arg args = {
- .clientid = server->nfs_client->cl_clientid,
- .fh = fhandle,
- .page = page,
- .bitmask = bitmask,
- .migration = 1, /* skip LOOKUP */
- .renew = 1, /* append RENEW */
- };
- struct nfs4_fs_locations_res res = {
- .fs_locations = locations,
- .migration = 1,
- .renew = 1,
- };
- struct rpc_message msg = {
- .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_FS_LOCATIONS],
- .rpc_argp = &args,
- .rpc_resp = &res,
- .rpc_cred = cred,
- };
- unsigned long now = jiffies;
- int status;
-
- nfs_fattr_init(locations->fattr);
- locations->server = server;
- locations->nlocations = 0;
-
- nfs4_init_sequence(&args.seq_args, &res.seq_res, 0, 1);
- status = nfs4_call_sync_sequence(clnt, server, &msg,
- &args.seq_args, &res.seq_res);
- if (status)
- return status;
-
- renew_lease(server, now);
- return 0;
-}
-
#ifdef CONFIG_NFS_V4_1
/*
@@ -8422,50 +8370,6 @@ int nfs4_proc_get_locations(struct nfs_server *server,
return status;
}
-/*
- * This operation also signals the server that this client is
- * performing "lease moved" recovery. The server can stop
- * returning NFS4ERR_LEASE_MOVED to this client. A RENEW operation
- * is appended to this compound to identify the client ID which is
- * performing recovery.
- */
-static int _nfs40_proc_fsid_present(struct inode *inode, const struct cred *cred)
-{
- struct nfs_server *server = NFS_SERVER(inode);
- struct nfs_client *clp = NFS_SERVER(inode)->nfs_client;
- struct rpc_clnt *clnt = server->client;
- struct nfs4_fsid_present_arg args = {
- .fh = NFS_FH(inode),
- .clientid = clp->cl_clientid,
- .renew = 1, /* append RENEW */
- };
- struct nfs4_fsid_present_res res = {
- .renew = 1,
- };
- struct rpc_message msg = {
- .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_FSID_PRESENT],
- .rpc_argp = &args,
- .rpc_resp = &res,
- .rpc_cred = cred,
- };
- unsigned long now = jiffies;
- int status;
-
- res.fh = nfs_alloc_fhandle();
- if (res.fh == NULL)
- return -ENOMEM;
-
- nfs4_init_sequence(&args.seq_args, &res.seq_res, 0, 1);
- status = nfs4_call_sync_sequence(clnt, server, &msg,
- &args.seq_args, &res.seq_res);
- nfs_free_fhandle(res.fh);
- if (status)
- return status;
-
- do_renew_lease(clp, now);
- return 0;
-}
-
#ifdef CONFIG_NFS_V4_1
/*
@@ -10701,14 +10605,7 @@ static const struct nfs4_state_maintenance_ops nfs41_state_renewal_ops = {
.get_state_renewal_cred = nfs4_get_machine_cred,
.renew_lease = nfs4_proc_sequence,
};
-#endif
-static const struct nfs4_mig_recovery_ops nfs40_mig_recovery_ops = {
- .get_locations = _nfs40_proc_get_locations,
- .fsid_present = _nfs40_proc_fsid_present,
-};
-
-#if defined(CONFIG_NFS_V4_1)
static const struct nfs4_mig_recovery_ops nfs41_mig_recovery_ops = {
.get_locations = _nfs41_proc_get_locations,
.fsid_present = _nfs41_proc_fsid_present,
--
2.52.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v2 06/14] NFS: Move the NFS v4.0 minor version ops into nfs40proc.c
2026-01-26 20:39 [PATCH v2 00/14] NFS: Make NFS v4.0 KConfig-urable Anna Schumaker
` (4 preceding siblings ...)
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 ` Anna Schumaker
2026-01-26 20:39 ` [PATCH v2 07/14] NFS: Make the various NFS v4.0 operations static again Anna Schumaker
` (7 subsequent siblings)
13 siblings, 0 replies; 16+ messages in thread
From: Anna Schumaker @ 2026-01-26 20:39 UTC (permalink / raw)
To: linux-nfs, trond.myklebust; +Cc: anna
From: Anna Schumaker <anna.schumaker@oracle.com>
Signed-off-by: Anna Schumaker <anna.schumaker@oracle.com>
---
fs/nfs/nfs40.h | 1 +
fs/nfs/nfs40proc.c | 106 +++++++++++++++++++++++++++++++++++++++++
fs/nfs/nfs4_fs.h | 4 ++
fs/nfs/nfs4proc.c | 115 ++-------------------------------------------
4 files changed, 115 insertions(+), 111 deletions(-)
diff --git a/fs/nfs/nfs40.h b/fs/nfs/nfs40.h
index a04fb2390fa7..05ba9f1afe7c 100644
--- a/fs/nfs/nfs40.h
+++ b/fs/nfs/nfs40.h
@@ -9,6 +9,7 @@ extern const struct nfs4_state_recovery_ops nfs40_reboot_recovery_ops;
extern const struct nfs4_state_recovery_ops nfs40_nograce_recovery_ops;
extern const struct nfs4_state_maintenance_ops nfs40_state_renewal_ops;
extern const struct nfs4_mig_recovery_ops nfs40_mig_recovery_ops;
+extern const struct nfs4_minor_version_ops nfs_v4_0_minor_ops;
/* nfs40state.c */
int nfs40_discover_server_trunking(struct nfs_client *clp,
diff --git a/fs/nfs/nfs40proc.c b/fs/nfs/nfs40proc.c
index 736e782a27e1..36802f9b94b5 100644
--- a/fs/nfs/nfs40proc.c
+++ b/fs/nfs/nfs40proc.c
@@ -126,6 +126,13 @@ static int nfs4_proc_renew(struct nfs_client *clp, const struct cred *cred)
return 0;
}
+static int nfs40_test_and_free_expired_stateid(struct nfs_server *server,
+ nfs4_stateid *stateid,
+ const struct cred *cred)
+{
+ return -NFS4ERR_BAD_STATEID;
+}
+
/*
* This operation also signals the server that this client is
* performing migration recovery. The server can stop returning
@@ -222,6 +229,86 @@ static int _nfs40_proc_fsid_present(struct inode *inode, const struct cred *cred
return 0;
}
+struct nfs_release_lockowner_data {
+ struct nfs4_lock_state *lsp;
+ struct nfs_server *server;
+ struct nfs_release_lockowner_args args;
+ struct nfs_release_lockowner_res res;
+ unsigned long timestamp;
+};
+
+static void nfs4_release_lockowner_prepare(struct rpc_task *task, void *calldata)
+{
+ struct nfs_release_lockowner_data *data = calldata;
+ struct nfs_server *server = data->server;
+ nfs4_setup_sequence(server->nfs_client, &data->args.seq_args,
+ &data->res.seq_res, task);
+ data->args.lock_owner.clientid = server->nfs_client->cl_clientid;
+ data->timestamp = jiffies;
+}
+
+static void nfs4_release_lockowner_done(struct rpc_task *task, void *calldata)
+{
+ struct nfs_release_lockowner_data *data = calldata;
+ struct nfs_server *server = data->server;
+
+ nfs40_sequence_done(task, &data->res.seq_res);
+
+ switch (task->tk_status) {
+ case 0:
+ renew_lease(server, data->timestamp);
+ break;
+ case -NFS4ERR_STALE_CLIENTID:
+ case -NFS4ERR_EXPIRED:
+ nfs4_schedule_lease_recovery(server->nfs_client);
+ break;
+ case -NFS4ERR_LEASE_MOVED:
+ case -NFS4ERR_DELAY:
+ if (nfs4_async_handle_error(task, server,
+ NULL, NULL) == -EAGAIN)
+ rpc_restart_call_prepare(task);
+ }
+}
+
+static void nfs4_release_lockowner_release(void *calldata)
+{
+ struct nfs_release_lockowner_data *data = calldata;
+ nfs4_free_lock_state(data->server, data->lsp);
+ kfree(calldata);
+}
+
+static const struct rpc_call_ops nfs4_release_lockowner_ops = {
+ .rpc_call_prepare = nfs4_release_lockowner_prepare,
+ .rpc_call_done = nfs4_release_lockowner_done,
+ .rpc_release = nfs4_release_lockowner_release,
+};
+
+static void
+nfs4_release_lockowner(struct nfs_server *server, struct nfs4_lock_state *lsp)
+{
+ struct nfs_release_lockowner_data *data;
+ struct rpc_message msg = {
+ .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_RELEASE_LOCKOWNER],
+ };
+
+ if (server->nfs_client->cl_mvops->minor_version != 0)
+ return;
+
+ data = kmalloc(sizeof(*data), GFP_KERNEL);
+ if (!data)
+ return;
+ data->lsp = lsp;
+ data->server = server;
+ data->args.lock_owner.clientid = server->nfs_client->cl_clientid;
+ data->args.lock_owner.id = lsp->ls_seqid.owner_id;
+ data->args.lock_owner.s_dev = server->s_dev;
+
+ msg.rpc_argp = &data->args;
+ msg.rpc_resp = &data->res;
+ nfs4_init_sequence(&data->args.seq_args, &data->res.seq_res, 0, 0);
+ rpc_call_async(server->client, &msg, 0, &nfs4_release_lockowner_ops, data);
+}
+
const struct rpc_call_ops nfs40_call_sync_ops = {
.rpc_call_prepare = nfs40_call_sync_prepare,
.rpc_call_done = nfs40_call_sync_done,
@@ -254,3 +341,22 @@ const struct nfs4_mig_recovery_ops nfs40_mig_recovery_ops = {
.get_locations = _nfs40_proc_get_locations,
.fsid_present = _nfs40_proc_fsid_present,
};
+
+const struct nfs4_minor_version_ops nfs_v4_0_minor_ops = {
+ .minor_version = 0,
+ .init_caps = NFS_CAP_READDIRPLUS
+ | NFS_CAP_ATOMIC_OPEN
+ | NFS_CAP_POSIX_LOCK,
+ .init_client = nfs40_init_client,
+ .shutdown_client = nfs40_shutdown_client,
+ .match_stateid = nfs4_match_stateid,
+ .find_root_sec = nfs4_find_root_sec,
+ .free_lock_state = nfs4_release_lockowner,
+ .test_and_free_expired = nfs40_test_and_free_expired_stateid,
+ .alloc_seqid = nfs_alloc_seqid,
+ .call_sync_ops = &nfs40_call_sync_ops,
+ .reboot_recovery_ops = &nfs40_reboot_recovery_ops,
+ .nograce_recovery_ops = &nfs40_nograce_recovery_ops,
+ .state_renewal_ops = &nfs40_state_renewal_ops,
+ .mig_recovery_ops = &nfs40_mig_recovery_ops,
+};
diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h
index 7f1fde3023a5..333dd0774517 100644
--- a/fs/nfs/nfs4_fs.h
+++ b/fs/nfs/nfs4_fs.h
@@ -310,6 +310,7 @@ extern int nfs4_call_sync_sequence(struct rpc_clnt *clnt,
struct nfs4_sequence_args *args,
struct nfs4_sequence_res *res);
extern void nfs4_init_sequence(struct nfs4_sequence_args *, struct nfs4_sequence_res *, int, int);
+extern int 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);
@@ -365,6 +366,9 @@ extern void nfs_finish_clear_delegation_stateid(struct nfs4_state *state,
const nfs4_stateid *stateid);
extern void nfs_state_clear_open_state_flags(struct nfs4_state *state);
extern void do_renew_lease(struct nfs_client *clp, unsigned long timestamp);
+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 *);
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 68c2925c404f..86ab868a6422 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -795,8 +795,8 @@ static void nfs40_sequence_free_slot(struct nfs4_sequence_res *res)
res->sr_slot = NULL;
}
-static int nfs40_sequence_done(struct rpc_task *task,
- struct nfs4_sequence_res *res)
+int nfs40_sequence_done(struct rpc_task *task,
+ struct nfs4_sequence_res *res)
{
if (res->sr_slot != NULL)
nfs40_sequence_free_slot(res);
@@ -2882,12 +2882,6 @@ void nfs_finish_clear_delegation_stateid(struct nfs4_state *state,
nfs_state_clear_delegation(state);
}
-static int nfs40_test_and_free_expired_stateid(struct nfs_server *server,
- nfs4_stateid *stateid, const struct cred *cred)
-{
- return -NFS4ERR_BAD_STATEID;
-}
-
#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)
@@ -4289,7 +4283,7 @@ static int nfs4_lookup_root_sec(struct nfs_server *server,
* Returns zero on success, or a negative NFS4ERR value, or a
* negative errno value.
*/
-static int nfs4_find_root_sec(struct nfs_server *server, struct nfs_fh *fhandle,
+int nfs4_find_root_sec(struct nfs_server *server, struct nfs_fh *fhandle,
struct nfs_fattr *fattr)
{
/* Per 3530bis 15.33.5 */
@@ -7868,86 +7862,6 @@ int nfs4_lock_delegation_recall(struct file_lock *fl, struct nfs4_state *state,
return nfs4_handle_delegation_recall_error(server, state, stateid, fl, err);
}
-struct nfs_release_lockowner_data {
- struct nfs4_lock_state *lsp;
- struct nfs_server *server;
- struct nfs_release_lockowner_args args;
- struct nfs_release_lockowner_res res;
- unsigned long timestamp;
-};
-
-static void nfs4_release_lockowner_prepare(struct rpc_task *task, void *calldata)
-{
- struct nfs_release_lockowner_data *data = calldata;
- struct nfs_server *server = data->server;
- nfs4_setup_sequence(server->nfs_client, &data->args.seq_args,
- &data->res.seq_res, task);
- data->args.lock_owner.clientid = server->nfs_client->cl_clientid;
- data->timestamp = jiffies;
-}
-
-static void nfs4_release_lockowner_done(struct rpc_task *task, void *calldata)
-{
- struct nfs_release_lockowner_data *data = calldata;
- struct nfs_server *server = data->server;
-
- nfs40_sequence_done(task, &data->res.seq_res);
-
- switch (task->tk_status) {
- case 0:
- renew_lease(server, data->timestamp);
- break;
- case -NFS4ERR_STALE_CLIENTID:
- case -NFS4ERR_EXPIRED:
- nfs4_schedule_lease_recovery(server->nfs_client);
- break;
- case -NFS4ERR_LEASE_MOVED:
- case -NFS4ERR_DELAY:
- if (nfs4_async_handle_error(task, server,
- NULL, NULL) == -EAGAIN)
- rpc_restart_call_prepare(task);
- }
-}
-
-static void nfs4_release_lockowner_release(void *calldata)
-{
- struct nfs_release_lockowner_data *data = calldata;
- nfs4_free_lock_state(data->server, data->lsp);
- kfree(calldata);
-}
-
-static const struct rpc_call_ops nfs4_release_lockowner_ops = {
- .rpc_call_prepare = nfs4_release_lockowner_prepare,
- .rpc_call_done = nfs4_release_lockowner_done,
- .rpc_release = nfs4_release_lockowner_release,
-};
-
-static void
-nfs4_release_lockowner(struct nfs_server *server, struct nfs4_lock_state *lsp)
-{
- struct nfs_release_lockowner_data *data;
- struct rpc_message msg = {
- .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_RELEASE_LOCKOWNER],
- };
-
- if (server->nfs_client->cl_mvops->minor_version != 0)
- return;
-
- data = kmalloc(sizeof(*data), GFP_KERNEL);
- if (!data)
- return;
- data->lsp = lsp;
- data->server = server;
- data->args.lock_owner.clientid = server->nfs_client->cl_clientid;
- data->args.lock_owner.id = lsp->ls_seqid.owner_id;
- data->args.lock_owner.s_dev = server->s_dev;
-
- msg.rpc_argp = &data->args;
- msg.rpc_resp = &data->res;
- nfs4_init_sequence(&data->args.seq_args, &data->res.seq_res, 0, 0);
- rpc_call_async(server->client, &msg, 0, &nfs4_release_lockowner_ops, data);
-}
-
#define XATTR_NAME_NFSV4_ACL "system.nfs4_acl"
static int nfs4_xattr_set_nfs4_acl(const struct xattr_handler *handler,
@@ -10572,7 +10486,7 @@ static bool nfs41_match_stateid(const nfs4_stateid *s1,
#endif /* CONFIG_NFS_V4_1 */
-static bool nfs4_match_stateid(const nfs4_stateid *s1,
+bool nfs4_match_stateid(const nfs4_stateid *s1,
const nfs4_stateid *s2)
{
trace_nfs4_match_stateid(s1, s2);
@@ -10610,28 +10524,7 @@ static const struct nfs4_mig_recovery_ops nfs41_mig_recovery_ops = {
.get_locations = _nfs41_proc_get_locations,
.fsid_present = _nfs41_proc_fsid_present,
};
-#endif /* CONFIG_NFS_V4_1 */
-static const struct nfs4_minor_version_ops nfs_v4_0_minor_ops = {
- .minor_version = 0,
- .init_caps = NFS_CAP_READDIRPLUS
- | NFS_CAP_ATOMIC_OPEN
- | NFS_CAP_POSIX_LOCK,
- .init_client = nfs40_init_client,
- .shutdown_client = nfs40_shutdown_client,
- .match_stateid = nfs4_match_stateid,
- .find_root_sec = nfs4_find_root_sec,
- .free_lock_state = nfs4_release_lockowner,
- .test_and_free_expired = nfs40_test_and_free_expired_stateid,
- .alloc_seqid = nfs_alloc_seqid,
- .call_sync_ops = &nfs40_call_sync_ops,
- .reboot_recovery_ops = &nfs40_reboot_recovery_ops,
- .nograce_recovery_ops = &nfs40_nograce_recovery_ops,
- .state_renewal_ops = &nfs40_state_renewal_ops,
- .mig_recovery_ops = &nfs40_mig_recovery_ops,
-};
-
-#if defined(CONFIG_NFS_V4_1)
static struct nfs_seqid *
nfs_alloc_no_seqid(struct nfs_seqid_counter *arg1, gfp_t arg2)
{
--
2.52.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v2 07/14] NFS: Make the various NFS v4.0 operations static again
2026-01-26 20:39 [PATCH v2 00/14] NFS: Make NFS v4.0 KConfig-urable Anna Schumaker
` (5 preceding siblings ...)
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 ` Anna Schumaker
2026-01-26 20:39 ` [PATCH v2 08/14] NFS: Move nfs40_shutdown_client into nfs40client.c Anna Schumaker
` (6 subsequent siblings)
13 siblings, 0 replies; 16+ messages in thread
From: Anna Schumaker @ 2026-01-26 20:39 UTC (permalink / raw)
To: linux-nfs, trond.myklebust; +Cc: anna
From: Anna Schumaker <anna.schumaker@oracle.com>
They don't need to be visible outside of nfs40proc.c anymore now that
the minor version ops have been moved over.
Signed-off-by: Anna Schumaker <anna.schumaker@oracle.com>
---
fs/nfs/nfs40.h | 5 -----
fs/nfs/nfs40proc.c | 10 +++++-----
2 files changed, 5 insertions(+), 10 deletions(-)
diff --git a/fs/nfs/nfs40.h b/fs/nfs/nfs40.h
index 05ba9f1afe7c..272e1ffdb161 100644
--- a/fs/nfs/nfs40.h
+++ b/fs/nfs/nfs40.h
@@ -4,11 +4,6 @@
/* nfs40proc.c */
-extern const struct rpc_call_ops nfs40_call_sync_ops;
-extern const struct nfs4_state_recovery_ops nfs40_reboot_recovery_ops;
-extern const struct nfs4_state_recovery_ops nfs40_nograce_recovery_ops;
-extern const struct nfs4_state_maintenance_ops nfs40_state_renewal_ops;
-extern const struct nfs4_mig_recovery_ops nfs40_mig_recovery_ops;
extern const struct nfs4_minor_version_ops nfs_v4_0_minor_ops;
/* nfs40state.c */
diff --git a/fs/nfs/nfs40proc.c b/fs/nfs/nfs40proc.c
index 36802f9b94b5..5968a3318d14 100644
--- a/fs/nfs/nfs40proc.c
+++ b/fs/nfs/nfs40proc.c
@@ -309,12 +309,12 @@ nfs4_release_lockowner(struct nfs_server *server, struct nfs4_lock_state *lsp)
rpc_call_async(server->client, &msg, 0, &nfs4_release_lockowner_ops, data);
}
-const struct rpc_call_ops nfs40_call_sync_ops = {
+static const struct rpc_call_ops nfs40_call_sync_ops = {
.rpc_call_prepare = nfs40_call_sync_prepare,
.rpc_call_done = nfs40_call_sync_done,
};
-const struct nfs4_state_recovery_ops nfs40_reboot_recovery_ops = {
+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,
.recover_open = nfs4_open_reclaim,
@@ -323,7 +323,7 @@ const struct nfs4_state_recovery_ops nfs40_reboot_recovery_ops = {
.detect_trunking = nfs40_discover_server_trunking,
};
-const struct nfs4_state_recovery_ops nfs40_nograce_recovery_ops = {
+static const struct nfs4_state_recovery_ops nfs40_nograce_recovery_ops = {
.owner_flag_bit = NFS_OWNER_RECLAIM_NOGRACE,
.state_flag_bit = NFS_STATE_RECLAIM_NOGRACE,
.recover_open = nfs40_open_expired,
@@ -331,13 +331,13 @@ const struct nfs4_state_recovery_ops nfs40_nograce_recovery_ops = {
.establish_clid = nfs4_init_clientid,
};
-const struct nfs4_state_maintenance_ops nfs40_state_renewal_ops = {
+static const struct nfs4_state_maintenance_ops nfs40_state_renewal_ops = {
.sched_state_renewal = nfs4_proc_async_renew,
.get_state_renewal_cred = nfs4_get_renew_cred,
.renew_lease = nfs4_proc_renew,
};
-const struct nfs4_mig_recovery_ops nfs40_mig_recovery_ops = {
+static const struct nfs4_mig_recovery_ops nfs40_mig_recovery_ops = {
.get_locations = _nfs40_proc_get_locations,
.fsid_present = _nfs40_proc_fsid_present,
};
--
2.52.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v2 08/14] NFS: Move nfs40_shutdown_client into nfs40client.c
2026-01-26 20:39 [PATCH v2 00/14] NFS: Make NFS v4.0 KConfig-urable Anna Schumaker
` (6 preceding siblings ...)
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 ` Anna Schumaker
2026-01-26 20:39 ` [PATCH v2 09/14] NFS: Move nfs40_init_client " Anna Schumaker
` (5 subsequent siblings)
13 siblings, 0 replies; 16+ messages in thread
From: Anna Schumaker @ 2026-01-26 20:39 UTC (permalink / raw)
To: linux-nfs, trond.myklebust; +Cc: anna
From: Anna Schumaker <anna.schumaker@oracle.com>
Signed-off-by: Anna Schumaker <anna.schumaker@oracle.com>
---
fs/nfs/nfs40.h | 3 +++
fs/nfs/nfs40client.c | 9 +++++++++
fs/nfs/nfs40proc.c | 1 +
fs/nfs/nfs4_fs.h | 1 -
fs/nfs/nfs4client.c | 8 --------
5 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/fs/nfs/nfs40.h b/fs/nfs/nfs40.h
index 272e1ffdb161..9369bb08825a 100644
--- a/fs/nfs/nfs40.h
+++ b/fs/nfs/nfs40.h
@@ -3,6 +3,9 @@
#define __LINUX_FS_NFS_NFS4_0_H
+/* nfs40client.c */
+void nfs40_shutdown_client(struct nfs_client *);
+
/* nfs40proc.c */
extern const struct nfs4_minor_version_ops nfs_v4_0_minor_ops;
diff --git a/fs/nfs/nfs40client.c b/fs/nfs/nfs40client.c
index bab073b6506b..8397d75a2f46 100644
--- a/fs/nfs/nfs40client.c
+++ b/fs/nfs/nfs40client.c
@@ -1,6 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0 */
#include <linux/nfs_fs.h>
#include "nfs4_fs.h"
+#include "nfs4session.h"
#include "callback.h"
#include "internal.h"
#include "netns.h"
@@ -44,6 +45,14 @@ static bool nfs4_same_verifier(nfs4_verifier *v1, nfs4_verifier *v2)
return memcmp(v1->data, v2->data, sizeof(v1->data)) == 0;
}
+void nfs40_shutdown_client(struct nfs_client *clp)
+{
+ if (clp->cl_slot_tbl) {
+ nfs4_shutdown_slot_table(clp->cl_slot_tbl);
+ kfree(clp->cl_slot_tbl);
+ }
+}
+
/**
* nfs40_walk_client_list - Find server that recognizes a client ID
*
diff --git a/fs/nfs/nfs40proc.c b/fs/nfs/nfs40proc.c
index 5968a3318d14..0399e2e68c6b 100644
--- a/fs/nfs/nfs40proc.c
+++ b/fs/nfs/nfs40proc.c
@@ -5,6 +5,7 @@
#include <linux/nfs_fs.h>
#include "internal.h"
#include "nfs4_fs.h"
+#include "nfs40.h"
#include "nfs4trace.h"
static void nfs40_call_sync_prepare(struct rpc_task *task, void *calldata)
diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h
index 333dd0774517..bfc0afb796ff 100644
--- a/fs/nfs/nfs4_fs.h
+++ b/fs/nfs/nfs4_fs.h
@@ -482,7 +482,6 @@ extern const u32 nfs4_pathconf_bitmap[3];
extern const u32 nfs4_fsinfo_bitmap[3];
extern const u32 nfs4_fs_locations_bitmap[3];
-void nfs40_shutdown_client(struct nfs_client *);
void nfs41_shutdown_client(struct nfs_client *);
int nfs40_init_client(struct nfs_client *);
int nfs41_init_client(struct nfs_client *);
diff --git a/fs/nfs/nfs4client.c b/fs/nfs/nfs4client.c
index 517cf8af2943..d83a8a2a3c70 100644
--- a/fs/nfs/nfs4client.c
+++ b/fs/nfs/nfs4client.c
@@ -189,14 +189,6 @@ void nfs41_shutdown_client(struct nfs_client *clp)
}
#endif /* CONFIG_NFS_V4_1 */
-void nfs40_shutdown_client(struct nfs_client *clp)
-{
- if (clp->cl_slot_tbl) {
- nfs4_shutdown_slot_table(clp->cl_slot_tbl);
- kfree(clp->cl_slot_tbl);
- }
-}
-
struct nfs_client *nfs4_alloc_client(const struct nfs_client_initdata *cl_init)
{
char buf[INET6_ADDRSTRLEN + 1];
--
2.52.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v2 09/14] NFS: Move nfs40_init_client into nfs40client.c
2026-01-26 20:39 [PATCH v2 00/14] NFS: Make NFS v4.0 KConfig-urable Anna Schumaker
` (7 preceding siblings ...)
2026-01-26 20:39 ` [PATCH v2 08/14] NFS: Move nfs40_shutdown_client into nfs40client.c Anna Schumaker
@ 2026-01-26 20:39 ` Anna Schumaker
2026-01-26 20:39 ` [PATCH v2 10/14] NFS: Move NFS v4.0 pathdown recovery " Anna Schumaker
` (4 subsequent siblings)
13 siblings, 0 replies; 16+ messages in thread
From: Anna Schumaker @ 2026-01-26 20:39 UTC (permalink / raw)
To: linux-nfs, trond.myklebust; +Cc: anna
From: Anna Schumaker <anna.schumaker@oracle.com>
Signed-off-by: Anna Schumaker <anna.schumaker@oracle.com>
---
fs/nfs/nfs40.h | 1 +
fs/nfs/nfs40client.c | 27 +++++++++++++++++++++++++++
fs/nfs/nfs4_fs.h | 1 -
fs/nfs/nfs4client.c | 27 ---------------------------
4 files changed, 28 insertions(+), 28 deletions(-)
diff --git a/fs/nfs/nfs40.h b/fs/nfs/nfs40.h
index 9369bb08825a..5a9c5d367b12 100644
--- a/fs/nfs/nfs40.h
+++ b/fs/nfs/nfs40.h
@@ -5,6 +5,7 @@
/* nfs40client.c */
void nfs40_shutdown_client(struct nfs_client *);
+int nfs40_init_client(struct nfs_client *);
/* nfs40proc.c */
extern const struct nfs4_minor_version_ops nfs_v4_0_minor_ops;
diff --git a/fs/nfs/nfs40client.c b/fs/nfs/nfs40client.c
index 8397d75a2f46..b0719403495d 100644
--- a/fs/nfs/nfs40client.c
+++ b/fs/nfs/nfs40client.c
@@ -53,6 +53,33 @@ void nfs40_shutdown_client(struct nfs_client *clp)
}
}
+/**
+ * nfs40_init_client - nfs_client initialization tasks for NFSv4.0
+ * @clp: nfs_client to initialize
+ *
+ * Returns zero on success, or a negative errno if some error occurred.
+ */
+int nfs40_init_client(struct nfs_client *clp)
+{
+ struct nfs4_slot_table *tbl;
+ int ret;
+
+ tbl = kzalloc(sizeof(*tbl), GFP_NOFS);
+ if (tbl == NULL)
+ return -ENOMEM;
+
+ ret = nfs4_setup_slot_table(tbl, NFS4_MAX_SLOT_TABLE,
+ "NFSv4.0 transport Slot table");
+ if (ret) {
+ nfs4_shutdown_slot_table(tbl);
+ kfree(tbl);
+ return ret;
+ }
+
+ clp->cl_slot_tbl = tbl;
+ return 0;
+}
+
/**
* nfs40_walk_client_list - Find server that recognizes a client ID
*
diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h
index bfc0afb796ff..702c63add4a1 100644
--- a/fs/nfs/nfs4_fs.h
+++ b/fs/nfs/nfs4_fs.h
@@ -483,7 +483,6 @@ extern const u32 nfs4_fsinfo_bitmap[3];
extern const u32 nfs4_fs_locations_bitmap[3];
void nfs41_shutdown_client(struct nfs_client *);
-int nfs40_init_client(struct nfs_client *);
int nfs41_init_client(struct nfs_client *);
void nfs4_free_client(struct nfs_client *);
diff --git a/fs/nfs/nfs4client.c b/fs/nfs/nfs4client.c
index d83a8a2a3c70..c376b2420b6c 100644
--- a/fs/nfs/nfs4client.c
+++ b/fs/nfs/nfs4client.c
@@ -331,33 +331,6 @@ static int nfs4_init_callback(struct nfs_client *clp)
return 0;
}
-/**
- * nfs40_init_client - nfs_client initialization tasks for NFSv4.0
- * @clp: nfs_client to initialize
- *
- * Returns zero on success, or a negative errno if some error occurred.
- */
-int nfs40_init_client(struct nfs_client *clp)
-{
- struct nfs4_slot_table *tbl;
- int ret;
-
- tbl = kzalloc(sizeof(*tbl), GFP_NOFS);
- if (tbl == NULL)
- return -ENOMEM;
-
- ret = nfs4_setup_slot_table(tbl, NFS4_MAX_SLOT_TABLE,
- "NFSv4.0 transport Slot table");
- if (ret) {
- nfs4_shutdown_slot_table(tbl);
- kfree(tbl);
- return ret;
- }
-
- clp->cl_slot_tbl = tbl;
- return 0;
-}
-
#if defined(CONFIG_NFS_V4_1)
/**
--
2.52.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v2 10/14] NFS: Move NFS v4.0 pathdown recovery into nfs40client.c
2026-01-26 20:39 [PATCH v2 00/14] NFS: Make NFS v4.0 KConfig-urable Anna Schumaker
` (8 preceding siblings ...)
2026-01-26 20:39 ` [PATCH v2 09/14] NFS: Move nfs40_init_client " Anna Schumaker
@ 2026-01-26 20:39 ` Anna Schumaker
2026-01-26 20:39 ` [PATCH v2 11/14] NFS: Pass a struct nfs_client to nfs4_init_sequence() Anna Schumaker
` (3 subsequent siblings)
13 siblings, 0 replies; 16+ messages in thread
From: Anna Schumaker @ 2026-01-26 20:39 UTC (permalink / raw)
To: linux-nfs, trond.myklebust; +Cc: anna
From: Anna Schumaker <anna.schumaker@oracle.com>
Signed-off-by: Anna Schumaker <anna.schumaker@oracle.com>
---
fs/nfs/nfs40.h | 1 +
fs/nfs/nfs40client.c | 23 +++++++++++++++++++++++
fs/nfs/nfs4state.c | 23 +----------------------
3 files changed, 25 insertions(+), 22 deletions(-)
diff --git a/fs/nfs/nfs40.h b/fs/nfs/nfs40.h
index 5a9c5d367b12..ee09aac738c8 100644
--- a/fs/nfs/nfs40.h
+++ b/fs/nfs/nfs40.h
@@ -6,6 +6,7 @@
/* nfs40client.c */
void nfs40_shutdown_client(struct nfs_client *);
int nfs40_init_client(struct nfs_client *);
+void nfs40_handle_cb_pathdown(struct nfs_client *clp);
/* nfs40proc.c */
extern const struct nfs4_minor_version_ops nfs_v4_0_minor_ops;
diff --git a/fs/nfs/nfs40client.c b/fs/nfs/nfs40client.c
index b0719403495d..0f88e7cbdc5e 100644
--- a/fs/nfs/nfs40client.c
+++ b/fs/nfs/nfs40client.c
@@ -3,6 +3,7 @@
#include "nfs4_fs.h"
#include "nfs4session.h"
#include "callback.h"
+#include "delegation.h"
#include "internal.h"
#include "netns.h"
#include "nfs40.h"
@@ -80,6 +81,28 @@ int nfs40_init_client(struct nfs_client *clp)
return 0;
}
+/*
+ * nfs40_handle_cb_pathdown - return all delegations after NFS4ERR_CB_PATH_DOWN
+ * @clp: client to process
+ *
+ * Set the NFS4CLNT_LEASE_EXPIRED state in order to force a
+ * resend of the SETCLIENTID and hence re-establish the
+ * callback channel. Then return all existing delegations.
+ */
+void nfs40_handle_cb_pathdown(struct nfs_client *clp)
+{
+ set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state);
+ nfs_expire_all_delegations(clp);
+ dprintk("%s: handling CB_PATHDOWN recovery for server %s\n", __func__,
+ clp->cl_hostname);
+}
+
+void nfs4_schedule_path_down_recovery(struct nfs_client *clp)
+{
+ nfs40_handle_cb_pathdown(clp);
+ nfs4_schedule_state_manager(clp);
+}
+
/**
* nfs40_walk_client_list - Find server that recognizes a client ID
*
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
index 5edc11cb2de0..1546351e76b2 100644
--- a/fs/nfs/nfs4state.c
+++ b/fs/nfs/nfs4state.c
@@ -54,6 +54,7 @@
#include <linux/sunrpc/clnt.h>
#include "nfs4_fs.h"
+#include "nfs40.h"
#include "callback.h"
#include "delegation.h"
#include "internal.h"
@@ -1294,28 +1295,6 @@ int nfs4_client_recover_expired_lease(struct nfs_client *clp)
return ret;
}
-/*
- * nfs40_handle_cb_pathdown - return all delegations after NFS4ERR_CB_PATH_DOWN
- * @clp: client to process
- *
- * Set the NFS4CLNT_LEASE_EXPIRED state in order to force a
- * resend of the SETCLIENTID and hence re-establish the
- * callback channel. Then return all existing delegations.
- */
-static void nfs40_handle_cb_pathdown(struct nfs_client *clp)
-{
- set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state);
- nfs_expire_all_delegations(clp);
- dprintk("%s: handling CB_PATHDOWN recovery for server %s\n", __func__,
- clp->cl_hostname);
-}
-
-void nfs4_schedule_path_down_recovery(struct nfs_client *clp)
-{
- nfs40_handle_cb_pathdown(clp);
- nfs4_schedule_state_manager(clp);
-}
-
static int nfs4_state_mark_reclaim_reboot(struct nfs_client *clp, struct nfs4_state *state)
{
--
2.52.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v2 11/14] NFS: Pass a struct nfs_client to nfs4_init_sequence()
2026-01-26 20:39 [PATCH v2 00/14] NFS: Make NFS v4.0 KConfig-urable Anna Schumaker
` (9 preceding siblings ...)
2026-01-26 20:39 ` [PATCH v2 10/14] NFS: Move NFS v4.0 pathdown recovery " Anna Schumaker
@ 2026-01-26 20:39 ` Anna Schumaker
2026-01-26 20:39 ` [PATCH v2 12/14] NFS: Move sequence slot operations into minorversion operations Anna Schumaker
` (2 subsequent siblings)
13 siblings, 0 replies; 16+ messages in thread
From: Anna Schumaker @ 2026-01-26 20:39 UTC (permalink / raw)
To: linux-nfs, trond.myklebust; +Cc: anna
From: Anna Schumaker <anna.schumaker@oracle.com>
No functional change in this patch. This just makes the next patch where
I introduce "sequence slot operations" simpler.
Signed-off-by: Anna Schumaker <anna.schumaker@oracle.com>
---
fs/nfs/nfs40proc.c | 14 ++---
fs/nfs/nfs42proc.c | 13 +++--
fs/nfs/nfs4_fs.h | 3 +-
fs/nfs/nfs4proc.c | 126 +++++++++++++++++++++++++--------------------
4 files changed, 87 insertions(+), 69 deletions(-)
diff --git a/fs/nfs/nfs40proc.c b/fs/nfs/nfs40proc.c
index 0399e2e68c6b..9b5b57170471 100644
--- a/fs/nfs/nfs40proc.c
+++ b/fs/nfs/nfs40proc.c
@@ -147,11 +147,12 @@ static int _nfs40_proc_get_locations(struct nfs_server *server,
struct page *page, const struct cred *cred)
{
struct rpc_clnt *clnt = server->client;
+ struct nfs_client *clp = server->nfs_client;
u32 bitmask[2] = {
[0] = FATTR4_WORD0_FSID | FATTR4_WORD0_FS_LOCATIONS,
};
struct nfs4_fs_locations_arg args = {
- .clientid = server->nfs_client->cl_clientid,
+ .clientid = clp->cl_clientid,
.fh = fhandle,
.page = page,
.bitmask = bitmask,
@@ -176,7 +177,7 @@ static int _nfs40_proc_get_locations(struct nfs_server *server,
locations->server = server;
locations->nlocations = 0;
- nfs4_init_sequence(&args.seq_args, &res.seq_res, 0, 1);
+ nfs4_init_sequence(clp, &args.seq_args, &res.seq_res, 0, 1);
status = nfs4_call_sync_sequence(clnt, server, &msg,
&args.seq_args, &res.seq_res);
if (status)
@@ -219,7 +220,7 @@ static int _nfs40_proc_fsid_present(struct inode *inode, const struct cred *cred
if (res.fh == NULL)
return -ENOMEM;
- nfs4_init_sequence(&args.seq_args, &res.seq_res, 0, 1);
+ nfs4_init_sequence(clp, &args.seq_args, &res.seq_res, 0, 1);
status = nfs4_call_sync_sequence(clnt, server, &msg,
&args.seq_args, &res.seq_res);
nfs_free_fhandle(res.fh);
@@ -288,11 +289,12 @@ static void
nfs4_release_lockowner(struct nfs_server *server, struct nfs4_lock_state *lsp)
{
struct nfs_release_lockowner_data *data;
+ struct nfs_client *clp = server->nfs_client;
struct rpc_message msg = {
.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_RELEASE_LOCKOWNER],
};
- if (server->nfs_client->cl_mvops->minor_version != 0)
+ if (clp->cl_mvops->minor_version != 0)
return;
data = kmalloc(sizeof(*data), GFP_KERNEL);
@@ -300,13 +302,13 @@ nfs4_release_lockowner(struct nfs_server *server, struct nfs4_lock_state *lsp)
return;
data->lsp = lsp;
data->server = server;
- data->args.lock_owner.clientid = server->nfs_client->cl_clientid;
+ data->args.lock_owner.clientid = clp->cl_clientid;
data->args.lock_owner.id = lsp->ls_seqid.owner_id;
data->args.lock_owner.s_dev = server->s_dev;
msg.rpc_argp = &data->args;
msg.rpc_resp = &data->res;
- nfs4_init_sequence(&data->args.seq_args, &data->res.seq_res, 0, 0);
+ nfs4_init_sequence(clp, &data->args.seq_args, &data->res.seq_res, 0, 0);
rpc_call_async(server->client, &msg, 0, &nfs4_release_lockowner_ops, data);
}
diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c
index c08520828708..3487948d7181 100644
--- a/fs/nfs/nfs42proc.c
+++ b/fs/nfs/nfs42proc.c
@@ -670,8 +670,8 @@ static int nfs42_do_offload_cancel_async(struct file *dst,
msg.rpc_argp = &data->args;
msg.rpc_resp = &data->res;
task_setup_data.callback_data = data;
- nfs4_init_sequence(&data->args.osa_seq_args, &data->res.osr_seq_res,
- 1, 0);
+ nfs4_init_sequence(dst_server->nfs_client, &data->args.osa_seq_args,
+ &data->res.osr_seq_res, 1, 0);
task = rpc_run_task(&task_setup_data);
if (IS_ERR(task))
return PTR_ERR(task);
@@ -1072,7 +1072,8 @@ int nfs42_proc_layoutstats_generic(struct nfs_server *server,
nfs42_layoutstat_release(data);
return -EAGAIN;
}
- nfs4_init_sequence(&data->args.seq_args, &data->res.seq_res, 0, 0);
+ nfs4_init_sequence(server->nfs_client, &data->args.seq_args,
+ &data->res.seq_res, 0, 0);
task = rpc_run_task(&task_setup);
if (IS_ERR(task))
return PTR_ERR(task);
@@ -1210,6 +1211,7 @@ int nfs42_proc_layouterror(struct pnfs_layout_segment *lseg,
const struct nfs42_layout_error *errors, size_t n)
{
struct inode *inode = lseg->pls_layout->plh_inode;
+ struct nfs_server *server = NFS_SERVER(inode);
struct nfs42_layouterror_data *data;
struct rpc_task *task;
struct rpc_message msg = {
@@ -1237,8 +1239,9 @@ int nfs42_proc_layouterror(struct pnfs_layout_segment *lseg,
msg.rpc_argp = &data->args;
msg.rpc_resp = &data->res;
task_setup.callback_data = data;
- task_setup.rpc_client = NFS_SERVER(inode)->client;
- nfs4_init_sequence(&data->args.seq_args, &data->res.seq_res, 0, 0);
+ task_setup.rpc_client = server->client;
+ nfs4_init_sequence(server->nfs_client, &data->args.seq_args,
+ &data->res.seq_res, 0, 0);
task = rpc_run_task(&task_setup);
if (IS_ERR(task))
return PTR_ERR(task);
diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h
index 702c63add4a1..c7c466fa5434 100644
--- a/fs/nfs/nfs4_fs.h
+++ b/fs/nfs/nfs4_fs.h
@@ -309,7 +309,8 @@ extern int nfs4_call_sync_sequence(struct rpc_clnt *clnt,
struct rpc_message *msg,
struct nfs4_sequence_args *args,
struct nfs4_sequence_res *res);
-extern void nfs4_init_sequence(struct nfs4_sequence_args *, struct nfs4_sequence_res *, int, int);
+extern 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 *);
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 86ab868a6422..a8cc3d1b9416 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -770,7 +770,8 @@ void renew_lease(const struct nfs_server *server, unsigned long timestamp)
do_renew_lease(clp, timestamp);
}
-void nfs4_init_sequence(struct nfs4_sequence_args *args,
+void nfs4_init_sequence(struct nfs_client *clp,
+ struct nfs4_sequence_args *args,
struct nfs4_sequence_res *res, int cache_reply,
int privileged)
{
@@ -1228,7 +1229,7 @@ int nfs4_call_sync(struct rpc_clnt *clnt,
struct nfs4_sequence_res *res,
int cache_reply)
{
- nfs4_init_sequence(args, res, cache_reply, 0);
+ nfs4_init_sequence(server->nfs_client, args, res, cache_reply, 0);
return nfs4_call_sync_sequence(clnt, server, msg, args, res);
}
@@ -2504,8 +2505,8 @@ static int _nfs4_proc_open_confirm(struct nfs4_opendata *data)
};
int status;
- nfs4_init_sequence(&data->c_arg.seq_args, &data->c_res.seq_res, 1,
- data->is_recover);
+ nfs4_init_sequence(server->nfs_client, &data->c_arg.seq_args,
+ &data->c_res.seq_res, 1, data->is_recover);
kref_get(&data->kref);
data->rpc_done = false;
data->rpc_status = 0;
@@ -2652,6 +2653,7 @@ static int nfs4_run_open_task(struct nfs4_opendata *data,
{
struct inode *dir = d_inode(data->dir);
struct nfs_server *server = NFS_SERVER(dir);
+ struct nfs_client *clp = server->nfs_client;
struct nfs_openargs *o_arg = &data->o_arg;
struct nfs_openres *o_res = &data->o_res;
struct rpc_task *task;
@@ -2680,11 +2682,11 @@ static int nfs4_run_open_task(struct nfs4_opendata *data,
data->cancelled = false;
data->is_recover = false;
if (!ctx) {
- nfs4_init_sequence(&o_arg->seq_args, &o_res->seq_res, 1, 1);
+ nfs4_init_sequence(clp, &o_arg->seq_args, &o_res->seq_res, 1, 1);
data->is_recover = true;
task_setup_data.flags |= RPC_TASK_TIMEOUT;
} else {
- nfs4_init_sequence(&o_arg->seq_args, &o_res->seq_res, 1, 0);
+ nfs4_init_sequence(clp, &o_arg->seq_args, &o_res->seq_res, 1, 0);
pnfs_lgopen_prepare(data, ctx);
}
task = rpc_run_task(&task_setup_data);
@@ -3807,6 +3809,7 @@ static const struct rpc_call_ops nfs4_close_ops = {
int nfs4_do_close(struct nfs4_state *state, gfp_t gfp_mask, int wait)
{
struct nfs_server *server = NFS_SERVER(state->inode);
+ struct nfs_client *clp = server->nfs_client;
struct nfs_seqid *(*alloc_seqid)(struct nfs_seqid_counter *, gfp_t);
struct nfs4_closedata *calldata;
struct nfs4_state_owner *sp = state->owner;
@@ -3827,20 +3830,21 @@ int nfs4_do_close(struct nfs4_state *state, gfp_t gfp_mask, int wait)
if (nfs_server_capable(state->inode, NFS_CAP_MOVEABLE))
task_setup_data.flags |= RPC_TASK_MOVEABLE;
- nfs4_state_protect(server->nfs_client, NFS_SP4_MACH_CRED_CLEANUP,
+ nfs4_state_protect(clp, NFS_SP4_MACH_CRED_CLEANUP,
&task_setup_data.rpc_client, &msg);
calldata = kzalloc(sizeof(*calldata), gfp_mask);
if (calldata == NULL)
goto out;
- nfs4_init_sequence(&calldata->arg.seq_args, &calldata->res.seq_res, 1, 0);
+ nfs4_init_sequence(clp, &calldata->arg.seq_args,
+ &calldata->res.seq_res, 1, 0);
calldata->inode = state->inode;
calldata->state = state;
calldata->arg.fh = NFS_FH(state->inode);
if (!nfs4_copy_open_stateid(&calldata->arg.stateid, state))
goto out_free_calldata;
/* Serialization for the sequence id */
- alloc_seqid = server->nfs_client->cl_mvops->alloc_seqid;
+ alloc_seqid = clp->cl_mvops->alloc_seqid;
calldata->arg.seqid = alloc_seqid(&state->owner->so_seqid, gfp_mask);
if (IS_ERR(calldata->arg.seqid))
goto out_free_calldata;
@@ -4498,10 +4502,11 @@ static int _nfs4_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle,
.callback_ops = &nfs4_call_getattr_ops,
.callback_data = &data,
};
+ struct nfs_client *clp = server->nfs_client;
struct nfs4_gdd_res gdd_res;
int status;
- if (nfs4_has_session(server->nfs_client))
+ if (nfs4_has_session(clp))
task_setup.flags = RPC_TASK_MOVEABLE;
/* Is this is an attribute revalidation, subject to softreval? */
@@ -4514,7 +4519,7 @@ static int _nfs4_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle,
nfs4_bitmap_copy_adjust(bitmask, nfs4_bitmask(server, fattr->label), inode, 0);
nfs_fattr_init(fattr);
- nfs4_init_sequence(&args.seq_args, &res.seq_res, 0, 0);
+ nfs4_init_sequence(clp, &args.seq_args, &res.seq_res, 0, 0);
status = nfs4_call_sync_custom(&task_setup);
@@ -4655,7 +4660,7 @@ static int _nfs4_proc_lookup(struct rpc_clnt *clnt, struct inode *dir,
nfs_fattr_init(fattr);
dprintk("NFS call lookup %pd2\n", dentry);
- nfs4_init_sequence(&args.seq_args, &res.seq_res, 0, 0);
+ nfs4_init_sequence(server->nfs_client, &args.seq_args, &res.seq_res, 0, 0);
status = nfs4_do_call_sync(clnt, server, &msg,
&args.seq_args, &res.seq_res, task_flags);
dprintk("NFS reply lookup: %d\n", status);
@@ -4773,7 +4778,7 @@ static int _nfs4_proc_lookupp(struct inode *inode,
args.bitmask = nfs4_bitmask(server, fattr->label);
nfs_fattr_init(fattr);
- nfs4_init_sequence(&args.seq_args, &res.seq_res, 0, 0);
+ nfs4_init_sequence(server->nfs_client, &args.seq_args, &res.seq_res, 0, 0);
dprintk("NFS call lookupp ino=0x%lx\n", inode->i_ino);
status = nfs4_do_call_sync(clnt, server, &msg, &args.seq_args,
@@ -5018,10 +5023,12 @@ static void nfs4_proc_unlink_setup(struct rpc_message *msg,
{
struct nfs_removeargs *args = msg->rpc_argp;
struct nfs_removeres *res = msg->rpc_resp;
+ struct nfs_server *server = NFS_SB(dentry->d_sb);
- res->server = NFS_SB(dentry->d_sb);
+ res->server = server;
msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_REMOVE];
- nfs4_init_sequence(&args->seq_args, &res->seq_res, 1, 0);
+ nfs4_init_sequence(server->nfs_client, &args->seq_args,
+ &res->seq_res, 1, 0);
nfs_fattr_init(res->dir_attr);
nfs_request_directory_delegation(d_inode(dentry->d_parent));
@@ -5062,6 +5069,7 @@ static void nfs4_proc_rename_setup(struct rpc_message *msg,
struct dentry *new_dentry,
struct inode *same_parent)
{
+ struct nfs_server *server = NFS_SB(old_dentry->d_sb);
struct nfs_renameargs *arg = msg->rpc_argp;
struct nfs_renameres *res = msg->rpc_resp;
struct inode *old_inode = d_inode(old_dentry);
@@ -5074,8 +5082,9 @@ static void nfs4_proc_rename_setup(struct rpc_message *msg,
if (same_parent)
nfs_request_directory_delegation(same_parent);
msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_RENAME];
- res->server = NFS_SB(old_dentry->d_sb);
- nfs4_init_sequence(&arg->seq_args, &res->seq_res, 1, 0);
+ res->server = server,
+ nfs4_init_sequence(server->nfs_client, &arg->seq_args,
+ &res->seq_res, 1, 0);
}
static void nfs4_proc_rename_rpc_prepare(struct rpc_task *task, struct nfs_renamedata *data)
@@ -5743,7 +5752,8 @@ static void nfs4_proc_read_setup(struct nfs_pgio_header *hdr,
hdr->pgio_done_cb = nfs4_read_done_cb;
if (!nfs42_read_plus_support(hdr, msg))
msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_READ];
- nfs4_init_sequence(&hdr->args.seq_args, &hdr->res.seq_res, 0, 0);
+ nfs4_init_sequence(NFS_SERVER(hdr->inode)->nfs_client,
+ &hdr->args.seq_args, &hdr->res.seq_res, 0, 0);
}
static int nfs4_proc_pgio_rpc_prepare(struct rpc_task *task,
@@ -5885,7 +5895,8 @@ static void nfs4_proc_write_setup(struct nfs_pgio_header *hdr,
hdr->timestamp = jiffies;
msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_WRITE];
- nfs4_init_sequence(&hdr->args.seq_args, &hdr->res.seq_res, 0, 0);
+ nfs4_init_sequence(server->nfs_client, &hdr->args.seq_args,
+ &hdr->res.seq_res, 0, 0);
nfs4_state_protect_write(hdr->ds_clp ? hdr->ds_clp : server->nfs_client, clnt, msg, hdr);
}
@@ -5926,7 +5937,8 @@ static void nfs4_proc_commit_setup(struct nfs_commit_data *data, struct rpc_mess
data->commit_done_cb = nfs4_commit_done_cb;
data->res.server = server;
msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_COMMIT];
- nfs4_init_sequence(&data->args.seq_args, &data->res.seq_res, 1, 0);
+ nfs4_init_sequence(server->nfs_client, &data->args.seq_args,
+ &data->res.seq_res, 1, 0);
nfs4_state_protect(data->ds_clp ? data->ds_clp : server->nfs_client,
NFS_SP4_MACH_CRED_COMMIT, clnt, msg);
}
@@ -6922,12 +6934,8 @@ static int _nfs4_proc_delegreturn(struct inode *inode, const struct cred *cred,
data->res.sattr_res = true;
}
- if (!data->inode)
- nfs4_init_sequence(&data->args.seq_args, &data->res.seq_res, 1,
- 1);
- else
- nfs4_init_sequence(&data->args.seq_args, &data->res.seq_res, 1,
- 0);
+ nfs4_init_sequence(server->nfs_client, &data->args.seq_args,
+ &data->res.seq_res, 1, !data->inode ? 1 : 0);
task_setup_data.callback_data = data;
msg.rpc_argp = &data->args;
@@ -7206,6 +7214,7 @@ static struct rpc_task *nfs4_do_unlck(struct file_lock *fl,
struct nfs_seqid *seqid)
{
struct nfs4_unlockdata *data;
+ struct nfs_client *clp = NFS_SERVER(lsp->ls_state->inode)->nfs_client;
struct rpc_message msg = {
.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_LOCKU],
.rpc_cred = ctx->cred,
@@ -7221,8 +7230,8 @@ static struct rpc_task *nfs4_do_unlck(struct file_lock *fl,
if (nfs_server_capable(lsp->ls_state->inode, NFS_CAP_MOVEABLE))
task_setup_data.flags |= RPC_TASK_MOVEABLE;
- nfs4_state_protect(NFS_SERVER(lsp->ls_state->inode)->nfs_client,
- NFS_SP4_MACH_CRED_CLEANUP, &task_setup_data.rpc_client, &msg);
+ nfs4_state_protect(clp, NFS_SP4_MACH_CRED_CLEANUP,
+ &task_setup_data.rpc_client, &msg);
/* Ensure this is an unlock - when canceling a lock, the
* canceled lock is passed in, and it won't be an unlock.
@@ -7237,7 +7246,7 @@ static struct rpc_task *nfs4_do_unlck(struct file_lock *fl,
return ERR_PTR(-ENOMEM);
}
- nfs4_init_sequence(&data->arg.seq_args, &data->res.seq_res, 1, 0);
+ nfs4_init_sequence(clp, &data->arg.seq_args, &data->res.seq_res, 1, 0);
msg.rpc_argp = &data->arg;
msg.rpc_resp = &data->res;
task_setup_data.callback_data = data;
@@ -7487,6 +7496,7 @@ static int _nfs4_do_setlk(struct nfs4_state *state, int cmd, struct file_lock *f
{
struct nfs4_lockdata *data;
struct rpc_task *task;
+ struct nfs_client *clp = NFS_SERVER(state->inode)->nfs_client;
struct rpc_message msg = {
.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_LOCK],
.rpc_cred = state->owner->so_cred,
@@ -7510,7 +7520,7 @@ static int _nfs4_do_setlk(struct nfs4_state *state, int cmd, struct file_lock *f
return -ENOMEM;
if (IS_SETLKW(cmd))
data->arg.block = 1;
- nfs4_init_sequence(&data->arg.seq_args, &data->res.seq_res, 1,
+ nfs4_init_sequence(clp, &data->arg.seq_args, &data->res.seq_res, 1,
recovery_type > NFS_LOCK_NEW);
msg.rpc_argp = &data->arg;
msg.rpc_resp = &data->res;
@@ -8190,6 +8200,7 @@ static int _nfs41_proc_get_locations(struct nfs_server *server,
struct page *page, const struct cred *cred)
{
struct rpc_clnt *clnt = server->client;
+ struct nfs_client *clp = server->nfs_client;
u32 bitmask[2] = {
[0] = FATTR4_WORD0_FSID | FATTR4_WORD0_FS_LOCATIONS,
};
@@ -8217,7 +8228,7 @@ static int _nfs41_proc_get_locations(struct nfs_server *server,
struct rpc_task_setup task_setup_data = {
.rpc_client = clnt,
.rpc_message = &msg,
- .callback_ops = server->nfs_client->cl_mvops->call_sync_ops,
+ .callback_ops = clp->cl_mvops->call_sync_ops,
.callback_data = &data,
.flags = RPC_TASK_NO_ROUND_ROBIN,
};
@@ -8227,7 +8238,7 @@ static int _nfs41_proc_get_locations(struct nfs_server *server,
locations->server = server;
locations->nlocations = 0;
- nfs4_init_sequence(&args.seq_args, &res.seq_res, 0, 1);
+ nfs4_init_sequence(clp, &args.seq_args, &res.seq_res, 0, 1);
status = nfs4_call_sync_custom(&task_setup_data);
if (status == NFS4_OK &&
res.seq_res.sr_status_flags & SEQ4_STATUS_LEASE_MOVED)
@@ -8314,7 +8325,7 @@ static int _nfs41_proc_fsid_present(struct inode *inode, const struct cred *cred
if (res.fh == NULL)
return -ENOMEM;
- nfs4_init_sequence(&args.seq_args, &res.seq_res, 0, 1);
+ nfs4_init_sequence(server->nfs_client, &args.seq_args, &res.seq_res, 0, 1);
status = nfs4_call_sync_sequence(clnt, server, &msg,
&args.seq_args, &res.seq_res);
nfs_free_fhandle(res.fh);
@@ -8415,7 +8426,7 @@ static int _nfs4_proc_secinfo(struct inode *dir, const struct qstr *name, struct
dprintk("NFS call secinfo %s\n", name->name);
nfs4_state_protect(clp, NFS_SP4_MACH_CRED_SECINFO, &clnt, &msg);
- nfs4_init_sequence(&args.seq_args, &res.seq_res, 0, 0);
+ nfs4_init_sequence(clp, &args.seq_args, &res.seq_res, 0, 0);
status = nfs4_call_sync_custom(&task_setup);
dprintk("NFS reply secinfo: %d\n", status);
@@ -9141,7 +9152,7 @@ int nfs4_proc_get_lease_time(struct nfs_client *clp, struct nfs_fsinfo *fsinfo)
.flags = RPC_TASK_TIMEOUT,
};
- nfs4_init_sequence(&args.la_seq_args, &res.lr_seq_res, 0, 1);
+ nfs4_init_sequence(clp, &args.la_seq_args, &res.lr_seq_res, 0, 1);
return nfs4_call_sync_custom(&task_setup);
}
@@ -9480,7 +9491,7 @@ static struct rpc_task *_nfs41_proc_sequence(struct nfs_client *clp,
calldata = kzalloc(sizeof(*calldata), GFP_KERNEL);
if (calldata == NULL)
goto out_put_clp;
- nfs4_init_sequence(&calldata->args, &calldata->res, 0, is_privileged);
+ nfs4_init_sequence(clp, &calldata->args, &calldata->res, 0, is_privileged);
nfs4_sequence_attach_slot(&calldata->args, &calldata->res, slot);
msg.rpc_argp = &calldata->args;
msg.rpc_resp = &calldata->res;
@@ -9630,7 +9641,7 @@ static int nfs41_proc_reclaim_complete(struct nfs_client *clp,
calldata->clp = clp;
calldata->arg.one_fs = 0;
- nfs4_init_sequence(&calldata->arg.seq_args, &calldata->res.seq_res, 0, 1);
+ nfs4_init_sequence(clp, &calldata->arg.seq_args, &calldata->res.seq_res, 0, 1);
msg.rpc_argp = &calldata->arg;
msg.rpc_resp = &calldata->res;
task_setup_data.callback_data = calldata;
@@ -9794,7 +9805,8 @@ nfs4_proc_layoutget(struct nfs4_layoutget *lgp,
struct pnfs_layout_segment *lseg = NULL;
int status = 0;
- nfs4_init_sequence(&lgp->args.seq_args, &lgp->res.seq_res, 0, 0);
+ nfs4_init_sequence(server->nfs_client, &lgp->args.seq_args,
+ &lgp->res.seq_res, 0, 0);
exception->retry = 0;
task = rpc_run_task(&task_setup_data);
@@ -9929,6 +9941,7 @@ static const struct rpc_call_ops nfs4_layoutreturn_call_ops = {
int nfs4_proc_layoutreturn(struct nfs4_layoutreturn *lrp, unsigned int flags)
{
+ struct nfs_client *clp = NFS_SERVER(lrp->args.inode)->nfs_client;
struct rpc_task *task;
struct rpc_message msg = {
.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_LAYOUTRETURN],
@@ -9945,9 +9958,8 @@ int nfs4_proc_layoutreturn(struct nfs4_layoutreturn *lrp, unsigned int flags)
};
int status = 0;
- nfs4_state_protect(NFS_SERVER(lrp->args.inode)->nfs_client,
- NFS_SP4_MACH_CRED_PNFS_CLEANUP,
- &task_setup_data.rpc_client, &msg);
+ nfs4_state_protect(clp, NFS_SP4_MACH_CRED_PNFS_CLEANUP,
+ &task_setup_data.rpc_client, &msg);
lrp->inode = nfs_igrab_and_active(lrp->args.inode);
if (flags & PNFS_FL_LAYOUTRETURN_ASYNC) {
@@ -9959,12 +9971,9 @@ int nfs4_proc_layoutreturn(struct nfs4_layoutreturn *lrp, unsigned int flags)
}
if (!lrp->inode)
flags |= PNFS_FL_LAYOUTRETURN_PRIVILEGED;
- if (flags & PNFS_FL_LAYOUTRETURN_PRIVILEGED)
- nfs4_init_sequence(&lrp->args.seq_args, &lrp->res.seq_res, 1,
- 1);
- else
- nfs4_init_sequence(&lrp->args.seq_args, &lrp->res.seq_res, 1,
- 0);
+
+ nfs4_init_sequence(clp, &lrp->args.seq_args, &lrp->res.seq_res, 1,
+ flags & PNFS_FL_LAYOUTRETURN_PRIVILEGED ? 1 : 0);
task = rpc_run_task(&task_setup_data);
if (IS_ERR(task))
return PTR_ERR(task);
@@ -10114,7 +10123,8 @@ nfs4_proc_layoutcommit(struct nfs4_layoutcommit_data *data, bool sync)
}
task_setup_data.flags = RPC_TASK_ASYNC;
}
- nfs4_init_sequence(&data->args.seq_args, &data->res.seq_res, 1, 0);
+ nfs4_init_sequence(NFS_SERVER(data->args.inode)->nfs_client,
+ &data->args.seq_args, &data->res.seq_res, 1, 0);
task = rpc_run_task(&task_setup_data);
if (IS_ERR(task))
return PTR_ERR(task);
@@ -10135,6 +10145,7 @@ static int _nfs41_proc_secinfo_no_name(struct nfs_server *server,
struct nfs4_secinfo_flavors *flavors,
bool use_integrity)
{
+ struct nfs_client *clp = server->nfs_client;
struct nfs41_secinfo_no_name_args args = {
.style = SECINFO_STYLE_CURRENT_FH,
};
@@ -10154,7 +10165,7 @@ static int _nfs41_proc_secinfo_no_name(struct nfs_server *server,
struct rpc_task_setup task_setup = {
.rpc_client = server->client,
.rpc_message = &msg,
- .callback_ops = server->nfs_client->cl_mvops->call_sync_ops,
+ .callback_ops = clp->cl_mvops->call_sync_ops,
.callback_data = &data,
.flags = RPC_TASK_NO_ROUND_ROBIN,
};
@@ -10162,13 +10173,13 @@ static int _nfs41_proc_secinfo_no_name(struct nfs_server *server,
int status;
if (use_integrity) {
- task_setup.rpc_client = server->nfs_client->cl_rpcclient;
+ task_setup.rpc_client = clp->cl_rpcclient;
- cred = nfs4_get_clid_cred(server->nfs_client);
+ cred = nfs4_get_clid_cred(clp);
msg.rpc_cred = cred;
}
- nfs4_init_sequence(&args.seq_args, &res.seq_res, 0, 0);
+ nfs4_init_sequence(clp, &args.seq_args, &res.seq_res, 0, 0);
status = nfs4_call_sync_custom(&task_setup);
dprintk("<-- %s status=%d\n", __func__, status);
@@ -10300,12 +10311,12 @@ static int _nfs41_test_stateid(struct nfs_server *server,
.rpc_cred = cred,
};
struct rpc_clnt *rpc_client = server->client;
+ struct nfs_client *clp = server->nfs_client;
- nfs4_state_protect(server->nfs_client, NFS_SP4_MACH_CRED_STATEID,
- &rpc_client, &msg);
+ nfs4_state_protect(clp, NFS_SP4_MACH_CRED_STATEID, &rpc_client, &msg);
dprintk("NFS call test_stateid %p\n", stateid);
- nfs4_init_sequence(&args.seq_args, &res.seq_res, 0, 1);
+ nfs4_init_sequence(clp, &args.seq_args, &res.seq_res, 0, 1);
status = nfs4_call_sync_sequence(rpc_client, server, &msg,
&args.seq_args, &res.seq_res);
if (status != NFS_OK) {
@@ -10435,7 +10446,7 @@ static int nfs41_free_stateid(struct nfs_server *server,
if (!refcount_inc_not_zero(&clp->cl_count))
return -EIO;
- nfs4_state_protect(server->nfs_client, NFS_SP4_MACH_CRED_STATEID,
+ nfs4_state_protect(clp, NFS_SP4_MACH_CRED_STATEID,
&task_setup.rpc_client, &msg);
dprintk("NFS call free_stateid %p\n", stateid);
@@ -10449,7 +10460,8 @@ static int nfs41_free_stateid(struct nfs_server *server,
msg.rpc_argp = &data->args;
msg.rpc_resp = &data->res;
- nfs4_init_sequence(&data->args.seq_args, &data->res.seq_res, 1, privileged);
+ nfs4_init_sequence(clp, &data->args.seq_args, &data->res.seq_res, 1,
+ privileged);
task = rpc_run_task(&task_setup);
if (IS_ERR(task))
return PTR_ERR(task);
--
2.52.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v2 12/14] NFS: Move sequence slot operations into minorversion operations
2026-01-26 20:39 [PATCH v2 00/14] NFS: Make NFS v4.0 KConfig-urable Anna Schumaker
` (10 preceding siblings ...)
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
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
13 siblings, 0 replies; 16+ messages in thread
From: Anna Schumaker @ 2026-01-26 20:39 UTC (permalink / raw)
To: linux-nfs, trond.myklebust; +Cc: anna
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
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v2 13/14] NFS: Add a way to disable NFS v4.0 via KConfig
2026-01-26 20:39 [PATCH v2 00/14] NFS: Make NFS v4.0 KConfig-urable Anna Schumaker
` (11 preceding siblings ...)
2026-01-26 20:39 ` [PATCH v2 12/14] NFS: Move sequence slot operations into minorversion operations Anna Schumaker
@ 2026-01-26 20:39 ` Anna Schumaker
2026-01-26 20:39 ` [PATCH v2 14/14] NFS: Merge CONFIG_NFS_V4_1 with CONFIG_NFS_V4 Anna Schumaker
13 siblings, 0 replies; 16+ messages in thread
From: Anna Schumaker @ 2026-01-26 20:39 UTC (permalink / raw)
To: linux-nfs, trond.myklebust; +Cc: anna
From: Anna Schumaker <anna.schumaker@oracle.com>
I introduce NFS4_MIN_MINOR_VERSION as a parallel to
NFS4_MAX_MINOR_VERSION to check if NFS v4.0 has been compiled in and
return an appropriate error if not.
Signed-off-by: Anna Schumaker <anna.schumaker@oracle.com>
---
fs/nfs/Kconfig | 9 +++++++++
fs/nfs/Makefile | 3 ++-
fs/nfs/fs_context.c | 3 ++-
fs/nfs/nfs4_fs.h | 6 ++++++
fs/nfs/nfs4client.c | 3 ++-
fs/nfs/nfs4proc.c | 2 ++
fs/nfs/nfs4state.c | 2 ++
fs/nfs/nfs4xdr.c | 27 +++++++++++++++++++++++++--
8 files changed, 50 insertions(+), 5 deletions(-)
diff --git a/fs/nfs/Kconfig b/fs/nfs/Kconfig
index 07932ce9246c..058ed67b98cc 100644
--- a/fs/nfs/Kconfig
+++ b/fs/nfs/Kconfig
@@ -96,6 +96,15 @@ config NFS_SWAP
help
This option enables swapon to work on files located on NFS mounts.
+config NFS_V4_0
+ bool "NFS client support for NFSv4.0"
+ depends on NFS_V4
+ help
+ This option enables support for minor version 0 of the NFSv4 protocol
+ (RFC 3530) in the kernel's NFS client.
+
+ If unsure, say N.
+
config NFS_V4_1
bool "NFS client support for NFSv4.1"
depends on NFS_V4
diff --git a/fs/nfs/Makefile b/fs/nfs/Makefile
index d05e69c00fe1..6a9aaf2f913b 100644
--- a/fs/nfs/Makefile
+++ b/fs/nfs/Makefile
@@ -27,9 +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 nfs40proc.o nfs40client.o
+ dns_resolve.o nfs4trace.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
diff --git a/fs/nfs/fs_context.c b/fs/nfs/fs_context.c
index b4679b7161b0..86750f110053 100644
--- a/fs/nfs/fs_context.c
+++ b/fs/nfs/fs_context.c
@@ -806,7 +806,8 @@ static int nfs_fs_context_parse_param(struct fs_context *fc,
ctx->mount_server.version = result.uint_32;
break;
case Opt_minorversion:
- if (result.uint_32 > NFS4_MAX_MINOR_VERSION)
+ if (result.uint_32 < NFS4_MIN_MINOR_VERSION ||
+ result.uint_32 > NFS4_MAX_MINOR_VERSION)
goto out_of_bounds;
ctx->minorversion = result.uint_32;
break;
diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h
index 6cb2c1d9d691..1f233411578c 100644
--- a/fs/nfs/nfs4_fs.h
+++ b/fs/nfs/nfs4_fs.h
@@ -10,6 +10,12 @@
#ifndef __LINUX_FS_NFS_NFS4_FS_H
#define __LINUX_FS_NFS_NFS4_FS_H
+#if defined(CONFIG_NFS_V4_0)
+#define NFS4_MIN_MINOR_VERSION 0
+#else
+#define NFS4_MIN_MINOR_VERSION 1
+#endif
+
#if defined(CONFIG_NFS_V4_2)
#define NFS4_MAX_MINOR_VERSION 2
#elif defined(CONFIG_NFS_V4_1)
diff --git a/fs/nfs/nfs4client.c b/fs/nfs/nfs4client.c
index c376b2420b6c..00b57e55aba8 100644
--- a/fs/nfs/nfs4client.c
+++ b/fs/nfs/nfs4client.c
@@ -203,7 +203,8 @@ struct nfs_client *nfs4_alloc_client(const struct nfs_client_initdata *cl_init)
if (err)
goto error;
- if (cl_init->minorversion > NFS4_MAX_MINOR_VERSION) {
+ if (cl_init->minorversion < NFS4_MIN_MINOR_VERSION ||
+ cl_init->minorversion > NFS4_MAX_MINOR_VERSION) {
err = -EINVAL;
goto error;
}
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index eaf2e5f5cf55..9daba5b7a545 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -10570,7 +10570,9 @@ static const struct nfs4_minor_version_ops nfs_v4_2_minor_ops = {
#endif
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
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
index 1546351e76b2..87c40c207ab6 100644
--- a/fs/nfs/nfs4state.c
+++ b/fs/nfs/nfs4state.c
@@ -1804,9 +1804,11 @@ static int nfs4_recovery_handle_error(struct nfs_client *clp, int error)
switch (error) {
case 0:
break;
+#if IS_ENABLED(CONFIG_NFS_V4_0)
case -NFS4ERR_CB_PATH_DOWN:
nfs40_handle_cb_pathdown(clp);
break;
+#endif /* CONFIG_NFS_V4_0 */
case -NFS4ERR_NO_GRACE:
nfs4_state_end_reclaim_reboot(clp);
break;
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index b6fe30577fab..73f36dd539ec 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -1399,11 +1399,13 @@ static void encode_locku(struct xdr_stream *xdr, const struct nfs_locku_args *ar
xdr_encode_hyper(p, nfs4_lock_length(args->fl));
}
+#if defined(CONFIG_NFS_V4_0)
static void encode_release_lockowner(struct xdr_stream *xdr, const struct nfs_lowner *lowner, struct compound_hdr *hdr)
{
encode_op_hdr(xdr, OP_RELEASE_LOCKOWNER, decode_release_lockowner_maxsz, hdr);
encode_lockowner(xdr, lowner);
}
+#endif /* CONFIG_NFS_V4_0 */
static void encode_lookup(struct xdr_stream *xdr, const struct qstr *name, struct compound_hdr *hdr)
{
@@ -2583,6 +2585,7 @@ static void nfs4_xdr_enc_locku(struct rpc_rqst *req, struct xdr_stream *xdr,
encode_nops(&hdr);
}
+#if defined(CONFIG_NFS_V4_0)
static void nfs4_xdr_enc_release_lockowner(struct rpc_rqst *req,
struct xdr_stream *xdr,
const void *data)
@@ -2596,6 +2599,7 @@ static void nfs4_xdr_enc_release_lockowner(struct rpc_rqst *req,
encode_release_lockowner(xdr, &args->lock_owner, &hdr);
encode_nops(&hdr);
}
+#endif /* CONFIG_NFS_V4_0 */
/*
* Encode a READLINK request
@@ -2825,6 +2829,7 @@ static void nfs4_xdr_enc_server_caps(struct rpc_rqst *req,
/*
* a RENEW request
*/
+#if defined(CONFIG_NFS_V4_0)
static void nfs4_xdr_enc_renew(struct rpc_rqst *req, struct xdr_stream *xdr,
const void *data)
@@ -2838,6 +2843,7 @@ static void nfs4_xdr_enc_renew(struct rpc_rqst *req, struct xdr_stream *xdr,
encode_renew(xdr, clp->cl_clientid, &hdr);
encode_nops(&hdr);
}
+#endif /* CONFIG_NFS_V4_0 */
/*
* a SETCLIENTID request
@@ -5224,10 +5230,12 @@ static int decode_locku(struct xdr_stream *xdr, struct nfs_locku_res *res)
return status;
}
+#if defined(CONFIG_NFS_V4_0)
static int decode_release_lockowner(struct xdr_stream *xdr)
{
return decode_op_hdr(xdr, OP_RELEASE_LOCKOWNER);
}
+#endif /* CONFIG_NFS_V4_0 */
static int decode_lookup(struct xdr_stream *xdr)
{
@@ -6930,6 +6938,7 @@ static int nfs4_xdr_dec_locku(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
return status;
}
+#if defined(CONFIG_NFS_V4_0)
static int nfs4_xdr_dec_release_lockowner(struct rpc_rqst *rqstp,
struct xdr_stream *xdr, void *dummy)
{
@@ -6941,6 +6950,7 @@ static int nfs4_xdr_dec_release_lockowner(struct rpc_rqst *rqstp,
status = decode_release_lockowner(xdr);
return status;
}
+#endif /* CONFIG_NFS_V4_0 */
/*
* Decode READLINK response
@@ -7162,6 +7172,7 @@ static int nfs4_xdr_dec_server_caps(struct rpc_rqst *req,
/*
* Decode RENEW response
*/
+#if defined(CONFIG_NFS_V4_0)
static int nfs4_xdr_dec_renew(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
void *__unused)
{
@@ -7173,6 +7184,7 @@ static int nfs4_xdr_dec_renew(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
status = decode_renew(xdr);
return status;
}
+#endif /* CONFIG_NFS_V4_0 */
/*
* Decode SETCLIENTID response
@@ -7754,7 +7766,18 @@ int nfs4_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry,
.p_name = #proc, \
}
+<<<<<<< Updated upstream
#if defined(CONFIG_NFS_V4_1)
+=======
+#if defined(CONFIG_NFS_V4_0)
+#define PROC40(proc, argtype, restype) \
+ PROC(proc, argtype, restype)
+#else
+#define PROC40(proc, argtype, restype) \
+ STUB(proc)
+#endif /* CONFIG_NFS_V4_0 */
+
+>>>>>>> Stashed changes
#define PROC41(proc, argtype, restype) \
PROC(proc, argtype, restype)
#else
@@ -7781,7 +7804,7 @@ const struct rpc_procinfo nfs4_procedures[] = {
PROC(CLOSE, enc_close, dec_close),
PROC(SETATTR, enc_setattr, dec_setattr),
PROC(FSINFO, enc_fsinfo, dec_fsinfo),
- PROC(RENEW, enc_renew, dec_renew),
+ PROC40(RENEW, enc_renew, dec_renew),
PROC(SETCLIENTID, enc_setclientid, dec_setclientid),
PROC(SETCLIENTID_CONFIRM, enc_setclientid_confirm, dec_setclientid_confirm),
PROC(LOCK, enc_lock, dec_lock),
@@ -7805,7 +7828,7 @@ const struct rpc_procinfo nfs4_procedures[] = {
PROC(GETACL, enc_getacl, dec_getacl),
PROC(SETACL, enc_setacl, dec_setacl),
PROC(FS_LOCATIONS, enc_fs_locations, dec_fs_locations),
- PROC(RELEASE_LOCKOWNER, enc_release_lockowner, dec_release_lockowner),
+ PROC40(RELEASE_LOCKOWNER, enc_release_lockowner, dec_release_lockowner),
PROC(SECINFO, enc_secinfo, dec_secinfo),
PROC(FSID_PRESENT, enc_fsid_present, dec_fsid_present),
PROC41(EXCHANGE_ID, enc_exchange_id, dec_exchange_id),
--
2.52.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v2 14/14] NFS: Merge CONFIG_NFS_V4_1 with CONFIG_NFS_V4
2026-01-26 20:39 [PATCH v2 00/14] NFS: Make NFS v4.0 KConfig-urable Anna Schumaker
` (12 preceding siblings ...)
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 ` Anna Schumaker
2026-02-13 8:58 ` Re; " Geert Uytterhoeven
13 siblings, 1 reply; 16+ messages in thread
From: Anna Schumaker @ 2026-01-26 20:39 UTC (permalink / raw)
To: linux-nfs, trond.myklebust; +Cc: anna
From: Anna Schumaker <anna.schumaker@oracle.com>
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 <anna.schumaker@oracle.com>
---
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 | 90 ---------------------------------------
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(+), 371 deletions(-)
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 @@ __be32 nfs4_callback_recall(void *argp, void *resp,
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 @@ static __be32 encode_getattr_res(struct svc_rqst *rqstp, struct xdr_stream *xdr,
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 1f233411578c..b48e5b87cb2a 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)
+#else
#define NFS4_MAX_MINOR_VERSION 1
-#else
-#define NFS4_MAX_MINOR_VERSION 0
#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[];
@@ -517,18 +489,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 @@ int nfs41_walk_client_list(struct nfs_client *new,
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 9daba5b7a545..9c2ffe72cf33 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 @@ static int nfs4_get_referral(struct rpc_clnt *client, struct inode *dir,
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 @@ int nfs4_lock_expired(struct nfs4_state *state, struct file_lock *request)
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,
@@ -8135,8 +8103,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
@@ -8199,8 +8165,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
@@ -8248,8 +8212,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
@@ -8288,8 +8250,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
@@ -8418,7 +8378,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
@@ -9031,8 +8990,6 @@ int nfs4_destroy_clientid(struct nfs_client *clp)
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;
@@ -9109,8 +9066,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,
@@ -10449,8 +10404,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)
{
@@ -10460,7 +10413,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,
@@ -10527,7 +10479,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 = {
@@ -10573,9 +10524,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
@@ -10743,7 +10692,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,
@@ -10757,7 +10705,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 = {
@@ -10769,10 +10716,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 87c40c207ab6..963719f35467 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 @@ int nfs4_discover_server_trunking(struct nfs_client *clp,
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 73f36dd539ec..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 @@ static int decode_sequence(struct xdr_stream *xdr,
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 @@ static int nfs4_xdr_dec_fsid_present(struct rpc_rqst *rqstp,
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
@@ -7766,9 +7684,6 @@ int nfs4_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry,
.p_name = #proc, \
}
-<<<<<<< Updated upstream
-#if defined(CONFIG_NFS_V4_1)
-=======
#if defined(CONFIG_NFS_V4_0)
#define PROC40(proc, argtype, restype) \
PROC(proc, argtype, restype)
@@ -7777,13 +7692,8 @@ int nfs4_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry,
STUB(proc)
#endif /* CONFIG_NFS_V4_0 */
->>>>>>> Stashed changes
#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 @@ shutdown_store(struct kobject *kobj, struct kobj_attribute *attr,
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 {
--
2.52.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re; [PATCH v2 14/14] NFS: Merge CONFIG_NFS_V4_1 with CONFIG_NFS_V4
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 ` Geert Uytterhoeven
0 siblings, 0 replies; 16+ messages in thread
From: Geert Uytterhoeven @ 2026-02-13 8:58 UTC (permalink / raw)
To: anna; +Cc: trond.myklebust, linux-nfs, linux-kernel
> 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 <anna.schumaker@oracle.com>
Thanks for your patch, which is now commit 7537db24806fdc3d ("NFS:
Merge CONFIG_NFS_V4_1 with CONFIG_NFS_V4") upstream.
> --- 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,
And out of context:
If unsure, say Y.
Shouldn't that become "N", cfr. the old NFS_V4_1 below?
And shouldn't all configs currently enabling CONFIG_NFS_V4, but not
CONFIG_NFS_V4_1, be updated to disable CONFIG_NFS_V4?
> @@ -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.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2026-02-13 8:59 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH v2 12/14] NFS: Move sequence slot operations into minorversion operations Anna Schumaker
2026-01-26 20:39 ` [PATCH v2 13/14] NFS: Add a way to disable NFS v4.0 via KConfig Anna Schumaker
2026-01-26 20:39 ` [PATCH v2 14/14] NFS: Merge CONFIG_NFS_V4_1 with CONFIG_NFS_V4 Anna Schumaker
2026-02-13 8:58 ` Re; " Geert Uytterhoeven
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox