Skip to content

Commit ad3d24c

Browse files
chuckleverChuck Lever
authored andcommitted
SUNRPC: Clean up xdr_write_pages()
Make it more evident how xdr_write_pages() updates the tail buffer by using the convention of naming the iov pointer variable "tail". I spent more than a couple of hours chasing through code to understand this, so someone is likely to find this useful later. Signed-off-by: Chuck Lever <[email protected]> Reviewed-by: Jeff Layton <[email protected]>
1 parent da522b5 commit ad3d24c

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

net/sunrpc/xdr.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,30 +1224,34 @@ EXPORT_SYMBOL(xdr_restrict_buflen);
12241224
/**
12251225
* xdr_write_pages - Insert a list of pages into an XDR buffer for sending
12261226
* @xdr: pointer to xdr_stream
1227-
* @pages: list of pages
1228-
* @base: offset of first byte
1229-
* @len: length of data in bytes
1227+
* @pages: array of pages to insert
1228+
* @base: starting offset of first data byte in @pages
1229+
* @len: number of data bytes in @pages to insert
12301230
*
1231+
* After the @pages are added, the tail iovec is instantiated pointing to
1232+
* end of the head buffer, and the stream is set up to encode subsequent
1233+
* items into the tail.
12311234
*/
12321235
void xdr_write_pages(struct xdr_stream *xdr, struct page **pages, unsigned int base,
12331236
unsigned int len)
12341237
{
12351238
struct xdr_buf *buf = xdr->buf;
1236-
struct kvec *iov = buf->tail;
1239+
struct kvec *tail = buf->tail;
1240+
12371241
buf->pages = pages;
12381242
buf->page_base = base;
12391243
buf->page_len = len;
12401244

1241-
iov->iov_base = (char *)xdr->p;
1242-
iov->iov_len = 0;
1243-
xdr->iov = iov;
1245+
tail->iov_base = xdr->p;
1246+
tail->iov_len = 0;
1247+
xdr->iov = tail;
12441248

12451249
if (len & 3) {
12461250
unsigned int pad = 4 - (len & 3);
12471251

12481252
BUG_ON(xdr->p >= xdr->end);
1249-
iov->iov_base = (char *)xdr->p + (len & 3);
1250-
iov->iov_len += pad;
1253+
tail->iov_base = (char *)xdr->p + (len & 3);
1254+
tail->iov_len += pad;
12511255
len += pad;
12521256
*xdr->p++ = 0;
12531257
}

0 commit comments

Comments
 (0)