Skip to content

Commit

Permalink
nfs41: allow async version layoutreturn
Browse files Browse the repository at this point in the history
Signed-off-by: Peng Tao <tao.peng@primarydata.com>
Signed-off-by: Tom Haynes <loghyr@primarydata.com>
  • Loading branch information
Peng Tao authored and Tom Haynes committed Feb 3, 2015
1 parent 15eb67c commit 6c16605
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
11 changes: 9 additions & 2 deletions fs/nfs/nfs4proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -7810,7 +7810,7 @@ static const struct rpc_call_ops nfs4_layoutreturn_call_ops = {
.rpc_release = nfs4_layoutreturn_release,
};

int nfs4_proc_layoutreturn(struct nfs4_layoutreturn *lrp)
int nfs4_proc_layoutreturn(struct nfs4_layoutreturn *lrp, bool sync)
{
struct rpc_task *task;
struct rpc_message msg = {
Expand All @@ -7824,16 +7824,23 @@ int nfs4_proc_layoutreturn(struct nfs4_layoutreturn *lrp)
.rpc_message = &msg,
.callback_ops = &nfs4_layoutreturn_call_ops,
.callback_data = lrp,
.flags = RPC_TASK_ASYNC,
};
int status;
int status = 0;

dprintk("--> %s\n", __func__);
nfs4_init_sequence(&lrp->args.seq_args, &lrp->res.seq_res, 1);
task = rpc_run_task(&task_setup_data);
if (IS_ERR(task))
return PTR_ERR(task);
if (sync == false)
goto out;
status = nfs4_wait_for_completion_rpc_task(task);
if (status != 0)
goto out;
status = task->tk_status;
trace_nfs4_layoutreturn(lrp->args.inode, status);
out:
dprintk("<-- %s status=%d\n", __func__, status);
rpc_put_task(task);
return status;
Expand Down
11 changes: 6 additions & 5 deletions fs/nfs/pnfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ static LIST_HEAD(pnfs_modules_tbl);

static int
pnfs_send_layoutreturn(struct pnfs_layout_hdr *lo, nfs4_stateid stateid,
enum pnfs_iomode iomode);
enum pnfs_iomode iomode, bool sync);

/* Return the registered pnfs layout driver module matching given id */
static struct pnfs_layoutdriver_type *
Expand Down Expand Up @@ -392,7 +392,8 @@ pnfs_put_lseg(struct pnfs_layout_segment *lseg)
spin_unlock(&inode->i_lock);
pnfs_free_lseg(lseg);
if (need_return)
pnfs_send_layoutreturn(lo, stateid, iomode);
pnfs_send_layoutreturn(lo, stateid, iomode,
true);
else
pnfs_put_layout_hdr(lo);
}
Expand Down Expand Up @@ -897,7 +898,7 @@ 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)
enum pnfs_iomode iomode, bool sync)
{
struct inode *ino = lo->plh_inode;
struct nfs4_layoutreturn *lrp;
Expand All @@ -923,7 +924,7 @@ pnfs_send_layoutreturn(struct pnfs_layout_hdr *lo, nfs4_stateid stateid,
lrp->clp = NFS_SERVER(ino)->nfs_client;
lrp->cred = lo->plh_lc_cred;

status = nfs4_proc_layoutreturn(lrp);
status = nfs4_proc_layoutreturn(lrp, sync);
out:
if (status) {
spin_lock(&ino->i_lock);
Expand Down Expand Up @@ -989,7 +990,7 @@ _pnfs_return_layout(struct inode *ino)
spin_unlock(&ino->i_lock);
pnfs_free_lseg_list(&tmp_list);

status = pnfs_send_layoutreturn(lo, stateid, IOMODE_ANY);
status = pnfs_send_layoutreturn(lo, stateid, IOMODE_ANY, true);
out:
dprintk("<-- %s status: %d\n", __func__, status);
return status;
Expand Down
2 changes: 1 addition & 1 deletion fs/nfs/pnfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ extern int nfs4_proc_getdeviceinfo(struct nfs_server *server,
struct pnfs_device *dev,
struct rpc_cred *cred);
extern struct pnfs_layout_segment* nfs4_proc_layoutget(struct nfs4_layoutget *lgp, gfp_t gfp_flags);
extern int nfs4_proc_layoutreturn(struct nfs4_layoutreturn *lrp);
extern int nfs4_proc_layoutreturn(struct nfs4_layoutreturn *lrp, bool sync);

/* pnfs.c */
void pnfs_get_layout_hdr(struct pnfs_layout_hdr *lo);
Expand Down

0 comments on commit 6c16605

Please sign in to comment.