SUNRPC/NFSD: Implement xdr_reserve_space_vec()
authorAnna Schumaker <Anna.Schumaker@Netapp.com>
Mon, 17 Aug 2020 16:53:06 +0000 (12:53 -0400)
committerJ. Bruce Fields <bfields@redhat.com>
Fri, 25 Sep 2020 22:01:27 +0000 (18:01 -0400)
commit403217f30418c808600e3e8e345413ba5cc15676
tree5513e684750faaaa6cf321498478809d87bf4b67
parent3caf91757ced158e6c4a44d8b105bd7b3e1767d8
SUNRPC/NFSD: Implement xdr_reserve_space_vec()

Reserving space for a large READ payload requires special handling when
reserving space in the xdr buffer pages. One problem we can have is use
of the scratch buffer, which is used to get a pointer to a contiguous
region of data up to PAGE_SIZE. When using the scratch buffer, calls to
xdr_commit_encode() shift the data to it's proper alignment in the xdr
buffer. If we've reserved several pages in a vector, then this could
potentially invalidate earlier pointers and result in incorrect READ
data being sent to the client.

I get around this by looking at the amount of space left in the current
page, and never reserve more than that for each entry in the read
vector. This lets us place data directly where it needs to go in the
buffer pages.

Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
fs/nfsd/nfs4xdr.c
include/linux/sunrpc/xdr.h
net/sunrpc/xdr.c