From patchwork Tue Jan 31 22:53:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 9548755 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E403960425 for ; Tue, 31 Jan 2017 22:54:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DA69E2832B for ; Tue, 31 Jan 2017 22:54:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CF5EA283EC; Tue, 31 Jan 2017 22:54:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5453D2832B for ; Tue, 31 Jan 2017 22:54:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750837AbdAaWyL (ORCPT ); Tue, 31 Jan 2017 17:54:11 -0500 Received: from mail-pf0-f181.google.com ([209.85.192.181]:36508 "EHLO mail-pf0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750828AbdAaWyK (ORCPT ); Tue, 31 Jan 2017 17:54:10 -0500 Received: by mail-pf0-f181.google.com with SMTP id 189so112770384pfu.3 for ; Tue, 31 Jan 2017 14:54:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osandov-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=eSTlL9ODdnwZG+GRCAt/RWVEqn3ISXKGJ8MvREdG7KI=; b=eaZtVsVJ3HKnS6uAloA/WYticr6iwgrNVSZq9a4+5zXk5c8KFHA8rWHhgM4+FasG78 7aSRerBhRJ3vYSUZ2vtzfK1zjrz/X1xdMx9ywXf3and/HS36KY93pMs0Pezwm9cJ1VlG z0ilmnKaRPJPDY/SRTukwR7rmG7cNQElMU75q0lGGOs7HqRwOE8zlhO3jpKlclWTSyQ7 RXOf1VfeogJS+PUbv4p6jm07Q1vVWboi6412h6jEa6XnE1RXzed01lm3dloHvBwSYpd3 sWnA34SiWkVBIrzTUaSz9zk8Xxg7v64C7JotzCDeve/mJkIQqKRecrGGeTAx9MRU63rx 34EQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=eSTlL9ODdnwZG+GRCAt/RWVEqn3ISXKGJ8MvREdG7KI=; b=cFktenwWOEhwlQTyMqoRdBv1XoJhUhj7MAEBgG1qstx5hIoePTBLHteVbvl3vBSJ8y +0PWRyD8boJ1T5Ix0U+5h9+YPs+snjpa6m5VqilbiAxfEtfQHRiLbEw3LDG0/smx/c20 85c8NBZXlHr63WSNxqG8QItmfB0Epe2ZdulWZyawbbyLMoGA6wq53IBAS4v903ttdSs7 3mP4rCKniizn4BlAwGsFZK/VPt3LnHfpFhMK/udn3GjVbQxi/okfy2mOPBFbIqzgYHXq hLqOOAA0WQDmZwgZCtImPz0nb36YHmTfYzUJ/l7K+0OEHao27WHRdVmV6HV7CDuiSxZy 9uVA== X-Gm-Message-State: AIkVDXIoPjPVi9o3bxuC5mXvYQNC12/tZzhQZ8zZ5W/9NNEjHKJN5uf0h9BHiOgkG5+PTQvX X-Received: by 10.84.231.203 with SMTP id g11mr43091072pln.165.1485903249479; Tue, 31 Jan 2017 14:54:09 -0800 (PST) Received: from vader.thefacebook.com ([2620:10d:c090:200::b:7f05]) by smtp.gmail.com with ESMTPSA id e127sm43614618pfh.89.2017.01.31.14.54.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 31 Jan 2017 14:54:08 -0800 (PST) From: Omar Sandoval To: Jens Axboe , linux-block@vger.kernel.org Cc: kernel-team@fb.com Subject: [PATCH 4/6] block: use same block debugfs directory for blk-mq and blktrace Date: Tue, 31 Jan 2017 14:53:20 -0800 Message-Id: <7b58d4b85fbd72a880774ddb745b090a085516aa.1485902856.git.osandov@fb.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Omar Sandoval 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: Omar Sandoval --- block/blk-core.c | 9 +++++++++ block/blk-mq-debugfs.c | 12 +++--------- block/blk-mq.c | 2 -- block/blk-mq.h | 5 ----- block/blk.h | 4 ++++ kernel/trace/blktrace.c | 18 +++++------------- 6 files changed, 21 insertions(+), 29 deletions(-) diff --git a/block/blk-core.c b/block/blk-core.c index 02833ce5664e..16d3b06c743c 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -33,6 +33,7 @@ #include #include #include +#include #define CREATE_TRACE_POINTS #include @@ -42,6 +43,10 @@ #include "blk-mq-sched.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_rq_remap); EXPORT_TRACEPOINT_SYMBOL_GPL(block_bio_complete); @@ -3482,5 +3487,9 @@ int __init blk_dev_init(void) blk_requestq_cachep = kmem_cache_create("request_queue", sizeof(struct request_queue), 0, SLAB_PANIC, NULL); +#ifdef CONFIG_DEBUG_FS + blk_debugfs_root = debugfs_create_dir("block", NULL); +#endif + return 0; } diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c index 5cd2b435a9f5..0cd29b99068c 100644 --- a/block/blk-mq-debugfs.c +++ b/block/blk-mq-debugfs.c @@ -19,6 +19,7 @@ #include #include +#include "blk.h" #include "blk-mq.h" #include "blk-mq-tag.h" @@ -28,8 +29,6 @@ struct blk_mq_debugfs_attr { const struct file_operations *fops; }; -static struct dentry *block_debugfs_root; - static int blk_mq_debugfs_seq_open(struct inode *inode, struct file *file, const struct seq_operations *ops) { @@ -641,10 +640,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) { - if (!block_debugfs_root) + if (!blk_debugfs_root) 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) goto err; @@ -749,8 +748,3 @@ void blk_mq_debugfs_unregister_hctxs(struct request_queue *q) debugfs_remove_recursive(q->mq_debugfs_dir); q->mq_debugfs_dir = NULL; } - -void blk_mq_debugfs_init(void) -{ - block_debugfs_root = debugfs_create_dir("block", NULL); -} diff --git a/block/blk-mq.c b/block/blk-mq.c index 60dac10228fe..ff70219c5afd 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -2827,8 +2827,6 @@ void blk_mq_enable_hotplug(void) static int __init blk_mq_init(void) { - blk_mq_debugfs_init(); - cpuhp_setup_state_multi(CPUHP_BLK_MQ_DEAD, "block/mq:dead", NULL, blk_mq_hctx_notify_dead); diff --git a/block/blk-mq.h b/block/blk-mq.h index b52abd62b1b0..24b2256186f3 100644 --- a/block/blk-mq.h +++ b/block/blk-mq.h @@ -85,16 +85,11 @@ extern void blk_mq_hctx_kobj_init(struct blk_mq_hw_ctx *hctx); * debugfs helpers */ #ifdef CONFIG_BLK_DEBUG_FS -void blk_mq_debugfs_init(void); int blk_mq_debugfs_register(struct request_queue *q, const char *name); void blk_mq_debugfs_unregister(struct request_queue *q); int blk_mq_debugfs_register_hctxs(struct request_queue *q); void blk_mq_debugfs_unregister_hctxs(struct request_queue *q); #else -static inline void blk_mq_debugfs_init(void) -{ -} - static inline int blk_mq_debugfs_register(struct request_queue *q, const char *name) { diff --git a/block/blk.h b/block/blk.h index 9a716b5925a4..22283b05fe33 100644 --- a/block/blk.h +++ b/block/blk.h @@ -14,6 +14,10 @@ /* Max future timer expiry for timeouts */ #define BLK_MAX_TIMEOUT (5 * HZ) +#ifdef CONFIG_DEBUG_FS +extern struct dentry *blk_debugfs_root; +#endif + struct blk_flush_queue { unsigned int flush_queue_delayed:1; unsigned int flush_pending_idx:1; diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c index 83d3b5b58f53..38052f625a0f 100644 --- a/kernel/trace/blktrace.c +++ b/kernel/trace/blktrace.c @@ -28,6 +28,8 @@ #include #include +#include "../../block/blk.h" + #include #include "trace_output.h" @@ -292,9 +294,6 @@ static void __blk_add_trace(struct blk_trace *bt, sector_t sector, int bytes, 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) { debugfs_remove(bt->msg_file); @@ -468,17 +467,10 @@ static int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev, ret = -ENOENT; - mutex_lock(&blk_tree_mutex); - if (!blk_tree_root) { - blk_tree_root = debugfs_create_dir("block", NULL); - if (!blk_tree_root) { - mutex_unlock(&blk_tree_mutex); - goto err; - } - } - mutex_unlock(&blk_tree_mutex); + if (!blk_debugfs_root) + goto err; - dir = debugfs_create_dir(buts->name, blk_tree_root); + dir = debugfs_create_dir(buts->name, blk_debugfs_root); if (!dir) goto err;