Commit 18fbda91 authored by Omar Sandoval's avatar Omar Sandoval Committed by Jens Axboe

block: use same block debugfs directory for blk-mq and blktrace

When I added the blk-mq debugging information to debugfs, I didn't
notice that blktrace also creates a "block" directory in debugfs. Make
them use the same dentry, now created in the core block code. Based on a
patch from Jens.
Signed-off-by: default avatarOmar Sandoval <osandov@fb.com>
Signed-off-by: default avatarJens Axboe <axboe@fb.com>
parent a428d314
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <linux/ratelimit.h> #include <linux/ratelimit.h>
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
#include <linux/blk-cgroup.h> #include <linux/blk-cgroup.h>
#include <linux/debugfs.h>
#define CREATE_TRACE_POINTS #define CREATE_TRACE_POINTS
#include <trace/events/block.h> #include <trace/events/block.h>
...@@ -42,6 +43,10 @@ ...@@ -42,6 +43,10 @@
#include "blk-mq-sched.h" #include "blk-mq-sched.h"
#include "blk-wbt.h" #include "blk-wbt.h"
#ifdef CONFIG_DEBUG_FS
struct dentry *blk_debugfs_root;
#endif
EXPORT_TRACEPOINT_SYMBOL_GPL(block_bio_remap); EXPORT_TRACEPOINT_SYMBOL_GPL(block_bio_remap);
EXPORT_TRACEPOINT_SYMBOL_GPL(block_rq_remap); EXPORT_TRACEPOINT_SYMBOL_GPL(block_rq_remap);
EXPORT_TRACEPOINT_SYMBOL_GPL(block_bio_complete); EXPORT_TRACEPOINT_SYMBOL_GPL(block_bio_complete);
...@@ -3441,5 +3446,9 @@ int __init blk_dev_init(void) ...@@ -3441,5 +3446,9 @@ int __init blk_dev_init(void)
blk_requestq_cachep = kmem_cache_create("request_queue", blk_requestq_cachep = kmem_cache_create("request_queue",
sizeof(struct request_queue), 0, SLAB_PANIC, NULL); sizeof(struct request_queue), 0, SLAB_PANIC, NULL);
#ifdef CONFIG_DEBUG_FS
blk_debugfs_root = debugfs_create_dir("block", NULL);
#endif
return 0; return 0;
} }
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include <linux/debugfs.h> #include <linux/debugfs.h>
#include <linux/blk-mq.h> #include <linux/blk-mq.h>
#include "blk.h"
#include "blk-mq.h" #include "blk-mq.h"
#include "blk-mq-tag.h" #include "blk-mq-tag.h"
...@@ -28,8 +29,6 @@ struct blk_mq_debugfs_attr { ...@@ -28,8 +29,6 @@ struct blk_mq_debugfs_attr {
const struct file_operations *fops; const struct file_operations *fops;
}; };
static struct dentry *block_debugfs_root;
static int blk_mq_debugfs_seq_open(struct inode *inode, struct file *file, static int blk_mq_debugfs_seq_open(struct inode *inode, struct file *file,
const struct seq_operations *ops) const struct seq_operations *ops)
{ {
...@@ -665,10 +664,10 @@ static const struct blk_mq_debugfs_attr blk_mq_debugfs_ctx_attrs[] = { ...@@ -665,10 +664,10 @@ static const struct blk_mq_debugfs_attr blk_mq_debugfs_ctx_attrs[] = {
int blk_mq_debugfs_register(struct request_queue *q, const char *name) int blk_mq_debugfs_register(struct request_queue *q, const char *name)
{ {
if (!block_debugfs_root) if (!blk_debugfs_root)
return -ENOENT; return -ENOENT;
q->debugfs_dir = debugfs_create_dir(name, block_debugfs_root); q->debugfs_dir = debugfs_create_dir(name, blk_debugfs_root);
if (!q->debugfs_dir) if (!q->debugfs_dir)
goto err; goto err;
...@@ -771,8 +770,3 @@ void blk_mq_debugfs_unregister_hctxs(struct request_queue *q) ...@@ -771,8 +770,3 @@ void blk_mq_debugfs_unregister_hctxs(struct request_queue *q)
debugfs_remove_recursive(q->mq_debugfs_dir); debugfs_remove_recursive(q->mq_debugfs_dir);
q->mq_debugfs_dir = NULL; q->mq_debugfs_dir = NULL;
} }
void blk_mq_debugfs_init(void)
{
block_debugfs_root = debugfs_create_dir("block", NULL);
}
...@@ -2817,8 +2817,6 @@ void blk_mq_enable_hotplug(void) ...@@ -2817,8 +2817,6 @@ void blk_mq_enable_hotplug(void)
static int __init blk_mq_init(void) static int __init blk_mq_init(void)
{ {
blk_mq_debugfs_init();
cpuhp_setup_state_multi(CPUHP_BLK_MQ_DEAD, "block/mq:dead", NULL, cpuhp_setup_state_multi(CPUHP_BLK_MQ_DEAD, "block/mq:dead", NULL,
blk_mq_hctx_notify_dead); blk_mq_hctx_notify_dead);
......
...@@ -85,16 +85,11 @@ extern void blk_mq_hctx_kobj_init(struct blk_mq_hw_ctx *hctx); ...@@ -85,16 +85,11 @@ extern void blk_mq_hctx_kobj_init(struct blk_mq_hw_ctx *hctx);
* debugfs helpers * debugfs helpers
*/ */
#ifdef CONFIG_BLK_DEBUG_FS #ifdef CONFIG_BLK_DEBUG_FS
void blk_mq_debugfs_init(void);
int blk_mq_debugfs_register(struct request_queue *q, const char *name); int blk_mq_debugfs_register(struct request_queue *q, const char *name);
void blk_mq_debugfs_unregister(struct request_queue *q); void blk_mq_debugfs_unregister(struct request_queue *q);
int blk_mq_debugfs_register_hctxs(struct request_queue *q); int blk_mq_debugfs_register_hctxs(struct request_queue *q);
void blk_mq_debugfs_unregister_hctxs(struct request_queue *q); void blk_mq_debugfs_unregister_hctxs(struct request_queue *q);
#else #else
static inline void blk_mq_debugfs_init(void)
{
}
static inline int blk_mq_debugfs_register(struct request_queue *q, static inline int blk_mq_debugfs_register(struct request_queue *q,
const char *name) const char *name)
{ {
......
...@@ -14,6 +14,10 @@ ...@@ -14,6 +14,10 @@
/* Max future timer expiry for timeouts */ /* Max future timer expiry for timeouts */
#define BLK_MAX_TIMEOUT (5 * HZ) #define BLK_MAX_TIMEOUT (5 * HZ)
#ifdef CONFIG_DEBUG_FS
extern struct dentry *blk_debugfs_root;
#endif
struct blk_flush_queue { struct blk_flush_queue {
unsigned int flush_queue_delayed:1; unsigned int flush_queue_delayed:1;
unsigned int flush_pending_idx:1; unsigned int flush_pending_idx:1;
......
...@@ -28,6 +28,8 @@ ...@@ -28,6 +28,8 @@
#include <linux/uaccess.h> #include <linux/uaccess.h>
#include <linux/list.h> #include <linux/list.h>
#include "../../block/blk.h"
#include <trace/events/block.h> #include <trace/events/block.h>
#include "trace_output.h" #include "trace_output.h"
...@@ -292,9 +294,6 @@ static void __blk_add_trace(struct blk_trace *bt, sector_t sector, int bytes, ...@@ -292,9 +294,6 @@ static void __blk_add_trace(struct blk_trace *bt, sector_t sector, int bytes,
local_irq_restore(flags); local_irq_restore(flags);
} }
static struct dentry *blk_tree_root;
static DEFINE_MUTEX(blk_tree_mutex);
static void blk_trace_free(struct blk_trace *bt) static void blk_trace_free(struct blk_trace *bt)
{ {
debugfs_remove(bt->msg_file); debugfs_remove(bt->msg_file);
...@@ -468,17 +467,10 @@ static int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev, ...@@ -468,17 +467,10 @@ static int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
ret = -ENOENT; ret = -ENOENT;
mutex_lock(&blk_tree_mutex); if (!blk_debugfs_root)
if (!blk_tree_root) { goto err;
blk_tree_root = debugfs_create_dir("block", NULL);
if (!blk_tree_root) {
mutex_unlock(&blk_tree_mutex);
goto err;
}
}
mutex_unlock(&blk_tree_mutex);
dir = debugfs_create_dir(buts->name, blk_tree_root); dir = debugfs_create_dir(buts->name, blk_debugfs_root);
if (!dir) if (!dir)
goto err; goto err;
......
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