Message ID | 20200316142928.153431-25-its@irrelevant.dk |
---|---|
State | New |
Headers | show |
Series | nvme: support NVMe v1.3d, SGLs and multiple namespaces | expand |
On Mon, 2020-03-16 at 07:29 -0700, Klaus Jensen wrote: > From: Klaus Jensen <k.jensen@samsung.com> > > Remove the has_sg member from NvmeRequest since it's redundant. To be honest this patch also replaces the dma_acct_start with block_acct_start which looks right to me, and IMHO its OK to have both in the same patch, but that should be mentioned in the commit message With this fixed, Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> Best regards, Maxim Levitsky > > Signed-off-by: Klaus Jensen <k.jensen@samsung.com> > --- > hw/block/nvme.c | 18 ++++++++++++------ > hw/block/nvme.h | 1 - > 2 files changed, 12 insertions(+), 7 deletions(-) > > diff --git a/hw/block/nvme.c b/hw/block/nvme.c > index 187c816eb6ad..e40c080c3b48 100644 > --- a/hw/block/nvme.c > +++ b/hw/block/nvme.c > @@ -484,16 +484,20 @@ static void nvme_rw_cb(void *opaque, int ret) > block_acct_failed(blk_get_stats(n->conf.blk), &req->acct); > req->status = NVME_INTERNAL_DEV_ERROR; > } > - if (req->has_sg) { > + > + if (req->qsg.nalloc) { > qemu_sglist_destroy(&req->qsg); > } > + if (req->iov.nalloc) { > + qemu_iovec_destroy(&req->iov); > + } > + > nvme_enqueue_req_completion(cq, req); > } > > static uint16_t nvme_flush(NvmeCtrl *n, NvmeNamespace *ns, NvmeCmd *cmd, > NvmeRequest *req) > { > - req->has_sg = false; > block_acct_start(blk_get_stats(n->conf.blk), &req->acct, 0, > BLOCK_ACCT_FLUSH); > req->aiocb = blk_aio_flush(n->conf.blk, nvme_rw_cb, req); > @@ -517,7 +521,6 @@ static uint16_t nvme_write_zeros(NvmeCtrl *n, NvmeNamespace *ns, NvmeCmd *cmd, > return NVME_LBA_RANGE | NVME_DNR; > } > > - 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, offset, count, > @@ -554,16 +557,19 @@ static uint16_t nvme_rw(NvmeCtrl *n, NvmeNamespace *ns, NvmeCmd *cmd, > return NVME_INVALID_FIELD | NVME_DNR; > } > > - dma_acct_start(n->conf.blk, &req->acct, &req->qsg, acct); > if (req->qsg.nsg > 0) { > - req->has_sg = true; > + block_acct_start(blk_get_stats(n->conf.blk), &req->acct, req->qsg.size, > + acct); > + > req->aiocb = is_write ? > dma_blk_write(n->conf.blk, &req->qsg, data_offset, BDRV_SECTOR_SIZE, > nvme_rw_cb, req) : > dma_blk_read(n->conf.blk, &req->qsg, data_offset, BDRV_SECTOR_SIZE, > nvme_rw_cb, req); > } else { > - req->has_sg = false; > + block_acct_start(blk_get_stats(n->conf.blk), &req->acct, req->iov.size, > + acct); > + > req->aiocb = is_write ? > blk_aio_pwritev(n->conf.blk, data_offset, &req->iov, 0, nvme_rw_cb, > req) : > diff --git a/hw/block/nvme.h b/hw/block/nvme.h > index b4d1738a3d0a..442b17bf1701 100644 > --- a/hw/block/nvme.h > +++ b/hw/block/nvme.h > @@ -29,7 +29,6 @@ typedef struct NvmeRequest { > struct NvmeSQueue *sq; > BlockAIOCB *aiocb; > uint16_t status; > - bool has_sg; > NvmeCqe cqe; > BlockAcctCookie acct; > QEMUSGList qsg;
On Mar 25 12:45, Maxim Levitsky wrote: > On Mon, 2020-03-16 at 07:29 -0700, Klaus Jensen wrote: > > From: Klaus Jensen <k.jensen@samsung.com> > > > > Remove the has_sg member from NvmeRequest since it's redundant. > > To be honest this patch also replaces the dma_acct_start with block_acct_start > which looks right to me, and IMHO its OK to have both in the same patch, > but that should be mentioned in the commit message > I pulled it to a separate patch :) > With this fixed, > Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> >
On Tue, 2020-03-31 at 07:44 +0200, Klaus Birkelund Jensen wrote: > On Mar 25 12:45, Maxim Levitsky wrote: > > On Mon, 2020-03-16 at 07:29 -0700, Klaus Jensen wrote: > > > From: Klaus Jensen <k.jensen@samsung.com> > > > > > > Remove the has_sg member from NvmeRequest since it's redundant. > > > > To be honest this patch also replaces the dma_acct_start with block_acct_start > > which looks right to me, and IMHO its OK to have both in the same patch, > > but that should be mentioned in the commit message > > > > I pulled it to a separate patch :) Cool. Thanks > > > With this fixed, > > Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> > > > > Best regards, Maxim Levitsky
diff --git a/hw/block/nvme.c b/hw/block/nvme.c index 187c816eb6ad..e40c080c3b48 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -484,16 +484,20 @@ static void nvme_rw_cb(void *opaque, int ret) block_acct_failed(blk_get_stats(n->conf.blk), &req->acct); req->status = NVME_INTERNAL_DEV_ERROR; } - if (req->has_sg) { + + if (req->qsg.nalloc) { qemu_sglist_destroy(&req->qsg); } + if (req->iov.nalloc) { + qemu_iovec_destroy(&req->iov); + } + nvme_enqueue_req_completion(cq, req); } static uint16_t nvme_flush(NvmeCtrl *n, NvmeNamespace *ns, NvmeCmd *cmd, NvmeRequest *req) { - req->has_sg = false; block_acct_start(blk_get_stats(n->conf.blk), &req->acct, 0, BLOCK_ACCT_FLUSH); req->aiocb = blk_aio_flush(n->conf.blk, nvme_rw_cb, req); @@ -517,7 +521,6 @@ static uint16_t nvme_write_zeros(NvmeCtrl *n, NvmeNamespace *ns, NvmeCmd *cmd, return NVME_LBA_RANGE | NVME_DNR; } - 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, offset, count, @@ -554,16 +557,19 @@ static uint16_t nvme_rw(NvmeCtrl *n, NvmeNamespace *ns, NvmeCmd *cmd, return NVME_INVALID_FIELD | NVME_DNR; } - dma_acct_start(n->conf.blk, &req->acct, &req->qsg, acct); if (req->qsg.nsg > 0) { - req->has_sg = true; + block_acct_start(blk_get_stats(n->conf.blk), &req->acct, req->qsg.size, + acct); + req->aiocb = is_write ? dma_blk_write(n->conf.blk, &req->qsg, data_offset, BDRV_SECTOR_SIZE, nvme_rw_cb, req) : dma_blk_read(n->conf.blk, &req->qsg, data_offset, BDRV_SECTOR_SIZE, nvme_rw_cb, req); } else { - req->has_sg = false; + block_acct_start(blk_get_stats(n->conf.blk), &req->acct, req->iov.size, + acct); + req->aiocb = is_write ? blk_aio_pwritev(n->conf.blk, data_offset, &req->iov, 0, nvme_rw_cb, req) : diff --git a/hw/block/nvme.h b/hw/block/nvme.h index b4d1738a3d0a..442b17bf1701 100644 --- a/hw/block/nvme.h +++ b/hw/block/nvme.h @@ -29,7 +29,6 @@ typedef struct NvmeRequest { struct NvmeSQueue *sq; BlockAIOCB *aiocb; uint16_t status; - bool has_sg; NvmeCqe cqe; BlockAcctCookie acct; QEMUSGList qsg;