Message ID | 20231110172834.3939490-8-yukuai1@huaweicloud.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b129:0:b0:403:3b70:6f57 with SMTP id q9csp1291652vqs; Fri, 10 Nov 2023 10:08:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IHliI4BmrH5Abibs98BF/6PTXpJHDj4Ev6j6FBf80YI7/KtDL/0vuEDeBXA4+JRnY5IvxgF X-Received: by 2002:a17:903:2289:b0:1cc:665d:f822 with SMTP id b9-20020a170903228900b001cc665df822mr61049plh.32.1699639701120; Fri, 10 Nov 2023 10:08:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699639701; cv=none; d=google.com; s=arc-20160816; b=H6TcR4jYo/jKdhiK7xpGtzf47IVhonnL6BriigbhnH7eDj9Yz7wLRyTRcT9iGkhods 3paHIwj58icvo/aSIJNKJBDJxGjloPNfrfAfBJRe9/FJkPdbr6k3AQTQXHB/ueB9F0C0 UFgDVc4C3khJQu3c/4hcPMkdSMp28Wo8Fn6xe8+PDmm3svadapi1RvP0COGkn7TPXsO6 sx8Nntw/IfF5oTN1rrsGryk2jHkcASKXTGGq/za4GPc0jbtBAqSG9nHidvl12vnfDsJh HaZ3A+AWm54M7xaU77Xvjcb+t9iOQ5DDBpeGrDyyTI5hX+QMAfWh8VObiTqi0yBOI5+b ajlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Tdj3k2dJMB2WMFF889rn/tnxD+mMrL23SYvs3iObShQ=; fh=8k/d6E6r9fN2MUmxCda3gomiJvMOngrQQX+toNARU7g=; b=WW/JrXb5uyzoMGRx9B9tl+cWFPIdGqJ+4bwM4gJZ78Ksj0HztR8bjqbTJziwQhW4EO LRbu4z9r1Dg+foEsluQ/9VLTifKI71OkMK90rlixWZRA0i9RylF23MIRwSTI65UF8Ors /CAkFGk4Cxj/xxbikzJIzEviqGSXapViTGvMTA68E+kdbnSfEQmNIr9Ok2x43HbMnVm/ 2+OsL8fhLeofXdoSqiCU+mPBV9X7oF+YZmwevm+ycrDyKe9M7UxmCHW7yBOyavhfKaU9 l7jA/qV1MBjf4crKQ1S28l80Fq5UqINiDsUZy58nN9PizEVM2tIQPKYlzq3O+zOCEQmN UF5A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id je1-20020a170903264100b001cdfb3e2b19si4290875plb.611.2023.11.10.10.08.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Nov 2023 10:08:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 576A081A43ED; Fri, 10 Nov 2023 10:08:20 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234956AbjKJSHz (ORCPT <rfc822;lhua1029@gmail.com> + 30 others); Fri, 10 Nov 2023 13:07:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234895AbjKJSFI (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 10 Nov 2023 13:05:08 -0500 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58894244B9; Fri, 10 Nov 2023 01:34:04 -0800 (PST) Received: from mail.maildlp.com (unknown [172.19.163.235]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4SRYYJ1YWwz4f4Q4G; Fri, 10 Nov 2023 17:33:56 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 16BE41A016D; Fri, 10 Nov 2023 17:34:00 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgA3iA4E+U1l0pQlAg--.33627S11; Fri, 10 Nov 2023 17:33:59 +0800 (CST) From: Yu Kuai <yukuai1@huaweicloud.com> To: song@kernel.org, xni@redhat.com, yukuai3@huawei.com, neilb@suse.de Cc: linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH -next 7/8] md: use new helper to stop sync_thread in __md_stop_writes() Date: Sat, 11 Nov 2023 01:28:33 +0800 Message-Id: <20231110172834.3939490-8-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231110172834.3939490-1-yukuai1@huaweicloud.com> References: <20231110172834.3939490-1-yukuai1@huaweicloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: cCh0CgA3iA4E+U1l0pQlAg--.33627S11 X-Coremail-Antispam: 1UD129KBjvJXoW7tw1xWr48GFW8XF1rJFy8uFg_yoW8Jw48p3 yfKFn8Ar4DZr47A3yUJa4kZa45Z3ZFqrWvyFW3u3yrXFy3JFsrWw4Y9FyDZFWkGa4Sv3Zx Xa95tFZ3Za48Kr7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPF14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2jI8I6cxK62vIxIIY0VWUZVW8XwA2048vs2IY02 0E87I2jVAFwI0_JF0E3s1l82xGYIkIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0 rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6x IIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xv wVC2z280aVCY1x0267AKxVW0oVCq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFc xC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUGVWUXwAv7VC2z280aVAFwI0_Jr0_ Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2 IErcIFxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E 14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_GFylIx kGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUCVW8JwCI42IY6xIIjxv20xvEc7CjxVAF wI0_Cr0_Gr1UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJV W8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjTRi4SO UUUUU X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ X-Spam-Status: No, score=0.0 required=5.0 tests=BAYES_00,DATE_IN_FUTURE_06_12, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 10 Nov 2023 10:08:20 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782201399157938240 X-GMAIL-MSGID: 1782201399157938240 |
Series |
md: bugfix and cleanup for sync_thread
|
|
Commit Message
Yu Kuai
Nov. 10, 2023, 5:28 p.m. UTC
From: Yu Kuai <yukuai3@huawei.com> md_reap_sync_thread() should only be called when md_do_sync() is done, for example, holding 'reconfig_mutex' to wait for md_do_sync() to be done can deadlock(see details in commit 130443d60b1b ("md: refactor idle/frozen_sync_thread() to fix deadlock")). Hence use new helper to stop sync_thread. Signed-off-by: Yu Kuai <yukuai3@huawei.com> Signed-off-by: Yu Kuai <yukuai1@huaweicloud.com> --- drivers/md/md.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/drivers/md/md.c b/drivers/md/md.c index 7252fae0c989..35f3dd7db369 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -6325,12 +6325,11 @@ static void md_clean(struct mddev *mddev) static void __md_stop_writes(struct mddev *mddev) { - set_bit(MD_RECOVERY_FROZEN, &mddev->recovery); - if (work_pending(&mddev->sync_work)) - flush_workqueue(md_misc_wq); - if (mddev->sync_thread) { - set_bit(MD_RECOVERY_INTR, &mddev->recovery); - md_reap_sync_thread(mddev); + if (test_bit(MD_RECOVERY_RUNNING, &mddev->recovery)) { + stop_sync_thread(mddev, true, false); + mddev_lock_nointr(mddev); + } else { + set_bit(MD_RECOVERY_FROZEN, &mddev->recovery); } del_timer_sync(&mddev->safemode_timer);