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

block: simplify partition_overlaps

Just use xa_for_each to iterate over the partitions as there is no need
to grab a reference to each partition.
Signed-off-by: NChristoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20210406062303.811835-8-hch@lst.deSigned-off-by: NJens Axboe <axboe@kernel.dk>
上级 6c4541a8
......@@ -420,21 +420,21 @@ static struct block_device *add_partition(struct gendisk *disk, int partno,
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;
unsigned long idx;
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;
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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册