Skip to content

Commit 6e7be9e

Browse files
Trond Myklebustamschuma-ntap
authored andcommitted
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 <[email protected]> Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
1 parent 41d0a8e commit 6e7be9e

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

fs/nfs/pnfs.c

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,6 +1171,26 @@ static void pnfs_clear_layoutcommit(struct inode *inode,
11711171
}
11721172
}
11731173

1174+
static void
1175+
pnfs_layoutreturn_retry_later_locked(struct pnfs_layout_hdr *lo,
1176+
const nfs4_stateid *arg_stateid,
1177+
const struct pnfs_layout_range *range)
1178+
{
1179+
const struct pnfs_layout_segment *lseg;
1180+
u32 seq = be32_to_cpu(arg_stateid->seqid);
1181+
1182+
if (pnfs_layout_is_valid(lo) &&
1183+
nfs4_stateid_match_other(&lo->plh_stateid, arg_stateid)) {
1184+
list_for_each_entry(lseg, &lo->plh_return_segs, pls_list) {
1185+
if (pnfs_seqid_is_newer(lseg->pls_seq, seq) ||
1186+
!pnfs_should_free_range(&lseg->pls_range, range))
1187+
continue;
1188+
pnfs_set_plh_return_info(lo, range->iomode, seq);
1189+
break;
1190+
}
1191+
}
1192+
}
1193+
11741194
void pnfs_layoutreturn_free_lsegs(struct pnfs_layout_hdr *lo,
11751195
const nfs4_stateid *arg_stateid,
11761196
const struct pnfs_layout_range *range,
@@ -1577,9 +1597,8 @@ void pnfs_roc_release(struct nfs4_layoutreturn_args *args,
15771597
switch (ret) {
15781598
case -NFS4ERR_NOMATCHING_LAYOUT:
15791599
spin_lock(&inode->i_lock);
1580-
if (pnfs_layout_is_valid(lo) &&
1581-
nfs4_stateid_match_other(&args->stateid, &lo->plh_stateid))
1582-
pnfs_set_plh_return_info(lo, args->range.iomode, 0);
1600+
pnfs_layoutreturn_retry_later_locked(lo, &args->stateid,
1601+
&args->range);
15831602
pnfs_clear_layoutreturn_waitbit(lo);
15841603
spin_unlock(&inode->i_lock);
15851604
break;

0 commit comments

Comments
 (0)