diff options
author | Trond Myklebust <trond.myklebust@primarydata.com> | 2015-12-22 12:30:24 -0500 |
---|---|---|
committer | Trond Myklebust <trond.myklebust@primarydata.com> | 2015-12-28 14:32:41 -0500 |
commit | 37e9ed22b1552fa94ee7db2901a5e7d8bdf60b15 (patch) | |
tree | 20dee7aec9c90350526b1b47c8af10ad1378bbac /fs/nfs | |
parent | 7eeea1679783e7c1c38074e8c562900b7e3d3dd7 (diff) |
pNFS: Add flag to track if we've called nfs4_ff_layout_stat_io_start_read/write
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Diffstat (limited to 'fs/nfs')
-rw-r--r-- | fs/nfs/flexfilelayout/flexfilelayout.c | 95 |
1 files changed, 70 insertions, 25 deletions
diff --git a/fs/nfs/flexfilelayout/flexfilelayout.c b/fs/nfs/flexfilelayout/flexfilelayout.c index 14109a82ce84..9257679a15ba 100644 --- a/fs/nfs/flexfilelayout/flexfilelayout.c +++ b/fs/nfs/flexfilelayout/flexfilelayout.c | |||
@@ -1279,14 +1279,31 @@ ff_layout_reset_to_mds(struct pnfs_layout_segment *lseg, int idx) | |||
1279 | return ff_layout_test_devid_unavailable(node); | 1279 | return ff_layout_test_devid_unavailable(node); |
1280 | } | 1280 | } |
1281 | 1281 | ||
1282 | static int ff_layout_read_prepare_common(struct rpc_task *task, | 1282 | static void ff_layout_read_record_layoutstats_start(struct rpc_task *task, |
1283 | struct nfs_pgio_header *hdr) | 1283 | struct nfs_pgio_header *hdr) |
1284 | { | 1284 | { |
1285 | if (test_and_set_bit(NFS_IOHDR_STAT, &hdr->flags)) | ||
1286 | return; | ||
1285 | nfs4_ff_layout_stat_io_start_read(hdr->inode, | 1287 | nfs4_ff_layout_stat_io_start_read(hdr->inode, |
1286 | FF_LAYOUT_COMP(hdr->lseg, hdr->pgio_mirror_idx), | 1288 | FF_LAYOUT_COMP(hdr->lseg, hdr->pgio_mirror_idx), |
1287 | hdr->args.count, | 1289 | hdr->args.count, |
1288 | task->tk_start); | 1290 | task->tk_start); |
1291 | } | ||
1292 | |||
1293 | static void ff_layout_read_record_layoutstats_done(struct rpc_task *task, | ||
1294 | struct nfs_pgio_header *hdr) | ||
1295 | { | ||
1296 | if (!test_and_clear_bit(NFS_IOHDR_STAT, &hdr->flags)) | ||
1297 | return; | ||
1298 | nfs4_ff_layout_stat_io_end_read(task, | ||
1299 | FF_LAYOUT_COMP(hdr->lseg, hdr->pgio_mirror_idx), | ||
1300 | hdr->args.count, | ||
1301 | hdr->res.count); | ||
1302 | } | ||
1289 | 1303 | ||
1304 | static int ff_layout_read_prepare_common(struct rpc_task *task, | ||
1305 | struct nfs_pgio_header *hdr) | ||
1306 | { | ||
1290 | if (unlikely(test_bit(NFS_CONTEXT_BAD, &hdr->args.context->flags))) { | 1307 | if (unlikely(test_bit(NFS_CONTEXT_BAD, &hdr->args.context->flags))) { |
1291 | rpc_exit(task, -EIO); | 1308 | rpc_exit(task, -EIO); |
1292 | return -EIO; | 1309 | return -EIO; |
@@ -1302,6 +1319,7 @@ static int ff_layout_read_prepare_common(struct rpc_task *task, | |||
1302 | } | 1319 | } |
1303 | hdr->pgio_done_cb = ff_layout_read_done_cb; | 1320 | hdr->pgio_done_cb = ff_layout_read_done_cb; |
1304 | 1321 | ||
1322 | ff_layout_read_record_layoutstats_start(task, hdr); | ||
1305 | return 0; | 1323 | return 0; |
1306 | } | 1324 | } |
1307 | 1325 | ||
@@ -1360,10 +1378,6 @@ static void ff_layout_read_call_done(struct rpc_task *task, void *data) | |||
1360 | 1378 | ||
1361 | dprintk("--> %s task->tk_status %d\n", __func__, task->tk_status); | 1379 | dprintk("--> %s task->tk_status %d\n", __func__, task->tk_status); |
1362 | 1380 | ||
1363 | nfs4_ff_layout_stat_io_end_read(task, | ||
1364 | FF_LAYOUT_COMP(hdr->lseg, hdr->pgio_mirror_idx), | ||
1365 | hdr->args.count, hdr->res.count); | ||
1366 | |||
1367 | if (test_bit(NFS_IOHDR_REDO, &hdr->flags) && | 1381 | if (test_bit(NFS_IOHDR_REDO, &hdr->flags) && |
1368 | task->tk_status == 0) { | 1382 | task->tk_status == 0) { |
1369 | nfs4_sequence_done(task, &hdr->res.seq_res); | 1383 | nfs4_sequence_done(task, &hdr->res.seq_res); |
@@ -1378,6 +1392,7 @@ static void ff_layout_read_count_stats(struct rpc_task *task, void *data) | |||
1378 | { | 1392 | { |
1379 | struct nfs_pgio_header *hdr = data; | 1393 | struct nfs_pgio_header *hdr = data; |
1380 | 1394 | ||
1395 | ff_layout_read_record_layoutstats_done(task, hdr); | ||
1381 | rpc_count_iostats_metrics(task, | 1396 | rpc_count_iostats_metrics(task, |
1382 | &NFS_CLIENT(hdr->inode)->cl_metrics[NFSPROC4_CLNT_READ]); | 1397 | &NFS_CLIENT(hdr->inode)->cl_metrics[NFSPROC4_CLNT_READ]); |
1383 | } | 1398 | } |
@@ -1453,14 +1468,31 @@ static int ff_layout_commit_done_cb(struct rpc_task *task, | |||
1453 | return 0; | 1468 | return 0; |
1454 | } | 1469 | } |
1455 | 1470 | ||
1456 | static int ff_layout_write_prepare_common(struct rpc_task *task, | 1471 | static void ff_layout_write_record_layoutstats_start(struct rpc_task *task, |
1457 | struct nfs_pgio_header *hdr) | 1472 | struct nfs_pgio_header *hdr) |
1458 | { | 1473 | { |
1474 | if (test_and_set_bit(NFS_IOHDR_STAT, &hdr->flags)) | ||
1475 | return; | ||
1459 | nfs4_ff_layout_stat_io_start_write(hdr->inode, | 1476 | nfs4_ff_layout_stat_io_start_write(hdr->inode, |
1460 | FF_LAYOUT_COMP(hdr->lseg, hdr->pgio_mirror_idx), | 1477 | FF_LAYOUT_COMP(hdr->lseg, hdr->pgio_mirror_idx), |
1461 | hdr->args.count, | 1478 | hdr->args.count, |
1462 | task->tk_start); | 1479 | task->tk_start); |
1480 | } | ||
1481 | |||
1482 | static void ff_layout_write_record_layoutstats_done(struct rpc_task *task, | ||
1483 | struct nfs_pgio_header *hdr) | ||
1484 | { | ||
1485 | if (!test_and_clear_bit(NFS_IOHDR_STAT, &hdr->flags)) | ||
1486 | return; | ||
1487 | nfs4_ff_layout_stat_io_end_write(task, | ||
1488 | FF_LAYOUT_COMP(hdr->lseg, hdr->pgio_mirror_idx), | ||
1489 | hdr->args.count, hdr->res.count, | ||
1490 | hdr->res.verf->committed); | ||
1491 | } | ||
1463 | 1492 | ||
1493 | static int ff_layout_write_prepare_common(struct rpc_task *task, | ||
1494 | struct nfs_pgio_header *hdr) | ||
1495 | { | ||
1464 | if (unlikely(test_bit(NFS_CONTEXT_BAD, &hdr->args.context->flags))) { | 1496 | if (unlikely(test_bit(NFS_CONTEXT_BAD, &hdr->args.context->flags))) { |
1465 | rpc_exit(task, -EIO); | 1497 | rpc_exit(task, -EIO); |
1466 | return -EIO; | 1498 | return -EIO; |
@@ -1477,6 +1509,7 @@ static int ff_layout_write_prepare_common(struct rpc_task *task, | |||
1477 | return -EAGAIN; | 1509 | return -EAGAIN; |
1478 | } | 1510 | } |
1479 | 1511 | ||
1512 | ff_layout_write_record_layoutstats_start(task, hdr); | ||
1480 | return 0; | 1513 | return 0; |
1481 | } | 1514 | } |
1482 | 1515 | ||
@@ -1526,23 +1559,45 @@ static void ff_layout_write_count_stats(struct rpc_task *task, void *data) | |||
1526 | { | 1559 | { |
1527 | struct nfs_pgio_header *hdr = data; | 1560 | struct nfs_pgio_header *hdr = data; |
1528 | 1561 | ||
1529 | nfs4_ff_layout_stat_io_end_write(task, | 1562 | ff_layout_write_record_layoutstats_done(task, hdr); |
1530 | FF_LAYOUT_COMP(hdr->lseg, hdr->pgio_mirror_idx), | ||
1531 | hdr->args.count, hdr->res.count, | ||
1532 | hdr->res.verf->committed); | ||
1533 | |||
1534 | rpc_count_iostats_metrics(task, | 1563 | rpc_count_iostats_metrics(task, |
1535 | &NFS_CLIENT(hdr->inode)->cl_metrics[NFSPROC4_CLNT_WRITE]); | 1564 | &NFS_CLIENT(hdr->inode)->cl_metrics[NFSPROC4_CLNT_WRITE]); |
1536 | } | 1565 | } |
1537 | 1566 | ||
1538 | static void ff_layout_commit_prepare_common(struct rpc_task *task, | 1567 | static void ff_layout_commit_record_layoutstats_start(struct rpc_task *task, |
1539 | struct nfs_commit_data *cdata) | 1568 | struct nfs_commit_data *cdata) |
1540 | { | 1569 | { |
1570 | if (test_and_set_bit(NFS_IOHDR_STAT, &cdata->flags)) | ||
1571 | return; | ||
1541 | nfs4_ff_layout_stat_io_start_write(cdata->inode, | 1572 | nfs4_ff_layout_stat_io_start_write(cdata->inode, |
1542 | FF_LAYOUT_COMP(cdata->lseg, cdata->ds_commit_index), | 1573 | FF_LAYOUT_COMP(cdata->lseg, cdata->ds_commit_index), |
1543 | 0, task->tk_start); | 1574 | 0, task->tk_start); |
1544 | } | 1575 | } |
1545 | 1576 | ||
1577 | static void ff_layout_commit_record_layoutstats_done(struct rpc_task *task, | ||
1578 | struct nfs_commit_data *cdata) | ||
1579 | { | ||
1580 | struct nfs_page *req; | ||
1581 | __u64 count = 0; | ||
1582 | |||
1583 | if (!test_and_clear_bit(NFS_IOHDR_STAT, &cdata->flags)) | ||
1584 | return; | ||
1585 | |||
1586 | if (task->tk_status == 0) { | ||
1587 | list_for_each_entry(req, &cdata->pages, wb_list) | ||
1588 | count += req->wb_bytes; | ||
1589 | } | ||
1590 | nfs4_ff_layout_stat_io_end_write(task, | ||
1591 | FF_LAYOUT_COMP(cdata->lseg, cdata->ds_commit_index), | ||
1592 | count, count, NFS_FILE_SYNC); | ||
1593 | } | ||
1594 | |||
1595 | static void ff_layout_commit_prepare_common(struct rpc_task *task, | ||
1596 | struct nfs_commit_data *cdata) | ||
1597 | { | ||
1598 | ff_layout_commit_record_layoutstats_start(task, cdata); | ||
1599 | } | ||
1600 | |||
1546 | static void ff_layout_commit_prepare_v3(struct rpc_task *task, void *data) | 1601 | static void ff_layout_commit_prepare_v3(struct rpc_task *task, void *data) |
1547 | { | 1602 | { |
1548 | ff_layout_commit_prepare_common(task, data); | 1603 | ff_layout_commit_prepare_common(task, data); |
@@ -1569,18 +1624,8 @@ static void ff_layout_commit_done(struct rpc_task *task, void *data) | |||
1569 | static void ff_layout_commit_count_stats(struct rpc_task *task, void *data) | 1624 | static void ff_layout_commit_count_stats(struct rpc_task *task, void *data) |
1570 | { | 1625 | { |
1571 | struct nfs_commit_data *cdata = data; | 1626 | struct nfs_commit_data *cdata = data; |
1572 | struct nfs_page *req; | ||
1573 | __u64 count = 0; | ||
1574 | |||
1575 | if (task->tk_status == 0) { | ||
1576 | list_for_each_entry(req, &cdata->pages, wb_list) | ||
1577 | count += req->wb_bytes; | ||
1578 | } | ||
1579 | |||
1580 | nfs4_ff_layout_stat_io_end_write(task, | ||
1581 | FF_LAYOUT_COMP(cdata->lseg, cdata->ds_commit_index), | ||
1582 | count, count, NFS_FILE_SYNC); | ||
1583 | 1627 | ||
1628 | ff_layout_commit_record_layoutstats_done(task, cdata); | ||
1584 | rpc_count_iostats_metrics(task, | 1629 | rpc_count_iostats_metrics(task, |
1585 | &NFS_CLIENT(cdata->inode)->cl_metrics[NFSPROC4_CLNT_COMMIT]); | 1630 | &NFS_CLIENT(cdata->inode)->cl_metrics[NFSPROC4_CLNT_COMMIT]); |
1586 | } | 1631 | } |