Skip to content
This repository has been archived by the owner on Apr 18, 2024. It is now read-only.

Commit

Permalink
block: fix a race between del_gendisk and BLKRRPART
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
gulams authored and axboe committed May 20, 2021
1 parent 6c60ff0 commit bc6a385
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions fs/block_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -1244,6 +1244,9 @@ int bdev_disk_changed(struct block_device *bdev, bool invalidate)

lockdep_assert_held(&bdev->bd_mutex);

if (!(disk->flags & GENHD_FL_UP))
return -ENXIO;

rescan:
if (bdev->bd_part_count)
return -EBUSY;
Expand Down

0 comments on commit bc6a385

Please sign in to comment.