summaryrefslogtreecommitdiff
path: root/fs/nfsd/nfs4xdr.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2015-06-18 16:44:58 +0200
committerJ. Bruce Fields <bfields@redhat.com>2015-06-19 15:39:51 -0400
commite749a4621e414c36a54ac8b3205955e267f00db3 (patch)
tree5567c049b21a6e9fdf9025b5a6fc0c8ec742f493 /fs/nfsd/nfs4xdr.c
parent97b1f9aae963cc0b229ef8147db4782170564d4f (diff)
nfsd: clean up raparams handling
Refactor the raparam hash helpers to just deal with the raparms, and keep opening/closing files separate from that. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd/nfs4xdr.c')
-rw-r--r--fs/nfsd/nfs4xdr.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index 5c7eab9c12ba..5286206169bc 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -33,6 +33,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <linux/file.h>
#include <linux/slab.h>
#include <linux/namei.h>
#include <linux/statfs.h>
@@ -3419,7 +3420,7 @@ nfsd4_encode_read(struct nfsd4_compoundres *resp, __be32 nfserr,
struct file *file = read->rd_filp;
struct svc_fh *fhp = read->rd_fhp;
int starting_len = xdr->buf->len;
- struct raparms *ra;
+ struct raparms *ra = NULL;
__be32 *p;
__be32 err;
@@ -3441,23 +3442,30 @@ nfsd4_encode_read(struct nfsd4_compoundres *resp, __be32 nfserr,
maxcount = min_t(unsigned long, maxcount, (xdr->buf->buflen - xdr->buf->len));
maxcount = min_t(unsigned long, maxcount, read->rd_length);
- if (read->rd_filp)
+ if (read->rd_filp) {
err = nfsd_permission(resp->rqstp, fhp->fh_export,
fhp->fh_dentry,
NFSD_MAY_READ|NFSD_MAY_OWNER_OVERRIDE);
- else
- err = nfsd_get_tmp_read_open(resp->rqstp, read->rd_fhp,
- &file, &ra);
- if (err)
- goto err_truncate;
+ if (err)
+ goto err_truncate;
+ } else {
+ err = nfsd_open(resp->rqstp, fhp, S_IFREG, NFSD_MAY_READ,
+ &file);
+ if (err)
+ goto err_truncate;
+
+ ra = nfsd_init_raparms(file);
+ }
if (file->f_op->splice_read && test_bit(RQ_SPLICE_OK, &resp->rqstp->rq_flags))
err = nfsd4_encode_splice_read(resp, read, file, maxcount);
else
err = nfsd4_encode_readv(resp, read, file, maxcount);
+ if (ra)
+ nfsd_put_raparams(file, ra);
if (!read->rd_filp)
- nfsd_put_tmp_read_open(file, ra);
+ fput(file);
err_truncate:
if (err)