Linux NFS development
 help / color / mirror / Atom feed
* [PATCH 0/6] RFC: NFS sysfs mounts to rpc client structure
@ 2023-04-06 14:09 Benjamin Coddington
  2023-04-06 14:09 ` [PATCH 1/6] NFS: rename nfs_client_kset to nfs_kset Benjamin Coddington
                   ` (5 more replies)
  0 siblings, 6 replies; 10+ messages in thread
From: Benjamin Coddington @ 2023-04-06 14:09 UTC (permalink / raw)
  To: linux-nfs; +Cc: Anna.Schumaker, Olga.Kornievskaia

Here's a bit of sysfs scaffolding that creates structure for each mount and
links that to the sunrpc transport objects.  Having links between mounts and
rpc clients can help admins figure out which sunrpc objects are associated
with which mount.

Ultimately, I would like to flesh out the mount side of this interface with
knobs that allow an "nfs shutdown" and the ability to control various
optional features without having to continually add mount options.  Even
though I don't have anything stable enough to share on that front, I'm
sharing these first few patches for criticism or collaboration.

Benjamin Coddington (6):
  NFS: rename nfs_client_kset to nfs_kset
  NFS: rename nfs_client_kobj to nfs_net_kobj
  NFS: add superblock sysfs entries
  NFS: Add sysfs links to sunrpc clients for nfs_clients
  NFS: add a sysfs link to the lockd rpc_client
  NFS: add a sysfs link to the acl rpc_client

 fs/lockd/clntlock.c         |  6 +++
 fs/nfs/client.c             | 21 ++++++++
 fs/nfs/nfs3client.c         |  4 ++
 fs/nfs/nfs4client.c         |  2 +
 fs/nfs/super.c              |  6 ++-
 fs/nfs/sysfs.c              | 98 ++++++++++++++++++++++++++++++++-----
 fs/nfs/sysfs.h              |  7 +++
 include/linux/lockd/bind.h  |  2 +
 include/linux/nfs_fs_sb.h   |  2 +
 include/linux/sunrpc/clnt.h |  8 ++-
 net/sunrpc/sysfs.h          |  7 ---
 11 files changed, 142 insertions(+), 21 deletions(-)

-- 
2.39.2


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/6] NFS: rename nfs_client_kset to nfs_kset
  2023-04-06 14:09 [PATCH 0/6] RFC: NFS sysfs mounts to rpc client structure Benjamin Coddington
@ 2023-04-06 14:09 ` Benjamin Coddington
  2023-04-06 14:10 ` [PATCH 2/6] NFS: rename nfs_client_kobj to nfs_net_kobj Benjamin Coddington
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Benjamin Coddington @ 2023-04-06 14:09 UTC (permalink / raw)
  To: linux-nfs; +Cc: Anna.Schumaker, Olga.Kornievskaia

Be brief and match the subsystem name.  There's no need to distinguish this
kset variable from the server.

Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
---
 fs/nfs/sysfs.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/fs/nfs/sysfs.c b/fs/nfs/sysfs.c
index 0cbcd2dfa732..81d98727b79f 100644
--- a/fs/nfs/sysfs.c
+++ b/fs/nfs/sysfs.c
@@ -18,7 +18,7 @@
 #include "sysfs.h"
 
 struct kobject *nfs_client_kobj;
