Skip to content

Commit 5a6d1db

Browse files
chuckleveramschuma-ntap
authored andcommitted
SUNRPC: Add a transport-specific private field in rpc_rqst
Currently there's a hidden and indirect mechanism for finding the rpcrdma_req that goes with an rpc_rqst. It depends on getting from the rq_buffer pointer in struct rpc_rqst to the struct rpcrdma_regbuf that controls that buffer, and then to the struct rpcrdma_req it goes with. This was done back in the day to avoid the need to add a per-rqst pointer or to alter the buf_free API when support for RPC-over-RDMA was introduced. I'm about to change the way regbuf's work to support larger inline thresholds. Now is a good time to replace this indirect mechanism with something that is more straightforward. I guess this should be considered a clean up. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
1 parent 6877894 commit 5a6d1db

File tree

5 files changed

+11
-12
lines changed

5 files changed

+11
-12
lines changed

include/linux/sunrpc/xprt.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ struct rpc_rqst {
8383
void (*rq_release_snd_buf)(struct rpc_rqst *); /* release rq_enc_pages */
8484
struct list_head rq_list;
8585

86+
void *rq_xprtdata; /* Per-xprt private data */
8687
void *rq_buffer; /* Call XDR encode buffer */
8788
size_t rq_callsize;
8889
void *rq_rbuffer; /* Reply XDR decode buffer */

net/sunrpc/xprtrdma/backchannel.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,9 @@ static int rpcrdma_bc_setup_rqst(struct rpcrdma_xprt *r_xprt,
5555
rb = rpcrdma_alloc_regbuf(ia, size, GFP_KERNEL);
5656
if (IS_ERR(rb))
5757
goto out_fail;
58-
rb->rg_owner = req;
5958
req->rl_sendbuf = rb;
60-
/* so that rpcr_to_rdmar works when receiving a request */
61-
rqst->rq_buffer = (void *)req->rl_sendbuf->rg_base;
62-
xdr_buf_init(&rqst->rq_snd_buf, rqst->rq_buffer, size);
59+
xdr_buf_init(&rqst->rq_snd_buf, rb->rg_base, size);
60+
rpcrdma_set_xprtdata(rqst, req);
6361
return 0;
6462

6563
out_fail:

net/sunrpc/xprtrdma/transport.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,7 @@ xprt_rdma_allocate(struct rpc_task *task)
523523
out:
524524
dprintk("RPC: %s: size %zd, request 0x%p\n", __func__, size, req);
525525
req->rl_connect_cookie = 0; /* our reserved value */
526+
rpcrdma_set_xprtdata(rqst, req);
526527
rqst->rq_buffer = req->rl_sendbuf->rg_base;
527528
rqst->rq_rbuffer = (char *)rqst->rq_buffer + rqst->rq_rcvsize;
528529
return 0;
@@ -559,7 +560,6 @@ xprt_rdma_allocate(struct rpc_task *task)
559560
rb = rpcrdma_alloc_regbuf(&r_xprt->rx_ia, size, flags);
560561
if (IS_ERR(rb))
561562
goto out_fail;
562-
rb->rg_owner = req;
563563

564564
r_xprt->rx_stats.hardway_register_count += size;
565565
rpcrdma_free_regbuf(&r_xprt->rx_ia, req->rl_sendbuf);

net/sunrpc/xprtrdma/verbs.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1210,7 +1210,6 @@ rpcrdma_alloc_regbuf(struct rpcrdma_ia *ia, size_t size, gfp_t flags)
12101210
iov->length = size;
12111211
iov->lkey = ia->ri_pd->local_dma_lkey;
12121212
rb->rg_size = size;
1213-
rb->rg_owner = NULL;
12141213
return rb;
12151214

12161215
out_free:

net/sunrpc/xprtrdma/xprt_rdma.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ struct rpcrdma_ep {
113113

114114
struct rpcrdma_regbuf {
115115
size_t rg_size;
116-
struct rpcrdma_req *rg_owner;
117116
struct ib_sge rg_iov;
118117
__be32 rg_base[0] __attribute__ ((aligned(256)));
119118
};
@@ -297,14 +296,16 @@ struct rpcrdma_req {
297296
struct rpcrdma_mr_seg rl_segments[RPCRDMA_MAX_SEGS];
298297
};
299298

299+
static inline void
300+
rpcrdma_set_xprtdata(struct rpc_rqst *rqst, struct rpcrdma_req *req)
301+
{
302+
rqst->rq_xprtdata = req;
303+
}
304+
300305
static inline struct rpcrdma_req *
301306
rpcr_to_rdmar(struct rpc_rqst *rqst)
302307
{
303-
void *buffer = rqst->rq_buffer;
304-
struct rpcrdma_regbuf *rb;
305-
306-
rb = container_of(buffer, struct rpcrdma_regbuf, rg_base);
307-
return rb->rg_owner;
308+
return rqst->rq_xprtdata;
308309
}
309310

310311
/*

0 commit comments

Comments
 (0)