Skip to content

Commit

Permalink
sunrpc: keep track of the xprt_class in rpc_xprt structure
Browse files Browse the repository at this point in the history
We need to keep track of the type for a given transport.

Signed-off-by: Olga Kornievskaia <kolga@netapp.com>
  • Loading branch information
olgakorn1 authored and intel-lab-lkp committed Apr 15, 2021
1 parent 6a14583 commit eb4c4b6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/linux/sunrpc/xprt.h
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions net/sunrpc/xprtrdma/transport.c
Expand Up @@ -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",
Expand Down Expand Up @@ -349,6 +350,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);

Expand Down
9 changes: 9 additions & 0 deletions net/sunrpc/xprtsock.c
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit eb4c4b6

Please sign in to comment.