From patchwork Fri Mar 1 09:56:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 208744 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp975401dyb; Fri, 1 Mar 2024 02:07:33 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVv7vpXTEUhS0kM7nzqNhD9jPoss67bKx5fHnhMTqzH8fd7Bf7ZFNlLiL3NdUWzE5OfHpAlHt49qiSHK3fsBjtHJahXWQ== X-Google-Smtp-Source: AGHT+IG7yLQXloB8pzh+eeQMrUNVjLN/q/8ZVaQ99YeXayxpXHi0fxDiBmpoquCC/3xoHlzKfxbK X-Received: by 2002:a05:6a20:c522:b0:1a0:f7d0:e652 with SMTP id gm34-20020a056a20c52200b001a0f7d0e652mr827590pzb.49.1709287653546; Fri, 01 Mar 2024 02:07:33 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709287653; cv=pass; d=google.com; s=arc-20160816; b=iSRVXTb/OkJLjtYwsF9btRedVJECvSQKcbte/WYms5heQbOJLJKFrUDsxLUM503qkk Mr4hKqVdSymLC8xL8GgbtNxiAh3NM0urWqhyFjidVdnqFAT4zaV0uG73Bp5KDhzy/A+Z ZqSALFWKJX1dbzB/CavYER7wL89R1f4O7tHx7S1SzyTaXFbqw7paCg373xKHvgxaCofw 07/iJdU2IgM4Plpkpn7PlJHkgj0OHABpkER+oNZgf2oSYp9ZWTk4PPZCkQdb/7Oct92t 5RF92W92YOUxHY5Y1ohDLIiGJDzX2GKVwP6F8jQbZSouJST2WWb14eYyCrLGY6BBUFyz 8VeA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=te0LmLiWZ4HWjtg4mCXeilr71PhFm8MNa/RetoCq2GE=; fh=D0tHjPHp+NwWiP9dALgrUrDY+JdDylAJlTP6wFQuWjg=; b=XbuQ9KKo5rT5duGEGHJ0bP99rR9tXM9iNfzdPiEEWJDQiqUnXh/nCdNjiG9FYdsl/b uBcXbno8KlGv4FtwDrjRFXShALmNPFe9CW1GmH0xuAvvAia7ZaiBXCcrmutNxOKMo+TM Fb2eVLpNsTeO9I9zhZG3KDFiSAzq+WrbtI5vGdJ1w7DaKum5i0Bwypr6EkErkftwAWcn keKB/tvybFruiS03zi6QvtEK65qTlwnudIAHFTD1QhyHBjmYPY/Mx+Ix8YELn+C2dsrD vo3N1bh2bBe7HJ0le+JtYr9QuaOef6c7mPjVNW9AJlv6iK1N49Hb1AgztwOVRzOtpLiB xVSg==; 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-88231-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88231-ouuuleilei=gmail.com@vger.kernel.org" Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id l5-20020a170902e2c500b001dccba6652fsi2992949plc.446.2024.03.01.02.07.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 02:07:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88231-ouuuleilei=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; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-88231-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88231-ouuuleilei=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 E4FFA2879C4 for ; Fri, 1 Mar 2024 10:07:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6FF8C7292E; Fri, 1 Mar 2024 10:03:15 +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 D57D06F08A; Fri, 1 Mar 2024 10:03:11 +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=1709287393; cv=none; b=lvSlCMHqbzH+/h7ANEZ9O67D+BJqqzSAPbTtdAxzdgUuWJO4LFB2e9x7v9pEAKHJwKXD614k/GjrrAVY6MQ1puwffcj6XpcKbXkPm2xmPPZMiRY+iCzuA01Sqep93msvyhtQHCS/qJ0SH033zab6jqpjju44eqVOKEavD05yuro= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709287393; c=relaxed/simple; bh=VziGCbwUbeAcm42yPFPU2H6z//+M0EMCvPLjzxVDX7g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Q2s16tsR1rxmZYnY40gEsOqXM2XBT9JXRtB5LDuXCSNPBD20jHeLaYCNl5Z3YqsrlNHsXVAuPl/5L4+0liBSv2eHTFq2WUYC2yfIPo3uL1pqz4Z8Q4ARdNmav1O9dksdF79D9ZGjheAS+HaAvzMSKXv0QUheP4fm+pEga2H1Y1o= 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 4TmNvF2BZGz4f3kkj; Fri, 1 Mar 2024 18:03:05 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id B0BE91A0E60; Fri, 1 Mar 2024 18:03:08 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgCXaBHTp+FlqmBuFg--.36874S13; Fri, 01 Mar 2024 18:03:08 +0800 (CST) From: Yu Kuai To: zkabelac@redhat.com, xni@redhat.com, agk@redhat.com, snitzer@kernel.org, mpatocka@redhat.com, dm-devel@lists.linux.dev, song@kernel.org, yukuai3@huawei.com, heinzm@redhat.com, neilb@suse.de, jbrassow@redhat.com Cc: linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH -next 9/9] dm-raid: fix lockdep waring in "pers->hot_add_disk" Date: Fri, 1 Mar 2024 17:56:57 +0800 Message-Id: <20240301095657.662111-10-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240301095657.662111-1-yukuai1@huaweicloud.com> References: <20240301095657.662111-1-yukuai1@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CM-TRANSID: cCh0CgCXaBHTp+FlqmBuFg--.36874S13 X-Coremail-Antispam: 1UD129KBjvJXoW7Cr45Jw1UZF45JF13GFW5GFg_yoW8Jw4Up3 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dzhxuhorxvhhfrp/ X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792318010904539347 X-GMAIL-MSGID: 1792318010904539347 From: Yu Kuai The lockdep assert is added by commit a448af25becf ("md/raid10: remove rcu protection to access rdev from conf") in print_conf(). And I didn't notice that dm-raid is calling "pers->hot_add_disk" without holding 'reconfig_mutex'. "pers->hot_add_disk" read and write many fields that is protected by 'reconfig_mutex', and raid_resume() already grab the lock in other contex. Hence fix this problem by protecting "pers->host_add_disk" with the lock. Fixes: 9092c02d9435 ("DM RAID: Add ability to restore transiently failed devices on resume") Fixes: a448af25becf ("md/raid10: remove rcu protection to access rdev from conf") Signed-off-by: Yu Kuai --- drivers/md/dm-raid.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c index 64d381123ce3..97ad4a8582c4 100644 --- a/drivers/md/dm-raid.c +++ b/drivers/md/dm-raid.c @@ -4091,7 +4091,9 @@ static void raid_resume(struct dm_target *ti) * Take this opportunity to check whether any failed * devices are reachable again. */ + mddev_lock_nointr(mddev); attempt_restore_of_faulty_devices(rs); + mddev_unlock(mddev); } if (test_and_clear_bit(RT_FLAG_RS_SUSPENDED, &rs->runtime_flags)) {