Commit a4cdda59 authored by Anna Schumaker's avatar Anna Schumaker Committed by Trond Myklebust

NFS: Create a common pgio_rpc_prepare function

The read and write paths do exactly the same thing for the rpc_prepare
rpc_op.  This patch combines them together into a single function.
Signed-off-by: default avatarAnna Schumaker <Anna.Schumaker@Netapp.com>
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@primarydata.com>
parent 4a0de55c
...@@ -241,6 +241,8 @@ struct nfs_rw_header *nfs_rw_header_alloc(const struct nfs_rw_ops *); ...@@ -241,6 +241,8 @@ struct nfs_rw_header *nfs_rw_header_alloc(const struct nfs_rw_ops *);
void nfs_rw_header_free(struct nfs_pgio_header *); void nfs_rw_header_free(struct nfs_pgio_header *);
struct nfs_pgio_data *nfs_pgio_data_alloc(struct nfs_pgio_header *, unsigned int); struct nfs_pgio_data *nfs_pgio_data_alloc(struct nfs_pgio_header *, unsigned int);
void nfs_pgio_data_release(struct nfs_pgio_data *); void nfs_pgio_data_release(struct nfs_pgio_data *);
void nfs_pgio_prepare(struct rpc_task *, void *);
void nfs_pgio_release(void *);
static inline void nfs_iocounter_init(struct nfs_io_counter *c) static inline void nfs_iocounter_init(struct nfs_io_counter *c)
{ {
......
...@@ -812,7 +812,7 @@ static void nfs3_proc_read_setup(struct nfs_pgio_data *data, struct rpc_message ...@@ -812,7 +812,7 @@ static void nfs3_proc_read_setup(struct nfs_pgio_data *data, struct rpc_message
msg->rpc_proc = &nfs3_procedures[NFS3PROC_READ]; msg->rpc_proc = &nfs3_procedures[NFS3PROC_READ];
} }
static int nfs3_proc_read_rpc_prepare(struct rpc_task *task, struct nfs_pgio_data *data) static int nfs3_proc_pgio_rpc_prepare(struct rpc_task *task, struct nfs_pgio_data *data)
{ {
rpc_call_start(task); rpc_call_start(task);
return 0; return 0;
...@@ -834,12 +834,6 @@ static void nfs3_proc_write_setup(struct nfs_pgio_data *data, struct rpc_message ...@@ -834,12 +834,6 @@ static void nfs3_proc_write_setup(struct nfs_pgio_data *data, struct rpc_message
msg->rpc_proc = &nfs3_procedures[NFS3PROC_WRITE]; msg->rpc_proc = &nfs3_procedures[NFS3PROC_WRITE];
} }
static int nfs3_proc_write_rpc_prepare(struct rpc_task *task, struct nfs_pgio_data *data)
{
rpc_call_start(task);
return 0;
}
static void nfs3_proc_commit_rpc_prepare(struct rpc_task *task, struct nfs_commit_data *data) static void nfs3_proc_commit_rpc_prepare(struct rpc_task *task, struct nfs_commit_data *data)
{ {
rpc_call_start(task); rpc_call_start(task);
...@@ -946,11 +940,10 @@ const struct nfs_rpc_ops nfs_v3_clientops = { ...@@ -946,11 +940,10 @@ const struct nfs_rpc_ops nfs_v3_clientops = {
.fsinfo = nfs3_proc_fsinfo, .fsinfo = nfs3_proc_fsinfo,
.pathconf = nfs3_proc_pathconf, .pathconf = nfs3_proc_pathconf,
.decode_dirent = nfs3_decode_dirent, .decode_dirent = nfs3_decode_dirent,
.pgio_rpc_prepare = nfs3_proc_pgio_rpc_prepare,
.read_setup = nfs3_proc_read_setup, .read_setup = nfs3_proc_read_setup,
.read_rpc_prepare = nfs3_proc_read_rpc_prepare,
.read_done = nfs3_read_done, .read_done = nfs3_read_done,
.write_setup = nfs3_proc_write_setup, .write_setup = nfs3_proc_write_setup,
.write_rpc_prepare = nfs3_proc_write_rpc_prepare,
.write_done = nfs3_write_done, .write_done = nfs3_write_done,
.commit_setup = nfs3_proc_commit_setup, .commit_setup = nfs3_proc_commit_setup,
.commit_rpc_prepare = nfs3_proc_commit_rpc_prepare, .commit_rpc_prepare = nfs3_proc_commit_rpc_prepare,
......
...@@ -4089,7 +4089,7 @@ static void nfs4_proc_read_setup(struct nfs_pgio_data *data, struct rpc_message ...@@ -4089,7 +4089,7 @@ static void nfs4_proc_read_setup(struct nfs_pgio_data *data, struct rpc_message
nfs4_init_sequence(&data->args.seq_args, &data->res.seq_res, 0); nfs4_init_sequence(&data->args.seq_args, &data->res.seq_res, 0);
} }
static int nfs4_proc_read_rpc_prepare(struct rpc_task *task, struct nfs_pgio_data *data) static int nfs4_proc_pgio_rpc_prepare(struct rpc_task *task, struct nfs_pgio_data *data)
{ {
if (nfs4_setup_sequence(NFS_SERVER(data->header->inode), if (nfs4_setup_sequence(NFS_SERVER(data->header->inode),
&data->args.seq_args, &data->args.seq_args,
...@@ -4097,7 +4097,7 @@ static int nfs4_proc_read_rpc_prepare(struct rpc_task *task, struct nfs_pgio_dat ...@@ -4097,7 +4097,7 @@ static int nfs4_proc_read_rpc_prepare(struct rpc_task *task, struct nfs_pgio_dat
task)) task))
return 0; return 0;
if (nfs4_set_rw_stateid(&data->args.stateid, data->args.context, if (nfs4_set_rw_stateid(&data->args.stateid, data->args.context,
data->args.lock_context, FMODE_READ) == -EIO) data->args.lock_context, data->header->rw_ops->rw_mode) == -EIO)
return -EIO; return -EIO;
if (unlikely(test_bit(NFS_CONTEXT_BAD, &data->args.context->flags))) if (unlikely(test_bit(NFS_CONTEXT_BAD, &data->args.context->flags)))
return -EIO; return -EIO;
...@@ -4177,21 +4177,6 @@ static void nfs4_proc_write_setup(struct nfs_pgio_data *data, struct rpc_message ...@@ -4177,21 +4177,6 @@ static void nfs4_proc_write_setup(struct nfs_pgio_data *data, struct rpc_message
nfs4_init_sequence(&data->args.seq_args, &data->res.seq_res, 1); nfs4_init_sequence(&data->args.seq_args, &data->res.seq_res, 1);
} }
static int nfs4_proc_write_rpc_prepare(struct rpc_task *task, struct nfs_pgio_data *data)
{
if (nfs4_setup_sequence(NFS_SERVER(data->header->inode),
&data->args.seq_args,
&data->res.seq_res,
task))
return 0;
if (nfs4_set_rw_stateid(&data->args.stateid, data->args.context,
data->args.lock_context, FMODE_WRITE) == -EIO)
return -EIO;
if (unlikely(test_bit(NFS_CONTEXT_BAD, &data->args.context->flags)))
return -EIO;
return 0;
}
static void nfs4_proc_commit_rpc_prepare(struct rpc_task *task, struct nfs_commit_data *data) static void nfs4_proc_commit_rpc_prepare(struct rpc_task *task, struct nfs_commit_data *data)
{ {
nfs4_setup_sequence(NFS_SERVER(data->inode), nfs4_setup_sequence(NFS_SERVER(data->inode),
...@@ -8432,11 +8417,10 @@ const struct nfs_rpc_ops nfs_v4_clientops = { ...@@ -8432,11 +8417,10 @@ const struct nfs_rpc_ops nfs_v4_clientops = {
.pathconf = nfs4_proc_pathconf, .pathconf = nfs4_proc_pathconf,
.set_capabilities = nfs4_server_capabilities, .set_capabilities = nfs4_server_capabilities,
.decode_dirent = nfs4_decode_dirent, .decode_dirent = nfs4_decode_dirent,
.pgio_rpc_prepare = nfs4_proc_pgio_rpc_prepare,
.read_setup = nfs4_proc_read_setup, .read_setup = nfs4_proc_read_setup,
.read_rpc_prepare = nfs4_proc_read_rpc_prepare,
.read_done = nfs4_read_done, .read_done = nfs4_read_done,
.write_setup = nfs4_proc_write_setup, .write_setup = nfs4_proc_write_setup,
.write_rpc_prepare = nfs4_proc_write_rpc_prepare,
.write_done = nfs4_write_done, .write_done = nfs4_write_done,
.commit_setup = nfs4_proc_commit_setup, .commit_setup = nfs4_proc_commit_setup,
.commit_rpc_prepare = nfs4_proc_commit_rpc_prepare, .commit_rpc_prepare = nfs4_proc_commit_rpc_prepare,
......
...@@ -386,6 +386,32 @@ void nfs_pgio_data_release(struct nfs_pgio_data *data) ...@@ -386,6 +386,32 @@ void nfs_pgio_data_release(struct nfs_pgio_data *data)
} }
EXPORT_SYMBOL_GPL(nfs_pgio_data_release); EXPORT_SYMBOL_GPL(nfs_pgio_data_release);
/**
* nfs_pgio_prepare - Prepare pageio data to go over the wire
* @task: The current task
* @calldata: pageio data to prepare
*/
void nfs_pgio_prepare(struct rpc_task *task, void *calldata)
{
struct nfs_pgio_data *data = calldata;
int err;
err = NFS_PROTO(data->header->inode)->pgio_rpc_prepare(task, data);
if (err)
rpc_exit(task, err);
}
/**
* nfs_pgio_release - Release pageio data
* @calldata: The pageio data to release
*/
void nfs_pgio_release(void *calldata)
{
struct nfs_pgio_data *data = calldata;
if (data->header->rw_ops->rw_release)
data->header->rw_ops->rw_release(data);
nfs_pgio_data_release(data);
}
/** /**
* nfs_pageio_init - initialise a page io descriptor * nfs_pageio_init - initialise a page io descriptor
* @desc: pointer to descriptor * @desc: pointer to descriptor
......
...@@ -599,7 +599,7 @@ static void nfs_proc_read_setup(struct nfs_pgio_data *data, struct rpc_message * ...@@ -599,7 +599,7 @@ static void nfs_proc_read_setup(struct nfs_pgio_data *data, struct rpc_message *
msg->rpc_proc = &nfs_procedures[NFSPROC_READ]; msg->rpc_proc = &nfs_procedures[NFSPROC_READ];
} }
static int nfs_proc_read_rpc_prepare(struct rpc_task *task, struct nfs_pgio_data *data) static int nfs_proc_pgio_rpc_prepare(struct rpc_task *task, struct nfs_pgio_data *data)
{ {
rpc_call_start(task); rpc_call_start(task);
return 0; return 0;
...@@ -621,12 +621,6 @@ static void nfs_proc_write_setup(struct nfs_pgio_data *data, struct rpc_message ...@@ -621,12 +621,6 @@ static void nfs_proc_write_setup(struct nfs_pgio_data *data, struct rpc_message
msg->rpc_proc = &nfs_procedures[NFSPROC_WRITE]; msg->rpc_proc = &nfs_procedures[NFSPROC_WRITE];
} }
static int nfs_proc_write_rpc_prepare(struct rpc_task *task, struct nfs_pgio_data *data)
{
rpc_call_start(task);
return 0;
}
static void nfs_proc_commit_rpc_prepare(struct rpc_task *task, struct nfs_commit_data *data) static void nfs_proc_commit_rpc_prepare(struct rpc_task *task, struct nfs_commit_data *data)
{ {
BUG(); BUG();
...@@ -734,11 +728,10 @@ const struct nfs_rpc_ops nfs_v2_clientops = { ...@@ -734,11 +728,10 @@ const struct nfs_rpc_ops nfs_v2_clientops = {
.fsinfo = nfs_proc_fsinfo, .fsinfo = nfs_proc_fsinfo,
.pathconf = nfs_proc_pathconf, .pathconf = nfs_proc_pathconf,
.decode_dirent = nfs2_decode_dirent, .decode_dirent = nfs2_decode_dirent,
.pgio_rpc_prepare = nfs_proc_pgio_rpc_prepare,
.read_setup = nfs_proc_read_setup, .read_setup = nfs_proc_read_setup,
.read_rpc_prepare = nfs_proc_read_rpc_prepare,
.read_done = nfs_read_done, .read_done = nfs_read_done,
.write_setup = nfs_proc_write_setup, .write_setup = nfs_proc_write_setup,
.write_rpc_prepare = nfs_proc_write_rpc_prepare,
.write_done = nfs_write_done, .write_done = nfs_write_done,
.commit_setup = nfs_proc_commit_setup, .commit_setup = nfs_proc_commit_setup,
.commit_rpc_prepare = nfs_proc_commit_rpc_prepare, .commit_rpc_prepare = nfs_proc_commit_rpc_prepare,
......
...@@ -454,24 +454,10 @@ static void nfs_readpage_result_common(struct rpc_task *task, void *calldata) ...@@ -454,24 +454,10 @@ static void nfs_readpage_result_common(struct rpc_task *task, void *calldata)
nfs_readpage_retry(task, data); nfs_readpage_retry(task, data);
} }
static void nfs_readpage_release_common(void *calldata)
{
nfs_pgio_data_release(calldata);
}
void nfs_read_prepare(struct rpc_task *task, void *calldata)
{
struct nfs_pgio_data *data = calldata;
int err;
err = NFS_PROTO(data->header->inode)->read_rpc_prepare(task, data);
if (err)
rpc_exit(task, err);
}
static const struct rpc_call_ops nfs_read_common_ops = { static const struct rpc_call_ops nfs_read_common_ops = {
.rpc_call_prepare = nfs_read_prepare, .rpc_call_prepare = nfs_pgio_prepare,
.rpc_call_done = nfs_readpage_result_common, .rpc_call_done = nfs_readpage_result_common,
.rpc_release = nfs_readpage_release_common, .rpc_release = nfs_pgio_release,
}; };
/* /*
...@@ -636,6 +622,7 @@ void nfs_destroy_readpagecache(void) ...@@ -636,6 +622,7 @@ void nfs_destroy_readpagecache(void)
} }
static const struct nfs_rw_ops nfs_rw_read_ops = { static const struct nfs_rw_ops nfs_rw_read_ops = {
.rw_mode = FMODE_READ,
.rw_alloc_header = nfs_readhdr_alloc, .rw_alloc_header = nfs_readhdr_alloc,
.rw_free_header = nfs_readhdr_free, .rw_free_header = nfs_readhdr_free,
}; };
...@@ -1248,15 +1248,6 @@ void nfs_pageio_reset_write_mds(struct nfs_pageio_descriptor *pgio) ...@@ -1248,15 +1248,6 @@ void nfs_pageio_reset_write_mds(struct nfs_pageio_descriptor *pgio)
EXPORT_SYMBOL_GPL(nfs_pageio_reset_write_mds); EXPORT_SYMBOL_GPL(nfs_pageio_reset_write_mds);
void nfs_write_prepare(struct rpc_task *task, void *calldata)
{
struct nfs_pgio_data *data = calldata;
int err;
err = NFS_PROTO(data->header->inode)->write_rpc_prepare(task, data);
if (err)
rpc_exit(task, err);
}
void nfs_commit_prepare(struct rpc_task *task, void *calldata) void nfs_commit_prepare(struct rpc_task *task, void *calldata)
{ {
struct nfs_commit_data *data = calldata; struct nfs_commit_data *data = calldata;
...@@ -1278,9 +1269,8 @@ static void nfs_writeback_done_common(struct rpc_task *task, void *calldata) ...@@ -1278,9 +1269,8 @@ static void nfs_writeback_done_common(struct rpc_task *task, void *calldata)
nfs_writeback_done(task, data); nfs_writeback_done(task, data);
} }
static void nfs_writeback_release_common(void *calldata) static void nfs_writeback_release_common(struct nfs_pgio_data *data)
{ {
struct nfs_pgio_data *data = calldata;
struct nfs_pgio_header *hdr = data->header; struct nfs_pgio_header *hdr = data->header;
int status = data->task.tk_status; int status = data->task.tk_status;
...@@ -1294,13 +1284,12 @@ static void nfs_writeback_release_common(void *calldata) ...@@ -1294,13 +1284,12 @@ static void nfs_writeback_release_common(void *calldata)
set_bit(NFS_IOHDR_NEED_RESCHED, &hdr->flags); set_bit(NFS_IOHDR_NEED_RESCHED, &hdr->flags);
spin_unlock(&hdr->lock); spin_unlock(&hdr->lock);
} }
nfs_pgio_data_release(data);
} }
static const struct rpc_call_ops nfs_write_common_ops = { static const struct rpc_call_ops nfs_write_common_ops = {
.rpc_call_prepare = nfs_write_prepare, .rpc_call_prepare = nfs_pgio_prepare,
.rpc_call_done = nfs_writeback_done_common, .rpc_call_done = nfs_writeback_done_common,
.rpc_release = nfs_writeback_release_common, .rpc_release = nfs_pgio_release,
}; };
/* /*
...@@ -1918,6 +1907,8 @@ void nfs_destroy_writepagecache(void) ...@@ -1918,6 +1907,8 @@ void nfs_destroy_writepagecache(void)
} }
static const struct nfs_rw_ops nfs_rw_write_ops = { static const struct nfs_rw_ops nfs_rw_write_ops = {
.rw_mode = FMODE_WRITE,
.rw_alloc_header = nfs_writehdr_alloc, .rw_alloc_header = nfs_writehdr_alloc,
.rw_free_header = nfs_writehdr_free, .rw_free_header = nfs_writehdr_free,
.rw_release = nfs_writeback_release_common,
}; };
...@@ -53,8 +53,10 @@ struct nfs_pageio_ops { ...@@ -53,8 +53,10 @@ struct nfs_pageio_ops {
}; };
struct nfs_rw_ops { struct nfs_rw_ops {
const fmode_t rw_mode;
struct nfs_rw_header *(*rw_alloc_header)(void); struct nfs_rw_header *(*rw_alloc_header)(void);
void (*rw_free_header)(struct nfs_rw_header *); void (*rw_free_header)(struct nfs_rw_header *);
void (*rw_release)(struct nfs_pgio_data *);
}; };
struct nfs_pageio_descriptor { struct nfs_pageio_descriptor {
......
...@@ -1429,11 +1429,10 @@ struct nfs_rpc_ops { ...@@ -1429,11 +1429,10 @@ struct nfs_rpc_ops {
struct nfs_pathconf *); struct nfs_pathconf *);
int (*set_capabilities)(struct nfs_server *, struct nfs_fh *); int (*set_capabilities)(struct nfs_server *, struct nfs_fh *);
int (*decode_dirent)(struct xdr_stream *, struct nfs_entry *, int); int (*decode_dirent)(struct xdr_stream *, struct nfs_entry *, int);
int (*pgio_rpc_prepare)(struct rpc_task *, struct nfs_pgio_data *);
void (*read_setup) (struct nfs_pgio_data *, struct rpc_message *); void (*read_setup) (struct nfs_pgio_data *, struct rpc_message *);
int (*read_rpc_prepare)(struct rpc_task *, struct nfs_pgio_data *);
int (*read_done) (struct rpc_task *, struct nfs_pgio_data *); int (*read_done) (struct rpc_task *, struct nfs_pgio_data *);
void (*write_setup) (struct nfs_pgio_data *, struct rpc_message *); void (*write_setup) (struct nfs_pgio_data *, struct rpc_message *);
int (*write_rpc_prepare)(struct rpc_task *, struct nfs_pgio_data *);
int (*write_done) (struct rpc_task *, struct nfs_pgio_data *); int (*write_done) (struct rpc_task *, struct nfs_pgio_data *);
void (*commit_setup) (struct nfs_commit_data *, struct rpc_message *); void (*commit_setup) (struct nfs_commit_data *, struct rpc_message *);
void (*commit_rpc_prepare)(struct rpc_task *, struct nfs_commit_data *); void (*commit_rpc_prepare)(struct rpc_task *, struct nfs_commit_data *);
......
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