]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
NFSv4: Fix clearing of layout segments in layoutreturn
authorTrond Myklebust <trond.myklebust@hammerspace.com>
Wed, 21 Aug 2024 18:05:01 +0000 (14:05 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 Sep 2024 17:24:06 +0000 (19:24 +0200)
[ Upstream commit d72b7963115bea971a28eaa2cb76722c023f9fdf ]

Make sure that we clear the layout segments in cases where we see a
fatal error, and also in the case where the layout is invalid.

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/nfs/nfs4proc.c
fs/nfs/pnfs.c

index e7ac249df1ad6cdc9f96df04a21ea8fe513a83cb..299ea2b86df668c0fe17ac0ea5438d6b4d5bab72 100644 (file)
@@ -9845,13 +9845,16 @@ static void nfs4_layoutreturn_done(struct rpc_task *task, void *calldata)
                fallthrough;
        default:
                task->tk_status = 0;
+               lrp->res.lrs_present = 0;
                fallthrough;
        case 0:
                break;
        case -NFS4ERR_DELAY:
-               if (nfs4_async_handle_error(task, server, NULL, NULL) != -EAGAIN)
-                       break;
-               goto out_restart;
+               if (nfs4_async_handle_error(task, server, NULL, NULL) ==
+                   -EAGAIN)
+                       goto out_restart;
+               lrp->res.lrs_present = 0;
+               break;
        }
        return;
 out_restart:
index 664d3128e730c0cb90e6d7f3650b0244dd2f796d..3d1a9f8634a999b1809fa4252c633249b258d58c 100644 (file)
@@ -1172,10 +1172,9 @@ void pnfs_layoutreturn_free_lsegs(struct pnfs_layout_hdr *lo,
        LIST_HEAD(freeme);
 
        spin_lock(&inode->i_lock);
-       if (!pnfs_layout_is_valid(lo) ||
-           !nfs4_stateid_match_other(&lo->plh_stateid, arg_stateid))
+       if (!nfs4_stateid_match_other(&lo->plh_stateid, arg_stateid))
                goto out_unlock;
-       if (stateid) {
+       if (stateid && pnfs_layout_is_valid(lo)) {
                u32 seq = be32_to_cpu(arg_stateid->seqid);
 
                pnfs_mark_matching_lsegs_invalid(lo, &freeme, range, seq);