summaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
Diffstat (limited to 'block')
-rw-r--r--block/blk.h1
-rw-r--r--block/genhd.c11
-rw-r--r--block/partitions/core.c14
3 files changed, 4 insertions, 22 deletions
diff --git a/block/blk.h b/block/blk.h
index 8f4337c5a9e6..8b3591aee0a5 100644
--- a/block/blk.h
+++ b/block/blk.h
@@ -349,7 +349,6 @@ char *disk_name(struct gendisk *hd, int partno, char *buf);
#define ADDPART_FLAG_NONE 0
#define ADDPART_FLAG_RAID 1
#define ADDPART_FLAG_WHOLEDISK 2
-void delete_partition(struct block_device *part);
int bdev_add_partition(struct block_device *bdev, int partno,
sector_t start, sector_t length);
int bdev_del_partition(struct block_device *bdev, int partno);
diff --git a/block/genhd.c b/block/genhd.c
index 15f99da4543f..8303ec67fd70 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -667,9 +667,6 @@ EXPORT_SYMBOL(device_add_disk_no_queue_reg);
*/
void del_gendisk(struct gendisk *disk)
{
- struct disk_part_iter piter;
- struct block_device *part;
-
might_sleep();
if (WARN_ON_ONCE(!disk->queue))
@@ -683,13 +680,7 @@ void del_gendisk(struct gendisk *disk)
* disk is marked as dead (GENHD_FL_UP cleared).
*/
down_write(&bdev_lookup_sem);
-
- /* invalidate stuff */
- 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);
-
+ blk_drop_partitions(disk);
fsync_bdev(disk->part0);
__invalidate_device(disk->part0, true);
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,