qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Klaus Jensen <its@irrelevant.dk>
To: Keith Busch <kbusch@kernel.org>
Cc: Kevin Wolf <kwolf@redhat.com>,
	Klaus Jensen <k.jensen@samsung.com>,
	qemu-devel@nongnu.org, qemu-block@nongnu.org,
	Max Reitz <mreitz@redhat.com>
Subject: Re: [PATCH v3 2/2] hw/block/nvme: add simple copy command
Date: Wed, 9 Dec 2020 11:08:12 +0100	[thread overview]
Message-ID: <X9CiDI0rYJ0pEBdr@apples.localdomain> (raw)
In-Reply-To: <20201208221327.GH27155@redsun51.ssa.fujisawa.hgst.com>

[-- Attachment #1: Type: text/plain, Size: 1547 bytes --]

On Dec  9 07:13, Keith Busch wrote:
> On Tue, Dec 08, 2020 at 09:33:39AM +0100, Klaus Jensen wrote:
> > +static uint16_t nvme_copy(NvmeCtrl *n, NvmeRequest *req)
> > +{
> 
> <snip>
> 
> > +    for (i = 0; i < nr; i++) {
> > +        uint32_t _nlb = le16_to_cpu(range[i].nlb) + 1;
> > +        if (_nlb > le16_to_cpu(ns->id_ns.mssrl)) {
> > +            return NVME_CMD_SIZE_LIMIT | NVME_DNR;
> > +        }
> > +
> > +        nlb += _nlb;
> > +    }
> > +
> > +    if (nlb > le32_to_cpu(ns->id_ns.mcl)) {
> > +        return NVME_CMD_SIZE_LIMIT | NVME_DNR;
> > +    }
> > +
> > +    bounce = bouncep = g_malloc(nvme_l2b(ns, nlb));
> > +
> > +    for (i = 0; i < nr; i++) {
> > +        uint64_t slba = le64_to_cpu(range[i].slba);
> > +        uint32_t nlb = le16_to_cpu(range[i].nlb) + 1;
> > +
> > +        status = nvme_check_bounds(ns, slba, nlb);
> > +        if (status) {
> > +            trace_pci_nvme_err_invalid_lba_range(slba, nlb, ns->id_ns.nsze);
> > +            goto free_bounce;
> > +        }
> > +
> > +        if (NVME_ERR_REC_DULBE(ns->features.err_rec)) {
> > +            status = nvme_check_dulbe(ns, slba, nlb);
> > +            if (status) {
> > +                goto free_bounce;
> > +            }
> > +        }
> > +    }
> 
> Only comment I have is that these two for-loops look like they can be
> collaped into one, which also simplifies how you account for the bounce
> buffer when error'ing out. 
> 

Yeah. And the shadowing of nlb is not good either. I'll fix it up.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

      reply	other threads:[~2020-12-09 10:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-08  8:33 [PATCH v3 0/2] hw/block/nvme: add simple copy command Klaus Jensen
2020-12-08  8:33 ` [PATCH v3 1/2] nvme: updated shared header for " Klaus Jensen
2020-12-08  8:33 ` [PATCH v3 2/2] hw/block/nvme: add simple " Klaus Jensen
2020-12-08 22:13   ` Keith Busch
2020-12-09 10:08     ` Klaus Jensen [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=X9CiDI0rYJ0pEBdr@apples.localdomain \
    --to=its@irrelevant.dk \
    --cc=k.jensen@samsung.com \
    --cc=kbusch@kernel.org \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).