linux/block
Connor Williamson 181bb9c9ea block: remove redundant GD_NEED_PART_SCAN in add_disk_final()
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 e5cfefa97b
("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: e5cfefa97b ("block: fix scan partition for exclusively open device again")
Cc: stable@vger.kernel.org
Signed-off-by: Connor Williamson <connordw@amazon.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Link: https://patch.msgid.link/20260615130715.53693-1-connordw@amazon.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2026-07-10 09:08:50 -06:00
..
partitions partitions: aix: bound the pp_count scan to the ppe array 2026-06-08 07:41:21 -06:00
badblocks.c badblocks: Fix a nonsense WARN_ON() which checks whether a u64 variable < 0 2025-03-10 07:41:58 -06:00
bdev.c block: Avoid mounting the bdev pseudo-filesystem in userspace 2026-05-26 11:01:55 -06:00
bfq-cgroup.c blk-cgroup: don't nest queue_lock under rcu in blkcg_print_blkgs() 2026-06-24 06:42:19 -06:00
bfq-iosched.c block, bfq: don't grab queue_lock to initialize bfq 2026-06-24 06:42:31 -06:00
bfq-iosched.h block, bfq: update outdated comment 2026-01-01 08:57:37 -07:00
bfq-wf2q.c
bio-integrity-auto.c block: fix GFP_ flags confusion in bio_integrity_alloc_buf 2026-06-24 06:53:25 -06:00
bio-integrity-fs.c block: fix GFP_ flags confusion in bio_integrity_alloc_buf 2026-06-24 06:53:25 -06:00
bio-integrity.c block: handle REQ_OP_ZONE_APPEND in __bio_integrity_action 2026-06-24 06:53:25 -06:00
bio.c block: respect iov_iter::nofault flag in bio_iov_iter_bounce_write() 2026-06-16 14:48:35 -06:00
blk-cgroup-fc-appid.c block: Replace all non-returning strlcpy with strscpy 2023-06-01 09:13:31 -06:00
blk-cgroup-rwstat.c blk-cgroup: don't nest queue_lock under rcu in blkcg_print_blkgs() 2026-06-24 06:42:19 -06:00
blk-cgroup-rwstat.h blk-cgroup: rwstat: fix kernel-doc warnings in header file 2025-01-13 07:47:09 -07:00
blk-cgroup.c blk-cgroup: don't nest queue_lock under blkcg->lock in blkcg_destroy_blkgs() 2026-06-24 06:42:31 -06:00
blk-cgroup.h blk-cgroup: don't nest queue_lock under rcu in blkcg_print_blkgs() 2026-06-24 06:42:19 -06:00
blk-core.c block: Remove redundant plug in __submit_bio() 2026-06-16 10:06:27 -06:00
blk-crypto-fallback.c for-7.2/block-20260615 2026-06-16 13:02:47 +05:30
blk-crypto-internal.h blk-crypto: handle the fallback above the block layer 2026-01-11 12:55:41 -07:00
blk-crypto-profile.c block/crypto: Annotate the crypto functions 2026-06-05 13:41:11 -06:00
blk-crypto-sysfs.c blk-crypto: make blk_crypto_attr instances const 2026-03-17 19:29:16 -06:00
blk-crypto.c - small cleanups in dm-vdo, dm-raid, dm-cache, dm-zoned-metadata 2026-06-16 13:20:54 +05:30
blk-flush.c block: pass io_comp_batch to rq_end_io_fn callback 2026-01-20 10:12:54 -07:00
blk-ia-ranges.c block: ia-ranges: make blk_ia_range_sysfs_entry instances const 2026-03-17 19:29:16 -06:00
blk-integrity.c block: don't merge bios with different app_tags 2026-01-06 19:10:08 -07:00
blk-ioc.c copy_process: pass clone_flags as u64 across calltree 2025-09-01 15:31:34 +02:00
blk-iocost.c blk-cgroup: don't nest queue_lock under rcu in blkcg_print_blkgs() 2026-06-24 06:42:19 -06:00
blk-iolatency.c blk-cgroup: delay freeing policy data after rcu grace period 2026-06-24 06:37:54 -06:00
blk-ioprio.c treewide: Replace kmalloc with kmalloc_obj for non-scalar types 2026-02-21 01:02:28 -08:00
blk-ioprio.h blk-ioprio: remove per-disk structure 2024-07-28 16:47:51 -06:00
blk-lib.c block: add a bio_submit_or_kill helper 2026-04-07 08:22:24 -06:00
blk-map.c block-7.0-20260305 2026-03-06 08:36:18 -08:00
blk-merge.c block: propagate in_flight to whole disk on partition I/O 2026-06-09 10:12:50 -06:00
blk-mq-cpumap.c blk-mq: add number of queue calc helper 2025-07-01 10:24:19 -06:00
blk-mq-debugfs.c block/blk-mq-debugfs: Improve lock context annotations 2026-06-05 13:41:11 -06:00
blk-mq-debugfs.h blk-mq-debugfs: remove blk_mq_debugfs_unregister_rqos() 2026-02-02 07:05:19 -07:00
blk-mq-dma.c block: fix partial IOVA mapping cleanup in blk_rq_dma_map_iova 2026-02-12 04:23:31 -07:00
blk-mq-sched.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
blk-mq-sched.h blk-mq-sched: unify elevators checking for async requests 2026-02-03 07:45:36 -07:00
blk-mq-sysfs.c blk-mq: make blk_mq_hw_ctx_sysfs_entry instances const 2026-03-17 19:29:16 -06:00
blk-mq-tag.c blk-mq: add tracepoint block_rq_tag_wait 2026-05-26 11:01:54 -06:00
blk-mq.c blk-mq: bound blk_hctx_poll() to one jiffy 2026-06-26 10:41:33 -06:00
blk-mq.h blk-mq: use queue_hctx in blk_mq_map_queue_type 2025-12-01 07:18:31 -07:00
blk-pm.c block: force noio scope in blk_mq_freeze_queue 2025-01-31 07:20:08 -07:00
blk-pm.h
blk-rq-qos.c blk-mq-debugfs: remove blk_mq_debugfs_unregister_rqos() 2026-02-02 07:05:19 -07:00
blk-rq-qos.h blk-rq-qos: Remove unlikely() hints from QoS checks 2026-01-06 19:08:23 -07:00
blk-settings.c block: clear BLK_FEAT_PCI_P2PDMA in blk_stack_limits() for non-supporting devices 2026-05-26 15:51:48 -06:00
blk-stat.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
blk-stat.h blk-stat: convert struct blk_stat_callback to kernel-doc 2026-02-16 10:21:06 -07:00
blk-sysfs.c block: add configurable error injection 2026-06-12 10:40:35 -06:00
blk-throttle.c blk-cgroup: delay freeing policy data after rcu grace period 2026-06-24 06:37:54 -06:00
blk-throttle.h blk-throttle: fix access race during throttle policy activation 2025-09-08 08:24:44 -06:00
blk-timeout.c
blk-wbt.c block: Make WBT latency writes honor enable state 2026-07-01 19:07:20 -06:00
blk-wbt.h blk-wbt: factor out a helper wbt_set_lat() 2026-02-02 07:05:19 -07:00
blk-zoned.c block: avoid potential deadlock on zone revalidation failure 2026-07-01 05:34:35 -06:00
blk.h block: avoid potential deadlock on zone revalidation failure 2026-07-01 05:34:35 -06:00
bsg-lib.c block: switch numa_node to int in blk_mq_hw_ctx and init_request 2026-05-26 11:01:55 -06:00
bsg.c bsg: add io_uring command support to generic layer 2026-03-19 11:38:24 -06:00
disk-events.c loop: fix partition scan race between udev and loop_reread_partitions() 2026-03-31 07:04:34 -06:00
early-lookup.c wrapper for access to ->bd_partno 2024-05-02 17:48:09 -04:00
elevator.c block: use trylock to avoid lockdep circular dependency in sysfs 2026-03-05 04:01:42 -07:00
elevator.h block: fix race between wbt_enable_default and IO submission 2025-12-12 12:51:11 -07:00
error-injection.c block: fix incorrect error injection static key decrement 2026-06-22 15:55:11 -06:00
error-injection.h block: add configurable error injection 2026-06-12 10:40:35 -06:00
fops.c block: add a bio_endio_status helper 2026-05-28 07:59:18 -06:00
genhd.c block: remove redundant GD_NEED_PART_SCAN in add_disk_final() 2026-07-10 09:08:50 -06:00
holder.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
ioctl.c block: fix IORING_URING_CMD_REISSUE flags check in blkdev_uring_cmd 2026-06-16 09:56:38 -06:00
ioprio.c block: remove test of incorrect io priority level 2025-05-08 09:04:12 -06:00
Kconfig block: add configurable error injection 2026-06-12 10:40:35 -06:00
Kconfig.iosched
kyber-iosched.c block/Kyber: Make the lock context annotations compatible with Clang 2026-06-05 13:41:11 -06:00
Makefile block: add configurable error injection 2026-06-12 10:40:35 -06:00
mq-deadline.c block/mq-deadline: Make the lock context annotations compatible with Clang 2026-06-05 13:41:11 -06:00
opal_proto.h sed-opal: Add STACK_RESET command 2026-03-31 07:04:00 -06:00
sed-opal.c sed-opal: Add STACK_RESET command 2026-03-31 07:04:00 -06:00
t10-pi.c blk-integrity: support arbitrary buffer alignment 2026-03-14 07:44:30 -06:00