Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp2099567rdb; Sun, 24 Dec 2023 17:35:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IEJwiT3eLYJzeLGlWtlrirgTnka4NQsIooUT3ZmX0Fln76/EEsj/5rR4PS120FIRVE1/64M X-Received: by 2002:a05:6870:ac28:b0:203:e684:3a2a with SMTP id kw40-20020a056870ac2800b00203e6843a2amr6163652oab.64.1703468149776; Sun, 24 Dec 2023 17:35:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703468149; cv=none; d=google.com; s=arc-20160816; b=IW+0bwjBcRHTo2WXwN1q/YdX6YM80r2bW8y+GZNuFI54J1Dlx3dvCxlD7++27al22I rB8Bo+X+fec55FuKKYeUG2KL5ylLqbCvHgNIjqcHgmIPP1bDn3zk5cbE9CV7QENEMx09 NrmlnD9UV44fIMs/WMZgaP92dBi3AWefAjlu0o//2UC+A97Mpk+fMx023RkIJB3KiJdL cNt26rbw+ningWbb66LcDcPWmyjncYYWsrinzzsoXG3GjX2IS5ixqKcyC3yOUCwbVni3 DRO8J1gQWJWmC5jzItYBW3CG5JCCEM329ouZijUTiCDh2EZ1Bht3dNfdb/DoIrCNKPFg C/Kg== ARC-Message-Signature: i=1; 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=Wo+jQpv7MeeFSbZ9hI41DK3BTR2BL2i4eKRMRzHcSbM=; fh=d25tYeHY1/9fxkNusM4woAGx0ntM6RuR6oX1iErajkc=; b=A1eq6TwmxCgvtEBZ3aa2DXghvjB1KRclsOaOS/D7ApkSbHiaeoT72dg91Xf+KYlKn+ pYYzNBq2wICJSDiYwnXlfvqn+xOJ2S1AVYxTjPCcRYc65k7+j1PaBaAZujn8WcAFc1iN 3FpfxPNVTdU5X/49ZUyH4poKljV0beBVybloHiH2jB4o1fUsaSHU0VjBkeAZwIl4o1rC RtVTaQj2wyVPS0xK8fGajFnrzuERsEd4758RBKmf78MNEC7gLTViduHK2HT/PSUV7U/p ZnsIKAl4OGpfdYlhQb0E+dxUozvS/9snK/WWgCCaA8WW7Vve3LxaZ+ORgcaklwbppjqR 265g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-10856-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10856-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 bx19-20020a056a02051300b005bd039e5a04si7385349pgb.622.2023.12.24.17.35.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Dec 2023 17:35:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-10856-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; spf=pass (google.com: domain of linux-kernel+bounces-10856-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10856-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 64F0C281B19 for ; Mon, 25 Dec 2023 01:35:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 128D4805; Mon, 25 Dec 2023 01:35:40 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org 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 1B2B663C; Mon, 25 Dec 2023 01:35:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.93.142]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4Sz0pK2S81z4f3lCx; Mon, 25 Dec 2023 09:35:21 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id AB9081A0198; Mon, 25 Dec 2023 09:35:26 +0800 (CST) Received: from [10.174.176.73] (unknown [10.174.176.73]) by APP1 (Coremail) with SMTP id cCh0CgC3uA5c3Ihl8Ss5Eg--.37786S3; Mon, 25 Dec 2023 09:35:26 +0800 (CST) Subject: Re: [PATCH 1/2] md: fix WARN_ON if create symlink fail in bind_rdev_to_array() To: Song Liu , Li Nan Cc: linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org, yi.zhang@huawei.com, houtao1@huawei.com, yangerkun@huawei.com, "yukuai (C)" References: <20231221071109.1562530-1-linan666@huaweicloud.com> <20231221071109.1562530-2-linan666@huaweicloud.com> From: Yu Kuai Message-ID: <3cf95141-0cdb-9e67-16a9-4c64b3251885@huaweicloud.com> Date: Mon, 25 Dec 2023 09:35:24 +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:cCh0CgC3uA5c3Ihl8Ss5Eg--.37786S3 X-Coremail-Antispam: 1UD129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 2023/12/25 9:11, Song Liu 写道: > On Thu, Dec 21, 2023 at 5:17 PM Li Nan wrote: >> >> >> >> 在 2023/12/22 2:58, Song Liu 写道: > [...] >>> In general, I would like to avoid adding flags if possible. >>> >> >> This flag is mainly used to fix deadlock in next patch. Or should we >> export bd_find_holder_disk()? Link hodler if it return NULL. >> just like: >> >> rdev_for_each_rcu >> if (!bd_find_holder_disk) >> bd_link_disk_holder > > I was thinking we will not need the flag if we fail bind_rdev_to_array() > on error (below). > >> >> >>>> }; >>>> >>>> static inline int is_badblock(struct md_rdev *rdev, sector_t s, int sectors, >>>> diff --git a/drivers/md/md.c b/drivers/md/md.c >>>> index e05858653a41..d6612b922c76 100644 >>>> --- a/drivers/md/md.c >>>> +++ b/drivers/md/md.c >>>> @@ -2526,7 +2526,8 @@ static int bind_rdev_to_array(struct md_rdev *rdev, struct mddev *mddev) >>>> sysfs_get_dirent_safe(rdev->kobj.sd, "bad_blocks"); >>>> >>>> list_add_rcu(&rdev->same_set, &mddev->disks); >>>> - bd_link_disk_holder(rdev->bdev, mddev->gendisk); >>>> + if (!bd_link_disk_holder(rdev->bdev, mddev->gendisk)) >>>> + set_bit(SymlinkCreated, &rdev->flags); >>> >>> Shall we just fail bind_rdev_to_array() if bd_link_disk_holder() >>> returns non-zero? >>> >> >> I keep this action because of commit 00bcb4ac7ee7 ("md: reduce >> dependence on sysfs."). Fail bind_rdev_to_array is good to me. > > I wonder whether the assumption in 00bcb4ac7ee7 is still true. If > bd_link_disk_holder() fails for valid reasons, we need to handle it > properly (set a flag, check the flag on unlink, etc.). If we only fail > bd_link_disk_holder() on extreme cases (ENOMEM, etc.), we can > just fail bind_rdev_to_array(). I totally agree! Currently, bd_link_disk_holder() from md won't return -EINVAL, it will return -ENOMEM or -ENODEV if underlying disk is deleted, which means bind_rdev_to_array() should fail as well. The only problem is that this will make next patch more complicated, but I think this can be solved. Thanks, Kuai > > Thanks, > Song > . >