diff mbox series

[v2,09/11] block: Expose queue nr_zones in sysfs

Message ID 20181011070952.13248-10-damien.lemoal@wdc.com (mailing list archive)
State New, archived
Headers show
Series Zoned block device support improvements | expand

Commit Message

Damien Le Moal Oct. 11, 2018, 7:09 a.m. UTC
Expose through sysfs the nr_zones field of a zoned block device request
queue. This represents the total number of zones of the device
calculated using the known disk capacity and zone size.

Exposing this value helps in debugging disk issues as well as
facilitating scripts based use of the disk (e.g. blktests).

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
---
 block/blk-sysfs.c      | 11 +++++++++++
 include/linux/blkdev.h |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)

Comments

Ewan Milne Oct. 11, 2018, 2:42 p.m. UTC | #1
So in v2 you moved the #ifdef CONFIG_BLK_DEV_ZONED
so that nr_zones is always present?  It was previously
changed to keep the request_queue size smaller.

Would make more sense to make the nr_zones sysfs
code here conditional on CONFIG_BLK_DEV_ZONED?

-Ewan


On Thu, 2018-10-11 at 16:09 +0900, Damien Le Moal wrote:
> Expose through sysfs the nr_zones field of a zoned block device request
> queue. This represents the total number of zones of the device
> calculated using the known disk capacity and zone size.
> 
> Exposing this value helps in debugging disk issues as well as
> facilitating scripts based use of the disk (e.g. blktests).
> 
> Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
> ---
>  block/blk-sysfs.c      | 11 +++++++++++
>  include/linux/blkdev.h |  2 +-
>  2 files changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
> index 3772671cf2bc..f7060a938bf9 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)
>  	}
>  }
>  
> +static ssize_t queue_nr_zones_show(struct request_queue *q, char *page)
> +{
> +	return queue_var_show(q->nr_zones, page);
> +}
> +
>  static ssize_t queue_nomerges_show(struct request_queue *q, char *page)
>  {
>  	return queue_var_show((blk_queue_nomerges(q) << 1) |
> @@ -637,6 +642,11 @@ static struct queue_sysfs_entry queue_zoned_entry = {
>  	.show = queue_zoned_show,
>  };
>  
> +static struct queue_sysfs_entry queue_nr_zones_entry = {
> +	.attr = {.name = "nr_zones", .mode = 0444 },
> +	.show = queue_nr_zones_show,
> +};
> +
>  static struct queue_sysfs_entry queue_nomerges_entry = {
>  	.attr = {.name = "nomerges", .mode = 0644 },
>  	.show = queue_nomerges_show,
> @@ -727,6 +737,7 @@ static struct attribute *default_attrs[] = {
>  	&queue_write_zeroes_max_entry.attr,
>  	&queue_nonrot_entry.attr,
>  	&queue_zoned_entry.attr,
> +	&queue_nr_zones_entry.attr,
>  	&queue_nomerges_entry.attr,
>  	&queue_rq_affinity_entry.attr,
>  	&queue_iostats_entry.attr,
> diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
> index c24969b1741b..23ab53d2d4ca 100644
> --- a/include/linux/blkdev.h
> +++ b/include/linux/blkdev.h
> @@ -593,7 +593,6 @@ struct request_queue {
>  
>  	struct queue_limits	limits;
>  
> -#ifdef CONFIG_BLK_DEV_ZONED
>  	/*
>  	 * Zoned block device information for request dispatch control.
>  	 * nr_zones is the total number of zones of the device. This is always
> @@ -612,6 +611,7 @@ struct request_queue {
>  	 * blk_mq_unfreeze_queue().
>  	 */
>  	unsigned int		nr_zones;
> +#ifdef CONFIG_BLK_DEV_ZONED
>  	unsigned long		*seq_zones_bitmap;
>  	unsigned long		*seq_zones_wlock;
>  #endif /* CONFIG_BLK_DEV_ZONED */
Damien Le Moal Oct. 12, 2018, 12:41 a.m. UTC | #2
On 2018/10/11 23:42, Ewan D. Milne wrote:
> So in v2 you moved the #ifdef CONFIG_BLK_DEV_ZONED
> so that nr_zones is always present?  It was previously
> changed to keep the request_queue size smaller.
> 
> Would make more sense to make the nr_zones sysfs
> code here conditional on CONFIG_BLK_DEV_ZONED?
> 

Yes, I guess it would. #ifdef in c code is normally not welcome, so I was a
little heavy handed with this v2 change to avoid adding any to blk-sysfs.c :)

I will rework this and send a v3.

Thanks for the review.
diff mbox series

Patch

diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index 3772671cf2bc..f7060a938bf9 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)
 	}
 }
 
+static ssize_t queue_nr_zones_show(struct request_queue *q, char *page)
+{
+	return queue_var_show(q->nr_zones, page);
+}
+
 static ssize_t queue_nomerges_show(struct request_queue *q, char *page)
 {
 	return queue_var_show((blk_queue_nomerges(q) << 1) |
@@ -637,6 +642,11 @@  static struct queue_sysfs_entry queue_zoned_entry = {
 	.show = queue_zoned_show,
 };
 
+static struct queue_sysfs_entry queue_nr_zones_entry = {
+	.attr = {.name = "nr_zones", .mode = 0444 },
+	.show = queue_nr_zones_show,
+};
+
 static struct queue_sysfs_entry queue_nomerges_entry = {
 	.attr = {.name = "nomerges", .mode = 0644 },
 	.show = queue_nomerges_show,
@@ -727,6 +737,7 @@  static struct attribute *default_attrs[] = {
 	&queue_write_zeroes_max_entry.attr,
 	&queue_nonrot_entry.attr,
 	&queue_zoned_entry.attr,
+	&queue_nr_zones_entry.attr,
 	&queue_nomerges_entry.attr,
 	&queue_rq_affinity_entry.attr,
 	&queue_iostats_entry.attr,
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index c24969b1741b..23ab53d2d4ca 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -593,7 +593,6 @@  struct request_queue {
 
 	struct queue_limits	limits;
 
-#ifdef CONFIG_BLK_DEV_ZONED
 	/*
 	 * Zoned block device information for request dispatch control.
 	 * nr_zones is the total number of zones of the device. This is always
@@ -612,6 +611,7 @@  struct request_queue {
 	 * blk_mq_unfreeze_queue().
 	 */
 	unsigned int		nr_zones;
+#ifdef CONFIG_BLK_DEV_ZONED
 	unsigned long		*seq_zones_bitmap;
 	unsigned long		*seq_zones_wlock;
 #endif /* CONFIG_BLK_DEV_ZONED */