aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeng Tao <tao.peng@primarydata.com>2015-06-23 07:52:01 -0400
committerTrond Myklebust <trond.myklebust@primarydata.com>2015-06-24 10:53:11 -0400
commitad4dc53e6496ba0b3c18aeda6f3367d9800b6ebf (patch)
tree911cb79b3c357f8058df5af8288039042f8c82a7
parentd983803d3818a7aef3200147c72a45f573d84537 (diff)
pnfs/flexfiles: add ff_layout_prepare_layoutstats
It fills in the generic part of LAYOUTSTATS call. One thing to note is that we don't really track if IO is continuous or not. So just fake to use the completed bytes for it. Still missing flexfiles specific part, which will be included in the next patch. Reviewed-by: Jeff Layton <jeff.layton@primarydata.com> Signed-off-by: Peng Tao <tao.peng@primarydata.com> Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
-rw-r--r--fs/nfs/flexfilelayout/flexfilelayout.c71
1 files changed, 71 insertions, 0 deletions
diff --git a/fs/nfs/flexfilelayout/flexfilelayout.c b/fs/nfs/flexfilelayout/flexfilelayout.c
index 4215278c9c76..cd999af504d9 100644
--- a/fs/nfs/flexfilelayout/flexfilelayout.c
+++ b/fs/nfs/flexfilelayout/flexfilelayout.c
@@ -20,6 +20,7 @@
20#include "../nfs4trace.h" 20#include "../nfs4trace.h"
21#include "../iostat.h" 21#include "../iostat.h"
22#include "../nfs.h" 22#include "../nfs.h"
23#include "../nfs42.h"
23 24
24#define NFSDBG_FACILITY NFSDBG_PNFS_LD 25#define NFSDBG_FACILITY NFSDBG_PNFS_LD
25 26
@@ -1659,6 +1660,75 @@ out:
1659 dprintk("%s: Return\n", __func__); 1660 dprintk("%s: Return\n", __func__);
1660} 1661}
1661 1662
1663static bool
1664ff_layout_mirror_prepare_stats(struct nfs42_layoutstat_args *args,
1665 struct pnfs_layout_segment *pls,
1666 int *dev_count, int dev_limit)
1667{
1668 struct nfs4_ff_layout_mirror *mirror;
1669 struct nfs4_deviceid_node *dev;
1670 struct nfs42_layoutstat_devinfo *devinfo;
1671 int i;
1672
1673 for (i = 0; i <= FF_LAYOUT_MIRROR_COUNT(pls); i++) {
1674 if (*dev_count >= dev_limit)
1675 break;
1676 mirror = FF_LAYOUT_COMP(pls, i);
1677 dev = FF_LAYOUT_DEVID_NODE(pls, i);
1678 devinfo = &args->devinfo[*dev_count];
1679 memcpy(&devinfo->dev_id, &dev->deviceid, NFS4_DEVICEID4_SIZE);
1680 devinfo->offset = pls->pls_range.offset;
1681 devinfo->length = pls->pls_range.length;
1682 /* well, we don't really know if IO is continuous or not! */
1683 devinfo->read_count = mirror->read_stat.io_stat.bytes_completed;
1684 devinfo->read_bytes = mirror->read_stat.io_stat.bytes_completed;
1685 devinfo->write_count = mirror->write_stat.io_stat.bytes_completed;
1686 devinfo->write_bytes = mirror->write_stat.io_stat.bytes_completed;
1687 devinfo->layout_type = LAYOUT_FLEX_FILES;
1688 devinfo->layoutstats_encode = NULL;
1689 devinfo->layout_private = NULL;
1690
1691 ++(*dev_count);
1692 }
1693
1694 return *dev_count < dev_limit;
1695}
1696
1697static int
1698ff_layout_prepare_layoutstats(struct nfs42_layoutstat_args *args)
1699{
1700 struct pnfs_layout_segment *pls;
1701 int dev_count = 0;
1702
1703 spin_lock(&args->inode->i_lock);
1704 list_for_each_entry(pls, &NFS_I(args->inode)->layout->plh_segs, pls_list) {
1705 dev_count += FF_LAYOUT_MIRROR_COUNT(pls);
1706 }
1707 spin_unlock(&args->inode->i_lock);
1708 /* For now, send at most PNFS_LAYOUTSTATS_MAXDEV statistics */
1709 if (dev_count > PNFS_LAYOUTSTATS_MAXDEV) {
1710 dprintk("%s: truncating devinfo to limit (%d:%d)\n",
1711 __func__, dev_count, PNFS_LAYOUTSTATS_MAXDEV);
1712 dev_count = PNFS_LAYOUTSTATS_MAXDEV;
1713 }
1714 args->devinfo = kmalloc(dev_count * sizeof(*args->devinfo), GFP_KERNEL);
1715 if (!args->devinfo)
1716 return -ENOMEM;
1717
1718 dev_count = 0;
1719 spin_lock(&args->inode->i_lock);
1720 list_for_each_entry(pls, &NFS_I(args->inode)->layout->plh_segs, pls_list) {
1721 if (!ff_layout_mirror_prepare_stats(args, pls, &dev_count,
1722 PNFS_LAYOUTSTATS_MAXDEV)) {
1723 break;
1724 }
1725 }
1726 spin_unlock(&args->inode->i_lock);
1727 args->num_dev = dev_count;
1728
1729 return 0;
1730}
1731
1662static struct pnfs_layoutdriver_type flexfilelayout_type = { 1732static struct pnfs_layoutdriver_type flexfilelayout_type = {
1663 .id = LAYOUT_FLEX_FILES, 1733 .id = LAYOUT_FLEX_FILES,
1664 .name = "LAYOUT_FLEX_FILES", 1734 .name = "LAYOUT_FLEX_FILES",
@@ -1681,6 +1751,7 @@ static struct pnfs_layoutdriver_type flexfilelayout_type = {
1681 .alloc_deviceid_node = ff_layout_alloc_deviceid_node, 1751 .alloc_deviceid_node = ff_layout_alloc_deviceid_node,
1682 .encode_layoutreturn = ff_layout_encode_layoutreturn, 1752 .encode_layoutreturn = ff_layout_encode_layoutreturn,
1683 .sync = pnfs_nfs_generic_sync, 1753 .sync = pnfs_nfs_generic_sync,
1754 .prepare_layoutstats = ff_layout_prepare_layoutstats,
1684}; 1755};
1685 1756
1686static int __init nfs4flexfilelayout_init(void) 1757static int __init nfs4flexfilelayout_init(void)