public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] null_blk: Add rotational feature support
@ 2024-11-26  0:09 Damien Le Moal
  2024-11-26  4:50 ` Christoph Hellwig
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Damien Le Moal @ 2024-11-26  0:09 UTC (permalink / raw)
  To: Jens Axboe, linux-block; +Cc: Christoph Hellwig, Keith Busch

To facilitate testing of kernel functions related to the rotational
feature (BLK_FEAT_ROTATIONAL) of a block device (e.g. NVMe rotational
bit support), add the rotational boolean configfs attribute and module
parameter to the null_blk driver. If set, a null block device will
report being a rotational device through it queue limits features with
the BLK_FEAT_ROTATIONAL flag.

Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
---
 drivers/block/null_blk/main.c     | 13 ++++++++++++-
 drivers/block/null_blk/null_blk.h |  1 +
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c
index 3c3d8d200abb..32bd232cceef 100644
--- a/drivers/block/null_blk/main.c
+++ b/drivers/block/null_blk/main.c
@@ -266,6 +266,10 @@ static bool g_zone_full;
 module_param_named(zone_full, g_zone_full, bool, S_IRUGO);
 MODULE_PARM_DESC(zone_full, "Initialize the sequential write required zones of a zoned device to be full. Default: false");
 
+static bool g_rotational;
+module_param_named(rotational, g_rotational, bool, S_IRUGO);
+MODULE_PARM_DESC(rotational, "Set the rotational feature for the device. Default: false");
+
 static struct nullb_device *null_alloc_dev(void);
 static void null_free_dev(struct nullb_device *dev);
 static void null_del_dev(struct nullb *nullb);
@@ -468,6 +472,7 @@ NULLB_DEVICE_ATTR(no_sched, bool, NULL);
 NULLB_DEVICE_ATTR(shared_tags, bool, NULL);
 NULLB_DEVICE_ATTR(shared_tag_bitmap, bool, NULL);
 NULLB_DEVICE_ATTR(fua, bool, NULL);
+NULLB_DEVICE_ATTR(rotational, bool, NULL);
 
 static ssize_t nullb_device_power_show(struct config_item *item, char *page)
 {
@@ -621,6 +626,7 @@ static struct configfs_attribute *nullb_device_attrs[] = {
 	&nullb_device_attr_shared_tags,
 	&nullb_device_attr_shared_tag_bitmap,
 	&nullb_device_attr_fua,
+	&nullb_device_attr_rotational,
 	NULL,
 };
 
@@ -706,7 +712,8 @@ static ssize_t memb_group_features_show(struct config_item *item, char *page)
 			"shared_tags,size,submit_queues,use_per_node_hctx,"
 			"virt_boundary,zoned,zone_capacity,zone_max_active,"
 			"zone_max_open,zone_nr_conv,zone_offline,zone_readonly,"
-			"zone_size,zone_append_max_sectors,zone_full\n");
+			"zone_size,zone_append_max_sectors,zone_full,"
+			"rotational\n");
 }
 
 CONFIGFS_ATTR_RO(memb_group_, features);
@@ -793,6 +800,7 @@ static struct nullb_device *null_alloc_dev(void)
 	dev->shared_tags = g_shared_tags;
 	dev->shared_tag_bitmap = g_shared_tag_bitmap;
 	dev->fua = g_fua;
+	dev->rotational = g_rotational;
 
 	return dev;
 }
@@ -1938,6 +1946,9 @@ static int null_add_dev(struct nullb_device *dev)
 			lim.features |= BLK_FEAT_FUA;
 	}
 
+	if (dev->rotational)
+		lim.features |= BLK_FEAT_ROTATIONAL;
+
 	nullb->disk = blk_mq_alloc_disk(nullb->tag_set, &lim, nullb);
 	if (IS_ERR(nullb->disk)) {
 		rv = PTR_ERR(nullb->disk);
diff --git a/drivers/block/null_blk/null_blk.h b/drivers/block/null_blk/null_blk.h
index a7bb32f73ec3..6f9fe6171087 100644
--- a/drivers/block/null_blk/null_blk.h
+++ b/drivers/block/null_blk/null_blk.h
@@ -107,6 +107,7 @@ struct nullb_device {
 	bool shared_tags; /* share tag set between devices for blk-mq */
 	bool shared_tag_bitmap; /* use hostwide shared tags */
 	bool fua; /* Support FUA */
+	bool rotational; /* Fake rotational device */
 };
 
 struct nullb {
-- 
2.47.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] null_blk: Add rotational feature support
  2024-11-26  0:09 [PATCH] null_blk: Add rotational feature support Damien Le Moal
@ 2024-11-26  4:50 ` Christoph Hellwig
  2024-11-26 10:57 ` Johannes Thumshirn
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2024-11-26  4:50 UTC (permalink / raw)
  To: Damien Le Moal; +Cc: Jens Axboe, linux-block, Christoph Hellwig, Keith Busch

On Tue, Nov 26, 2024 at 09:09:56AM +0900, Damien Le Moal wrote:
> To facilitate testing of kernel functions related to the rotational
> feature (BLK_FEAT_ROTATIONAL) of a block device (e.g. NVMe rotational
> bit support), add the rotational boolean configfs attribute and module
> parameter to the null_blk driver. If set, a null block device will
> report being a rotational device through it queue limits features with
> the BLK_FEAT_ROTATIONAL flag.

Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] null_blk: Add rotational feature support
  2024-11-26  0:09 [PATCH] null_blk: Add rotational feature support Damien Le Moal
  2024-11-26  4:50 ` Christoph Hellwig
