All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nvme: fix write zeroes offset and count
@ 2019-03-11 15:11 ` Keith Busch
  0 siblings, 0 replies; 4+ messages in thread
From: Keith Busch @ 2019-03-11 15:11 UTC (permalink / raw)


The implementation used blocks units rather than the expected bytes.

Fixes: c03e7ef12a9 ("nvme: Implement Write Zeroes")
Reported-by: Ming Lei <ming.lei at redhat.com>
Signed-off-by: Keith Busch <keith.busch at intel.com>
---
 hw/block/nvme.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/block/nvme.c b/hw/block/nvme.c
index 7c8c63e8f5..e8fe8f1ddd 100644
--- a/hw/block/nvme.c
+++ b/hw/block/nvme.c
@@ -324,8 +324,8 @@ static uint16_t nvme_write_zeros(NvmeCtrl *n, NvmeNamespace *ns, NvmeCmd *cmd,
     const uint8_t data_shift = ns->id_ns.lbaf[lba_index].ds;
     uint64_t slba = le64_to_cpu(rw->slba);
     uint32_t nlb  = le16_to_cpu(rw->nlb) + 1;
-    uint64_t aio_slba = slba << (data_shift - BDRV_SECTOR_BITS);
-    uint32_t aio_nlb = nlb << (data_shift - BDRV_SECTOR_BITS);
+    uint64_t offset = slba << data_shift;
+    uint32_t count = nlb << data_shift;
 
     if (unlikely(slba + nlb > ns->id_ns.nsze)) {
         trace_nvme_err_invalid_lba_range(slba, nlb, ns->id_ns.nsze);
@@ -335,7 +335,7 @@ static uint16_t nvme_write_zeros(NvmeCtrl *n, NvmeNamespace *ns, NvmeCmd *cmd,
     req->has_sg = false;
     block_acct_start(blk_get_stats(n->conf.blk), &req->acct, 0,
                      BLOCK_ACCT_WRITE);
-    req->aiocb = blk_aio_pwrite_zeroes(n->conf.blk, aio_slba, aio_nlb,
+    req->aiocb = blk_aio_pwrite_zeroes(n->conf.blk, offset, count,
                                         BDRV_REQ_MAY_UNMAP, nvme_rw_cb, req);
     return NVME_NO_COMPLETE;
 }
-- 
2.14.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [Qemu-devel] [PATCH] nvme: fix write zeroes offset and count
@ 2019-03-11 15:11 ` Keith Busch
  0 siblings, 0 replies; 4+ messages in thread
From: Keith Busch @ 2019-03-11 15:11 UTC (permalink / raw)
  To: qemu-devel, Kevin Wolf; +Cc: Ming Lei, linux-nvme, Keith Busch

The implementation used blocks units rather than the expected bytes.

Fixes: c03e7ef12a9 ("nvme: Implement Write Zeroes")
Reported-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Keith Busch <keith.busch@intel.com>
---
 hw/block/nvme.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/block/nvme.c b/hw/block/nvme.c
index 7c8c63e8f5..e8fe8f1ddd 100644
--- a/hw/block/nvme.c
+++ b/hw/block/nvme.c
@@ -324,8 +324,8 @@ static uint16_t nvme_write_zeros(NvmeCtrl *n, NvmeNamespace *ns, NvmeCmd *cmd,
     const uint8_t data_shift = ns->id_ns.lbaf[lba_index].ds;
     uint64_t slba = le64_to_cpu(rw->slba);
     uint32_t nlb  = le16_to_cpu(rw->nlb) + 1;
-    uint64_t aio_slba = slba << (data_shift - BDRV_SECTOR_BITS);
-    uint32_t aio_nlb = nlb << (data_shift - BDRV_SECTOR_BITS);
+    uint64_t offset = slba << data_shift;
+    uint32_t count = nlb << data_shift;
 
     if (unlikely(slba + nlb > ns->id_ns.nsze)) {
         trace_nvme_err_invalid_lba_range(slba, nlb, ns->id_ns.nsze);
@@ -335,7 +335,7 @@ static uint16_t nvme_write_zeros(NvmeCtrl *n, NvmeNamespace *ns, NvmeCmd *cmd,
     req->has_sg = false;
     block_acct_start(blk_get_stats(n->conf.blk), &req->acct, 0,
                      BLOCK_ACCT_WRITE);
-    req->aiocb = blk_aio_pwrite_zeroes(n->conf.blk, aio_slba, aio_nlb,
+    req->aiocb = blk_aio_pwrite_zeroes(n->conf.blk, offset, count,
                                         BDRV_REQ_MAY_UNMAP, nvme_rw_cb, req);
     return NVME_NO_COMPLETE;
 }
-- 
2.14.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] nvme: fix write zeroes offset and count
  2019-03-11 15:11 ` [Qemu-devel] " Keith Busch
  (?)
@ 2019-03-12 14:48 ` Christoph Hellwig
  -1 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2019-03-12 14:48 UTC (permalink / raw)


On Mon, Mar 11, 2019@09:11:53AM -0600, Keith Busch wrote:
> The implementation used blocks units rather than the expected bytes.

Thank,

looks good:

Reviewed-by: Christoph Hellwig <hch at lst.de>

And sorry for causing this mess.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] nvme: fix write zeroes offset and count
  2019-03-11 15:11 ` [Qemu-devel] " Keith Busch
  (?)
  (?)
@ 2019-03-12 15:05 ` Kevin Wolf
  -1 siblings, 0 replies; 4+ messages in thread
From: Kevin Wolf @ 2019-03-12 15:05 UTC (permalink / raw)


Am 11.03.2019 um 16:11 hat Keith Busch geschrieben:
> The implementation used blocks units rather than the expected bytes.
> 
> Fixes: c03e7ef12a9 ("nvme: Implement Write Zeroes")
> Reported-by: Ming Lei <ming.lei at redhat.com>
> Signed-off-by: Keith Busch <keith.busch at intel.com>

Thanks, applied to the block branch.

Kevin

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-03-12 15:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-11 15:11 [PATCH] nvme: fix write zeroes offset and count Keith Busch
2019-03-11 15:11 ` [Qemu-devel] " Keith Busch
2019-03-12 14:48 ` Christoph Hellwig
2019-03-12 15:05 ` Kevin Wolf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.