aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/write.c
diff options
context:
space:
mode:
authorWeston Andros Adamson <dros@primarydata.com>2014-06-09 11:48:35 -0400
committerTrond Myklebust <trond.myklebust@primarydata.com>2014-06-24 18:47:00 -0400
commitd45f60c67848b9f19160692581d78e5b4757a000 (patch)
tree5f31965abe5bd21e73eae10454db74fe6ce901e9 /fs/nfs/write.c
parent823b0c9d9800e712374cda89ac3565bd29f6701b (diff)
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>
Diffstat (limited to 'fs/nfs/write.c')
-rw-r--r--fs/nfs/write.c56
1 files changed, 29 insertions, 27 deletions
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index 6afe0f679420..6a2d0986a3a3 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -596,11 +596,11 @@ nfs_clear_request_commit(struct nfs_page *req)
596} 596}
597 597
598static inline 598static inline
599int nfs_write_need_commit(struct nfs_pgio_data *data) 599int nfs_write_need_commit(struct nfs_pgio_header *hdr)
600{ 600{
601 if (data->writeverf.committed == NFS_DATA_SYNC) 601 if (hdr->writeverf.committed == NFS_DATA_SYNC)
602 return data->header->lseg == NULL; 602 return hdr->lseg == NULL;
603 return data->writeverf.committed != NFS_FILE_SYNC; 603 return hdr->writeverf.committed != NFS_FILE_SYNC;
604} 604}
605 605
606#else 606#else
@@ -627,7 +627,7 @@ nfs_clear_request_commit(struct nfs_page *req)
627} 627}
628 628
629static inline 629static inline
630int nfs_write_need_commit(struct nfs_pgio_data *data) 630int nfs_write_need_commit(struct nfs_pgio_header *hdr)
631{ 631{
632 return 0; 632 return 0;
633} 633}
@@ -1013,17 +1013,18 @@ static int flush_task_priority(int how)
1013 return RPC_PRIORITY_NORMAL; 1013 return RPC_PRIORITY_NORMAL;
1014} 1014}
1015 1015
1016static void nfs_initiate_write(struct nfs_pgio_data *data, struct rpc_message *msg, 1016static void nfs_initiate_write(struct nfs_pgio_header *hdr,
1017 struct rpc_message *msg,
1017 struct rpc_task_setup *task_setup_data, int how) 1018 struct rpc_task_setup *task_setup_data, int how)
1018{ 1019{
1019 struct inode *inode = data->header->inode; 1020 struct inode *inode = hdr->inode;
1020 int priority = flush_task_priority(how); 1021 int priority = flush_task_priority(how);
1021 1022
1022 task_setup_data->priority = priority; 1023 task_setup_data->priority = priority;
1023 NFS_PROTO(inode)->write_setup(data, msg); 1024 NFS_PROTO(inode)->write_setup(hdr, msg);
1024 1025
1025 nfs4_state_protect_write(NFS_SERVER(inode)->nfs_client, 1026 nfs4_state_protect_write(NFS_SERVER(inode)->nfs_client,
1026 &task_setup_data->rpc_client, msg, data); 1027 &task_setup_data->rpc_client, msg, hdr);
1027} 1028}
1028 1029
1029/* If a nfs_flush_* function fails, it should remove reqs from @head and 1030/* 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)
1085 NFS_PROTO(data->inode)->commit_rpc_prepare(task, data); 1086 NFS_PROTO(data->inode)->commit_rpc_prepare(task, data);
1086} 1087}
1087 1088
1088static void nfs_writeback_release_common(struct nfs_pgio_data *data) 1089static void nfs_writeback_release_common(struct nfs_pgio_header *hdr)
1089{ 1090{
1090 struct nfs_pgio_header *hdr = data->header; 1091 int status = hdr->task.tk_status;
1091 int status = data->task.tk_status;
1092 1092
1093 if ((status >= 0) && nfs_write_need_commit(data)) { 1093 if ((status >= 0) && nfs_write_need_commit(hdr)) {
1094 spin_lock(&hdr->lock); 1094 spin_lock(&hdr->lock);
1095 if (test_bit(NFS_IOHDR_NEED_RESCHED, &hdr->flags)) 1095 if (test_bit(NFS_IOHDR_NEED_RESCHED, &hdr->flags))
1096 ; /* Do nothing */ 1096 ; /* Do nothing */
1097 else if (!test_and_set_bit(NFS_IOHDR_NEED_COMMIT, &hdr->flags)) 1097 else if (!test_and_set_bit(NFS_IOHDR_NEED_COMMIT, &hdr->flags))
1098 memcpy(&hdr->verf, &data->writeverf, sizeof(hdr->verf)); 1098 memcpy(&hdr->verf, &hdr->writeverf, sizeof(hdr->verf));
1099 else if (memcmp(&hdr->verf, &data->writeverf, 1099 else if (memcmp(&hdr->verf, &hdr->writeverf, sizeof(hdr->verf)))
1100 sizeof(hdr->verf)))
1101 set_bit(NFS_IOHDR_NEED_RESCHED, &hdr->flags); 1100 set_bit(NFS_IOHDR_NEED_RESCHED, &hdr->flags);
1102 spin_unlock(&hdr->lock); 1101 spin_unlock(&hdr->lock);
1103 } 1102 }
@@ -1131,7 +1130,8 @@ static int nfs_should_remove_suid(const struct inode *inode)
1131/* 1130/*
1132 * This function is called when the WRITE call is complete. 1131 * This function is called when the WRITE call is complete.
1133 */ 1132 */
1134static int nfs_writeback_done(struct rpc_task *task, struct nfs_pgio_data *data, 1133static int nfs_writeback_done(struct rpc_task *task,
1134 struct nfs_pgio_header *hdr,
1135 struct inode *inode) 1135 struct inode *inode)
1136{ 1136{
1137 int status; 1137 int status;
@@ -1143,13 +1143,14 @@ static int nfs_writeback_done(struct rpc_task *task, struct nfs_pgio_data *data,
1143 * another writer had changed the file, but some applications 1143 * another writer had changed the file, but some applications
1144 * depend on tighter cache coherency when writing. 1144 * depend on tighter cache coherency when writing.
1145 */ 1145 */
1146 status = NFS_PROTO(inode)->write_done(task, data); 1146 status = NFS_PROTO(inode)->write_done(task, hdr);
1147 if (status != 0) 1147 if (status != 0)
1148 return status; 1148 return status;
1149 nfs_add_stats(inode, NFSIOS_SERVERWRITTENBYTES, data->res.count); 1149 nfs_add_stats(inode, NFSIOS_SERVERWRITTENBYTES, hdr->res.count);
1150 1150
1151#if IS_ENABLED(CONFIG_NFS_V3) || IS_ENABLED(CONFIG_NFS_V4) 1151#if IS_ENABLED(CONFIG_NFS_V3) || IS_ENABLED(CONFIG_NFS_V4)
1152 if (data->res.verf->committed < data->args.stable && task->tk_status >= 0) { 1152 if (hdr->res.verf->committed < hdr->args.stable &&
1153 task->tk_status >= 0) {
1153 /* We tried a write call, but the server did not 1154 /* We tried a write call, but the server did not
1154 * commit data to stable storage even though we 1155 * commit data to stable storage even though we
1155 * requested it. 1156 * requested it.
@@ -1165,7 +1166,7 @@ static int nfs_writeback_done(struct rpc_task *task, struct nfs_pgio_data *data,
1165 dprintk("NFS: faulty NFS server %s:" 1166 dprintk("NFS: faulty NFS server %s:"
1166 " (committed = %d) != (stable = %d)\n", 1167 " (committed = %d) != (stable = %d)\n",
1167 NFS_SERVER(inode)->nfs_client->cl_hostname, 1168 NFS_SERVER(inode)->nfs_client->cl_hostname,
1168 data->res.verf->committed, data->args.stable); 1169 hdr->res.verf->committed, hdr->args.stable);
1169 complain = jiffies + 300 * HZ; 1170 complain = jiffies + 300 * HZ;
1170 } 1171 }
1171 } 1172 }
@@ -1180,16 +1181,17 @@ static int nfs_writeback_done(struct rpc_task *task, struct nfs_pgio_data *data,
1180/* 1181/*
1181 * This function is called when the WRITE call is complete. 1182 * This function is called when the WRITE call is complete.
1182 */ 1183 */
1183static void nfs_writeback_result(struct rpc_task *task, struct nfs_pgio_data *data) 1184static void nfs_writeback_result(struct rpc_task *task,
1185 struct nfs_pgio_header *hdr)
1184{ 1186{
1185 struct nfs_pgio_args *argp = &data->args; 1187 struct nfs_pgio_args *argp = &hdr->args;
1186 struct nfs_pgio_res *resp = &data->res; 1188 struct nfs_pgio_res *resp = &hdr->res;
1187 1189
1188 if (resp->count < argp->count) { 1190 if (resp->count < argp->count) {
1189 static unsigned long complain; 1191 static unsigned long complain;
1190 1192
1191 /* This a short write! */ 1193 /* This a short write! */
1192 nfs_inc_stats(data->header->inode, NFSIOS_SHORTWRITE); 1194 nfs_inc_stats(hdr->inode, NFSIOS_SHORTWRITE);
1193 1195
1194 /* Has the server at least made some progress? */ 1196 /* Has the server at least made some progress? */
1195 if (resp->count == 0) { 1197 if (resp->count == 0) {
@@ -1199,14 +1201,14 @@ static void nfs_writeback_result(struct rpc_task *task, struct nfs_pgio_data *da
1199 argp->count); 1201 argp->count);
1200 complain = jiffies + 300 * HZ; 1202 complain = jiffies + 300 * HZ;
1201 } 1203 }
1202 nfs_set_pgio_error(data->header, -EIO, argp->offset); 1204 nfs_set_pgio_error(hdr, -EIO, argp->offset);
1203 task->tk_status = -EIO; 1205 task->tk_status = -EIO;
1204 return; 1206 return;
1205 } 1207 }
1206 /* Was this an NFSv2 write or an NFSv3 stable write? */ 1208 /* Was this an NFSv2 write or an NFSv3 stable write? */
1207 if (resp->verf->committed != NFS_UNSTABLE) { 1209 if (resp->verf->committed != NFS_UNSTABLE) {
1208 /* Resend from where the server left off */ 1210 /* Resend from where the server left off */
1209 data->mds_offset += resp->count; 1211 hdr->mds_offset += resp->count;
1210 argp->offset += resp->count; 1212 argp->offset += resp->count;
1211 argp->pgbase += resp->count; 1213 argp->pgbase += resp->count;
1212 argp->count -= resp->count; 1214 argp->count -= resp->count;