[PATCH RFC 4/6] SUNRPC: svc_fill_write_vector() must handle non-zero page_bases

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



svc_fill_write_vector() was introduced in commit 8154ef2776aa
("NFSD: Clean up legacy NFS WRITE argument XDR decoders").

I'm about to add a case where page_base will sometimes not be zero
when the NFS WRITE proc functions invoke this API. Refactor the
API and function internals to handle this case properly.

Signed-off-by: Chuck Lever <chuck.lever@xxxxxxxxxx>
---
 net/sunrpc/svc.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
index 34ced7f538ee..3d9f9da98aed 100644
--- a/net/sunrpc/svc.c
+++ b/net/sunrpc/svc.c
@@ -1705,6 +1705,7 @@ unsigned int svc_fill_write_vector(struct svc_rqst *rqstp,
 	struct kvec *vec = rqstp->rq_vec;
 	size_t total = payload->len;
 	unsigned int i;
+	size_t offset;
 
 	/* Some types of transport can present the write payload
 	 * entirely in rq_arg.pages. In this case, @first is empty.
@@ -1717,12 +1718,14 @@ unsigned int svc_fill_write_vector(struct svc_rqst *rqstp,
 		++i;
 	}
 
+	offset = payload->page_base;
 	while (total) {
-		vec[i].iov_base = page_address(*pages);
-		vec[i].iov_len = min_t(size_t, total, PAGE_SIZE);
+		vec[i].iov_base = page_address(*pages) + offset;
+		vec[i].iov_len = min_t(size_t, total, PAGE_SIZE - offset);
 		total -= vec[i].iov_len;
 		++i;
 		++pages;
+		offset = 0;
 	}
 
 	WARN_ON_ONCE(i > ARRAY_SIZE(rqstp->rq_vec));





[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux