scoutfs: add options debugfs dir

Add a debugfs dir that will offer debugging options for an actively
mounted volume.

Signed-off-by: Zach Brown <zab@versity.com>
This commit is contained in:
Zach Brown
2018-04-13 08:59:03 -07:00
committed by Zach Brown
parent 90de34361c
commit 31286ad714
4 changed files with 70 additions and 6 deletions
+55 -6
View File
@@ -14,6 +14,8 @@
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/types.h>
#include <linux/slab.h>
#include <linux/debugfs.h>
#include <linux/parser.h>
#include <linux/inet.h>
@@ -22,12 +24,7 @@
#include "msg.h"
#include "options.h"
enum {
Opt_listen = 0,
Opt_cluster,
Opt_err,
};
#include "super.h"
static const match_table_t tokens = {
{Opt_listen, "listen=%s"},
@@ -35,6 +32,20 @@ static const match_table_t tokens = {
{Opt_err, NULL}
};
struct options_sb_info {
struct dentry *debugfs_dir;
};
u32 scoutfs_option_u32(struct super_block *sb, int token)
{
switch(token) {
default: break;
}
WARN_ON_ONCE(1);
return 0;
}
int scoutfs_parse_options(struct super_block *sb, char *options,
struct mount_options *parsed)
{
@@ -79,3 +90,41 @@ int scoutfs_parse_options(struct super_block *sb, char *options,
return 0;
}
int scoutfs_options_setup(struct super_block *sb)
{
struct scoutfs_sb_info *sbi = SCOUTFS_SB(sb);
struct options_sb_info *osi;
int ret;
osi = kzalloc(sizeof(struct options_sb_info), GFP_KERNEL);
if (!osi)
return -ENOMEM;
sbi->options = osi;
osi->debugfs_dir = debugfs_create_dir("options", sbi->debug_root);
if (!osi->debugfs_dir) {
ret = -ENOMEM;
goto out;
}
ret = 0;
out:
if (ret)
scoutfs_options_destroy(sb);
return ret;
}
void scoutfs_options_destroy(struct super_block *sb)
{
struct scoutfs_sb_info *sbi = SCOUTFS_SB(sb);
struct options_sb_info *osi = sbi->options;
if (osi) {
if (osi->debugfs_dir)
debugfs_remove_recursive(osi->debugfs_dir);
kfree(osi);
sbi->options = NULL;
}
}
+11
View File
@@ -4,6 +4,12 @@
#include <linux/fs.h>
#include "format.h"
enum {
Opt_listen = 0,
Opt_cluster,
Opt_err,
};
#define MAX_CLUSTER_NAME_LEN 17
struct mount_options
{
@@ -13,5 +19,10 @@ struct mount_options
int scoutfs_parse_options(struct super_block *sb, char *options,
struct mount_options *parsed);
int scoutfs_options_setup(struct super_block *sb);
void scoutfs_options_destroy(struct super_block *sb);
u32 scoutfs_option_u32(struct super_block *sb, int token);
#define scoutfs_option_bool scoutfs_option_u32
#endif /* _SCOUTFS_OPTIONS_H_ */
+2
View File
@@ -137,6 +137,7 @@ static void scoutfs_put_super(struct super_block *sb)
scoutfs_lock_destroy(sb);
scoutfs_destroy_triggers(sb);
scoutfs_options_destroy(sb);
debugfs_remove(sbi->debug_root);
scoutfs_destroy_counters(sb);
scoutfs_destroy_sysfs(sb);
@@ -331,6 +332,7 @@ static int scoutfs_fill_super(struct super_block *sb, void *data, int silent)
scoutfs_setup_counters(sb) ?:
scoutfs_read_supers(sb, &SCOUTFS_SB(sb)->super) ?:
scoutfs_debugfs_setup(sb) ?:
scoutfs_options_setup(sb) ?:
scoutfs_setup_triggers(sb) ?:
scoutfs_seg_setup(sb) ?:
scoutfs_item_setup(sb) ?:
+2
View File
@@ -21,6 +21,7 @@ struct server_info;
struct inode_sb_info;
struct btree_info;
struct sysfs_info;
struct options_sb_info;
struct scoutfs_sb_info {
struct super_block *sb;
@@ -64,6 +65,7 @@ struct scoutfs_sb_info {
struct scoutfs_triggers *triggers;
struct mount_options opts;
struct options_sb_info *options;
struct dentry *debug_root;