Skip to content

Commit

Permalink
block: return -EBUSY when there are open partitions in blkdev_reread_…
Browse files Browse the repository at this point in the history
…part

The switch to go through blkdev_get_by_dev means we now ignore the
return value from bdev_disk_changed in __blkdev_get.  Add a manual
check to restore the old semantics.

Fixes: 4601b4b ("block: reopen the device in blkdev_reread_part")
Reported-by: Karel Zak <[email protected]>
Signed-off-by: Christoph Hellwig <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
Christoph Hellwig authored and axboe committed Apr 21, 2021
1 parent f06c609 commit 68e6582
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions block/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ static int blkdev_reread_part(struct block_device *bdev, fmode_t mode)
return -EINVAL;
if (!capable(CAP_SYS_ADMIN))
return -EACCES;
if (bdev->bd_part_count)
return -EBUSY;

/*
* Reopen the device to revalidate the driver state and force a
Expand Down

0 comments on commit 68e6582

Please sign in to comment.