summaryrefslogtreecommitdiff
path: root/block/partitions/core.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2021-04-06 08:22:55 +0200
committerJens Axboe <axboe@kernel.dk>2021-04-08 10:24:36 -0600
commitd3c4a43d9291279c28b26757351a6ab72c110753 (patch)
tree191523e681fdff315c7e14029ace1a42ce1aaa5e /block/partitions/core.c
parent473338be3aaea117a7133720305f240eb7f68951 (diff)
downloadlwn-d3c4a43d9291279c28b26757351a6ab72c110753.tar.gz
lwn-d3c4a43d9291279c28b26757351a6ab72c110753.zip
block: refactor blk_drop_partitions
Move the busy check and disk-wide sync into the only caller, so that the remainder can be shared with del_gendisk. Also pass the gendisk instead of the bdev as that is all that is needed. Signed-off-by: Christoph Hellwig <hch@lst.de> Link: https://lore.kernel.org/r/20210406062303.811835-5-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/partitions/core.c')
-rw-r--r--block/partitions/core.c14
1 files changed, 3 insertions, 11 deletions
diff --git a/block/partitions/core.c b/block/partitions/core.c
index 8c1735292940..536f7c5bb0b6 100644
--- a/block/partitions/core.c
+++ b/block/partitions/core.c
@@ -285,7 +285,7 @@ struct device_type part_type = {
* Must be called either with bd_mutex held, before a disk can be opened or
* after all disk users are gone.
*/
-void delete_partition(struct block_device *part)
+static void delete_partition(struct block_device *part)
{
fsync_bdev(part);
__invalidate_device(part, true);
@@ -526,23 +526,15 @@ static bool disk_unlock_native_capacity(struct gendisk *disk)
}
}
-int blk_drop_partitions(struct block_device *bdev)
+void blk_drop_partitions(struct gendisk *disk)
{
struct disk_part_iter piter;
struct block_device *part;
- if (bdev->bd_part_count)
- return -EBUSY;
-
- sync_blockdev(bdev);
- invalidate_bdev(bdev);
-
- disk_part_iter_init(&piter, bdev->bd_disk, DISK_PITER_INCL_EMPTY);
+ disk_part_iter_init(&piter, disk, DISK_PITER_INCL_EMPTY);
while ((part = disk_part_iter_next(&piter)))
delete_partition(part);
disk_part_iter_exit(&piter);
-
- return 0;
}
static bool blk_add_partition(struct gendisk *disk, struct block_device *bdev,