diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2010-04-11 16:48:44 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-04-26 10:47:53 -0400 |
commit | 9c84e4813a02a219d61f61967d7058f2d8037d88 (patch) | |
tree | 2d9d9aa2a465e30cda0fa984117bbe60004de705 /fs/nfs | |
parent | a354226edbcd28cd1a55d0abbbbc9a703ba26f1c (diff) |
NFSv4: fix delegated locking
commit 0df5dd4aae211edeeeb84f7f84f6d093406d7c22 upstream.
Arnaud Giersch reports that NFSv4 locking is broken when we hold a
delegation since commit 8e469ebd6dc32cbaf620e134d79f740bf0ebab79 (NFSv4:
Don't allow posix locking against servers that don't support it).
According to Arnaud, the lock succeeds the first time he opens the file
(since we cannot do a delegated open) but then fails after we start using
delegated opens.
The following patch fixes it by ensuring that locking behaviour is
governed by a per-filesystem capability flag that is initially set, but
gets cleared if the server ever returns an OPEN without the
NFS4_OPEN_RESULT_LOCKTYPE_POSIX flag being set.
Reported-by: Arnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'fs/nfs')
-rw-r--r-- | fs/nfs/client.c | 3 | ||||
-rw-r--r-- | fs/nfs/nfs4proc.c | 4 |
2 files changed, 5 insertions, 2 deletions
diff --git a/fs/nfs/client.c b/fs/nfs/client.c index ee77713ce68b..bd39abc51508 100644 --- a/fs/nfs/client.c +++ b/fs/nfs/client.c | |||
@@ -1293,7 +1293,8 @@ static int nfs4_init_server(struct nfs_server *server, | |||
1293 | 1293 | ||
1294 | /* Initialise the client representation from the mount data */ | 1294 | /* Initialise the client representation from the mount data */ |
1295 | server->flags = data->flags; | 1295 | server->flags = data->flags; |
1296 | server->caps |= NFS_CAP_ATOMIC_OPEN|NFS_CAP_CHANGE_ATTR; | 1296 | server->caps |= NFS_CAP_ATOMIC_OPEN|NFS_CAP_CHANGE_ATTR| |
1297 | NFS_CAP_POSIX_LOCK; | ||
1297 | server->options = data->options; | 1298 | server->options = data->options; |
1298 | 1299 | ||
1299 | /* Get a client record */ | 1300 | /* Get a client record */ |
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 375f0fae2c6a..ecf660204755 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c | |||
@@ -1520,6 +1520,8 @@ static int _nfs4_proc_open(struct nfs4_opendata *data) | |||
1520 | nfs_post_op_update_inode(dir, o_res->dir_attr); | 1520 | nfs_post_op_update_inode(dir, o_res->dir_attr); |
1521 | } else | 1521 | } else |
1522 | nfs_refresh_inode(dir, o_res->dir_attr); | 1522 | nfs_refresh_inode(dir, o_res->dir_attr); |
1523 | if ((o_res->rflags & NFS4_OPEN_RESULT_LOCKTYPE_POSIX) == 0) | ||
1524 | server->caps &= ~NFS_CAP_POSIX_LOCK; | ||
1523 | if(o_res->rflags & NFS4_OPEN_RESULT_CONFIRM) { | 1525 | if(o_res->rflags & NFS4_OPEN_RESULT_CONFIRM) { |
1524 | status = _nfs4_proc_open_confirm(data); | 1526 | status = _nfs4_proc_open_confirm(data); |
1525 | if (status != 0) | 1527 | if (status != 0) |
@@ -1660,7 +1662,7 @@ static int _nfs4_do_open(struct inode *dir, struct path *path, fmode_t fmode, in | |||
1660 | status = PTR_ERR(state); | 1662 | status = PTR_ERR(state); |
1661 | if (IS_ERR(state)) | 1663 | if (IS_ERR(state)) |
1662 | goto err_opendata_put; | 1664 | goto err_opendata_put; |
1663 | if ((opendata->o_res.rflags & NFS4_OPEN_RESULT_LOCKTYPE_POSIX) != 0) | 1665 | if (server->caps & NFS_CAP_POSIX_LOCK) |
1664 | set_bit(NFS_STATE_POSIX_LOCKS, &state->flags); | 1666 | set_bit(NFS_STATE_POSIX_LOCKS, &state->flags); |
1665 | nfs4_opendata_put(opendata); | 1667 | nfs4_opendata_put(opendata); |
1666 | nfs4_put_state_owner(sp); | 1668 | nfs4_put_state_owner(sp); |