Skip to content

Commit fcbeced

Browse files
chuckleverJ. Bruce Fields
authored andcommitted
svcrdma: Move read list XDR round-up logic
This is a pre-requisite for a subsequent patch. Read list XDR round-up needs to be done _before_ additional inline content is copied to the end of the XDR buffer's page list. Move the logic added by commit e560e3b ("svcrdma: Add zero padding if the client doesn't send it"). Signed-off-by: Chuck Lever <[email protected]> Reviewed-by: Steve Wise <[email protected]> Signed-off-by: J. Bruce Fields <[email protected]>
1 parent 0b056c2 commit fcbeced

File tree

1 file changed

+9
-28
lines changed

1 file changed

+9
-28
lines changed

net/sunrpc/xprtrdma/svc_rdma_recvfrom.c

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
#include <linux/sunrpc/debug.h>
4444
#include <linux/sunrpc/rpc_rdma.h>
4545
#include <linux/spinlock.h>
46-
#include <linux/highmem.h>
4746
#include <asm/unaligned.h>
4847
#include <rdma/ib_verbs.h>
4948
#include <rdma/rdma_cm.h>
@@ -434,6 +433,15 @@ static int rdma_read_chunks(struct svcxprt_rdma *xprt,
434433
}
435434
}
436435

436+
/* Read list may need XDR round-up (see RFC 5666, s. 3.7) */
437+
if (page_offset & 3) {
438+
u32 pad = 4 - (page_offset & 3);
439+
440+
head->arg.page_len += pad;
441+
head->arg.len += pad;
442+
head->arg.buflen += pad;
443+
}
444+
437445
ret = 1;
438446
head->position = position;
439447

@@ -446,32 +454,6 @@ static int rdma_read_chunks(struct svcxprt_rdma *xprt,
446454
return ret;
447455
}
448456

449-
/*
450-
* To avoid a separate RDMA READ just for a handful of zero bytes,
451-
* RFC 5666 section 3.7 allows the client to omit the XDR zero pad
452-
* in chunk lists.
453-
*/
454-
static void
455-
rdma_fix_xdr_pad(struct xdr_buf *buf)
456-
{
457-
unsigned int page_len = buf->page_len;
458-
unsigned int size = (XDR_QUADLEN(page_len) << 2) - page_len;
459-
unsigned int offset, pg_no;
460-
char *p;
461-
462-
if (size == 0)
463-
return;
464-
465-
pg_no = page_len >> PAGE_SHIFT;
466-
offset = page_len & ~PAGE_MASK;
467-
p = page_address(buf->pages[pg_no]);
468-
memset(p + offset, 0, size);
469-
470-
buf->page_len += size;
471-
buf->buflen += size;
472-
buf->len += size;
473-
}
474-
475457
static int rdma_read_complete(struct svc_rqst *rqstp,
476458
struct svc_rdma_op_ctxt *head)
477459
{
@@ -499,7 +481,6 @@ static int rdma_read_complete(struct svc_rqst *rqstp,
499481
}
500482

501483
/* Point rq_arg.pages past header */
502-
rdma_fix_xdr_pad(&head->arg);
503484
rqstp->rq_arg.pages = &rqstp->rq_pages[head->hdr_count];
504485
rqstp->rq_arg.page_len = head->arg.page_len;
505486
rqstp->rq_arg.page_base = head->arg.page_base;

0 commit comments

Comments
 (0)