Skip to content

Commit

Permalink
NFS: Create a common read and write data struct
Browse files Browse the repository at this point in the history
At this point, the only difference between nfs_read_data and
nfs_write_data is the write verifier.

Signed-off-by: Anna Schumaker <[email protected]>
Signed-off-by: Trond Myklebust <[email protected]>
  • Loading branch information
amschuma-ntap authored and trondmypd committed May 28, 2014
1 parent 9137bdf commit 9c7e1b3
Show file tree
Hide file tree
Showing 17 changed files with 150 additions and 164 deletions.
22 changes: 11 additions & 11 deletions fs/nfs/blocklayout/blocklayout.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ static void bl_end_io_read(struct bio *bio, int err)
SetPageUptodate(bvec->bv_page);

if (err) {
struct nfs_read_data *rdata = par->data;
struct nfs_pgio_data *rdata = par->data;
struct nfs_pgio_header *header = rdata->header;

if (!header->pnfs_error)
Expand All @@ -224,25 +224,25 @@ static void bl_end_io_read(struct bio *bio, int err)
static void bl_read_cleanup(struct work_struct *work)
{
struct rpc_task *task;
struct nfs_read_data *rdata;
struct nfs_pgio_data *rdata;
dprintk("%s enter\n", __func__);
task = container_of(work, struct rpc_task, u.tk_work);
rdata = container_of(task, struct nfs_read_data, task);
rdata = container_of(task, struct nfs_pgio_data, task);
pnfs_ld_read_done(rdata);
}

static void
bl_end_par_io_read(void *data, int unused)
{
struct nfs_read_data *rdata = data;
struct nfs_pgio_data *rdata = data;

rdata->task.tk_status = rdata->header->pnfs_error;
INIT_WORK(&rdata->task.u.tk_work, bl_read_cleanup);
schedule_work(&rdata->task.u.tk_work);
}

static enum pnfs_try_status
bl_read_pagelist(struct nfs_read_data *rdata)
bl_read_pagelist(struct nfs_pgio_data *rdata)
{
struct nfs_pgio_header *header = rdata->header;
int i, hole;
Expand Down Expand Up @@ -390,7 +390,7 @@ static void bl_end_io_write_zero(struct bio *bio, int err)
}

if (unlikely(err)) {
struct nfs_write_data *data = par->data;
struct nfs_pgio_data *data = par->data;
struct nfs_pgio_header *header = data->header;

if (!header->pnfs_error)
Expand All @@ -405,7 +405,7 @@ static void bl_end_io_write(struct bio *bio, int err)
{
struct parallel_io *par = bio->bi_private;
const int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags);
struct nfs_write_data *data = par->data;
struct nfs_pgio_data *data = par->data;
struct nfs_pgio_header *header = data->header;

if (!uptodate) {
Expand All @@ -423,10 +423,10 @@ static void bl_end_io_write(struct bio *bio, int err)
static void bl_write_cleanup(struct work_struct *work)
{
struct rpc_task *task;
struct nfs_write_data *wdata;
struct nfs_pgio_data *wdata;
dprintk("%s enter\n", __func__);
task = container_of(work, struct rpc_task, u.tk_work);
wdata = container_of(task, struct nfs_write_data, task);
wdata = container_of(task, struct nfs_pgio_data, task);
if (likely(!wdata->header->pnfs_error)) {
/* Marks for LAYOUTCOMMIT */
mark_extents_written(BLK_LSEG2EXT(wdata->header->lseg),
Expand All @@ -438,7 +438,7 @@ static void bl_write_cleanup(struct work_struct *work)
/* Called when last of bios associated with a bl_write_pagelist call finishes */
static void bl_end_par_io_write(void *data, int num_se)
{
struct nfs_write_data *wdata = data;
struct nfs_pgio_data *wdata = data;

if (unlikely(wdata->header->pnfs_error)) {
bl_free_short_extents(&BLK_LSEG2EXT(wdata->header->lseg)->bl_inval,
Expand Down Expand Up @@ -673,7 +673,7 @@ bl_find_get_zeroing_page(struct inode *inode, pgoff_t index,
}

static enum pnfs_try_status
bl_write_pagelist(struct nfs_write_data *wdata, int sync)
bl_write_pagelist(struct nfs_pgio_data *wdata, int sync)
{
struct nfs_pgio_header *header = wdata->header;
int i, ret, npg_zero, pg_index, last = 0;
Expand Down
10 changes: 5 additions & 5 deletions fs/nfs/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -401,13 +401,13 @@ extern void nfs_pageio_init_read(struct nfs_pageio_descriptor *pgio,
struct inode *inode, bool force_mds,
const struct nfs_pgio_completion_ops *compl_ops);
extern int nfs_initiate_read(struct rpc_clnt *clnt,
struct nfs_read_data *data,
struct nfs_pgio_data *data,
const struct rpc_call_ops *call_ops, int flags);
extern void nfs_read_prepare(struct rpc_task *task, void *calldata);
extern int nfs_generic_pagein(struct nfs_pageio_descriptor *desc,
struct nfs_pgio_header *hdr);
extern void nfs_pageio_reset_read_mds(struct nfs_pageio_descriptor *pgio);
extern void nfs_readdata_release(struct nfs_read_data *rdata);
extern void nfs_readdata_release(struct nfs_pgio_data *rdata);

/* super.c */
void nfs_clone_super(struct super_block *, struct nfs_mount_info *);
Expand All @@ -429,10 +429,10 @@ extern void nfs_writehdr_free(struct nfs_pgio_header *hdr);
extern int nfs_generic_flush(struct nfs_pageio_descriptor *desc,
struct nfs_pgio_header *hdr);
extern void nfs_pageio_reset_write_mds(struct nfs_pageio_descriptor *pgio);
extern void nfs_writedata_release(struct nfs_write_data *wdata);
extern void nfs_writedata_release(struct nfs_pgio_data *wdata);
extern void nfs_commit_free(struct nfs_commit_data *p);
extern int nfs_initiate_write(struct rpc_clnt *clnt,
struct nfs_write_data *data,
struct nfs_pgio_data *data,
const struct rpc_call_ops *call_ops,
int how, int flags);
extern void nfs_write_prepare(struct rpc_task *task, void *calldata);
Expand Down Expand Up @@ -492,7 +492,7 @@ static inline void nfs_inode_dio_wait(struct inode *inode)
extern ssize_t nfs_dreq_bytes_left(struct nfs_direct_req *dreq);

/* nfs4proc.c */
extern void __nfs4_read_done_cb(struct nfs_read_data *);
extern void __nfs4_read_done_cb(struct nfs_pgio_data *);
extern struct nfs_client *nfs4_init_client(struct nfs_client *clp,
const struct rpc_timeout *timeparms,
const char *ip_addr);
Expand Down
12 changes: 6 additions & 6 deletions fs/nfs/nfs3proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ nfs3_proc_pathconf(struct nfs_server *server, struct nfs_fh *fhandle,
return status;
}

static int nfs3_read_done(struct rpc_task *task, struct nfs_read_data *data)
static int nfs3_read_done(struct rpc_task *task, struct nfs_pgio_data *data)
{
struct inode *inode = data->header->inode;

Expand All @@ -807,18 +807,18 @@ static int nfs3_read_done(struct rpc_task *task, struct nfs_read_data *data)
return 0;
}

static void nfs3_proc_read_setup(struct nfs_read_data *data, struct rpc_message *msg)
static void nfs3_proc_read_setup(struct nfs_pgio_data *data, struct rpc_message *msg)
{
msg->rpc_proc = &nfs3_procedures[NFS3PROC_READ];
}

static int nfs3_proc_read_rpc_prepare(struct rpc_task *task, struct nfs_read_data *data)
static int nfs3_proc_read_rpc_prepare(struct rpc_task *task, struct nfs_pgio_data *data)
{
rpc_call_start(task);
return 0;
}

static int nfs3_write_done(struct rpc_task *task, struct nfs_write_data *data)
static int nfs3_write_done(struct rpc_task *task, struct nfs_pgio_data *data)
{
struct inode *inode = data->header->inode;

Expand All @@ -829,12 +829,12 @@ static int nfs3_write_done(struct rpc_task *task, struct nfs_write_data *data)
return 0;
}

static void nfs3_proc_write_setup(struct nfs_write_data *data, struct rpc_message *msg)
static void nfs3_proc_write_setup(struct nfs_pgio_data *data, struct rpc_message *msg)
{
msg->rpc_proc = &nfs3_procedures[NFS3PROC_WRITE];
}

static int nfs3_proc_write_rpc_prepare(struct rpc_task *task, struct nfs_write_data *data)
static int nfs3_proc_write_rpc_prepare(struct rpc_task *task, struct nfs_pgio_data *data)
{
rpc_call_start(task);
return 0;
Expand Down
4 changes: 2 additions & 2 deletions fs/nfs/nfs4_fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ nfs4_state_protect(struct nfs_client *clp, unsigned long sp4_mode,
*/
static inline void
nfs4_state_protect_write(struct nfs_client *clp, struct rpc_clnt **clntp,
struct rpc_message *msg, struct nfs_write_data *wdata)
struct rpc_message *msg, struct nfs_pgio_data *wdata)
{
if (_nfs4_state_protect(clp, NFS_SP4_MACH_CRED_WRITE, clntp, msg) &&
!test_bit(NFS_SP4_MACH_CRED_COMMIT, &clp->cl_sp4_flags))
Expand Down Expand Up @@ -369,7 +369,7 @@ nfs4_state_protect(struct nfs_client *clp, unsigned long sp4_flags,

static inline void
nfs4_state_protect_write(struct nfs_client *clp, struct rpc_clnt **clntp,
struct rpc_message *msg, struct nfs_write_data *wdata)
struct rpc_message *msg, struct nfs_pgio_data *wdata)
{
}
#endif /* CONFIG_NFS_V4_1 */
Expand Down
34 changes: 17 additions & 17 deletions fs/nfs/nfs4filelayout.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ filelayout_get_dserver_offset(struct pnfs_layout_segment *lseg, loff_t offset)
BUG();
}

static void filelayout_reset_write(struct nfs_write_data *data)
static void filelayout_reset_write(struct nfs_pgio_data *data)
{
struct nfs_pgio_header *hdr = data->header;
struct rpc_task *task = &data->task;
Expand All @@ -105,7 +105,7 @@ static void filelayout_reset_write(struct nfs_write_data *data)
}
}

static void filelayout_reset_read(struct nfs_read_data *data)
static void filelayout_reset_read(struct nfs_pgio_data *data)
{
struct nfs_pgio_header *hdr = data->header;
struct rpc_task *task = &data->task;
Expand Down Expand Up @@ -243,7 +243,7 @@ static int filelayout_async_handle_error(struct rpc_task *task,
/* NFS_PROTO call done callback routines */

static int filelayout_read_done_cb(struct rpc_task *task,
struct nfs_read_data *data)
struct nfs_pgio_data *data)
{
struct nfs_pgio_header *hdr = data->header;
int err;
Expand All @@ -270,7 +270,7 @@ static int filelayout_read_done_cb(struct rpc_task *task,
* rfc5661 is not clear about which credential should be used.
*/
static void
filelayout_set_layoutcommit(struct nfs_write_data *wdata)
filelayout_set_layoutcommit(struct nfs_pgio_data *wdata)
{
struct nfs_pgio_header *hdr = wdata->header;

Expand Down Expand Up @@ -305,7 +305,7 @@ filelayout_reset_to_mds(struct pnfs_layout_segment *lseg)
*/
static void filelayout_read_prepare(struct rpc_task *task, void *data)
{
struct nfs_read_data *rdata = data;
struct nfs_pgio_data *rdata = data;

if (unlikely(test_bit(NFS_CONTEXT_BAD, &rdata->args.context->flags))) {
rpc_exit(task, -EIO);
Expand All @@ -317,7 +317,7 @@ static void filelayout_read_prepare(struct rpc_task *task, void *data)
rpc_exit(task, 0);
return;
}
rdata->read_done_cb = filelayout_read_done_cb;
rdata->pgio_done_cb = filelayout_read_done_cb;

if (nfs41_setup_sequence(rdata->ds_clp->cl_session,
&rdata->args.seq_args,
Expand All @@ -331,7 +331,7 @@ static void filelayout_read_prepare(struct rpc_task *task, void *data)

static void filelayout_read_call_done(struct rpc_task *task, void *data)
{
struct nfs_read_data *rdata = data;
struct nfs_pgio_data *rdata = data;

dprintk("--> %s task->tk_status %d\n", __func__, task->tk_status);

Expand All @@ -347,14 +347,14 @@ static void filelayout_read_call_done(struct rpc_task *task, void *data)

static void filelayout_read_count_stats(struct rpc_task *task, void *data)
{
struct nfs_read_data *rdata = data;
struct nfs_pgio_data *rdata = data;

rpc_count_iostats(task, NFS_SERVER(rdata->header->inode)->client->cl_metrics);
}

static void filelayout_read_release(void *data)
{
struct nfs_read_data *rdata = data;
struct nfs_pgio_data *rdata = data;
struct pnfs_layout_hdr *lo = rdata->header->lseg->pls_layout;

filelayout_fenceme(lo->plh_inode, lo);
Expand All @@ -363,7 +363,7 @@ static void filelayout_read_release(void *data)
}

static int filelayout_write_done_cb(struct rpc_task *task,
struct nfs_write_data *data)
struct nfs_pgio_data *data)
{
struct nfs_pgio_header *hdr = data->header;
int err;
Expand Down Expand Up @@ -419,7 +419,7 @@ static int filelayout_commit_done_cb(struct rpc_task *task,

static void filelayout_write_prepare(struct rpc_task *task, void *data)
{
struct nfs_write_data *wdata = data;
struct nfs_pgio_data *wdata = data;

if (unlikely(test_bit(NFS_CONTEXT_BAD, &wdata->args.context->flags))) {
rpc_exit(task, -EIO);
Expand All @@ -443,7 +443,7 @@ static void filelayout_write_prepare(struct rpc_task *task, void *data)

static void filelayout_write_call_done(struct rpc_task *task, void *data)
{
struct nfs_write_data *wdata = data;
struct nfs_pgio_data *wdata = data;

if (test_bit(NFS_IOHDR_REDO, &wdata->header->flags) &&
task->tk_status == 0) {
Expand All @@ -457,14 +457,14 @@ static void filelayout_write_call_done(struct rpc_task *task, void *data)

static void filelayout_write_count_stats(struct rpc_task *task, void *data)
{
struct nfs_write_data *wdata = data;
struct nfs_pgio_data *wdata = data;

rpc_count_iostats(task, NFS_SERVER(wdata->header->inode)->client->cl_metrics);
}

static void filelayout_write_release(void *data)
{
struct nfs_write_data *wdata = data;
struct nfs_pgio_data *wdata = data;
struct pnfs_layout_hdr *lo = wdata->header->lseg->pls_layout;

filelayout_fenceme(lo->plh_inode, lo);
Expand Down Expand Up @@ -529,7 +529,7 @@ static const struct rpc_call_ops filelayout_commit_call_ops = {
};

static enum pnfs_try_status
filelayout_read_pagelist(struct nfs_read_data *data)
filelayout_read_pagelist(struct nfs_pgio_data *data)
{
struct nfs_pgio_header *hdr = data->header;
struct pnfs_layout_segment *lseg = hdr->lseg;
Expand Down Expand Up @@ -575,7 +575,7 @@ filelayout_read_pagelist(struct nfs_read_data *data)

/* Perform async writes. */
static enum pnfs_try_status
filelayout_write_pagelist(struct nfs_write_data *data, int sync)
filelayout_write_pagelist(struct nfs_pgio_data *data, int sync)
{
struct nfs_pgio_header *hdr = data->header;
struct pnfs_layout_segment *lseg = hdr->lseg;
Expand All @@ -600,7 +600,7 @@ filelayout_write_pagelist(struct nfs_write_data *data, int sync)
__func__, hdr->inode->i_ino, sync, (size_t) data->args.count,
offset, ds->ds_remotestr, atomic_read(&ds->ds_clp->cl_count));

data->write_done_cb = filelayout_write_done_cb;
data->pgio_done_cb = filelayout_write_done_cb;
atomic_inc(&ds->ds_clp->cl_count);
data->ds_clp = ds->ds_clp;
fh = nfs4_fl_select_ds_fh(lseg, j);
Expand Down
Loading

0 comments on commit 9c7e1b3

Please sign in to comment.