]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
xfs: per-filesystem stats in sysfs
authorBill O'Donnell <billodo@redhat.com>
Mon, 12 Oct 2015 07:21:19 +0000 (18:21 +1100)
committerDan Duval <dan.duval@oracle.com>
Wed, 7 Dec 2016 17:25:58 +0000 (12:25 -0500)
Orabug: 22913653

This patch implements per-filesystem stats objects in sysfs. It
depends on the application of the previous patch series that
develops the infrastructure to support both xfs global stats and
xfs per-fs stats in sysfs.

Stats objects are instantiated when an xfs filesystem is mounted
and deleted on unmount. With this patch, the stats directory is
created and populated with the familiar stats and stats_clear files.
Example:
        /sys/fs/xfs/sda9/stats/stats
        /sys/fs/xfs/sda9/stats/stats_clear

With this patch, the individual counts within the new per-fs
stats file(s) remain at zero. Functions that use the the macros
to increment, decrement, and add-to the per-fs stats counts will
be covered in a separate new patch to follow this one. Note that
the counts within the global stats file (/sys/fs/xfs/stats/stats)
advance normally and can be cleared as it was prior to this patch.

[dchinner: move setup/teardown to xfs_fs_{fill|put}_super() so
it is down before/after any path that uses the per-mount stats. ]

Signed-off-by: Bill O'Donnell <billodo@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
(cherry picked from commit 225e4635580ce9fb12f8a2dc88473161cd64dbf6)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
fs/xfs/xfs_mount.c
fs/xfs/xfs_mount.h
fs/xfs/xfs_super.c

index 6f23fbdfb365adca1571eadece38b77a619c50ad..f210c0fb6d012632439e1d2806f0ee65b48f83b1 100644 (file)
@@ -693,10 +693,15 @@ xfs_mountfs(
        if (error)
                goto out;
 
-       error = xfs_uuid_mount(mp);
+       error = xfs_sysfs_init(&mp->m_stats.xs_kobj, &xfs_stats_ktype,
+                              &mp->m_kobj, "stats");
        if (error)
                goto out_remove_sysfs;
 
+       error = xfs_uuid_mount(mp);
+       if (error)
+               goto out_del_stats;
+
        /*
         * Set the minimum read and write sizes
         */
@@ -951,6 +956,8 @@ xfs_mountfs(
        xfs_da_unmount(mp);
  out_remove_uuid:
        xfs_uuid_unmount(mp);
+ out_del_stats:
+       xfs_sysfs_del(&mp->m_stats.xs_kobj);
  out_remove_sysfs:
        xfs_sysfs_del(&mp->m_kobj);
  out:
@@ -1027,6 +1034,7 @@ xfs_unmountfs(
                xfs_warn(mp, "Unable to update superblock counters. "
                                "Freespace may not be correct on next mount.");
 
+
        xfs_log_unmount(mp);
        xfs_da_unmount(mp);
        xfs_uuid_unmount(mp);
@@ -1036,6 +1044,7 @@ xfs_unmountfs(
 #endif
        xfs_free_perag(mp);
 
+       xfs_sysfs_del(&mp->m_stats.xs_kobj);
        xfs_sysfs_del(&mp->m_kobj);
 }
 
index ae28efc44ab30cb5b72ed9c76f68e4f0c4553423..d43a804309844728dc3fb6780fa6fd94b84c2d3d 100644 (file)
@@ -125,6 +125,7 @@ typedef struct xfs_mount {
        int64_t                 m_low_space[XFS_LOWSP_MAX];
                                                /* low free space thresholds */
        struct xfs_kobj         m_kobj;
+       struct xstats           m_stats;        /* per-fs stats */
 
        struct workqueue_struct *m_buf_workqueue;
        struct workqueue_struct *m_data_workqueue;
index a873ab26a605fb53c64b5da51ba4b8f7006069de..5f2ef9d6608a7fce20f94297f56b00cc2e1aa3b9 100644 (file)
@@ -1482,9 +1482,16 @@ xfs_fs_fill_super(
        if (error)
                goto out_destroy_workqueues;
 
+       /* Allocate stats memory before we do operations that might use it */
+       mp->m_stats.xs_stats = alloc_percpu(struct xfsstats);
+       if (!mp->m_stats.xs_stats) {
+               error = PTR_ERR(mp->m_stats.xs_stats);
+               goto out_destroy_counters;
+       }
+
        error = xfs_readsb(mp, flags);
        if (error)
-               goto out_destroy_counters;
+               goto out_free_stats;
 
        error = xfs_finish_flags(mp);
        if (error)
@@ -1549,9 +1556,11 @@ xfs_fs_fill_super(
        xfs_filestream_unmount(mp);
  out_free_sb:
        xfs_freesb(mp);
+ out_free_stats:
+       free_percpu(mp->m_stats.xs_stats);
  out_destroy_counters:
        xfs_destroy_percpu_counters(mp);
-out_destroy_workqueues:
+ out_destroy_workqueues:
        xfs_destroy_mount_workqueues(mp);
  out_close_devices:
        xfs_close_devices(mp);
@@ -1578,6 +1587,7 @@ xfs_fs_put_super(
        xfs_unmountfs(mp);
 
        xfs_freesb(mp);
+       free_percpu(mp->m_stats.xs_stats);
        xfs_destroy_percpu_counters(mp);
        xfs_destroy_mount_workqueues(mp);
        xfs_close_devices(mp);