From patchwork Mon Oct 30 21:46:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Lyle X-Patchwork-Id: 10033311 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 1026A6039A for ; Mon, 30 Oct 2017 21:47:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0281828945 for ; Mon, 30 Oct 2017 21:47:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EB84828949; Mon, 30 Oct 2017 21:47:06 +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.4 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM 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 9B08C28945 for ; Mon, 30 Oct 2017 21:47:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932682AbdJ3VrF (ORCPT ); Mon, 30 Oct 2017 17:47:05 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:54338 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932353AbdJ3VrC (ORCPT ); Mon, 30 Oct 2017 17:47:02 -0400 Received: by mail-pf0-f194.google.com with SMTP id n89so12061786pfk.11 for ; Mon, 30 Oct 2017 14:47:01 -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=sXjBQqWUq9/G6TrIKrBYuKClw4n0wkDhJSiFHEJ82IM=; b=s+Ja7amc2PNFbTXtN41LGANIc7XICK/Jltu1MaXh4IC+sv4zbmGqtSOTpJRLLS596A cou16UnxFBBdIejJPFff4TQXI3uQxg5T3XJDdAHuLurm8T6EjtrDfPlB0rWQhUmnpY5+ 3ATWNRP90qx/GMs/qjm6+UFnTzasux0s03EYoksME/0CFR7siPNJYFpWCDK3lVw6ayr0 X60u075NhfPUpl8INFvzvLwwqniJ7kXxHOBGJHbZKQp/ib6KLDXTlFhMae1zDNPAZd6o wNkcWwCg0zTlG2JVAzlKTP3VGgsQLSoewFjIEsNDqDoTfgGjEvy4fQgs9YCpGbktcyeO 2Qug== 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=sXjBQqWUq9/G6TrIKrBYuKClw4n0wkDhJSiFHEJ82IM=; b=hF7PTOhKOFQaDjkeHWUABGH46q2Il4Ma8sXk5CUU/yVyjzKEjZdm9qsZGI3L0oJFNi +eYUMCDw8DwT1zJFgTzILCR1uDYnCEiiaM2sBkuB3OdqOue2yEX0t3v2rfTsPIPSNO7q 0Jo8s35orQqPzCK67kBMueUwZPCLODDCL50btrTA3Nj901cCWO5H8L3zjpiPMTp7jL+m eq3Ae1qqopZaNMykrSMuvbb2U5mdSqX6ekyJUDKIAe7T0amgNgKVKqPg/TOY7ecp6JFA WCT4BCGYgd9rfO+Dw2Eo+HajgJfN5w/P6qXk6nNcbPFA4Te+T7HE1ch91JEvSt6whzFD rnpg== X-Gm-Message-State: AMCzsaULcASN3PSkKylJWnQdk2M0giAzuosZ6VbjvzLQtIk8C/cMIUX3 yBe+YUGfym/jT7KxG54wdHYAVA== X-Google-Smtp-Source: ABhQp+Rook9pAgmsMGEsAr/Pu7SSE9C9PDSxNVw7OKpSTbmBMraLoXEbAkXIBijfYHJjsEzHaBMsrg== X-Received: by 10.84.241.5 with SMTP id a5mr8205262pll.81.1509400021297; Mon, 30 Oct 2017 14:47:01 -0700 (PDT) Received: from localhost.localdomain (68-189-67-104.dhcp.prtv.ca.charter.com. [68.189.67.104]) by smtp.gmail.com with ESMTPSA id t78sm23733329pgb.93.2017.10.30.14.46.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Oct 2017 14:47:00 -0700 (PDT) From: Michael Lyle To: linux-bcache@vger.kernel.org, linux-block@vger.kernel.org Cc: axboe@fb.com, Liang Chen Subject: [PATCH 5/5] bcache: explicitly destroy mutex while exiting Date: Mon, 30 Oct 2017 14:46:35 -0700 Message-Id: <20171030214635.29888-6-mlyle@lyle.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171030214635.29888-1-mlyle@lyle.org> References: <20171030214635.29888-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: Liang Chen mutex_destroy does nothing most of time, but it's better to call it to make the code future proof and it also has some meaning for like mutex debug. As Coly pointed out in a previous review, bcache_exit() may not be able to handle all the references properly if userspace registers cache and backing devices right before bch_debug_init runs and bch_debug_init failes later. So not exposing userspace interface until everything is ready to avoid that issue. Signed-off-by: Liang Chen Reviewed-by: Michael Lyle Reviewed-by: Coly Li Reviewed-by: Eric Wheeler --- drivers/md/bcache/super.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c index 46134c45c6f6..b4d28928dec5 100644 --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c @@ -2095,6 +2095,7 @@ static void bcache_exit(void) if (bcache_major) unregister_blkdev(bcache_major, "bcache"); unregister_reboot_notifier(&reboot); + mutex_destroy(&bch_register_lock); } static int __init bcache_init(void) @@ -2113,14 +2114,15 @@ static int __init bcache_init(void) bcache_major = register_blkdev(0, "bcache"); if (bcache_major < 0) { unregister_reboot_notifier(&reboot); + mutex_destroy(&bch_register_lock); return bcache_major; } if (!(bcache_wq = alloc_workqueue("bcache", WQ_MEM_RECLAIM, 0)) || !(bcache_kobj = kobject_create_and_add("bcache", fs_kobj)) || - sysfs_create_files(bcache_kobj, files) || bch_request_init() || - bch_debug_init(bcache_kobj)) + bch_debug_init(bcache_kobj) || + sysfs_create_files(bcache_kobj, files)) goto err; return 0;