Skip to content

Commit

Permalink
pNFS: Handle NFS4ERR_OLD_STATEID on layoutreturn by bumping the state…
Browse files Browse the repository at this point in the history
… seqid

If a LAYOUTRETURN receives a reply of NFS4ERR_OLD_STATEID then assume we've
missed an update, and just bump the stateid.

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
  • Loading branch information
Trond Myklebust authored and Anna Schumaker committed Sep 20, 2019
1 parent 9228395 commit 30cb3ee
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion fs/nfs/nfs4proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -9063,7 +9063,7 @@ static void nfs4_layoutreturn_done(struct rpc_task *task, void *calldata)
server = NFS_SERVER(lrp->args.inode);
switch (task->tk_status) {
case -NFS4ERR_OLD_STATEID:
if (nfs4_layoutreturn_refresh_stateid(&lrp->args.stateid,
if (nfs4_layout_refresh_old_stateid(&lrp->args.stateid,
&lrp->args.range,
lrp->args.inode))
goto out_restart;
Expand Down
18 changes: 14 additions & 4 deletions fs/nfs/pnfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,10 @@ pnfs_clear_lseg_state(struct pnfs_layout_segment *lseg,
}

/*
* Update the seqid of a layout stateid
* Update the seqid of a layout stateid after receiving
* NFS4ERR_OLD_STATEID
*/
bool nfs4_layoutreturn_refresh_stateid(nfs4_stateid *dst,
bool nfs4_layout_refresh_old_stateid(nfs4_stateid *dst,
struct pnfs_layout_range *dst_range,
struct inode *inode)
{
Expand All @@ -377,14 +378,23 @@ bool nfs4_layoutreturn_refresh_stateid(nfs4_stateid *dst,

spin_lock(&inode->i_lock);
lo = NFS_I(inode)->layout;
if (lo && nfs4_stateid_match_other(dst, &lo->plh_stateid)) {
if (lo && pnfs_layout_is_valid(lo) &&
nfs4_stateid_match_other(dst, &lo->plh_stateid)) {
/* Is our call using the most recent seqid? If so, bump it */
if (!nfs4_stateid_is_newer(&lo->plh_stateid, dst)) {
nfs4_stateid_seqid_inc(dst);
ret = true;
goto out;
}
/* Try to update the seqid to the most recent */
err = pnfs_mark_matching_lsegs_return(lo, &head, &range, 0);
if (err != -EBUSY) {
dst->seqid = lo->plh_stateid.seqid;
*dst_range = range;
ret = true;
}
}
out:
spin_unlock(&inode->i_lock);
pnfs_free_lseg_list(&head);
return ret;
Expand Down Expand Up @@ -1475,7 +1485,7 @@ int pnfs_roc_done(struct rpc_task *task, struct inode *inode,
*ret = -NFS4ERR_NOMATCHING_LAYOUT;
return 0;
case -NFS4ERR_OLD_STATEID:
if (!nfs4_layoutreturn_refresh_stateid(&arg->stateid,
if (!nfs4_layout_refresh_old_stateid(&arg->stateid,
&arg->range, inode))
break;
*ret = -NFS4ERR_NOMATCHING_LAYOUT;
Expand Down
4 changes: 2 additions & 2 deletions fs/nfs/pnfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ int pnfs_destroy_layouts_byfsid(struct nfs_client *clp,
bool is_recall);
int pnfs_destroy_layouts_byclid(struct nfs_client *clp,
bool is_recall);
bool nfs4_layoutreturn_refresh_stateid(nfs4_stateid *dst,
bool nfs4_layout_refresh_old_stateid(nfs4_stateid *dst,
struct pnfs_layout_range *dst_range,
struct inode *inode);
void pnfs_put_layout_hdr(struct pnfs_layout_hdr *lo);
Expand Down Expand Up @@ -798,7 +798,7 @@ static inline void nfs4_pnfs_v3_ds_connect_unload(void)
{
}

static inline bool nfs4_layoutreturn_refresh_stateid(nfs4_stateid *dst,
static inline bool nfs4_layout_refresh_old_stateid(nfs4_stateid *dst,
struct pnfs_layout_range *dst_range,
struct inode *inode)
{
Expand Down

0 comments on commit 30cb3ee

Please sign in to comment.