]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
NFSv4: Don't use the zero stateid with layoutget
authorTrond Myklebust <trond.myklebust@hammerspace.com>
Tue, 16 Jul 2019 19:38:28 +0000 (15:38 -0400)
committerTrond Myklebust <trond.myklebust@hammerspace.com>
Thu, 18 Jul 2019 18:43:52 +0000 (14:43 -0400)
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 <trond.myklebust@hammerspace.com>
fs/nfs/nfs4state.c
fs/nfs/pnfs.c

index f32b02c2bc7344f4b1071156d0122306f8b65074..9afd051a487605f8fe043ded2b4e0e25dcfd51bb 100644 (file)
@@ -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;
index 56e423cd8180a4bc754dd1621712c7ddb0cbad6c..5b9145c62fd97770819ae339f037b6e6af9465b3 100644 (file)
@@ -1915,6 +1915,7 @@ lookup_again:
         * stateid.
         */
        if (test_bit(NFS_LAYOUT_INVALID_STID, &lo->plh_flags)) {
+               int status;
 
                /*
                 * The first layoutget for the file. Need to serialize per
@@ -1934,13 +1935,20 @@ lookup_again:
                }
 
                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);