From patchwork Tue Jan 30 02:18:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 193813 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp961911dyb; Mon, 29 Jan 2024 18:42:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IEC2P1YXCTCM/A6/puSBNsb6vr9FCzGUq7J4BakjD44KsNlfAlfJCALr7pevLnhC4OM0hJd X-Received: by 2002:a17:90a:6982:b0:28d:c2ec:8950 with SMTP id s2-20020a17090a698200b0028dc2ec8950mr440741pjj.2.1706582575767; Mon, 29 Jan 2024 18:42:55 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706582575; cv=pass; d=google.com; s=arc-20160816; b=hkcWskdGJAhQB0XfMOi9MF0HJ8JtLut17g+9lWXwD6nk6nO3tM6zns96Zxe8IeAgVD TlKPYzN5Sf0eLNFZ18p1nKyQPttXUMtiAho02Jf3eQVgZG9I7xqkU7U83UJkEDT3Wn7n u8b1fJSJxSrpQ6Tf3FsQHPDHrOSaBAI1oB43FEGwvxHjBsVkSC9tv5b20epx5TY80R82 IH3rsHv6CiiKMEIoIeTHhcL5iGFjd25Fuf3Pmnh1DMVyV3tyj9/4pUaw8HVKA9iM3eMd +R8krHQQu9jWtiJCEh/zEhcWraL6+x1ofiFCX58vCrVMYwlH1TQ4KjJei4NHrNZwpY3z lbwA== 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=FtirvJJ13L8gehLQ375a0lCTkAroffAi0JfnF40Fa78=; b=u3Q/Wm3KE/MSEGgtyhmDanHyCOe/Vq3vaDWAFw174XLEo13rrcwGElsqsBk4urRwyi olBKoQ4U/fHIK6D7JQ+iR8PfCrpPyBbM7mJpzXpVYucc9hlhJfunly5ZGtp3mK7/swTB MoFOkcLIKBmcLmyRn2OQDEDOGqKWWCzJP/PnntBVf4TVTxbfEtROWnV72EbPgHRWYfQa /hilBwLhEvoZ3MLecU16Q5xL1m+oehcqWC7oFqWWf45FlBZiLOb1vgATU78iFyd67gDS F7UEaM6jjSPJUoZ0tMbB3MU1zo2s+6jPGyn6HJy8k8hTS5d6IMufNQSTE043MWuDHRUo YCXA== 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-43816-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-43816-ouuuleilei=gmail.com@vger.kernel.org" Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id z6-20020a170903018600b001d8ac7882b6si705458plg.561.2024.01.29.18.42.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 18:42:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-43816-ouuuleilei=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; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-43816-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-43816-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id AE556B24DB7 for ; Tue, 30 Jan 2024 02:27:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9DF8615B0E4; Tue, 30 Jan 2024 02:23: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 E8C024C60E; Tue, 30 Jan 2024 02:23: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=1706581393; cv=none; b=erjK2aNotzG6ZMkPcS903hm81ydFaE9U8DZjAHsTwplD7F3Xs9dzf+vB8D/L1oAW/NkU/lTnBzt9GQN+U28blhZuV91gEpkakulSVJc0SOTXlz+gtU1GzwVo7HpK5/YjrLYdo769g+UX6iOS1nZM7nKWnTv45VafdTa64mz0j3g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706581393; c=relaxed/simple; bh=a7HDR2QZuFH8EpmOVAfdCFF1UeWbNCM4RUwmYnTBG/s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=mzrOYxH5sMUW4Yw6BGrfR/xjcC5oM9z7HhU0sl3xgZ/NjnRe5jG3NyaiWHvB4hV962zn/CpKK4YBT7WVrkW/qEp85QVkydIjC1ehBTulZEyKqyE2oII/ibrZ3NH8r9rxNW4y0o/GaG2X1R/HWyYtm/wEVKpz8u1Wck/SBjwOCMU= 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 4TP88k4D4Nz4f3m7G; Tue, 30 Jan 2024 10:23:02 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 11C081A027B; Tue, 30 Jan 2024 10:23:09 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgBHGBGBXbhlrAigCQ--.55484S16; Tue, 30 Jan 2024 10:23:08 +0800 (CST) From: Yu Kuai To: mpatocka@redhat.com, heinzm@redhat.com, xni@redhat.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 v4 12/14] dm-raid: fix lockdep waring in "pers->hot_add_disk" Date: Tue, 30 Jan 2024 10:18:41 +0800 Message-Id: <20240130021843.3608859-13-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240130021843.3608859-1-yukuai1@huaweicloud.com> References: <20240130021843.3608859-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: cCh0CgBHGBGBXbhlrAigCQ--.55484S16 X-Coremail-Antispam: 1UD129KBjvJXoW7Cr45Jw1UZF45JF13GFW5GFg_yoW8Jw4Up3 ZrK343Kw4DJr48Za1qvw1q9a45tan8K3ySy39xG395ZFy7ZrZI9ws8Ga1agFWDJFZaya98 AFW3J398Was5K3DanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPI14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628vn2 kIc2xKxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E 14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_GFv_WrylIx kGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVW8JVW5JwCI42IY6xIIjxv20xvEc7CjxVAF wI0_Gr1j6F4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Gr 0_Cr1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUQ SdkUUUUU= X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789481530895096410 X-GMAIL-MSGID: 1789481530895096410 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)) {