Message ID | 20240201092559.910982-2-yukuai1@huaweicloud.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-47864-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2719:b0:106:209c:c626 with SMTP id hl25csp29430dyb; Thu, 1 Feb 2024 01:31:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IFYP5gXKr0DlvaExxBhR7HXFCcecKF8+rtGM14OG4s5JVksOqfrTlfhCj4cGBcNqkg35kp0 X-Received: by 2002:a05:6402:1cb9:b0:55f:aed2:98eb with SMTP id cz25-20020a0564021cb900b0055faed298ebmr877070edb.40.1706779863545; Thu, 01 Feb 2024 01:31:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706779863; cv=pass; d=google.com; s=arc-20160816; b=kSnJ5TgiHFLglvVajlffrWagftZ7ZaWx99YNwTbTltz19R/65cke8rBmKzu9BeAbGc W/kNpVNofcE5tvM5u+7HPFRR7eNE4Dv+qv2QJ8xx+dcnDyqVg0TvHIo9BST9W1vmvzvl E1dPJiFNwF3IcpWR1IsRC4MyzM+9KUMsbejTlnqth3yFqZFFsPbk7Sykd4o7PKdvJlAn YFWOFHe6Omg8A9aQ4i+aowF+LKUDhk9pzEzkuh1+5GZcNhcExI69Af1XSN4vW11R3Lcu LsN+HtsluQrzx+M4e4P/PByXzTCMh8Nfjlv9x6632xqXxau0Jaxo3m0IMxa4zgKfeN6A v7lw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=dBaWySK1O6HNfOrqRqopNpWnbd2nAQFt9nqs3kj8Nq8=; fh=ys5ZFiOR4HW6mMVRzQqB0m6by8yvbuK9vDYMYQL2vk4=; b=e0ib/pUmPPyrvadKocOmZnXu/5En1bIKElBozTM8BZu+yh2GO8Aw3e/LF6mKQcQ6Y5 rkVb5F5X6Qpuq90dbtANLeig0P3uJdpnwxEUvnOQJP1QncLnnv5NJoUDR0THpj2hCAZ7 MtJTqAr14IKSbeKUHN4cEpCR12upIUezoJHB5E9RujbGDDrZIGhZPaESXjZuD5RQ+sMq 1wi1z6Q9+3hH8eTPjHHUI6uyCntZn7O7N250DW0OX3C3Xpe6SDDZa3ndpdEixZrhgHrZ DGDXCid7LDBeKn404pdLtzs2TLoR5oEfgxt4E4RLSuxPCr+kwcz/4u6hayRAtbegtcfR Ft4g==; 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-47864-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47864-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCWkpZuyEwEGsKreOY7Mvdhd0hxCSwSbM0L6aGDlRvgApmhqutooxnqeAJ2EI5UshX8GlP6lQAL2pq1CNDHvpnnllD5q2g== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id g15-20020a056402090f00b0055a748b0999si6486409edz.544.2024.02.01.01.31.03 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 01:31:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-47864-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-47864-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47864-ouuuleilei=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 2CFCC1F275DB for <ouuuleilei@gmail.com>; Thu, 1 Feb 2024 09:31:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D853715CD42; Thu, 1 Feb 2024 09:30:32 +0000 (UTC) Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [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 6F05E15B105; Thu, 1 Feb 2024 09:30:28 +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=1706779830; cv=none; b=bEEIjJCE816EvQ4nP0jxfD/AtoqUMOi4AMs4q2HNCenaZ7Q7WRMihnywTCSFFEkDCVLToYLIvQSem3Vk/DqxoCGKQ78tdvhbe2YRTwPduzYe8UCHV1ALXFYApP/N5tK7pkzYzXxeCtXXn+an+0ZkkLtj0IyJVo+fhqx91seX3fA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706779830; c=relaxed/simple; bh=niaIFrprWvPwC2Lv0RN5Cl1tFCytXopzeriQpGSoAMg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=MpoSpwa8+pBknnpZirnoXmS4nUWBxljhhyFl370geFCfkrMyb339iRhwugW4VexslKOrYRKqHTj8AIHU6vB0uPsSVl7MUoc0/snWPMTfXLhsF/kh9cTeDPMQbvE1HZfZsdTQK5aF1VD95dKGo38+rYIuTLHrRNpUgJfmZkx+l74= 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.235]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4TQYXs2rwzz4f3l6f; Thu, 1 Feb 2024 17:30:21 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 974E11A0283; Thu, 1 Feb 2024 17:30:25 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgCXaBGtZLtl8V6KCg--.33515S5; Thu, 01 Feb 2024 17:30:25 +0800 (CST) From: Yu Kuai <yukuai1@huaweicloud.com> To: mpatocka@redhat.com, heinzm@redhat.com, xni@redhat.com, blazej.kucman@linux.intel.com, agk@redhat.com, snitzer@kernel.org, dm-devel@lists.linux.dev, song@kernel.org, yukuai3@huawei.com, jbrassow@f14.redhat.com, neilb@suse.de, shli@fb.com, akpm@osdl.org Cc: linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH v5 01/14] md: don't ignore suspended array in md_check_recovery() Date: Thu, 1 Feb 2024 17:25:46 +0800 Message-Id: <20240201092559.910982-2-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240201092559.910982-1-yukuai1@huaweicloud.com> References: <20240201092559.910982-1-yukuai1@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: cCh0CgCXaBGtZLtl8V6KCg--.33515S5 X-Coremail-Antispam: 1UD129KBjvJXoWxJryDAF43ArW7JrWrZr1xGrg_yoW8ZFy7pa yIkF1YyrWjyFZ7Aa4qka4UZa4rAr1jqrW5AFy3u34rCa4fKw43CrWYgFyDXFyqkFyxKrZY vw4rJa15uw18KF7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUBE14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_Jr4l82xGYIkIc2 x26xkF7I0E14v26r4j6ryUM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJw A2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq3wAS 0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2 IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0 Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628vn2kIc2 xKxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v2 6r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_GFv_WrylIxkGc2 Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_ Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMI IF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x0JU4T5dUUUUU = X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789688401974209136 X-GMAIL-MSGID: 1789688401974209136 |
Series |
[v5,01/14] md: don't ignore suspended array in md_check_recovery()
|
|
Commit Message
Yu Kuai
Feb. 1, 2024, 9:25 a.m. UTC
From: Yu Kuai <yukuai3@huawei.com> mddev_suspend() never stop sync_thread, hence it doesn't make sense to ignore suspended array in md_check_recovery(), which might cause sync_thread can't be unregistered. After commit f52f5c71f3d4 ("md: fix stopping sync thread"), following hang can be triggered by test shell/integrity-caching.sh: 1) suspend the array: raid_postsuspend mddev_suspend 2) stop the array: raid_dtr md_stop __md_stop_writes stop_sync_thread set_bit(MD_RECOVERY_INTR, &mddev->recovery); md_wakeup_thread_directly(mddev->sync_thread); wait_event(..., !test_bit(MD_RECOVERY_RUNNING, &mddev->recovery)) 3) sync thread done: md_do_sync set_bit(MD_RECOVERY_DONE, &mddev->recovery); md_wakeup_thread(mddev->thread); 4) daemon thread can't unregister sync thread: md_check_recovery if (mddev->suspended) return; -> return directly md_read_sync_thread clear_bit(MD_RECOVERY_RUNNING, &mddev->recovery); -> MD_RECOVERY_RUNNING can't be cleared, hence step 2 hang; This problem is not just related to dm-raid, fix it by ignoring suspended array in md_check_recovery(). And follow up patches will improve dm-raid better to frozen sync thread during suspend. Reported-by: Mikulas Patocka <mpatocka@redhat.com> Closes: https://lore.kernel.org/all/8fb335e-6d2c-dbb5-d7-ded8db5145a@redhat.com/ Fixes: 68866e425be2 ("MD: no sync IO while suspended") Fixes: f52f5c71f3d4 ("md: fix stopping sync thread") Signed-off-by: Yu Kuai <yukuai3@huawei.com> --- drivers/md/md.c | 3 --- 1 file changed, 3 deletions(-)
Comments
On Thu, Feb 1, 2024 at 5:30 PM Yu Kuai <yukuai1@huaweicloud.com> wrote: > > From: Yu Kuai <yukuai3@huawei.com> > > mddev_suspend() never stop sync_thread, hence it doesn't make sense to > ignore suspended array in md_check_recovery(), which might cause > sync_thread can't be unregistered. > > After commit f52f5c71f3d4 ("md: fix stopping sync thread"), following > hang can be triggered by test shell/integrity-caching.sh: Hi Kuai After applying this patch, it's still stuck at mddev_suspend. Maybe the deadlock can be fixed by other patches from the patch set. But this patch can't fix this issue. If so, the comment is not right. > > 1) suspend the array: > raid_postsuspend > mddev_suspend > > 2) stop the array: > raid_dtr > md_stop > __md_stop_writes > stop_sync_thread > set_bit(MD_RECOVERY_INTR, &mddev->recovery); > md_wakeup_thread_directly(mddev->sync_thread); > wait_event(..., !test_bit(MD_RECOVERY_RUNNING, &mddev->recovery)) > > 3) sync thread done: > md_do_sync > set_bit(MD_RECOVERY_DONE, &mddev->recovery); > md_wakeup_thread(mddev->thread); > > 4) daemon thread can't unregister sync thread: > md_check_recovery > if (mddev->suspended) > return; -> return directly > md_read_sync_thread > clear_bit(MD_RECOVERY_RUNNING, &mddev->recovery); > -> MD_RECOVERY_RUNNING can't be cleared, hence step 2 hang; I add some debug logs when stopping dmraid with lvremove command. The step you mentioned are sequential but not async. The process is : dev_remove->dm_destroy->__dm_destroy->dm_table_postsuspend_targets(raid_postsuspend) -> dm_table_destroy(raid_dtr). It looks like mddev_suspend is waiting for active_io to be zero. Best Regards Xiao > This problem is not just related to dm-raid, fix it by ignoring > suspended array in md_check_recovery(). And follow up patches will > improve dm-raid better to frozen sync thread during suspend. > > Reported-by: Mikulas Patocka <mpatocka@redhat.com> > Closes: https://lore.kernel.org/all/8fb335e-6d2c-dbb5-d7-ded8db5145a@redhat.com/ > Fixes: 68866e425be2 ("MD: no sync IO while suspended") > Fixes: f52f5c71f3d4 ("md: fix stopping sync thread") > Signed-off-by: Yu Kuai <yukuai3@huawei.com> > --- > drivers/md/md.c | 3 --- > 1 file changed, 3 deletions(-) > > diff --git a/drivers/md/md.c b/drivers/md/md.c > index 2266358d8074..07b80278eaa5 100644 > --- a/drivers/md/md.c > +++ b/drivers/md/md.c > @@ -9469,9 +9469,6 @@ static void md_start_sync(struct work_struct *ws) > */ > void md_check_recovery(struct mddev *mddev) > { > - if (READ_ONCE(mddev->suspended)) > - return; > - > if (mddev->bitmap) > md_bitmap_daemon_work(mddev); > > -- > 2.39.2 >
Hi, 在 2024/02/16 14:58, Xiao Ni 写道: > On Thu, Feb 1, 2024 at 5:30 PM Yu Kuai <yukuai1@huaweicloud.com> wrote: >> >> From: Yu Kuai <yukuai3@huawei.com> >> >> mddev_suspend() never stop sync_thread, hence it doesn't make sense to >> ignore suspended array in md_check_recovery(), which might cause >> sync_thread can't be unregistered. >> >> After commit f52f5c71f3d4 ("md: fix stopping sync thread"), following >> hang can be triggered by test shell/integrity-caching.sh: > > Hi Kuai > > After applying this patch, it's still stuck at mddev_suspend. Maybe > the deadlock can be fixed by other patches from the patch set. But > this patch can't fix this issue. If so, the comment is not right. This patch alone can't fix the problem that mddev_suspend() can stuck thoroughly, patches 1-4 will all be needed. Thanks, Kuai > >> >> 1) suspend the array: >> raid_postsuspend >> mddev_suspend >> >> 2) stop the array: >> raid_dtr >> md_stop >> __md_stop_writes >> stop_sync_thread >> set_bit(MD_RECOVERY_INTR, &mddev->recovery); >> md_wakeup_thread_directly(mddev->sync_thread); >> wait_event(..., !test_bit(MD_RECOVERY_RUNNING, &mddev->recovery)) >> >> 3) sync thread done: >> md_do_sync >> set_bit(MD_RECOVERY_DONE, &mddev->recovery); >> md_wakeup_thread(mddev->thread); >> >> 4) daemon thread can't unregister sync thread: >> md_check_recovery >> if (mddev->suspended) >> return; -> return directly >> md_read_sync_thread >> clear_bit(MD_RECOVERY_RUNNING, &mddev->recovery); >> -> MD_RECOVERY_RUNNING can't be cleared, hence step 2 hang; > > I add some debug logs when stopping dmraid with lvremove command. The > step you mentioned are sequential but not async. The process is : > dev_remove->dm_destroy->__dm_destroy->dm_table_postsuspend_targets(raid_postsuspend) > -> dm_table_destroy(raid_dtr). It looks like mddev_suspend is waiting > for active_io to be zero. > > Best Regards > Xiao > >> This problem is not just related to dm-raid, fix it by ignoring >> suspended array in md_check_recovery(). And follow up patches will >> improve dm-raid better to frozen sync thread during suspend. >> >> Reported-by: Mikulas Patocka <mpatocka@redhat.com> >> Closes: https://lore.kernel.org/all/8fb335e-6d2c-dbb5-d7-ded8db5145a@redhat.com/ >> Fixes: 68866e425be2 ("MD: no sync IO while suspended") >> Fixes: f52f5c71f3d4 ("md: fix stopping sync thread") >> Signed-off-by: Yu Kuai <yukuai3@huawei.com> >> --- >> drivers/md/md.c | 3 --- >> 1 file changed, 3 deletions(-) >> >> diff --git a/drivers/md/md.c b/drivers/md/md.c >> index 2266358d8074..07b80278eaa5 100644 >> --- a/drivers/md/md.c >> +++ b/drivers/md/md.c >> @@ -9469,9 +9469,6 @@ static void md_start_sync(struct work_struct *ws) >> */ >> void md_check_recovery(struct mddev *mddev) >> { >> - if (READ_ONCE(mddev->suspended)) >> - return; >> - >> if (mddev->bitmap) >> md_bitmap_daemon_work(mddev); >> >> -- >> 2.39.2 >> > > > . >
On Sun, Feb 18, 2024 at 9:15 AM Yu Kuai <yukuai1@huaweicloud.com> wrote: > > Hi, > > 在 2024/02/16 14:58, Xiao Ni 写道: > > On Thu, Feb 1, 2024 at 5:30 PM Yu Kuai <yukuai1@huaweicloud.com> wrote: > >> > >> From: Yu Kuai <yukuai3@huawei.com> > >> > >> mddev_suspend() never stop sync_thread, hence it doesn't make sense to > >> ignore suspended array in md_check_recovery(), which might cause > >> sync_thread can't be unregistered. > >> > >> After commit f52f5c71f3d4 ("md: fix stopping sync thread"), following > >> hang can be triggered by test shell/integrity-caching.sh: > > > > Hi Kuai > > > > After applying this patch, it's still stuck at mddev_suspend. Maybe > > the deadlock can be fixed by other patches from the patch set. But > > this patch can't fix this issue. If so, the comment is not right. > > This patch alone can't fix the problem that mddev_suspend() can stuck > thoroughly, patches 1-4 will all be needed. > > Thanks, > Kuai > > > > >> > >> 1) suspend the array: > >> raid_postsuspend > >> mddev_suspend > >> > >> 2) stop the array: > >> raid_dtr > >> md_stop > >> __md_stop_writes > >> stop_sync_thread > >> set_bit(MD_RECOVERY_INTR, &mddev->recovery); > >> md_wakeup_thread_directly(mddev->sync_thread); > >> wait_event(..., !test_bit(MD_RECOVERY_RUNNING, &mddev->recovery)) > >> > >> 3) sync thread done: > >> md_do_sync > >> set_bit(MD_RECOVERY_DONE, &mddev->recovery); > >> md_wakeup_thread(mddev->thread); > >> > >> 4) daemon thread can't unregister sync thread: > >> md_check_recovery > >> if (mddev->suspended) > >> return; -> return directly > >> md_read_sync_thread > >> clear_bit(MD_RECOVERY_RUNNING, &mddev->recovery); > >> -> MD_RECOVERY_RUNNING can't be cleared, hence step 2 hang; > > > > I add some debug logs when stopping dmraid with lvremove command. The > > step you mentioned are sequential but not async. The process is : > > dev_remove->dm_destroy->__dm_destroy->dm_table_postsuspend_targets(raid_postsuspend) > > -> dm_table_destroy(raid_dtr). It looks like mddev_suspend is waiting > > for active_io to be zero. The deadlock problem mentioned in this patch should not be right? Regards Xiao > > > > Best Regards > > Xiao > > > >> This problem is not just related to dm-raid, fix it by ignoring > >> suspended array in md_check_recovery(). And follow up patches will > >> improve dm-raid better to frozen sync thread during suspend. > >> > >> Reported-by: Mikulas Patocka <mpatocka@redhat.com> > >> Closes: https://lore.kernel.org/all/8fb335e-6d2c-dbb5-d7-ded8db5145a@redhat.com/ > >> Fixes: 68866e425be2 ("MD: no sync IO while suspended") > >> Fixes: f52f5c71f3d4 ("md: fix stopping sync thread") > >> Signed-off-by: Yu Kuai <yukuai3@huawei.com> > >> --- > >> drivers/md/md.c | 3 --- > >> 1 file changed, 3 deletions(-) > >> > >> diff --git a/drivers/md/md.c b/drivers/md/md.c > >> index 2266358d8074..07b80278eaa5 100644 > >> --- a/drivers/md/md.c > >> +++ b/drivers/md/md.c > >> @@ -9469,9 +9469,6 @@ static void md_start_sync(struct work_struct *ws) > >> */ > >> void md_check_recovery(struct mddev *mddev) > >> { > >> - if (READ_ONCE(mddev->suspended)) > >> - return; > >> - > >> if (mddev->bitmap) > >> md_bitmap_daemon_work(mddev); > >> > >> -- > >> 2.39.2 > >> > > > > > > . > > >
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.
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.
Thanks,
Kuai
On Sun, Feb 18, 2024 at 9:46 AM Yu Kuai <yukuai1@huaweicloud.com> 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. > > 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 >
Hi, 在 2024/02/18 10:27, Xiao Ni 写道: > On Sun, Feb 18, 2024 at 9:46 AM Yu Kuai <yukuai1@huaweicloud.com> 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 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 >> > > . >
On Sun, Feb 18, 2024 at 10:34 AM Yu Kuai <yukuai1@huaweicloud.com> wrote: > > Hi, > > 在 2024/02/18 10:27, Xiao Ni 写道: > > On Sun, Feb 18, 2024 at 9:46 AM Yu Kuai <yukuai1@huaweicloud.com> 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: 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 > >> > > > > . > > >
Hi, 在 2024/02/18 11:15, Xiao Ni 写道: > On Sun, Feb 18, 2024 at 10:34 AM Yu Kuai <yukuai1@huaweicloud.com> wrote: >> >> Hi, >> >> 在 2024/02/18 10:27, Xiao Ni 写道: >>> On Sun, Feb 18, 2024 at 9:46 AM Yu Kuai <yukuai1@huaweicloud.com> 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 >>>> >>> >>> . >>> >> > > . >
On Sun, Feb 18, 2024 at 11:24 AM Yu Kuai <yukuai1@huaweicloud.com> wrote: > > Hi, > > 在 2024/02/18 11:15, Xiao Ni 写道: > > On Sun, Feb 18, 2024 at 10:34 AM Yu Kuai <yukuai1@huaweicloud.com> wrote: > >> > >> Hi, > >> > >> 在 2024/02/18 10:27, Xiao Ni 写道: > >>> On Sun, Feb 18, 2024 at 9:46 AM Yu Kuai <yukuai1@huaweicloud.com> 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? And patch01 is breaking one logic which seems right: commit 68866e425be2ef2664aa5c691bb3ab789736acf5 Author: Jonathan Brassow <jbrassow@f14.redhat.com> 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. 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 > >>>> > >>> > >>> . > >>> > >> > > > > . > > >
Hi, 在 2024/02/18 13:07, Xiao Ni 写道: > On Sun, Feb 18, 2024 at 11:24 AM Yu Kuai <yukuai1@huaweicloud.com> wrote: >> >> Hi, >> >> 在 2024/02/18 11:15, Xiao Ni 写道: >>> On Sun, Feb 18, 2024 at 10:34 AM Yu Kuai <yukuai1@huaweicloud.com> wrote: >>>> >>>> Hi, >>>> >>>> 在 2024/02/18 10:27, Xiao Ni 写道: >>>>> On Sun, Feb 18, 2024 at 9:46 AM Yu Kuai <yukuai1@huaweicloud.com> 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 <jbrassow@f14.redhat.com> > 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 >>>>>> >>>>> >>>>> . >>>>> >>>> >>> >>> . >>> >> > > . >
On Sun, Feb 18, 2024 at 2:22 PM Yu Kuai <yukuai1@huaweicloud.com> wrote: > > Hi, > > 在 2024/02/18 13:07, Xiao Ni 写道: > > On Sun, Feb 18, 2024 at 11:24 AM Yu Kuai <yukuai1@huaweicloud.com> wrote: > >> > >> Hi, > >> > >> 在 2024/02/18 11:15, Xiao Ni 写道: > >>> On Sun, Feb 18, 2024 at 10:34 AM Yu Kuai <yukuai1@huaweicloudcom> wrote: > >>>> > >>>> Hi, > >>>> > >>>> 在 2024/02/18 10:27, Xiao Ni 写道: > >>>>> On Sun, Feb 18, 2024 at 9:46 AM Yu Kuai <yukuai1@huaweicloud.com> 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. Because this patch set is used to fix dm raid deadlocks. But this patch changes logic, it looks like more a feature - "we can start/stop sync thread when array is suspended". Because this patch is added many years ago and dm raid works well. If we change this, there is possibilities to introduce new problems. Now we should try to walk slowly. And is it a deadlock? After resume, the sync thread can be started/stopped again. Could you explain the deadlock more? > > > > > And patch01 is breaking one logic which seems right: > > > > commit 68866e425be2ef2664aa5c691bb3ab789736acf5 > > Author: Jonathan Brassow <jbrassow@f14.redhat.com> > > 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. I don't want to change the logic of mddev_suspend. mddev_suspend is only used to suspend array. Cc Jon who is the author of this patch. > > - 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 > >>>>>> > >>>>> > >>>>> . > >>>>> > >>>> > >>> > >>> . > >>> > >> > > > > . > > >
Hi, 在 2024/02/18 16:07, Xiao Ni 写道: > On Sun, Feb 18, 2024 at 2:22 PM Yu Kuai <yukuai1@huaweicloud.com> wrote: >> >> Hi, >> >> 在 2024/02/18 13:07, Xiao Ni 写道: >>> On Sun, Feb 18, 2024 at 11:24 AM Yu Kuai <yukuai1@huaweicloud.com> wrote: >>>> >>>> Hi, >>>> >>>> 在 2024/02/18 11:15, Xiao Ni 写道: >>>>> On Sun, Feb 18, 2024 at 10:34 AM Yu Kuai <yukuai1@huaweicloud.com> wrote: >>>>>> >>>>>> Hi, >>>>>> >>>>>> 在 2024/02/18 10:27, Xiao Ni 写道: >>>>>>> On Sun, Feb 18, 2024 at 9:46 AM Yu Kuai <yukuai1@huaweicloud.com> 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. > > Because this patch set is used to fix dm raid deadlocks. But this > patch changes logic, it looks like more a feature - "we can start/stop > sync thread when array is suspended". Because this patch is added many > years ago and dm raid works well. If we change this, there is > possibilities to introduce new problems. Now we should try to walk > slowly. This patch itself really is quite simple, it fixes problems for md/raid, and can be triggered by dm-raid as well. This patch will be needed regardless of dm-raid, and it's absolutely not a feature. For dm-raid, there is no doubt that sync_thread should be stopped before suspend, and keep frozen until resume, and this behaviour is not changed at all and will never change. Other patches actually tries to gurantee this. If you think this patch can introduce new problems for dm-raid, please be more specific. The problem in dm-raid is that it relies on __md_stop_writes() to stop and frozen sync_thread, while it also relies that MD_RECOVERY_FROZEN is not set, and this is abuse of MD_RECOVERY_FROZEN. And if you still think there are problems with considering of the entire patchset, feel free to discuss. :) Thanks, Kuai
On Sun, Feb 18, 2024 at 4:48 PM Yu Kuai <yukuai1@huaweicloud.com> wrote: > > Hi, > > 在 2024/02/18 16:07, Xiao Ni 写道: > > On Sun, Feb 18, 2024 at 2:22 PM Yu Kuai <yukuai1@huaweicloud.com> wrote: > >> > >> Hi, > >> > >> 在 2024/02/18 13:07, Xiao Ni 写道: > >>> On Sun, Feb 18, 2024 at 11:24 AM Yu Kuai <yukuai1@huaweicloudcom> wrote: > >>>> > >>>> Hi, > >>>> > >>>> 在 2024/02/18 11:15, Xiao Ni 写道: > >>>>> On Sun, Feb 18, 2024 at 10:34 AM Yu Kuai <yukuai1@huaweicloud.com> wrote: > >>>>>> > >>>>>> Hi, > >>>>>> > >>>>>> 在 2024/02/18 10:27, Xiao Ni 写道: > >>>>>>> On Sun, Feb 18, 2024 at 9:46 AM Yu Kuai <yukuai1@huaweicloud.com> 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. > > > > Because this patch set is used to fix dm raid deadlocks. But this > > patch changes logic, it looks like more a feature - "we can start/stop > > sync thread when array is suspended". Because this patch is added many > > years ago and dm raid works well. If we change this, there is > > possibilities to introduce new problems. Now we should try to walk > > slowly. > > This patch itself really is quite simple, it fixes problems for md/raid, > and can be triggered by dm-raid as well. This patch will be needed > regardless of dm-raid, and it's absolutely not a feature. Hi Kuai Yes, this patch is simple. But it changes the original logic. Do we really need to do this? And as the title of the patch set, it's used to fix regression problems. We need to avoid much changes, find out the root cause and fix them. It's better to use another patch set to do more jobs. For example, allow sync request when array is suspended (But I don't want to do this change). > > For dm-raid, there is no doubt that sync_thread should be stopped before > suspend, and keep frozen until resume, and this behaviour is not changed Agree with this > at all and will never change. Other patches actually tries to gurantee In fact, we only need to use one line code to do this. We don't need so many patches. It only needs to set MD_RECOVERY_FROZEN before stop sync thread. set_bit(MD_RECOVERY_FROZEN, &mddev->recovery); __md_stop_writes(mddev); > this. If you think this patch can introduce new problems for dm-raid, > please be more specific. > > The problem in dm-raid is that it relies on __md_stop_writes() to stop > and frozen sync_thread, while it also relies that MD_RECOVERY_FROZEN is > not set, and this is abuse of MD_RECOVERY_FROZEN. And if you still think > there are problems with considering of the entire patchset, feel free to > discuss. :) In fact, dmraid sets MD_RECOVERY_FROZEN before f52f5c71f3d4 (md: fix stopping sync thread). It calls __md_stop_writes and this function sets MD_RECOVERY_FROZEN. Thanks for your patience :) Regards Xiao > > Thanks, > Kuai >
Hi, 在 2024/02/19 15:10, Xiao Ni 写道: > On Sun, Feb 18, 2024 at 4:48 PM Yu Kuai <yukuai1@huaweicloud.com> wrote: >> >> Hi, >> >> 在 2024/02/18 16:07, Xiao Ni 写道: >>> On Sun, Feb 18, 2024 at 2:22 PM Yu Kuai <yukuai1@huaweicloud.com> wrote: >>>> >>>> Hi, >>>> >>>> 在 2024/02/18 13:07, Xiao Ni 写道: >>>>> On Sun, Feb 18, 2024 at 11:24 AM Yu Kuai <yukuai1@huaweicloud.com> wrote: >>>>>> >>>>>> Hi, >>>>>> >>>>>> 在 2024/02/18 11:15, Xiao Ni 写道: >>>>>>> On Sun, Feb 18, 2024 at 10:34 AM Yu Kuai <yukuai1@huaweicloud.com> wrote: >>>>>>>> >>>>>>>> Hi, >>>>>>>> >>>>>>>> 在 2024/02/18 10:27, Xiao Ni 写道: >>>>>>>>> On Sun, Feb 18, 2024 at 9:46 AM Yu Kuai <yukuai1@huaweicloud.com> 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. >>> >>> Because this patch set is used to fix dm raid deadlocks. But this >>> patch changes logic, it looks like more a feature - "we can start/stop >>> sync thread when array is suspended". Because this patch is added many >>> years ago and dm raid works well. If we change this, there is >>> possibilities to introduce new problems. Now we should try to walk >>> slowly. >> >> This patch itself really is quite simple, it fixes problems for md/raid, >> and can be triggered by dm-raid as well. This patch will be needed >> regardless of dm-raid, and it's absolutely not a feature. > > Hi Kuai > > Yes, this patch is simple. But it changes the original logic. Do we > really need to do this? And as the title of the patch set, it's used Nothing is changed, this patch itself fix a long term regression. And I already change the title to fix dm-raid and md/raid regressions. > to fix regression problems. We need to avoid much changes, find out > the root cause and fix them. It's better to use another patch set to > do more jobs. For example, allow sync request when array is suspended > (But I don't want to do this change). Following behaviour is not changed with this patchset: 1. dm-raid should stop and frozen sync_thread during suspend; 2. sync_thread can still runing while md/raid is suspended; And my point is that if you want to forbit new sync_thread, use MD_REOCVERY_FROZEN instead of suspended; >> >> For dm-raid, there is no doubt that sync_thread should be stopped before >> suspend, and keep frozen until resume, and this behaviour is not changed > > Agree with this >> at all and will never change. Other patches actually tries to gurantee > > In fact, we only need to use one line code to do this. We don't need > so many patches. It only needs to set MD_RECOVERY_FROZEN before stop > sync thread. > > set_bit(MD_RECOVERY_FROZEN, &mddev->recovery); I agree this make sense, but as I said in the other thread, this is not enough. > __md_stop_writes(mddev); > >> this. If you think this patch can introduce new problems for dm-raid, >> please be more specific. >> >> The problem in dm-raid is that it relies on __md_stop_writes() to stop >> and frozen sync_thread, while it also relies that MD_RECOVERY_FROZEN is >> not set, and this is abuse of MD_RECOVERY_FROZEN. And if you still think >> there are problems with considering of the entire patchset, feel free to >> discuss. :) > > In fact, dmraid sets MD_RECOVERY_FROZEN before f52f5c71f3d4 (md: fix > stopping sync thread). It calls __md_stop_writes and this function > sets MD_RECOVERY_FROZEN. Thanks for your patience :) I know that, and f52f5c71f3d4 really should set MD_RECOVERY_FROZEN. But looks like you want to keep the way it used to be, and you don't want to fix problems that exist in dm-raid for a long term. If you send your patches before this, I'll be happy to accept them. However, I know this patchest might be complicated, but I already did the hard work, and I think this patchset fix the regressions in a better way, and I'm trying to let dm-raid and md/raid to manage sync_thread the same safer way. So far, I think all problems that you concerned are all fixed with this patchset, and as I said, I'll be happy to dissuss if you think there are other problems with this patchset. Thanks, Kuai > > Regards > Xiao >> >> Thanks, >> Kuai >> > > . >
diff --git a/drivers/md/md.c b/drivers/md/md.c index 2266358d8074..07b80278eaa5 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -9469,9 +9469,6 @@ static void md_start_sync(struct work_struct *ws) */ void md_check_recovery(struct mddev *mddev) { - if (READ_ONCE(mddev->suspended)) - return; - if (mddev->bitmap) md_bitmap_daemon_work(mddev);