diff options
author | Bernd Schubert <bernd.schubert@itwm.fraunhofer.de> | 2012-03-18 22:44:50 -0400 |
---|---|---|
committer | Ben Hutchings <ben@decadent.org.uk> | 2013-11-28 14:01:59 +0000 |
commit | 7ddeebd9bb1f005226b818f58cd6b2eaadf7976c (patch) | |
tree | 3d07f6819611e98e2bccf98238cf44886b3560f9 /fs | |
parent | d1ccc87a6bdf9397675c8b086cf633db0a17ee51 (diff) |
nfsd: vfs_llseek() with 32 or 64 bit offsets (hashes)
commit 06effdbb49af5f6c7d20affaec74603914acc768 upstream.
Use 32-bit or 64-bit llseek() hashes for directory offsets depending on
the NFS version. NFSv2 gets 32-bit hashes only.
NOTE: This patch got rather complex as Christoph asked to set the
filp->f_mode flag in the open call or immediatly after dentry_open()
in nfsd_open() to avoid races.
Personally I still do not see a reason for that and in my opinion
FMODE_32BITHASH/FMODE_64BITHASH flags could be set nfsd_readdir(), as it
follows directly after nfsd_open() without a chance of races.
Signed-off-by: Bernd Schubert <bernd.schubert@itwm.fraunhofer.de>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Acked-by: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/nfsd/vfs.c | 15 | ||||
-rw-r--r-- | fs/nfsd/vfs.h | 2 |
2 files changed, 15 insertions, 2 deletions
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index 3a80c400a255..61b697e69ef3 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c @@ -786,9 +786,15 @@ nfsd_open(struct svc_rqst *rqstp, struct svc_fh *fhp, int type, if (IS_ERR(*filp)) { host_err = PTR_ERR(*filp); *filp = NULL; - } else + } else { host_err = ima_file_check(*filp, may_flags); + if (may_flags & NFSD_MAY_64BIT_COOKIE) + (*filp)->f_mode |= FMODE_64BITHASH; + else + (*filp)->f_mode |= FMODE_32BITHASH; + } + out_nfserr: err = nfserrno(host_err); out: @@ -2018,8 +2024,13 @@ nfsd_readdir(struct svc_rqst *rqstp, struct svc_fh *fhp, loff_t *offsetp, __be32 err; struct file *file; loff_t offset = *offsetp; + int may_flags = NFSD_MAY_READ; + + /* NFSv2 only supports 32 bit cookies */ + if (rqstp->rq_vers > 2) + may_flags |= NFSD_MAY_64BIT_COOKIE; - err = nfsd_open(rqstp, fhp, S_IFDIR, NFSD_MAY_READ, &file); + err = nfsd_open(rqstp, fhp, S_IFDIR, may_flags, &file); if (err) goto out; diff --git a/fs/nfsd/vfs.h b/fs/nfsd/vfs.h index 3f54ad03bb2b..85d4d422458a 100644 --- a/fs/nfsd/vfs.h +++ b/fs/nfsd/vfs.h @@ -27,6 +27,8 @@ #define NFSD_MAY_BYPASS_GSS 0x400 #define NFSD_MAY_READ_IF_EXEC 0x800 +#define NFSD_MAY_64BIT_COOKIE 0x1000 /* 64 bit readdir cookies for >= NFSv3 */ + #define NFSD_MAY_CREATE (NFSD_MAY_EXEC|NFSD_MAY_WRITE) #define NFSD_MAY_REMOVE (NFSD_MAY_EXEC|NFSD_MAY_WRITE|NFSD_MAY_TRUNC) |