Re: [PATCH 1/6] null_blk: allow write zeores on non-membacked

From: Chaitanya Kulkarni
Date: Wed Oct 05 2022 - 01:24:28 EST


On 10/4/22 21:54, Damien Le Moal wrote:
> On 10/5/22 12:16, Chaitanya Kulkarni wrote:
>> Add a helper function to enable the REQ_OP_WRITE_ZEROES operations
>> when null_blk is configured with the non-membacked operations.
>>
>> Since write-zeroes is a non-trivial I/O operation we need this to
>> add a blktest so we can test the non-trivial I/O path from the
>> application to the block layer.
>>
>> Signed-off-by: Chaitanya Kulkarni <kch@xxxxxxxxxx>
>> ---
>> drivers/block/null_blk/main.c | 13 +++++++++++++
>> drivers/block/null_blk/null_blk.h | 1 +
>> 2 files changed, 14 insertions(+)
>>
>> diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c
>> index 1f154f92f4c2..fc3e883f7b84 100644
>> --- a/drivers/block/null_blk/main.c
>> +++ b/drivers/block/null_blk/main.c
>> @@ -209,6 +209,10 @@ static bool g_discard;
>> module_param_named(discard, g_discard, bool, 0444);
>> MODULE_PARM_DESC(discard, "Support discard operations (requires memory-backed null_blk device). Default: false");
>>
>> +static bool g_write_zeroes;
>> +module_param_named(write_zeroes, g_write_zeroes, bool, 0444);
>> +MODULE_PARM_DESC(write_zeroes, "Support write-zeores operations. Default: false");
>
> Why not make this a number of sectors representing the maximum size of a
> write zero command (blk_queue_max_write_zeroes_sectors()) ? That would
> allow exercising split write zeros BIOs.
>

I kept the implementation identical to the g_discard.

Perhaps it's time to change it so REQ_OP_DISCARD and
REQ_OP_WRITE_ZEROES will have same implementation.

I'll add a discard patch to match your suggested write-zeroes
behavior.

-ck