summaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_sysfs.c
diff options
context:
space:
mode:
authorBill O'Donnell <billodo@redhat.com>2015-10-11 20:19:45 +0200
committerDave Chinner <david@fromorbit.com>2015-10-11 20:19:45 +0200
commit80529c45ab66188a0b3814ba31409b31f5fcb53d (patch)
treef9de7af29683cb58b16856bea822c3b5c044dd68 /fs/xfs/xfs_sysfs.c
parentxfs: consolidate sysfs ops (diff)
downloadlinux-80529c45ab66188a0b3814ba31409b31f5fcb53d.tar.xz
linux-80529c45ab66188a0b3814ba31409b31f5fcb53d.zip
xfs: pass xfsstats structures to handlers and macros
This patch is the next step toward per-fs xfs stats. The patch makes the show and clear routines able to handle any stats structure associated with a kobject. Instead of a single global xfsstats structure, add kobject and a pointer to a per-cpu struct xfsstats. Modify the macros that manipulate the stats accordingly: XFS_STATS_INC, XFS_STATS_DEC, and XFS_STATS_ADD now access xfsstats->xs_stats. The sysfs functions need to get from the kobject back to the xfsstats structure which contains it, and pass the pointer to the ->xs_stats percpu structure into the show & clear routines. Signed-off-by: Bill O'Donnell <billodo@redhat.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
Diffstat (limited to 'fs/xfs/xfs_sysfs.c')
-rw-r--r--fs/xfs/xfs_sysfs.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/fs/xfs/xfs_sysfs.c b/fs/xfs/xfs_sysfs.c
index fa3dc66d82f1..ee70f5dec9dc 100644
--- a/fs/xfs/xfs_sysfs.c
+++ b/fs/xfs/xfs_sysfs.c
@@ -131,12 +131,22 @@ struct kobj_type xfs_dbg_ktype = {
/* stats */
+static inline struct xstats *
+to_xstats(struct kobject *kobject)
+{
+ struct xfs_kobj *kobj = to_kobj(kobject);
+
+ return container_of(kobj, struct xstats, xs_kobj);
+}
+
STATIC ssize_t
stats_show(
struct kobject *kobject,
char *buf)
{
- return xfs_stats_format(buf);
+ struct xstats *stats = to_xstats(kobject);
+
+ return xfs_stats_format(stats->xs_stats, buf);
}
XFS_SYSFS_ATTR_RO(stats);
@@ -148,6 +158,7 @@ stats_clear_store(
{
int ret;
int val;
+ struct xstats *stats = to_xstats(kobject);
ret = kstrtoint(buf, 0, &val);
if (ret)
@@ -155,7 +166,8 @@ stats_clear_store(
if (val != 1)
return -EINVAL;
- xfs_stats_clearall();
+
+ xfs_stats_clearall(stats->xs_stats);
return count;
}
XFS_SYSFS_ATTR_WO(stats_clear);