提交 6c4541a8 编写于 作者: C Christoph Hellwig 提交者: Jens Axboe

block: simplify partition removal

Always look up the first available entry instead of the complicated
stateful traversal.
Signed-off-by: NChristoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20210406062303.811835-7-hch@lst.deSigned-off-by: NJens Axboe <axboe@kernel.dk>
上级 c76f48eb
......@@ -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,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册