* [PATCH 0/4 V4] xfs: new global stats in sysfs
@ 2015-09-08 15:09 Bill O'Donnell
2015-09-08 15:09 ` [PATCH 1/4] xfs: create global stats and stats_clear " Bill O'Donnell
` (3 more replies)
0 siblings, 4 replies; 9+ messages in thread
From: Bill O'Donnell @ 2015-09-08 15:09 UTC (permalink / raw)
To: xfs
Hi all-
Here is a new pass at the series to add new global stats to sysfs.
The new series now includes a fourth patch that consolidates sysfs
ops for debug, stats and log. (Per Dave Chinner's suggestion to
create a common sysfs_ops structure to help streamline).
The series provides the beginnings of the infrastructure for per-fs
stats (in addition to global accumulative stats).
We already have per-fs information in /sys, so it makes sense to
have per-fs stats there too. As a first step, moving existing
global stats infrastructure to /sys will allow us to re-use that
sysfs code for per-fs stats as well.
Patch 1 handles the bring-up and tear down of xfs/stats directory
structure in sysfs when an fs is mounted. The directory contains
the stats file and the stats_clear file. The stats file contents mimic
those of /proc/fs/xfs/stat. The stats_clear file is empty, and much
like the current stat_clear command, handles the zeroing of the stats
file when a "1" is echoed to the stats_clear file.
Patch 2 creates the symlink for stats from procfs to sysfs.
Patch 3 removes the now unused portions of procfs for stat.
Patch 4 consolidates the sysfs ops for dbg, stats, log.
Once again, comments and questions are welcome.
Thanks-
Bill
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/4] xfs: create global stats and stats_clear in sysfs
2015-09-08 15:09 [PATCH 0/4 V4] xfs: new global stats in sysfs Bill O'Donnell
@ 2015-09-08 15:09 ` Bill O'Donnell
2015-09-08 15:09 ` [PATCH 2/4] xfs: create symlink proc/fs/xfs/stat to sys/fs/xfs/stats Bill O'Donnell
` (2 subsequent siblings)
3 siblings, 0 replies; 9+ messages in thread
From: Bill O'Donnell @ 2015-09-08 15:09 UTC (permalink / raw)
To: xfs
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>
---
fs/xfs/xfs_stats.c | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++
fs/xfs/xfs_stats.h | 2 ++
fs/xfs/xfs_super.c | 20 +++++++++----
fs/xfs/xfs_sysctl.c | 15 ++--------
fs/xfs/xfs_sysfs.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++
fs/xfs/xfs_sysfs.h | 1 +
6 files changed, 179 insertions(+), 17 deletions(-)
diff --git a/fs/xfs/xfs_stats.c b/fs/xfs/xfs_stats.c
index f224038..6008e25 100644
--- a/fs/xfs/xfs_stats.c
+++ b/fs/xfs/xfs_stats.c
@@ -29,6 +29,89 @@ static int counter_val(int idx)
return val;
}
+int xfs_stats_format(char *buf)
+{
+ int i, j;
+ int len = 0;
+ __uint64_t xs_xstrat_bytes = 0;
+ __uint64_t xs_write_bytes = 0;
+ __uint64_t xs_read_bytes = 0;
+
+ static const struct xstats_entry {
+ char *desc;
+ int endpoint;
+ } xstats[] = {
+ { "extent_alloc", XFSSTAT_END_EXTENT_ALLOC },
+ { "abt", XFSSTAT_END_ALLOC_BTREE },
+ { "blk_map", XFSSTAT_END_BLOCK_MAPPING },
+ { "bmbt", XFSSTAT_END_BLOCK_MAP_BTREE },
+ { "dir", XFSSTAT_END_DIRECTORY_OPS },
+ { "trans", XFSSTAT_END_TRANSACTIONS },
+ { "ig", XFSSTAT_END_INODE_OPS },
+ { "log", XFSSTAT_END_LOG_OPS },
+ { "push_ail", XFSSTAT_END_TAIL_PUSHING },
+ { "xstrat", XFSSTAT_END_WRITE_CONVERT },
+ { "rw", XFSSTAT_END_READ_WRITE_OPS },
+ { "attr", XFSSTAT_END_ATTRIBUTE_OPS },
+ { "icluster", XFSSTAT_END_INODE_CLUSTER },
+ { "vnodes", XFSSTAT_END_VNODE_OPS },
+ { "buf", XFSSTAT_END_BUF },
+ { "abtb2", XFSSTAT_END_ABTB_V2 },
+ { "abtc2", XFSSTAT_END_ABTC_V2 },
+ { "bmbt2", XFSSTAT_END_BMBT_V2 },
+ { "ibt2", XFSSTAT_END_IBT_V2 },
+ { "fibt2", XFSSTAT_END_FIBT_V2 },
+ /* we print both series of quota information together */
+ { "qm", XFSSTAT_END_QM },
+ };
+
+ /* Loop over all stats groups */
+
+ for (i = j = 0; i < ARRAY_SIZE(xstats); i++) {
+ len += snprintf(buf + len, PATH_MAX - len, "%s",
+ xstats[i].desc);
+ /* inner loop does each group */
+ for (; j < xstats[i].endpoint; j++)
+ len += snprintf(buf + len, PATH_MAX - len, " %u",
+ counter_val(j));
+ len += snprintf(buf + len, PATH_MAX - len, "\n");
+ }
+ /* extra precision counters */
+ for_each_possible_cpu(i) {
+ xs_xstrat_bytes += per_cpu(xfsstats, i).xs_xstrat_bytes;
+ xs_write_bytes += per_cpu(xfsstats, i).xs_write_bytes;
+ xs_read_bytes += per_cpu(xfsstats, i).xs_read_bytes;
+ }
+
+ len += snprintf(buf+len, PATH_MAX-len, "xpc %Lu %Lu %Lu\n",
+ xs_xstrat_bytes, xs_write_bytes, xs_read_bytes);
+ len += snprintf(buf+len, PATH_MAX-len, "debug %u\n",
+#if defined(DEBUG)
+ 1);
+#else
+ 0);
+#endif
+
+return len;
+}
+
+void xfs_stats_clearall(void)
+{
+ int c;
+ __uint32_t vn_active;
+
+ xfs_notice(NULL, "Clearing xfsstats");
+ for_each_possible_cpu(c) {
+ preempt_disable();
+ /* save vn_active, it's a universal truth! */
+ vn_active = per_cpu(xfsstats, c).vn_active;
+ memset(&per_cpu(xfsstats, c), 0,
+ sizeof(struct xfsstats));
+ per_cpu(xfsstats, c).vn_active = vn_active;
+ preempt_enable();
+ }
+}
+
static int xfs_stat_proc_show(struct seq_file *m, void *v)
{
int i, j;
diff --git a/fs/xfs/xfs_stats.h b/fs/xfs/xfs_stats.h
index c8f238b..18807b5 100644
--- a/fs/xfs/xfs_stats.h
+++ b/fs/xfs/xfs_stats.h
@@ -18,6 +18,8 @@
#ifndef __XFS_STATS_H__
#define __XFS_STATS_H__
+int xfs_stats_format(char *buf);
+void xfs_stats_clearall(void);
#if defined(CONFIG_PROC_FS) && !defined(XFS_STATS_OFF)
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index 3bf503a..31ad281 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -61,6 +61,7 @@ static kmem_zone_t *xfs_ioend_zone;
mempool_t *xfs_ioend_pool;
static struct kset *xfs_kset; /* top-level xfs sysfs dir */
+static struct xfs_kobj xfs_stats_kobj; /* global stats sysfs attrs */
#ifdef DEBUG
static struct xfs_kobj xfs_dbg_kobj; /* global debug sysfs attrs */
#endif
@@ -1838,19 +1839,25 @@ init_xfs_fs(void)
xfs_kset = kset_create_and_add("xfs", NULL, fs_kobj);
if (!xfs_kset) {
error = -ENOMEM;
- goto out_sysctl_unregister;;
+ goto out_sysctl_unregister;
}
+ xfs_stats_kobj.kobject.kset = xfs_kset;
+ error = xfs_sysfs_init(&xfs_stats_kobj, &xfs_stats_ktype, NULL,
+ "stats");
+ if (error)
+ goto out_kset_unregister;
+
#ifdef DEBUG
xfs_dbg_kobj.kobject.kset = xfs_kset;
error = xfs_sysfs_init(&xfs_dbg_kobj, &xfs_dbg_ktype, NULL, "debug");
if (error)
- goto out_kset_unregister;
+ goto out_remove_stats_kobj;
#endif
error = xfs_qm_init();
if (error)
- goto out_remove_kobj;
+ goto out_remove_dbg_kobj;
error = register_filesystem(&xfs_fs_type);
if (error)
@@ -1859,11 +1866,13 @@ init_xfs_fs(void)
out_qm_exit:
xfs_qm_exit();
- out_remove_kobj:
+ out_remove_dbg_kobj:
#ifdef DEBUG
xfs_sysfs_del(&xfs_dbg_kobj);
- out_kset_unregister:
+ out_remove_stats_kobj:
#endif
+ xfs_sysfs_del(&xfs_stats_kobj);
+ out_kset_unregister:
kset_unregister(xfs_kset);
out_sysctl_unregister:
xfs_sysctl_unregister();
@@ -1889,6 +1898,7 @@ exit_xfs_fs(void)
#ifdef DEBUG
xfs_sysfs_del(&xfs_dbg_kobj);
#endif
+ xfs_sysfs_del(&xfs_stats_kobj);
kset_unregister(xfs_kset);
xfs_sysctl_unregister();
xfs_cleanup_procfs();
diff --git a/fs/xfs/xfs_sysctl.c b/fs/xfs/xfs_sysctl.c
index a0c8067..5defabb 100644
--- a/fs/xfs/xfs_sysctl.c
+++ b/fs/xfs/xfs_sysctl.c
@@ -19,6 +19,7 @@
#include <linux/sysctl.h>
#include <linux/proc_fs.h>
#include "xfs_error.h"
+#include "xfs_stats.h"
static struct ctl_table_header *xfs_table_header;
@@ -31,22 +32,12 @@ xfs_stats_clear_proc_handler(
size_t *lenp,
loff_t *ppos)
{
- int c, ret, *valp = ctl->data;
- __uint32_t vn_active;
+ int ret, *valp = ctl->data;
ret = proc_dointvec_minmax(ctl, write, buffer, lenp, ppos);
if (!ret && write && *valp) {
- xfs_notice(NULL, "Clearing xfsstats");
- for_each_possible_cpu(c) {
- preempt_disable();
- /* save vn_active, it's a universal truth! */
- vn_active = per_cpu(xfsstats, c).vn_active;
- memset(&per_cpu(xfsstats, c), 0,
- sizeof(struct xfsstats));
- per_cpu(xfsstats, c).vn_active = vn_active;
- preempt_enable();
- }
+ xfs_stats_clearall();
xfs_stats_clear = 0;
}
diff --git a/fs/xfs/xfs_sysfs.c b/fs/xfs/xfs_sysfs.c
index aa03670..a094e20 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
diff --git a/fs/xfs/xfs_sysfs.h b/fs/xfs/xfs_sysfs.h
index 240eee3..be692e5 100644
--- a/fs/xfs/xfs_sysfs.h
+++ b/fs/xfs/xfs_sysfs.h
@@ -22,6 +22,7 @@
extern struct kobj_type xfs_mp_ktype; /* xfs_mount */
extern struct kobj_type xfs_dbg_ktype; /* debug */
extern struct kobj_type xfs_log_ktype; /* xlog */
+extern struct kobj_type xfs_stats_ktype; /* stats */
static inline struct xfs_kobj *
to_kobj(struct kobject *kobject)
--
2.4.3
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/4] xfs: create symlink proc/fs/xfs/stat to sys/fs/xfs/stats
2015-09-08 15:09 [PATCH 0/4 V4] xfs: new global stats in sysfs Bill O'Donnell
2015-09-08 15:09 ` [PATCH 1/4] xfs: create global stats and stats_clear " Bill O'Donnell
@ 2015-09-08 15:09 ` Bill O'Donnell
2015-09-08 15:09 ` [PATCH 3/4] xfs: remove unused procfs code Bill O'Donnell
2015-09-08 15:09 ` [PATCH 4/4] xfs: consolidate sysfs ops (dbg, stats, log) Bill O'Donnell
3 siblings, 0 replies; 9+ messages in thread
From: Bill O'Donnell @ 2015-09-08 15:09 UTC (permalink / raw)
To: xfs
As a part of the work to move xfs global stats from procfs to sysfs,
this patch creates the symlink from proc/fs/xfs/stat to sys/fs/xfs/stats.
Signed-off-by: Bill O'Donnell <billodo@redhat.com>
---
fs/xfs/xfs_stats.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/fs/xfs/xfs_stats.c b/fs/xfs/xfs_stats.c
index 6008e25..a9f05de 100644
--- a/fs/xfs/xfs_stats.c
+++ b/fs/xfs/xfs_stats.c
@@ -244,9 +244,10 @@ xfs_init_procfs(void)
if (!proc_mkdir("fs/xfs", NULL))
goto out;
- if (!proc_create("fs/xfs/stat", 0, NULL,
- &xfs_stat_proc_fops))
+ if (!proc_symlink("fs/xfs/stat", NULL,
+ "/sys/fs/xfs/stats/stats"))
goto out_remove_xfs_dir;
+
#ifdef CONFIG_XFS_QUOTA
if (!proc_create("fs/xfs/xqmstat", 0, NULL,
&xqmstat_proc_fops))
--
2.4.3
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 3/4] xfs: remove unused procfs code
2015-09-08 15:09 [PATCH 0/4 V4] xfs: new global stats in sysfs Bill O'Donnell
2015-09-08 15:09 ` [PATCH 1/4] xfs: create global stats and stats_clear " Bill O'Donnell
2015-09-08 15:09 ` [PATCH 2/4] xfs: create symlink proc/fs/xfs/stat to sys/fs/xfs/stats Bill O'Donnell
@ 2015-09-08 15:09 ` Bill O'Donnell
2015-09-08 15:09 ` [PATCH 4/4] xfs: consolidate sysfs ops (dbg, stats, log) Bill O'Donnell
3 siblings, 0 replies; 9+ messages in thread
From: Bill O'Donnell @ 2015-09-08 15:09 UTC (permalink / raw)
To: xfs
As a part of the work to move xfs global stats from procfs to sysfs,
this patch removes the now unused procfs code that was xfs stat specific.
Signed-off-by: Bill O'Donnell <billodo@redhat.com>
---
fs/xfs/xfs_stats.c | 74 ------------------------------------------------------
1 file changed, 74 deletions(-)
diff --git a/fs/xfs/xfs_stats.c b/fs/xfs/xfs_stats.c
index a9f05de..05d5227 100644
--- a/fs/xfs/xfs_stats.c
+++ b/fs/xfs/xfs_stats.c
@@ -112,80 +112,6 @@ void xfs_stats_clearall(void)
}
}
-static int xfs_stat_proc_show(struct seq_file *m, void *v)
-{
- int i, j;
- __uint64_t xs_xstrat_bytes = 0;
- __uint64_t xs_write_bytes = 0;
- __uint64_t xs_read_bytes = 0;
-
- static const struct xstats_entry {
- char *desc;
- int endpoint;
- } xstats[] = {
- { "extent_alloc", XFSSTAT_END_EXTENT_ALLOC },
- { "abt", XFSSTAT_END_ALLOC_BTREE },
- { "blk_map", XFSSTAT_END_BLOCK_MAPPING },
- { "bmbt", XFSSTAT_END_BLOCK_MAP_BTREE },
- { "dir", XFSSTAT_END_DIRECTORY_OPS },
- { "trans", XFSSTAT_END_TRANSACTIONS },
- { "ig", XFSSTAT_END_INODE_OPS },
- { "log", XFSSTAT_END_LOG_OPS },
- { "push_ail", XFSSTAT_END_TAIL_PUSHING },
- { "xstrat", XFSSTAT_END_WRITE_CONVERT },
- { "rw", XFSSTAT_END_READ_WRITE_OPS },
- { "attr", XFSSTAT_END_ATTRIBUTE_OPS },
- { "icluster", XFSSTAT_END_INODE_CLUSTER },
- { "vnodes", XFSSTAT_END_VNODE_OPS },
- { "buf", XFSSTAT_END_BUF },
- { "abtb2", XFSSTAT_END_ABTB_V2 },
- { "abtc2", XFSSTAT_END_ABTC_V2 },
- { "bmbt2", XFSSTAT_END_BMBT_V2 },
- { "ibt2", XFSSTAT_END_IBT_V2 },
- { "fibt2", XFSSTAT_END_FIBT_V2 },
- /* we print both series of quota information together */
- { "qm", XFSSTAT_END_QM },
- };
-
- /* Loop over all stats groups */
- for (i = j = 0; i < ARRAY_SIZE(xstats); i++) {
- seq_printf(m, "%s", xstats[i].desc);
- /* inner loop does each group */
- for (; j < xstats[i].endpoint; j++)
- seq_printf(m, " %u", counter_val(j));
- seq_putc(m, '\n');
- }
- /* extra precision counters */
- for_each_possible_cpu(i) {
- xs_xstrat_bytes += per_cpu(xfsstats, i).xs_xstrat_bytes;
- xs_write_bytes += per_cpu(xfsstats, i).xs_write_bytes;
- xs_read_bytes += per_cpu(xfsstats, i).xs_read_bytes;
- }
-
- seq_printf(m, "xpc %Lu %Lu %Lu\n",
- xs_xstrat_bytes, xs_write_bytes, xs_read_bytes);
- seq_printf(m, "debug %u\n",
-#if defined(DEBUG)
- 1);
-#else
- 0);
-#endif
- return 0;
-}
-
-static int xfs_stat_proc_open(struct inode *inode, struct file *file)
-{
- return single_open(file, xfs_stat_proc_show, NULL);
-}
-
-static const struct file_operations xfs_stat_proc_fops = {
- .owner = THIS_MODULE,
- .open = xfs_stat_proc_open,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
-};
-
/* legacy quota interfaces */
#ifdef CONFIG_XFS_QUOTA
static int xqm_proc_show(struct seq_file *m, void *v)
--
2.4.3
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 4/4] xfs: consolidate sysfs ops (dbg, stats, log)
2015-09-08 15:09 [PATCH 0/4 V4] xfs: new global stats in sysfs Bill O'Donnell
` (2 preceding siblings ...)
2015-09-08 15:09 ` [PATCH 3/4] xfs: remove unused procfs code Bill O'Donnell
@ 2015-09-08 15:09 ` Bill O'Donnell
2015-09-08 16:23 ` Brian Foster
3 siblings, 1 reply; 9+ messages in thread
From: Bill O'Donnell @ 2015-09-08 15:09 UTC (permalink / raw)
To: xfs
As a part of the series to move xfs global stats from procfs to sysfs,
this patch consolidates the sysfs ops functions and removes redundancy.
Signed-off-by: Bill O'Donnell <billodo@redhat.com>
---
fs/xfs/xfs_stats.c | 2 +-
fs/xfs/xfs_sysfs.c | 147 ++++++++++++++++++-----------------------------------
2 files changed, 51 insertions(+), 98 deletions(-)
diff --git a/fs/xfs/xfs_stats.c b/fs/xfs/xfs_stats.c
index 05d5227..dc6ca67 100644
--- a/fs/xfs/xfs_stats.c
+++ b/fs/xfs/xfs_stats.c
@@ -92,7 +92,7 @@ int xfs_stats_format(char *buf)
0);
#endif
-return len;
+ return len;
}
void xfs_stats_clearall(void)
diff --git a/fs/xfs/xfs_sysfs.c b/fs/xfs/xfs_sysfs.c
index a094e20..6c44e95 100644
--- a/fs/xfs/xfs_sysfs.c
+++ b/fs/xfs/xfs_sysfs.c
@@ -54,6 +54,53 @@ struct kobj_type xfs_mp_ktype = {
.release = xfs_sysfs_release,
};
+static inline struct xlog *
+to_xlog(struct kobject *kobject)
+{
+ struct xfs_kobj *kobj = to_kobj(kobject);
+ return container_of(kobj, struct xlog, l_kobj);
+}
+
+STATIC ssize_t
+xfs_sysfs_object_show(
+ struct kobject *kobject,
+ struct attribute *attr,
+ char *buf)
+{
+ struct xfs_sysfs_attr *xfs_attr = to_attr(attr);
+ struct kobj_type *ktype = get_ktype(kobject);
+
+ if (ktype == &xfs_log_ktype) {
+ struct xlog *log = to_xlog(kobject);
+ return xfs_attr->show ? xfs_attr->show(buf, log) : 0;
+ }
+ else
+ return xfs_attr->show ? xfs_attr->show(buf, NULL) : 0;
+}
+
+STATIC ssize_t
+xfs_sysfs_object_store(
+ struct kobject *kobject,
+ struct attribute *attr,
+ const char *buf,
+ size_t count)
+{
+ struct xfs_sysfs_attr *xfs_attr = to_attr(attr);
+ struct kobj_type *ktype = get_ktype(kobject);
+
+ if (ktype == &xfs_log_ktype) {
+ struct xlog *log = to_xlog(kobject);
+ return xfs_attr->store ? xfs_attr->store(buf, count, log) : 0;
+ }
+ else
+ return xfs_attr->store ? xfs_attr->store(buf, count, NULL) : 0;
+}
+
+static struct sysfs_ops xfs_sysfs_ops = {
+ .show = xfs_sysfs_object_show,
+ .store = xfs_sysfs_object_store,
+};
+
#ifdef DEBUG
/* debug */
@@ -92,43 +139,14 @@ static struct attribute *xfs_dbg_attrs[] = {
NULL,
};
-STATIC ssize_t
-xfs_dbg_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_dbg_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_dbg_ops = {
- .show = xfs_dbg_show,
- .store = xfs_dbg_store,
-};
-
struct kobj_type xfs_dbg_ktype = {
.release = xfs_sysfs_release,
- .sysfs_ops = &xfs_dbg_ops,
+ .sysfs_ops = &xfs_sysfs_ops,
.default_attrs = xfs_dbg_attrs,
};
#endif /* DEBUG */
-
/* stats */
STATIC ssize_t
@@ -166,37 +184,9 @@ static struct attribute *xfs_stats_attrs[] = {
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,
+ .sysfs_ops = &xfs_sysfs_ops,
.default_attrs = xfs_stats_attrs,
};
@@ -270,45 +260,8 @@ static struct attribute *xfs_log_attrs[] = {
NULL,
};
-static inline struct xlog *
-to_xlog(struct kobject *kobject)
-{
- struct xfs_kobj *kobj = to_kobj(kobject);
- return container_of(kobj, struct xlog, l_kobj);
-}
-
-STATIC ssize_t
-xfs_log_show(
- struct kobject *kobject,
- struct attribute *attr,
- char *buf)
-{
- struct xlog *log = to_xlog(kobject);
- struct xfs_sysfs_attr *xfs_attr = to_attr(attr);
-
- return xfs_attr->show ? xfs_attr->show(buf, log) : 0;
-}
-
-STATIC ssize_t
-xfs_log_store(
- struct kobject *kobject,
- struct attribute *attr,
- const char *buf,
- size_t count)
-{
- struct xlog *log = to_xlog(kobject);
- struct xfs_sysfs_attr *xfs_attr = to_attr(attr);
-
- return xfs_attr->store ? xfs_attr->store(buf, count, log) : 0;
-}
-
-static struct sysfs_ops xfs_log_ops = {
- .show = xfs_log_show,
- .store = xfs_log_store,
-};
-
struct kobj_type xfs_log_ktype = {
.release = xfs_sysfs_release,
- .sysfs_ops = &xfs_log_ops,
+ .sysfs_ops = &xfs_sysfs_ops,
.default_attrs = xfs_log_attrs,
};
--
2.4.3
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 4/4] xfs: consolidate sysfs ops (dbg, stats, log)
2015-09-08 15:09 ` [PATCH 4/4] xfs: consolidate sysfs ops (dbg, stats, log) Bill O'Donnell
@ 2015-09-08 16:23 ` Brian Foster
0 siblings, 0 replies; 9+ messages in thread
From: Brian Foster @ 2015-09-08 16:23 UTC (permalink / raw)
To: Bill O'Donnell; +Cc: xfs
On Tue, Sep 08, 2015 at 10:09:32AM -0500, Bill O'Donnell wrote:
> As a part of the series to move xfs global stats from procfs to sysfs,
> this patch consolidates the sysfs ops functions and removes redundancy.
>
> Signed-off-by: Bill O'Donnell <billodo@redhat.com>
> ---
> fs/xfs/xfs_stats.c | 2 +-
> fs/xfs/xfs_sysfs.c | 147 ++++++++++++++++++-----------------------------------
> 2 files changed, 51 insertions(+), 98 deletions(-)
>
> diff --git a/fs/xfs/xfs_stats.c b/fs/xfs/xfs_stats.c
> index 05d5227..dc6ca67 100644
> --- a/fs/xfs/xfs_stats.c
> +++ b/fs/xfs/xfs_stats.c
> @@ -92,7 +92,7 @@ int xfs_stats_format(char *buf)
> 0);
> #endif
>
> -return len;
> + return len;
Looks like this snuck in from a fix to a previous patch.
> }
>
> void xfs_stats_clearall(void)
> diff --git a/fs/xfs/xfs_sysfs.c b/fs/xfs/xfs_sysfs.c
> index a094e20..6c44e95 100644
> --- a/fs/xfs/xfs_sysfs.c
> +++ b/fs/xfs/xfs_sysfs.c
> @@ -54,6 +54,53 @@ struct kobj_type xfs_mp_ktype = {
> .release = xfs_sysfs_release,
> };
>
> +static inline struct xlog *
> +to_xlog(struct kobject *kobject)
> +{
> + struct xfs_kobj *kobj = to_kobj(kobject);
> + return container_of(kobj, struct xlog, l_kobj);
> +}
> +
> +STATIC ssize_t
> +xfs_sysfs_object_show(
> + struct kobject *kobject,
> + struct attribute *attr,
> + char *buf)
> +{
> + struct xfs_sysfs_attr *xfs_attr = to_attr(attr);
> + struct kobj_type *ktype = get_ktype(kobject);
> +
> + if (ktype == &xfs_log_ktype) {
> + struct xlog *log = to_xlog(kobject);
> + return xfs_attr->show ? xfs_attr->show(buf, log) : 0;
> + }
> + else
> + return xfs_attr->show ? xfs_attr->show(buf, NULL) : 0;
Could we just set a void pointer to the object and not duplicate the
function call? The attribute handler parameter is a void * anyways.
E.g.:
void *data = NULL;
...
if (...)
data = to_xlog(kobject);
return xfs_attr->show ? xfs_attr->show(buf, data) : 0;
(and in the store path as well). Otherwise, looks like a nice cleanup to
me.
Brian
P.S., It's good practice to include a brief, but running changelog in
the cover letter to call out precisely what changed from the previous
version(s) to help out reviewers. For example:
v4:
- Fixed up whitespace in patch N.
- Added patch 4.
...
v3:
...
> +}
> +
> +STATIC ssize_t
> +xfs_sysfs_object_store(
> + struct kobject *kobject,
> + struct attribute *attr,
> + const char *buf,
> + size_t count)
> +{
> + struct xfs_sysfs_attr *xfs_attr = to_attr(attr);
> + struct kobj_type *ktype = get_ktype(kobject);
> +
> + if (ktype == &xfs_log_ktype) {
> + struct xlog *log = to_xlog(kobject);
> + return xfs_attr->store ? xfs_attr->store(buf, count, log) : 0;
> + }
> + else
> + return xfs_attr->store ? xfs_attr->store(buf, count, NULL) : 0;
> +}
> +
> +static struct sysfs_ops xfs_sysfs_ops = {
> + .show = xfs_sysfs_object_show,
> + .store = xfs_sysfs_object_store,
> +};
> +
> #ifdef DEBUG
> /* debug */
>
> @@ -92,43 +139,14 @@ static struct attribute *xfs_dbg_attrs[] = {
> NULL,
> };
>
> -STATIC ssize_t
> -xfs_dbg_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_dbg_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_dbg_ops = {
> - .show = xfs_dbg_show,
> - .store = xfs_dbg_store,
> -};
> -
> struct kobj_type xfs_dbg_ktype = {
> .release = xfs_sysfs_release,
> - .sysfs_ops = &xfs_dbg_ops,
> + .sysfs_ops = &xfs_sysfs_ops,
> .default_attrs = xfs_dbg_attrs,
> };
>
> #endif /* DEBUG */
>
> -
> /* stats */
>
> STATIC ssize_t
> @@ -166,37 +184,9 @@ static struct attribute *xfs_stats_attrs[] = {
> 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,
> + .sysfs_ops = &xfs_sysfs_ops,
> .default_attrs = xfs_stats_attrs,
> };
>
> @@ -270,45 +260,8 @@ static struct attribute *xfs_log_attrs[] = {
> NULL,
> };
>
> -static inline struct xlog *
> -to_xlog(struct kobject *kobject)
> -{
> - struct xfs_kobj *kobj = to_kobj(kobject);
> - return container_of(kobj, struct xlog, l_kobj);
> -}
> -
> -STATIC ssize_t
> -xfs_log_show(
> - struct kobject *kobject,
> - struct attribute *attr,
> - char *buf)
> -{
> - struct xlog *log = to_xlog(kobject);
> - struct xfs_sysfs_attr *xfs_attr = to_attr(attr);
> -
> - return xfs_attr->show ? xfs_attr->show(buf, log) : 0;
> -}
> -
> -STATIC ssize_t
> -xfs_log_store(
> - struct kobject *kobject,
> - struct attribute *attr,
> - const char *buf,
> - size_t count)
> -{
> - struct xlog *log = to_xlog(kobject);
> - struct xfs_sysfs_attr *xfs_attr = to_attr(attr);
> -
> - return xfs_attr->store ? xfs_attr->store(buf, count, log) : 0;
> -}
> -
> -static struct sysfs_ops xfs_log_ops = {
> - .show = xfs_log_show,
> - .store = xfs_log_store,
> -};
> -
> struct kobj_type xfs_log_ktype = {
> .release = xfs_sysfs_release,
> - .sysfs_ops = &xfs_log_ops,
> + .sysfs_ops = &xfs_sysfs_ops,
> .default_attrs = xfs_log_attrs,
> };
> --
> 2.4.3
>
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 4/4] xfs: consolidate sysfs ops (dbg, stats, log)
2015-09-08 17:49 [PATCH 0/4 V5] xfs: new global stats in sysfs Bill O'Donnell
@ 2015-09-08 17:49 ` Bill O'Donnell
2015-09-08 21:06 ` Dave Chinner
0 siblings, 1 reply; 9+ messages in thread
From: Bill O'Donnell @ 2015-09-08 17:49 UTC (permalink / raw)
To: xfs
As a part of the series to move xfs global stats from procfs to sysfs,
this patch consolidates the sysfs ops functions and removes redundancy.
Signed-off-by: Bill O'Donnell <billodo@redhat.com>
---
fs/xfs/xfs_stats.c | 2 +-
fs/xfs/xfs_sysfs.c | 144 +++++++++++++++++------------------------------------
2 files changed, 48 insertions(+), 98 deletions(-)
diff --git a/fs/xfs/xfs_stats.c b/fs/xfs/xfs_stats.c
index 05d5227..dc6ca67 100644
--- a/fs/xfs/xfs_stats.c
+++ b/fs/xfs/xfs_stats.c
@@ -92,7 +92,7 @@ int xfs_stats_format(char *buf)
0);
#endif
-return len;
+ return len;
}
void xfs_stats_clearall(void)
diff --git a/fs/xfs/xfs_sysfs.c b/fs/xfs/xfs_sysfs.c
index a094e20..6fd597b 100644
--- a/fs/xfs/xfs_sysfs.c
+++ b/fs/xfs/xfs_sysfs.c
@@ -54,6 +54,50 @@ struct kobj_type xfs_mp_ktype = {
.release = xfs_sysfs_release,
};
+static inline struct xlog *
+to_xlog(struct kobject *kobject)
+{
+ struct xfs_kobj *kobj = to_kobj(kobject);
+
+ return container_of(kobj, struct xlog, l_kobj);
+}
+
+STATIC ssize_t
+xfs_sysfs_object_show(
+ struct kobject *kobject,
+ struct attribute *attr,
+ char *buf)
+{
+ struct xfs_sysfs_attr *xfs_attr = to_attr(attr);
+ struct kobj_type *ktype = get_ktype(kobject);
+ void *data = NULL;
+
+ if (ktype == &xfs_log_ktype)
+ data = to_xlog(kobject);
+ return xfs_attr->show ? xfs_attr->show(buf, data) : 0;
+}
+
+STATIC ssize_t
+xfs_sysfs_object_store(
+ struct kobject *kobject,
+ struct attribute *attr,
+ const char *buf,
+ size_t count)
+{
+ struct xfs_sysfs_attr *xfs_attr = to_attr(attr);
+ struct kobj_type *ktype = get_ktype(kobject);
+ void *data = NULL;
+
+ if (ktype == &xfs_log_ktype)
+ data = to_xlog(kobject);
+ return xfs_attr->store ? xfs_attr->store(buf, count, data) : 0;
+}
+
+static const struct sysfs_ops xfs_sysfs_ops = {
+ .show = xfs_sysfs_object_show,
+ .store = xfs_sysfs_object_store,
+};
+
#ifdef DEBUG
/* debug */
@@ -92,43 +136,14 @@ static struct attribute *xfs_dbg_attrs[] = {
NULL,
};
-STATIC ssize_t
-xfs_dbg_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_dbg_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_dbg_ops = {
- .show = xfs_dbg_show,
- .store = xfs_dbg_store,
-};
-
struct kobj_type xfs_dbg_ktype = {
.release = xfs_sysfs_release,
- .sysfs_ops = &xfs_dbg_ops,
+ .sysfs_ops = &xfs_sysfs_ops,
.default_attrs = xfs_dbg_attrs,
};
#endif /* DEBUG */
-
/* stats */
STATIC ssize_t
@@ -166,37 +181,9 @@ static struct attribute *xfs_stats_attrs[] = {
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,
+ .sysfs_ops = &xfs_sysfs_ops,
.default_attrs = xfs_stats_attrs,
};
@@ -270,45 +257,8 @@ static struct attribute *xfs_log_attrs[] = {
NULL,
};
-static inline struct xlog *
-to_xlog(struct kobject *kobject)
-{
- struct xfs_kobj *kobj = to_kobj(kobject);
- return container_of(kobj, struct xlog, l_kobj);
-}
-
-STATIC ssize_t
-xfs_log_show(
- struct kobject *kobject,
- struct attribute *attr,
- char *buf)
-{
- struct xlog *log = to_xlog(kobject);
- struct xfs_sysfs_attr *xfs_attr = to_attr(attr);
-
- return xfs_attr->show ? xfs_attr->show(buf, log) : 0;
-}
-
-STATIC ssize_t
-xfs_log_store(
- struct kobject *kobject,
- struct attribute *attr,
- const char *buf,
- size_t count)
-{
- struct xlog *log = to_xlog(kobject);
- struct xfs_sysfs_attr *xfs_attr = to_attr(attr);
-
- return xfs_attr->store ? xfs_attr->store(buf, count, log) : 0;
-}
-
-static struct sysfs_ops xfs_log_ops = {
- .show = xfs_log_show,
- .store = xfs_log_store,
-};
-
struct kobj_type xfs_log_ktype = {
.release = xfs_sysfs_release,
- .sysfs_ops = &xfs_log_ops,
+ .sysfs_ops = &xfs_sysfs_ops,
.default_attrs = xfs_log_attrs,
};
--
2.4.3
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 4/4] xfs: consolidate sysfs ops (dbg, stats, log)
2015-09-08 17:49 ` [PATCH 4/4] xfs: consolidate sysfs ops (dbg, stats, log) Bill O'Donnell
@ 2015-09-08 21:06 ` Dave Chinner
0 siblings, 0 replies; 9+ messages in thread
From: Dave Chinner @ 2015-09-08 21:06 UTC (permalink / raw)
To: Bill O'Donnell; +Cc: xfs
On Tue, Sep 08, 2015 at 12:49:54PM -0500, Bill O'Donnell wrote:
> As a part of the series to move xfs global stats from procfs to sysfs,
> this patch consolidates the sysfs ops functions and removes redundancy.
>
> Signed-off-by: Bill O'Donnell <billodo@redhat.com>
> ---
> fs/xfs/xfs_stats.c | 2 +-
> fs/xfs/xfs_sysfs.c | 144 +++++++++++++++++------------------------------------
> 2 files changed, 48 insertions(+), 98 deletions(-)
>
> diff --git a/fs/xfs/xfs_stats.c b/fs/xfs/xfs_stats.c
> index 05d5227..dc6ca67 100644
> --- a/fs/xfs/xfs_stats.c
> +++ b/fs/xfs/xfs_stats.c
> @@ -92,7 +92,7 @@ int xfs_stats_format(char *buf)
> 0);
> #endif
>
> -return len;
> + return len;
> }
>
> void xfs_stats_clearall(void)
> diff --git a/fs/xfs/xfs_sysfs.c b/fs/xfs/xfs_sysfs.c
> index a094e20..6fd597b 100644
> --- a/fs/xfs/xfs_sysfs.c
> +++ b/fs/xfs/xfs_sysfs.c
> @@ -54,6 +54,50 @@ struct kobj_type xfs_mp_ktype = {
> .release = xfs_sysfs_release,
> };
>
> +static inline struct xlog *
> +to_xlog(struct kobject *kobject)
> +{
> + struct xfs_kobj *kobj = to_kobj(kobject);
> +
> + return container_of(kobj, struct xlog, l_kobj);
> +}
> +
> +STATIC ssize_t
> +xfs_sysfs_object_show(
> + struct kobject *kobject,
> + struct attribute *attr,
> + char *buf)
> +{
> + struct xfs_sysfs_attr *xfs_attr = to_attr(attr);
> + struct kobj_type *ktype = get_ktype(kobject);
> + void *data = NULL;
> +
> + if (ktype == &xfs_log_ktype)
> + data = to_xlog(kobject);
Move the to_xlog(kobject) to the relevant ->show/->store operations
and just pass the kobject to them. Otherwise we'll end up with a lot
of non-generic functionality in these functions.
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 4/4] xfs: consolidate sysfs ops (dbg, stats, log)
2015-09-09 17:06 [PATCH 0/4 v6] xfs: new global stats in sysfs Bill O'Donnell
@ 2015-09-09 17:06 ` Bill O'Donnell
0 siblings, 0 replies; 9+ messages in thread
From: Bill O'Donnell @ 2015-09-09 17:06 UTC (permalink / raw)
To: xfs
As a part of the series to move xfs global stats from procfs to sysfs,
this patch consolidates the sysfs ops functions and removes redundancy.
Signed-off-by: Bill O'Donnell <billodo@redhat.com>
---
fs/xfs/xfs_stats.c | 2 +-
fs/xfs/xfs_sysfs.c | 182 +++++++++++++++++++----------------------------------
2 files changed, 64 insertions(+), 120 deletions(-)
diff --git a/fs/xfs/xfs_stats.c b/fs/xfs/xfs_stats.c
index 05d5227..dc6ca67 100644
--- a/fs/xfs/xfs_stats.c
+++ b/fs/xfs/xfs_stats.c
@@ -92,7 +92,7 @@ int xfs_stats_format(char *buf)
0);
#endif
-return len;
+ return len;
}
void xfs_stats_clearall(void)
diff --git a/fs/xfs/xfs_sysfs.c b/fs/xfs/xfs_sysfs.c
index a094e20..ab4850b 100644
--- a/fs/xfs/xfs_sysfs.c
+++ b/fs/xfs/xfs_sysfs.c
@@ -25,8 +25,9 @@
struct xfs_sysfs_attr {
struct attribute attr;
- ssize_t (*show)(char *buf, void *data);
- ssize_t (*store)(const char *buf, size_t count, void *data);
+ ssize_t (*show)(struct kobject *kobject, char *buf);
+ ssize_t (*store)(struct kobject *kobject, const char *buf,
+ size_t count);
};
static inline struct xfs_sysfs_attr *
@@ -54,14 +55,42 @@ struct kobj_type xfs_mp_ktype = {
.release = xfs_sysfs_release,
};
+STATIC ssize_t
+xfs_sysfs_object_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(kobject, buf) : 0;
+}
+
+STATIC ssize_t
+xfs_sysfs_object_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(kobject, buf, count) : 0;
+}
+
+static const struct sysfs_ops xfs_sysfs_ops = {
+ .show = xfs_sysfs_object_show,
+ .store = xfs_sysfs_object_store,
+};
+
#ifdef DEBUG
/* debug */
STATIC ssize_t
log_recovery_delay_store(
+ struct kobject *kobject,
const char *buf,
- size_t count,
- void *data)
+ size_t count)
{
int ret;
int val;
@@ -80,8 +109,8 @@ log_recovery_delay_store(
STATIC ssize_t
log_recovery_delay_show(
- char *buf,
- void *data)
+ struct kobject *kobject,
+ char *buf)
{
return snprintf(buf, PAGE_SIZE, "%d\n", xfs_globals.log_recovery_delay);
}
@@ -92,49 +121,20 @@ static struct attribute *xfs_dbg_attrs[] = {
NULL,
};
-STATIC ssize_t
-xfs_dbg_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_dbg_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_dbg_ops = {
- .show = xfs_dbg_show,
- .store = xfs_dbg_store,
-};
-
struct kobj_type xfs_dbg_ktype = {
.release = xfs_sysfs_release,
- .sysfs_ops = &xfs_dbg_ops,
+ .sysfs_ops = &xfs_sysfs_ops,
.default_attrs = xfs_dbg_attrs,
};
#endif /* DEBUG */
-
/* stats */
STATIC ssize_t
stats_show(
- char *buf,
- void *data)
+ struct kobject *kobject,
+ char *buf)
{
return xfs_stats_format(buf);
}
@@ -142,9 +142,9 @@ XFS_SYSFS_ATTR_RO(stats);
STATIC ssize_t
stats_clear_store(
+ struct kobject *kobject,
const char *buf,
- size_t count,
- void *data)
+ size_t count)
{
int ret;
int val;
@@ -166,50 +166,30 @@ static struct attribute *xfs_stats_attrs[] = {
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,
+ .sysfs_ops = &xfs_sysfs_ops,
.default_attrs = xfs_stats_attrs,
};
/* xlog */
+static inline struct xlog *
+to_xlog(struct kobject *kobject)
+{
+ struct xfs_kobj *kobj = to_kobj(kobject);
+
+ return container_of(kobj, struct xlog, l_kobj);
+}
+
STATIC ssize_t
log_head_lsn_show(
- char *buf,
- void *data)
+ struct kobject *kobject,
+ char *buf)
{
- struct xlog *log = data;
int cycle;
int block;
+ struct xlog *log = to_xlog(kobject);
spin_lock(&log->l_icloglock);
cycle = log->l_curr_cycle;
@@ -222,12 +202,12 @@ XFS_SYSFS_ATTR_RO(log_head_lsn);
STATIC ssize_t
log_tail_lsn_show(
- char *buf,
- void *data)
+ struct kobject *kobject,
+ char *buf)
{
- struct xlog *log = data;
int cycle;
int block;
+ struct xlog *log = to_xlog(kobject);
xlog_crack_atomic_lsn(&log->l_tail_lsn, &cycle, &block);
return snprintf(buf, PAGE_SIZE, "%d:%d\n", cycle, block);
@@ -236,12 +216,13 @@ XFS_SYSFS_ATTR_RO(log_tail_lsn);
STATIC ssize_t
reserve_grant_head_show(
- char *buf,
- void *data)
+ struct kobject *kobject,
+ char *buf)
+
{
- struct xlog *log = data;
int cycle;
int bytes;
+ struct xlog *log = to_xlog(kobject);
xlog_crack_grant_head(&log->l_reserve_head.grant, &cycle, &bytes);
return snprintf(buf, PAGE_SIZE, "%d:%d\n", cycle, bytes);
@@ -250,12 +231,12 @@ XFS_SYSFS_ATTR_RO(reserve_grant_head);
STATIC ssize_t
write_grant_head_show(
- char *buf,
- void *data)
+ struct kobject *kobject,
+ char *buf)
{
- struct xlog *log = data;
int cycle;
int bytes;
+ struct xlog *log = to_xlog(kobject);
xlog_crack_grant_head(&log->l_write_head.grant, &cycle, &bytes);
return snprintf(buf, PAGE_SIZE, "%d:%d\n", cycle, bytes);
@@ -270,45 +251,8 @@ static struct attribute *xfs_log_attrs[] = {
NULL,
};
-static inline struct xlog *
-to_xlog(struct kobject *kobject)
-{
- struct xfs_kobj *kobj = to_kobj(kobject);
- return container_of(kobj, struct xlog, l_kobj);
-}
-
-STATIC ssize_t
-xfs_log_show(
- struct kobject *kobject,
- struct attribute *attr,
- char *buf)
-{
- struct xlog *log = to_xlog(kobject);
- struct xfs_sysfs_attr *xfs_attr = to_attr(attr);
-
- return xfs_attr->show ? xfs_attr->show(buf, log) : 0;
-}
-
-STATIC ssize_t
-xfs_log_store(
- struct kobject *kobject,
- struct attribute *attr,
- const char *buf,
- size_t count)
-{
- struct xlog *log = to_xlog(kobject);
- struct xfs_sysfs_attr *xfs_attr = to_attr(attr);
-
- return xfs_attr->store ? xfs_attr->store(buf, count, log) : 0;
-}
-
-static struct sysfs_ops xfs_log_ops = {
- .show = xfs_log_show,
- .store = xfs_log_store,
-};
-
struct kobj_type xfs_log_ktype = {
.release = xfs_sysfs_release,
- .sysfs_ops = &xfs_log_ops,
+ .sysfs_ops = &xfs_sysfs_ops,
.default_attrs = xfs_log_attrs,
};
--
2.4.3
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply related [flat|nested] 9+ messages in thread
end of thread, other threads:[~2015-09-09 17:07 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-08 15:09 [PATCH 0/4 V4] xfs: new global stats in sysfs Bill O'Donnell
2015-09-08 15:09 ` [PATCH 1/4] xfs: create global stats and stats_clear " Bill O'Donnell
2015-09-08 15:09 ` [PATCH 2/4] xfs: create symlink proc/fs/xfs/stat to sys/fs/xfs/stats Bill O'Donnell
2015-09-08 15:09 ` [PATCH 3/4] xfs: remove unused procfs code Bill O'Donnell
2015-09-08 15:09 ` [PATCH 4/4] xfs: consolidate sysfs ops (dbg, stats, log) Bill O'Donnell
2015-09-08 16:23 ` Brian Foster
-- strict thread matches above, loose matches on Subject: below --
2015-09-08 17:49 [PATCH 0/4 V5] xfs: new global stats in sysfs Bill O'Donnell
2015-09-08 17:49 ` [PATCH 4/4] xfs: consolidate sysfs ops (dbg, stats, log) Bill O'Donnell
2015-09-08 21:06 ` Dave Chinner
2015-09-09 17:06 [PATCH 0/4 v6] xfs: new global stats in sysfs Bill O'Donnell
2015-09-09 17:06 ` [PATCH 4/4] xfs: consolidate sysfs ops (dbg, stats, log) Bill O'Donnell
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.