NFSD: Clean up SPLICE_OK in nfsd4_encode_read()
[ Upstream commit c738b218a2e5a753a336b4b7fee6720b902c7ace ] Do the test_bit() once -- this reduces the number of locked-bus operations and makes the function a little easier to read. Reviewed-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
b91534de99
commit
abc7f2871b
1 changed files with 4 additions and 5 deletions
|
@ -3991,6 +3991,7 @@ static __be32
|
||||||
nfsd4_encode_read(struct nfsd4_compoundres *resp, __be32 nfserr,
|
nfsd4_encode_read(struct nfsd4_compoundres *resp, __be32 nfserr,
|
||||||
struct nfsd4_read *read)
|
struct nfsd4_read *read)
|
||||||
{
|
{
|
||||||
|
bool splice_ok = test_bit(RQ_SPLICE_OK, &resp->rqstp->rq_flags);
|
||||||
unsigned long maxcount;
|
unsigned long maxcount;
|
||||||
struct xdr_stream *xdr = resp->xdr;
|
struct xdr_stream *xdr = resp->xdr;
|
||||||
struct file *file;
|
struct file *file;
|
||||||
|
@ -4003,11 +4004,10 @@ nfsd4_encode_read(struct nfsd4_compoundres *resp, __be32 nfserr,
|
||||||
|
|
||||||
p = xdr_reserve_space(xdr, 8); /* eof flag and byte count */
|
p = xdr_reserve_space(xdr, 8); /* eof flag and byte count */
|
||||||
if (!p) {
|
if (!p) {
|
||||||
WARN_ON_ONCE(test_bit(RQ_SPLICE_OK, &resp->rqstp->rq_flags));
|
WARN_ON_ONCE(splice_ok);
|
||||||
return nfserr_resource;
|
return nfserr_resource;
|
||||||
}
|
}
|
||||||
if (resp->xdr->buf->page_len &&
|
if (resp->xdr->buf->page_len && splice_ok) {
|
||||||
test_bit(RQ_SPLICE_OK, &resp->rqstp->rq_flags)) {
|
|
||||||
WARN_ON_ONCE(1);
|
WARN_ON_ONCE(1);
|
||||||
return nfserr_serverfault;
|
return nfserr_serverfault;
|
||||||
}
|
}
|
||||||
|
@ -4016,8 +4016,7 @@ nfsd4_encode_read(struct nfsd4_compoundres *resp, __be32 nfserr,
|
||||||
maxcount = min_t(unsigned long, read->rd_length,
|
maxcount = min_t(unsigned long, read->rd_length,
|
||||||
(xdr->buf->buflen - xdr->buf->len));
|
(xdr->buf->buflen - xdr->buf->len));
|
||||||
|
|
||||||
if (file->f_op->splice_read &&
|
if (file->f_op->splice_read && splice_ok)
|
||||||
test_bit(RQ_SPLICE_OK, &resp->rqstp->rq_flags))
|
|
||||||
nfserr = nfsd4_encode_splice_read(resp, read, file, maxcount);
|
nfserr = nfsd4_encode_splice_read(resp, read, file, maxcount);
|
||||||
else
|
else
|
||||||
nfserr = nfsd4_encode_readv(resp, read, file, maxcount);
|
nfserr = nfsd4_encode_readv(resp, read, file, maxcount);
|
||||||
|
|
Loading…
Add table
Reference in a new issue