[PATCH v1 4/8] sunrpc: have client directory a symlink to the root transport

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Instead of duplicating `dstaddr` in client directory, we add a symlink
to the relevant transport directory which now hosts a `dstaddr`.

Signed-off-by: Dan Aloni <dan@xxxxxxxxxxxx>
---
 net/sunrpc/sysfs.c | 44 ++++++--------------------------------------
 1 file changed, 6 insertions(+), 38 deletions(-)

diff --git a/net/sunrpc/sysfs.c b/net/sunrpc/sysfs.c
index 687d4470b90d..ae608235d7e0 100644
--- a/net/sunrpc/sysfs.c
+++ b/net/sunrpc/sysfs.c
@@ -69,37 +69,6 @@ int rpc_sysfs_init(void)
 	return -ENOMEM;
 }
 
-static ssize_t rpc_netns_dstaddr_show(struct kobject *kobj,
-		struct kobj_attribute *attr, char *buf)
-{
-	struct rpc_netns_client *c = container_of(kobj,
-				struct rpc_netns_client, kobject);
-	struct rpc_clnt *clnt = c->clnt;
-	struct rpc_xprt *xprt = rcu_dereference(clnt->cl_xprt);
-
-	return rpc_ntop((struct sockaddr *)&xprt->addr, buf, PAGE_SIZE);
-}
-
-static ssize_t rpc_netns_dstaddr_store(struct kobject *kobj,
-		struct kobj_attribute *attr, const char *buf, size_t count)
-{
-	struct rpc_netns_client *c = container_of(kobj,
-				struct rpc_netns_client, kobject);
-	struct rpc_clnt *clnt = c->clnt;
-	struct rpc_xprt *xprt = rcu_dereference(clnt->cl_xprt);
-	struct sockaddr *saddr = (struct sockaddr *)&xprt->addr;
-	int port = rpc_get_port(saddr);
-
-	xprt->addrlen = rpc_pton(xprt->xprt_net, buf, count - 1, saddr, sizeof(*saddr));
-	rpc_set_port(saddr, port);
-
-	kfree(xprt->address_strings[RPC_DISPLAY_ADDR]);
-	xprt->address_strings[RPC_DISPLAY_ADDR] = kstrndup(buf, count - 1, GFP_KERNEL);
-
-	xprt->ops->connect(xprt, NULL);
-	return count;
-}
-
 static void rpc_netns_client_release(struct kobject *kobj)
 {
 	struct rpc_netns_client *c;
@@ -113,11 +82,7 @@ static const void *rpc_netns_client_namespace(struct kobject *kobj)
 	return container_of(kobj, struct rpc_netns_client, kobject)->net;
 }
 
-static struct kobj_attribute rpc_netns_client_dstaddr = __ATTR(dstaddr,
-		0644, rpc_netns_dstaddr_show, rpc_netns_dstaddr_store);
-
 static struct attribute *rpc_netns_client_attrs[] = {
-	&rpc_netns_client_dstaddr.attr,
 	NULL,
 };
 
@@ -156,12 +121,14 @@ void rpc_netns_client_sysfs_setup(struct rpc_clnt *clnt, struct net *net)
 {
 	struct rpc_netns_client *rpc_client;
 	struct rpc_xprt *xprt = rcu_dereference(clnt->cl_xprt);
-
-	if (!(xprt->prot & (IPPROTO_TCP | XPRT_TRANSPORT_RDMA)))
-		return;
+	struct rpc_netns_xprt *rpc_xprt;
+	int ret;
 
 	rpc_client = rpc_netns_client_alloc(rpc_client_kobj, net, clnt->cl_clid);
 	if (rpc_client) {
+		rpc_xprt = xprt->sysfs;
+		ret = sysfs_create_link_nowarn(&rpc_client->kobject,
+					 &rpc_xprt->kobject, "transport");
 		clnt->cl_sysfs = rpc_client;
 		rpc_client->clnt = clnt;
 		kobject_uevent(&rpc_client->kobject, KOBJ_ADD);
@@ -173,6 +140,7 @@ void rpc_netns_client_sysfs_destroy(struct rpc_clnt *clnt)
 	struct rpc_netns_client *rpc_client = clnt->cl_sysfs;
 
 	if (rpc_client) {
+		sysfs_remove_link(&rpc_client->kobject, "transport");
 		kobject_uevent(&rpc_client->kobject, KOBJ_REMOVE);
 		kobject_del(&rpc_client->kobject);
 		kobject_put(&rpc_client->kobject);
-- 
2.26.2




[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux