* [PATCH v3] nvmet: avoid unnecessary flush bio
@ 2022-07-29 3:53 Guixin Liu
2022-08-01 8:54 ` Guixin Liu
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Guixin Liu @ 2022-07-29 3:53 UTC (permalink / raw)
To: hch, sagi, kch; +Cc: linux-nvme
For no volatile write cache block device backend, sending flush bio is
unnecessary, avoid to do that.
Signed-off-by: Guixin Liu <kanie@linux.alibaba.com>
---
Changes on v3:
- Remove file backend change.
Changes on v2:
- Use bdev_write_cache instead of open code.
- Use NVME_SC_SUCCESS instead of translation, and remove "else".
Test log:
- Add printk log at new if branch.
- Use nvme_loop to emulate nvme device.
- Use tcm_loop and tcmu to emulate no volatile write cache block backend
by setting emulate_write_cache=0.
- Send "nvme flush /dev/nvme0n1", there is a log print, and cmd return success.
- Send "nvme set-feature /dev/nvme0n1 --namespace-id=1 --feature-id=0x84 --value=1",
there is a log print, and cmd return success.
- Format nvme0n1 to ext4 filesystem, then create a file, write data and save, there
is a log print, and no error.
drivers/nvme/target/io-cmd-bdev.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/nvme/target/io-cmd-bdev.c b/drivers/nvme/target/io-cmd-bdev.c
index 2dc1c10..8d527a8 100644
--- a/drivers/nvme/target/io-cmd-bdev.c
+++ b/drivers/nvme/target/io-cmd-bdev.c
@@ -334,6 +334,11 @@ static void nvmet_bdev_execute_flush(struct nvmet_req *req)
{
struct bio *bio = &req->b.inline_bio;
+ if (!bdev_write_cache(req->ns->bdev)) {
+ nvmet_req_complete(req, NVME_SC_SUCCESS);
+ return;
+ }
+
if (!nvmet_check_transfer_len(req, 0))
return;
@@ -347,6 +352,9 @@ static void nvmet_bdev_execute_flush(struct nvmet_req *req)
u16 nvmet_bdev_flush(struct nvmet_req *req)
{
+ if (!bdev_write_cache(req->ns->bdev))
+ return 0;
+
if (blkdev_issue_flush(req->ns->bdev))
return NVME_SC_INTERNAL | NVME_SC_DNR;
return 0;
--
1.8.3.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH v3] nvmet: avoid unnecessary flush bio
2022-07-29 3:53 [PATCH v3] nvmet: avoid unnecessary flush bio Guixin Liu
@ 2022-08-01 8:54 ` Guixin Liu
2022-08-01 17:25 ` Christoph Hellwig
2022-08-04 6:46 ` Chaitanya Kulkarni
2022-09-05 11:02 ` Christoph Hellwig
2 siblings, 1 reply; 5+ messages in thread
From: Guixin Liu @ 2022-08-01 8:54 UTC (permalink / raw)
To: hch, sagi, kch; +Cc: linux-nvme
Hi,
Gentle ping.
thanks,
Guixin Liu
在 2022/7/29 11:53, Guixin Liu 写道:
> For no volatile write cache block device backend, sending flush bio is
> unnecessary, avoid to do that.
>
> Signed-off-by: Guixin Liu <kanie@linux.alibaba.com>
> ---
>
> Changes on v3:
> - Remove file backend change.
>
> Changes on v2:
> - Use bdev_write_cache instead of open code.
> - Use NVME_SC_SUCCESS instead of translation, and remove "else".
>
> Test log:
> - Add printk log at new if branch.
> - Use nvme_loop to emulate nvme device.
> - Use tcm_loop and tcmu to emulate no volatile write cache block backend
> by setting emulate_write_cache=0.
> - Send "nvme flush /dev/nvme0n1", there is a log print, and cmd return success.
> - Send "nvme set-feature /dev/nvme0n1 --namespace-id=1 --feature-id=0x84 --value=1",
> there is a log print, and cmd return success.
> - Format nvme0n1 to ext4 filesystem, then create a file, write data and save, there
> is a log print, and no error.
>
> drivers/nvme/target/io-cmd-bdev.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/drivers/nvme/target/io-cmd-bdev.c b/drivers/nvme/target/io-cmd-bdev.c
> index 2dc1c10..8d527a8 100644
> --- a/drivers/nvme/target/io-cmd-bdev.c
> +++ b/drivers/nvme/target/io-cmd-bdev.c
> @@ -334,6 +334,11 @@ static void nvmet_bdev_execute_flush(struct nvmet_req *req)
> {
> struct bio *bio = &req->b.inline_bio;
>
> + if (!bdev_write_cache(req->ns->bdev)) {
> + nvmet_req_complete(req, NVME_SC_SUCCESS);
> + return;
> + }
> +
> if (!nvmet_check_transfer_len(req, 0))
> return;
>
> @@ -347,6 +352,9 @@ static void nvmet_bdev_execute_flush(struct nvmet_req *req)
>
> u16 nvmet_bdev_flush(struct nvmet_req *req)
> {
> + if (!bdev_write_cache(req->ns->bdev))
> + return 0;
> +
> if (blkdev_issue_flush(req->ns->bdev))
> return NVME_SC_INTERNAL | NVME_SC_DNR;
> return 0;
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH v3] nvmet: avoid unnecessary flush bio
2022-07-29 3:53 [PATCH v3] nvmet: avoid unnecessary flush bio Guixin Liu
2022-08-01 8:54 ` Guixin Liu
@ 2022-08-04 6:46 ` Chaitanya Kulkarni
2022-09-05 11:02 ` Christoph Hellwig
2 siblings, 0 replies; 5+ messages in thread
From: Chaitanya Kulkarni @ 2022-08-04 6:46 UTC (permalink / raw)
To: Guixin Liu
Cc: linux-nvme@lists.infradead.org, hch@lst.de, Chaitanya Kulkarni,
sagi@grimberg.me
On 7/28/22 20:53, Guixin Liu wrote:
> For no volatile write cache block device backend, sending flush bio is
> unnecessary, avoid to do that.
>
> Signed-off-by: Guixin Liu <kanie@linux.alibaba.com>
> ---
>
> Changes on v3:
> - Remove file backend change.
>
> Changes on v2:
> - Use bdev_write_cache instead of open code.
> - Use NVME_SC_SUCCESS instead of translation, and remove "else".
>
> Test log:
> - Add printk log at new if branch.
> - Use nvme_loop to emulate nvme device.
> - Use tcm_loop and tcmu to emulate no volatile write cache block backend
> by setting emulate_write_cache=0.
> - Send "nvme flush /dev/nvme0n1", there is a log print, and cmd return success.
> - Send "nvme set-feature /dev/nvme0n1 --namespace-id=1 --feature-id=0x84 --value=1",
> there is a log print, and cmd return success.
> - Format nvme0n1 to ext4 filesystem, then create a file, write data and save, there
> is a log print, and no error.
>
> drivers/nvme/target/io-cmd-bdev.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
Thanks for the test report, looks good.
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
-ck
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v3] nvmet: avoid unnecessary flush bio
2022-07-29 3:53 [PATCH v3] nvmet: avoid unnecessary flush bio Guixin Liu
2022-08-01 8:54 ` Guixin Liu
2022-08-04 6:46 ` Chaitanya Kulkarni
@ 2022-09-05 11:02 ` Christoph Hellwig
2 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2022-09-05 11:02 UTC (permalink / raw)
To: Guixin Liu; +Cc: hch, sagi, kch, linux-nvme
Thanks,
applied to nvme-6.1.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-09-05 14:14 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-29 3:53 [PATCH v3] nvmet: avoid unnecessary flush bio Guixin Liu
2022-08-01 8:54 ` Guixin Liu
2022-08-01 17:25 ` Christoph Hellwig
2022-08-04 6:46 ` Chaitanya Kulkarni
2022-09-05 11:02 ` Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox