diff options
author | Damien Le Moal <damien.lemoal@wdc.com> | 2018-10-12 06:08:48 -0400 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2018-10-25 13:17:40 -0400 |
commit | 965b652e901886ea54f93c60027b5be76328d958 (patch) | |
tree | 3fc654b827875179138aeeeadd68fd1ebb287771 | |
parent | a2d6b3a2d39005ab4d4a83481a7db092ebf0e9d6 (diff) |
block: Expose queue nr_zones in sysfs
Expose through sysfs the nr_zones field of struct request_queue.
Exposing this value helps in debugging disk issues as well as
facilitating scripts based use of the disk (e.g. blktests).
For zoned block devices, the nr_zones field indicates the total number
of zones of the device calculated using the known disk capacity and
zone size. This number of zones is always 0 for regular block devices.
Since nr_zones is defined conditionally with CONFIG_BLK_DEV_ZONED,
introduce the blk_queue_nr_zones() function to return the correct value
for any device, regardless if CONFIG_BLK_DEV_ZONED is set.
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r-- | block/blk-sysfs.c | 11 | ||||
-rw-r--r-- | include/linux/blkdev.h | 10 |
2 files changed, 21 insertions, 0 deletions
diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c index 3772671cf2bc..92be8092ca4f 100644 --- a/block/blk-sysfs.c +++ b/block/blk-sysfs.c | |||
@@ -300,6 +300,11 @@ static ssize_t queue_zoned_show(struct request_queue *q, char *page) | |||
300 | } | 300 | } |
301 | } | 301 | } |
302 | 302 | ||
303 | static ssize_t queue_nr_zones_show(struct request_queue *q, char *page) | ||
304 | { | ||
305 | return queue_var_show(blk_queue_nr_zones(q), page); | ||
306 | } | ||
307 | |||
303 | static ssize_t queue_nomerges_show(struct request_queue *q, char *page) | 308 | static ssize_t queue_nomerges_show(struct request_queue *q, char *page) |
304 | { | 309 | { |
305 | return queue_var_show((blk_queue_nomerges(q) << 1) | | 310 | return queue_var_show((blk_queue_nomerges(q) << 1) | |
@@ -637,6 +642,11 @@ static struct queue_sysfs_entry queue_zoned_entry = { | |||
637 | .show = queue_zoned_show, | 642 | .show = queue_zoned_show, |
638 | }; | 643 | }; |
639 | 644 | ||
645 | static struct queue_sysfs_entry queue_nr_zones_entry = { | ||
646 | .attr = {.name = "nr_zones", .mode = 0444 }, | ||
647 | .show = queue_nr_zones_show, | ||
648 | }; | ||
649 | |||
640 | static struct queue_sysfs_entry queue_nomerges_entry = { | 650 | static struct queue_sysfs_entry queue_nomerges_entry = { |
641 | .attr = {.name = "nomerges", .mode = 0644 }, | 651 | .attr = {.name = "nomerges", .mode = 0644 }, |
642 | .show = queue_nomerges_show, | 652 | .show = queue_nomerges_show, |
@@ -727,6 +737,7 @@ static struct attribute *default_attrs[] = { | |||
727 | &queue_write_zeroes_max_entry.attr, | 737 | &queue_write_zeroes_max_entry.attr, |
728 | &queue_nonrot_entry.attr, | 738 | &queue_nonrot_entry.attr, |
729 | &queue_zoned_entry.attr, | 739 | &queue_zoned_entry.attr, |
740 | &queue_nr_zones_entry.attr, | ||
730 | &queue_nomerges_entry.attr, | 741 | &queue_nomerges_entry.attr, |
731 | &queue_rq_affinity_entry.attr, | 742 | &queue_rq_affinity_entry.attr, |
732 | &queue_iostats_entry.attr, | 743 | &queue_iostats_entry.attr, |
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index ca5fdc1b7745..6bb845f9601a 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h | |||
@@ -811,6 +811,11 @@ static inline unsigned int blk_queue_zone_sectors(struct request_queue *q) | |||
811 | } | 811 | } |
812 | 812 | ||
813 | #ifdef CONFIG_BLK_DEV_ZONED | 813 | #ifdef CONFIG_BLK_DEV_ZONED |
814 | static inline unsigned int blk_queue_nr_zones(struct request_queue *q) | ||
815 | { | ||
816 | return blk_queue_is_zoned(q) ? q->nr_zones : 0; | ||
817 | } | ||
818 | |||
814 | static inline unsigned int blk_queue_zone_no(struct request_queue *q, | 819 | static inline unsigned int blk_queue_zone_no(struct request_queue *q, |
815 | sector_t sector) | 820 | sector_t sector) |
816 | { | 821 | { |
@@ -826,6 +831,11 @@ static inline bool blk_queue_zone_is_seq(struct request_queue *q, | |||
826 | return false; | 831 | return false; |
827 | return test_bit(blk_queue_zone_no(q, sector), q->seq_zones_bitmap); | 832 | return test_bit(blk_queue_zone_no(q, sector), q->seq_zones_bitmap); |
828 | } | 833 | } |
834 | #else /* CONFIG_BLK_DEV_ZONED */ | ||
835 | static inline unsigned int blk_queue_nr_zones(struct request_queue *q) | ||
836 | { | ||
837 | return 0; | ||
838 | } | ||
829 | #endif /* CONFIG_BLK_DEV_ZONED */ | 839 | #endif /* CONFIG_BLK_DEV_ZONED */ |
830 | 840 | ||
831 | static inline bool rq_is_sync(struct request *rq) | 841 | static inline bool rq_is_sync(struct request *rq) |