Skip to content

Commit

Permalink
NFSv4: Fix clearing of layout segments in layoutreturn
Browse files Browse the repository at this point in the history
[ Upstream commit d72b796 ]

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 <[email protected]>
Reviewed-by: Jeff Layton <[email protected]>
Signed-off-by: Anna Schumaker <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
  • Loading branch information
Trond Myklebust authored and gregkh committed Sep 18, 2024
1 parent 5c605d8 commit f2331b8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
9 changes: 6 additions & 3 deletions fs/nfs/nfs4proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -9873,13 +9873,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:
Expand Down
5 changes: 2 additions & 3 deletions fs/nfs/pnfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit f2331b8

Please sign in to comment.