nfs: merge nfs_pgio_data into _header
struct nfs_pgio_data only exists as a member of nfs_pgio_header, but is passed around everywhere, because there used to be multiple _data structs per _header. Many of these functions then use the _data to find a pointer to the _header. This patch cleans this up by merging the nfs_pgio_data structure into nfs_pgio_header and passing nfs_pgio_header around instead. Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Weston Andros Adamson <dros@primarydata.com> Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
This commit is contained in:

committed by
Trond Myklebust

parent
823b0c9d98
commit
d45f60c678
@@ -596,11 +596,11 @@ nfs_clear_request_commit(struct nfs_page *req)
|
||||
}
|
||||
|
||||
static inline
|
||||
int nfs_write_need_commit(struct nfs_pgio_data *data)
|
||||
int nfs_write_need_commit(struct nfs_pgio_header *hdr)
|
||||
{
|
||||
if (data->writeverf.committed == NFS_DATA_SYNC)
|
||||
return data->header->lseg == NULL;
|
||||
return data->writeverf.committed != NFS_FILE_SYNC;
|
||||
if (hdr->writeverf.committed == NFS_DATA_SYNC)
|
||||
return hdr->lseg == NULL;
|
||||
return hdr->writeverf.committed != NFS_FILE_SYNC;
|
||||
}
|
||||
|
||||
#else
|
||||
@@ -627,7 +627,7 @@ nfs_clear_request_commit(struct nfs_page *req)
|
||||
}
|
||||
|
||||
static inline
|
||||
int nfs_write_need_commit(struct nfs_pgio_data *data)
|
||||
int nfs_write_need_commit(struct nfs_pgio_header *hdr)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -1013,17 +1013,18 @@ static int flush_task_priority(int how)
|
||||
return RPC_PRIORITY_NORMAL;
|
||||
}
|
||||
|
||||
static void nfs_initiate_write(struct nfs_pgio_data *data, struct rpc_message *msg,
|
||||
static void nfs_initiate_write(struct nfs_pgio_header *hdr,
|
||||
struct rpc_message *msg,
|
||||
struct rpc_task_setup *task_setup_data, int how)
|
||||
{
|
||||
struct inode *inode = data->header->inode;
|
||||
struct inode *inode = hdr->inode;
|
||||
int priority = flush_task_priority(how);
|
||||
|
||||
task_setup_data->priority = priority;
|
||||
NFS_PROTO(inode)->write_setup(data, msg);
|
||||
NFS_PROTO(inode)->write_setup(hdr, msg);
|
||||
|
||||
nfs4_state_protect_write(NFS_SERVER(inode)->nfs_client,
|
||||
&task_setup_data->rpc_client, msg, data);
|
||||
&task_setup_data->rpc_client, msg, hdr);
|
||||
}
|
||||
|
||||
/* If a nfs_flush_* function fails, it should remove reqs from @head and
|
||||
@@ -1085,19 +1086,17 @@ void nfs_commit_prepare(struct rpc_task *task, void *calldata)
|
||||
NFS_PROTO(data->inode)->commit_rpc_prepare(task, data);
|
||||
}
|
||||
|
||||
static void nfs_writeback_release_common(struct nfs_pgio_data *data)
|
||||
static void nfs_writeback_release_common(struct nfs_pgio_header *hdr)
|
||||
{
|
||||
struct nfs_pgio_header *hdr = data->header;
|
||||
int status = data->task.tk_status;
|
||||
int status = hdr->task.tk_status;
|
||||
|
||||
if ((status >= 0) && nfs_write_need_commit(data)) {
|
||||
if ((status >= 0) && nfs_write_need_commit(hdr)) {
|
||||
spin_lock(&hdr->lock);
|
||||
if (test_bit(NFS_IOHDR_NEED_RESCHED, &hdr->flags))
|
||||
; /* Do nothing */
|
||||
else if (!test_and_set_bit(NFS_IOHDR_NEED_COMMIT, &hdr->flags))
|
||||
memcpy(&hdr->verf, &data->writeverf, sizeof(hdr->verf));
|
||||
else if (memcmp(&hdr->verf, &data->writeverf,
|
||||
sizeof(hdr->verf)))
|
||||
memcpy(&hdr->verf, &hdr->writeverf, sizeof(hdr->verf));
|
||||
else if (memcmp(&hdr->verf, &hdr->writeverf, sizeof(hdr->verf)))
|
||||
set_bit(NFS_IOHDR_NEED_RESCHED, &hdr->flags);
|
||||
spin_unlock(&hdr->lock);
|
||||
}
|
||||
@@ -1131,7 +1130,8 @@ static int nfs_should_remove_suid(const struct inode *inode)
|
||||
/*
|
||||
* This function is called when the WRITE call is complete.
|
||||
*/
|
||||
static int nfs_writeback_done(struct rpc_task *task, struct nfs_pgio_data *data,
|
||||
static int nfs_writeback_done(struct rpc_task *task,
|
||||
struct nfs_pgio_header *hdr,
|
||||
struct inode *inode)
|
||||
{
|
||||
int status;
|
||||
@@ -1143,13 +1143,14 @@ static int nfs_writeback_done(struct rpc_task *task, struct nfs_pgio_data *data,
|
||||
* another writer had changed the file, but some applications
|
||||
* depend on tighter cache coherency when writing.
|
||||
*/
|
||||
status = NFS_PROTO(inode)->write_done(task, data);
|
||||
status = NFS_PROTO(inode)->write_done(task, hdr);
|
||||
if (status != 0)
|
||||
return status;
|
||||
nfs_add_stats(inode, NFSIOS_SERVERWRITTENBYTES, data->res.count);
|
||||
nfs_add_stats(inode, NFSIOS_SERVERWRITTENBYTES, hdr->res.count);
|
||||
|
||||
#if IS_ENABLED(CONFIG_NFS_V3) || IS_ENABLED(CONFIG_NFS_V4)
|
||||
if (data->res.verf->committed < data->args.stable && task->tk_status >= 0) {
|
||||
if (hdr->res.verf->committed < hdr->args.stable &&
|
||||
task->tk_status >= 0) {
|
||||
/* We tried a write call, but the server did not
|
||||
* commit data to stable storage even though we
|
||||
* requested it.
|
||||
@@ -1165,7 +1166,7 @@ static int nfs_writeback_done(struct rpc_task *task, struct nfs_pgio_data *data,
|
||||
dprintk("NFS: faulty NFS server %s:"
|
||||
" (committed = %d) != (stable = %d)\n",
|
||||
NFS_SERVER(inode)->nfs_client->cl_hostname,
|
||||
data->res.verf->committed, data->args.stable);
|
||||
hdr->res.verf->committed, hdr->args.stable);
|
||||
complain = jiffies + 300 * HZ;
|
||||
}
|
||||
}
|
||||
@@ -1180,16 +1181,17 @@ static int nfs_writeback_done(struct rpc_task *task, struct nfs_pgio_data *data,
|
||||
/*
|
||||
* This function is called when the WRITE call is complete.
|
||||
*/
|
||||
static void nfs_writeback_result(struct rpc_task *task, struct nfs_pgio_data *data)
|
||||
static void nfs_writeback_result(struct rpc_task *task,
|
||||
struct nfs_pgio_header *hdr)
|
||||
{
|
||||
struct nfs_pgio_args *argp = &data->args;
|
||||
struct nfs_pgio_res *resp = &data->res;
|
||||
struct nfs_pgio_args *argp = &hdr->args;
|
||||
struct nfs_pgio_res *resp = &hdr->res;
|
||||
|
||||
if (resp->count < argp->count) {
|
||||
static unsigned long complain;
|
||||
|
||||
/* This a short write! */
|
||||
nfs_inc_stats(data->header->inode, NFSIOS_SHORTWRITE);
|
||||
nfs_inc_stats(hdr->inode, NFSIOS_SHORTWRITE);
|
||||
|
||||
/* Has the server at least made some progress? */
|
||||
if (resp->count == 0) {
|
||||
@@ -1199,14 +1201,14 @@ static void nfs_writeback_result(struct rpc_task *task, struct nfs_pgio_data *da
|
||||
argp->count);
|
||||
complain = jiffies + 300 * HZ;
|
||||
}
|
||||
nfs_set_pgio_error(data->header, -EIO, argp->offset);
|
||||
nfs_set_pgio_error(hdr, -EIO, argp->offset);
|
||||
task->tk_status = -EIO;
|
||||
return;
|
||||
}
|
||||
/* Was this an NFSv2 write or an NFSv3 stable write? */
|
||||
if (resp->verf->committed != NFS_UNSTABLE) {
|
||||
/* Resend from where the server left off */
|
||||
data->mds_offset += resp->count;
|
||||
hdr->mds_offset += resp->count;
|
||||
argp->offset += resp->count;
|
||||
argp->pgbase += resp->count;
|
||||
argp->count -= resp->count;
|
||||
|
Reference in New Issue
Block a user