Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

nfsd: fput rd_file from XDR encode context

Remove the hack where we fput the read-specific file in generic code.
Instead we can do it in nfsd4_encode_read as that gets called for all
error cases as well.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>

authored by

Christoph Hellwig and committed by
J. Bruce Fields
96bcad50 af90f707

+14 -12
-4
fs/nfsd/nfs4proc.c
··· 1723 1723 be32_to_cpu(status)); 1724 1724 1725 1725 nfsd4_cstate_clear_replay(cstate); 1726 - /* XXX Ugh, we need to get rid of this kind of special case: */ 1727 - if (op->opnum == OP_READ && op->u.read.rd_filp) 1728 - fput(op->u.read.rd_filp); 1729 - 1730 1726 nfsd4_increment_op_stats(op->opnum); 1731 1727 } 1732 1728
+14 -8
fs/nfsd/nfs4xdr.c
··· 33 33 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 34 */ 35 35 36 + #include <linux/file.h> 36 37 #include <linux/slab.h> 37 38 #include <linux/namei.h> 38 39 #include <linux/statfs.h> ··· 3421 3420 int starting_len = xdr->buf->len; 3422 3421 struct raparms *ra = NULL; 3423 3422 __be32 *p; 3424 - __be32 err; 3425 3423 3426 3424 if (nfserr) 3427 - return nfserr; 3425 + goto out; 3428 3426 3429 3427 p = xdr_reserve_space(xdr, 8); /* eof flag and byte count */ 3430 3428 if (!p) { 3431 3429 WARN_ON_ONCE(test_bit(RQ_SPLICE_OK, &resp->rqstp->rq_flags)); 3432 - return nfserr_resource; 3430 + nfserr = nfserr_resource; 3431 + goto out; 3433 3432 } 3434 3433 if (resp->xdr.buf->page_len && test_bit(RQ_SPLICE_OK, &resp->rqstp->rq_flags)) { 3435 3434 WARN_ON_ONCE(1); 3436 - return nfserr_resource; 3435 + nfserr = nfserr_resource; 3436 + goto out; 3437 3437 } 3438 3438 xdr_commit_encode(xdr); 3439 3439 ··· 3446 3444 ra = nfsd_init_raparms(file); 3447 3445 3448 3446 if (file->f_op->splice_read && test_bit(RQ_SPLICE_OK, &resp->rqstp->rq_flags)) 3449 - err = nfsd4_encode_splice_read(resp, read, file, maxcount); 3447 + nfserr = nfsd4_encode_splice_read(resp, read, file, maxcount); 3450 3448 else 3451 - err = nfsd4_encode_readv(resp, read, file, maxcount); 3449 + nfserr = nfsd4_encode_readv(resp, read, file, maxcount); 3452 3450 3453 3451 if (ra) 3454 3452 nfsd_put_raparams(file, ra); 3455 3453 3456 - if (err) 3454 + if (nfserr) 3457 3455 xdr_truncate_encode(xdr, starting_len); 3458 - return err; 3456 + 3457 + out: 3458 + if (file) 3459 + fput(file); 3460 + return nfserr; 3459 3461 } 3460 3462 3461 3463 static __be32