* [PATCH] nvmet: fix data_len to 0 for bdev-backed write_zeroes
@ 2019-06-02 3:43 Minwoo Im
2019-06-02 7:32 ` Sagi Grimberg
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Minwoo Im @ 2019-06-02 3:43 UTC (permalink / raw)
The WRITE ZEROES command has no data transfer so that we need to
initialize the struct (nvmet_req *req)->data_len to 0x0. While
(nvmet_req *req)->transfer_len is initialized in nvmet_req_init(),
data_len will be initialized by nowhere which might cause the failure
with status code NVME_SC_SGL_INVALID_DATA | NVME_SC_DNR randomly. It's
because nvmet_req_execute() checks like:
if (unlikely(req->data_len != req->transfer_len)) {
req->error_loc = offsetof(struct nvme_common_command, dptr);
nvmet_req_complete(req, NVME_SC_SGL_INVALID_DATA | NVME_SC_DNR);
} else
req->execute(req);
This patch fixes req->data_len not to be a randomly assigned by
initializing it to 0x0 when preparing the command in
nvmet_bdev_parse_io_cmd().
nvmet_file_parse_io_cmd() which is for file-backed I/O has already
initialized the data_len field to 0x0, though.
Cc: Christoph Hellwig <hch at lst.de>
Cc: Sagi Grimberg <sagi at grimberg.me>
Cc: Chaitanya Kulkarni <Chaitanya.Kulkarni at wdc.com>
Signed-off-by: Minwoo Im <minwoo.im.dev at gmail.com>
---
drivers/nvme/target/io-cmd-bdev.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/nvme/target/io-cmd-bdev.c b/drivers/nvme/target/io-cmd-bdev.c
index 3efc52f9c309..7a1cf6437a6a 100644
--- a/drivers/nvme/target/io-cmd-bdev.c
+++ b/drivers/nvme/target/io-cmd-bdev.c
@@ -293,6 +293,7 @@ u16 nvmet_bdev_parse_io_cmd(struct nvmet_req *req)
return 0;
case nvme_cmd_write_zeroes:
req->execute = nvmet_bdev_execute_write_zeroes;
+ req->data_len = 0;
return 0;
default:
pr_err("unhandled cmd %d on qid %d\n", cmd->common.opcode,
--
2.21.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH] nvmet: fix data_len to 0 for bdev-backed write_zeroes
2019-06-02 3:43 [PATCH] nvmet: fix data_len to 0 for bdev-backed write_zeroes Minwoo Im
@ 2019-06-02 7:32 ` Sagi Grimberg
2019-06-02 7:41 ` Minwoo Im
2019-06-02 22:57 ` Chaitanya Kulkarni
2019-06-04 7:24 ` Christoph Hellwig
2 siblings, 1 reply; 5+ messages in thread
From: Sagi Grimberg @ 2019-06-02 7:32 UTC (permalink / raw)
Is this a regression? IIRC write-zeros used to work...
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] nvmet: fix data_len to 0 for bdev-backed write_zeroes
2019-06-02 7:32 ` Sagi Grimberg
@ 2019-06-02 7:41 ` Minwoo Im
0 siblings, 0 replies; 5+ messages in thread
From: Minwoo Im @ 2019-06-02 7:41 UTC (permalink / raw)
On 19-06-02 00:32:43, Sagi Grimberg wrote:
> Is this a regression? IIRC write-zeros used to work...
Hi Sagi,
The following outputs are a looping basic tests with a single command:
(I think you can find the commands will easily be failed.)
root at target:~# nvme list-subsys
nvme-subsys0 - NQN=nqn.2014.08.org.nvmexpress:80861af4foo
QEMU NVMe Ctrl
\
+- nvme0 pcie 0000:00:04.0 live
nvme-subsys1 - NQN=test
\
+- nvme1 loop live
root at target:~# nvme write-zeroes /dev/nvme1n1
NVME Write Zeroes Success
root at target:~# nvme write-zeroes /dev/nvme1n1
NVME Write Zeroes Success
root at target:~# nvme write-zeroes /dev/nvme1n1
NVME Write Zeroes Success
root at target:~# nvme write-zeroes /dev/nvme1n1
NVMe status: Unknown(0x600f)
root at target:~# nvme write-zeroes /dev/nvme1n1
NVME Write Zeroes Success
root at target:~#
The write-zeroes command has been requested with SLBA 0 and NLB 0 as a
default options. This might happen with status code 0x600f which is
NVME_SC_SGL_INVALID_DATA | NVME_SC_DNR which happened due to:
req->data_len != req->transfer_len
The transfer_len is always 0x0 for write-zeroes, but data-len is never
initialized in this case.
Please correct me if I'm wrong here.
Thanks,
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] nvmet: fix data_len to 0 for bdev-backed write_zeroes
2019-06-02 3:43 [PATCH] nvmet: fix data_len to 0 for bdev-backed write_zeroes Minwoo Im
2019-06-02 7:32 ` Sagi Grimberg
@ 2019-06-02 22:57 ` Chaitanya Kulkarni
2019-06-04 7:24 ` Christoph Hellwig
2 siblings, 0 replies; 5+ messages in thread
From: Chaitanya Kulkarni @ 2019-06-02 22:57 UTC (permalink / raw)
Thanks for the fix.
Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni at wdc.com>
On 6/1/19 8:44 PM, Minwoo Im wrote:
> The WRITE ZEROES command has no data transfer so that we need to
> initialize the struct (nvmet_req *req)->data_len to 0x0. While
> (nvmet_req *req)->transfer_len is initialized in nvmet_req_init(),
> data_len will be initialized by nowhere which might cause the failure
> with status code NVME_SC_SGL_INVALID_DATA | NVME_SC_DNR randomly. It's
> because nvmet_req_execute() checks like:
>
> if (unlikely(req->data_len != req->transfer_len)) {
> req->error_loc = offsetof(struct nvme_common_command, dptr);
> nvmet_req_complete(req, NVME_SC_SGL_INVALID_DATA | NVME_SC_DNR);
> } else
> req->execute(req);
>
> This patch fixes req->data_len not to be a randomly assigned by
> initializing it to 0x0 when preparing the command in
> nvmet_bdev_parse_io_cmd().
>
> nvmet_file_parse_io_cmd() which is for file-backed I/O has already
> initialized the data_len field to 0x0, though.
>
> Cc: Christoph Hellwig <hch at lst.de>
> Cc: Sagi Grimberg <sagi at grimberg.me>
> Cc: Chaitanya Kulkarni <Chaitanya.Kulkarni at wdc.com>
> Signed-off-by: Minwoo Im <minwoo.im.dev at gmail.com>
> ---
> drivers/nvme/target/io-cmd-bdev.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/nvme/target/io-cmd-bdev.c b/drivers/nvme/target/io-cmd-bdev.c
> index 3efc52f9c309..7a1cf6437a6a 100644
> --- a/drivers/nvme/target/io-cmd-bdev.c
> +++ b/drivers/nvme/target/io-cmd-bdev.c
> @@ -293,6 +293,7 @@ u16 nvmet_bdev_parse_io_cmd(struct nvmet_req *req)
> return 0;
> case nvme_cmd_write_zeroes:
> req->execute = nvmet_bdev_execute_write_zeroes;
> + req->data_len = 0;
> return 0;
> default:
> pr_err("unhandled cmd %d on qid %d\n", cmd->common.opcode,
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] nvmet: fix data_len to 0 for bdev-backed write_zeroes
2019-06-02 3:43 [PATCH] nvmet: fix data_len to 0 for bdev-backed write_zeroes Minwoo Im
2019-06-02 7:32 ` Sagi Grimberg
2019-06-02 22:57 ` Chaitanya Kulkarni
@ 2019-06-04 7:24 ` Christoph Hellwig
2 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2019-06-04 7:24 UTC (permalink / raw)
Looks good,
Reviewed-by: Christoph Hellwig <hch at lst.de>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-06-04 7:24 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-06-02 3:43 [PATCH] nvmet: fix data_len to 0 for bdev-backed write_zeroes Minwoo Im
2019-06-02 7:32 ` Sagi Grimberg
2019-06-02 7:41 ` Minwoo Im
2019-06-02 22:57 ` Chaitanya Kulkarni
2019-06-04 7:24 ` Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).