summaryrefslogtreecommitdiffstats
path: root/block/partitions
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2021-04-28 14:27:12 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2021-04-28 14:27:12 -0700
commit6c0029211382011af508273c4fc98a732f841d95 (patch)
tree63b47915c50542b28d1de48d0e50318afdb32dbb /block/partitions
parent16b3d0cf5bad844daaf436ad2e9061de0fe36e5c (diff)
parentf46ec84b5acbf8d7067d71a6bbdde213d4b86036 (diff)
downloadlinux-6c0029211382011af508273c4fc98a732f841d95.tar.gz
linux-6c0029211382011af508273c4fc98a732f841d95.tar.bz2
linux-6c0029211382011af508273c4fc98a732f841d95.zip
Merge tag 'for-5.13/block-2021-04-27' of git://git.kernel.dk/linux-block
Pull block updates from Jens Axboe: "Pretty quiet round this time, which is nice. In detail: - Series revamping bounce buffer support (Christoph) - Dead code removal (Christoph, Bart) - Partition iteration revamp, now using xarray (Christoph) - Passthrough request scheduler improvements (Lin) - Series of BFQ improvements (Paolo) - Fix ioprio task iteration (Peter) - Various little tweaks and fixes (Tejun, Saravanan, Bhaskar, Max, Nikolay)" * tag 'for-5.13/block-2021-04-27' of git://git.kernel.dk/linux-block: (41 commits) blk-iocost: don't ignore vrate_min on QD contention blk-mq: Fix spurious debugfs directory creation during initialization bfq/mq-deadline: remove redundant check for passthrough request blk-mq: bypass IO scheduler's limit_depth for passthrough request block: Remove an obsolete comment from sg_io() block: move bio_list_copy_data to pktcdvd block: remove zero_fill_bio_iter block: add queue_to_disk() to get gendisk from request_queue block: remove an incorrect check from blk_rq_append_bio block: initialize ret in bdev_disk_changed block: Fix sys_ioprio_set(.which=IOPRIO_WHO_PGRP) task iteration block: remove disk_part_iter block: simplify diskstats_show block: simplify show_partition block: simplify printk_all_partitions block: simplify partition_overlaps block: simplify partition removal block: take bd_mutex around delete_partitions in del_gendisk block: refactor blk_drop_partitions block: move more syncing and invalidation to delete_partition ...
Diffstat (limited to 'block/partitions')
-rw-r--r--block/partitions/core.c54
1 files changed, 23 insertions, 31 deletions
diff --git a/block/partitions/core.c b/block/partitions/core.c
index 46f055bc7ecb..dc60ecf46fe6 100644
--- a/block/partitions/core.c
+++ b/block/partitions/core.c
@@ -285,8 +285,11 @@ 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);
+
xa_erase(&part->bd_disk->part_tbl, part->bd_partno);
kobject_put(part->bd_holder_dir);
device_del(&part->bd_device);
@@ -424,21 +427,21 @@ out_put:
static bool partition_overlaps(struct gendisk *disk, sector_t start,
sector_t length, int skip_partno)
{
- struct disk_part_iter piter;
struct block_device *part;
bool overlap = false;
-
- disk_part_iter_init(&piter, disk, DISK_PITER_INCL_EMPTY);
- while ((part = disk_part_iter_next(&piter))) {
- if (part->bd_partno == skip_partno ||
- start >= part->bd_start_sect + bdev_nr_sectors(part) ||
- start + length <= part->bd_start_sect)
- continue;
- overlap = true;
- break;
+ unsigned long idx;
+
+ rcu_read_lock();
+ xa_for_each_start(&disk->part_tbl, idx, part, 1) {
+ if (part->bd_partno != skip_partno &&
+ start < part->bd_start_sect + bdev_nr_sectors(part) &&
+ start + length > part->bd_start_sect) {
+ overlap = true;
+ break;
+ }
}
+ rcu_read_unlock();
- disk_part_iter_exit(&piter);
return overlap;
}
@@ -475,9 +478,6 @@ int bdev_del_partition(struct block_device *bdev, int partno)
if (part->bd_openers)
goto out_unlock;
- sync_blockdev(part);
- invalidate_bdev(part);
-
delete_partition(part);
ret = 0;
out_unlock:
@@ -533,28 +533,20 @@ 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;
+ unsigned long idx;
- if (bdev->bd_part_count)
- return -EBUSY;
+ lockdep_assert_held(&disk->part0->bd_mutex);
- sync_blockdev(bdev);
- invalidate_bdev(bdev);
-
- disk_part_iter_init(&piter, bdev->bd_disk, DISK_PITER_INCL_EMPTY);
- while ((part = disk_part_iter_next(&piter)))
+ xa_for_each_start(&disk->part_tbl, idx, part, 1) {
+ if (!bdgrab(part))
+ continue;
delete_partition(part);
- disk_part_iter_exit(&piter);
-
- return 0;
+ bdput(part);
+ }
}
-#ifdef CONFIG_S390
-/* for historic reasons in the DASD driver */
-EXPORT_SYMBOL_GPL(blk_drop_partitions);
-#endif
static bool blk_add_partition(struct gendisk *disk, struct block_device *bdev,
struct parsed_partitions *state, int p)