Skip to content

Commit

Permalink
block: fix busy device checking in blk_drop_partitions
Browse files Browse the repository at this point in the history
bd_super is only set by get_tree_bdev and mount_bdev, and thus not by
other openers like btrfs or the XFS realtime and log devices, as well as
block devices directly opened from user space.  Check bd_openers
instead.

Fixes: 77032ca ("Return EBUSY from BLKRRPART for mounted whole-dev fs")
Signed-off-by: Christoph Hellwig <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
Christoph Hellwig authored and axboe committed Apr 7, 2020
1 parent 536167d commit d3ef553
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion block/partitions/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ int blk_drop_partitions(struct gendisk *disk, struct block_device *bdev)

if (!disk_part_scan_enabled(disk))
return 0;
if (bdev->bd_part_count || bdev->bd_super)
if (bdev->bd_part_count || bdev->bd_openers)
return -EBUSY;
res = invalidate_partition(disk, 0);
if (res)
Expand Down

0 comments on commit d3ef553

Please sign in to comment.