Skip to contentSkip to conversation

null_blk: add zoned config support information

PATCH Superseded John Pittman 4 participants 8 messages Jan 4, 2019 – Jan 6, 2019

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 null_blk: add zoned config support information

If the kernel is built without CONFIG_BLK_DEV_ZONED, a modprobe of the null_blk driver with zoned=1 fails with 'Invalid argument'. This can be confusing to users, prompting a search as to why the parameter is invalid. To assist in that search, add a bit more information to the failure, additionally adding to the documentation that CONFIG_BLK_DEV_ZONED is needed for zoned=1.

---
 Documentation/block/null_blk.txt | 3 ++-
 drivers/block/null_blk.h         | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)
Documentation/block/null_blk.txt +2 -1
index ea2dafe49ae8..4cad1024fff7 100644
@@ -88,7 +88,8 @@ shared_tags=[0/1]: Default: 0
 
 zoned=[0/1]: Default: 0
   0: Block device is exposed as a random-access block device.
-  1: Block device is exposed as a host-managed zoned block device.
+  1: Block device is exposed as a host-managed zoned block device. Requires
+     CONFIG_BLK_DEV_ZONED.
 
 zone_size=[MB]: Default: 256
   Per zone size when exposed as a zoned block device. Must be a power of two.
drivers/block/null_blk.h +1 -0
index b3df2793e7cd..cab4808f14bd 100644
@@ -97,6 +97,7 @@ void null_zone_reset(struct nullb_cmd *cmd, sector_t sector);
 #else
 static inline int null_zone_init(struct nullb_device *dev)
 {
+	pr_info("CONFIG_BLK_DEV_ZONED not enabled\n");
 	return -EINVAL;
 }
 static inline void null_zone_exit(struct nullb_device *dev) {}
Signature · 1 line
2.17.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 42 lines · John Pittman

If the kernel is built without CONFIG_BLK_DEV_ZONED, a modprobe of the null_blk driver with zoned=1 fails with 'Invalid argument'. This can be confusing to users, prompting a search as to why the parameter is invalid. To assist in that search, add a bit more information to the failure, additionally adding to the documentation that CONFIG_BLK_DEV_ZONED is needed for zoned=1.

---
 Documentation/block/null_blk.txt | 3 ++-
 drivers/block/null_blk.h         | 1 +

 2 files changed, 3 insertions(+), 1 deletion(-)
Documentation/block/null_blk.txt +0 -0
index ea2dafe49ae8..4cad1024fff7 100644
@@ -88,7 +88,8 @@ shared_tags=[0/1]: Default: 0


 zoned=[0/1]: Default: 0
   0: Block device is exposed as a random-access block device. -  1: Block device is exposed as a host-managed zoned block device. +  1: Block device is exposed as a host-managed zoned block device. Requires
+     CONFIG_BLK_DEV_ZONED.

 zone_size=[MB]: Default: 256
   Per zone size when exposed as a zoned block device. Must be a power of two.

drivers/block/null_blk.h +1 -0
index b3df2793e7cd..cab4808f14bd 100644
@@ -97,6 +97,7 @@ void null_zone_reset(struct nullb_cmd *cmd,
 sector_t sector);
  #else
  static inline int null_zone_init(struct nullb_device *dev)
  {
+	pr_info("CONFIG_BLK_DEV_ZONED not enabled\n");
  	return -EINVAL;
  }
Quoted 1 line

 static inline void null_zone_exit(struct nullb_device *dev) {}

Looks good to me, useful change in my opinion.

#2 lore raw
In reply to John Pittman
Quoted 2 lines · John Pittman

static inline int null_zone_init(struct nullb_device *dev)
{>+- pr_info("CONFIG_BLK_DEV_ZONED not enabled\n";> return -EINVAL;> }

Have you considered to use pr_err() instead of pr_info()?

Thanks,

Bart.

#3 lore raw
Quoted 9 lines · Bart Van Assche
Quoted 5 lines · John Pittman

 static inline int null_zone_init(struct nullb_device *dev) {

drivers/block/null_blk.h +1 -0
+	pr_info("CONFIG_BLK_DEV_ZONED not enabled\n");

  return -EINVAL;
 }

Have you considered to use pr_err() instead of pr_info()?

Quoted 3 lines

Thanks,

Bart.

Bart, good point, Thank you
Laurence

#4 lore raw
In reply to Bart Van Assche

Thanks Bart; I made the changes and sent them in as a v2, I'm sure you already saw. I have a quick, unrelated question if you have a moment. In testing the null_blk driver, I found that trim commands sent by fio were rejected due to lack of support. Tracking down Shaohua's commit 306eb6b4a ("nullb: support discard"), he mentions that "discard makes sense for memory backed disk". Just to see what would happen, I edited the source to make discard a configurable parameter at modprobe, and after the edit & build, the trim commands submitted fine. Does this sort of change make sense? I mean the ability to do discard to null_blk without it being memory backed; solely for testing/benchmarking purposes. I haven't found any good instructions on creating a memory backed or discard enabled null_blk device from the command line, so I assume a higher level driver would have to hook in and enable these features manually. Thanks for your time and any information.
John

Quoted 13 lines · Bart Van Assche
Quoted 5 lines · John Pittman

static inline int null_zone_init(struct nullb_device *dev) {

+     pr_info("CONFIG_BLK_DEV_ZONED not enabled\n");
      return -EINVAL;

}

Have you considered to use pr_err() instead of pr_info()?

Thanks,

Bart.

#5 lore raw
Quoted 7 lines · John Pittman

Thanks Bart;I made the changes and sent them in as a v2, I'm sure you already saw. I have a quick, unrelated question if you have a moment. In testing the null_blk driver, I found that trim commands sent by fio were rejected due to lack of support. Tracking down Shaohua's commit 306eb6b4a ("nullb: support discard", he mentions that "discard makes sense for memory backed disk" Just to see what would happen, I edited the source to make discard a configurable parameter at

Quoted 8 lines

modprobe, and after the edit &build, the trim commands submitted fine. Does this sort of change make sense? I mean the ability to do discard to null_blk without it being memory backed; solely for testing/benchmarking purposes. I haven't found any good instructions on creating a memory backed or discard enabled null_blk device from the command line, so I assume a higher level driver would have to hook in and enable these features manually. Thanks for your time and any information.

Hi John,

Jens as the block layer maintainer has the last word about this. Personally I would welcome that functionality. Before discard functionality was removed from the brd driver I used the brd driver to test the discard functionality in storage target stacks. If discard functionality would be added to the null_blk driver then that would make it possible to use that driver for testing the discard functionality in e.g. LIO. See also commit f09a06a193d9 ("brd: remove discard support".

I'm not sure that we need a modprobe parameter to enable or disable trim functionality in the null_blk driver. I'm fine with always enabling trim functionality in that driver.

Bart.

#6 lore raw

Thanks Bart, I appreciate it.

Quoted 33 lines · Bart Van Assche
Quoted 7 lines · John Pittman

Thanks Bart; I made the changes and sent them in as a v2, I'm sure you already saw. I have a quick, unrelated question if you have a moment. In testing the null_blk driver, I found that trim commands sent by fio were rejected due to lack of support. Tracking down Shaohua's commit 306eb6b4a ("nullb: support discard"), he mentions that "discard makes sense for memory backed disk". Just to see what would happen, I edited the source to make discard a configurable parameter at

Quoted 8 lines

modprobe, and after the edit & build, the trim commands submitted fine. Does this sort of change make sense? I mean the ability to do discard to null_blk without it being memory backed; solely for testing/benchmarking purposes. I haven't found any good instructions on creating a memory backed or discard enabled null_blk device from the command line, so I assume a higher level driver would have to hook in and enable these features manually. Thanks for your time and any information.

Hi John,

Jens as the block layer maintainer has the last word about this. Personally I would welcome that functionality. Before discard functionality was removed from the brd driver I used the brd driver to test the discard functionality in storage target stacks. If discard functionality would be added to the null_blk driver then that would make it possible to use that driver for testing the discard functionality in e.g. LIO. See also commit f09a06a193d9 ("brd: remove discard support").

I'm not sure that we need a modprobe parameter to enable or disable trim functionality in the null_blk driver. I'm fine with always enabling trim functionality in that driver.

Bart.

maintainer
#7 lore raw
In reply to John Pittman
Quoted 7 lines · John Pittman

Thanks Bart; I made the changes and sent them in as a v2, I'm sure you already saw. I have a quick, unrelated question if you have a moment. In testing the null_blk driver, I found that trim commands sent by fio were rejected due to lack of support. Tracking down Shaohua's commit 306eb6b4a ("nullb: support discard"), he mentions that "discard makes sense for memory backed disk". Just to see what would happen, I edited the source to make discard a configurable parameter at

Quoted 8 lines

modprobe, and after the edit & build, the trim commands submitted fine. Does this sort of change make sense? I mean the ability to do discard to null_blk without it being memory backed; solely for testing/benchmarking purposes. I haven't found any good instructions on creating a memory backed or discard enabled null_blk device from the command line, so I assume a higher level driver would have to hook in and enable these features manually. Thanks for your time and any information.

I think that would be fine, no option needed. It's really no different than reads/writes being completed without having a memory backing.

Signature · 1 line
Jens Axboe