]> Git Repo - J-linux.git/commitdiff
block: fix a race between del_gendisk and BLKRRPART
authorGulam Mohamed <[email protected]>
Fri, 14 May 2021 13:18:42 +0000 (15:18 +0200)
committerJens Axboe <[email protected]>
Thu, 20 May 2021 13:59:35 +0000 (07:59 -0600)
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]>
fs/block_dev.c

index 580bae995b87980010e9ad716a7ade4c4fe22b4c..4494411fa4d3ef0f8bd1a826f60f866b101204ca 100644 (file)
@@ -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;
This page took 0.043537 seconds and 4 git commands to generate.