From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>,
Stefan Haberland <sth@linux.ibm.com>,
Jan Hoeppner <hoeppner@linux.ibm.com>
Cc: Tejun Heo <tj@kernel.org>,
linux-block@vger.kernel.org, linux-s390@vger.kernel.org
Subject: [PATCH 08/11] block: simplify printk_all_partitions
Date: Tue, 6 Apr 2021 08:22:59 +0200 [thread overview]
Message-ID: <20210406062303.811835-9-hch@lst.de> (raw)
In-Reply-To: <20210406062303.811835-1-hch@lst.de>
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>
---
block/genhd.c | 33 ++++++++++++++++-----------------
1 file changed, 16 insertions(+), 17 deletions(-)
diff --git a/block/genhd.c b/block/genhd.c
index e3f3c2321773f9..409ff4710f9215 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -806,10 +806,10 @@ void __init printk_all_partitions(void)
class_dev_iter_init(&iter, &block_class, NULL, &disk_type);
while ((dev = class_dev_iter_next(&iter))) {
struct gendisk *disk = dev_to_disk(dev);
- struct disk_part_iter piter;
struct block_device *part;
char name_buf[BDEVNAME_SIZE];
char devt_buf[BDEVT_SIZE];
+ unsigned long idx;
/*
* Don't show empty devices or things that have been
@@ -820,30 +820,29 @@ void __init printk_all_partitions(void)
continue;
/*
- * Note, unlike /proc/partitions, I am showing the
- * numbers in hex - the same format as the root=
- * option takes.
+ * Note, unlike /proc/partitions, I am showing the numbers in
+ * hex - the same format as the root= option takes.
*/
- disk_part_iter_init(&piter, disk, DISK_PITER_INCL_PART0);
- while ((part = disk_part_iter_next(&piter))) {
- bool is_part0 = part == disk->part0;
-
- printk("%s%s %10llu %s %s", is_part0 ? "" : " ",
+ rcu_read_lock();
+ xa_for_each(&disk->part_tbl, idx, part) {
+ if (!bdev_nr_sectors(part))
+ continue;
+ printk("%s%s %10llu %s %s",
+ bdev_is_partition(part) ? " " : "",
bdevt_str(part->bd_dev, devt_buf),
bdev_nr_sectors(part) >> 1,
disk_name(disk, part->bd_partno, name_buf),
part->bd_meta_info ?
part->bd_meta_info->uuid : "");
- if (is_part0) {
- if (dev->parent && dev->parent->driver)
- printk(" driver: %s\n",
- dev->parent->driver->name);
- else
- printk(" (driver?)\n");
- } else
+ if (bdev_is_partition(part))
printk("\n");
+ else if (dev->parent && dev->parent->driver)
+ printk(" driver: %s\n",
+ dev->parent->driver->name);
+ else
+ printk(" (driver?)\n");
}
- disk_part_iter_exit(&piter);
+ rcu_read_unlock();
}
class_dev_iter_exit(&iter);
}
--
2.30.1
next prev parent reply other threads:[~2021-04-06 6:23 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-06 6:22 partition iteration simplifications Christoph Hellwig
2021-04-06 6:22 ` [PATCH 01/11] dasd: use bdev_disk_changed instead of blk_drop_partitions Christoph Hellwig
2021-04-08 14:31 ` Stefan Haberland
2021-04-06 6:22 ` [PATCH 02/11] block: remove invalidate_partition Christoph Hellwig
2021-04-06 6:22 ` [PATCH 03/11] block: move more syncing and invalidation to delete_partition Christoph Hellwig
2021-04-06 6:22 ` [PATCH 04/11] block: refactor blk_drop_partitions Christoph Hellwig
2021-04-06 6:22 ` [PATCH 05/11] block: take bd_mutex around delete_partitions in del_gendisk Christoph Hellwig
2021-04-06 6:22 ` [PATCH 06/11] block: simplify partition removal Christoph Hellwig
2021-04-06 6:22 ` [PATCH 07/11] block: simplify partition_overlaps Christoph Hellwig
2021-04-06 6:22 ` Christoph Hellwig [this message]
2021-04-06 6:23 ` [PATCH 09/11] block: simplify show_partition Christoph Hellwig
2021-04-06 6:23 ` [PATCH 10/11] block: simplify diskstats_show Christoph Hellwig
2021-04-06 6:23 ` [PATCH 11/11] block: remove disk_part_iter Christoph Hellwig
2021-04-08 16:24 ` partition iteration simplifications Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210406062303.811835-9-hch@lst.de \
--to=hch@lst.de \
--cc=axboe@kernel.dk \
--cc=hoeppner@linux.ibm.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=sth@linux.ibm.com \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).