Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp558545rdb; Sun, 18 Feb 2024 00:48:19 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUeNVS/Ztacj7RN8C/P/xf91QaE91/l0ByqNbnm9gsHcKRoKxmLV0Aaa22MoyD85vMQA6nANMTqffISdUvY5z2PNU0pCmmTXAq/fMXaPQ== X-Google-Smtp-Source: AGHT+IEWww4nGafX7JsaiBw93nTMlhuCuAjtb+CHLl0GcZnWGrG0c8wEZCQmDjZBJBw7gDgv2IyZ X-Received: by 2002:a05:6402:14d0:b0:564:66c1:d527 with SMTP id f16-20020a05640214d000b0056466c1d527mr319579edx.36.1708246098920; Sun, 18 Feb 2024 00:48:18 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708246098; cv=pass; d=google.com; s=arc-20160816; b=XJMh2ysbNU29XW3cnNfz8ZXcbVF1UWrjcbxIi/LFryxi+RsQWQjI/grvO6POwmmzPx elju7UpG+ZLXmaCO06VLs5GQ+hLmFxfUQYN35TbuLBp84oUPmg0gMsE1ILWg0FrOHAnY 0oc/swEJWByyzawZe330Nqqq7KJwdGsWa1LhbXSdPE8pJHTBcMHCVN8WK12RXgkCEdpP JwXUnLIoimuav23mpd3QGkC0tUEZkOEH5lxLxAYOXC1e3aLkdNesWx4/03NjYy0wFFm0 XFDLV3XJ0m1KbEtYSLSPVfoOtac5nH0Hcje4RLucxrj9Nlq8eh822bL/3j6if8aPElR7 rmlA== 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=7bHY/Ter6zcnNlyvXNbCkSA9zc6c3YaaEtvc/P/BZ44=; fh=CjkgtI4dY3CXxTj6EL3+z307nLpXmmgCNibn/JKWqxI=; b=CTb4LOMN/NhDhRyAIHv//SWNCvDdv+ADHQyrpyo7cOG+0KPdAmOiv0A4LrFETaUlIN WMJ4Kn27kO1nEBxUCsRwNBk2c8SJ1+R8IVB3cY7PC2oq7ftLzL/Ur3/STYKHG+QqvPj/ JMCJDDQ0BqFP27plvMDofPas2bXtNAqG5YJtK/uh0siYfu+XwoDcm2TxTeXkYCb4vGme MMbpNc9cXXoCMz87KWIkb2dJkHWpWJZWbI5IsvKdHVw6Pu22sXRrqvKDRUa4sJMtHGLp zIlquYb3DtCiXIPHHDXySgDZtXiTvef/+jj0hLr8RHX2lNyt3PkzcYvNEHHQYc3epd4p sQFg==; 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-70301-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70301-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id r7-20020a056402234700b00563d1136229si1573852eda.436.2024.02.18.00.48.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Feb 2024 00:48:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-70301-linux.lists.archive=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-70301-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70301-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 85AF41F21719 for ; Sun, 18 Feb 2024 08:48:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 083A6171D5; Sun, 18 Feb 2024 08:47:58 +0000 (UTC) Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [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 1B57114281; Sun, 18 Feb 2024 08:47:54 +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=1708246077; cv=none; b=ftWL/vr/SLdRB5MWUfUBOAkyNNkriV0rXSeumO3doSDuNTlbY15G1bcyshZVAGXXC4B/QhMw1LhNHzfeqsrB6JNQGrHREIwil48YFvsK+T/xbc4gcAhxKNql9kGun1MOKlldr5sYGtkmejmQfSvlC/GUtZOSMUZ10XRXVkvims4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708246077; c=relaxed/simple; bh=hTNi/orprw9Qjmvh/s2Omv4QpAAV9grYwXTtiGH83o0=; h=Subject:To:Cc:References:From:Message-ID:Date:MIME-Version: In-Reply-To:Content-Type; b=Qy7GztT1pSSXm4qbt9mNM5wMSnunyVXVQzy1dFCpYn4A9GJqtDr3aNJ4kq4t0UfPW3Fb/VCmp8FpgGMIiQ0wfwjCDP5TBFSoqdcGOdQwlueXOuIngGBQlQsqFaKkK5TIl2+IbIHlT2dzciit3UUYIHz0iEJgiR8hIhtEMSXdZ1s= 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 4Tcznw5mfbz4f3kJs; Sun, 18 Feb 2024 16:47:48 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id DC3FC1A0C84; Sun, 18 Feb 2024 16:47:51 +0800 (CST) Received: from [10.174.176.73] (unknown [10.174.176.73]) by APP1 (Coremail) with SMTP id cCh0CgBHZQ41xNFl6KqFEQ--.10218S3; Sun, 18 Feb 2024 16:47:51 +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, 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, Jonathan Brassow , "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> <5480b350-efe3-2be7-cf3b-3a62bb0e012b@huaweicloud.com> From: Yu Kuai Message-ID: Date: Sun, 18 Feb 2024 16:47:49 +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:cCh0CgBHZQ41xNFl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U0xZFpf9x0JU6c_fUUUUU= X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ Hi, 在 2024/02/18 16:07, Xiao Ni 写道: > On Sun, Feb 18, 2024 at 2:22 PM Yu Kuai wrote: >> >> Hi, >> >> 在 2024/02/18 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. > > 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