summaryrefslogtreecommitdiffstats
path: root/fs/nfs/write.c
diff options
context:
space:
mode:
authorAnna Schumaker <Anna.Schumaker@netapp.com>2014-05-06 09:12:32 -0400
committerTrond Myklebust <trond.myklebust@primarydata.com>2014-05-28 18:40:36 -0400
commit0eecb2145c1ce18e36617008424a93836ad0a3bd (patch)
tree469884c95d6e3c65383800e0c41b197d44851543 /fs/nfs/write.c
parenta4cdda59111f92000297e0d3edb1e0e08ba3549b (diff)
NFS: Create a common nfs_pgio_result_common function
Combining these functions will let me make a single nfs_rw_common_ops struct (see the next patch). Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com> Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Diffstat (limited to 'fs/nfs/write.c')
-rw-r--r--fs/nfs/write.c51
1 files changed, 20 insertions, 31 deletions
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index ae799c96ec2b..1d3e1d75c8c5 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -1255,20 +1255,6 @@ void nfs_commit_prepare(struct rpc_task *task, void *calldata)
1255 NFS_PROTO(data->inode)->commit_rpc_prepare(task, data); 1255 NFS_PROTO(data->inode)->commit_rpc_prepare(task, data);
1256} 1256}
1257 1257
1258/*
1259 * Handle a write reply that flushes a whole page.
1260 *
1261 * FIXME: There is an inherent race with invalidate_inode_pages and
1262 * writebacks since the page->count is kept > 1 for as long
1263 * as the page has a write request pending.
1264 */
1265static void nfs_writeback_done_common(struct rpc_task *task, void *calldata)
1266{
1267 struct nfs_pgio_data *data = calldata;
1268
1269 nfs_writeback_done(task, data);
1270}
1271
1272static void nfs_writeback_release_common(struct nfs_pgio_data *data) 1258static void nfs_writeback_release_common(struct nfs_pgio_data *data)
1273{ 1259{
1274 struct nfs_pgio_header *hdr = data->header; 1260 struct nfs_pgio_header *hdr = data->header;
@@ -1288,7 +1274,7 @@ static void nfs_writeback_release_common(struct nfs_pgio_data *data)
1288 1274
1289static const struct rpc_call_ops nfs_write_common_ops = { 1275static const struct rpc_call_ops nfs_write_common_ops = {
1290 .rpc_call_prepare = nfs_pgio_prepare, 1276 .rpc_call_prepare = nfs_pgio_prepare,
1291 .rpc_call_done = nfs_writeback_done_common, 1277 .rpc_call_done = nfs_pgio_result,
1292 .rpc_release = nfs_pgio_release, 1278 .rpc_release = nfs_pgio_release,
1293}; 1279};
1294 1280
@@ -1320,16 +1306,11 @@ static int nfs_should_remove_suid(const struct inode *inode)
1320/* 1306/*
1321 * This function is called when the WRITE call is complete. 1307 * This function is called when the WRITE call is complete.
1322 */ 1308 */
1323void nfs_writeback_done(struct rpc_task *task, struct nfs_pgio_data *data) 1309static int nfs_writeback_done(struct rpc_task *task, struct nfs_pgio_data *data,
1310 struct inode *inode)
1324{ 1311{
1325 struct nfs_pgio_args *argp = &data->args;
1326 struct nfs_pgio_res *resp = &data->res;
1327 struct inode *inode = data->header->inode;
1328 int status; 1312 int status;
1329 1313
1330 dprintk("NFS: %5u nfs_writeback_done (status %d)\n",
1331 task->tk_pid, task->tk_status);
1332
1333 /* 1314 /*
1334 * ->write_done will attempt to use post-op attributes to detect 1315 * ->write_done will attempt to use post-op attributes to detect
1335 * conflicting writes by other clients. A strict interpretation 1316 * conflicting writes by other clients. A strict interpretation
@@ -1339,11 +1320,11 @@ void nfs_writeback_done(struct rpc_task *task, struct nfs_pgio_data *data)
1339 */ 1320 */
1340 status = NFS_PROTO(inode)->write_done(task, data); 1321 status = NFS_PROTO(inode)->write_done(task, data);
1341 if (status != 0) 1322 if (status != 0)
1342 return; 1323 return status;
1343 nfs_add_stats(inode, NFSIOS_SERVERWRITTENBYTES, resp->count); 1324 nfs_add_stats(inode, NFSIOS_SERVERWRITTENBYTES, data->res.count);
1344 1325
1345#if IS_ENABLED(CONFIG_NFS_V3) || IS_ENABLED(CONFIG_NFS_V4) 1326#if IS_ENABLED(CONFIG_NFS_V3) || IS_ENABLED(CONFIG_NFS_V4)
1346 if (resp->verf->committed < argp->stable && task->tk_status >= 0) { 1327 if (data->res.verf->committed < data->args.stable && task->tk_status >= 0) {
1347 /* We tried a write call, but the server did not 1328 /* We tried a write call, but the server did not
1348 * commit data to stable storage even though we 1329 * commit data to stable storage even though we
1349 * requested it. 1330 * requested it.
@@ -1359,25 +1340,31 @@ void nfs_writeback_done(struct rpc_task *task, struct nfs_pgio_data *data)
1359 dprintk("NFS: faulty NFS server %s:" 1340 dprintk("NFS: faulty NFS server %s:"
1360 " (committed = %d) != (stable = %d)\n", 1341 " (committed = %d) != (stable = %d)\n",
1361 NFS_SERVER(inode)->nfs_client->cl_hostname, 1342 NFS_SERVER(inode)->nfs_client->cl_hostname,
1362 resp->verf->committed, argp->stable); 1343 data->res.verf->committed, data->args.stable);
1363 complain = jiffies + 300 * HZ; 1344 complain = jiffies + 300 * HZ;
1364 } 1345 }
1365 } 1346 }
1366#endif 1347#endif
1367 if (task->tk_status < 0) {
1368 nfs_set_pgio_error(data->header, task->tk_status, argp->offset);
1369 return;
1370 }
1371 1348
1372 /* Deal with the suid/sgid bit corner case */ 1349 /* Deal with the suid/sgid bit corner case */
1373 if (nfs_should_remove_suid(inode)) 1350 if (nfs_should_remove_suid(inode))
1374 nfs_mark_for_revalidate(inode); 1351 nfs_mark_for_revalidate(inode);
1352 return 0;
1353}
1354
1355/*
1356 * This function is called when the WRITE call is complete.
1357 */
1358static void nfs_writeback_result(struct rpc_task *task, struct nfs_pgio_data *data)
1359{
1360 struct nfs_pgio_args *argp = &data->args;
1361 struct nfs_pgio_res *resp = &data->res;
1375 1362
1376 if (resp->count < argp->count) { 1363 if (resp->count < argp->count) {
1377 static unsigned long complain; 1364 static unsigned long complain;
1378 1365
1379 /* This a short write! */ 1366 /* This a short write! */
1380 nfs_inc_stats(inode, NFSIOS_SHORTWRITE); 1367 nfs_inc_stats(data->header->inode, NFSIOS_SHORTWRITE);
1381 1368
1382 /* Has the server at least made some progress? */ 1369 /* Has the server at least made some progress? */
1383 if (resp->count == 0) { 1370 if (resp->count == 0) {
@@ -1911,4 +1898,6 @@ static const struct nfs_rw_ops nfs_rw_write_ops = {
1911 .rw_alloc_header = nfs_writehdr_alloc, 1898 .rw_alloc_header = nfs_writehdr_alloc,
1912 .rw_free_header = nfs_writehdr_free, 1899 .rw_free_header = nfs_writehdr_free,
1913 .rw_release = nfs_writeback_release_common, 1900 .rw_release = nfs_writeback_release_common,
1901 .rw_done = nfs_writeback_done,
1902 .rw_result = nfs_writeback_result,
1914}; 1903};