Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp872843rdb; Tue, 23 Jan 2024 19:14:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IFIBiiKg/lqQdnbeqxTSHgyDlFoCwB3cVcQA76/1jRe3fS3FIAukPZ0qIvZ9sGbqdgHBFRq X-Received: by 2002:a05:6a21:188:b0:19b:559a:683b with SMTP id le8-20020a056a21018800b0019b559a683bmr281902pzb.23.1706066096717; Tue, 23 Jan 2024 19:14:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706066096; cv=pass; d=google.com; s=arc-20160816; b=cFyj4A0CbAUdEm2f+w0MFyVtPnyqDsy3shQGXbHGuxHCzRDtSmrpC6UI7LI7hXX8ov AH2ZL22oLR8OXypqpH/WUO3PhNzt2fDEK2VW3QnnG6viEY+Q4dn5vYrUVD/O833vXacM zXJtzy+Dazb3V7xqhAP3TmlP9tGqg+KAlscIh8yW5iaqhe7xjM7wHviF2SFXkwWgJw9g LhNVcZQMHBmyFxzuaQ+2md5dJwgDHGY6fbc3P0hmst8g5zfzMwae/qsGr4cnnyzaIgEL 7wWeX2JsfZ5wS8/GnpjDnVAY5z8Cs5ion3fM6vnVLcnof2kvl8rBAN7+kqdFQBcdWXMx xOjg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:user-agent:date:message-id:from :references:cc:to:subject; bh=CXFwLdQSfmN3FbAbBs4yv2RRmWLpVmQw404WLIvY480=; fh=E2hldrkvMNRaaHFZ3E1PRtRlc624ckBfoL5vzmxPF2U=; b=K7NSDHmY0vOIOrdJ08zEv+d1uvDYQxv7P19YlDzp/0XitpycRNP4StdHWwK6fxbjSD 6Kdyl0Sr/36ZrAUsYFpiL9t/L1rc1JfGpFdvD6Wpem0ZONwq5uCDOAPXt6DgEOLmSp1B LSpRB2Dip/wa5OwkloYw6tjyXu1nyRm38tIs3J8Qo2Le2kYA2v3kTLTwCgAuKU0ZD9MX nd/Qtnez8wI/KVpK+1pggmlXsGQOp2Do24Lwnn+kh6bBPMJKwqcWEOb+hQttJrb+oist gWvsOONfxveEBxiKcgbbFDUvsrkZcMgIMXo664O8nEhT6/NKmm71qwgMIKfaCHIm0OHP NRwQ== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-36392-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-36392-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id m13-20020a056a00080d00b006dbe009fcd4si4566848pfk.172.2024.01.23.19.14.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 19:14:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-36392-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-36392-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-36392-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id CA80F293156 for ; Wed, 24 Jan 2024 03:14:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 506B36105; Wed, 24 Jan 2024 03:14:30 +0000 (UTC) Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2201D46BF; Wed, 24 Jan 2024 03:14:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706066069; cv=none; b=bRBePVbFlsS55/lFPCd8Bd9EPLcj7c7QCqxtMyjG5cv5ymKYafRK56ewjqlYGWwerUyPHKO2BvWMzkiRJxj1DE84SAUqoxtSKKa1JXld0r8iAr4WUZuuGdoi1mRnNhX7PeHD7OPsoN8HWa0nWkydQxicrmXs+Z2WMHn94+boqAU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706066069; c=relaxed/simple; bh=g3vDQVNYQHCfXhK9AZEZvl7enAqSQCJdQIj+M8vN8m8=; h=Subject:To:Cc:References:From:Message-ID:Date:MIME-Version: In-Reply-To:Content-Type; b=mUq5zyRHNpFRzsFXghDVRAHwbI55cRBl6rrlNrVeEWKN+zl/lqUy7jSKPNTAOfnLGtguYduhZemSIMdqTC+FtW8LCSFpvWNrt+UcwrkiE/tDFrrA+NlB3ZOg6Gb0rjuAbCybFDCxfZQu2kkiQIEh5aQThriezsuokESBKRWrVRI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.163.216]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4TKTZd0SHRz4f3lgR; Wed, 24 Jan 2024 11:14:17 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 58BB11A017A; Wed, 24 Jan 2024 11:14:23 +0800 (CST) Received: from [10.174.176.73] (unknown [10.174.176.73]) by APP1 (Coremail) with SMTP id cCh0CgBXKBGNgLBloWgsBw--.40402S3; Wed, 24 Jan 2024 11:14:23 +0800 (CST) Subject: Re: [PATCH 3/5] md: make sure md_do_sync() will set MD_RECOVERY_DONE To: Xiao Ni , Yu Kuai Cc: mpatocka@redhat.com, dm-devel@lists.linux.dev, msnitzer@redhat.com, heinzm@redhat.com, song@kernel.org, linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org, yi.zhang@huawei.com, yangerkun@huawei.com, "yukuai (C)" References: <20240120103734.4155446-1-yukuai1@huaweicloud.com> <20240120103734.4155446-4-yukuai1@huaweicloud.com> From: Yu Kuai Message-ID: Date: Wed, 24 Jan 2024 11:14:21 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-CM-TRANSID:cCh0CgBXKBGNgLBloWgsBw--.40402S3 X-Coremail-Antispam: 1UD129KBjvJXoWxWF15Gw13GFWfWr18tFW5ZFb_yoW5Ww15p3 y8GFn0krW8Ary29F9Fqa4YqFyY9r4FyrZ8CFyfWwn8Ar93Kr13GFy0ka1UZFWDAF1fJa10 va15JF9xZFyFkFJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUU9Y14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26w1j6s0DM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26F4U JVW0owA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oV Cq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0 I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r 4UM4x0Y48IcVAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628vn2kI c2xKxwCYjI0SjxkI62AI1cAE67vIY487MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4 AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE 17CEb7AF67AKxVWUtVW8ZwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMI IF0xvE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwCI42IY6xAIw20EY4v20xvaj40_WFyUJVCq 3wCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCT nIWIevJa73UjIFyTuYvjfUoOJ5UUUUU X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ Hi, 在 2024/01/24 10:58, Xiao Ni 写道: > Hi all > > MD_RECOVERY_WAIT was introduced in d5d885fd5. From this patch, > MD_RECOVERY_WAIT only has one usage during creating raid device. > resync job needs to wait until pers->start finishes(The only place > which is checked). If we remove it from md_do_sync, will it break the > logic? Or we don't need this flag anymore? If so can we remove this > flag? > > dm-raid uses this bit in patch 644e2537f (dm raid: fix stripe adding > reshape deadlock). It's the reason why md_do_sync can't set > MD_RECOVERY_DONE. Now we stop sync thread asynchronously, can we > revert this patch? I made some changes that will be sent for v2 that sync_thread is frozen from dm suspend to resume, so I think the flag can be removed, and I actually tried that, howver, dm-raid tests failed because ext4 is corrupted. Anyway, let's focus on dm-raid regression for now and we can try to remove this flag later. Thanks, Kuai > > Best Regards > Xiao > > On Sat, Jan 20, 2024 at 6:41 PM Yu Kuai wrote: >> >> From: Yu Kuai >> >> stop_sync_thread() will interrupt md_do_sync(), and md_do_sync() must >> set MD_RECOVERY_DONE, so that follow up md_check_recovery() will >> unregister sync_thread, clear MD_RECOVERY_RUNNING and wake up >> stop_sync_thread(). >> >> Before this patch, if MD_RECOVERY_WAIT is set or the array is read-only, >> md_do_sync() will return without setting MD_RECOVERY_DONE, hence use >> stop_sync_thread() directly will hang because md_check_recovery() can't >> clear MD_RECOVERY_RUNNING, which is possible for dm-raid. >> >> Signed-off-by: Yu Kuai >> --- >> drivers/md/md.c | 10 ++++++---- >> 1 file changed, 6 insertions(+), 4 deletions(-) >> >> diff --git a/drivers/md/md.c b/drivers/md/md.c >> index 6906d023f1d6..ba45c7be3dbe 100644 >> --- a/drivers/md/md.c >> +++ b/drivers/md/md.c >> @@ -8788,12 +8788,13 @@ void md_do_sync(struct md_thread *thread) >> int ret; >> >> /* just incase thread restarts... */ >> - if (test_bit(MD_RECOVERY_DONE, &mddev->recovery) || >> - test_bit(MD_RECOVERY_WAIT, &mddev->recovery)) >> + if (test_bit(MD_RECOVERY_DONE, &mddev->recovery)) >> return; >> - if (!md_is_rdwr(mddev)) {/* never try to sync a read-only array */ >> + >> + if (test_bit(MD_RECOVERY_WAIT, &mddev->recovery) || >> + !md_is_rdwr(mddev)) {/* never try to sync a read-only array */ >> set_bit(MD_RECOVERY_INTR, &mddev->recovery); >> - return; >> + goto out; >> } >> >> if (mddev_is_clustered(mddev)) { >> @@ -9171,6 +9172,7 @@ void md_do_sync(struct md_thread *thread) >> mddev->array_sectors); >> } >> >> +out: >> spin_lock(&mddev->lock); >> if (!test_bit(MD_RECOVERY_INTR, &mddev->recovery)) { >> /* We completed so min/max setting can be forgotten if used. */ >> -- >> 2.39.2 >> >> > > . >