diff mbox series

[07/13] sunrpc: keep track of the xprt_class in rpc_xprt structure

Message ID 20210415022802.31692-8-olga.kornievskaia@gmail.com (mailing list archive)
State New
Headers show
Series create sysfs files for changing IP address | expand

Commit Message

Olga Kornievskaia April 15, 2021, 2:27 a.m. UTC
From: Olga Kornievskaia <kolga@netapp.com>

We need to keep track of the type for a given transport.

Signed-off-by: Olga Kornievskaia <kolga@netapp.com>
---
 include/linux/sunrpc/xprt.h     | 2 ++
 net/sunrpc/xprtrdma/transport.c | 2 ++
 net/sunrpc/xprtsock.c           | 9 +++++++++
 3 files changed, 13 insertions(+)

Comments

kernel test robot April 15, 2021, 6:34 a.m. UTC | #1
Hi Olga,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on nfs/linux-next]
[also build test ERROR on nfsd/nfsd-next v5.12-rc7 next-20210414]
[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]

url:    https://github.com/0day-ci/linux/commits/Olga-Kornievskaia/create-sysfs-files-for-changing-IP-address/20210415-102946
base:   git://git.linux-nfs.org/projects/trondmy/linux-nfs.git linux-next
config: ia64-gensparse_defconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 9.3.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/0day-ci/linux/commit/eb4c4b6126d3914b950cb13c118d7b28ce132dc3
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Olga-Kornievskaia/create-sysfs-files-for-changing-IP-address/20210415-102946
        git checkout eb4c4b6126d3914b950cb13c118d7b28ce132dc3
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross W=1 ARCH=ia64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   net/sunrpc/xprtrdma/transport.c: In function 'xprt_setup_rdma':
>> net/sunrpc/xprtrdma/transport.c:353:22: error: 'xprt_rdma' undeclared (first use in this function); did you mean 'xprt_rdma_bc'?
     353 |  xprt->xprt_class = &xprt_rdma;
         |                      ^~~~~~~~~
         |                      xprt_rdma_bc
   net/sunrpc/xprtrdma/transport.c:353:22: note: each undeclared identifier is reported only once for each function it appears in


vim +353 net/sunrpc/xprtrdma/transport.c

   308	
   309	/**
   310	 * xprt_setup_rdma - Set up transport to use RDMA
   311	 *
   312	 * @args: rpc transport arguments
   313	 */
   314	static struct rpc_xprt *
   315	xprt_setup_rdma(struct xprt_create *args)
   316	{
   317		struct rpc_xprt *xprt;
   318		struct rpcrdma_xprt *new_xprt;
   319		struct sockaddr *sap;
   320		int rc;
   321	
   322		if (args->addrlen > sizeof(xprt->addr))
   323			return ERR_PTR(-EBADF);
   324	
   325		if (!try_module_get(THIS_MODULE))
   326			return ERR_PTR(-EIO);
   327	
   328		xprt = xprt_alloc(args->net, sizeof(struct rpcrdma_xprt), 0,
   329				  xprt_rdma_slot_table_entries);
   330		if (!xprt) {
   331			module_put(THIS_MODULE);
   332			return ERR_PTR(-ENOMEM);
   333		}
   334	
   335		xprt->timeout = &xprt_rdma_default_timeout;
   336		xprt->connect_timeout = xprt->timeout->to_initval;
   337		xprt->max_reconnect_timeout = xprt->timeout->to_maxval;
   338		xprt->bind_timeout = RPCRDMA_BIND_TO;
   339		xprt->reestablish_timeout = RPCRDMA_INIT_REEST_TO;
   340		xprt->idle_timeout = RPCRDMA_IDLE_DISC_TO;
   341	
   342		xprt->resvport = 0;		/* privileged port not needed */
   343		xprt->ops = &xprt_rdma_procs;
   344	
   345		/*
   346		 * Set up RDMA-specific connect data.
   347		 */
   348		sap = args->dstaddr;
   349	
   350		/* Ensure xprt->addr holds valid server TCP (not RDMA)
   351		 * address, for any side protocols which peek at it */
   352		xprt->prot = IPPROTO_TCP;
 > 353		xprt->xprt_class = &xprt_rdma;
   354		xprt->addrlen = args->addrlen;
   355		memcpy(&xprt->addr, sap, xprt->addrlen);
   356	
   357		if (rpc_get_port(sap))
   358			xprt_set_bound(xprt);
   359		xprt_rdma_format_addresses(xprt, sap);
   360	
   361		new_xprt = rpcx_to_rdmax(xprt);
   362		rc = rpcrdma_buffer_create(new_xprt);
   363		if (rc) {
   364			xprt_rdma_free_addresses(xprt);
   365			xprt_free(xprt);
   366			module_put(THIS_MODULE);
   367			return ERR_PTR(rc);
   368		}
   369	
   370		INIT_DELAYED_WORK(&new_xprt->rx_connect_worker,
   371				  xprt_rdma_connect_worker);
   372	
   373		xprt->max_payload = RPCRDMA_MAX_DATA_SEGS << PAGE_SHIFT;
   374	
   375		return xprt;
   376	}
   377	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
kernel test robot April 16, 2021, 12:42 a.m. UTC | #2
Hi Olga,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on nfs/linux-next]
[also build test ERROR on nfsd/nfsd-next v5.12-rc7 next-20210415]
[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]

url:    https://github.com/0day-ci/linux/commits/Olga-Kornievskaia/create-sysfs-files-for-changing-IP-address/20210415-102946
base:   git://git.linux-nfs.org/projects/trondmy/linux-nfs.git linux-next
config: x86_64-randconfig-a011-20210415 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 6a18cc23efad410db48a3ccfc233d215de7d4cb9)
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
        # install x86_64 cross compiling tool for clang build
        # apt-get install binutils-x86-64-linux-gnu
        # https://github.com/0day-ci/linux/commit/eb4c4b6126d3914b950cb13c118d7b28ce132dc3
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Olga-Kornievskaia/create-sysfs-files-for-changing-IP-address/20210415-102946
        git checkout eb4c4b6126d3914b950cb13c118d7b28ce132dc3
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

>> net/sunrpc/xprtrdma/transport.c:353:22: error: use of undeclared identifier 'xprt_rdma'; did you mean 'xprt_rdma_bc'?
           xprt->xprt_class = &xprt_rdma;
                               ^~~~~~~~~
                               xprt_rdma_bc
   net/sunrpc/xprtrdma/xprt_rdma.h:595:26: note: 'xprt_rdma_bc' declared here
   extern struct xprt_class xprt_rdma_bc;
                            ^
   1 error generated.


vim +353 net/sunrpc/xprtrdma/transport.c

   308	
   309	/**
   310	 * xprt_setup_rdma - Set up transport to use RDMA
   311	 *
   312	 * @args: rpc transport arguments
   313	 */
   314	static struct rpc_xprt *
   315	xprt_setup_rdma(struct xprt_create *args)
   316	{
   317		struct rpc_xprt *xprt;
   318		struct rpcrdma_xprt *new_xprt;
   319		struct sockaddr *sap;
   320		int rc;
   321	
   322		if (args->addrlen > sizeof(xprt->addr))
   323			return ERR_PTR(-EBADF);
   324	
   325		if (!try_module_get(THIS_MODULE))
   326			return ERR_PTR(-EIO);
   327	
   328		xprt = xprt_alloc(args->net, sizeof(struct rpcrdma_xprt), 0,
   329				  xprt_rdma_slot_table_entries);
   330		if (!xprt) {
   331			module_put(THIS_MODULE);
   332			return ERR_PTR(-ENOMEM);
   333		}
   334	
   335		xprt->timeout = &xprt_rdma_default_timeout;
   336		xprt->connect_timeout = xprt->timeout->to_initval;
   337		xprt->max_reconnect_timeout = xprt->timeout->to_maxval;
   338		xprt->bind_timeout = RPCRDMA_BIND_TO;
   339		xprt->reestablish_timeout = RPCRDMA_INIT_REEST_TO;
   340		xprt->idle_timeout = RPCRDMA_IDLE_DISC_TO;
   341	
   342		xprt->resvport = 0;		/* privileged port not needed */
   343		xprt->ops = &xprt_rdma_procs;
   344	
   345		/*
   346		 * Set up RDMA-specific connect data.
   347		 */
   348		sap = args->dstaddr;
   349	
   350		/* Ensure xprt->addr holds valid server TCP (not RDMA)
   351		 * address, for any side protocols which peek at it */
   352		xprt->prot = IPPROTO_TCP;
 > 353		xprt->xprt_class = &xprt_rdma;
   354		xprt->addrlen = args->addrlen;
   355		memcpy(&xprt->addr, sap, xprt->addrlen);
   356	
   357		if (rpc_get_port(sap))
   358			xprt_set_bound(xprt);
   359		xprt_rdma_format_addresses(xprt, sap);
   360	
   361		new_xprt = rpcx_to_rdmax(xprt);
   362		rc = rpcrdma_buffer_create(new_xprt);
   363		if (rc) {
   364			xprt_rdma_free_addresses(xprt);
   365			xprt_free(xprt);
   366			module_put(THIS_MODULE);
   367			return ERR_PTR(rc);
   368		}
   369	
   370		INIT_DELAYED_WORK(&new_xprt->rx_connect_worker,
   371				  xprt_rdma_connect_worker);
   372	
   373		xprt->max_payload = RPCRDMA_MAX_DATA_SEGS << PAGE_SHIFT;
   374	
   375		return xprt;
   376	}
   377	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff mbox series

