提交 c16467dc 编写于 作者: T Trond Myklebust 提交者: Anna Schumaker

pnfs: Fix handling of NFS4ERR_OLD_STATEID replies to layoutreturn

If the server tells us that out layoutreturn raced with another layout
update, then we must ensure that the new layout segments are not in use
before we resend with an updated layout stateid.
Signed-off-by: NTrond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: NAnna Schumaker <Anna.Schumaker@Netapp.com>
上级 8d4fb8ff
...@@ -3232,7 +3232,7 @@ static void nfs4_close_done(struct rpc_task *task, void *data) ...@@ -3232,7 +3232,7 @@ static void nfs4_close_done(struct rpc_task *task, void *data)
calldata->res.lr_res = NULL; calldata->res.lr_res = NULL;
break; break;
case -NFS4ERR_OLD_STATEID: case -NFS4ERR_OLD_STATEID:
if (nfs4_refresh_layout_stateid(&calldata->arg.lr_args->stateid, if (nfs4_layoutreturn_refresh_stateid(&calldata->arg.lr_args->stateid,
calldata->inode)) calldata->inode))
goto lr_restart; goto lr_restart;
/* Fallthrough */ /* Fallthrough */
...@@ -5914,7 +5914,7 @@ static void nfs4_delegreturn_done(struct rpc_task *task, void *calldata) ...@@ -5914,7 +5914,7 @@ static void nfs4_delegreturn_done(struct rpc_task *task, void *calldata)
data->res.lr_res = NULL; data->res.lr_res = NULL;
break; break;
case -NFS4ERR_OLD_STATEID: case -NFS4ERR_OLD_STATEID:
if (nfs4_refresh_layout_stateid(&data->args.lr_args->stateid, if (nfs4_layoutreturn_refresh_stateid(&data->args.lr_args->stateid,
data->inode)) data->inode))
goto lr_restart; goto lr_restart;
/* Fallthrough */ /* Fallthrough */
...@@ -8863,7 +8863,7 @@ static void nfs4_layoutreturn_done(struct rpc_task *task, void *calldata) ...@@ -8863,7 +8863,7 @@ static void nfs4_layoutreturn_done(struct rpc_task *task, void *calldata)
server = NFS_SERVER(lrp->args.inode); server = NFS_SERVER(lrp->args.inode);
switch (task->tk_status) { switch (task->tk_status) {
case -NFS4ERR_OLD_STATEID: case -NFS4ERR_OLD_STATEID:
if (nfs4_refresh_layout_stateid(&lrp->args.stateid, if (nfs4_layoutreturn_refresh_stateid(&lrp->args.stateid,
lrp->args.inode)) lrp->args.inode))
goto out_restart; goto out_restart;
/* Fallthrough */ /* Fallthrough */
......
...@@ -361,18 +361,29 @@ pnfs_clear_lseg_state(struct pnfs_layout_segment *lseg, ...@@ -361,18 +361,29 @@ pnfs_clear_lseg_state(struct pnfs_layout_segment *lseg,
/* /*
* Update the seqid of a layout stateid * Update the seqid of a layout stateid
*/ */
bool nfs4_refresh_layout_stateid(nfs4_stateid *dst, struct inode *inode) bool nfs4_layoutreturn_refresh_stateid(nfs4_stateid *dst, struct inode *inode)
{ {
struct pnfs_layout_hdr *lo; struct pnfs_layout_hdr *lo;
struct pnfs_layout_range range = {
.iomode = IOMODE_ANY,
.offset = 0,
.length = NFS4_MAX_UINT64,
};
bool ret = false; bool ret = false;
LIST_HEAD(head);
int err;
spin_lock(&inode->i_lock); spin_lock(&inode->i_lock);
lo = NFS_I(inode)->layout; lo = NFS_I(inode)->layout;
if (lo && nfs4_stateid_match_other(dst, &lo->plh_stateid)) { if (lo && nfs4_stateid_match_other(dst, &lo->plh_stateid)) {
dst->seqid = lo->plh_stateid.seqid; err = pnfs_mark_matching_lsegs_return(lo, &head, &range, 0);
ret = true; if (err != -EBUSY) {
dst->seqid = lo->plh_stateid.seqid;
ret = true;
}
} }
spin_unlock(&inode->i_lock); spin_unlock(&inode->i_lock);
pnfs_free_lseg_list(&head);
return ret; return ret;
} }
......
...@@ -259,7 +259,7 @@ int pnfs_destroy_layouts_byfsid(struct nfs_client *clp, ...@@ -259,7 +259,7 @@ int pnfs_destroy_layouts_byfsid(struct nfs_client *clp,
bool is_recall); bool is_recall);
int pnfs_destroy_layouts_byclid(struct nfs_client *clp, int pnfs_destroy_layouts_byclid(struct nfs_client *clp,
bool is_recall); bool is_recall);
bool nfs4_refresh_layout_stateid(nfs4_stateid *dst, struct inode *inode); bool nfs4_layoutreturn_refresh_stateid(nfs4_stateid *dst, struct inode *inode);
void pnfs_put_layout_hdr(struct pnfs_layout_hdr *lo); void pnfs_put_layout_hdr(struct pnfs_layout_hdr *lo);
void pnfs_set_layout_stateid(struct pnfs_layout_hdr *lo, void pnfs_set_layout_stateid(struct pnfs_layout_hdr *lo,
const nfs4_stateid *new, const nfs4_stateid *new,
...@@ -780,7 +780,7 @@ static inline void nfs4_pnfs_v3_ds_connect_unload(void) ...@@ -780,7 +780,7 @@ static inline void nfs4_pnfs_v3_ds_connect_unload(void)
{ {
} }
static inline bool nfs4_refresh_layout_stateid(nfs4_stateid *dst, static inline bool nfs4_layoutreturn_refresh_stateid(nfs4_stateid *dst,
struct inode *inode) struct inode *inode)
{ {
return false; return false;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册