If the client is doing an operation that needs a particular open
mode, then nfs4_select_rw_stateid() should only copy the
open stateid if the latter has the correct open mode.
Otherwise we should just use the zero stateid.
Reported-by: Miklos Szeredi <miklos@szeredi.hu>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
{
if (nfs4_copy_delegation_stateid(dst, state->inode, fmode))
return;
+
+ fmode &= FMODE_READ|FMODE_WRITE;
+ if ((state->state & fmode) != fmode) {
+ nfs4_stateid_copy(dst, &zero_stateid);
+ return;
+ }
+
if (nfs4_copy_lock_stateid(dst, state, fl_owner, fl_pid))
return;
nfs4_copy_open_stateid(dst, state);