Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp880005rdb; Tue, 23 Jan 2024 19:34:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IG1DcYlHfzMfBSj8yDzW6UA4B3CJVzpM/rvnUxqShy5rUmr3ePJ4mTJy3tpkHXa7uis8zmY X-Received: by 2002:a05:6a20:65a4:b0:19a:dad9:1dd5 with SMTP id p36-20020a056a2065a400b0019adad91dd5mr155289pzh.120.1706067294085; Tue, 23 Jan 2024 19:34:54 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706067294; cv=pass; d=google.com; s=arc-20160816; b=IG91fF0LapoiKMg9LouB3GAcRoxRyvge246xCPeRt7dGO3eLQLsW4kvLi0NqFQ8ses TAuYImNOCps31dkkfFA5G6VUim2/0u+P9XA2sZa3Nrqy2/bS4QBkl1QLdAnQ9CHuuO0C mozP0Ni6ykquNhoXp3hY3Vy2NY1QeuUeYRz2a/93w8u09sgoXaU4tUhmmvtQf2sCcr89 mp1KejoGAsMdWCcY699ocEwUv9HgtgH0ECJxy9omX8dj+E7rCUxet34Ate2Z7/FcxOXu 3zRbfDVzAp5/JnQ4r8Iu5F0p0P2PQrech+48r7DaUarYz0nAABTGCHGJupREkLBRfDu6 Aybw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:date:message-id; bh=BbqyxICIKNGEhONR6Oo8eeofUXeKQcvgqlZOrBivWvw=; fh=EUn8TtNtPzRWjV0f69Sf1tYv/M2g1IMYkKIzl4FJRuo=; b=bCfUTBalUFD1Sa/b0i0kTMFjRdXO43eapH7f0fSIcVU7yb7H5X+M0zDAIdpabyaSIt fSua5BFMksAcvo5z0hoUJcyRSEs8MIlJ0vf/RSj/4Vpk2p2VHqp4atZLZ33OFLWJdEHK JGU100Ga20W963xz285yOpYks+v1frGTpvyiSdVCeYgQjvWFzYsqwcGDBsXG068kcBzZ /CBxrKbxnIua0TkYqum4fG1jVwYz4LbYPSJg02wr9+bkfWDnbnsTfEcRC8O9XGltNAo+ pRoX8vhcazUkkPMLn7mOQKM2f8kHj2zLT56dBapqm4Zku8eku4dsIAYGnrN4xmJ/V32J x6+w== 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-36394-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-36394-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id i13-20020a170902eb4d00b001d752bafbf5si4558343pli.254.2024.01.23.19.34.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 19:34:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-36394-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-36394-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-36394-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 0EED8B28860 for ; Wed, 24 Jan 2024 03:17:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2DCD26105; Wed, 24 Jan 2024 03:16:56 +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 05BC4524C; Wed, 24 Jan 2024 03:16: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=1706066215; cv=none; b=Tgx1HNhrTJ1nn3lhZP/9snjmDdzYd58CP8V0o9QnzHsJMOVkBpBfWNNCEQGOb42rJEy3GcxisBj6cZd7k/ElBb/48uvZg6UVBS+wnaNUNqf1Ydujg58RoSplud5jg1tj6brYlCJH8tYwRmgy9n7uVvJ1JLLVceMILIIWTn9Pxi4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706066215; c=relaxed/simple; bh=KoKJOAfFqJj/64JXWg/TEVuQifWy5nCHkEHI2/1w9NQ=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=mrBODRH5ss0nOjYj7OEMRgxtOpEmndiEKc5ymR9Rh3cByArfm++F+iQbXXWpzjswiVLnIr87nBBUY1nvZwXO3+kJ8CfoN/FNcpW5o03LidYtBuNA3UoX9KE0Xhb3SJ18FhzPseAItdBw3tUUdf3YJ2yQy6hgIDsYPJ3tDRoQaOw= 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.235]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4TKTdX4GCyz4f3k6W; Wed, 24 Jan 2024 11:16:48 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.75]) by mail.maildlp.com (Postfix) with ESMTP id E7D151A0272; Wed, 24 Jan 2024 11:16:50 +0800 (CST) Received: from [10.174.179.247] (unknown [10.174.179.247]) by APP2 (Coremail) with SMTP id Syh0CgBXfA8ggbBlYOZHBw--.11031S3; Wed, 24 Jan 2024 11:16:50 +0800 (CST) Message-ID: <425044a0-95ce-b2a3-e98d-527c31f0313a@huaweicloud.com> Date: Wed, 24 Jan 2024 11:16:48 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Subject: Re: [PATCH v2 3/3] md: sync blockdev before stopping raid or setting readonly To: Mariusz Tkaczyk , linan666@huaweicloud.com Cc: song@kernel.org, shli@fb.com, neilb@suse.com, zlliu@suse.com, linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org, yukuai3@huawei.com, yi.zhang@huawei.com, houtao1@huawei.com, yangerkun@huawei.com References: <20240117093707.2767209-1-linan666@huaweicloud.com> <20240117093707.2767209-4-linan666@huaweicloud.com> <20240118090205.00000212@linux.intel.com> From: Li Nan In-Reply-To: <20240118090205.00000212@linux.intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-CM-TRANSID:Syh0CgBXfA8ggbBlYOZHBw--.11031S3 X-Coremail-Antispam: 1UD129KBjvJXoW7uFyDCF4kAryDCrW7JFy5Jwb_yoW8AF45p3 y0yFs0gr1UJry3A3ZrW3W8Wa4rKF92yFZxKr13A3WUZryDCrnxXr9agw4YvFykK3sayw40 vw4UXa93Ga42ga7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUBI14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26F1j6w1UM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4U JVWxJr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Gc CE3s1lnxkEFVAIw20F6cxK64vIFxWle2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xv F2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r1j6r 4UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvEwIxGrwACjI8F5VA0II8E6IAqYI8I648v 4I1lFIxGxcIEc7CjxVA2Y2ka0xkIwI1lc7I2V7IY0VAS07AlzVAYIcxG8wCF04k20xvY0x 0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E 7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_GFylIxkGc2Ij64vIr41lIxAIcV C0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF 04k26cxKx2IYs7xG6rW3Jr0E3s1lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aV CY1x0267AKxVW8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7VUbHa0DUUUUU== X-CM-SenderInfo: polqt0awwwqx5xdzvxpfor3voofrz/ 在 2024/1/18 16:02, Mariusz Tkaczyk 写道: > On Wed, 17 Jan 2024 17:37:07 +0800 > linan666@huaweicloud.com wrote: > >> From: Li Nan >> >> Commit a05b7ea03d72 ("md: avoid crash when stopping md array races >> with closing other open fds.") added sync_block before stopping raid and >> setting readonly. Later in commit 260fa034ef7a ("md: avoid deadlock when >> dirty buffers during md_stop.") it is moved to ioctl. array_state_store() >> was ignored. Add sync blockdev to array_state_store() now. >> >> Signed-off-by: Li Nan [...] >> + >> + /* we will call set readonly or stop raid, sync blockdev */ >> + if (st == clear || (mddev->pers && (st == readonly || >> + st == inactive || (st == read_auto && md_is_rdwr(mddev))))) { >> + err = mddev_sync_blockdev(mddev); >> + if (err) >> + return err; >> + clear_md_closing = true; >> + } >> + > > Please reorganize it a little for readability: > I think if no mddev->pers we don't need to consider sync_blockdev at all. If > personality is there we can probably check for read-write. If it is not > read-write then nothing to sync. What about that: > > if (mddev->pers && md_is_rdwr(mddev) && > (st == clear || st == readonly || st == inactive || st == read_auto)) > > Please note that I didn't test it so please let me know if you see issue in > proposed logic. > I think that we may be able to include it in "/* No lock dependent actions */" > switch. Please consider it too: > Thanks for your review. It is a really good idea. I will test and improve it. > case clear: > case readonly: > case inactive: > case read_auto: > if(!mddev->pers || !md_is_rdwr(mddev)) > break; > err = mddev_sync_blockdev(mddev); > if (err) > return err; > clear_md_closing = true; > -- Thanks, Nan