diff options
author | Chuck Lever <chuck.lever@oracle.com> | 2019-04-24 16:39:27 +0300 |
---|---|---|
committer | Anna Schumaker <Anna.Schumaker@Netapp.com> | 2019-04-25 22:02:32 +0300 |
commit | 0f665ceb71a20520bdce76fb63ad68c21841aa62 (patch) | |
tree | cab2855a32d7526fafb478d42a527992b7d4daac /net/sunrpc/xprtrdma/verbs.c | |
parent | bb93a1ae2bf4f6eb3cedf05a2ea4a2e6a80712e6 (diff) | |
download | linux-0f665ceb71a20520bdce76fb63ad68c21841aa62.tar.xz |
xprtrdma: De-duplicate "allocate new, free old regbuf"
Clean up by providing an API to do this common task.
At this point, the difference between rpcrdma_get_sendbuf and
rpcrdma_get_recvbuf has become tiny. These can be collapsed into a
single helper.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
Diffstat (limited to 'net/sunrpc/xprtrdma/verbs.c')
-rw-r--r-- | net/sunrpc/xprtrdma/verbs.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/net/sunrpc/xprtrdma/verbs.c b/net/sunrpc/xprtrdma/verbs.c index 77e0f21c9017..734dfe5d18bd 100644 --- a/net/sunrpc/xprtrdma/verbs.c +++ b/net/sunrpc/xprtrdma/verbs.c @@ -1400,6 +1400,31 @@ rpcrdma_alloc_regbuf(size_t size, enum dma_data_direction direction, } /** + * rpcrdma_regbuf_realloc - re-allocate a SEND/RECV buffer + * @rb: regbuf to reallocate + * @size: size of buffer to be allocated, in bytes + * @flags: GFP flags + * + * Returns true if reallocation was successful. If false is + * returned, @rb is left untouched. + */ +bool rpcrdma_regbuf_realloc(struct rpcrdma_regbuf *rb, size_t size, gfp_t flags) +{ + void *buf; + + buf = kmalloc(size, flags); + if (!buf) + return false; + + rpcrdma_dma_unmap_regbuf(rb); + kfree(rb->rg_data); + + rb->rg_data = buf; + rb->rg_iov.length = size; + return true; +} + +/** * __rpcrdma_map_regbuf - DMA-map a regbuf * @ia: controlling rpcrdma_ia * @rb: regbuf to be mapped |