Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp481231rdb; Sat, 17 Feb 2024 19:25:27 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV9gsIw/bIQtXYw5qhGBlBUMjEEULFRMX0HUfsGAtFP0tT0Sc9CSV9JbjvJSD7k30wwODDhDMpMTA9xJhWD1F9z/DMuN9ziReBjT7lk1w== X-Google-Smtp-Source: AGHT+IFBol0SuMI3bzWsVhxhNRwwH4G7kRwE6XvU0Ow3d5UnI/fiL7s4HDgu3/yViVEbZVzyCS/A X-Received: by 2002:a17:902:b20a:b0:1d9:a647:5579 with SMTP id t10-20020a170902b20a00b001d9a6475579mr7818054plr.1.1708226727082; Sat, 17 Feb 2024 19:25:27 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708226727; cv=pass; d=google.com; s=arc-20160816; b=sRdBW/elBpJ2BqndmUYU0TVqBhcjR0TAvZlP6BD3VTwae8ig/3HdMHOg9MxZZkKtd4 UXwCihtJCoWenHwPArGFxIfiv4eJpguGGOqc0MpgB3H0Vcif1suxFoefDITe1nIXdd5b WFPgHgT6wxb/dSwJja7Yzx5V/qIqiUKuycDo9sAYh1sTlwsvHnpKitRYGfKpyc2csznD is+6BkdDmpjf6g21GVgK8lQjgGZiuLNH+NeW+nvUvLC+ms2AcUWvs6XADtdXbw9Q/tVw Vw+UhxQppbc0IbvH9xlH8Y0DZpVlTFgjfMNiB76RLC+UJlga5Xa0ux4e0afgW+FBxBQZ 6jJQ== 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=3AHJOd/ed/0fmEnQdXnfGHEU5bzs1x/Q8P4g9JcZy1U=; fh=hpgXmDcHmoAP7QiZFPl4dBcSK4LHxEp3OCRhZY9sl74=; b=Iw0hbNsSeCPRyCW+Z4xubd76q62RDKI/V4OaNiyyPJ39A5e1NxrMiE8HdACNqgsjrI oOv7h8kqu8PV3yBN85KmvMvlyhtPfeD9OZq9MGXFdSY3FcBK/gmJo8BkBA8qW5J/8PhD f3D2GCG97DsbeZJ3uqwRz4siPhjAMcjhXiuXBRUl+gjAsEejhVSaKl8E8ZO0KDsGK5Sd BXgr+PM0QlJH1zgCf9sOpYKvzTp1ZLF+Jni7DFAXftVmIUj2ly0hhE90KNN9+x8DWjPK xclaVu4nYDsaT6Mn9uZVKWN1gKgkH8Fd1FxtQ7zYt4bLHKsF1ZQghwXVJ5nI4IrjvWYN hu7Q==; 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-70177-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70177-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id c4-20020a170903234400b001d9c1dedd99si2294884plh.384.2024.02.17.19.25.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Feb 2024 19:25:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-70177-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-70177-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70177-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 F39682822FF for ; Sun, 18 Feb 2024 03:24:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A9C225227; Sun, 18 Feb 2024 03:24:43 +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 9D3734C6D; Sun, 18 Feb 2024 03:24:40 +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=1708226683; cv=none; b=pHefC7beNVT7HNvcHxws7fOltNSOCCO/PzxXD5cv+LZo/xhYi92YVpBYD1ykfTRqtlwMvbMIRN02NzWw1R26Hiv8IZu3pP1njggBVESCgRXwW99PVKLFOlYDEMCqtwZ4cGGfuw2DZmjQQrIR+AipjddBkZ8bzUNJNkVMXL59ur0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708226683; c=relaxed/simple; bh=BY05uZrcFu7xtAxk5fCx+bheSiCu/C4nKPg69SmEjJk=; h=Subject:To:Cc:References:From:Message-ID:Date:MIME-Version: In-Reply-To:Content-Type; b=WXi0jOoQRzbnuzZd9sOnS3jx5A/ftdTmjQvEfOS0Mqp7oT50OczRy2pp36OG0yua6hpIS4pbkC6m+1jEfbJBLXGGMte9GEV7gjlTpOd6/GA87nwgTqAXOpDQrNvXyGZBaR4BJ80Bs+lCVxyCzh0b2QGI/VFt1leIbaAinoa5wes= 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.93.142]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4Tcrcs4DS9z4f3lWJ; Sun, 18 Feb 2024 11:24:29 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id 978A31A0172; Sun, 18 Feb 2024 11:24:36 +0800 (CST) Received: from [10.174.176.73] (unknown [10.174.176.73]) by APP4 (Coremail) with SMTP id gCh0CgB3fW9yeNFlYqKrEQ--.57206S3; Sun, 18 Feb 2024 11:24:36 +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> From: Yu Kuai Message-ID: <2fa01c30-2ee7-7c01-6833-bf74142e6d7c@huaweicloud.com> Date: Sun, 18 Feb 2024 11:24:34 +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:gCh0CgB3fW9yeNFlYqKrEQ--.57206S3 X-Co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uYvjfUOmhFUUUUU X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ 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. 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 >>>> >>> >>> . >>> >> > > . >