diff mbox series

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

Message ID 20181010015239.24930-10-damien.lemoal@wdc.com (mailing list archive)
State Not Applicable
Headers show
Series Zoned block device support improvements | expand

Commit Message

Damien Le Moal Oct. 10, 2018, 1:52 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 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Christoph Hellwig Oct. 10, 2018, 1:28 p.m. UTC | #1
On Wed, Oct 10, 2018 at 10:52:37AM +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).

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>
kernel test robot Oct. 10, 2018, 2:05 p.m. UTC | #2
Hi Damien,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on block/for-next]
[also build test ERROR on v4.19-rc7 next-20181010]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Damien-Le-Moal/Zoned-block-device-support-improvements/20181010-190504
base:   https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git for-next
config: x86_64-randconfig-x000-201840 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All error/warnings (new ones prefixed by >>):

   block/blk-sysfs.c: In function 'queue_nr_zones_show':
>> block/blk-sysfs.c:305:27: error: 'struct request_queue' has no member named 'nr_zones'; did you mean 'nr_rqs'?
     return queue_var_show(q->nr_zones, page);
                              ^~~~~~~~
                              nr_rqs
>> block/blk-sysfs.c:306:1: warning: control reaches end of non-void function [-Wreturn-type]
    }
    ^

vim +305 block/blk-sysfs.c

   302	
   303	static ssize_t queue_nr_zones_show(struct request_queue *q, char *page)
   304	{
 > 305		return queue_var_show(q->nr_zones, page);
 > 306	}
   307	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
kernel test robot Oct. 10, 2018, 6:44 p.m. UTC | #3
Hi Damien,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on block/for-next]
[also build test ERROR on v4.19-rc7 next-20181010]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Damien-Le-Moal/Zoned-block-device-support-improvements/20181010-190504
base:   https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git for-next
config: i386-randconfig-x0-10102333 (attached as .config)
compiler: gcc-5 (Debian 5.5.0-3) 5.4.1 20171010
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All errors (new ones prefixed by >>):

   block/blk-sysfs.c: In function 'queue_nr_zones_show':
>> block/blk-sysfs.c:305:25: error: 'struct request_queue' has no member named 'nr_zones'
     return queue_var_show(q->nr_zones, page);
                            ^
   block/blk-sysfs.c:306:1: warning: control reaches end of non-void function [-Wreturn-type]
    }
    ^

vim +305 block/blk-sysfs.c

   302	
   303	static ssize_t queue_nr_zones_show(struct request_queue *q, char *page)
   304	{
 > 305		return queue_var_show(q->nr_zones, page);
   306	}
   307	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
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,