aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2010-01-26 15:42:30 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2010-01-26 15:42:30 -0500
commit8e469ebd6dc32cbaf620e134d79f740bf0ebab79 (patch)
treea83e806a7cfa0a57ba6e55aef6da027aa2f08fee /fs/nfs
parent2bee72a6aa1e6d0a4f5da56217f0d0bbbdd0d9a3 (diff)
NFSv4: Don't allow posix locking against servers that don't support it
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com> Cc: stable@kernel.org Reviewed-by: Chuck Lever <chuck.lever@oracle.com>
Diffstat (limited to 'fs/nfs')
-rw-r--r--fs/nfs/nfs4_fs.h1
-rw-r--r--fs/nfs/nfs4proc.c7
2 files changed, 7 insertions, 1 deletions
diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h
index 865265bdca03..ea2f41b26aea 100644
--- a/fs/nfs/nfs4_fs.h
+++ b/fs/nfs/nfs4_fs.h
@@ -146,6 +146,7 @@ enum {
146 NFS_O_RDWR_STATE, /* OPEN stateid has read/write state */ 146 NFS_O_RDWR_STATE, /* OPEN stateid has read/write state */
147 NFS_STATE_RECLAIM_REBOOT, /* OPEN stateid server rebooted */ 147 NFS_STATE_RECLAIM_REBOOT, /* OPEN stateid server rebooted */
148 NFS_STATE_RECLAIM_NOGRACE, /* OPEN stateid needs to recover state */ 148 NFS_STATE_RECLAIM_NOGRACE, /* OPEN stateid needs to recover state */
149 NFS_STATE_POSIX_LOCKS, /* Posix locks are supported */
149}; 150};
150 151
151struct nfs4_state { 152struct nfs4_state {
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 0b68238ed0c8..be044b58e811 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -1658,6 +1658,8 @@ static int _nfs4_do_open(struct inode *dir, struct path *path, fmode_t fmode, in
1658 status = PTR_ERR(state); 1658 status = PTR_ERR(state);
1659 if (IS_ERR(state)) 1659 if (IS_ERR(state))
1660 goto err_opendata_put; 1660 goto err_opendata_put;
1661 if ((opendata->o_res.rflags & NFS4_OPEN_RESULT_LOCKTYPE_POSIX) != 0)
1662 set_bit(NFS_STATE_POSIX_LOCKS, &state->flags);
1661 nfs4_opendata_put(opendata); 1663 nfs4_opendata_put(opendata);
1662 nfs4_put_state_owner(sp); 1664 nfs4_put_state_owner(sp);
1663 *res = state; 1665 *res = state;
@@ -4200,8 +4202,11 @@ static int _nfs4_proc_setlk(struct nfs4_state *state, int cmd, struct file_lock
4200{ 4202{
4201 struct nfs_inode *nfsi = NFS_I(state->inode); 4203 struct nfs_inode *nfsi = NFS_I(state->inode);
4202 unsigned char fl_flags = request->fl_flags; 4204 unsigned char fl_flags = request->fl_flags;
4203 int status; 4205 int status = -ENOLCK;
4204 4206
4207 if ((fl_flags & FL_POSIX) &&
4208 !test_bit(NFS_STATE_POSIX_LOCKS, &state->flags))
4209 goto out;
4205 /* Is this a delegated open? */ 4210 /* Is this a delegated open? */
4206 status = nfs4_set_lock_state(state, request); 4211 status = nfs4_set_lock_state(state, request);
4207 if (status != 0) 4212 if (status != 0)