summaryrefslogtreecommitdiff
path: root/fs/nfs/pnfs.c
diff options
context:
space:
mode:
authorTrond Myklebust <trond.myklebust@hammerspace.com>2024-06-13 01:00:50 -0400
committerAnna Schumaker <Anna.Schumaker@Netapp.com>2024-07-08 13:47:26 -0400
commit6e7be9e7b71e38d5965f0a52323316e4e8202b40 (patch)
tree370014c47b6229dcb5fe89b6e7a3cb3d7e420fd9 /fs/nfs/pnfs.c
parent41d0a8ead97209c0e3e1f64e6484c31a98e31154 (diff)
downloadlinux-6e7be9e7b71e38d5965f0a52323316e4e8202b40.tar.gz
linux-6e7be9e7b71e38d5965f0a52323316e4e8202b40.tar.bz2
linux-6e7be9e7b71e38d5965f0a52323316e4e8202b40.zip
NFSv4/pNFS: Add a helper to defer failed layoutreturn calls
If the layoutreturn-on-close fails due to an RPC layer problem, such as a timeout, then we want to retry at a later time. Add a helper function to allow this. 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>
Diffstat (limited to 'fs/nfs/pnfs.c')
-rw-r--r--fs/nfs/pnfs.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index 3bfc74841831..a79ae47b3842 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -1171,6 +1171,26 @@ static void pnfs_clear_layoutcommit(struct inode *inode,
}
}
+static void
+pnfs_layoutreturn_retry_later_locked(struct pnfs_layout_hdr *lo,
+ const nfs4_stateid *arg_stateid,
+ const struct pnfs_layout_range *range)
+{
+ const struct pnfs_layout_segment *lseg;
+ u32 seq = be32_to_cpu(arg_stateid->seqid);
+
+ if (pnfs_layout_is_valid(lo) &&
+ nfs4_stateid_match_other(&lo->plh_stateid, arg_stateid)) {
+ list_for_each_entry(lseg, &lo->plh_return_segs, pls_list) {
+ if (pnfs_seqid_is_newer(lseg->pls_seq, seq) ||
+ !pnfs_should_free_range(&lseg->pls_range, range))
+ continue;
+ pnfs_set_plh_return_info(lo, range->iomode, seq);
+ break;
+ }
+ }
+}
+
void pnfs_layoutreturn_free_lsegs(struct pnfs_layout_hdr *lo,
const nfs4_stateid *arg_stateid,
const struct pnfs_layout_range *range,
@@ -1577,9 +1597,8 @@ void pnfs_roc_release(struct nfs4_layoutreturn_args *args,
switch (ret) {
case -NFS4ERR_NOMATCHING_LAYOUT:
spin_lock(&inode->i_lock);
- if (pnfs_layout_is_valid(lo) &&
- nfs4_stateid_match_other(&args->stateid, &lo->plh_stateid))
- pnfs_set_plh_return_info(lo, args->range.iomode, 0);
+ pnfs_layoutreturn_retry_later_locked(lo, &args->stateid,
+ &args->range);
pnfs_clear_layoutreturn_waitbit(lo);
spin_unlock(&inode->i_lock);
break;