aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Foster <bfoster@redhat.com>2014-09-08 21:52:42 -0400
committerDave Chinner <david@fromorbit.com>2014-09-08 21:52:42 -0400
commit65b65735fede29b516fed1d8c2391e8bc373b805 (patch)
tree841419a2f24fe12359ff4602ae26885667891efd
parente1b05723ed834090caab56866adc05bce31c9bdd (diff)
xfs: add debug sysfs attribute set
Create a top-level debug directory for global debug sysfs attributes. This directory is added and removed on XFS module initialization and removal respectively for DEBUG mode kernels only. It typically resides at /sys/fs/xfs/debug. It is located at the top level of the xfs sysfs hierarchy as attributes might define global behavior or behavior that must be configured before an xfs mount is available (e.g., log recovery behavior). Define the global debug kobject that represents the debug sysfs directory and add generic attribute show/store helpers to support future attributes. No debug attributes are exported as of yet. Signed-off-by: Brian Foster <bfoster@redhat.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
-rw-r--r--fs/xfs/xfs_super.c23
-rw-r--r--fs/xfs/xfs_sysfs.c43
-rw-r--r--fs/xfs/xfs_sysfs.h1
3 files changed, 65 insertions, 2 deletions
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index bc9ec44cae45..dcd4b93dccdc 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -47,6 +47,7 @@
47#include "xfs_dinode.h" 47#include "xfs_dinode.h"
48#include "xfs_filestream.h" 48#include "xfs_filestream.h"
49#include "xfs_quota.h" 49#include "xfs_quota.h"
50#include "xfs_sysfs.h"
50 51
51#include <linux/namei.h> 52#include <linux/namei.h>
52#include <linux/init.h> 53#include <linux/init.h>
@@ -61,7 +62,11 @@
61static const struct super_operations xfs_super_operations; 62static const struct super_operations xfs_super_operations;
62static kmem_zone_t *xfs_ioend_zone; 63static kmem_zone_t *xfs_ioend_zone;
63mempool_t *xfs_ioend_pool; 64mempool_t *xfs_ioend_pool;
64struct kset *xfs_kset; 65
66struct kset *xfs_kset; /* top-level xfs sysfs dir */
67#ifdef DEBUG
68static struct xfs_kobj xfs_dbg_kobj; /* global debug sysfs attrs */
69#endif
65 70
66#define MNTOPT_LOGBUFS "logbufs" /* number of XFS log buffers */ 71#define MNTOPT_LOGBUFS "logbufs" /* number of XFS log buffers */
67#define MNTOPT_LOGBSIZE "logbsize" /* size of XFS log buffers */ 72#define MNTOPT_LOGBSIZE "logbsize" /* size of XFS log buffers */
@@ -1769,9 +1774,16 @@ init_xfs_fs(void)
1769 goto out_sysctl_unregister;; 1774 goto out_sysctl_unregister;;
1770 } 1775 }
1771 1776
1772 error = xfs_qm_init(); 1777#ifdef DEBUG
1778 xfs_dbg_kobj.kobject.kset = xfs_kset;
1779 error = xfs_sysfs_init(&xfs_dbg_kobj, &xfs_dbg_ktype, NULL, "debug");
1773 if (error) 1780 if (error)
1774 goto out_kset_unregister; 1781 goto out_kset_unregister;
1782#endif
1783
1784 error = xfs_qm_init();
1785 if (error)
1786 goto out_remove_kobj;
1775 1787
1776 error = register_filesystem(&xfs_fs_type); 1788 error = register_filesystem(&xfs_fs_type);
1777 if (error) 1789 if (error)
@@ -1780,7 +1792,11 @@ init_xfs_fs(void)
1780 1792
1781 out_qm_exit: 1793 out_qm_exit:
1782 xfs_qm_exit(); 1794 xfs_qm_exit();
1795 out_remove_kobj:
1796#ifdef DEBUG
1797 xfs_sysfs_del(&xfs_dbg_kobj);
1783 out_kset_unregister: 1798 out_kset_unregister:
1799#endif
1784 kset_unregister(xfs_kset); 1800 kset_unregister(xfs_kset);
1785 out_sysctl_unregister: 1801 out_sysctl_unregister:
1786 xfs_sysctl_unregister(); 1802 xfs_sysctl_unregister();
@@ -1803,6 +1819,9 @@ exit_xfs_fs(void)
1803{ 1819{
1804 xfs_qm_exit(); 1820 xfs_qm_exit();
1805 unregister_filesystem(&xfs_fs_type); 1821 unregister_filesystem(&xfs_fs_type);
1822#ifdef DEBUG
1823 xfs_sysfs_del(&xfs_dbg_kobj);
1824#endif
1806 kset_unregister(xfs_kset); 1825 kset_unregister(xfs_kset);
1807 xfs_sysctl_unregister(); 1826 xfs_sysctl_unregister();
1808 xfs_cleanup_procfs(); 1827 xfs_cleanup_procfs();
diff --git a/fs/xfs/xfs_sysfs.c b/fs/xfs/xfs_sysfs.c
index 9835139ce1ec..32ddf0c8c50e 100644
--- a/fs/xfs/xfs_sysfs.c
+++ b/fs/xfs/xfs_sysfs.c
@@ -51,6 +51,49 @@ struct kobj_type xfs_mp_ktype = {
51 .release = xfs_sysfs_release, 51 .release = xfs_sysfs_release,
52}; 52};
53 53
54#ifdef DEBUG
55/* debug */
56
57static struct attribute *xfs_dbg_attrs[] = {
58 NULL,
59};
60
61STATIC ssize_t
62xfs_dbg_show(
63 struct kobject *kobject,
64 struct attribute *attr,
65 char *buf)
66{
67 struct xfs_sysfs_attr *xfs_attr = to_attr(attr);
68
69 return xfs_attr->show ? xfs_attr->show(buf, NULL) : 0;
70}
71
72STATIC ssize_t
73xfs_dbg_store(
74 struct kobject *kobject,
75 struct attribute *attr,
76 const char *buf,
77 size_t count)
78{
79 struct xfs_sysfs_attr *xfs_attr = to_attr(attr);
80
81 return xfs_attr->store ? xfs_attr->store(buf, count, NULL) : 0;
82}
83
84static struct sysfs_ops xfs_dbg_ops = {
85 .show = xfs_dbg_show,
86 .store = xfs_dbg_store,
87};
88
89struct kobj_type xfs_dbg_ktype = {
90 .release = xfs_sysfs_release,
91 .sysfs_ops = &xfs_dbg_ops,
92 .default_attrs = xfs_dbg_attrs,
93};
94
95#endif /* DEBUG */
96
54/* xlog */ 97/* xlog */
55 98
56STATIC ssize_t 99STATIC ssize_t
diff --git a/fs/xfs/xfs_sysfs.h b/fs/xfs/xfs_sysfs.h
index 54a2091183c0..240eee35f342 100644
--- a/fs/xfs/xfs_sysfs.h
+++ b/fs/xfs/xfs_sysfs.h
@@ -20,6 +20,7 @@
20#define __XFS_SYSFS_H__ 20#define __XFS_SYSFS_H__
21 21
22extern struct kobj_type xfs_mp_ktype; /* xfs_mount */ 22extern struct kobj_type xfs_mp_ktype; /* xfs_mount */
23extern struct kobj_type xfs_dbg_ktype; /* debug */
23extern struct kobj_type xfs_log_ktype; /* xlog */ 24extern struct kobj_type xfs_log_ktype; /* xlog */
24 25
25static inline struct xfs_kobj * 26static inline struct xfs_kobj *