diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2013-04-20 01:25:45 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2013-04-20 01:39:42 -0400 |
commit | 92b40e93849e29f9ca661de6442bb66282738bf7 (patch) | |
tree | 3809ff1f036c1ecbdf7fd265046e49fdefe8eb68 | |
parent | 042ad0b398ea4e937e38324dd096bdf9d2c495f7 (diff) |
NFSv4: Use the open stateid if the delegation has the wrong mode
Fix nfs4_select_rw_stateid() so that it chooses the open stateid
(or an all-zero stateid) if the delegation does not match the selected
read/write mode.
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
-rw-r--r-- | fs/nfs/nfs4_fs.h | 1 | ||||
-rw-r--r-- | fs/nfs/nfs4proc.c | 1 | ||||
-rw-r--r-- | fs/nfs/nfs4state.c | 6 |
3 files changed, 7 insertions, 1 deletions
diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h index 7ef19ce6d832..553a83cc4106 100644 --- a/fs/nfs/nfs4_fs.h +++ b/fs/nfs/nfs4_fs.h | |||
@@ -144,6 +144,7 @@ struct nfs4_lock_state { | |||
144 | enum { | 144 | enum { |
145 | LK_STATE_IN_USE, | 145 | LK_STATE_IN_USE, |
146 | NFS_DELEGATED_STATE, /* Current stateid is delegation */ | 146 | NFS_DELEGATED_STATE, /* Current stateid is delegation */ |
147 | NFS_OPEN_STATE, /* OPEN stateid is set */ | ||
147 | NFS_O_RDONLY_STATE, /* OPEN stateid has read-only state */ | 148 | NFS_O_RDONLY_STATE, /* OPEN stateid has read-only state */ |
148 | NFS_O_WRONLY_STATE, /* OPEN stateid has write-only state */ | 149 | NFS_O_WRONLY_STATE, /* OPEN stateid has write-only state */ |
149 | NFS_O_RDWR_STATE, /* OPEN stateid has read/write state */ | 150 | NFS_O_RDWR_STATE, /* OPEN stateid has read/write state */ |
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 282d9fa6994a..39849360f9f6 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c | |||
@@ -978,6 +978,7 @@ static void nfs_set_open_stateid_locked(struct nfs4_state *state, nfs4_stateid * | |||
978 | if (test_bit(NFS_DELEGATED_STATE, &state->flags) == 0) | 978 | if (test_bit(NFS_DELEGATED_STATE, &state->flags) == 0) |
979 | nfs4_stateid_copy(&state->stateid, stateid); | 979 | nfs4_stateid_copy(&state->stateid, stateid); |
980 | nfs4_stateid_copy(&state->open_stateid, stateid); | 980 | nfs4_stateid_copy(&state->open_stateid, stateid); |
981 | set_bit(NFS_OPEN_STATE, &state->flags); | ||
981 | switch (fmode) { | 982 | switch (fmode) { |
982 | case FMODE_READ: | 983 | case FMODE_READ: |
983 | set_bit(NFS_O_RDONLY_STATE, &state->flags); | 984 | set_bit(NFS_O_RDONLY_STATE, &state->flags); |
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c index 1eb17285c99a..b7796950eceb 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c | |||
@@ -1024,12 +1024,16 @@ out: | |||
1024 | 1024 | ||
1025 | static int nfs4_copy_open_stateid(nfs4_stateid *dst, struct nfs4_state *state) | 1025 | static int nfs4_copy_open_stateid(nfs4_stateid *dst, struct nfs4_state *state) |
1026 | { | 1026 | { |
1027 | const nfs4_stateid *src; | ||
1027 | int ret; | 1028 | int ret; |
1028 | int seq; | 1029 | int seq; |
1029 | 1030 | ||
1030 | do { | 1031 | do { |
1032 | src = &zero_stateid; | ||
1031 | seq = read_seqbegin(&state->seqlock); | 1033 | seq = read_seqbegin(&state->seqlock); |
1032 | nfs4_stateid_copy(dst, &state->stateid); | 1034 | if (test_bit(NFS_OPEN_STATE, &state->flags)) |
1035 | src = &state->open_stateid; | ||
1036 | nfs4_stateid_copy(dst, src); | ||
1033 | ret = 0; | 1037 | ret = 0; |
1034 | smp_rmb(); | 1038 | smp_rmb(); |
1035 | if (!list_empty(&state->owner->so_seqid.list)) | 1039 | if (!list_empty(&state->owner->so_seqid.list)) |