All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Aloni <dan@kernelim.com>
To: linux-nfs@vger.kernel.org, Anna Schumaker <anna.schumaker@netapp.com>
Cc: Trond Myklebust <trond.myklebust@hammerspace.com>
Subject: [PATCH v1 7/8] sunrpc: change rpc_clnt_add_xprt() to rpc_add_xprt()
Date: Mon, 15 Feb 2021 19:40:01 +0200	[thread overview]
Message-ID: <20210215174002.2376333-8-dan@kernelim.com> (raw)
In-Reply-To: <20210215174002.2376333-1-dan@kernelim.com>

This change of API allows adding transports without holding a reference
to an rpc client.

Signed-off-by: Dan Aloni <dan@kernelim.com>
---
 fs/nfs/pnfs_nfs.c           | 12 +++++++-----
 include/linux/sunrpc/clnt.h | 12 +++++++-----
 net/sunrpc/clnt.c           | 31 +++++++++++++++++--------------
 3 files changed, 31 insertions(+), 24 deletions(-)

diff --git a/fs/nfs/pnfs_nfs.c b/fs/nfs/pnfs_nfs.c
index 49d3389bd813..1e61626bd0fa 100644
--- a/fs/nfs/pnfs_nfs.c
+++ b/fs/nfs/pnfs_nfs.c
@@ -878,8 +878,9 @@ static int _nfs4_pnfs_v3_ds_connect(struct nfs_server *mds_srv,
 			if (da->da_addr.ss_family != clp->cl_addr.ss_family)
 				continue;
 			/* Add this address as an alias */
-			rpc_clnt_add_xprt(clp->cl_rpcclient, &xprt_args,
-					rpc_clnt_test_and_add_xprt, NULL);
+			rpc_add_xprt(&clp->cl_rpcclient->cl_xpi,
+				     clp->cl_rpcclient, &xprt_args,
+				     rpc_clnt_test_and_add_xprt, NULL);
 			continue;
 		}
 		clp = get_v3_ds_connect(mds_srv,
@@ -945,9 +946,10 @@ static int _nfs4_pnfs_v4_ds_connect(struct nfs_server *mds_srv,
 			* add as an alias
 			*/
 			xprtdata.cred = nfs4_get_clid_cred(clp),
-			rpc_clnt_add_xprt(clp->cl_rpcclient, &xprt_args,
-					  rpc_clnt_setup_test_and_add_xprt,
-					  &rpcdata);
+			rpc_add_xprt(&clp->cl_rpcclient->cl_xpi,
+				     clp->cl_rpcclient, &xprt_args,
+				     rpc_clnt_setup_test_and_add_xprt,
+				     &rpcdata);
 			if (xprtdata.cred)
 				put_cred(xprtdata.cred);
 		} else {
diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
index 503653720e18..19bb23143eef 100644
--- a/include/linux/sunrpc/clnt.h
+++ b/include/linux/sunrpc/clnt.h
@@ -210,21 +210,23 @@ int 		rpc_clnt_iterate_for_each_xprt(struct rpc_clnt *clnt,
 			int (*fn)(struct rpc_clnt *, struct rpc_xprt *, void *),
 			void *data);
 
-int 		rpc_clnt_test_and_add_xprt(struct rpc_clnt *clnt,
+int 		rpc_clnt_test_and_add_xprt(void *clnt,
 			struct rpc_xprt_switch *xps,
 			struct rpc_xprt *xprt,
 			void *dummy);
-int		rpc_clnt_add_xprt(struct rpc_clnt *, struct xprt_create *,
-			int (*setup)(struct rpc_clnt *,
+int		rpc_add_xprt(struct rpc_xprt_iter *iter,
+		        void *ctx,
+		        struct xprt_create *xprtargs,
+		        int (*setup)(void *ctx,
 				struct rpc_xprt_switch *,
 				struct rpc_xprt *,
 				void *),
-			void *data);
+		        void *data);
 void		rpc_set_connect_timeout(struct rpc_clnt *clnt,
 			unsigned long connect_timeout,
 			unsigned long reconnect_timeout);
 
-int		rpc_clnt_setup_test_and_add_xprt(struct rpc_clnt *,
+int		rpc_clnt_setup_test_and_add_xprt(void *,
 			struct rpc_xprt_switch *,
 			struct rpc_xprt *,
 			void *);
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
index 0a4811be01cd..b94d274a5446 100644
--- a/net/sunrpc/clnt.c
+++ b/net/sunrpc/clnt.c
@@ -598,7 +598,7 @@ struct rpc_clnt *rpc_create(struct rpc_create_args *args)
 		return clnt;
 
 	for (i = 0; i < args->nconnect - 1; i++) {
-		if (rpc_clnt_add_xprt(clnt, &xprtargs, NULL, NULL) < 0)
+		if (rpc_add_xprt(&clnt->cl_xpi, NULL, &xprtargs, NULL, NULL) < 0)
 			break;
 	}
 	return clnt;
@@ -2751,10 +2751,11 @@ static const struct rpc_call_ops rpc_cb_add_xprt_call_ops = {
  * @xprt: pointer struct rpc_xprt
  * @dummy: unused
  */
-int rpc_clnt_test_and_add_xprt(struct rpc_clnt *clnt,
+int rpc_clnt_test_and_add_xprt(void *ptr,
 		struct rpc_xprt_switch *xps, struct rpc_xprt *xprt,
 		void *dummy)
 {
+	struct rpc_clnt *clnt = ptr;
 	struct rpc_cb_add_xprt_calldata *data;
 	struct rpc_task *task;
 
@@ -2795,11 +2796,12 @@ EXPORT_SYMBOL_GPL(rpc_clnt_test_and_add_xprt);
  * @data: a struct rpc_add_xprt_test pointer that holds the test function
  *        and test function call data
  */
-int rpc_clnt_setup_test_and_add_xprt(struct rpc_clnt *clnt,
+int rpc_clnt_setup_test_and_add_xprt(void *ptr,
 				     struct rpc_xprt_switch *xps,
 				     struct rpc_xprt *xprt,
 				     void *data)
 {
+	struct rpc_clnt *clnt = ptr;
 	struct rpc_task *task;
 	struct rpc_add_xprt_test *xtest = (struct rpc_add_xprt_test *)data;
 	int status = -EADDRINUSE;
@@ -2852,13 +2854,14 @@ EXPORT_SYMBOL_GPL(rpc_clnt_setup_test_and_add_xprt);
  * adding the new transport.
  *
  */
-int rpc_clnt_add_xprt(struct rpc_clnt *clnt,
-		struct xprt_create *xprtargs,
-		int (*setup)(struct rpc_clnt *,
-			struct rpc_xprt_switch *,
-			struct rpc_xprt *,
-			void *),
-		void *data)
+int rpc_add_xprt(struct rpc_xprt_iter *iter,
+		 void *ctx,
+		 struct xprt_create *xprtargs,
+		 int (*setup)(void *ctx,
+			      struct rpc_xprt_switch *,
+			      struct rpc_xprt *,
+			      void *),
+		 void *data)
 {
 	struct rpc_xprt_switch *xps;
 	struct rpc_xprt *xprt;
@@ -2868,8 +2871,8 @@ int rpc_clnt_add_xprt(struct rpc_clnt *clnt,
 	int ret = 0;
 
 	rcu_read_lock();
-	xps = xprt_switch_get(rcu_dereference(clnt->cl_xpi.xpi_xpswitch));
-	xprt = xprt_iter_xprt(&clnt->cl_xpi);
+	xps = xprt_switch_get(rcu_dereference(iter->xpi_xpswitch));
+	xprt = xprt_iter_xprt(iter);
 	if (xps == NULL || xprt == NULL) {
 		rcu_read_unlock();
 		xprt_switch_put(xps);
@@ -2895,7 +2898,7 @@ int rpc_clnt_add_xprt(struct rpc_clnt *clnt,
 
 	rpc_xprt_switch_set_roundrobin(xps);
 	if (setup) {
-		ret = setup(clnt, xps, xprt, data);
+		ret = setup(ctx, xps, xprt, data);
 		if (ret != 0)
 			goto out_put_xprt;
 	}
@@ -2906,7 +2909,7 @@ int rpc_clnt_add_xprt(struct rpc_clnt *clnt,
 	xprt_switch_put(xps);
 	return ret;
 }
-EXPORT_SYMBOL_GPL(rpc_clnt_add_xprt);
+EXPORT_SYMBOL_GPL(rpc_add_xprt);
 
 struct connect_timeout_data {
 	unsigned long connect_timeout;
-- 
2.26.2


  parent reply	other threads:[~2021-02-15 17:41 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-15 17:39 [PATCH v1 0/8] sysfs files for multipath transport control Dan Aloni
2021-02-15 17:39 ` [PATCH v1 1/8] sunrpc: rename 'net' to 'client' Dan Aloni
2021-02-16 21:24   ` Anna Schumaker
2021-02-17 18:58     ` Dan Aloni
2021-02-15 17:39 ` [PATCH v1 2/8] sunrpc: add xprt id Dan Aloni
2021-02-15 17:39 ` [PATCH v1 3/8] sunrpc: add a directory per sunrpc xprt Dan Aloni
2021-02-16 21:46   ` Anna Schumaker
2021-02-17 19:01     ` Dan Aloni
2021-02-15 17:39 ` [PATCH v1 4/8] sunrpc: have client directory a symlink to the root transport Dan Aloni
2021-02-15 17:39 ` [PATCH v1 5/8] sunrpc: add IDs to multipath Dan Aloni
2021-02-15 17:40 ` [PATCH v1 6/8] sunrpc: add multipath directory and symlink from client Dan Aloni
2021-02-15 17:40 ` Dan Aloni [this message]
2021-02-15 17:40 ` [PATCH v1 8/8] sunrpc: introduce an 'add' node to 'multipath' sysfs directory Dan Aloni
2021-03-02  3:56 ` [PATCH v1 0/8] sysfs files for multipath transport control Olga Kornievskaia
2021-03-04 11:58   ` Dan Aloni
2021-03-04 18:39     ` Chuck Lever

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210215174002.2376333-8-dan@kernelim.com \
    --to=dan@kernelim.com \
    --cc=anna.schumaker@netapp.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=trond.myklebust@hammerspace.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.