-static struct kset *nfs_client_kset;
+static struct kset *nfs_kset;
 
 static void nfs_netns_object_release(struct kobject *kobj)
 {
@@ -55,13 +55,13 @@ static struct kobject *nfs_netns_object_alloc(const char *name,
 
 int nfs_sysfs_init(void)
 {
-	nfs_client_kset = kset_create_and_add("nfs", NULL, fs_kobj);
-	if (!nfs_client_kset)
+	nfs_kset = kset_create_and_add("nfs", NULL, fs_kobj);
+	if (!nfs_kset)
 		return -ENOMEM;
-	nfs_client_kobj = nfs_netns_object_alloc("net", nfs_client_kset, NULL);
+	nfs_client_kobj = nfs_netns_object_alloc("net", nfs_kset, NULL);
 	if  (!nfs_client_kobj) {
-		kset_unregister(nfs_client_kset);
-		nfs_client_kset = NULL;
+		kset_unregister(nfs_kset);
+		nfs_kset = NULL;
 		return -ENOMEM;
 	}
 	return 0;
@@ -70,7 +70,7 @@ int nfs_sysfs_init(void)
 void nfs_sysfs_exit(void)
 {
 	kobject_put(nfs_client_kobj);
-	kset_unregister(nfs_client_kset);
+	kset_unregister(nfs_kset);
 }
 
 static ssize_t nfs_netns_identifier_show(struct kobject *kobj,
@@ -159,7 +159,7 @@ static struct nfs_netns_client *nfs_netns_client_alloc(struct kobject *parent,
 	p = kzalloc(sizeof(*p), GFP_KERNEL);
 	if (p) {
 		p->net = net;
-		p->kobject.kset = nfs_client_kset;
+		p->kobject.kset = nfs_kset;
 		if (kobject_init_and_add(&p->kobject, &nfs_netns_client_type,
 					parent, "nfs_client") == 0)
 			return p;
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/6] NFS: rename nfs_client_kobj to nfs_net_kobj
  2023-04-06 14:09 [PATCH 0/6] RFC: NFS sysfs mounts to rpc client structure Benjamin Coddington
  2023-04-06 14:09 ` [PATCH 1/6] NFS: rename nfs_client_kset to nfs_kset Benjamin Coddington
@ 2023-04-06 14:10 ` Benjamin Coddington
  2023-04-06 22:48   ` kernel test robot
  2023-04-06 14:10 ` [PATCH 3/6] NFS: add superblock sysfs entries Benjamin Coddington
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 10+ messages in thread
From: Benjamin Coddington @ 2023-04-06 14:10 UTC (permalink / raw)
  To: linux-nfs; +Cc: Anna.Schumaker, Olga.Kornievskaia

Match the variable names to the sysfs structure.

Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
---
 fs/nfs/sysfs.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/fs/nfs/sysfs.c b/fs/nfs/sysfs.c
index 81d98727b79f..a496e26fcfb7 100644
--- a/fs/nfs/sysfs.c
+++ b/fs/nfs/sysfs.c
@@ -17,7 +17,7 @@
 #include "netns.h"
 #include "sysfs.h"
 
-struct kobject *nfs_client_kobj;
+struct kobject *nfs_net_kobj;
 static struct kset *nfs_kset;
 
 static void nfs_netns_object_release(struct kobject *kobj)
@@ -58,8 +58,8 @@ int nfs_sysfs_init(void)
 	nfs_kset = kset_create_and_add("nfs", NULL, fs_kobj);
 	if (!nfs_kset)
 		return -ENOMEM;
-	nfs_client_kobj = nfs_netns_object_alloc("net", nfs_kset, NULL);
-	if  (!nfs_client_kobj) {
+	nfs_net_kobj = nfs_netns_object_alloc("net", nfs_kset, NULL);
+	if  (!nfs_net_kobj) {
 		kset_unregister(nfs_kset);
 		nfs_kset = NULL;
 		return -ENOMEM;
@@ -69,7 +69,7 @@ int nfs_sysfs_init(void)
 
 void nfs_sysfs_exit(void)
 {
-	kobject_put(nfs_client_kobj);
+	kobject_put(nfs_net_kobj);
 	kset_unregister(nfs_kset);
 }
 
@@ -172,7 +172,7 @@ void nfs_netns_sysfs_setup(struct nfs_net *netns, struct net *net)
 {
 	struct nfs_netns_client *clp;
 
-	clp = nfs_netns_client_alloc(nfs_client_kobj, net);
+	clp = nfs_netns_client_alloc(nfs_net_kobj, net);
 	if (clp) {
 		netns->nfs_client = clp;
 		kobject_uevent(&clp->kobject, KOBJ_ADD);
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 3/6] NFS: add superblock sysfs entries
  2023-04-06 14:09 [PATCH 0/6] RFC: NFS sysfs mounts to rpc client structure Benjamin Coddington
  2023-04-06 14:09 ` [PATCH 1/6] NFS: rename nfs_client_kset to nfs_kset Benjamin Coddington
  2023-04-06 14:10 ` [PATCH 2/6] NFS: rename nfs_client_kobj to nfs_net_kobj Benjamin Coddington
@ 2023-04-06 14:10 ` Benjamin Coddington
  2023-04-06 16:38   ` kernel test robot
  2023-04-06 16:38   ` kernel test robot
  2023-04-06 14:10 ` [PATCH 4/6] NFS: Add sysfs links to sunrpc clients for nfs_clients Benjamin Coddington
                   ` (2 subsequent siblings)
  5 siblings, 2 replies; 10+ messages in thread
From: Benjamin Coddington @ 2023-04-06 14:10 UTC (permalink / raw)
  To: linux-nfs; +Cc: Anna.Schumaker, Olga.Kornievskaia

Create a sysfs directory for each mount that corresponds to the mount's
nfs_server struct.  As the mount is being constructed, use the name
"server-n", but rename it to the "MAJOR:MINOR" of the mount after assigning
a device_id. The rename approach allows us to populate the mount's directory
with links to the various rpc_client objects during the mount's
construction.  The naming convention (MAJOR:MINOR) can be used to reference
a particular NFS mount's sysfs tree.

Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
---
 fs/nfs/client.c           | 15 +++++++++++
 fs/nfs/super.c            |  6 ++++-
 fs/nfs/sysfs.c            | 54 +++++++++++++++++++++++++++++++++++++++
 fs/nfs/sysfs.h            |  5 ++++
 include/linux/nfs_fs_sb.h |  2 ++
 5 files changed, 81 insertions(+), 1 deletion(-)

diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index f50e025ae406..72da715fc617 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -944,6 +944,8 @@ void nfs_server_remove_lists(struct nfs_server *server)
 }
 EXPORT_SYMBOL_GPL(nfs_server_remove_lists);
 
+static DEFINE_IDA(s_sysfs_ids);
+
 /*
  * Allocate and initialise a server record
  */
@@ -955,6 +957,13 @@ struct nfs_server *nfs_alloc_server(void)
 	if (!server)
 		return NULL;
 
+	server->s_sysfs_id = ida_simple_get(
+		&s_sysfs_ids, 0, 0, GFP_KERNEL);
+	if (server->s_sysfs_id < 0) {
+		kfree(server);
+		return NULL;
+	}
+
 	server->client = server->client_acl = ERR_PTR(-EINVAL);
 
 	/* Zero out the NFS state stuff */
@@ -979,6 +988,7 @@ struct nfs_server *nfs_alloc_server(void)
 	ida_init(&server->lockowner_id);
 	pnfs_init_server(server);
 	rpc_init_wait_queue(&server->uoc_rpcwaitq, "NFS UOC");
+	nfs_sysfs_add_server(server);
 
 	return server;
 }
@@ -1001,6 +1011,10 @@ void nfs_free_server(struct nfs_server *server)
 
 	nfs_put_client(server->nfs_client);
 
+	nfs_sysfs_remove_server(server);
+	kobject_put(&server->kobj);
+	ida_simple_remove(&s_sysfs_ids, server->s_sysfs_id);
+
 	ida_destroy(&server->lockowner_id);
 	ida_destroy(&server->openowner_id);
 	nfs_free_iostats(server->io_stats);
@@ -1385,6 +1399,7 @@ int __init nfs_fs_proc_init(void)
 void nfs_fs_proc_exit(void)
 {
 	remove_proc_subtree("fs/nfsfs", NULL);
+	ida_destroy(&s_sysfs_ids);
 }
 
 #endif /* CONFIG_PROC_FS */
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 05ae23657527..40a866db7965 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -68,6 +68,8 @@
 #include "nfs4session.h"
 #include "pnfs.h"
 #include "nfs.h"
+#include "netns.h"
+#include "sysfs.h"
 
 #define NFSDBG_FACILITY		NFSDBG_VFS
 
@@ -1088,6 +1090,7 @@ static void nfs_fill_super(struct super_block *sb, struct nfs_fs_context *ctx)
 						 &sb->s_blocksize_bits);
 
 	nfs_super_set_maxbytes(sb, server->maxfilesize);
+	nfs_sysfs_move_server_to_sb(sb);
 	server->has_sec_mnt_opts = ctx->has_sec_mnt_opts;
 }
 
@@ -1333,13 +1336,14 @@ int nfs_get_tree_common(struct fs_context *fc)
 }
 
 /*
- * Destroy an NFS2/3 superblock
+ * Destroy an NFS superblock
  */
 void nfs_kill_super(struct super_block *s)
 {
 	struct nfs_server *server = NFS_SB(s);
 	dev_t dev = s->s_dev;
 
+	nfs_sysfs_move_sb_to_server(server);
 	generic_shutdown_super(s);
 
 	nfs_fscache_release_super_cookie(s);
diff --git a/fs/nfs/sysfs.c b/fs/nfs/sysfs.c
index a496e26fcfb7..9eb9fbbf606e 100644
--- a/fs/nfs/sysfs.c
+++ b/fs/nfs/sysfs.c
@@ -190,3 +190,57 @@ void nfs_netns_sysfs_destroy(struct nfs_net *netns)
 		netns->nfs_client = NULL;
 	}
 }
+
+static void nfs_sysfs_sb_release(struct kobject *kobj)
+{
+	/* no-op: why? see lib/kobject.c kobject_cleanup() */
+}
+
+static struct attribute *nfs_mp_attrs[] = {
+        NULL,
+};
+
+ATTRIBUTE_GROUPS(nfs_mp);
+
+static struct kobj_type nfs_sb_ktype = {
+	.release = nfs_sysfs_sb_release,
+	.sysfs_ops = &kobj_sysfs_ops,
+	.default_groups = nfs_mp_groups,
+};
+
+void nfs_sysfs_add_server(struct nfs_server *server)
+{
+	int ret;
+	ret = kobject_init_and_add(&server->kobj, &nfs_sb_ktype,
+				&nfs_kset->kobj, "server-%d", server->s_sysfs_id);
+}
+
+void nfs_sysfs_move_server_to_sb(struct super_block *s)
+{
+	struct nfs_server *server = s->s_fs_info;
+	int ret;
+
+	ret = kobject_rename(&server->kobj, s->s_id);
+	if (ret < 0)
+		pr_warn("NFS: rename sysfs %s failed (%d)\n",
+					server->kobj.name, ret);
+}
+
+void nfs_sysfs_move_sb_to_server(struct nfs_server *server)
+{
+	const char *s;
+	int ret = -ENOMEM;
+
+	s = kasprintf(GFP_KERNEL, "server-%d", server->s_sysfs_id);
+	if (s)
+		ret = kobject_rename(&server->kobj, s);
+	if (ret < 0)
+		pr_warn("NFS: rename sysfs %s failed (%d)\n",
+					server->kobj.name, ret);
+}
+
+/* unlink, not dec-ref */
+void nfs_sysfs_remove_server(struct nfs_server *server)
+{
+	kobject_del(&server->kobj);
+}
diff --git a/fs/nfs/sysfs.h b/fs/nfs/sysfs.h
index 5501ef573c32..ca2373fc76cf 100644
--- a/fs/nfs/sysfs.h
+++ b/fs/nfs/sysfs.h
@@ -22,4 +22,9 @@ extern void nfs_sysfs_exit(void);
 void nfs_netns_sysfs_setup(struct nfs_net *netns, struct net *net);
 void nfs_netns_sysfs_destroy(struct nfs_net *netns);
 
+void nfs_sysfs_add_server(struct nfs_server *s);
+void nfs_sysfs_move_server_to_sb(struct super_block *s);
+void nfs_sysfs_move_sb_to_server(struct nfs_server *s);
+void nfs_sysfs_remove_server(struct nfs_server *s);
+
 #endif
diff --git a/include/linux/nfs_fs_sb.h b/include/linux/nfs_fs_sb.h
index ea2f7e6b1b0b..dee1664abca8 100644
--- a/include/linux/nfs_fs_sb.h
+++ b/include/linux/nfs_fs_sb.h
@@ -183,6 +183,7 @@ struct nfs_server {
 				change_attr_type;/* Description of change attribute */
 
 	struct nfs_fsid		fsid;
+	int			s_sysfs_id;	/* sysfs dentry index */
 	__u64			maxfilesize;	/* maximum file size */
 	struct timespec64	time_delta;	/* smallest time granularity */
 	unsigned long		mount_time;	/* when this fs was mounted */
@@ -259,6 +260,7 @@ struct nfs_server {
 	/* User namespace info */
 	const struct cred	*cred;
 	bool			has_sec_mnt_opts;
+	struct kobject	kobj;
 };
 
 /* Server capabilities */
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 4/6] NFS: Add sysfs links to sunrpc clients for nfs_clients
  2023-04-06 14:09 [PATCH 0/6] RFC: NFS sysfs mounts to rpc client structure Benjamin Coddington
                   ` (2 preceding siblings ...)
  2023-04-06 14:10 ` [PATCH 3/6] NFS: add superblock sysfs entries Benjamin Coddington
@ 2023-04-06 14:10 ` Benjamin Coddington
  2023-04-06 14:10 ` [PATCH 5/6] NFS: add a sysfs link to the lockd rpc_client Benjamin Coddington
  2023-04-06 14:10 ` [PATCH 6/6] NFS: add a sysfs link to the acl rpc_client Benjamin Coddington
  5 siblings, 0 replies; 10+ messages in thread
From: Benjamin Coddington @ 2023-04-06 14:10 UTC (permalink / raw)
  To: linux-nfs; +Cc: Anna.Schumaker, Olga.Kornievskaia

For the general and state management nfs_client under each mount, create
symlinks to their respective rpc_client sysfs entries.

Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
---
 fs/nfs/client.c             |  5 +++++
 fs/nfs/nfs4client.c         |  2 ++
 fs/nfs/sysfs.c              | 20 ++++++++++++++++++++
 fs/nfs/sysfs.h              |  2 ++
 include/linux/sunrpc/clnt.h |  8 +++++++-
 net/sunrpc/sysfs.h          |  7 -------
 6 files changed, 36 insertions(+), 8 deletions(-)

diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index 72da715fc617..de275f1fde92 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -621,6 +621,7 @@ int nfs_init_server_rpcclient(struct nfs_server *server,
 	if (server->flags & NFS_MOUNT_SOFT)
 		server->client->cl_softrtry = 1;
 
+	nfs_sysfs_link_rpc_client(server, server->client, NULL);
 	return 0;
 }
 EXPORT_SYMBOL_GPL(nfs_init_server_rpcclient);
@@ -690,6 +691,7 @@ static int nfs_init_server(struct nfs_server *server,
 		return PTR_ERR(clp);
 
 	server->nfs_client = clp;
+	nfs_sysfs_link_rpc_client(server, clp->cl_rpcclient, "_state");
 
 	/* Initialise the client representation from the mount data */
 	server->flags = ctx->flags;
@@ -1116,6 +1118,9 @@ struct nfs_server *nfs_clone_server(struct nfs_server *source,
 
 	server->fsid = fattr->fsid;
 
+	nfs_sysfs_link_rpc_client(server,
+		server->nfs_client->cl_rpcclient, "_state");
+
 	error = nfs_init_server_rpcclient(server,
 			source->client->cl_timeout,
 			flavor);
diff --git a/fs/nfs/nfs4client.c b/fs/nfs/nfs4client.c
index d3051b051a56..c7012f22a009 100644
--- a/fs/nfs/nfs4client.c
+++ b/fs/nfs/nfs4client.c
@@ -18,6 +18,7 @@
 #include "nfs4idmap.h"
 #include "pnfs.h"
 #include "netns.h"
+#include "sysfs.h"
 
 #define NFSDBG_FACILITY		NFSDBG_CLIENT
 
@@ -947,6 +948,7 @@ static int nfs4_set_client(struct nfs_server *server,
 	set_bit(NFS_CS_CHECK_LEASE_TIME, &clp->cl_res_state);
 
 	server->nfs_client = clp;
+	nfs_sysfs_link_rpc_client(server, clp->cl_rpcclient, "_state");
 	return 0;
 }
 
diff --git a/fs/nfs/sysfs.c b/fs/nfs/sysfs.c
index 9eb9fbbf606e..39bfcbcf916c 100644
--- a/fs/nfs/sysfs.c
+++ b/fs/nfs/sysfs.c
@@ -191,6 +191,26 @@ void nfs_netns_sysfs_destroy(struct nfs_net *netns)
 	}
 }
 
+#define RPC_CLIENT_NAME_SIZE 64
+
+void nfs_sysfs_link_rpc_client(struct nfs_server *server,
+			struct rpc_clnt *clnt, const char *uniq)
+{
+	char name[RPC_CLIENT_NAME_SIZE];
+	int ret;
+
+	strcpy(name, clnt->cl_program->name);
+	strcat(name, uniq ? uniq : "");
+	strcat(name, "_client");
+
+	ret = sysfs_create_link_nowarn(&server->kobj,
+						&clnt->cl_sysfs->kobject, name);
+	if (ret < 0)
+		pr_warn("NFS: can't create link to %s in sysfs (%d)\n",
+			name, ret);
+}
+EXPORT_SYMBOL_GPL(nfs_sysfs_link_rpc_client);
+
 static void nfs_sysfs_sb_release(struct kobject *kobj)
 {
 	/* no-op: why? see lib/kobject.c kobject_cleanup() */
diff --git a/fs/nfs/sysfs.h b/fs/nfs/sysfs.h
index ca2373fc76cf..34e40f3a14cb 100644
--- a/fs/nfs/sysfs.h
+++ b/fs/nfs/sysfs.h
@@ -22,6 +22,8 @@ extern void nfs_sysfs_exit(void);
 void nfs_netns_sysfs_setup(struct nfs_net *netns, struct net *net);
 void nfs_netns_sysfs_destroy(struct nfs_net *netns);
 
+void nfs_sysfs_link_rpc_client(struct nfs_server *server,
+			struct rpc_clnt *clnt, const char *sysfs_prefix);
 void nfs_sysfs_add_server(struct nfs_server *s);
 void nfs_sysfs_move_server_to_sb(struct super_block *s);
 void nfs_sysfs_move_sb_to_server(struct nfs_server *s);
diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
index 770ef2cb5775..4ec718aa91f5 100644
--- a/include/linux/sunrpc/clnt.h
+++ b/include/linux/sunrpc/clnt.h
@@ -30,7 +30,13 @@
 #include <linux/sunrpc/xprtmultipath.h>
 
 struct rpc_inode;
-struct rpc_sysfs_client;
+struct rpc_sysfs_client {
+	struct kobject kobject;
+	struct net *net;
+	struct rpc_clnt *clnt;
+	struct rpc_xprt_switch *xprt_switch;
+};
+
 
 /*
  * The high-level client handle
diff --git a/net/sunrpc/sysfs.h b/net/sunrpc/sysfs.h
index 6620cebd1037..d2dd77a0a0e9 100644
--- a/net/sunrpc/sysfs.h
+++ b/net/sunrpc/sysfs.h
@@ -5,13 +5,6 @@
 #ifndef __SUNRPC_SYSFS_H
 #define __SUNRPC_SYSFS_H
 
-struct rpc_sysfs_client {
-	struct kobject kobject;
-	struct net *net;
-	struct rpc_clnt *clnt;
-	struct rpc_xprt_switch *xprt_switch;
-};
-
 struct rpc_sysfs_xprt_switch {
 	struct kobject kobject;
 	struct net *net;
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 5/6] NFS: add a sysfs link to the lockd rpc_client
  2023-04-06 14:09 [PATCH 0/6] RFC: NFS sysfs mounts to rpc client structure Benjamin Coddington
                   ` (3 preceding siblings ...)
  2023-04-06 14:10 ` [PATCH 4/6] NFS: Add sysfs links to sunrpc clients for nfs_clients Benjamin Coddington
@ 2023-04-06 14:10 ` Benjamin Coddington
  2023-04-06 14:10 ` [PATCH 6/6] NFS: add a sysfs link to the acl rpc_client Benjamin Coddington
  5 siblings, 0 replies; 10+ messages in thread
From: Benjamin Coddington @ 2023-04-06 14:10 UTC (permalink / raw)
  To: linux-nfs; +Cc: Anna.Schumaker, Olga.Kornievskaia

After lockd is started, add a symlink for lockd's rpc_client under
NFS' superblock sysfs.

Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
---
 fs/lockd/clntlock.c        | 6 ++++++
 fs/nfs/client.c            | 1 +
 include/linux/lockd/bind.h | 2 ++
 3 files changed, 9 insertions(+)

diff --git a/fs/lockd/clntlock.c b/fs/lockd/clntlock.c
index a5bb3f721a9d..0340e10b5715 100644
--- a/fs/lockd/clntlock.c
+++ b/fs/lockd/clntlock.c
@@ -94,6 +94,12 @@ void nlmclnt_done(struct nlm_host *host)
 }
 EXPORT_SYMBOL_GPL(nlmclnt_done);
 
+struct rpc_clnt *nlmclnt_rpc_clnt(struct nlm_host *host)
+{
+	return host->h_rpcclnt;
+}
+EXPORT_SYMBOL_GPL(nlmclnt_rpc_clnt);
+
 /*
  * Queue up a lock for blocking so that the GRANTED request can see it
  */
diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index de275f1fde92..eede8c28a56b 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -592,6 +592,7 @@ static int nfs_start_lockd(struct nfs_server *server)
 
 	server->nlm_host = host;
 	server->destroy = nfs_destroy_server;
+	nfs_sysfs_link_rpc_client(server, nlmclnt_rpc_clnt(host), NULL);
 	return 0;
 }
 
diff --git a/include/linux/lockd/bind.h b/include/linux/lockd/bind.h
index 3bc9f7410e21..c53c81242e72 100644
--- a/include/linux/lockd/bind.h
+++ b/include/linux/lockd/bind.h
@@ -20,6 +20,7 @@
 /* Dummy declarations */
 struct svc_rqst;
 struct rpc_task;
+struct rpc_clnt;
 
 /*
  * This is the set of functions for lockd->nfsd communication
@@ -56,6 +57,7 @@ struct nlmclnt_initdata {
 
 extern struct nlm_host *nlmclnt_init(const struct nlmclnt_initdata *nlm_init);
 extern void	nlmclnt_done(struct nlm_host *host);
+extern struct rpc_clnt *nlmclnt_rpc_clnt(struct nlm_host *host);
 
 /*
  * NLM client operations provide a means to modify RPC processing of NLM
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 6/6] NFS: add a sysfs link to the acl rpc_client
  2023-04-06 14:09 [PATCH 0/6] RFC: NFS sysfs mounts to rpc client structure Benjamin Coddington
                   ` (4 preceding siblings ...)
  2023-04-06 14:10 ` [PATCH 5/6] NFS: add a sysfs link to the lockd rpc_client Benjamin Coddington
@ 2023-04-06 14:10 ` Benjamin Coddington
  5 siblings, 0 replies; 10+ messages in thread
From: Benjamin Coddington @ 2023-04-06 14:10 UTC (permalink / raw)
  To: linux-nfs; +Cc: Anna.Schumaker, Olga.Kornievskaia

Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
---
 fs/nfs/nfs3client.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/fs/nfs/nfs3client.c b/fs/nfs/nfs3client.c
index 669cda757a5c..d6726b830c7c 100644
--- a/fs/nfs/nfs3client.c
+++ b/fs/nfs/nfs3client.c
@@ -4,6 +4,8 @@
 #include <linux/sunrpc/addr.h>
 #include "internal.h"
 #include "nfs3_fs.h"
+#include "netns.h"
+#include "sysfs.h"
 
 #ifdef CONFIG_NFS_V3_ACL
 static struct rpc_stat		nfsacl_rpcstat = { &nfsacl_program };
@@ -31,6 +33,8 @@ static void nfs_init_server_aclclient(struct nfs_server *server)
 	if (IS_ERR(server->client_acl))
 		goto out_noacl;
 
+	nfs_sysfs_link_rpc_client(server, server->client_acl, NULL);
+
 	/* No errors! Assume that Sun nfsacls are supported */
 	server->caps |= NFS_CAP_ACLS;
 	return;
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 3/6] NFS: add superblock sysfs entries
  2023-04-06 14:10 ` [PATCH 3/6] NFS: add superblock sysfs entries Benjamin Coddington
@ 2023-04-06 16:38   ` kernel test robot
  2023-04-06 16:38   ` kernel test robot
  1 sibling, 0 replies; 10+ messages in thread
From: kernel test robot @ 2023-04-06 16:38 UTC (permalink / raw)
  To: Benjamin Coddington, linux-nfs
  Cc: oe-kbuild-all, Anna.Schumaker, Olga.Kornievskaia

Hi Benjamin,

kernel test robot noticed the following build warnings:

[auto build test WARNING on trondmy-nfs/linux-next]
[also build test WARNING on linus/master v6.3-rc5 next-20230406]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Benjamin-Coddington/NFS-rename-nfs_client_kset-to-nfs_kset/20230406-221247
base:   git://git.linux-nfs.org/projects/trondmy/linux-nfs.git linux-next
patch link:    https://lore.kernel.org/r/706fb7c1e5bfd869165a61a51663427104567c49.1680786859.git.bcodding%40redhat.com
patch subject: [PATCH 3/6] NFS: add superblock sysfs entries
config: riscv-allmodconfig (https://download.01.org/0day-ci/archive/20230407/202304070050.prAZXGm5-lkp@intel.com/config)
compiler: riscv64-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/d1dbf0643a167363732daa337b0e519f44190733
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Benjamin-Coddington/NFS-rename-nfs_client_kset-to-nfs_kset/20230406-221247
        git checkout d1dbf0643a167363732daa337b0e519f44190733
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=riscv olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=riscv SHELL=/bin/bash fs/nfs/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202304070050.prAZXGm5-lkp@intel.com/

All warnings (new ones prefixed by >>):

   fs/nfs/sysfs.c: In function 'nfs_sysfs_add_server':
>> fs/nfs/sysfs.c:213:13: warning: variable 'ret' set but not used [-Wunused-but-set-variable]
     213 |         int ret;
         |             ^~~


vim +/ret +213 fs/nfs/sysfs.c

   210	
   211	void nfs_sysfs_add_server(struct nfs_server *server)
   212	{
 > 213		int ret;
   214		ret = kobject_init_and_add(&server->kobj, &nfs_sb_ktype,
   215					&nfs_kset->kobj, "server-%d", server->s_sysfs_id);
   216	}
   217	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 3/6] NFS: add superblock sysfs entries
  2023-04-06 14:10 ` [PATCH 3/6] NFS: add superblock sysfs entries Benjamin Coddington
  2023-04-06 16:38   ` kernel test robot
@ 2023-04-06 16:38   ` kernel test robot
  1 sibling, 0 replies; 10+ messages in thread
From: kernel test robot @ 2023-04-06 16:38 UTC (permalink / raw)
  To: Benjamin Coddington, linux-nfs
  Cc: llvm, oe-kbuild-all, Anna.Schumaker, Olga.Kornievskaia

Hi Benjamin,

kernel test robot noticed the following build warnings:

[auto build test WARNING on trondmy-nfs/linux-next]
[also build test WARNING on linus/master v6.3-rc5 next-20230406]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Benjamin-Coddington/NFS-rename-nfs_client_kset-to-nfs_kset/20230406-221247
base:   git://git.linux-nfs.org/projects/trondmy/linux-nfs.git linux-next
patch link:    https://lore.kernel.org/r/706fb7c1e5bfd869165a61a51663427104567c49.1680786859.git.bcodding%40redhat.com
patch subject: [PATCH 3/6] NFS: add superblock sysfs entries
config: i386-randconfig-a004-20230403 (https://download.01.org/0day-ci/archive/20230407/202304070036.ohHbkfab-lkp@intel.com/config)
compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/d1dbf0643a167363732daa337b0e519f44190733
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Benjamin-Coddington/NFS-rename-nfs_client_kset-to-nfs_kset/20230406-221247
        git checkout d1dbf0643a167363732daa337b0e519f44190733
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 SHELL=/bin/bash fs/nfs/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202304070036.ohHbkfab-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> fs/nfs/sysfs.c:213:6: warning: variable 'ret' set but not used [-Wunused-but-set-variable]
           int ret;
               ^
   1 warning generated.


vim +/ret +213 fs/nfs/sysfs.c

   210	
   211	void nfs_sysfs_add_server(struct nfs_server *server)
   212	{
 > 213		int ret;
   214		ret = kobject_init_and_add(&server->kobj, &nfs_sb_ktype,
   215					&nfs_kset->kobj, "server-%d", server->s_sysfs_id);
   216	}
   217	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/6] NFS: rename nfs_client_kobj to nfs_net_kobj
  2023-04-06 14:10 ` [PATCH 2/6] NFS: rename nfs_client_kobj to nfs_net_kobj Benjamin Coddington
@ 2023-04-06 22:48   ` kernel test robot
  0 siblings, 0 replies; 10+ messages in thread
From: kernel test robot @ 2023-04-06 22:48 UTC (permalink / raw)
  To: Benjamin Coddington, linux-nfs
  Cc: oe-kbuild-all, Anna.Schumaker, Olga.Kornievskaia

Hi Benjamin,

kernel test robot noticed the following build warnings:

[auto build test WARNING on trondmy-nfs/linux-next]
[also build test WARNING on linus/master v6.3-rc5 next-20230406]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Benjamin-Coddington/NFS-rename-nfs_client_kset-to-nfs_kset/20230406-221247
base:   git://git.linux-nfs.org/projects/trondmy/linux-nfs.git linux-next
patch link:    https://lore.kernel.org/r/75aec6f877a89c63478073861cf277bbfcb90453.1680786859.git.bcodding%40redhat.com
patch subject: [PATCH 2/6] NFS: rename nfs_client_kobj to nfs_net_kobj
config: i386-randconfig-s001-20230403 (https://download.01.org/0day-ci/archive/20230407/202304070607.zNXFIg0W-lkp@intel.com/config)
compiler: gcc-11 (Debian 11.3.0-8) 11.3.0
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.4-39-gce1a6720-dirty
        # https://github.com/intel-lab-lkp/linux/commit/27e42c94f90782f5d27b8de8e18d701e99764a03
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Benjamin-Coddington/NFS-rename-nfs_client_kset-to-nfs_kset/20230406-221247
        git checkout 27e42c94f90782f5d27b8de8e18d701e99764a03
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=i386 olddefconfig
        make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=i386 SHELL=/bin/bash fs/nfs/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202304070607.zNXFIg0W-lkp@intel.com/

sparse warnings: (new ones prefixed by >>)
>> fs/nfs/sysfs.c:20:16: sparse: sparse: symbol 'nfs_net_kobj' was not declared. Should it be static?

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-04-06 22:49 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-06 14:09 [PATCH 0/6] RFC: NFS sysfs mounts to rpc client structure Benjamin Coddington
2023-04-06 14:09 ` [PATCH 1/6] NFS: rename nfs_client_kset to nfs_kset Benjamin Coddington
2023-04-06 14:10 ` [PATCH 2/6] NFS: rename nfs_client_kobj to nfs_net_kobj Benjamin Coddington
2023-04-06 22:48   ` kernel test robot
2023-04-06 14:10 ` [PATCH 3/6] NFS: add superblock sysfs entries Benjamin Coddington
2023-04-06 16:38   ` kernel test robot
2023-04-06 16:38   ` kernel test robot
2023-04-06 14:10 ` [PATCH 4/6] NFS: Add sysfs links to sunrpc clients for nfs_clients Benjamin Coddington
2023-04-06 14:10 ` [PATCH 5/6] NFS: add a sysfs link to the lockd rpc_client Benjamin Coddington
2023-04-06 14:10 ` [PATCH 6/6] NFS: add a sysfs link to the acl rpc_client Benjamin Coddington

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox