Skip to content

Commit bc6a385

Browse files
gulamsaxboe
authored andcommitted
block: fix a race between del_gendisk and BLKRRPART
When BLKRRPART is called concurrently with del_gendisk, the partitions rescan can create a stale partition that will never be be cleaned up. Fix this by checking the the disk is up before rescanning partitions while under bd_mutex. Signed-off-by: Gulam Mohamed <[email protected]> [hch: split from a larger patch] Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Ming Lei <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 6c60ff0 commit bc6a385

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

fs/block_dev.c

+3
Original file line numberDiff line numberDiff line change
@@ -1244,6 +1244,9 @@ int bdev_disk_changed(struct block_device *bdev, bool invalidate)
12441244

12451245
lockdep_assert_held(&bdev->bd_mutex);
12461246

1247+
if (!(disk->flags & GENHD_FL_UP))
1248+
return -ENXIO;
1249+
12471250
rescan:
12481251
if (bdev->bd_part_count)
12491252
return -EBUSY;

0 commit comments

Comments
 (0)