From: Klaus Jensen <its@irrelevant.dk>
To: qemu-devel@nongnu.org
Cc: qemu-block@nongnu.org, Keith Busch <kbusch@kernel.org>,
Klaus Jensen <its@irrelevant.dk>,
Klaus Jensen <k.jensen@samsung.com>
Subject: [PATCH for-7.2 v2 5/6] hw/nvme: fix cancellation handling in dsm
Date: Thu, 10 Nov 2022 08:05:22 +0100 [thread overview]
Message-ID: <20221110070523.36290-6-its@irrelevant.dk> (raw)
In-Reply-To: <20221110070523.36290-1-its@irrelevant.dk>
From: Klaus Jensen <k.jensen@samsung.com>
When the DSM operation is cancelled asynchronously, we set iocb->ret to
-ECANCELED. However, the callback function only checks the return value
of the completed aio, which may have completed succesfully prior to the
cancellation and thus the callback ends up continuing the dsm operation
instead of bailing out. Fix this.
Fixes: d7d1474fd85d ("hw/nvme: reimplement dsm to allow cancellation")
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
---
hw/nvme/ctrl.c | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)
diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c
index fa8e4b8dd53a..6f217c3951bd 100644
--- a/hw/nvme/ctrl.c
+++ b/hw/nvme/ctrl.c
@@ -2384,16 +2384,10 @@ static void nvme_dsm_md_cb(void *opaque, int ret)
uint64_t slba;
uint32_t nlb;
- if (ret < 0) {
- iocb->ret = ret;
+ if (ret < 0 || iocb->ret < 0 || !ns->lbaf.ms) {
goto done;
}
- if (!ns->lbaf.ms) {
- nvme_dsm_cb(iocb, 0);
- return;
- }
-
range = &iocb->range[iocb->idx - 1];
slba = le64_to_cpu(range->slba);
nlb = le32_to_cpu(range->nlb);
@@ -2406,7 +2400,6 @@ static void nvme_dsm_md_cb(void *opaque, int ret)
ret = nvme_block_status_all(ns, slba, nlb, BDRV_BLOCK_ZERO);
if (ret) {
if (ret < 0) {
- iocb->ret = ret;
goto done;
}
@@ -2420,8 +2413,7 @@ static void nvme_dsm_md_cb(void *opaque, int ret)
return;
done:
- iocb->aiocb = NULL;
- qemu_bh_schedule(iocb->bh);
+ nvme_dsm_cb(iocb, ret);
}
static void nvme_dsm_cb(void *opaque, int ret)
@@ -2434,7 +2426,9 @@ static void nvme_dsm_cb(void *opaque, int ret)
uint64_t slba;
uint32_t nlb;
- if (ret < 0) {
+ if (iocb->ret < 0) {
+ goto done;
+ } else if (ret < 0) {
iocb->ret = ret;
goto done;
}
--
2.38.1
next prev parent reply other threads:[~2022-11-10 7:06 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-10 7:05 [PATCH for-7.2 v2 0/6] hw/nvme: misc fixes Klaus Jensen
2022-11-10 7:05 ` [PATCH for-7.2 v2 1/6] hw/nvme: fix accidental reintroduction of redundant code Klaus Jensen
2022-11-10 7:05 ` [PATCH for-7.2 v2 2/6] hw/nvme: fix cancellation of format operations Klaus Jensen
2022-11-10 9:53 ` Philippe Mathieu-Daudé
2022-11-10 9:54 ` Philippe Mathieu-Daudé
2022-11-10 7:05 ` [PATCH for-7.2 v2 3/6] hw/nvme: fix flush cancel Klaus Jensen
2022-11-10 7:05 ` [PATCH for-7.2 v2 4/6] hw/nvme: fix cancellation handling in zone reset Klaus Jensen
2022-11-10 7:05 ` Klaus Jensen [this message]
2022-11-10 7:05 ` [PATCH for-7.2 v2 6/6] hw/nvme: fix numzrwa handling 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=20221110070523.36290-6-its@irrelevant.dk \
--to=its@irrelevant.dk \
--cc=k.jensen@samsung.com \
--cc=kbusch@kernel.org \
--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).