@ 2024-11-26 10:57 ` Johannes Thumshirn
  2024-11-26 12:42 ` Hannes Reinecke
  2024-11-29 16:04 ` Jens Axboe
  3 siblings, 0 replies; 5+ messages in thread
From: Johannes Thumshirn @ 2024-11-26 10:57 UTC (permalink / raw)
  To: Damien Le Moal, Jens Axboe, linux-block@vger.kernel.org; +Cc: hch, Keith Busch

Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] null_blk: Add rotational feature support
  2024-11-26  0:09 [PATCH] null_blk: Add rotational feature support Damien Le Moal
  2024-11-26  4:50 ` Christoph Hellwig
  2024-11-26 10:57 ` Johannes Thumshirn
@ 2024-11-26 12:42 ` Hannes Reinecke
  2024-11-29 16:04 ` Jens Axboe
  3 siblings, 0 replies; 5+ messages in thread
From: Hannes Reinecke @ 2024-11-26 12:42 UTC (permalink / raw)
  To: Damien Le Moal, Jens Axboe, linux-block; +Cc: Christoph Hellwig, Keith Busch

On 11/26/24 01:09, Damien Le Moal wrote:
> To facilitate testing of kernel functions related to the rotational
> feature (BLK_FEAT_ROTATIONAL) of a block device (e.g. NVMe rotational
> bit support), add the rotational boolean configfs attribute and module
> parameter to the null_blk driver. If set, a null block device will
> report being a rotational device through it queue limits features with
> the BLK_FEAT_ROTATIONAL flag.
> 
> Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
> ---
>   drivers/block/null_blk/main.c     | 13 ++++++++++++-
>   drivers/block/null_blk/null_blk.h |  1 +
>   2 files changed, 13 insertions(+), 1 deletion(-)
> 
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke                  Kernel Storage Architect
hare@suse.de                                +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] null_blk: Add rotational feature support
  2024-11-26  0:09 [PATCH] null_blk: Add rotational feature support Damien Le Moal
                   ` (2 preceding siblings ...)
  2024-11-26 12:42 ` Hannes Reinecke
@ 2024-11-29 16:04 ` Jens Axboe
  3 siblings, 0 replies; 5+ messages in thread
From: Jens Axboe @ 2024-11-29 16:04 UTC (permalink / raw)
  To: linux-block, Damien Le Moal; +Cc: Christoph Hellwig, Keith Busch


On Tue, 26 Nov 2024 09:09:56 +0900, Damien Le Moal wrote:
> To facilitate testing of kernel functions related to the rotational
> feature (BLK_FEAT_ROTATIONAL) of a block device (e.g. NVMe rotational
> bit support), add the rotational boolean configfs attribute and module
> parameter to the null_blk driver. If set, a null block device will
> report being a rotational device through it queue limits features with
> the BLK_FEAT_ROTATIONAL flag.
> 
> [...]

Applied, thanks!

[1/1] null_blk: Add rotational feature support
      commit: 1c42dabc051ee9b55db21bf66959c7884f3a243e

Best regards,
-- 
Jens Axboe




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-11-29 16:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-26  0:09 [PATCH] null_blk: Add rotational feature support Damien Le Moal
2024-11-26  4:50 ` Christoph Hellwig
2024-11-26 10:57 ` Johannes Thumshirn
2024-11-26 12:42 ` Hannes Reinecke
2024-11-29 16:04 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox