|
@@ -24,6 +24,7 @@
|
|
#include <linux/kobject.h>
|
|
#include <linux/kobject.h>
|
|
#include <linux/bug.h>
|
|
#include <linux/bug.h>
|
|
#include <linux/genhd.h>
|
|
#include <linux/genhd.h>
|
|
|
|
+#include <linux/debugfs.h>
|
|
|
|
|
|
#include "ctree.h"
|
|
#include "ctree.h"
|
|
#include "disk-io.h"
|
|
#include "disk-io.h"
|
|
@@ -599,6 +600,12 @@ static int add_device_membership(struct btrfs_fs_info *fs_info)
|
|
/* /sys/fs/btrfs/ entry */
|
|
/* /sys/fs/btrfs/ entry */
|
|
static struct kset *btrfs_kset;
|
|
static struct kset *btrfs_kset;
|
|
|
|
|
|
|
|
+/* /sys/kernel/debug/btrfs */
|
|
|
|
+static struct dentry *btrfs_debugfs_root_dentry;
|
|
|
|
+
|
|
|
|
+/* Debugging tunables and exported data */
|
|
|
|
+u64 btrfs_debugfs_test;
|
|
|
|
+
|
|
int btrfs_sysfs_add_one(struct btrfs_fs_info *fs_info)
|
|
int btrfs_sysfs_add_one(struct btrfs_fs_info *fs_info)
|
|
{
|
|
{
|
|
int error;
|
|
int error;
|
|
@@ -642,27 +649,41 @@ failure:
|
|
return error;
|
|
return error;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+static int btrfs_init_debugfs(void)
|
|
|
|
+{
|
|
|
|
+#ifdef CONFIG_DEBUG_FS
|
|
|
|
+ btrfs_debugfs_root_dentry = debugfs_create_dir("btrfs", NULL);
|
|
|
|
+ if (!btrfs_debugfs_root_dentry)
|
|
|
|
+ return -ENOMEM;
|
|
|
|
+
|
|
|
|
+ debugfs_create_u64("test", S_IRUGO | S_IWUGO, btrfs_debugfs_root_dentry,
|
|
|
|
+ &btrfs_debugfs_test);
|
|
|
|
+#endif
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+
|
|
int btrfs_init_sysfs(void)
|
|
int btrfs_init_sysfs(void)
|
|
{
|
|
{
|
|
int ret;
|
|
int ret;
|
|
|
|
+
|
|
btrfs_kset = kset_create_and_add("btrfs", NULL, fs_kobj);
|
|
btrfs_kset = kset_create_and_add("btrfs", NULL, fs_kobj);
|
|
if (!btrfs_kset)
|
|
if (!btrfs_kset)
|
|
return -ENOMEM;
|
|
return -ENOMEM;
|
|
|
|
|
|
- init_feature_attrs();
|
|
|
|
|
|
+ ret = btrfs_init_debugfs();
|
|
|
|
+ if (ret)
|
|
|
|
+ return ret;
|
|
|
|
|
|
|
|
+ init_feature_attrs();
|
|
ret = sysfs_create_group(&btrfs_kset->kobj, &btrfs_feature_attr_group);
|
|
ret = sysfs_create_group(&btrfs_kset->kobj, &btrfs_feature_attr_group);
|
|
- if (ret) {
|
|
|
|
- kset_unregister(btrfs_kset);
|
|
|
|
- return ret;
|
|
|
|
- }
|
|
|
|
|
|
|
|
- return 0;
|
|
|
|
|
|
+ return ret;
|
|
}
|
|
}
|
|
|
|
|
|
void btrfs_exit_sysfs(void)
|
|
void btrfs_exit_sysfs(void)
|
|
{
|
|
{
|
|
sysfs_remove_group(&btrfs_kset->kobj, &btrfs_feature_attr_group);
|
|
sysfs_remove_group(&btrfs_kset->kobj, &btrfs_feature_attr_group);
|
|
kset_unregister(btrfs_kset);
|
|
kset_unregister(btrfs_kset);
|
|
|
|
+ debugfs_remove_recursive(btrfs_debugfs_root_dentry);
|
|
}
|
|
}
|
|
|
|
|