nfsd4: minor encode_read cleanup
authorJ. Bruce Fields <bfields@redhat.com>
Tue, 11 Mar 2014 20:51:23 +0000 (16:51 -0400)
committerJ. Bruce Fields <bfields@redhat.com>
Fri, 30 May 2014 21:31:58 +0000 (17:31 -0400)
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
fs/nfsd/nfs4xdr.c

index 8b3d24de9cacebbf6c4f4689f97d58e417392f89..8ce6c8d5ee8a810c9ce7afb186abcfae634ee496 100644 (file)
@@ -3076,18 +3076,20 @@ nfsd4_encode_read(struct nfsd4_compoundres *resp, __be32 nfserr,
 
        len = maxcount;
        v = 0;
-       while (len > 0) {
+       while (len) {
+               int thislen;
+
                page = *(resp->rqstp->rq_next_page);
                if (!page) { /* ran out of pages */
                        maxcount -= len;
                        break;
                }
+               thislen = min_t(long, len, PAGE_SIZE);
                resp->rqstp->rq_vec[v].iov_base = page_address(page);
-               resp->rqstp->rq_vec[v].iov_len =
-                       len < PAGE_SIZE ? len : PAGE_SIZE;
+               resp->rqstp->rq_vec[v].iov_len = thislen;
                resp->rqstp->rq_next_page++;
                v++;
-               len -= PAGE_SIZE;
+               len -= thislen;
        }
        read->rd_vlen = v;