From: Klaus Jensen <its@irrelevant.dk>
To: Keith Busch <kbusch@kernel.org>
Cc: ddtikhov@gmail.com, linux@yadro.com,
Dmitry Tikhov <d.tihov@yadro.com>,
qemu-block@nongnu.org, qemu-devel@nongnu.org
Subject: Re: [PATCH] hw/nvme: fix control flow statement
Date: Fri, 15 Apr 2022 21:42:05 +0200 [thread overview]
Message-ID: <YlnKjTc4FRkfsOv9@apples> (raw)
In-Reply-To: <YlnI8EONxaX/fnPZ@kbusch-mbp.dhcp.thefacebook.com>
[-- Attachment #1: Type: text/plain, Size: 1564 bytes --]
On Apr 15 13:35, Keith Busch wrote:
> On Fri, Apr 15, 2022 at 10:27:21PM +0300, Dmitry Tikhov wrote:
> > Since there is no else after nvme_dsm_cb invocation, metadata associated
> > with non-zero block range is currently zeroed. Also this behaviour leads
> > to segfault since we schedule iocb->bh two times. First when entering
> > nvme_dsm_cb with iocb->idx == iocb->nr and second on call stack unwinding
> > by calling blk_aio_pwrite_zeroes and subsequent nvme_dsm_cb callback
> > because of missing else statement.
> >
> > Signed-off-by: Dmitry Tikhov <d.tihov@yadro.com>
> > ---
> > hw/nvme/ctrl.c | 7 ++++---
> > 1 file changed, 4 insertions(+), 3 deletions(-)
> >
> > diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c
> > index 03760ddeae..7ebd2aa326 100644
> > --- a/hw/nvme/ctrl.c
> > +++ b/hw/nvme/ctrl.c
> > @@ -2372,11 +2372,12 @@ static void nvme_dsm_md_cb(void *opaque, int ret)
> > }
> >
> > nvme_dsm_cb(iocb, 0);
> > + } else {
> > + iocb->aiocb = blk_aio_pwrite_zeroes(ns->blkconf.blk, nvme_moff(ns, slba),
> > + nvme_m2b(ns, nlb), BDRV_REQ_MAY_UNMAP,
> > + nvme_dsm_cb, iocb);
> > }
>
> Instead of the 'else', just insert an early 'return;' after nvme_dsm_cb() like
> the earlier condition above here. Otherwise, looks good, and thanks for the
> fix.
Dmitry,
Agree with Keith - also, please add
Fixes: d7d1474fd85d ("hw/nvme: reimplement dsm to allow cancellation")
Thanks again!
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2022-04-15 19:51 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-15 19:27 [PATCH] hw/nvme: fix control flow statement Dmitry Tikhov
2022-04-15 19:35 ` Keith Busch
2022-04-15 19:42 ` Klaus Jensen [this message]
2022-04-15 20:23 ` Dmitry Tikhov
2022-04-15 20:27 ` Klaus Jensen
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=YlnKjTc4FRkfsOv9@apples \
--to=its@irrelevant.dk \
--cc=d.tihov@yadro.com \
--cc=ddtikhov@gmail.com \
--cc=kbusch@kernel.org \
--cc=linux@yadro.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).