block: simplify show_partition
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: Christoph Hellwig <hch@lst.de> Link: https://lore.kernel.org/r/20210406062303.811835-10-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
Родитель
e559f58d20
Коммит
ecc75a98b8
|
@ -907,8 +907,8 @@ static void *show_partition_start(struct seq_file *seqf, loff_t *pos)
|
||||||
static int show_partition(struct seq_file *seqf, void *v)
|
static int show_partition(struct seq_file *seqf, void *v)
|
||||||
{
|
{
|
||||||
struct gendisk *sgp = v;
|
struct gendisk *sgp = v;
|
||||||
struct disk_part_iter piter;
|
|
||||||
struct block_device *part;
|
struct block_device *part;
|
||||||
|
unsigned long idx;
|
||||||
char buf[BDEVNAME_SIZE];
|
char buf[BDEVNAME_SIZE];
|
||||||
|
|
||||||
/* Don't show non-partitionable removeable devices or empty devices */
|
/* Don't show non-partitionable removeable devices or empty devices */
|
||||||
|
@ -918,15 +918,16 @@ static int show_partition(struct seq_file *seqf, void *v)
|
||||||
if (sgp->flags & GENHD_FL_SUPPRESS_PARTITION_INFO)
|
if (sgp->flags & GENHD_FL_SUPPRESS_PARTITION_INFO)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* show the full disk and all non-0 size partitions of it */
|
rcu_read_lock();
|
||||||
disk_part_iter_init(&piter, sgp, DISK_PITER_INCL_PART0);
|
xa_for_each(&sgp->part_tbl, idx, part) {
|
||||||
while ((part = disk_part_iter_next(&piter)))
|
if (!bdev_nr_sectors(part))
|
||||||
|
continue;
|
||||||
seq_printf(seqf, "%4d %7d %10llu %s\n",
|
seq_printf(seqf, "%4d %7d %10llu %s\n",
|
||||||
MAJOR(part->bd_dev), MINOR(part->bd_dev),
|
MAJOR(part->bd_dev), MINOR(part->bd_dev),
|
||||||
bdev_nr_sectors(part) >> 1,
|
bdev_nr_sectors(part) >> 1,
|
||||||
disk_name(sgp, part->bd_partno, buf));
|
disk_name(sgp, part->bd_partno, buf));
|
||||||
disk_part_iter_exit(&piter);
|
}
|
||||||
|
rcu_read_unlock();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче