Skip to content

Commit d3abc73

Browse files
olgakorn1Trond Myklebust
authored andcommitted
sunrpc: keep track of the xprt_class in rpc_xprt structure
We need to keep track of the type for a given transport. Signed-off-by: Olga Kornievskaia <kolga@netapp.com> Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
1 parent 5b92687 commit d3abc73

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

include/linux/sunrpc/xprt.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ enum rpc_display_format_t {
5353

5454
struct rpc_task;
5555
struct rpc_xprt;
56+
struct xprt_class;
5657
struct seq_file;
5758
struct svc_serv;
5859
struct net;
@@ -289,6 +290,7 @@ struct rpc_xprt {
289290
atomic_t inject_disconnect;
290291
#endif
291292
struct rcu_head rcu;
293+
const struct xprt_class *xprt_class;
292294
};
293295

294296
#if defined(CONFIG_SUNRPC_BACKCHANNEL)

net/sunrpc/xprtrdma/transport.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ unsigned int xprt_rdma_max_inline_read = RPCRDMA_DEF_INLINE;
7373
unsigned int xprt_rdma_max_inline_write = RPCRDMA_DEF_INLINE;
7474
unsigned int xprt_rdma_memreg_strategy = RPCRDMA_FRWR;
7575
int xprt_rdma_pad_optimize;
76+
static struct xprt_class xprt_rdma;
7677

7778
#if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
7879

@@ -349,6 +350,7 @@ xprt_setup_rdma(struct xprt_create *args)
349350
/* Ensure xprt->addr holds valid server TCP (not RDMA)
350351
* address, for any side protocols which peek at it */
351352
xprt->prot = IPPROTO_TCP;
353+
xprt->xprt_class = &xprt_rdma;
352354
xprt->addrlen = args->addrlen;
353355
memcpy(&xprt->addr, sap, xprt->addrlen);
354356

net/sunrpc/xprtsock.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ static unsigned int xprt_max_resvport_limit = RPC_MAX_RESVPORT;
9191

9292
static struct ctl_table_header *sunrpc_table_header;
9393

94+
static struct xprt_class xs_local_transport;
95+
static struct xprt_class xs_udp_transport;
96+
static struct xprt_class xs_tcp_transport;
97+
static struct xprt_class xs_bc_tcp_transport;
98+
9499
/*
95100
* FIXME: changing the UDP slot table size should also resize the UDP
96101
* socket buffers for existing UDP transports
@@ -2779,6 +2784,7 @@ static struct rpc_xprt *xs_setup_local(struct xprt_create *args)
27792784
transport = container_of(xprt, struct sock_xprt, xprt);
27802785

27812786
xprt->prot = 0;
2787+
xprt->xprt_class = &xs_local_transport;
27822788
xprt->max_payload = RPC_MAX_FRAGMENT_SIZE;
27832789

27842790
xprt->bind_timeout = XS_BIND_TO;
@@ -2848,6 +2854,7 @@ static struct rpc_xprt *xs_setup_udp(struct xprt_create *args)
28482854
transport = container_of(xprt, struct sock_xprt, xprt);
28492855

28502856
xprt->prot = IPPROTO_UDP;
2857+
xprt->xprt_class = &xs_udp_transport;
28512858
/* XXX: header size can vary due to auth type, IPv6, etc. */
28522859
xprt->max_payload = (1U << 16) - (MAX_HEADER << 3);
28532860

@@ -2928,6 +2935,7 @@ static struct rpc_xprt *xs_setup_tcp(struct xprt_create *args)
29282935
transport = container_of(xprt, struct sock_xprt, xprt);
29292936

29302937
xprt->prot = IPPROTO_TCP;
2938+
xprt->xprt_class = &xs_tcp_transport;
29312939
xprt->max_payload = RPC_MAX_FRAGMENT_SIZE;
29322940

29332941
xprt->bind_timeout = XS_BIND_TO;
@@ -3001,6 +3009,7 @@ static struct rpc_xprt *xs_setup_bc_tcp(struct xprt_create *args)
30013009
transport = container_of(xprt, struct sock_xprt, xprt);
30023010

30033011
xprt->prot = IPPROTO_TCP;
3012+
xprt->xprt_class = &xs_bc_tcp_transport;
30043013
xprt->max_payload = RPC_MAX_FRAGMENT_SIZE;
30053014
xprt->timeout = &xs_tcp_default_timeout;
30063015

0 commit comments

Comments
 (0)