Commit 287bd3e9 authored by Trond Myklebust's avatar Trond Myklebust

pNFS: Add a layoutreturn callback to performa layout-private setup

Add a callback to allow the flexfiles layout driver to initialise the
layout private payload.
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@primarydata.com>
parent 4d796d75
...@@ -1072,6 +1072,7 @@ pnfs_send_layoutreturn(struct pnfs_layout_hdr *lo, const nfs4_stateid *stateid, ...@@ -1072,6 +1072,7 @@ pnfs_send_layoutreturn(struct pnfs_layout_hdr *lo, const nfs4_stateid *stateid,
enum pnfs_iomode iomode, bool sync) enum pnfs_iomode iomode, bool sync)
{ {
struct inode *ino = lo->plh_inode; struct inode *ino = lo->plh_inode;
struct pnfs_layoutdriver_type *ld = NFS_SERVER(ino)->pnfs_curr_ld;
struct nfs4_layoutreturn *lrp; struct nfs4_layoutreturn *lrp;
int status = 0; int status = 0;
...@@ -1089,6 +1090,8 @@ pnfs_send_layoutreturn(struct pnfs_layout_hdr *lo, const nfs4_stateid *stateid, ...@@ -1089,6 +1090,8 @@ pnfs_send_layoutreturn(struct pnfs_layout_hdr *lo, const nfs4_stateid *stateid,
lrp->args.ld_private = &lrp->ld_private; lrp->args.ld_private = &lrp->ld_private;
lrp->clp = NFS_SERVER(ino)->nfs_client; lrp->clp = NFS_SERVER(ino)->nfs_client;
lrp->cred = lo->plh_lc_cred; lrp->cred = lo->plh_lc_cred;
if (ld->prepare_layoutreturn)
ld->prepare_layoutreturn(&lrp->args);
status = nfs4_proc_layoutreturn(lrp, sync); status = nfs4_proc_layoutreturn(lrp, sync);
out: out:
...@@ -1310,9 +1313,15 @@ bool pnfs_roc(struct inode *ino, ...@@ -1310,9 +1313,15 @@ bool pnfs_roc(struct inode *ino,
out_noroc: out_noroc:
spin_unlock(&ino->i_lock); spin_unlock(&ino->i_lock);
pnfs_layoutcommit_inode(ino, true); pnfs_layoutcommit_inode(ino, true);
if (roc) {
struct pnfs_layoutdriver_type *ld = NFS_SERVER(ino)->pnfs_curr_ld;
if (ld->prepare_layoutreturn)
ld->prepare_layoutreturn(args);
return true;
}
if (layoutreturn) if (layoutreturn)
pnfs_send_layoutreturn(lo, &stateid, iomode, true); pnfs_send_layoutreturn(lo, &stateid, iomode, true);
return roc; return false;
} }
void pnfs_roc_release(struct nfs4_layoutreturn_args *args, void pnfs_roc_release(struct nfs4_layoutreturn_args *args,
...@@ -1322,6 +1331,7 @@ void pnfs_roc_release(struct nfs4_layoutreturn_args *args, ...@@ -1322,6 +1331,7 @@ void pnfs_roc_release(struct nfs4_layoutreturn_args *args,
struct pnfs_layout_hdr *lo = args->layout; struct pnfs_layout_hdr *lo = args->layout;
const nfs4_stateid *arg_stateid = NULL; const nfs4_stateid *arg_stateid = NULL;
const nfs4_stateid *res_stateid = NULL; const nfs4_stateid *res_stateid = NULL;
struct nfs4_xdr_opaque_data *ld_private = args->ld_private;
if (ret == 0) { if (ret == 0) {
arg_stateid = &args->stateid; arg_stateid = &args->stateid;
...@@ -1330,6 +1340,8 @@ void pnfs_roc_release(struct nfs4_layoutreturn_args *args, ...@@ -1330,6 +1340,8 @@ void pnfs_roc_release(struct nfs4_layoutreturn_args *args,
} }
pnfs_layoutreturn_free_lsegs(lo, arg_stateid, &args->range, pnfs_layoutreturn_free_lsegs(lo, arg_stateid, &args->range,
res_stateid); res_stateid);
if (ld_private && ld_private->ops && ld_private->ops->free)
ld_private->ops->free(ld_private);
pnfs_put_layout_hdr(lo); pnfs_put_layout_hdr(lo);
trace_nfs4_layoutreturn_on_close(args->inode, 0); trace_nfs4_layoutreturn_on_close(args->inode, 0);
} }
......
...@@ -172,6 +172,7 @@ struct pnfs_layoutdriver_type { ...@@ -172,6 +172,7 @@ struct pnfs_layoutdriver_type {
(struct nfs_server *server, struct pnfs_device *pdev, (struct nfs_server *server, struct pnfs_device *pdev,
gfp_t gfp_flags); gfp_t gfp_flags);
int (*prepare_layoutreturn) (struct nfs4_layoutreturn_args *);
void (*encode_layoutreturn) (struct xdr_stream *xdr, void (*encode_layoutreturn) (struct xdr_stream *xdr,
const struct nfs4_layoutreturn_args *args); const struct nfs4_layoutreturn_args *args);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment