Skip to content

Commit

Permalink
NFSv4: Don't use the zero stateid with layoutget
Browse files Browse the repository at this point in the history
The NFSv4.1 protocol explicitly forbids us from using the zero stateid
together with layoutget, so when we see that nfs4_select_rw_stateid()
is unable to return a valid delegation, lock or open stateid, then
we should initiate recovery and retry.

Signed-off-by: Trond Myklebust <[email protected]>
  • Loading branch information
Trond Myklebust committed Jul 18, 2019
1 parent 7402a4f commit d9aba2b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
3 changes: 1 addition & 2 deletions fs/nfs/nfs4state.c
Original file line number Diff line number Diff line change
Expand Up @@ -1064,8 +1064,7 @@ int nfs4_select_rw_stateid(struct nfs4_state *state,
* choose to use.
*/
goto out;
nfs4_copy_open_stateid(dst, state);
ret = 0;
ret = nfs4_copy_open_stateid(dst, state) ? 0 : -EAGAIN;
out:
if (nfs_server_capable(state->inode, NFS_CAP_STATEID_NFSV41))
dst->seqid = 0;
Expand Down
14 changes: 11 additions & 3 deletions fs/nfs/pnfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1915,6 +1915,7 @@ pnfs_update_layout(struct inode *ino,
* stateid.
*/
if (test_bit(NFS_LAYOUT_INVALID_STID, &lo->plh_flags)) {
int status;

/*
* The first layoutget for the file. Need to serialize per
Expand All @@ -1934,13 +1935,20 @@ pnfs_update_layout(struct inode *ino,
}

first = true;
if (nfs4_select_rw_stateid(ctx->state,
status = nfs4_select_rw_stateid(ctx->state,
iomode == IOMODE_RW ? FMODE_WRITE : FMODE_READ,
NULL, &stateid, NULL) != 0) {
NULL, &stateid, NULL);
if (status != 0) {
trace_pnfs_update_layout(ino, pos, count,
iomode, lo, lseg,
PNFS_UPDATE_LAYOUT_INVALID_OPEN);
goto out_unlock;
if (status != -EAGAIN)
goto out_unlock;
spin_unlock(&ino->i_lock);
nfs4_schedule_stateid_recovery(server, ctx->state);
pnfs_clear_first_layoutget(lo);
pnfs_put_layout_hdr(lo);
goto lookup_again;
}
} else {
nfs4_stateid_copy(&stateid, &lo->plh_stateid);
Expand Down

0 comments on commit d9aba2b

Please sign in to comment.