Message ID | 20200720113748.322965-4-its@irrelevant.dk |
---|---|
State | New |
Headers | show |
Series | hw/block/nvme: dma handling and address mapping cleanup | expand |
Klaus, On 20-07-20 13:37:35, Klaus Jensen wrote: > From: Klaus Jensen <k.jensen@samsung.com> > > The QSG isn't always initialized, so accounting could be wrong. Issue a > call to blk_acct_start instead with the size taken from the QSG or IOV > depending on the kind of I/O. > > Signed-off-by: Klaus Jensen <k.jensen@samsung.com> > Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> > --- > hw/block/nvme.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/hw/block/nvme.c b/hw/block/nvme.c > index 9b1a080cdc70..cb236d1c8c46 100644 > --- a/hw/block/nvme.c > +++ b/hw/block/nvme.c > @@ -620,9 +620,10 @@ 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) : > @@ -630,6 +631,8 @@ static uint16_t nvme_rw(NvmeCtrl *n, NvmeNamespace *ns, NvmeCmd *cmd, > 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) : Reviewed-by: Minwoo Im <minwoo.im.dev@gmail.com> Thanks,
diff --git a/hw/block/nvme.c b/hw/block/nvme.c index 9b1a080cdc70..cb236d1c8c46 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -620,9 +620,10 @@ 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) : @@ -630,6 +631,8 @@ static uint16_t nvme_rw(NvmeCtrl *n, NvmeNamespace *ns, NvmeCmd *cmd, 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) :