From patchwork Mon Mar 19 00:36:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Lyle X-Patchwork-Id: 10291473 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 8A3D460291 for ; Mon, 19 Mar 2018 00:37:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7C24A28EDF for ; Mon, 19 Mar 2018 00:37:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 70BD128F56; Mon, 19 Mar 2018 00:37:03 +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.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI 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 B7FA028EDF for ; Mon, 19 Mar 2018 00:37:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754836AbeCSAg7 (ORCPT ); Sun, 18 Mar 2018 20:36:59 -0400 Received: from mail-pl0-f65.google.com ([209.85.160.65]:34164 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754801AbeCSAgw (ORCPT ); Sun, 18 Mar 2018 20:36:52 -0400 Received: by mail-pl0-f65.google.com with SMTP id u11-v6so5561117plq.1 for ; Sun, 18 Mar 2018 17:36:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lyle-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=KJPPuGmUDypqk/CZXZL5Pwr8l5HAApohmOLKaCszhR4=; b=Sr9Ycei5wFjTOKnXPWpwJ2uoeqa/6mGW/2Uu5TTAfzvOEy8IDMMXLjg+DQYKjcqDBv nDQLYTgeju7p8Jv3VzuPpb7vQzk6EW+SRYVD+8kfjj0W77L0bueGSMOFj2lACGqDt7vp K3aRUEvzaWAbLRHpM/2jIn4c5DHIDAAG+huK+tmVjVUn/jBagnYo/bTG+0QuNfr84d0K TkvRsK6SLI4HB9ZDqeHv3Ry5nHoYEUi4KwbbOzFAK3W8GrQrjKghcLpTN77xQEgKgKxA 1lbC7FqN+6TRdEsbgh8pxpodFJ0/PuyozOoqkIJPT9xS/+5wQR57re9NJ0BmFcHtNAC7 QclA== 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; bh=KJPPuGmUDypqk/CZXZL5Pwr8l5HAApohmOLKaCszhR4=; b=VvFxlnKm3TuqjWrdYBhe28J+nyStlTX7bswoij6rbd287JpV1EBVLRC61S19LEz4wh 0vxS7E0qrsoA4+DCbmc1ox1OeXIsWy9RrSfOHJJ5Ivi2xJd5VHHqze2BW61AhEn+jrOP 8tJtap/wpuz+yYHGxp052XcyzPFjXjkescXfwpgParVn6K6ZjaM3PHdt/oP3wCrJuLXz 2pjweB4AYssNPgnKee1aQ5BUqRmAtQuLJORWn+BDLawvvj2Aoo6tmA2CvVq9ST1ftn4L wglWI3HBzxVLB3u2/PDK8gn8XbBTtmBHBiS64p3c60Pk51hieyFheIX9h1pjh81fNGSJ azdg== X-Gm-Message-State: AElRT7HfURgRAVIrPnPZIlzs5NQoIUrs1BeVmWvWabaregFRdous/7bq eGLwsUv4fgy3jMaDpygsLekYUTuvdfM= X-Google-Smtp-Source: AG47ELv+wl3aSwsDzJiZioJaBx9BtVheMNWA3wVHaOV7a9W177rWttYYPYUcRzhcbDWZCsNOvvXMyA== X-Received: by 2002:a17:902:51ca:: with SMTP id y68-v6mr4529258plh.25.1521419811932; Sun, 18 Mar 2018 17:36:51 -0700 (PDT) Received: from midnight.lan (2600-6c52-6200-09b7-0000-0000-0000-0d66.dhcp6.chtrptr.net. [2600:6c52:6200:9b7::d66]) by smtp.gmail.com with ESMTPSA id a17sm27674857pfc.122.2018.03.18.17.36.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 18 Mar 2018 17:36:51 -0700 (PDT) From: Michael Lyle To: linux-bcache@vger.kernel.org, linux-block@vger.kernel.org Cc: axboe@fb.com, Chengguang Xu Subject: [for-4.17 10/20] bcache: move closure debug file into debug directory Date: Sun, 18 Mar 2018 17:36:23 -0700 Message-Id: <20180319003633.27225-11-mlyle@lyle.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180319003633.27225-1-mlyle@lyle.org> References: <20180319003633.27225-1-mlyle@lyle.org> 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: Chengguang Xu In current code closure debug file is outside of debug directory and when unloading module there is lack of removing operation for closure debug file, so it will cause creating error when trying to reload module. This patch move closure debug file into "bcache" debug direcory so that the file can get deleted properly. Signed-off-by: Chengguang Xu Reviewed-by: Michael Lyle Reviewed-by: Tang Junhui --- drivers/md/bcache/closure.c | 9 +++++---- drivers/md/bcache/closure.h | 5 +++-- drivers/md/bcache/debug.c | 14 +++++++------- drivers/md/bcache/super.c | 3 +-- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/drivers/md/bcache/closure.c b/drivers/md/bcache/closure.c index 7f12920c14f7..c0949c9f843b 100644 --- a/drivers/md/bcache/closure.c +++ b/drivers/md/bcache/closure.c @@ -157,7 +157,7 @@ void closure_debug_destroy(struct closure *cl) } EXPORT_SYMBOL(closure_debug_destroy); -static struct dentry *debug; +static struct dentry *closure_debug; static int debug_seq_show(struct seq_file *f, void *data) { @@ -199,11 +199,12 @@ static const struct file_operations debug_ops = { .release = single_release }; -void __init closure_debug_init(void) +int __init closure_debug_init(void) { - debug = debugfs_create_file("closures", 0400, NULL, NULL, &debug_ops); + closure_debug = debugfs_create_file("closures", + 0400, bcache_debug, NULL, &debug_ops); + return IS_ERR_OR_NULL(closure_debug); } - #endif MODULE_AUTHOR("Kent Overstreet "); diff --git a/drivers/md/bcache/closure.h b/drivers/md/bcache/closure.h index 3b9dfc9962ad..71427eb5fdae 100644 --- a/drivers/md/bcache/closure.h +++ b/drivers/md/bcache/closure.h @@ -105,6 +105,7 @@ struct closure; struct closure_syncer; typedef void (closure_fn) (struct closure *); +extern struct dentry *bcache_debug; struct closure_waitlist { struct llist_head list; @@ -185,13 +186,13 @@ static inline void closure_sync(struct closure *cl) #ifdef CONFIG_BCACHE_CLOSURES_DEBUG -void closure_debug_init(void); +int closure_debug_init(void); void closure_debug_create(struct closure *cl); void closure_debug_destroy(struct closure *cl); #else -static inline void closure_debug_init(void) {} +static inline int closure_debug_init(void) { return 0; } static inline void closure_debug_create(struct closure *cl) {} static inline void closure_debug_destroy(struct closure *cl) {} diff --git a/drivers/md/bcache/debug.c b/drivers/md/bcache/debug.c index af89408befe8..028f7b386e01 100644 --- a/drivers/md/bcache/debug.c +++ b/drivers/md/bcache/debug.c @@ -17,7 +17,7 @@ #include #include -static struct dentry *debug; +struct dentry *bcache_debug; #ifdef CONFIG_BCACHE_DEBUG @@ -232,11 +232,11 @@ static const struct file_operations cache_set_debug_ops = { void bch_debug_init_cache_set(struct cache_set *c) { - if (!IS_ERR_OR_NULL(debug)) { + if (!IS_ERR_OR_NULL(bcache_debug)) { char name[50]; snprintf(name, 50, "bcache-%pU", c->sb.set_uuid); - c->debug = debugfs_create_file(name, 0400, debug, c, + c->debug = debugfs_create_file(name, 0400, bcache_debug, c, &cache_set_debug_ops); } } @@ -245,13 +245,13 @@ void bch_debug_init_cache_set(struct cache_set *c) void bch_debug_exit(void) { - if (!IS_ERR_OR_NULL(debug)) - debugfs_remove_recursive(debug); + if (!IS_ERR_OR_NULL(bcache_debug)) + debugfs_remove_recursive(bcache_debug); } int __init bch_debug_init(struct kobject *kobj) { - debug = debugfs_create_dir("bcache", NULL); + bcache_debug = debugfs_create_dir("bcache", NULL); - return IS_ERR_OR_NULL(debug); + return IS_ERR_OR_NULL(bcache_debug); } diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c index dab9f59a1a2f..26b7a7d4df15 100644 --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c @@ -2239,7 +2239,6 @@ static int __init bcache_init(void) mutex_init(&bch_register_lock); init_waitqueue_head(&unregister_wait); register_reboot_notifier(&reboot); - closure_debug_init(); bcache_major = register_blkdev(0, "bcache"); if (bcache_major < 0) { @@ -2251,7 +2250,7 @@ static int __init bcache_init(void) if (!(bcache_wq = alloc_workqueue("bcache", WQ_MEM_RECLAIM, 0)) || !(bcache_kobj = kobject_create_and_add("bcache", fs_kobj)) || bch_request_init() || - bch_debug_init(bcache_kobj) || + bch_debug_init(bcache_kobj) || closure_debug_init() || sysfs_create_files(bcache_kobj, files)) goto err;