Commit 3c6b899c authored by Anna Schumaker's avatar Anna Schumaker Committed by Trond Myklebust

NFS: Create a common argument structure for reads and writes

Reads and writes have very similar arguments.  This patch combines them
together and documents the few fields used only by write.
Signed-off-by: default avatarAnna Schumaker <Anna.Schumaker@Netapp.com>
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@primarydata.com>
parent fab5fc25
...@@ -613,7 +613,7 @@ static void nfs2_xdr_enc_readlinkargs(struct rpc_rqst *req, ...@@ -613,7 +613,7 @@ static void nfs2_xdr_enc_readlinkargs(struct rpc_rqst *req,
* }; * };
*/ */
static void encode_readargs(struct xdr_stream *xdr, static void encode_readargs(struct xdr_stream *xdr,
const struct nfs_readargs *args) const struct nfs_pgio_args *args)
{ {
u32 offset = args->offset; u32 offset = args->offset;
u32 count = args->count; u32 count = args->count;
...@@ -629,7 +629,7 @@ static void encode_readargs(struct xdr_stream *xdr, ...@@ -629,7 +629,7 @@ static void encode_readargs(struct xdr_stream *xdr,
static void nfs2_xdr_enc_readargs(struct rpc_rqst *req, static void nfs2_xdr_enc_readargs(struct rpc_rqst *req,
struct xdr_stream *xdr, struct xdr_stream *xdr,
const struct nfs_readargs *args) const struct nfs_pgio_args *args)
{ {
encode_readargs(xdr, args); encode_readargs(xdr, args);
prepare_reply_buffer(req, args->pages, args->pgbase, prepare_reply_buffer(req, args->pages, args->pgbase,
...@@ -649,7 +649,7 @@ static void nfs2_xdr_enc_readargs(struct rpc_rqst *req, ...@@ -649,7 +649,7 @@ static void nfs2_xdr_enc_readargs(struct rpc_rqst *req,
* }; * };
*/ */
static void encode_writeargs(struct xdr_stream *xdr, static void encode_writeargs(struct xdr_stream *xdr,
const struct nfs_writeargs *args) const struct nfs_pgio_args *args)
{ {
u32 offset = args->offset; u32 offset = args->offset;
u32 count = args->count; u32 count = args->count;
...@@ -669,7 +669,7 @@ static void encode_writeargs(struct xdr_stream *xdr, ...@@ -669,7 +669,7 @@ static void encode_writeargs(struct xdr_stream *xdr,
static void nfs2_xdr_enc_writeargs(struct rpc_rqst *req, static void nfs2_xdr_enc_writeargs(struct rpc_rqst *req,
struct xdr_stream *xdr, struct xdr_stream *xdr,
const struct nfs_writeargs *args) const struct nfs_pgio_args *args)
{ {
encode_writeargs(xdr, args); encode_writeargs(xdr, args);
xdr->buf->flags |= XDRBUF_WRITE; xdr->buf->flags |= XDRBUF_WRITE;
......
...@@ -953,7 +953,7 @@ static void nfs3_xdr_enc_readlink3args(struct rpc_rqst *req, ...@@ -953,7 +953,7 @@ static void nfs3_xdr_enc_readlink3args(struct rpc_rqst *req,
* }; * };
*/ */
static void encode_read3args(struct xdr_stream *xdr, static void encode_read3args(struct xdr_stream *xdr,
const struct nfs_readargs *args) const struct nfs_pgio_args *args)
{ {
__be32 *p; __be32 *p;
...@@ -966,7 +966,7 @@ static void encode_read3args(struct xdr_stream *xdr, ...@@ -966,7 +966,7 @@ static void encode_read3args(struct xdr_stream *xdr,
static void nfs3_xdr_enc_read3args(struct rpc_rqst *req, static void nfs3_xdr_enc_read3args(struct rpc_rqst *req,
struct xdr_stream *xdr, struct xdr_stream *xdr,
const struct nfs_readargs *args) const struct nfs_pgio_args *args)
{ {
encode_read3args(xdr, args); encode_read3args(xdr, args);
prepare_reply_buffer(req, args->pages, args->pgbase, prepare_reply_buffer(req, args->pages, args->pgbase,
...@@ -992,7 +992,7 @@ static void nfs3_xdr_enc_read3args(struct rpc_rqst *req, ...@@ -992,7 +992,7 @@ static void nfs3_xdr_enc_read3args(struct rpc_rqst *req,
* }; * };
*/ */
static void encode_write3args(struct xdr_stream *xdr, static void encode_write3args(struct xdr_stream *xdr,
const struct nfs_writeargs *args) const struct nfs_pgio_args *args)
{ {
__be32 *p; __be32 *p;
...@@ -1008,7 +1008,7 @@ static void encode_write3args(struct xdr_stream *xdr, ...@@ -1008,7 +1008,7 @@ static void encode_write3args(struct xdr_stream *xdr,
static void nfs3_xdr_enc_write3args(struct rpc_rqst *req, static void nfs3_xdr_enc_write3args(struct rpc_rqst *req,
struct xdr_stream *xdr, struct xdr_stream *xdr,
const struct nfs_writeargs *args) const struct nfs_pgio_args *args)
{ {
encode_write3args(xdr, args); encode_write3args(xdr, args);
xdr->buf->flags |= XDRBUF_WRITE; xdr->buf->flags |= XDRBUF_WRITE;
......
...@@ -4055,7 +4055,7 @@ static int nfs4_read_done_cb(struct rpc_task *task, struct nfs_read_data *data) ...@@ -4055,7 +4055,7 @@ static int nfs4_read_done_cb(struct rpc_task *task, struct nfs_read_data *data)
} }
static bool nfs4_read_stateid_changed(struct rpc_task *task, static bool nfs4_read_stateid_changed(struct rpc_task *task,
struct nfs_readargs *args) struct nfs_pgio_args *args)
{ {
if (!nfs4_error_stateid_expired(task->tk_status) || if (!nfs4_error_stateid_expired(task->tk_status) ||
...@@ -4121,7 +4121,7 @@ static int nfs4_write_done_cb(struct rpc_task *task, struct nfs_write_data *data ...@@ -4121,7 +4121,7 @@ static int nfs4_write_done_cb(struct rpc_task *task, struct nfs_write_data *data
} }
static bool nfs4_write_stateid_changed(struct rpc_task *task, static bool nfs4_write_stateid_changed(struct rpc_task *task,
struct nfs_writeargs *args) struct nfs_pgio_args *args)
{ {
if (!nfs4_error_stateid_expired(task->tk_status) || if (!nfs4_error_stateid_expired(task->tk_status) ||
......
...@@ -1556,7 +1556,8 @@ static void encode_putrootfh(struct xdr_stream *xdr, struct compound_hdr *hdr) ...@@ -1556,7 +1556,8 @@ static void encode_putrootfh(struct xdr_stream *xdr, struct compound_hdr *hdr)
encode_op_hdr(xdr, OP_PUTROOTFH, decode_putrootfh_maxsz, hdr); encode_op_hdr(xdr, OP_PUTROOTFH, decode_putrootfh_maxsz, hdr);
} }
static void encode_read(struct xdr_stream *xdr, const struct nfs_readargs *args, struct compound_hdr *hdr) static void encode_read(struct xdr_stream *xdr, const struct nfs_pgio_args *args,
struct compound_hdr *hdr)
{ {
__be32 *p; __be32 *p;
...@@ -1701,7 +1702,8 @@ static void encode_setclientid_confirm(struct xdr_stream *xdr, const struct nfs4 ...@@ -1701,7 +1702,8 @@ static void encode_setclientid_confirm(struct xdr_stream *xdr, const struct nfs4
encode_nfs4_verifier(xdr, &arg->confirm); encode_nfs4_verifier(xdr, &arg->confirm);
} }
static void encode_write(struct xdr_stream *xdr, const struct nfs_writeargs *args, struct compound_hdr *hdr) static void encode_write(struct xdr_stream *xdr, const struct nfs_pgio_args *args,
struct compound_hdr *hdr)
{ {
__be32 *p; __be32 *p;
...@@ -2451,7 +2453,7 @@ static void nfs4_xdr_enc_readdir(struct rpc_rqst *req, struct xdr_stream *xdr, ...@@ -2451,7 +2453,7 @@ static void nfs4_xdr_enc_readdir(struct rpc_rqst *req, struct xdr_stream *xdr,
* Encode a READ request * Encode a READ request
*/ */
static void nfs4_xdr_enc_read(struct rpc_rqst *req, struct xdr_stream *xdr, static void nfs4_xdr_enc_read(struct rpc_rqst *req, struct xdr_stream *xdr,
struct nfs_readargs *args) struct nfs_pgio_args *args)
{ {
struct compound_hdr hdr = { struct compound_hdr hdr = {
.minorversion = nfs4_xdr_minorversion(&args->seq_args), .minorversion = nfs4_xdr_minorversion(&args->seq_args),
...@@ -2513,7 +2515,7 @@ static void nfs4_xdr_enc_getacl(struct rpc_rqst *req, struct xdr_stream *xdr, ...@@ -2513,7 +2515,7 @@ static void nfs4_xdr_enc_getacl(struct rpc_rqst *req, struct xdr_stream *xdr,
* Encode a WRITE request * Encode a WRITE request
*/ */
static void nfs4_xdr_enc_write(struct rpc_rqst *req, struct xdr_stream *xdr, static void nfs4_xdr_enc_write(struct rpc_rqst *req, struct xdr_stream *xdr,
struct nfs_writeargs *args) struct nfs_pgio_args *args)
{ {
struct compound_hdr hdr = { struct compound_hdr hdr = {
.minorversion = nfs4_xdr_minorversion(&args->seq_args), .minorversion = nfs4_xdr_minorversion(&args->seq_args),
......
...@@ -470,7 +470,7 @@ int nfs_readpage_result(struct rpc_task *task, struct nfs_read_data *data) ...@@ -470,7 +470,7 @@ int nfs_readpage_result(struct rpc_task *task, struct nfs_read_data *data)
static void nfs_readpage_retry(struct rpc_task *task, struct nfs_read_data *data) static void nfs_readpage_retry(struct rpc_task *task, struct nfs_read_data *data)
{ {
struct nfs_readargs *argp = &data->args; struct nfs_pgio_args *argp = &data->args;
struct nfs_readres *resp = &data->res; struct nfs_readres *resp = &data->res;
/* This is a short read! */ /* This is a short read! */
......
...@@ -1388,7 +1388,7 @@ static int nfs_should_remove_suid(const struct inode *inode) ...@@ -1388,7 +1388,7 @@ static int nfs_should_remove_suid(const struct inode *inode)
*/ */
void nfs_writeback_done(struct rpc_task *task, struct nfs_write_data *data) void nfs_writeback_done(struct rpc_task *task, struct nfs_write_data *data)
{ {
struct nfs_writeargs *argp = &data->args; struct nfs_pgio_args *argp = &data->args;
struct nfs_writeres *resp = &data->res; struct nfs_writeres *resp = &data->res;
struct inode *inode = data->header->inode; struct inode *inode = data->header->inode;
int status; int status;
......
...@@ -491,18 +491,6 @@ struct nfs4_delegreturnres { ...@@ -491,18 +491,6 @@ struct nfs4_delegreturnres {
/* /*
* Arguments to the read call. * Arguments to the read call.
*/ */
struct nfs_readargs {
struct nfs4_sequence_args seq_args;
struct nfs_fh * fh;
struct nfs_open_context *context;
struct nfs_lock_context *lock_context;
nfs4_stateid stateid;
__u64 offset;
__u32 count;
unsigned int pgbase;
struct page ** pages;
};
struct nfs_readres { struct nfs_readres {
struct nfs4_sequence_res seq_res; struct nfs4_sequence_res seq_res;
struct nfs_fattr * fattr; struct nfs_fattr * fattr;
...@@ -513,20 +501,6 @@ struct nfs_readres { ...@@ -513,20 +501,6 @@ struct nfs_readres {
/* /*
* Arguments to the write call. * Arguments to the write call.
*/ */
struct nfs_writeargs {
struct nfs4_sequence_args seq_args;
struct nfs_fh * fh;
struct nfs_open_context *context;
struct nfs_lock_context *lock_context;
nfs4_stateid stateid;
__u64 offset;
__u32 count;
enum nfs3_stable_how stable;
unsigned int pgbase;
struct page ** pages;
const u32 * bitmask;
};
struct nfs_write_verifier { struct nfs_write_verifier {
char data[8]; char data[8];
}; };
...@@ -544,6 +518,23 @@ struct nfs_writeres { ...@@ -544,6 +518,23 @@ struct nfs_writeres {
const struct nfs_server *server; const struct nfs_server *server;
}; };
/*
* Arguments shared by the read and write call.
*/
struct nfs_pgio_args {
struct nfs4_sequence_args seq_args;
struct nfs_fh * fh;
struct nfs_open_context *context;
struct nfs_lock_context *lock_context;
nfs4_stateid stateid;
__u64 offset;
__u32 count;
unsigned int pgbase;
struct page ** pages;
const u32 * bitmask; /* used by write */
enum nfs3_stable_how stable; /* used by write */
};
/* /*
* Arguments to the commit call. * Arguments to the commit call.
*/ */
...@@ -1269,7 +1260,7 @@ struct nfs_read_data { ...@@ -1269,7 +1260,7 @@ struct nfs_read_data {
struct list_head list; struct list_head list;
struct rpc_task task; struct rpc_task task;
struct nfs_fattr fattr; /* fattr storage */ struct nfs_fattr fattr; /* fattr storage */
struct nfs_readargs args; struct nfs_pgio_args args;
struct nfs_readres res; struct nfs_readres res;
unsigned long timestamp; /* For lease renewal */ unsigned long timestamp; /* For lease renewal */
int (*read_done_cb) (struct rpc_task *task, struct nfs_read_data *data); int (*read_done_cb) (struct rpc_task *task, struct nfs_read_data *data);
...@@ -1321,7 +1312,7 @@ struct nfs_write_data { ...@@ -1321,7 +1312,7 @@ struct nfs_write_data {
struct rpc_task task; struct rpc_task task;
struct nfs_fattr fattr; struct nfs_fattr fattr;
struct nfs_writeverf verf; struct nfs_writeverf verf;
struct nfs_writeargs args; /* argument struct */ struct nfs_pgio_args args; /* argument struct */
struct nfs_writeres res; /* result struct */ struct nfs_writeres res; /* result struct */
unsigned long timestamp; /* For lease renewal */ unsigned long timestamp; /* For lease renewal */
int (*write_done_cb) (struct rpc_task *task, struct nfs_write_data *data); int (*write_done_cb) (struct rpc_task *task, struct nfs_write_data *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