From patchwork Thu Feb 1 09:25:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 195227 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2719:b0:106:209c:c626 with SMTP id hl25csp31080dyb; Thu, 1 Feb 2024 01:34:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IHnvGVRIUE716A5Ln9LuPhL34w4gl3S9zOyN9vEZs6XcnXgwWLIreF3vbWNXtG3f/0iN1Kv X-Received: by 2002:a17:906:5944:b0:a35:a017:fb37 with SMTP id g4-20020a170906594400b00a35a017fb37mr3371070ejr.44.1706780098710; Thu, 01 Feb 2024 01:34:58 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706780098; cv=pass; d=google.com; s=arc-20160816; b=GUJ81V0seyVZ6Jcr5Np/tfmNcnOl4pFIApb56ctdg/ZIHDa22+CIZhigjlJa3serix E1fd0iA9fBXUzCbNo+6hUD/bE3NeFIMKE8Pbp4Na6Gg991AlgiP5nKYMxJIUSjqU4ZOg Itjh7AbAcSL8PcCkTJh0UI10SuLBC9qpR0Yiz6JbJ2gfZWON3dDildziiDcxQ8gOqI8f U8h8Qzrit46iR62hPksH0DjAPwwia1ORdj4WYdU3pyl4qpyZnsIchCQFJEgP+8EIOeU8 mI75ngQ3+Bzehug2Z8OjUaaykspnJ2ATebxpP1tiV2Wk3FFK7Ig82JRy6NjHlY7QmClv RLPg== 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=Gwajdbjq2bg1uihxFCNEmqNIL/yeEurfElrgwydZMvg=; fh=4kR0Wf2kEToqvXyrNqaMM9qup7Mym0KV7fdA7htr+BY=; b=ZIbkrrBjx8r/hh6c2D8Qm1fiNFG9QQPFC8hMEas3tO7Vo/UoaY1x9D44XEPaF+/Lhm XtAJKhvb7VFXSCXHJ/tVYIhkkx7cLdzvoBJoQiuzkAErSU/6+u0/l4HrROEQw+Ro8jse y7C0SjNH+VM+1GKWVTQv2WnlIhbHTjGOXXho3X4x9h99OTzkSytmQIAS1G0pcAqbEf2t 5hh37G07errFENaWj9pgFQzeCMhL4quHlvH+QVnbYRGBSu5Tmnpuj5XhdMweWbBRlKVf GPm0sgeF6UQq2bOhwwu5HSg/+72t6uyli7SDYLrrYGoDQF4P1aumYf5nyofEdsrFEZqK 4upQ==; 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-47877-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47877-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCWXB0hcSLag9uNzsKwOsgdAs7dCxDmsJARt6afFI2bl4gmvrgqbFAYUOrP4N2Jy82XNNdBUsz/YdFKJwdALxIjM7IHcqA== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id l14-20020a170906644e00b00a33923b5b5fsi6574117ejn.134.2024.02.01.01.34.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 01:34:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-47877-ouuuleilei=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-47877-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47877-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 257961F283C4 for ; Thu, 1 Feb 2024 09:34:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 18BDE1649BF; Thu, 1 Feb 2024 09:30:42 +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 D2FAE161B54; Thu, 1 Feb 2024 09:30:38 +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=1706779840; cv=none; b=FbP65hqUB4Visegpvmejemq/v3vcrUBq+Xk3u2d5P3ODutVi5mZVABFihWqN6vKZsjtvBdR7qHWZI0uCvzmmezvsYBMMiWbmPvAB8Y8j6Klhsg2saKfjjJa/sq22Syasq6MeL763Ua/4gUU2ikiuUlUqkmpv2wGHXfBL3XZDUaU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706779840; c=relaxed/simple; bh=a7HDR2QZuFH8EpmOVAfdCFF1UeWbNCM4RUwmYnTBG/s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=QpewRAZUTgPPylKm9LR9evyfAqnmULklbZQhHZfb7C5ITveBa8B2F8y0d7ZuYndo7ulart+Tu/2sJuwoVBwom3ayB1grFdDz+HcpNkOwEyoQWuNMj4vyLZpIsvfO4BR0NWabJVSXo4sx5QLY6XSpQLV6nXN7yfqXMfFqLtfWSIE= 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 4TQYY528Mxz4f3k6V; Thu, 1 Feb 2024 17:30:33 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id DB30F1A0232; Thu, 1 Feb 2024 17:30:35 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgCXaBGtZLtl8V6KCg--.33515S17; Thu, 01 Feb 2024 17:30:35 +0800 (CST) From: Yu Kuai To: mpatocka@redhat.com, heinzm@redhat.com, xni@redhat.com, blazej.kucman@linux.intel.com, agk@redhat.com, snitzer@kernel.org, dm-devel@lists.linux.dev, song@kernel.org, yukuai3@huawei.com, jbrassow@f14.redhat.com, neilb@suse.de, shli@fb.com, akpm@osdl.org Cc: linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH v5 13/14] dm-raid: fix lockdep waring in "pers->hot_add_disk" Date: Thu, 1 Feb 2024 17:25:58 +0800 Message-Id: <20240201092559.910982-14-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240201092559.910982-1-yukuai1@huaweicloud.com> References: <20240201092559.910982-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: cCh0CgCXaBGtZLtl8V6KCg--.33515S17 X-Coremail-Antispam: 1UD129KBjvJXoW7Cr45Jw1UZF45JF13GFW5GFg_yoW8Jw4Up3 ZrK343Kw4DJr48Za1qvw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-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789688649075583385 X-GMAIL-MSGID: 1789688649075583385 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 16d3348abfed..5f78cc19d6f3 100644 --- a/drivers/md/dm-raid.c +++ b/drivers/md/dm-raid.c @@ -4077,7 +4077,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)) {