Patch

diff --git a/include/linux/sunrpc/xprt.h b/include/linux/sunrpc/xprt.h
index 82294d06075c..a2edcc42e6c4 100644
--- a/include/linux/sunrpc/xprt.h
+++ b/include/linux/sunrpc/xprt.h
@@ -53,6 +53,7 @@  enum rpc_display_format_t {
 
 struct rpc_task;
 struct rpc_xprt;
+struct xprt_class;
 struct seq_file;
 struct svc_serv;
 struct net;
@@ -289,6 +290,7 @@  struct rpc_xprt {
 	atomic_t		inject_disconnect;
 #endif
 	struct rcu_head		rcu;
+	const struct xprt_class	*xprt_class;
 };
 
 #if defined(CONFIG_SUNRPC_BACKCHANNEL)
diff --git a/net/sunrpc/xprtrdma/transport.c b/net/sunrpc/xprtrdma/transport.c
index 78d29d1bcc20..2c2e51e54fbb 100644
--- a/net/sunrpc/xprtrdma/transport.c
+++ b/net/sunrpc/xprtrdma/transport.c
@@ -87,6 +87,7 @@  static unsigned int dummy;
 
 static struct ctl_table_header *sunrpc_table_header;
 
+static struct xprt_class xprt_rdma;
 static struct ctl_table xr_tunables_table[] = {
 	{
 		.procname	= "rdma_slot_table_entries",
@@ -347,6 +348,7 @@  xprt_setup_rdma(struct xprt_create *args)
 	/* Ensure xprt->addr holds valid server TCP (not RDMA)
 	 * address, for any side protocols which peek at it */
 	xprt->prot = IPPROTO_TCP;
+	xprt->xprt_class = &xprt_rdma;
 	xprt->addrlen = args->addrlen;
 	memcpy(&xprt->addr, sap, xprt->addrlen);
 
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
index 2bcb80c19339..5ff37badd335 100644
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -91,6 +91,11 @@  static unsigned int xprt_max_resvport_limit = RPC_MAX_RESVPORT;
 
 static struct ctl_table_header *sunrpc_table_header;
 
+static struct xprt_class xs_local_transport;
+static struct xprt_class xs_udp_transport;
+static struct xprt_class xs_tcp_transport;
+static struct xprt_class xs_bc_tcp_transport;
+
 /*
  * FIXME: changing the UDP slot table size should also resize the UDP
  *        socket buffers for existing UDP transports
@@ -2777,6 +2782,7 @@  static struct rpc_xprt *xs_setup_local(struct xprt_create *args)
 	transport = container_of(xprt, struct sock_xprt, xprt);
 
 	xprt->prot = 0;
+	xprt->xprt_class = &xs_local_transport;
 	xprt->max_payload = RPC_MAX_FRAGMENT_SIZE;
 
 	xprt->bind_timeout = XS_BIND_TO;
@@ -2846,6 +2852,7 @@  static struct rpc_xprt *xs_setup_udp(struct xprt_create *args)
 	transport = container_of(xprt, struct sock_xprt, xprt);
 
 	xprt->prot = IPPROTO_UDP;
+	xprt->xprt_class = &xs_udp_transport;
 	/* XXX: header size can vary due to auth type, IPv6, etc. */
 	xprt->max_payload = (1U << 16) - (MAX_HEADER << 3);
 
@@ -2926,6 +2933,7 @@  static struct rpc_xprt *xs_setup_tcp(struct xprt_create *args)
 	transport = container_of(xprt, struct sock_xprt, xprt);
 
 	xprt->prot = IPPROTO_TCP;
+	xprt->xprt_class = &xs_tcp_transport;
 	xprt->max_payload = RPC_MAX_FRAGMENT_SIZE;
 
 	xprt->bind_timeout = XS_BIND_TO;
@@ -2999,6 +3007,7 @@  static struct rpc_xprt *xs_setup_bc_tcp(struct xprt_create *args)
 	transport = container_of(xprt, struct sock_xprt, xprt);
 
 	xprt->prot = IPPROTO_TCP;
+	xprt->xprt_class = &xs_bc_tcp_transport;
 	xprt->max_payload = RPC_MAX_FRAGMENT_SIZE;
 	xprt->timeout = &xs_tcp_default_timeout;