Received: by 2002:a05:7208:13ce:b0:7f:395a:35b6 with SMTP id r14csp210147rbe; Wed, 28 Feb 2024 18:14:32 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU1DqS6mhnFvsWvWvP1FJDTlFVjvsZ2i7WXxHAr0Gqx29Q9QIcqYiHS5rVKsf/qiDk8OTWYYkPzg33U6l/pTvFPjWZUZ5DEHTgOAv0eHw== X-Google-Smtp-Source: AGHT+IHhC0j5gEyLXa6yGkTk0pHqIedTPU0KegkDLTK+J1Q7n3iuiUPYfN5/mxnx3AU7HtGfPVnG X-Received: by 2002:a17:906:e20b:b0:a43:8c43:b702 with SMTP id gf11-20020a170906e20b00b00a438c43b702mr414182ejb.8.1709172871868; Wed, 28 Feb 2024 18:14:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709172871; cv=pass; d=google.com; s=arc-20160816; b=VLTys7HB8c7q59qyU5yf0OozENnOCXeBJDRmB7ETXhgjy8UTwRPPvpp3VdqpR8vRdO m5MR8uvR4qiBApe7NbZCjO78MLvFwkWYBV3wgWFWkCRGTFDqkhGUQxCK1uoB29ewlZMA VWJAGzBvHwH08lgIEDhB5YYQ1ASj928C1aciKzEcoRViPDZP4NmMCgBQRQPO+caYE5B9 WXZ6qVPEV3RcD8XcDSR6vZ4COywnZBBmBt6gddlXwcLRPKGz/rXmJwRLebdvaFS91MIH 9k58X6z7boNubthlD/dJImvd/Z2Cylx+ThwoGh7nLYELr5WxIZCEisLdtmvCFX+d2LrB E2HA== 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=1AKwzCVmTF1HULWdxGWcEttI2szOpbVfTO0Dt77cvPk=; fh=AOmE2KdTIIwe9s1ksCT9ksIMpvbiMan4vqnbKsg0xD0=; b=VqD4U84VFI/Rhbk+RVpYaNXQtW3vl11K4GgO1xpKZOnMiCGMOZu8DygG2+3Aq9+m+F PHd0zF2X9fIdETC+/S0Ee6+jmxHdi7YKwoRayiLncXg+WbX7Bgw3whj9tPKnSOlhzXQ2 vyHtpumWOzRwvxDrqaxjI8IYDf+i3pZDFEBoUhhZbnUVQJYgqhSOElr7FrgdZMyYBlR7 fuqrJL0feFxH2hgoWEZDQaHx/ptldrXcfv2bVq8rhFgzFaFsnqRCtk01vVJ3TILDhIh2 +5bAHTYxoC3qdf4Unbw1K/2aDcJxmNFs1IQcsSrB7xMFf93DXPEqPdQ1lEXvgYikCMEj c2KA==; 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-86034-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86034-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 r18-20020a170906351200b00a441103b899si130903eja.347.2024.02.28.18.14.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 18:14:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-86034-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-86034-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86034-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 9D94D1F261A9 for ; Thu, 29 Feb 2024 02:14:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0E9EB36B0D; Thu, 29 Feb 2024 02:14:22 +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 A60E622612; Thu, 29 Feb 2024 02:14:19 +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=1709172861; cv=none; b=qR5/ku/YQe+2f/jScHmTE0rF6IjeT/NabzkhaDZ8DuCRDRkbSQYFGu9q8CHQOl64L4xVPenCgFPJL4VSy3fOzvBd3RjU4TQrRB5dtirjR6YXoDCImdtfikyckuCuS18nNiTXMXGnBIxpbQ7vhkznf+z/+YIBvWAHONGD79mthYU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709172861; c=relaxed/simple; bh=YTYbyy3+UTYewtVzLjaJat1vjlG10V1fAJH99Lsa9Pk=; h=Subject:To:Cc:References:From:Message-ID:Date:MIME-Version: In-Reply-To:Content-Type; b=VKMruX7/l8FwwhU6zB5V8+djss6NndPgK0nBPrxPJq3c5qRKtAW8wX1spE7IEBUYa6zNmdLyDFlc5gmBqIXh1g4f+9C0YE0kbmlMGqkDhBoCccVuEA5aFL1DJRht10mTL4yL6ZrP35qHwiylLRgDzY3qLCrxPd8UcR83xu1BYcY= 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 4TlZXc4X4Fz4f3mJM; Thu, 29 Feb 2024 10:14:08 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id F317D1A0B5D; Thu, 29 Feb 2024 10:14:15 +0800 (CST) Received: from [10.174.176.73] (unknown [10.174.176.73]) by APP1 (Coremail) with SMTP id cCh0CgAn9g526N9ld_rlFQ--.55635S3; Thu, 29 Feb 2024 10:14:15 +0800 (CST) Subject: Re: [PATCH v5 05/14] md: don't suspend the array for interrupted reshape To: Xiao Ni , Yu Kuai , 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 Cc: 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-6-yukuai1@huaweicloud.com> <60d75867-8fb7-4c67-96f7-3e5ba65bdbd9@redhat.com> From: Yu Kuai Message-ID: <0f768b3d-d0a2-92ff-e854-74acc9d0ad7a@huaweicloud.com> Date: Thu, 29 Feb 2024 10:14:14 +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: <60d75867-8fb7-4c67-96f7-3e5ba65bdbd9@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-CM-TRANSID:cCh0CgAn9g526N9ld_rlFQ--.55635S3 X-Coremail-Ant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n3trlr6x35dzhxuhorxvhhfrp/ Hi, 在 2024/02/29 10:10, Xiao Ni 写道: > > 在 2024/2/1 下午5:25, Yu Kuai 写道: >> From: Yu Kuai >> >> md_start_sync() will suspend the array if there are spares that can be >> added or removed from conf, however, if reshape is still in progress, > > > Hi Kuai > > Why md_start_sync can run when reshape is still in progress? > md_check_recovery should return without queue sync_work, right? > >> this won't happen at all or data will be corrupted(remove_and_add_spares >> won't be called from md_choose_sync_action for reshape), hence there is >> no need to suspend the array if reshape is not done yet. >> >> Meanwhile, there is a potential deadlock for raid456: >> >> 1) reshape is interrupted; >> >> 2) set one of the disk WantReplacement, and add a new disk to the array, >>     however, recovery won't start until the reshape is finished; >> >> 3) then issue an IO across reshpae position, this IO will wait for >>     reshape to make progress; >> >> 4) continue to reshape, then md_start_sync() found there is a spare disk >>     that can be added to conf, mddev_suspend() is called; > > > I c. The answer for my above question is reshape is interrupted and then > it continues the reshape, right? > Yes, reshape is interrupted and sync_thread is unregister, then sync_thread can be registered again to continue reshape. Thanks, Kuai > > Best Regards > > Xiao > >> >> Step 4 and step 3 is waiting for each other, deadlock triggered. Noted >> this problem is found by code review, and it's not reporduced yet. >> >> Fix this porblem by don't suspend the array for interrupted reshape, >> this is safe because conf won't be changed until reshape is done. >> >> Fixes: bc08041b32ab ("md: suspend array in md_start_sync() if array >> need reconfiguration") >> Signed-off-by: Yu Kuai >> --- >>   drivers/md/md.c | 13 +++++++++---- >>   1 file changed, 9 insertions(+), 4 deletions(-) >> >> diff --git a/drivers/md/md.c b/drivers/md/md.c >> index 6c5d0a372927..85fde05c37dd 100644 >> --- a/drivers/md/md.c >> +++ b/drivers/md/md.c >> @@ -9374,12 +9374,17 @@ static void md_start_sync(struct work_struct *ws) >>       bool suspend = false; >>       char *name; >> -    if (md_spares_need_change(mddev)) >> +    /* >> +     * If reshape is still in progress, spares won't be added or removed >> +     * from conf until reshape is done. >> +     */ >> +    if (mddev->reshape_position == MaxSector && >> +        md_spares_need_change(mddev)) { >>           suspend = true; >> +        mddev_suspend(mddev, false); >> +    } >> -    suspend ? mddev_suspend_and_lock_nointr(mddev) : >> -          mddev_lock_nointr(mddev); >> - >> +    mddev_lock_nointr(mddev); >>       if (!md_is_rdwr(mddev)) { >>           /* >>            * On a read-only array we can: > > . >