summaryrefslogtreecommitdiff
path: root/fs/nfsd/lockd.c
diff options
context:
space:
mode:
authorJ. Bruce Fields <bfields@redhat.com>2021-08-23 16:44:00 -0400
committerChuck Lever <chuck.lever@oracle.com>2021-08-23 18:05:31 -0400
commit7f024fcd5c97dc70bb9121c80407cf3cf9be7159 (patch)
tree069bd48a61ba4d33bd1f981e3e9d616c262030b5 /fs/nfsd/lockd.c
parentb661601a9fdf1af8516e1100de8bba84bd41cca4 (diff)
Keep read and write fds with each nlm_file
We shouldn't really be using a read-only file descriptor to take a write lock. Most filesystems will put up with it. But NFS, for example, won't. Signed-off-by: J. Bruce Fields <bfields@redhat.com> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Diffstat (limited to 'fs/nfsd/lockd.c')
-rw-r--r--fs/nfsd/lockd.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/fs/nfsd/lockd.c b/fs/nfsd/lockd.c
index 3f5b3d7b62b7..606fa155c28a 100644
--- a/fs/nfsd/lockd.c
+++ b/fs/nfsd/lockd.c
@@ -25,9 +25,11 @@
* Note: we hold the dentry use count while the file is open.
*/
static __be32
-nlm_fopen(struct svc_rqst *rqstp, struct nfs_fh *f, struct file **filp)
+nlm_fopen(struct svc_rqst *rqstp, struct nfs_fh *f, struct file **filp,
+ int mode)
{
__be32 nfserr;
+ int access;
struct svc_fh fh;
/* must initialize before using! but maxsize doesn't matter */
@@ -36,7 +38,9 @@ nlm_fopen(struct svc_rqst *rqstp, struct nfs_fh *f, struct file **filp)
memcpy((char*)&fh.fh_handle.fh_base, f->data, f->size);
fh.fh_export = NULL;
- nfserr = nfsd_open(rqstp, &fh, S_IFREG, NFSD_MAY_LOCK, filp);
+ access = (mode == O_WRONLY) ? NFSD_MAY_WRITE : NFSD_MAY_READ;
+ access |= NFSD_MAY_LOCK;
+ nfserr = nfsd_open(rqstp, &fh, S_IFREG, access, filp);
fh_put(&fh);
/* We return nlm error codes as nlm doesn't know
* about nfsd, but nfsd does know about nlm..