Commit a76dba3b authored by Darrick J. Wong's avatar Darrick J. Wong

xfs: create scaffolding for creating debugfs entries

Set up debugfs directories for xfs as a whole, and a subdirectory for
each mounted filesystem.  This will enable the creation of debugfs files
in the next patch.
Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
parent 764018ca
...@@ -63,6 +63,7 @@ typedef __u32 xfs_nlink_t; ...@@ -63,6 +63,7 @@ typedef __u32 xfs_nlink_t;
#include <linux/rhashtable.h> #include <linux/rhashtable.h>
#include <linux/xattr.h> #include <linux/xattr.h>
#include <linux/mnt_idmapping.h> #include <linux/mnt_idmapping.h>
#include <linux/debugfs.h>
#include <asm/page.h> #include <asm/page.h>
#include <asm/div64.h> #include <asm/div64.h>
......
...@@ -208,6 +208,7 @@ typedef struct xfs_mount { ...@@ -208,6 +208,7 @@ typedef struct xfs_mount {
uint64_t m_resblks_avail;/* available reserved blocks */ uint64_t m_resblks_avail;/* available reserved blocks */
uint64_t m_resblks_save; /* reserved blks @ remount,ro */ uint64_t m_resblks_save; /* reserved blks @ remount,ro */
struct delayed_work m_reclaim_work; /* background inode reclaim */ struct delayed_work m_reclaim_work; /* background inode reclaim */
struct dentry *m_debugfs; /* debugfs parent */
struct xfs_kobj m_kobj; struct xfs_kobj m_kobj;
struct xfs_kobj m_error_kobj; struct xfs_kobj m_error_kobj;
struct xfs_kobj m_error_meta_kobj; struct xfs_kobj m_error_meta_kobj;
......
...@@ -49,6 +49,7 @@ ...@@ -49,6 +49,7 @@
static const struct super_operations xfs_super_operations; static const struct super_operations xfs_super_operations;
static struct dentry *xfs_debugfs; /* top-level xfs debugfs dir */
static struct kset *xfs_kset; /* top-level xfs sysfs dir */ static struct kset *xfs_kset; /* top-level xfs sysfs dir */
#ifdef DEBUG #ifdef DEBUG
static struct xfs_kobj xfs_dbg_kobj; /* global debug sysfs attrs */ static struct xfs_kobj xfs_dbg_kobj; /* global debug sysfs attrs */
...@@ -758,6 +759,7 @@ static void ...@@ -758,6 +759,7 @@ static void
xfs_mount_free( xfs_mount_free(
struct xfs_mount *mp) struct xfs_mount *mp)
{ {
debugfs_remove(mp->m_debugfs);
kfree(mp->m_rtname); kfree(mp->m_rtname);
kfree(mp->m_logname); kfree(mp->m_logname);
kmem_free(mp); kmem_free(mp);
...@@ -1479,6 +1481,21 @@ xfs_fs_validate_params( ...@@ -1479,6 +1481,21 @@ xfs_fs_validate_params(
return 0; return 0;
} }
struct dentry *
xfs_debugfs_mkdir(
const char *name,
struct dentry *parent)
{
struct dentry *child;
/* Apparently we're expected to ignore error returns?? */
child = debugfs_create_dir(name, parent);
if (IS_ERR(child))
return NULL;
return child;
}
static int static int
xfs_fs_fill_super( xfs_fs_fill_super(
struct super_block *sb, struct super_block *sb,
...@@ -1521,6 +1538,13 @@ xfs_fs_fill_super( ...@@ -1521,6 +1538,13 @@ xfs_fs_fill_super(
if (error) if (error)
goto out_free_names; goto out_free_names;
if (xfs_debugfs) {
mp->m_debugfs = xfs_debugfs_mkdir(mp->m_super->s_id,
xfs_debugfs);
} else {
mp->m_debugfs = NULL;
}
error = xfs_init_mount_workqueues(mp); error = xfs_init_mount_workqueues(mp);
if (error) if (error)
goto out_close_devices; goto out_close_devices;
...@@ -2353,10 +2377,12 @@ init_xfs_fs(void) ...@@ -2353,10 +2377,12 @@ init_xfs_fs(void)
if (error) if (error)
goto out_cleanup_procfs; goto out_cleanup_procfs;
xfs_debugfs = xfs_debugfs_mkdir("xfs", NULL);
xfs_kset = kset_create_and_add("xfs", NULL, fs_kobj); xfs_kset = kset_create_and_add("xfs", NULL, fs_kobj);
if (!xfs_kset) { if (!xfs_kset) {
error = -ENOMEM; error = -ENOMEM;
goto out_sysctl_unregister; goto out_debugfs_unregister;
} }
xfsstats.xs_kobj.kobject.kset = xfs_kset; xfsstats.xs_kobj.kobject.kset = xfs_kset;
...@@ -2400,7 +2426,8 @@ init_xfs_fs(void) ...@@ -2400,7 +2426,8 @@ init_xfs_fs(void)
free_percpu(xfsstats.xs_stats); free_percpu(xfsstats.xs_stats);
out_kset_unregister: out_kset_unregister:
kset_unregister(xfs_kset); kset_unregister(xfs_kset);
out_sysctl_unregister: out_debugfs_unregister:
debugfs_remove(xfs_debugfs);
xfs_sysctl_unregister(); xfs_sysctl_unregister();
out_cleanup_procfs: out_cleanup_procfs:
xfs_cleanup_procfs(); xfs_cleanup_procfs();
...@@ -2427,6 +2454,7 @@ exit_xfs_fs(void) ...@@ -2427,6 +2454,7 @@ exit_xfs_fs(void)
xfs_sysfs_del(&xfsstats.xs_kobj); xfs_sysfs_del(&xfsstats.xs_kobj);
free_percpu(xfsstats.xs_stats); free_percpu(xfsstats.xs_stats);
kset_unregister(xfs_kset); kset_unregister(xfs_kset);
debugfs_remove(xfs_debugfs);
xfs_sysctl_unregister(); xfs_sysctl_unregister();
xfs_cleanup_procfs(); xfs_cleanup_procfs();
xfs_mru_cache_uninit(); xfs_mru_cache_uninit();
......
...@@ -100,4 +100,6 @@ extern struct workqueue_struct *xfs_discard_wq; ...@@ -100,4 +100,6 @@ extern struct workqueue_struct *xfs_discard_wq;
#define XFS_M(sb) ((struct xfs_mount *)((sb)->s_fs_info)) #define XFS_M(sb) ((struct xfs_mount *)((sb)->s_fs_info))
struct dentry *xfs_debugfs_mkdir(const char *name, struct dentry *parent);
#endif /* __XFS_SUPER_H__ */ #endif /* __XFS_SUPER_H__ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment