[pnfs] [PATCH 1/5] [SQUASHME] pnfs: refactor pnfs call data out of nfs_{read, write}_data
Benny Halevy
bhalevy at panasas.com
Wed Jun 18 15:55:16 EDT 2008
Separate the generic pnfs call data and file layout-type
sepecific data out of struct nfs_{read,write}_data.
The motivation for doing this is having a common clean up
function for the read, write, and commit calls done paths.
Signed-off-by: Benny Halevy <bhalevy at panasas.com>
---
fs/nfs/nfs4filelayout.c | 66 +++++++++++++++++++++++-----------------------
fs/nfs/nfs4proc.c | 24 ++++++++--------
fs/nfs/pnfs.c | 48 +++++++++++++++++++---------------
fs/nfs/read.c | 8 +++---
fs/nfs/write.c | 10 +++---
include/linux/nfs_xdr.h | 38 +++++++++++++++-----------
6 files changed, 103 insertions(+), 91 deletions(-)
diff --git a/fs/nfs/nfs4filelayout.c b/fs/nfs/nfs4filelayout.c
index b1b6b76..9751006 100644
--- a/fs/nfs/nfs4filelayout.c
+++ b/fs/nfs/nfs4filelayout.c
@@ -208,11 +208,10 @@ static void filelayout_read_call_done(struct rpc_task *task, void *data)
{
struct nfs_read_data *rdata = (struct nfs_read_data *)data;
-
- if (rdata->orig_offset) {
+ if (rdata->fldata.orig_offset) {
dprintk("%s new off %llu orig offset %llu\n",
- __func__, rdata->args.offset, rdata->orig_offset);
- rdata->args.offset = rdata->orig_offset;
+ __func__, rdata->args.offset, rdata->fldata.orig_offset);
+ rdata->args.offset = rdata->fldata.orig_offset;
}
pnfs_callback_ops->nfs_readlist_complete(rdata);
@@ -222,10 +221,10 @@ static void filelayout_write_call_done(struct rpc_task *task, void *data)
{
struct nfs_write_data *wdata = (struct nfs_write_data *)data;
- if (wdata->orig_offset) {
+ if (wdata->fldata.orig_offset) {
dprintk("%s new off %llu orig offset %llu\n",
- __func__, wdata->args.offset, wdata->orig_offset);
- wdata->args.offset = wdata->orig_offset;
+ __func__, wdata->args.offset, wdata->fldata.orig_offset);
+ wdata->args.offset = wdata->fldata.orig_offset;
}
pnfs_callback_ops->nfs_writelist_complete(wdata);
@@ -264,18 +263,18 @@ static int filelayout_read_pagelist(
struct nfs4_pnfs_ds *ds;
int status;
- flseg = LSEG_LD_DATA(data->lseg);
+ flseg = LSEG_LD_DATA(data->pdata.lseg);
/* Retrieve the correct rpc_client for the byte range */
- status = nfs4_pnfs_dserver_get(data->lseg,
+ status = nfs4_pnfs_dserver_get(data->pdata.lseg,
offset,
count,
&dserver);
if (status) {
printk(KERN_ERR "%s: dserver get failed status %d use MDS\n",
__func__, status);
- data->pnfs_client = NFS_CLIENT(inode);
- data->ds_nfs_client = NULL;
+ data->fldata.pnfs_client = NFS_CLIENT(inode);
+ data->fldata.ds_nfs_client = NULL;
data->args.fh = NFS_FH(inode);
status = 0;
} else {
@@ -285,8 +284,8 @@ static int filelayout_read_pagelist(
htonl(ds->ds_ip_addr), ds->r_addr);
/* just try the first data server for the index..*/
- data->pnfs_client = ds->ds_clp->cl_rpcclient;
- data->ds_nfs_client = ds->ds_clp;
+ data->fldata.pnfs_client = ds->ds_clp->cl_rpcclient;
+ data->fldata.ds_nfs_client = ds->ds_clp;
data->args.fh = dserver.fh;
/* Now get the file offset on the dserver
@@ -297,13 +296,14 @@ static int filelayout_read_pagelist(
*/
data->args.offset = filelayout_get_dserver_offset(offset,
flseg);
- data->orig_offset = offset;
+ data->fldata.orig_offset = offset;
}
/* Perform an asynchronous read */
- nfs_initiate_read(data, data->pnfs_client, &filelayout_read_call_ops);
+ nfs_initiate_read(data, data->fldata.pnfs_client,
+ &filelayout_read_call_ops);
- data->pnfs_error = 0;
+ data->pdata.pnfs_error = 0;
return status;
}
@@ -330,7 +330,7 @@ static int filelayout_write_pagelist(
struct nfs_write_data *data)
{
struct inode *inode = PNFS_INODE(layoutid);
- struct nfs4_filelayout_segment *flseg = LSEG_LD_DATA(data->lseg);
+ struct nfs4_filelayout_segment *flseg = LSEG_LD_DATA(data->pdata.lseg);
struct nfs4_pnfs_dserver dserver;
struct nfs4_pnfs_ds *ds;
int status;
@@ -339,7 +339,7 @@ static int filelayout_write_pagelist(
__func__, inode->i_ino, nr_pages, pgbase, count, offset, sync);
/* Retrieve the correct rpc_client for the byte range */
- status = nfs4_pnfs_dserver_get(data->lseg,
+ status = nfs4_pnfs_dserver_get(data->pdata.lseg,
offset,
count,
&dserver);
@@ -347,8 +347,8 @@ static int filelayout_write_pagelist(
if (status) {
printk(KERN_ERR "%s: dserver get failed status %d use MDS\n",
__func__, status);
- data->pnfs_client = NFS_CLIENT(inode);
- data->ds_nfs_client = NULL;
+ data->fldata.pnfs_client = NFS_CLIENT(inode);
+ data->fldata.ds_nfs_client = NULL;
data->args.fh = NFS_FH(inode);
status = 0;
} else {
@@ -360,24 +360,24 @@ static int filelayout_write_pagelist(
htonl(ds->ds_ip_addr), ntohs(ds->ds_port),
ds->r_addr);
- data->pnfs_client = ds->ds_clp->cl_rpcclient;
- data->ds_nfs_client = ds->ds_clp;
+ data->fldata.pnfs_client = ds->ds_clp->cl_rpcclient;
+ data->fldata.ds_nfs_client = ds->ds_clp;
data->args.fh = dserver.fh;
/* Get the file offset on the dserver. Set the write offset to
* this offset and save the original offset.
*/
data->args.offset = filelayout_get_dserver_offset(offset, flseg);
- data->orig_offset = offset;
+ data->fldata.orig_offset = offset;
}
/* Perform an asynchronous write The offset will be reset in the
* call_ops->rpc_call_done() routine
*/
- nfs_initiate_write(data, data->pnfs_client,
+ nfs_initiate_write(data, data->fldata.pnfs_client,
&filelayout_write_call_ops, sync);
- data->pnfs_error = 0;
+ data->pdata.pnfs_error = 0;
return 0;
}
@@ -561,8 +561,8 @@ filelayout_clone_write_data(struct nfs_write_data *old)
nfs_fattr_init(&new->fattr);
new->res.verf = &new->verf;
new->args.context = old->args.context;
- new->call_ops = old->call_ops;
- new->how = old->how;
+ new->pdata.call_ops = old->pdata.call_ops;
+ new->pdata.how = old->pdata.how;
out:
return new;
}
@@ -588,10 +588,10 @@ filelayout_commit(struct pnfs_layout_type *layoutid, int sync,
struct nfs4_pnfs_dev_item *di;
u32 idx1, idx2;
- nfslay = LSEG_LD_DATA(data->lseg);
+ nfslay = LSEG_LD_DATA(data->pdata.lseg);
dprintk("%s data %p pnfs_client %p nfslay %p sync %d\n",
- __func__, data, data->pnfs_client, nfslay, sync);
+ __func__, data, data->fldata.pnfs_client, nfslay, sync);
if (nfslay->commit_through_mds) {
dprintk("%s data %p commit through mds\n", __func__, data);
@@ -615,7 +615,7 @@ filelayout_commit(struct pnfs_layout_type *layoutid, int sync,
file_offset = (loff_t)req->wb_index << PAGE_CACHE_SHIFT;
/* Get dserver for the current page */
- status = nfs4_pnfs_dserver_get(data->lseg,
+ status = nfs4_pnfs_dserver_get(data->pdata.lseg,
file_offset,
req->wb_bytes,
&dserver);
@@ -636,8 +636,8 @@ filelayout_commit(struct pnfs_layout_type *layoutid, int sync,
/* Just try the first multipath data server */
ds = dserver.dev->ds_list[0];
- dsdata->pnfs_client = ds->ds_clp->cl_rpcclient;
- dsdata->ds_nfs_client = ds->ds_clp;
+ dsdata->fldata.pnfs_client = ds->ds_clp->cl_rpcclient;
+ dsdata->fldata.ds_nfs_client = ds->ds_clp;
dsdata->args.fh = dserver.fh;
cbytes = req->wb_bytes;
@@ -662,7 +662,7 @@ filelayout_commit(struct pnfs_layout_type *layoutid, int sync,
print_ds(ds);
/* Send COMMIT to data server */
- nfs_initiate_commit(dsdata, dsdata->pnfs_client, sync);
+ nfs_initiate_commit(dsdata, dsdata->fldata.pnfs_client, sync);
}
/* Release original commit data since it is not used */
nfs_commit_free(data);
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 833971c..ed2c475 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -2950,15 +2950,15 @@ static int pnfs4_read_done(struct rpc_task *task, struct nfs_read_data *data)
dprintk("--> %s\n", __func__);
- if (data->pnfsflags & PNFS_NO_RPC)
+ if (data->pdata.pnfsflags & PNFS_NO_RPC)
return 0;
status = task->tk_status >= 0 ? 0 : task->tk_status;
/* Is this a DS session */
- if (data->ds_nfs_client) {
+ if (data->fldata.ds_nfs_client) {
dprintk("%s DS read\n", __func__);
- session = data->ds_nfs_client->cl_ds_session;
+ session = data->fldata.ds_nfs_client->cl_ds_session;
client = NULL; /* do not update mds lease...*/
}
@@ -2975,7 +2975,7 @@ static int pnfs4_read_done(struct rpc_task *task, struct nfs_read_data *data)
}
/* Only renew lease if this was a read call to MDS */
- if (task->tk_status > 0 && !data->ds_nfs_client)
+ if (task->tk_status > 0 && !data->fldata.ds_nfs_client)
renew_lease(mds_svr, data->timestamp);
dprintk("<-- %s\n", __func__);
@@ -2993,13 +2993,13 @@ static int pnfs4_write_done(struct rpc_task *task, struct nfs_write_data *data)
struct nfs_client *client = mds_svr->nfs_client;
int status = task->tk_status;
- if (data->pnfsflags & PNFS_NO_RPC)
+ if (data->pdata.pnfsflags & PNFS_NO_RPC)
return 0;
/* Is this a DS session */
- if (data->ds_nfs_client) {
+ if (data->fldata.ds_nfs_client) {
dprintk("%s DS write\n", __func__);
- session = data->ds_nfs_client->cl_ds_session;
+ session = data->fldata.ds_nfs_client->cl_ds_session;
client = NULL; /* do not update mds lease...*/
}
@@ -3019,7 +3019,7 @@ static int pnfs4_write_done(struct rpc_task *task, struct nfs_write_data *data)
* DS write: update lastbyte written
*/
if (task->tk_status > 0) {
- if (!data->ds_nfs_client) {
+ if (!data->fldata.ds_nfs_client) {
nfs_post_op_update_inode_force_wcc(data->inode,
data->res.fattr);
renew_lease(mds_svr, data->timestamp);
@@ -3046,13 +3046,13 @@ static int pnfs4_commit_done(struct rpc_task *task, struct nfs_write_data *data)
dprintk("--> %s task->tk_status %d\n", __func__, task->tk_status);
- if (data->pnfsflags & PNFS_NO_RPC)
+ if (data->pdata.pnfsflags & PNFS_NO_RPC)
return 0;
/* Is this a DS session */
- if (data->ds_nfs_client) {
+ if (data->fldata.ds_nfs_client) {
dprintk("%s DS commit\n", __func__);
- session = data->ds_nfs_client->cl_ds_session;
+ session = data->fldata.ds_nfs_client->cl_ds_session;
client = NULL; /* do not update mds lease...*/
}
@@ -3065,7 +3065,7 @@ static int pnfs4_commit_done(struct rpc_task *task, struct nfs_write_data *data)
}
/* Update inode if commit to MDS */
- if (task->tk_status >= 0 && !data->ds_nfs_client)
+ if (task->tk_status >= 0 && !data->fldata.ds_nfs_client)
nfs_refresh_inode(data->inode, data->res.fattr);
dprintk("<-- %s\n", __func__);
return 0;
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index 349e3bd..54377e0 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -1387,13 +1387,15 @@ static int pnfs_use_rpc_code(struct pnfs_layoutdriver_type *ld)
static void
pnfs_writeback_done(struct nfs_write_data *data)
{
+ struct pnfs_call_data *pdata = &data->pdata;
+
dprintk("%s: Begin (status %d)\n", __func__, data->task.tk_status);
/* update last write offset and need layout commit
* for non-files layout types (files layout calls
* pnfs4_write_done for this)
*/
- if ((data->pnfsflags & PNFS_NO_RPC) &&
+ if ((pdata->pnfsflags & PNFS_NO_RPC) &&
data->task.tk_status >= 0 && data->res.count > 0) {
struct nfs_inode *nfsi = NFS_I(data->inode);
@@ -1401,9 +1403,9 @@ pnfs_writeback_done(struct nfs_write_data *data)
pnfs_need_layoutcommit(nfsi, data->args.context);
}
- put_lseg(data->lseg);
- data->call_ops->rpc_call_done(&data->task, data);
- data->call_ops->rpc_release(data);
+ put_lseg(pdata->lseg);
+ pdata->call_ops->rpc_call_done(&data->task, data);
+ pdata->call_ops->rpc_release(data);
}
/*
@@ -1491,8 +1493,8 @@ pnfs_writepages(struct nfs_write_data *wdata, int how)
how,
numpages);
if (!pnfs_use_rpc_code(nfss->pnfs_curr_ld))
- wdata->pnfsflags |= PNFS_NO_RPC;
- wdata->lseg = lseg;
+ wdata->pdata.pnfsflags |= PNFS_NO_RPC;
+ wdata->pdata.lseg = lseg;
status = nfss->pnfs_curr_ld->ld_io_ops->write_pagelist(
nfsi->current_layout,
args->pages,
@@ -1505,7 +1507,7 @@ pnfs_writepages(struct nfs_write_data *wdata, int how)
BUG_ON(status < 0);
if (status)
- wdata->pnfsflags &= ~PNFS_NO_RPC;
+ wdata->pdata.pnfsflags &= ~PNFS_NO_RPC;
out:
dprintk("%s: End Status %d\n", __func__, status);
return status;
@@ -1517,11 +1519,13 @@ out:
static void
pnfs_read_done(struct nfs_read_data *data)
{
+ struct pnfs_call_data *pdata = &data->pdata;
+
dprintk("%s: Begin (status %d)\n", __func__, data->task.tk_status);
- put_lseg(data->lseg);
- data->call_ops->rpc_call_done(&data->task, data);
- data->call_ops->rpc_release(data);
+ put_lseg(pdata->lseg);
+ pdata->call_ops->rpc_call_done(&data->task, data);
+ pdata->call_ops->rpc_release(data);
}
/*
@@ -1569,8 +1573,8 @@ pnfs_readpages(struct nfs_read_data *rdata)
dprintk("%s: Calling layout driver read with %d pages\n",
__func__, numpages);
if (!pnfs_use_rpc_code(nfss->pnfs_curr_ld))
- rdata->pnfsflags |= PNFS_NO_RPC;
- rdata->lseg = lseg;
+ rdata->pdata.pnfsflags |= PNFS_NO_RPC;
+ rdata->pdata.lseg = lseg;
status = nfss->pnfs_curr_ld->ld_io_ops->read_pagelist(
nfsi->current_layout,
args->pages,
@@ -1581,7 +1585,7 @@ pnfs_readpages(struct nfs_read_data *rdata)
rdata);
BUG_ON(status < 0);
if (status)
- rdata->pnfsflags &= ~PNFS_NO_RPC;
+ rdata->pdata.pnfsflags &= ~PNFS_NO_RPC;
out:
dprintk("%s: End Status %d\n", __func__, status);
return status;
@@ -1601,7 +1605,7 @@ int _pnfs_try_to_read_data(struct nfs_read_data *data,
return 1;
} else {
dprintk("%s: Utilizing pNFS I/O\n", __func__);
- data->call_ops = call_ops;
+ data->pdata.call_ops = call_ops;
return pnfs_readpages(data);
}
}
@@ -1687,8 +1691,8 @@ int _pnfs_try_to_write_data(struct nfs_write_data *data,
return 1;
} else {
dprintk("%s: Utilizing pNFS I/O\n", __func__);
- data->call_ops = call_ops;
- data->how = how;
+ data->pdata.call_ops = call_ops;
+ data->pdata.how = how;
return pnfs_writepages(data, how);
}
}
@@ -1704,7 +1708,7 @@ int _pnfs_try_to_commit(struct nfs_write_data *data)
} else {
/* data->call_ops and data->how set in nfs_commit_rpcsetup */
dprintk("%s: Utilizing pNFS I/O\n", __func__);
- status = pnfs_commit(data, data->how);
+ status = pnfs_commit(data, data->pdata.how);
return status;
}
}
@@ -1713,11 +1717,13 @@ int _pnfs_try_to_commit(struct nfs_write_data *data)
static void
pnfs_commit_done(struct nfs_write_data *data)
{
+ struct pnfs_call_data *pdata = &data->pdata;
+
dprintk("%s: Begin (status %d)\n", __func__, data->task.tk_status);
- put_lseg(data->lseg);
- data->call_ops->rpc_call_done(&data->task, data);
- data->call_ops->rpc_release(data);
+ put_lseg(pdata->lseg);
+ pdata->call_ops->rpc_call_done(&data->task, data);
+ pdata->call_ops->rpc_release(data);
}
int
@@ -1767,7 +1773,7 @@ pnfs_commit(struct nfs_write_data *data, int sync)
}
dprintk("%s: Calling layout driver commit\n", __func__);
- data->lseg = lseg;
+ data->pdata.lseg = lseg;
result = nfss->pnfs_curr_ld->ld_io_ops->commit(nfsi->current_layout,
sync, data);
diff --git a/fs/nfs/read.c b/fs/nfs/read.c
index bff0a39..d78c0f9 100644
--- a/fs/nfs/read.c
+++ b/fs/nfs/read.c
@@ -224,7 +224,7 @@ static int nfs_read_rpcsetup(struct nfs_page *req, struct nfs_read_data *data,
ret = pnfs_try_to_read_data(data, call_ops);
if (ret == 0)
- return data->pnfs_error;
+ return data->pdata.pnfs_error;
return nfs_initiate_read(data, NFS_CLIENT(inode), call_ops);
}
@@ -374,7 +374,7 @@ static void nfs_readpage_retry(struct rpc_task *task, struct nfs_read_data *data
struct nfs_readres *resp = &data->res;
#ifdef CONFIG_PNFS
- if (data->pnfsflags & PNFS_NO_RPC)
+ if (data->pdata.pnfsflags & PNFS_NO_RPC)
return;
#endif /* CONFIG_PNFS */
if (resp->eof || resp->count == argp->count)
@@ -435,8 +435,8 @@ int nfs_read_validate(struct rpc_task *task, void *calldata)
struct nfs4_session *session = server->session;
#ifdef CONFIG_PNFS
- if (data->ds_nfs_client)
- session = data->ds_nfs_client->cl_ds_session;
+ if (data->fldata.ds_nfs_client)
+ session = data->fldata.ds_nfs_client->cl_ds_session;
#endif /* CONFIG_PNFS */
return nfs4_setup_sequence(server->nfs_client, session,
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index c124881..ec5c549 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -867,7 +867,7 @@ static int nfs_write_rpcsetup(struct nfs_page *req,
ret = pnfs_try_to_write_data(data, call_ops, how);
if (ret == 0)
- return data->pnfs_error;
+ return data->pdata.pnfs_error;
return nfs_initiate_write(data, NFS_CLIENT(inode), call_ops, how);
}
@@ -1066,8 +1066,8 @@ int nfs_write_validate(struct rpc_task *task, void *calldata)
struct nfs4_session *session = server->session;
#ifdef CONFIG_PNFS
- if (data->ds_nfs_client)
- session = data->ds_nfs_client->cl_ds_session;
+ if (data->fldata.ds_nfs_client)
+ session = data->fldata.ds_nfs_client->cl_ds_session;
#endif /* CONFIG_PNFS */
return nfs4_setup_sequence(server->nfs_client, session,
@@ -1309,8 +1309,8 @@ static int nfs_commit_rpcsetup(struct list_head *head,
nfs_fattr_init(&data->fattr);
data->args.context = first->wb_context; /* used by commit done */
- data->call_ops = &nfs_commit_ops;
- data->how = how;
+ data->pdata.call_ops = &nfs_commit_ops;
+ data->pdata.how = how;
ret = pnfs_try_to_commit(data);
if (ret <= 0)
return ret;
diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h
index cbdd54e..8ace858 100644
--- a/include/linux/nfs_xdr.h
+++ b/include/linux/nfs_xdr.h
@@ -1034,6 +1034,24 @@ struct nfs_page;
#define NFS_PAGEVEC_SIZE (8U)
+#if defined(CONFIG_PNFS)
+/* pnfs-specific data needed for read, write, and commit calls */
+struct pnfs_call_data {
+ struct pnfs_layout_segment *lseg;
+ const struct rpc_call_ops *call_ops;
+ int pnfsflags;
+ int pnfs_error;
+ int how; /* for FLUSH_STABLE */
+};
+
+/* files layout-type specific data for read, write, and commit */
+struct pnfs_fl_call_data {
+ struct rpc_clnt *pnfs_client; /* Holds pNFS device across async calls */
+ struct nfs_client *ds_nfs_client;
+ __u64 orig_offset;
+};
+#endif /* CONFIG_PNFS */
+
struct nfs_read_data {
int flags;
struct rpc_task task;
@@ -1050,13 +1068,8 @@ struct nfs_read_data {
unsigned long timestamp; /* For lease renewal */
#endif
#if defined(CONFIG_PNFS)
- struct pnfs_layout_segment *lseg;
- const struct rpc_call_ops *call_ops;
- struct rpc_clnt *pnfs_client; /* Holds pNFS device across async calls */
- int pnfsflags;
- int pnfs_error;
- __u64 orig_offset;
- struct nfs_client *ds_nfs_client;
+ struct pnfs_call_data pdata;
+ struct pnfs_fl_call_data fldata;
#endif /* CONFIG_PNFS */
struct page *page_array[NFS_PAGEVEC_SIZE];
};
@@ -1083,15 +1096,8 @@ struct nfs_write_data {
unsigned long timestamp; /* For lease renewal */
#endif
#if defined(CONFIG_PNFS)
- struct pnfs_layout_segment *lseg;
- const struct rpc_call_ops *call_ops;
- struct rpc_clnt *pnfs_client; /* Holds pNFS device across
- async calls */
- int pnfsflags;
- int pnfs_error;
- __u64 orig_offset;
- int how; /* for FLUSH_STABLE */
- struct nfs_client *ds_nfs_client;
+ struct pnfs_call_data pdata;
+ struct pnfs_fl_call_data fldata;
#endif /* CONFIG_PNFS */
struct page *page_array[NFS_PAGEVEC_SIZE];
};
--
1.5.3.3
More information about the pNFS
mailing list