Commit 92b40e93 authored by Trond Myklebust's avatar Trond Myklebust

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: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent 042ad0b3
...@@ -144,6 +144,7 @@ struct nfs4_lock_state { ...@@ -144,6 +144,7 @@ struct nfs4_lock_state {
enum { enum {
LK_STATE_IN_USE, LK_STATE_IN_USE,
NFS_DELEGATED_STATE, /* Current stateid is delegation */ NFS_DELEGATED_STATE, /* Current stateid is delegation */
NFS_OPEN_STATE, /* OPEN stateid is set */
NFS_O_RDONLY_STATE, /* OPEN stateid has read-only state */ NFS_O_RDONLY_STATE, /* OPEN stateid has read-only state */
NFS_O_WRONLY_STATE, /* OPEN stateid has write-only state */ NFS_O_WRONLY_STATE, /* OPEN stateid has write-only state */
NFS_O_RDWR_STATE, /* OPEN stateid has read/write state */ NFS_O_RDWR_STATE, /* OPEN stateid has read/write state */
......
...@@ -978,6 +978,7 @@ static void nfs_set_open_stateid_locked(struct nfs4_state *state, nfs4_stateid * ...@@ -978,6 +978,7 @@ static void nfs_set_open_stateid_locked(struct nfs4_state *state, nfs4_stateid *
if (test_bit(NFS_DELEGATED_STATE, &state->flags) == 0) if (test_bit(NFS_DELEGATED_STATE, &state->flags) == 0)
nfs4_stateid_copy(&state->stateid, stateid); nfs4_stateid_copy(&state->stateid, stateid);
nfs4_stateid_copy(&state->open_stateid, stateid); nfs4_stateid_copy(&state->open_stateid, stateid);
set_bit(NFS_OPEN_STATE, &state->flags);
switch (fmode) { switch (fmode) {
case FMODE_READ: case FMODE_READ:
set_bit(NFS_O_RDONLY_STATE, &state->flags); set_bit(NFS_O_RDONLY_STATE, &state->flags);
......
...@@ -1024,12 +1024,16 @@ static int nfs4_copy_lock_stateid(nfs4_stateid *dst, ...@@ -1024,12 +1024,16 @@ static int nfs4_copy_lock_stateid(nfs4_stateid *dst,
static int nfs4_copy_open_stateid(nfs4_stateid *dst, struct nfs4_state *state) static int nfs4_copy_open_stateid(nfs4_stateid *dst, struct nfs4_state *state)
{ {
const nfs4_stateid *src;
int ret; int ret;
int seq; int seq;
do { do {
src = &zero_stateid;
seq = read_seqbegin(&state->seqlock); seq = read_seqbegin(&state->seqlock);
nfs4_stateid_copy(dst, &state->stateid); if (test_bit(NFS_OPEN_STATE, &state->flags))
src = &state->open_stateid;
nfs4_stateid_copy(dst, src);
ret = 0; ret = 0;
smp_rmb(); smp_rmb();
if (!list_empty(&state->owner->so_seqid.list)) if (!list_empty(&state->owner->so_seqid.list))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment