nfs41: make a helper function to send layoutreturn
It allows to specify different iomode to return. Signed-off-by: Peng Tao <tao.peng@primarydata.com> Signed-off-by: Tom Haynes <Thomas.Haynes@primarydata.com>
This commit is contained in:
parent
4579d6b897
commit
f40eb5d044
|
@ -845,6 +845,38 @@ static void pnfs_clear_layoutcommit(struct inode *inode,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
pnfs_send_layoutreturn(struct pnfs_layout_hdr *lo, nfs4_stateid stateid,
|
||||||
|
enum pnfs_iomode iomode)
|
||||||
|
{
|
||||||
|
struct inode *ino = lo->plh_inode;
|
||||||
|
struct nfs4_layoutreturn *lrp;
|
||||||
|
int status = 0;
|
||||||
|
|
||||||
|
lrp = kzalloc(sizeof(*lrp), GFP_KERNEL);
|
||||||
|
if (unlikely(lrp == NULL)) {
|
||||||
|
status = -ENOMEM;
|
||||||
|
spin_lock(&ino->i_lock);
|
||||||
|
lo->plh_block_lgets--;
|
||||||
|
spin_unlock(&ino->i_lock);
|
||||||
|
pnfs_put_layout_hdr(lo);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
lrp->args.stateid = stateid;
|
||||||
|
lrp->args.layout_type = NFS_SERVER(ino)->pnfs_curr_ld->id;
|
||||||
|
lrp->args.inode = ino;
|
||||||
|
lrp->args.iomode = iomode;
|
||||||
|
lrp->args.layout = lo;
|
||||||
|
lrp->clp = NFS_SERVER(ino)->nfs_client;
|
||||||
|
lrp->cred = lo->plh_lc_cred;
|
||||||
|
|
||||||
|
status = nfs4_proc_layoutreturn(lrp);
|
||||||
|
out:
|
||||||
|
dprintk("<-- %s status: %d\n", __func__, status);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initiates a LAYOUTRETURN(FILE), and removes the pnfs_layout_hdr
|
* Initiates a LAYOUTRETURN(FILE), and removes the pnfs_layout_hdr
|
||||||
* when the layout segment list is empty.
|
* when the layout segment list is empty.
|
||||||
|
@ -859,7 +891,6 @@ _pnfs_return_layout(struct inode *ino)
|
||||||
struct pnfs_layout_hdr *lo = NULL;
|
struct pnfs_layout_hdr *lo = NULL;
|
||||||
struct nfs_inode *nfsi = NFS_I(ino);
|
struct nfs_inode *nfsi = NFS_I(ino);
|
||||||
LIST_HEAD(tmp_list);
|
LIST_HEAD(tmp_list);
|
||||||
struct nfs4_layoutreturn *lrp;
|
|
||||||
nfs4_stateid stateid;
|
nfs4_stateid stateid;
|
||||||
int status = 0, empty;
|
int status = 0, empty;
|
||||||
|
|
||||||
|
@ -901,25 +932,7 @@ _pnfs_return_layout(struct inode *ino)
|
||||||
spin_unlock(&ino->i_lock);
|
spin_unlock(&ino->i_lock);
|
||||||
pnfs_free_lseg_list(&tmp_list);
|
pnfs_free_lseg_list(&tmp_list);
|
||||||
|
|
||||||
lrp = kzalloc(sizeof(*lrp), GFP_KERNEL);
|
status = pnfs_send_layoutreturn(lo, stateid, IOMODE_ANY);
|
||||||
if (unlikely(lrp == NULL)) {
|
|
||||||
status = -ENOMEM;
|
|
||||||
spin_lock(&ino->i_lock);
|
|
||||||
lo->plh_block_lgets--;
|
|
||||||
spin_unlock(&ino->i_lock);
|
|
||||||
pnfs_put_layout_hdr(lo);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
lrp->args.stateid = stateid;
|
|
||||||
lrp->args.layout_type = NFS_SERVER(ino)->pnfs_curr_ld->id;
|
|
||||||
lrp->args.inode = ino;
|
|
||||||
lrp->args.iomode = IOMODE_ANY;
|
|
||||||
lrp->args.layout = lo;
|
|
||||||
lrp->clp = NFS_SERVER(ino)->nfs_client;
|
|
||||||
lrp->cred = lo->plh_lc_cred;
|
|
||||||
|
|
||||||
status = nfs4_proc_layoutreturn(lrp);
|
|
||||||
out:
|
out:
|
||||||
dprintk("<-- %s status: %d\n", __func__, status);
|
dprintk("<-- %s status: %d\n", __func__, status);
|
||||||
return status;
|
return status;
|
||||||
|
|
Loading…
Reference in New Issue