From: Damien Le Moal <damien.lemoal@opensource.wdc.com>
To: Chaitanya Kulkarni <kch@nvidia.com>,
linux-block@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: axboe@kernel.dk, johannes.thumshirn@wdc.com, bvanassche@acm.org,
ming.lei@redhat.com, shinichiro.kawasaki@wdc.com,
vincent.fu@samsung.com, yukuai3@huawei.com
Subject: Re: [PATCH 1/6] null_blk: allow write zeores on non-membacked
Date: Wed, 5 Oct 2022 13:54:44 +0900 [thread overview]
Message-ID: <66698df8-74ca-e802-2250-04aecafa1106@opensource.wdc.com> (raw)
In-Reply-To: <20221005031701.79077-2-kch@nvidia.com>
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@nvidia.com>
> ---
> 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.
> +
> static unsigned long g_cache_size;
> module_param_named(cache_size, g_cache_size, ulong, 0444);
> MODULE_PARM_DESC(mbps, "Cache size in MiB for memory-backed device. Default: 0 (none)");
> @@ -678,6 +682,7 @@ static struct nullb_device *null_alloc_dev(void)
> dev->blocking = g_blocking;
> dev->memory_backed = g_memory_backed;
> dev->discard = g_discard;
> + dev->write_zeroes = g_write_zeroes;
> dev->cache_size = g_cache_size;
> dev->mbps = g_mbps;
> dev->use_per_node_hctx = g_use_per_node_hctx;
> @@ -1800,6 +1805,13 @@ static void null_config_discard(struct nullb *nullb)
> blk_queue_max_discard_sectors(nullb->q, UINT_MAX >> 9);
> }
>
> +static void null_config_write_zeroes(struct nullb *nullb)
> +{
> + if (!nullb->dev->write_zeroes)
> + return;
> + blk_queue_max_write_zeroes_sectors(nullb->q, UINT_MAX >> 9);
> +}
> +
> static const struct block_device_operations null_bio_ops = {
> .owner = THIS_MODULE,
> .submit_bio = null_submit_bio,
> @@ -2111,6 +2123,7 @@ static int null_add_dev(struct nullb_device *dev)
> blk_queue_virt_boundary(nullb->q, PAGE_SIZE - 1);
>
> null_config_discard(nullb);
> + null_config_write_zeroes(nullb);
>
> if (config_item_name(&dev->item)) {
> /* Use configfs dir name as the device name */
> diff --git a/drivers/block/null_blk/null_blk.h b/drivers/block/null_blk/null_blk.h
> index 94ff68052b1e..2c0c9c29158f 100644
> --- a/drivers/block/null_blk/null_blk.h
> +++ b/drivers/block/null_blk/null_blk.h
> @@ -111,6 +111,7 @@ struct nullb_device {
> bool power; /* power on/off the device */
> bool memory_backed; /* if data is stored in memory */
> bool discard; /* if support discard */
> + bool write_zeroes; /* if support write_zeroes */
> bool zoned; /* if device is zoned */
> bool virt_boundary; /* virtual boundary on/off for the device */
> bool no_sched; /* no IO scheduler for the device */
--
Damien Le Moal
Western Digital Research
next prev parent reply other threads:[~2022-10-05 4:55 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-05 3:16 [PATCH 0/6] null_blk: allow REQ_OP_WRITE_ZEROES and cleanup Chaitanya Kulkarni
2022-10-05 3:16 ` [PATCH 1/6] null_blk: allow write zeores on non-membacked Chaitanya Kulkarni
2022-10-05 4:54 ` Damien Le Moal [this message]
2022-10-05 5:24 ` Chaitanya Kulkarni
2022-10-05 18:33 ` Chaitanya Kulkarni
2022-10-05 3:16 ` [PATCH 2/6] null_blk: allow write zeores on membacked Chaitanya Kulkarni
2022-10-05 4:57 ` Damien Le Moal
2022-10-05 5:10 ` Chaitanya Kulkarni
2022-10-05 17:18 ` Brian Foster
2022-10-05 3:16 ` [PATCH 3/6] null_blk: code cleaup Chaitanya Kulkarni
2022-10-05 5:02 ` Damien Le Moal
2022-10-05 5:21 ` Chaitanya Kulkarni
2022-10-05 3:16 ` [PATCH 4/6] null_blk: initialize cmd->bio in __alloc_cmd() Chaitanya Kulkarni
2022-10-05 5:04 ` Damien Le Moal
2022-10-05 3:17 ` [PATCH 5/6] null_blk: don't use magic numbers in the code Chaitanya Kulkarni
2022-10-05 5:05 ` Damien Le Moal
2022-10-05 3:17 ` [PATCH 6/6] null_blk: remove extra space in switch condition Chaitanya Kulkarni
2022-10-05 5:06 ` Damien Le Moal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=66698df8-74ca-e802-2250-04aecafa1106@opensource.wdc.com \
--to=damien.lemoal@opensource.wdc.com \
--cc=axboe@kernel.dk \
--cc=bvanassche@acm.org \
--cc=johannes.thumshirn@wdc.com \
--cc=kch@nvidia.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ming.lei@redhat.com \
--cc=shinichiro.kawasaki@wdc.com \
--cc=vincent.fu@samsung.com \
--cc=yukuai3@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox