]>
Commit | Line | Data |
---|---|---|
6691e1a9 GKH |
1 | From 0df5dd4aae211edeeeb84f7f84f6d093406d7c22 Mon Sep 17 00:00:00 2001 |
2 | From: Trond Myklebust <Trond.Myklebust@netapp.com> | |
3 | Date: Sun, 11 Apr 2010 16:48:44 -0400 | |
4 | Subject: NFSv4: fix delegated locking | |
5 | ||
6 | From: Trond Myklebust <Trond.Myklebust@netapp.com> | |
7 | ||
8 | commit 0df5dd4aae211edeeeb84f7f84f6d093406d7c22 upstream. | |
9 | ||
10 | Arnaud Giersch reports that NFSv4 locking is broken when we hold a | |
11 | delegation since commit 8e469ebd6dc32cbaf620e134d79f740bf0ebab79 (NFSv4: | |
12 | Don't allow posix locking against servers that don't support it). | |
13 | ||
14 | According to Arnaud, the lock succeeds the first time he opens the file | |
15 | (since we cannot do a delegated open) but then fails after we start using | |
16 | delegated opens. | |
17 | ||
18 | The following patch fixes it by ensuring that locking behaviour is | |
19 | governed by a per-filesystem capability flag that is initially set, but | |
20 | gets cleared if the server ever returns an OPEN without the | |
21 | NFS4_OPEN_RESULT_LOCKTYPE_POSIX flag being set. | |
22 | ||
23 | Reported-by: Arnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr> | |
24 | Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com> | |
25 | Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> | |
26 | ||
27 | --- | |
28 | fs/nfs/client.c | 3 ++- | |
29 | fs/nfs/nfs4proc.c | 4 +++- | |
30 | include/linux/nfs_fs_sb.h | 1 + | |
31 | 3 files changed, 6 insertions(+), 2 deletions(-) | |
32 | ||
33 | --- a/fs/nfs/client.c | |
34 | +++ b/fs/nfs/client.c | |
35 | @@ -1283,7 +1283,8 @@ static int nfs4_init_server(struct nfs_s | |
36 | ||
37 | /* Initialise the client representation from the mount data */ | |
38 | server->flags = data->flags; | |
39 | - server->caps |= NFS_CAP_ATOMIC_OPEN|NFS_CAP_CHANGE_ATTR; | |
40 | + server->caps |= NFS_CAP_ATOMIC_OPEN|NFS_CAP_CHANGE_ATTR| | |
41 | + NFS_CAP_POSIX_LOCK; | |
42 | server->options = data->options; | |
43 | ||
44 | /* Get a client record */ | |
45 | --- a/fs/nfs/nfs4proc.c | |
46 | +++ b/fs/nfs/nfs4proc.c | |
47 | @@ -1439,6 +1439,8 @@ static int _nfs4_proc_open(struct nfs4_o | |
48 | nfs_post_op_update_inode(dir, o_res->dir_attr); | |
49 | } else | |
50 | nfs_refresh_inode(dir, o_res->dir_attr); | |
51 | + if ((o_res->rflags & NFS4_OPEN_RESULT_LOCKTYPE_POSIX) == 0) | |
52 | + server->caps &= ~NFS_CAP_POSIX_LOCK; | |
53 | if(o_res->rflags & NFS4_OPEN_RESULT_CONFIRM) { | |
54 | status = _nfs4_proc_open_confirm(data); | |
55 | if (status != 0) | |
56 | @@ -1573,7 +1575,7 @@ static int _nfs4_do_open(struct inode *d | |
57 | status = PTR_ERR(state); | |
58 | if (IS_ERR(state)) | |
59 | goto err_opendata_put; | |
60 | - if ((opendata->o_res.rflags & NFS4_OPEN_RESULT_LOCKTYPE_POSIX) != 0) | |
61 | + if (server->caps & NFS_CAP_POSIX_LOCK) | |
62 | set_bit(NFS_STATE_POSIX_LOCKS, &state->flags); | |
63 | nfs4_opendata_put(opendata); | |
64 | nfs4_put_state_owner(sp); | |
65 | --- a/include/linux/nfs_fs_sb.h | |
66 | +++ b/include/linux/nfs_fs_sb.h | |
67 | @@ -176,6 +176,7 @@ struct nfs_server { | |
68 | #define NFS_CAP_ATIME (1U << 11) | |
69 | #define NFS_CAP_CTIME (1U << 12) | |
70 | #define NFS_CAP_MTIME (1U << 13) | |
71 | +#define NFS_CAP_POSIX_LOCK (1U << 14) | |
72 | ||
73 | ||
74 | /* maximum number of slots to use */ |