aboutsummaryrefslogtreecommitdiffstats
path: root/block
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2021-04-06 08:23:01 +0200
committerJens Axboe <axboe@kernel.dk>2021-04-08 10:24:36 -0600
commit7fae67cc9c0e0645e8c82156ba3a8bb7bae995bb (patch)
tree18a0fd40bac57da2623d615acccaaacd9ffa11c8 /block
parentblock: simplify show_partition (diff)
downloadlinux-dev-7fae67cc9c0e0645e8c82156ba3a8bb7bae995bb.tar.xz
linux-dev-7fae67cc9c0e0645e8c82156ba3a8bb7bae995bb.zip
block: simplify diskstats_show
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-11-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block')
-rw-r--r--block/genhd.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/block/genhd.c b/block/genhd.c
index 5726714ef82f..cbfe1ff19360 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -1236,11 +1236,11 @@ const struct device_type disk_type = {
static int diskstats_show(struct seq_file *seqf, void *v)
{
struct gendisk *gp = v;
- struct disk_part_iter piter;
struct block_device *hd;
char buf[BDEVNAME_SIZE];
unsigned int inflight;
struct disk_stats stat;
+ unsigned long idx;
/*
if (&disk_to_dev(gp)->kobj.entry == block_class.devices.next)
@@ -1250,8 +1250,10 @@ static int diskstats_show(struct seq_file *seqf, void *v)
"\n\n");
*/
- disk_part_iter_init(&piter, gp, DISK_PITER_INCL_EMPTY_PART0);
- while ((hd = disk_part_iter_next(&piter))) {
+ rcu_read_lock();
+ xa_for_each(&gp->part_tbl, idx, hd) {
+ if (bdev_is_partition(hd) && !bdev_nr_sectors(hd))
+ continue;
part_stat_read_all(hd, &stat);
if (queue_is_mq(gp->queue))
inflight = blk_mq_in_flight(gp->queue, hd);
@@ -1294,7 +1296,7 @@ static int diskstats_show(struct seq_file *seqf, void *v)
NSEC_PER_MSEC)
);
}
- disk_part_iter_exit(&piter);
+ rcu_read_unlock();
return 0;
}