Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp232778lqs; Mon, 4 Mar 2024 23:31:35 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUAAHTZRqhCDCeCLNhPK6UMbzcCjCm4X8tq97IDdRQXeQ0zVD0Hz6ixYk1oFJXxnksOVH4xf/OxX8uxz6PbrB28IWZP3LfgK6p2cIYkZQ== X-Google-Smtp-Source: AGHT+IEYMzqOLxjFxDOphUY2WrSV5q4IM/8XZd43F5gGFZCkdEmJQuRqZcqttxAnNiA3xlJ/DN+O X-Received: by 2002:ac8:7f09:0:b0:42e:e0df:cd78 with SMTP id f9-20020ac87f09000000b0042ee0dfcd78mr1346395qtk.50.1709623895485; Mon, 04 Mar 2024 23:31:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709623895; cv=pass; d=google.com; s=arc-20160816; b=KkX5oJOeZ8QVcBF+UPx3b2WTpMQ0/dp0Yn9jx3g3jr553CZdr0ZwrDswUxcZeRRWZT FMHqS6+jWM7zWpWgz4Fbbm5x3T2cBbO9D7do3jEj8pNA+f3tOZeQfXTGUze3UbrYCa7q 5sjNEou1YHZt6May6PDMqLaeYeEjdFESWbhQ3mFekyGNyPT6Ns/pHTbHL1fgIDkhC/JX /yyDF5ZCwCHN751dXRIzxRkEIyy1F/TSg7HKoPsSmwy4RG8oRQ90XrDa7R7DdlzDamuX /R+XWDtyjRdU5FH+OMMFAIraWjxyboJFi/CWJmkNJUldV+gfBKG9p7ci7N08rWf7uj4o hlow== 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=2D5ckc7zLT8XE472r2z8voku33JxMeIc7L6WolGp4Fo=; fh=YoyvrhSFX/gomruhs8E5v3LJBIcHojMCK8eMDUDpafQ=; b=nwJom++8fHwUEdl4MfUPlVNH5tSRjO/oG0NQv7NsZSS3aPl0532nqXJ5Fxa9dcYv2f z+KYNTpPZKyBqm62j7EtUiRycxCDf9nk90yuPt0cMRBxXZYhhiC/bpgYMszmggb3nyu1 JQc5v42iM3xLZaZwn40hBCzQs5T99zD6hXTMaLMHZe4DcywoHk/ctt7cSo2lTDBC+YTg ngQqnKAMsCIOM/QVwQDROxqnQVZ6UDUPazSTGYTDxqhnw7jf3zVz/TXnBWfW9ta4cfmC VGQIRZWFEUHU1fEO3rc8g2Hv+HLCmgpw6NJgX9f96Dk7A5JaQwn4Ydx/HEc/4qOp3t9T nZfw==; 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-91804-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-91804-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id ay40-20020a05622a22a800b0042efaabc715si2254909qtb.202.2024.03.04.23.31.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 23:31:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-91804-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-91804-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-91804-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 39B861C21F02 for ; Tue, 5 Mar 2024 07:31:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BEBB580BE3; Tue, 5 Mar 2024 07:29:37 +0000 (UTC) Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [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 274727F474; Tue, 5 Mar 2024 07:29:33 +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=1709623777; cv=none; b=JGIBNaHBIqT5oxWTKDGIdz4oQsAKQtLHuZSHK010k9uTTHXCte00Ui5rC9xRPs61hELhzYYp/U1HBDTA1kliIj/MnpQfJXySEYElcod41Zp5e+D379gsAGJeQjdbZ6jF1FuRG0VK2ohbmlK0MgQuUzBIkJJ+3GuZHWVDh5E5ccQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709623777; c=relaxed/simple; bh=KEW/XJoqhjDOxQSQ1eSle9j1tLlHhzVv3KI/rIzFYbI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=HUuEQ5PifwROOHd5B8pLiSCz8Xt47KO0+snPX6u+3qf9VOCyCfImBRLW4FxL7hpMknWdSBj3pwQVs5meR/CPU87h1Eo8PQ33hHX06PIYEbD+7AxzuwwbjPEgStIbvythJFAvHHOWnqH+y3qvmocnDSYptSloWBDjSX8zrUj8iyA= 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 4TpnJ75gYJz4f3kJs; Tue, 5 Mar 2024 15:29:27 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 49C9C1A0C3A; Tue, 5 Mar 2024 15:29:31 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgBHGBHRyeZlGnf+Fw--.17927S13; Tue, 05 Mar 2024 15:29:31 +0800 (CST) From: Yu Kuai To: xni@redhat.com, zkabelac@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, jbrassow@redhat.com, neilb@suse.de Cc: linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH md-6.8 v2 9/9] dm-raid: fix lockdep waring in "pers->hot_add_disk" Date: Tue, 5 Mar 2024 15:23:06 +0800 Message-Id: <20240305072306.2562024-10-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240305072306.2562024-1-yukuai1@huaweicloud.com> References: <20240305072306.2562024-1-yukuai1@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID:cCh0CgBHGBHRyeZlGnf+Fw--.17927S13 X-Coremail-Antispam: 1UD129KBjvJXoW7Cr45Jw1UZF45JF13GFW5GFg_yoW8GFy3p3 ZrK343Kw4DJr48Z3Wqvw1q9a45tan8K3ySyrZxG3s5ZFy2vrZI9wn8Ka1agFWDZFyftFW5 AF43J3yrW3Z8t3DanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPI14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628vn2 kIc2xKxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E 14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_GFv_WrylIx kGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUCVW8JwCI42IY6xIIjxv20xvEc7CjxVAF wI0_Gr1j6F4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr 0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUQ SdkUUUUU= X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ 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 Signed-off-by: Xiao Ni Acked-by: Mike Snitzer --- 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 ea45f777691c..17e9af60bbf7 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)) { -- 2.39.2