Skip to content

Commit a76dba3

Browse files
author
Darrick J. Wong
committed
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: Darrick J. Wong <[email protected]> Reviewed-by: Dave Chinner <[email protected]>
1 parent 764018c commit a76dba3

File tree

4 files changed

+34
-2
lines changed

4 files changed

+34
-2
lines changed

fs/xfs/xfs_linux.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ typedef __u32 xfs_nlink_t;
6363
#include <linux/rhashtable.h>
6464
#include <linux/xattr.h>
6565
#include <linux/mnt_idmapping.h>
66+
#include <linux/debugfs.h>
6667

6768
#include <asm/page.h>
6869
#include <asm/div64.h>

fs/xfs/xfs_mount.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ typedef struct xfs_mount {
208208
uint64_t m_resblks_avail;/* available reserved blocks */
209209
uint64_t m_resblks_save; /* reserved blks @ remount,ro */
210210
struct delayed_work m_reclaim_work; /* background inode reclaim */
211+
struct dentry *m_debugfs; /* debugfs parent */
211212
struct xfs_kobj m_kobj;
212213
struct xfs_kobj m_error_kobj;
213214
struct xfs_kobj m_error_meta_kobj;

fs/xfs/xfs_super.c

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949

5050
static const struct super_operations xfs_super_operations;
5151

52+
static struct dentry *xfs_debugfs; /* top-level xfs debugfs dir */
5253
static struct kset *xfs_kset; /* top-level xfs sysfs dir */
5354
#ifdef DEBUG
5455
static struct xfs_kobj xfs_dbg_kobj; /* global debug sysfs attrs */
@@ -758,6 +759,7 @@ static void
758759
xfs_mount_free(
759760
struct xfs_mount *mp)
760761
{
762+
debugfs_remove(mp->m_debugfs);
761763
kfree(mp->m_rtname);
762764
kfree(mp->m_logname);
763765
kmem_free(mp);
@@ -1479,6 +1481,21 @@ xfs_fs_validate_params(
14791481
return 0;
14801482
}
14811483

1484+
struct dentry *
1485+
xfs_debugfs_mkdir(
1486+
const char *name,
1487+
struct dentry *parent)
1488+
{
1489+
struct dentry *child;
1490+
1491+
/* Apparently we're expected to ignore error returns?? */
1492+
child = debugfs_create_dir(name, parent);
1493+
if (IS_ERR(child))
1494+
return NULL;
1495+
1496+
return child;
1497+
}
1498+
14821499
static int
14831500
xfs_fs_fill_super(
14841501
struct super_block *sb,
@@ -1521,6 +1538,13 @@ xfs_fs_fill_super(
15211538
if (error)
15221539
goto out_free_names;
15231540

1541+
if (xfs_debugfs) {
1542+
mp->m_debugfs = xfs_debugfs_mkdir(mp->m_super->s_id,
1543+
xfs_debugfs);
1544+
} else {
1545+
mp->m_debugfs = NULL;
1546+
}
1547+
15241548
error = xfs_init_mount_workqueues(mp);
15251549
if (error)
15261550
goto out_close_devices;
@@ -2353,10 +2377,12 @@ init_xfs_fs(void)
23532377
if (error)
23542378
goto out_cleanup_procfs;
23552379

2380+
xfs_debugfs = xfs_debugfs_mkdir("xfs", NULL);
2381+
23562382
xfs_kset = kset_create_and_add("xfs", NULL, fs_kobj);
23572383
if (!xfs_kset) {
23582384
error = -ENOMEM;
2359-
goto out_sysctl_unregister;
2385+
goto out_debugfs_unregister;
23602386
}
23612387

23622388
xfsstats.xs_kobj.kobject.kset = xfs_kset;
@@ -2400,7 +2426,8 @@ init_xfs_fs(void)
24002426
free_percpu(xfsstats.xs_stats);
24012427
out_kset_unregister:
24022428
kset_unregister(xfs_kset);
2403-
out_sysctl_unregister:
2429+
out_debugfs_unregister:
2430+
debugfs_remove(xfs_debugfs);
24042431
xfs_sysctl_unregister();
24052432
out_cleanup_procfs:
24062433
xfs_cleanup_procfs();
@@ -2427,6 +2454,7 @@ exit_xfs_fs(void)
24272454
xfs_sysfs_del(&xfsstats.xs_kobj);
24282455
free_percpu(xfsstats.xs_stats);
24292456
kset_unregister(xfs_kset);
2457+
debugfs_remove(xfs_debugfs);
24302458
xfs_sysctl_unregister();
24312459
xfs_cleanup_procfs();
24322460
xfs_mru_cache_uninit();

fs/xfs/xfs_super.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,6 @@ extern struct workqueue_struct *xfs_discard_wq;
100100

101101
#define XFS_M(sb) ((struct xfs_mount *)((sb)->s_fs_info))
102102

103+
struct dentry *xfs_debugfs_mkdir(const char *name, struct dentry *parent);
104+
103105
#endif /* __XFS_SUPER_H__ */

0 commit comments

Comments
 (0)