Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp521824rdb; Sat, 17 Feb 2024 22:22:30 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVvD/EqaMzm+2gYHjMNWaZE1ydFhC4ibeFSma1o2D20FeJGqIGE2c0kEm3qFZmkGnMD2R6HO1To2Eg465kqVoyxrMip9g3ZvKedplZ6Hg== X-Google-Smtp-Source: AGHT+IE4e6xf1WjZ/JanAk5/l2AaOK/iMOIyLTItKFvZfoart0J4DY7fUkgOnKJw9xTIBiRsM6AQ X-Received: by 2002:a05:6402:785:b0:563:ef90:9395 with SMTP id d5-20020a056402078500b00563ef909395mr3430955edy.38.1708237350108; Sat, 17 Feb 2024 22:22:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708237350; cv=pass; d=google.com; s=arc-20160816; b=1IYpGIGHThhAP6AkWCKlHyLZvNdu78FtfYp2CQMFe/lkDS5lOa10H8YkWicOYYwu1t iO3wktPGsI9ynOSkV0hgezG3nDVK9j2icjUoKM3/OshT6w2eTpRCDTiqsSANYa/pKjVN NEk2oSCZSO9bJ5HWhwgN7hltVeAjiWk54Bp1o/u0OneGLXH6sdGJsnE17nE2BDSBT+eC rSQmeWEQysabDhIn077mGY4NNkIQ/R1CFsHGxOe6gOafv2CscK4RFMT9UZKMHfJB957/ x0hS2Aey7gkdH1DW8Yna7qb/9QN7Oefo879htMjwtH+MUonInuSudwhTQoWHB7F1W26a 2GDQ== 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=O40yg2108/vYFzMa1Er04LmF5a3eKVCc6Q3zaN7Hs0Y=; fh=hpgXmDcHmoAP7QiZFPl4dBcSK4LHxEp3OCRhZY9sl74=; b=rc4TDBeNwWIOZ/KIszexG/rgn9KaLqWHNHLnYB4UZhUpIl9HhLhdqX0NIW+BMVjEWt BTxDJNV269Qj5GQphpCG+sd1nN0pAf3JKl6T5HF5cHI9nYux8JNEadp6Jk7tik6rAgcw 91DBGiES3AH+zXK1lt8LWWS6mthXTnRStH2uDGdjGAB5te2QFY94KqergR3FAqjAwWdw ofTCv+xPEjqctzqtORwck7mKML1qRjLY4DjDk2JGIlwDP9Y3yNLjS1FtgosNU0KKqQrX JBXOFCIRV/88K8+eOg/brRokdQJmWrQXN3V4uEwvoQ6S6JsCfibioLI+76oMA9hlOU2j GSVA==; dara=google.com 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-70217-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70217-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id p2-20020a50cd82000000b005638df46e5bsi1424685edi.648.2024.02.17.22.22.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Feb 2024 22:22:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-70217-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-70217-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70217-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 9CA7D1F217EF for ; Sun, 18 Feb 2024 06:22:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9818A63A7; Sun, 18 Feb 2024 06:22:19 +0000 (UTC) Received: from dggsgout12.his.huawei.com (unknown [45.249.212.56]) (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 7114E15C9; Sun, 18 Feb 2024 06:22:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708237339; cv=none; b=kT3tH8huh7PHSrPlm/h9km2R5QpmSK05ER5ffn1Y7683CF0LfeMURN8ynR/zzv6Go9ZM8g99XvKu0dVwLincNAxfrQhBO5XVlAESUuyJk6nYDETEiTnjxl+xkLCyfVCUY1SWTesWlh7V11MLshF9N+RWkliQWu/X/IqEVmuN8D8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708237339; c=relaxed/simple; bh=DELF/Sa212R0lUf3hHPALmBz+5/UQRBsAaWQYXYZETc=; h=Subject:To:Cc:References:From:Message-ID:Date:MIME-Version: In-Reply-To:Content-Type; b=FOHssHe59p47pufgJFyPTNGBzyU450PgCyQC0mZ6TsoXbUi28brceh4hnUS4K9cM9th4USL5NfGAnR7PeW+inNodKwY6/1n1gLvPr7XxAJDUzj/XOVSIGVhoAHFMtAuEGaisOmh/23CqYZ6CXl3fdkGhcH0LcgT9e5Ga6BSzy7I= 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.56 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 dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4TcwYm5Yghz4f3jMP; Sun, 18 Feb 2024 14:22:04 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 9E2801A0D7B; Sun, 18 Feb 2024 14:22:09 +0800 (CST) Received: from [10.174.176.73] (unknown [10.174.176.73]) by APP1 (Coremail) with SMTP id cCh0CgCXaBEPotFlQQ17EQ--.38616S3; Sun, 18 Feb 2024 14:22:09 +0800 (CST) Subject: Re: [PATCH v5 01/14] md: don't ignore suspended array in md_check_recovery() To: Xiao Ni , Yu Kuai Cc: mpatocka@redhat.com, heinzm@redhat.com, blazej.kucman@linux.intel.com, agk@redhat.com, snitzer@kernel.org, dm-devel@lists.linux.dev, song@kernel.org, jbrassow@f14.redhat.com, neilb@suse.de, shli@fb.com, akpm@osdl.org, linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, yi.zhang@huawei.com, yangerkun@huawei.com, "yukuai (C)" References: <20240201092559.910982-1-yukuai1@huaweicloud.com> <20240201092559.910982-2-yukuai1@huaweicloud.com> <64d27757-9387-09dc-48e8-a9eedd67f075@huaweicloud.com> <2fa01c30-2ee7-7c01-6833-bf74142e6d7c@huaweicloud.com> From: Yu Kuai Message-ID: <5480b350-efe3-2be7-cf3b-3a62bb0e012b@huaweicloud.com> Date: Sun, 18 Feb 2024 14:22:07 +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:cCh0CgCXaBEPotFlQQ17EQ--.38616S3 X-Coremail-Antispam: 1UD129KBjvJXoW3Wr15XF1kGry7AF1ktrW5K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13:07, Xiao Ni 写道: > On Sun, Feb 18, 2024 at 11:24 AM Yu Kuai wrote: >> >> Hi, >> >> 在 2024/02/18 11:15, Xiao Ni 写道: >>> On Sun, Feb 18, 2024 at 10:34 AM Yu Kuai wrote: >>>> >>>> Hi, >>>> >>>> 在 2024/02/18 10:27, Xiao Ni 写道: >>>>> On Sun, Feb 18, 2024 at 9:46 AM Yu Kuai wrote: >>>>>> >>>>>> Hi, >>>>>> >>>>>> 在 2024/02/18 9:33, Xiao Ni 写道: >>>>>>> The deadlock problem mentioned in this patch should not be right? >>>>>> >>>>>> No, I think it's right. Looks like you are expecting other problems, >>>>>> like mentioned in patch 6, to be fixed by this patch. >>>>> >>>>> Hi Kuai >>>>> >>>>> Could you explain why step1 and step2 from this comment can happen >>>>> simultaneously? From the log, the process should be >>>>> The process is : >>>>> dev_remove->dm_destroy->__dm_destroy->dm_table_postsuspend_targets(raid_postsuspend) >>>>> -> dm_table_destroy(raid_dtr). >>>>> After suspending the array, it calls raid_dtr. So these two functions >>>>> can't happen simultaneously. >>>> >>>> You're removing the target directly, however, dm can suspend the disk >>>> directly, you can simplily: >>>> >>>> 1) dmsetup suspend xxx >>>> 2) dmsetup remove xxx >>> >>> For dm-raid, the design of suspend stops sync thread first and then it >>> calls mddev_suspend to suspend array. So I'm curious why the sync >>> thread can still exit when array is suspended. I know the reason now. >>> Because before f52f5c71f (md: fix stopping sync thread), the process >>> is raid_postsuspend->md_stop_writes->__md_stop_writes >>> (__md_stop_writes sets MD_RECOVERY_FROZEN). In patch f52f5c71f, it >>> doesn't set MD_RECOVERY_FROZEN in __md_stop_writes anymore. >>> >>> The process changes to >>> 1. raid_postsuspend->md_stop_writes->__md_stop_writes->stop_sync_thread >>> (wait until MD_RECOVERY_RUNNING clears) >>> 2. md thread -> md_check_recovery -> unregister_sync_thread -> >>> md_reap_sync_thread (clears MD_RECOVERY_RUNNING, stop_sync_thread >>> returns, md_reap_sync_thread sets MD_RECOVERY_NEEDED) >>> 3. raid_postsuspend->mddev_suspend >>> 4. md sync thread starts again because __md_stop_writes doesn't set >>> MD_RECOVERY_FROZEN. >>> It's the reason why we can see sync thread still happens when raid is suspended. >>> >>> So the patch fix this problem should: >> >> As I said, this is really a different problem from this patch, and it is >> fixed seperately by patch 9. Please take a look at that patch. > > I think we're talking about the same problem. In patch07 it has a new > api md_frozen_sync_thread. It sets MD_RECOVERY_FROZEN before > stop_sync_thread. This is right. If we use this api in > raid_postsuspend, sync thread can't restart. So the deadlock can't > happen anymore? We are not talking about the same problem at all. This patch just fix a simple problem in md/raid(not dm-raid). And the deadlock can also be triggered for md/raid the same. - mddev_suspend() doesn't handle sync_thread at all; - md_check_recovery() ignore suspended array; Please keep in mind this patch just fix the above case. The deadlock in dm-raid is just an example of problems caused by this. Fix the deadlock other way doesn't mean this case is fine. > > And patch01 is breaking one logic which seems right: > > commit 68866e425be2ef2664aa5c691bb3ab789736acf5 > Author: Jonathan Brassow > Date: Wed Jun 8 15:10:08 2011 +1000 > > MD: no sync IO while suspended > > Disallow resync I/O while the RAID array is suspended. > > We're trying to fix deadlock problems. But it's not good to fix a > problem by breaking an existing rule. The existing rule itself is problematic. Above patch doesn't do well. It's just a simple problem here, should sync thread also stop in mddev_suspend? If you want do do this, you can submit a patch, in the right way, we'll see how this will work. - keep this patch to remove checking of suspended array; - set MD_RECOVERY_FORZEN and stop sync thread in mddev_suspend, 'reconfig_mutex' will be needed again, and lots of callers need to be checked. Thanks, Kuai > > Regards > Xiao > > >> >> Thanks, >> Kuai >> >>> >>> diff --git a/drivers/md/md.c b/drivers/md/md.c >>> index 9e41a9aaba8b..666761466f02 100644 >>> --- a/drivers/md/md.c >>> +++ b/drivers/md/md.c >>> @@ -6315,6 +6315,7 @@ static void md_clean(struct mddev *mddev) >>> >>> static void __md_stop_writes(struct mddev *mddev) >>> { >>> + set_bit(MD_RECOVERY_FROZEN, &mddev->recovery); >>> stop_sync_thread(mddev, true, false); >>> del_timer_sync(&mddev->safemode_timer); >>> >>> Like other places which call stop_sync_thread, it needs to set the >>> MD_RECOVERY_FROZEN bit. >>> >>> Regards >>> Xiao >>> >>>> >>>> Please also take a look at other patches, why step 1) can't stop sync >>>> thread. >>>> >>>> Thanks, >>>> Kuai >>>> >>>>> >>>>> >>>>>> >>>>>> Noted that this patch just fix one case that MD_RECOVERY_RUNNING can't >>>>>> be cleared, I you are testing this patch alone, please make sure that >>>>>> you still triggered the exactly same case: >>>>>> >>>>>> - MD_RCOVERY_RUNNING can't be cleared while array is suspended. >>>>> >>>>> I'm not testing this patch. I want to understand the patch well. So I >>>>> need to understand the issue first. I can't understand how this >>>>> deadlock (step1,step2) happens. >>>>> >>>>> Regards >>>>> Xiao >>>>>> >>>>>> Thanks, >>>>>> Kuai >>>>>> >>>>> >>>>> . >>>>> >>>> >>> >>> . >>> >> > > . >