Message ID | 20190711175328.16430-4-chaitanya.kulkarni@wdc.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | null_blk: add missing write-zeroes and discard support | expand |
On 19-07-11 10:53:23, Chaitanya Kulkarni wrote: > This patch adds support to execute REQ_OP_WRITE_ZEROES operations on > the null_blk device when device is not memory-backed. Just like > REQ_OP_DISCARD we add a new module parameter to enable this support. > > Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com> > --- > drivers/block/null_blk_main.c | 15 +++++++++++++++ > 1 file changed, 15 insertions(+) > > diff --git a/drivers/block/null_blk_main.c b/drivers/block/null_blk_main.c > index 20d60b951622..65da7c2d93b9 100644 > --- a/drivers/block/null_blk_main.c > +++ b/drivers/block/null_blk_main.c > @@ -198,6 +198,10 @@ static bool g_discard; > module_param_named(discard, g_discard, bool, 0444); > MODULE_PARM_DESC(discard, "Allow REQ_OP_DISCARD processing. Default: false"); > > +static bool g_write_zeroes; > +module_param_named(write_zeroes, g_write_zeroes, bool, 0444); > +MODULE_PARM_DESC(write_zeroes, "Allow REQ_OP_WRITE_ZEROES processing. 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); > @@ -535,7 +539,10 @@ static struct nullb_device *null_alloc_dev(void) > dev->zone_size = g_zone_size; > dev->zone_nr_conv = g_zone_nr_conv; > dev->discard = g_discard; > + dev->write_zeroes = g_write_zeroes; > pr_info("discard : %s\n", dev->discard ? "TRUE" : "FALSE"); > + pr_info("write-zeroes : %s\n", dev->write_zeroes ? "TRUE" : "FALSE"); > + > return dev; > } > > @@ -1419,6 +1426,13 @@ static void null_config_discard(struct nullb *nullb) > blk_queue_flag_set(QUEUE_FLAG_DISCARD, nullb->q); > } > > +static void null_config_write_zeroes(struct nullb *nullb) > +{ > + if (nullb->dev->write_zeroes == false) Can this trivial one for the style like the others in this module ? if (!nullb->dev->write_zeroes) Besides that it looks good to me :) Thanks!
diff --git a/drivers/block/null_blk_main.c b/drivers/block/null_blk_main.c index 20d60b951622..65da7c2d93b9 100644 --- a/drivers/block/null_blk_main.c +++ b/drivers/block/null_blk_main.c @@ -198,6 +198,10 @@ static bool g_discard; module_param_named(discard, g_discard, bool, 0444); MODULE_PARM_DESC(discard, "Allow REQ_OP_DISCARD processing. Default: false"); +static bool g_write_zeroes; +module_param_named(write_zeroes, g_write_zeroes, bool, 0444); +MODULE_PARM_DESC(write_zeroes, "Allow REQ_OP_WRITE_ZEROES processing. 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); @@ -535,7 +539,10 @@ static struct nullb_device *null_alloc_dev(void) dev->zone_size = g_zone_size; dev->zone_nr_conv = g_zone_nr_conv; dev->discard = g_discard; + dev->write_zeroes = g_write_zeroes; pr_info("discard : %s\n", dev->discard ? "TRUE" : "FALSE"); + pr_info("write-zeroes : %s\n", dev->write_zeroes ? "TRUE" : "FALSE"); + return dev; } @@ -1419,6 +1426,13 @@ static void null_config_discard(struct nullb *nullb) blk_queue_flag_set(QUEUE_FLAG_DISCARD, nullb->q); } +static void null_config_write_zeroes(struct nullb *nullb) +{ + if (nullb->dev->write_zeroes == false) + return; + blk_queue_max_write_zeroes_sectors(nullb->q, UINT_MAX >> SECTOR_SHIFT); +} + static int null_open(struct block_device *bdev, fmode_t mode) { return 0; @@ -1710,6 +1724,7 @@ static int null_add_dev(struct nullb_device *dev) blk_queue_physical_block_size(nullb->q, dev->blocksize); null_config_discard(nullb); + null_config_write_zeroes(nullb); sprintf(nullb->disk_name, "nullb%d", nullb->index);
This patch adds support to execute REQ_OP_WRITE_ZEROES operations on the null_blk device when device is not memory-backed. Just like REQ_OP_DISCARD we add a new module parameter to enable this support. Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com> --- drivers/block/null_blk_main.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)