summaryrefslogtreecommitdiffstats
path: root/block
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2021-04-06 08:22:57 +0200
committerJens Axboe <axboe@kernel.dk>2021-04-08 10:24:36 -0600
commit6c4541a8bb94a1cccca55ee53c866eb72bf279cf (patch)
treeb6cf2a625cb966c30449fd60b0cade9f6851ca19 /block
parentc76f48eb5c084b1e15c931ae8cc1826cd771d70d (diff)
downloadlinux-stable-6c4541a8bb94a1cccca55ee53c866eb72bf279cf.tar.gz
linux-stable-6c4541a8bb94a1cccca55ee53c866eb72bf279cf.tar.bz2
linux-stable-6c4541a8bb94a1cccca55ee53c866eb72bf279cf.zip
block: simplify partition removal
Always look up the first available entry instead of the complicated stateful traversal. Signed-off-by: Christoph Hellwig <hch@lst.de> Link: https://lore.kernel.org/r/20210406062303.811835-7-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block')
-rw-r--r--block/partitions/core.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/block/partitions/core.c b/block/partitions/core.c
index 9fbaec466b51..927144d4e59d 100644
--- a/block/partitions/core.c
+++ b/block/partitions/core.c
@@ -528,15 +528,17 @@ static bool disk_unlock_native_capacity(struct gendisk *disk)
void blk_drop_partitions(struct gendisk *disk)
{
- struct disk_part_iter piter;
struct block_device *part;
+ unsigned long idx;
lockdep_assert_held(&disk->part0->bd_mutex);
- disk_part_iter_init(&piter, 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);
+ bdput(part);
+ }
}
static bool blk_add_partition(struct gendisk *disk, struct block_device *bdev,