aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/pnfs.c
diff options
context:
space:
mode:
authorFred Isaman <iisaman@netapp.com>2012-04-20 14:47:48 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2012-04-27 14:10:38 -0400
commit061ae2edb7375ab6776468b075da71008a098b55 (patch)
treea34f25d4d85d90a196b058b879eef3ba374f6d16 /fs/nfs/pnfs.c
parent6c75dc0d498caa402fb17b1bf769835a9db875c8 (diff)
NFS: create completion structure to pass into page_init functions
Factors out the code that will need to change when directio starts using these code paths. This will allow directio to use the generic pagein and flush routines Signed-off-by: Fred Isaman <iisaman@netapp.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/pnfs.c')
-rw-r--r--fs/nfs/pnfs.c39
1 files changed, 25 insertions, 14 deletions
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index d515f00614cd..b3a0c01718af 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -1113,26 +1113,31 @@ pnfs_generic_pg_init_write(struct nfs_pageio_descriptor *pgio, struct nfs_page *
1113EXPORT_SYMBOL_GPL(pnfs_generic_pg_init_write); 1113EXPORT_SYMBOL_GPL(pnfs_generic_pg_init_write);
1114 1114
1115bool 1115bool
1116pnfs_pageio_init_read(struct nfs_pageio_descriptor *pgio, struct inode *inode) 1116pnfs_pageio_init_read(struct nfs_pageio_descriptor *pgio, struct inode *inode,
1117 const struct nfs_pgio_completion_ops *compl_ops)
1117{ 1118{
1118 struct nfs_server *server = NFS_SERVER(inode); 1119 struct nfs_server *server = NFS_SERVER(inode);
1119 struct pnfs_layoutdriver_type *ld = server->pnfs_curr_ld; 1120 struct pnfs_layoutdriver_type *ld = server->pnfs_curr_ld;
1120 1121
1121 if (ld == NULL) 1122 if (ld == NULL)
1122 return false; 1123 return false;
1123 nfs_pageio_init(pgio, inode, ld->pg_read_ops, server->rsize, 0); 1124 nfs_pageio_init(pgio, inode, ld->pg_read_ops, compl_ops,
1125 server->rsize, 0);
1124 return true; 1126 return true;
1125} 1127}
1126 1128
1127bool 1129bool
1128pnfs_pageio_init_write(struct nfs_pageio_descriptor *pgio, struct inode *inode, int ioflags) 1130pnfs_pageio_init_write(struct nfs_pageio_descriptor *pgio, struct inode *inode,
1131 int ioflags,
1132 const struct nfs_pgio_completion_ops *compl_ops)
1129{ 1133{
1130 struct nfs_server *server = NFS_SERVER(inode); 1134 struct nfs_server *server = NFS_SERVER(inode);
1131 struct pnfs_layoutdriver_type *ld = server->pnfs_curr_ld; 1135 struct pnfs_layoutdriver_type *ld = server->pnfs_curr_ld;
1132 1136
1133 if (ld == NULL) 1137 if (ld == NULL)
1134 return false; 1138 return false;
1135 nfs_pageio_init(pgio, inode, ld->pg_write_ops, server->wsize, ioflags); 1139 nfs_pageio_init(pgio, inode, ld->pg_write_ops, compl_ops,
1140 server->wsize, ioflags);
1136 return true; 1141 return true;
1137} 1142}
1138 1143
@@ -1162,13 +1167,15 @@ pnfs_generic_pg_test(struct nfs_pageio_descriptor *pgio, struct nfs_page *prev,
1162} 1167}
1163EXPORT_SYMBOL_GPL(pnfs_generic_pg_test); 1168EXPORT_SYMBOL_GPL(pnfs_generic_pg_test);
1164 1169
1165static int pnfs_write_done_resend_to_mds(struct inode *inode, struct list_head *head) 1170static int pnfs_write_done_resend_to_mds(struct inode *inode,
1171 struct list_head *head,
1172 const struct nfs_pgio_completion_ops *compl_ops)
1166{ 1173{
1167 struct nfs_pageio_descriptor pgio; 1174 struct nfs_pageio_descriptor pgio;
1168 LIST_HEAD(failed); 1175 LIST_HEAD(failed);
1169 1176
1170 /* Resend all requests through the MDS */ 1177 /* Resend all requests through the MDS */
1171 nfs_pageio_init_write_mds(&pgio, inode, FLUSH_STABLE); 1178 nfs_pageio_init_write_mds(&pgio, inode, FLUSH_STABLE, compl_ops);
1172 while (!list_empty(head)) { 1179 while (!list_empty(head)) {
1173 struct nfs_page *req = nfs_list_entry(head->next); 1180 struct nfs_page *req = nfs_list_entry(head->next);
1174 1181
@@ -1201,7 +1208,8 @@ static void pnfs_ld_handle_write_error(struct nfs_write_data *data)
1201 } 1208 }
1202 if (!test_and_set_bit(NFS_IOHDR_REDO, &hdr->flags)) 1209 if (!test_and_set_bit(NFS_IOHDR_REDO, &hdr->flags))
1203 data->task.tk_status = pnfs_write_done_resend_to_mds(hdr->inode, 1210 data->task.tk_status = pnfs_write_done_resend_to_mds(hdr->inode,
1204 &hdr->pages); 1211 &hdr->pages,
1212 hdr->completion_ops);
1205} 1213}
1206 1214
1207/* 1215/*
@@ -1292,7 +1300,7 @@ pnfs_generic_pg_writepages(struct nfs_pageio_descriptor *desc)
1292 1300
1293 whdr = nfs_writehdr_alloc(); 1301 whdr = nfs_writehdr_alloc();
1294 if (!whdr) { 1302 if (!whdr) {
1295 nfs_async_write_error(&desc->pg_list); 1303 desc->pg_completion_ops->error_cleanup(&hdr->pages);
1296 put_lseg(desc->pg_lseg); 1304 put_lseg(desc->pg_lseg);
1297 desc->pg_lseg = NULL; 1305 desc->pg_lseg = NULL;
1298 return -ENOMEM; 1306 return -ENOMEM;
@@ -1309,18 +1317,20 @@ pnfs_generic_pg_writepages(struct nfs_pageio_descriptor *desc)
1309 } else 1317 } else
1310 pnfs_do_multiple_writes(desc, &hdr->rpc_list, desc->pg_ioflags); 1318 pnfs_do_multiple_writes(desc, &hdr->rpc_list, desc->pg_ioflags);
1311 if (atomic_dec_and_test(&hdr->refcnt)) 1319 if (atomic_dec_and_test(&hdr->refcnt))
1312 nfs_write_completion(hdr); 1320 hdr->completion_ops->completion(hdr);
1313 return ret; 1321 return ret;
1314} 1322}
1315EXPORT_SYMBOL_GPL(pnfs_generic_pg_writepages); 1323EXPORT_SYMBOL_GPL(pnfs_generic_pg_writepages);
1316 1324
1317static int pnfs_read_done_resend_to_mds(struct inode *inode, struct list_head *head) 1325static int pnfs_read_done_resend_to_mds(struct inode *inode,
1326 struct list_head *head,
1327 const struct nfs_pgio_completion_ops *compl_ops)
1318{ 1328{
1319 struct nfs_pageio_descriptor pgio; 1329 struct nfs_pageio_descriptor pgio;
1320 LIST_HEAD(failed); 1330 LIST_HEAD(failed);
1321 1331
1322 /* Resend all requests through the MDS */ 1332 /* Resend all requests through the MDS */
1323 nfs_pageio_init_read_mds(&pgio, inode); 1333 nfs_pageio_init_read_mds(&pgio, inode, compl_ops);
1324 while (!list_empty(head)) { 1334 while (!list_empty(head)) {
1325 struct nfs_page *req = nfs_list_entry(head->next); 1335 struct nfs_page *req = nfs_list_entry(head->next);
1326 1336
@@ -1349,7 +1359,8 @@ static void pnfs_ld_handle_read_error(struct nfs_read_data *data)
1349 } 1359 }
1350 if (!test_and_set_bit(NFS_IOHDR_REDO, &hdr->flags)) 1360 if (!test_and_set_bit(NFS_IOHDR_REDO, &hdr->flags))
1351 data->task.tk_status = pnfs_read_done_resend_to_mds(hdr->inode, 1361 data->task.tk_status = pnfs_read_done_resend_to_mds(hdr->inode,
1352 &hdr->pages); 1362 &hdr->pages,
1363 hdr->completion_ops);
1353} 1364}
1354 1365
1355/* 1366/*
@@ -1443,7 +1454,7 @@ pnfs_generic_pg_readpages(struct nfs_pageio_descriptor *desc)
1443 1454
1444 rhdr = nfs_readhdr_alloc(); 1455 rhdr = nfs_readhdr_alloc();
1445 if (!rhdr) { 1456 if (!rhdr) {
1446 nfs_async_read_error(&desc->pg_list); 1457 desc->pg_completion_ops->error_cleanup(&desc->pg_list);
1447 ret = -ENOMEM; 1458 ret = -ENOMEM;
1448 put_lseg(desc->pg_lseg); 1459 put_lseg(desc->pg_lseg);
1449 desc->pg_lseg = NULL; 1460 desc->pg_lseg = NULL;
@@ -1461,7 +1472,7 @@ pnfs_generic_pg_readpages(struct nfs_pageio_descriptor *desc)
1461 } else 1472 } else
1462 pnfs_do_multiple_reads(desc, &hdr->rpc_list); 1473 pnfs_do_multiple_reads(desc, &hdr->rpc_list);
1463 if (atomic_dec_and_test(&hdr->refcnt)) 1474 if (atomic_dec_and_test(&hdr->refcnt))
1464 nfs_read_completion(hdr); 1475 hdr->completion_ops->completion(hdr);
1465 return ret; 1476 return ret;
1466} 1477}
1467EXPORT_SYMBOL_GPL(pnfs_generic_pg_readpages); 1478EXPORT_SYMBOL_GPL(pnfs_generic_pg_readpages);