[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL 15/28] nvme: fix write zeroes offset and count
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PULL 15/28] nvme: fix write zeroes offset and count |
Date: |
Tue, 12 Mar 2019 18:30:12 +0100 |
From: Keith Busch <address@hidden>
The implementation used blocks units rather than the expected bytes.
Fixes: c03e7ef12a9 ("nvme: Implement Write Zeroes")
Reported-by: Ming Lei <address@hidden>
Signed-off-by: Keith Busch <address@hidden>
Reviewed-by: Christoph Hellwig <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
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 8325b5e88a..7caf92532a 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.20.1
- Re: [Qemu-block] [Qemu-devel] [PULL 04/28] qapi: drop x- from x-block-latency-histogram-set, (continued)
- [Qemu-block] [PULL 03/28] qapi: move to QOM path for x-block-latency-histogram-set, Kevin Wolf, 2019/03/12
- [Qemu-block] [PULL 07/28] block: Avoid useless local_err, Kevin Wolf, 2019/03/12
- [Qemu-block] [PULL 06/28] qemu-iotests: commit to backing file with auto-read-only, Kevin Wolf, 2019/03/12
- [Qemu-block] [PULL 09/28] file-posix: Fix bdrv_open_flags() for snapshot=on, Kevin Wolf, 2019/03/12
- [Qemu-block] [PULL 11/28] file-posix: Store BDRVRawState.reopen_state during reopen, Kevin Wolf, 2019/03/12
- [Qemu-block] [PULL 10/28] file-posix: Factor out raw_reconfigure_getfd(), Kevin Wolf, 2019/03/12
- [Qemu-block] [PULL 14/28] file-posix: Make auto-read-only dynamic, Kevin Wolf, 2019/03/12
- [Qemu-block] [PULL 15/28] nvme: fix write zeroes offset and count,
Kevin Wolf <=
- [Qemu-block] [PULL 08/28] block: Make permission changes in reopen less wrong, Kevin Wolf, 2019/03/12
- [Qemu-block] [PULL 12/28] file-posix: Lock new fd in raw_reopen_prepare(), Kevin Wolf, 2019/03/12
- [Qemu-block] [PULL 13/28] file-posix: Prepare permission code for fd switching, Kevin Wolf, 2019/03/12
- [Qemu-block] [PULL 16/28] block: Allow freezing BdrvChild links, Kevin Wolf, 2019/03/12
- [Qemu-block] [PULL 17/28] block: Freeze the backing chain for the duration of the commit job, Kevin Wolf, 2019/03/12
- [Qemu-block] [PULL 18/28] block: Freeze the backing chain for the duration of the mirror job, Kevin Wolf, 2019/03/12
- [Qemu-block] [PULL 19/28] block: Freeze the backing chain for the duration of the stream job, Kevin Wolf, 2019/03/12
- [Qemu-block] [PULL 20/28] block: Add 'keep_old_opts' parameter to bdrv_reopen_queue(), Kevin Wolf, 2019/03/12