Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp2093087rdb; Sun, 24 Dec 2023 17:11:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IESavB/dfIRkpk/J29exWem5NvST0yIOlZ5Tldblbdtamc06j8fZufQA/6wGytcQysgXtQ7 X-Received: by 2002:a17:903:454:b0:1d3:47ba:ba45 with SMTP id iw20-20020a170903045400b001d347baba45mr4945427plb.136.1703466690974; Sun, 24 Dec 2023 17:11:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703466690; cv=none; d=google.com; s=arc-20160816; b=CO1vZXzGCdYIUC5EUhvP+XEaM+gUfMwmkUCw7sN5E0ya9c6X6rrwHCEwRv2fuPn9W+ p8sIzfZxKgvvSzWkI82f67+CLhDMRM8X1/SaSzbvhc3rm5ZjaD4a2W1DPYys2q/0fclG iW/a1/vslZsuCOTX+BTTcDRi90xgz8w7+62ME8qfDnizjIp3Az3apOmdtjbRFgDVdzIn eIxC6PXBFoS0dVkAGrT8XGmqtUYy0s5TWXBafxPsqS4Z69p4ZHtJfXmVR8D89eWp72fL uSXP3Gm7BkNHNAle2tcluqHUi49vUZaemkqpxHu07OQX3daqt5KL45Zk1x3QSMxVch/W jzpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=1C8DPllF3NR4OY5tLAQQnlVh8qhCKyM6n+Ff9tQsfBI=; fh=y+JSO8F914xen1WB4zNbwLKOmQnNCXAn/YYa+1Bm0y4=; b=ya2IfSFzkXrI5QXtgzfKZmMBJrxmjBcaEysJ/E5HcvtjQsBaMAC00lJkSOsiC+0Wjp e2k9ePwk1/+DXsfCMrWpHwM/L3GLvr05PDK0VEApsn6wN3Z6aeRYCxXs81TTJTgrX8Iu 8Hftqa9FLd3iNeXpqqTlyu+FCeO0iYG9wefwyNhcD9zqtefQo3T3NcJdURJwpZVl54qF yEAGgUoB6L7UvXNl7N2eDEZUgu4m7JAfkEEcIjsfEywU0Xt+xASHvOow1+isFeRYV0dA rL5V+r7wb/d29rb8rvy79VUmviO7K+d8B+qtmD5BqBVNRQjF1OUtKqA4WNGDoFv1HdEw kPew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qdlZYrpW; spf=pass (google.com: domain of linux-kernel+bounces-10853-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10853-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 a8-20020a170902b58800b001d3df52d28bsi2801080pls.583.2023.12.24.17.11.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Dec 2023 17:11:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-10853-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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qdlZYrpW; spf=pass (google.com: domain of linux-kernel+bounces-10853-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10853-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 743A6B21101 for ; Mon, 25 Dec 2023 01:11:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 93941804; Mon, 25 Dec 2023 01:11:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="qdlZYrpW" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 C2F16632; Mon, 25 Dec 2023 01:11:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2EB15C433C7; Mon, 25 Dec 2023 01:11:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1703466675; bh=d4mJqlfdedbmYfVGJKIxN2wD9IVAoX/SkySuUqr/AJs=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=qdlZYrpWaTELwpw49MScHs/wIDJXiu9ZF62GIymKoFFW5sszsUGthLBYO6NL7BoiR VpgSjuAZYa51Y0EPsvnUl6pIU0Y8Qx6SpKZpZUrIzlnwY7OdcFuWEnzr3YEqyu+MJL D2GnecJlg98XJH3oCw2t/lLWvH2bSsF037k0LVRHPrzvPbzc8QGll9Ds955Guj8tA0 kjGx62FhA5h1M6K0IzUdbRSoeWrH6AnDc0X8lNwiI06Q3lkJhZpDdnj50QWsdezaBr 89lUT5yqi0HVuMk6OF2z9TzzkeCFJhaY8A7mtoNOb1gwTJHH4Izpeqac3hhs8S1STL lFBeukMByZvlg== Received: by mail-lf1-f52.google.com with SMTP id 2adb3069b0e04-50e70b0b869so1336518e87.2; Sun, 24 Dec 2023 17:11:15 -0800 (PST) X-Gm-Message-State: AOJu0Yyjk5euzlyegYxmb0Be3KKS4nDJ5WYtx55MQdXShBj6QG9hPJ+E sk/V6tXqXJig9MAMGSuBVxzB6huHeqixZ/atE/Q= X-Received: by 2002:a05:6512:3c9d:b0:50e:74f4:d1e6 with SMTP id h29-20020a0565123c9d00b0050e74f4d1e6mr954423lfv.18.1703466673405; Sun, 24 Dec 2023 17:11:13 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20231221071109.1562530-1-linan666@huaweicloud.com> <20231221071109.1562530-2-linan666@huaweicloud.com> In-Reply-To: From: Song Liu Date: Sun, 24 Dec 2023 17:11:02 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 1/2] md: fix WARN_ON if create symlink fail in bind_rdev_to_array() To: Li Nan Cc: yukuai3@huawei.com, linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org, yi.zhang@huawei.com, houtao1@huawei.com, yangerkun@huawei.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Dec 21, 2023 at 5:17=E2=80=AFPM Li Nan w= rote: > > > > =E5=9C=A8 2023/12/22 2:58, Song Liu =E5=86=99=E9=81=93: [...] > > 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 *rd= ev, 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(). Thanks, Song