Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 6B987471250; Tue, 21 Jul 2026 18:36:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784658966; cv=none; b=qdcHJtYe4SW3poBTUHhYBBWJgyW3lJDTbVFMsq9FXCryGcZfOYSm+vR3QQIQwBQzlTrN2enLVTidlY9hHX0v7QP7+Q6oABswOW3cZQDFFNMS5Fmei1QtDypMzxo34yvSDGXSAHlPG09p8lyNlPUFgXKKNMdk9cpjRlkil/v+DUk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784658966; c=relaxed/simple; bh=r0M3+7GuH1g5MDvztEHgwjF7t/fQjDf04QD+milXIeM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Nbu7/uUfo/j2oHa78P7rklYBbNAuuD6DmR4qGbdQOBclTExkYkwBwzm5VktckDt/i92Xgt9YMRa60TOala6HokA0xXNLZlpO15ag2owgGgtxQIuwANOkcHm1SIgbwV2RF6BeQntRVv7J96p6c+aZQ/oXv3sSmH9pdEAHHeTRrBM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=S+Co+QUs; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="S+Co+QUs" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CA8681F000E9; Tue, 21 Jul 2026 18:36:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784658965; bh=ejmzCCYfhvb3sc1xxWD2suOwgdj0gsnUvd2xiIB6HyA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=S+Co+QUsJtX8QaKCS0msZr+ShLfVxXYmHFO3GOl7xipORBHry/ikROVAO+VbySOlO Uf1aWrc30dkfFTTaAsHIYGdFvIOMmHnKRCcyFOGXpA4/oClaYBu+d7We+txFwH09Zu 6coqVJYciYGCs63WH3BsTBgXTVnK/lN1VQJcFj1Y= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Connor Williamson , Christoph Hellwig , Jens Axboe Subject: [PATCH 6.18 1341/1611] block: remove redundant GD_NEED_PART_SCAN in add_disk_final() Date: Tue, 21 Jul 2026 17:24:17 +0200 Message-ID: <20260721152545.616486465@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152514.750365251@linuxfoundation.org> References: <20260721152514.750365251@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Connor Williamson commit 181bb9c9eae4f69fe510a62a42c2932d0314a800 upstream. add_disk_final() sets GD_NEED_PART_SCAN before calling bdev_add(), then calls disk_scan_partitions() which sets the flag itself. The early set is redundant and introduces a race. Between bdev_add() and disk_scan_partitions(), concurrent openers (multipathd, blkid, LVM) see the flag in blkdev_get_whole() and trigger bdev_disk_changed(). When disk_scan_partitions() then runs, it calls bdev_disk_changed() again, dropping the partitions the concurrent opener already created before re-adding them, which can result in transient partition disappearances. The race is observable by inserting an msleep() between bdev_add() and disk_scan_partitions() while running concurrent open() calls during device bind. Without artificial delay, it manifests under scheduling pressure during boot on systems with aggressive device scanners (multipathd, systemd-udevd). Therefore, do not set GD_NEED_PART_SCAN in add_disk_final(). Other GD_NEED_PART_SCAN consumers (blkdev_get_whole(), sd_need_revalidate()) should not be affected as the flag is set internally by disk_scan_partitions(). The retry-on-next-open intention from commit e5cfefa97bcc ("block: fix scan partition for exclusively open device again") should also not be affected as the early return paths in disk_scan_partitions() should be unreachable at device registration time (bd_holder is NULL and open_partitions is zero). Fixes: e5cfefa97bcc ("block: fix scan partition for exclusively open device again") Cc: stable@vger.kernel.org Signed-off-by: Connor Williamson Reviewed-by: Christoph Hellwig Link: https://patch.msgid.link/20260615130715.53693-1-connordw@amazon.com Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- block/genhd.c | 4 ---- 1 file changed, 4 deletions(-) --- a/block/genhd.c +++ b/block/genhd.c @@ -407,10 +407,6 @@ static void add_disk_final(struct gendis struct device *ddev = disk_to_dev(disk); if (!(disk->flags & GENHD_FL_HIDDEN)) { - /* Make sure the first partition scan will be proceed */ - if (get_capacity(disk) && disk_has_partscan(disk)) - set_bit(GD_NEED_PART_SCAN, &disk->state); - bdev_add(disk->part0, ddev->devt); if (get_capacity(disk)) disk_scan_partitions(disk, BLK_OPEN_READ);