From patchwork Wed Aug 7 12:46:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Righi X-Patchwork-Id: 1143482 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 463WTg6JyJz9sNy; Wed, 7 Aug 2019 22:46:31 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1hvLKm-0001J3-8Y; Wed, 07 Aug 2019 12:46:28 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1hvLKi-0001Hk-Ps for kernel-team@lists.ubuntu.com; Wed, 07 Aug 2019 12:46:24 +0000 Received: from mail-wm1-f72.google.com ([209.85.128.72]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1hvLKi-0007Gn-A2 for kernel-team@lists.ubuntu.com; Wed, 07 Aug 2019 12:46:24 +0000 Received: by mail-wm1-f72.google.com with SMTP id d65so20933637wmd.3 for ; Wed, 07 Aug 2019 05:46:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=i39TZg4/lC1sYg8RsWLOczzpBhjieEf2OPrEg4BV53Y=; b=MYvBMsU/TaClrANn0FZLl6iDttcF1mmYuos0AgXRx/LgcaDDGrK0Mh7gCvEAGYt0V2 7y14p1MdYujfvNl5CgPzo4JTrnfTiSV2dcrTEYm4vMS0Paq/Fh/8QZOlhGdW0/7JJRqw /L0YUWdrqLZDUhUVVBvtB01Qh/f7Jsky6l8m84sOCjIW/3UkdtFEg6D2xG6wuaBG/rvj U8le4EceW3AprWid5xROpE3f7J4FC0DjEyGqb4R3CRKKPQF4DBw2pzG0ghq0besRKZmJ d3vXLOhTtgVedR4oxAvn2VxVc1stsW0HpcAofaoQ4DRz8uwp9lKdI2K9I4DfgfK1cE4N 6SwQ== X-Gm-Message-State: APjAAAWJYSJG0ypzRNfVv/XjNvny7m9e29ybvJaA8Ij7f2VFVB+FoH8v yiTAaZ9vaZJzB+2T3QRqxFvuThE90QPW0keHBpZg2Saujv+Gap9k7vwwn2hIs1kxXtSoG+HSB6Z jYxEWTk1MnCywEtfsxk/ucLh5PDaRkToC5OuDG3Ot0g== X-Received: by 2002:a5d:4ec6:: with SMTP id s6mr8371691wrv.327.1565181983794; Wed, 07 Aug 2019 05:46:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqyOJmDHOMHoHATTSizV5x5IeWemKiIn40MiEIdBC7kqTGVqD6bg47jtD+tLZAa6FQimMCGKaA== X-Received: by 2002:a5d:4ec6:: with SMTP id s6mr8371658wrv.327.1565181983521; Wed, 07 Aug 2019 05:46:23 -0700 (PDT) Received: from xps-13.homenet.telecomitalia.it (host21-131-dynamic.46-79-r.retail.telecomitalia.it. [79.46.131.21]) by smtp.gmail.com with ESMTPSA id p7sm64020091wrs.6.2019.08.07.05.46.22 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 07 Aug 2019 05:46:22 -0700 (PDT) From: Andrea Righi To: kernel-team@lists.ubuntu.com Subject: [PATCH 2/3] bcache: improve bcache_reboot() Date: Wed, 7 Aug 2019 14:46:16 +0200 Message-Id: <20190807124617.30224-3-andrea.righi@canonical.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190807124617.30224-1-andrea.righi@canonical.com> References: <20190807124617.30224-1-andrea.righi@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Coly Li BugLink: https://bugs.launchpad.net/bugs/1784665 This patch tries to release mutex bch_register_lock early, to give chance to stop cache set and bcache device early. This patch also expends time out of stopping all bcache device from 2 seconds to 10 seconds, because stopping writeback rate update worker may delay for 5 seconds, 2 seconds is not enough. After this patch applied, stopping bcache devices during system reboot or shutdown is very hard to be observed any more. Signed-off-by: Coly Li Reviewed-by: Hannes Reinecke Signed-off-by: Jens Axboe (cherry picked from commit eb8cbb6df38f6e5124a3d5f1f8a3dbf519537c60) Signed-off-by: Andrea Righi --- drivers/md/bcache/super.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c index ffc3093dd9f7..5f7b3ce09c6f 100644 --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c @@ -2384,10 +2384,19 @@ static int bcache_reboot(struct notifier_block *n, unsigned long code, void *x) list_for_each_entry_safe(dc, tdc, &uncached_devices, list) bcache_device_stop(&dc->disk); + mutex_unlock(&bch_register_lock); + + /* + * Give an early chance for other kthreads and + * kworkers to stop themselves + */ + schedule(); + /* What's a condition variable? */ while (1) { - long timeout = start + 2 * HZ - jiffies; + long timeout = start + 10 * HZ - jiffies; + mutex_lock(&bch_register_lock); stopped = list_empty(&bch_cache_sets) && list_empty(&uncached_devices); @@ -2399,7 +2408,6 @@ static int bcache_reboot(struct notifier_block *n, unsigned long code, void *x) mutex_unlock(&bch_register_lock); schedule_timeout(timeout); - mutex_lock(&bch_register_lock); } finish_wait(&unregister_wait, &wait);