summaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_sysfs.c
diff options
context:
space:
mode:
authorBill O'Donnell <billodo@redhat.com>2015-10-12 05:15:45 +1100
committerDave Chinner <david@fromorbit.com>2015-10-12 05:15:45 +1100
commitbb230c124730f21eea13deab433f9f8fc96bd5f3 (patch)
treed01a02b30ce4a5aa04a371e416b22f9f6d533217 /fs/xfs/xfs_sysfs.c
parent1f93e4a96c9109378204c147b3eec0d0e8100fde (diff)
downloadlinux-bb230c124730f21eea13deab433f9f8fc96bd5f3.tar.bz2
xfs: create global stats and stats_clear in sysfs
Currently, xfs global stats are in procfs. This patch introduces (replicates) the global stats in sysfs. Additionally a stats_clear file is introduced in sysfs. 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.c75
1 files changed, 75 insertions, 0 deletions
diff --git a/fs/xfs/xfs_sysfs.c b/fs/xfs/xfs_sysfs.c
index aa03670851d8..a094e20f567b 100644
--- a/fs/xfs/xfs_sysfs.c
+++ b/fs/xfs/xfs_sysfs.c
@@ -21,6 +21,7 @@
#include "xfs_log_format.h"
#include "xfs_log.h"
#include "xfs_log_priv.h"
+#include "xfs_stats.h"
struct xfs_sysfs_attr {
struct attribute attr;
@@ -38,6 +39,8 @@ to_attr(struct attribute *attr)
static struct xfs_sysfs_attr xfs_sysfs_attr_##name = __ATTR_RW(name)
#define XFS_SYSFS_ATTR_RO(name) \
static struct xfs_sysfs_attr xfs_sysfs_attr_##name = __ATTR_RO(name)
+#define XFS_SYSFS_ATTR_WO(name) \
+ static struct xfs_sysfs_attr xfs_sysfs_attr_##name = __ATTR_WO(name)
#define ATTR_LIST(name) &xfs_sysfs_attr_##name.attr
@@ -125,6 +128,78 @@ struct kobj_type xfs_dbg_ktype = {
#endif /* DEBUG */
+
+/* stats */
+
+STATIC ssize_t
+stats_show(
+ char *buf,
+ void *data)
+{
+ return xfs_stats_format(buf);
+}
+XFS_SYSFS_ATTR_RO(stats);
+
+STATIC ssize_t
+stats_clear_store(
+ const char *buf,
+ size_t count,
+ void *data)
+{
+ int ret;
+ int val;
+
+ ret = kstrtoint(buf, 0, &val);
+ if (ret)
+ return ret;
+
+ if (val != 1)
+ return -EINVAL;
+ xfs_stats_clearall();
+ return count;
+}
+XFS_SYSFS_ATTR_WO(stats_clear);
+
+static struct attribute *xfs_stats_attrs[] = {
+ ATTR_LIST(stats),
+ ATTR_LIST(stats_clear),
+ NULL,
+};
+
+STATIC ssize_t
+xfs_stats_show(
+ struct kobject *kobject,
+ struct attribute *attr,
+ char *buf)
+{
+ struct xfs_sysfs_attr *xfs_attr = to_attr(attr);
+
+ return xfs_attr->show ? xfs_attr->show(buf, NULL) : 0;
+}
+
+STATIC ssize_t
+xfs_stats_store(
+ struct kobject *kobject,
+ struct attribute *attr,
+ const char *buf,
+ size_t count)
+{
+ struct xfs_sysfs_attr *xfs_attr = to_attr(attr);
+
+ return xfs_attr->store ? xfs_attr->store(buf, count, NULL) : 0;
+}
+
+static struct sysfs_ops xfs_stats_ops = {
+ .show = xfs_stats_show,
+ .store = xfs_stats_store,
+};
+
+struct kobj_type xfs_stats_ktype = {
+ .release = xfs_sysfs_release,
+ .sysfs_ops = &xfs_stats_ops,
+ .default_attrs = xfs_stats_attrs,
+};
+
/* xlog */
STATIC ssize_t