Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Brian Foster and committed by
Dave Chinner
65b65735 e1b05723

+65 -2
+21 -2
fs/xfs/xfs_super.c
··· 47 47 #include "xfs_dinode.h" 48 48 #include "xfs_filestream.h" 49 49 #include "xfs_quota.h" 50 + #include "xfs_sysfs.h" 50 51 51 52 #include <linux/namei.h> 52 53 #include <linux/init.h> ··· 62 61 static const struct super_operations xfs_super_operations; 63 62 static kmem_zone_t *xfs_ioend_zone; 64 63 mempool_t *xfs_ioend_pool; 65 - struct kset *xfs_kset; 64 + 65 + struct kset *xfs_kset; /* top-level xfs sysfs dir */ 66 + #ifdef DEBUG 67 + static struct xfs_kobj xfs_dbg_kobj; /* global debug sysfs attrs */ 68 + #endif 66 69 67 70 #define MNTOPT_LOGBUFS "logbufs" /* number of XFS log buffers */ 68 71 #define MNTOPT_LOGBSIZE "logbsize" /* size of XFS log buffers */ ··· 1774 1769 goto out_sysctl_unregister;; 1775 1770 } 1776 1771 1777 - error = xfs_qm_init(); 1772 + #ifdef DEBUG 1773 + xfs_dbg_kobj.kobject.kset = xfs_kset; 1774 + error = xfs_sysfs_init(&xfs_dbg_kobj, &xfs_dbg_ktype, NULL, "debug"); 1778 1775 if (error) 1779 1776 goto out_kset_unregister; 1777 + #endif 1778 + 1779 + error = xfs_qm_init(); 1780 + if (error) 1781 + goto out_remove_kobj; 1780 1782 1781 1783 error = register_filesystem(&xfs_fs_type); 1782 1784 if (error) ··· 1792 1780 1793 1781 out_qm_exit: 1794 1782 xfs_qm_exit(); 1783 + out_remove_kobj: 1784 + #ifdef DEBUG 1785 + xfs_sysfs_del(&xfs_dbg_kobj); 1795 1786 out_kset_unregister: 1787 + #endif 1796 1788 kset_unregister(xfs_kset); 1797 1789 out_sysctl_unregister: 1798 1790 xfs_sysctl_unregister(); ··· 1819 1803 { 1820 1804 xfs_qm_exit(); 1821 1805 unregister_filesystem(&xfs_fs_type); 1806 + #ifdef DEBUG 1807 + xfs_sysfs_del(&xfs_dbg_kobj); 1808 + #endif 1822 1809 kset_unregister(xfs_kset); 1823 1810 xfs_sysctl_unregister(); 1824 1811 xfs_cleanup_procfs();
+43
fs/xfs/xfs_sysfs.c
··· 51 51 .release = xfs_sysfs_release, 52 52 }; 53 53 54 + #ifdef DEBUG 55 + /* debug */ 56 + 57 + static struct attribute *xfs_dbg_attrs[] = { 58 + NULL, 59 + }; 60 + 61 + STATIC ssize_t 62 + xfs_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 + 72 + STATIC ssize_t 73 + xfs_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 + 84 + static struct sysfs_ops xfs_dbg_ops = { 85 + .show = xfs_dbg_show, 86 + .store = xfs_dbg_store, 87 + }; 88 + 89 + struct 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 97 /* xlog */ 55 98 56 99 STATIC ssize_t
+1
fs/xfs/xfs_sysfs.h
··· 20 20 #define __XFS_SYSFS_H__ 21 21 22 22 extern struct kobj_type xfs_mp_ktype; /* xfs_mount */ 23 + extern struct kobj_type xfs_dbg_ktype; /* debug */ 23 24 extern struct kobj_type xfs_log_ktype; /* xlog */ 24 25 25 26 static inline struct xfs_kobj *