[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH for-7.2 v2 4/6] hw/nvme: fix cancellation handling in zone reset
From: |
Klaus Jensen |
Subject: |
[PATCH for-7.2 v2 4/6] hw/nvme: fix cancellation handling in zone reset |
Date: |
Thu, 10 Nov 2022 08:05:21 +0100 |
From: Klaus Jensen <k.jensen@samsung.com>
If the zone reset operation is cancelled but the block unmap operation
completes normally, the callback will continue resetting the next zone
since it neglects to check iocb->ret which will have been set to
-ECANCELED. Make sure that this is checked and bail out if an error is
present.
Fixes: 63d96e4ffd71 ("hw/nvme: reimplement zone reset to allow cancellation")
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
---
hw/nvme/ctrl.c | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c
index fe748fc18a2e..fa8e4b8dd53a 100644
--- a/hw/nvme/ctrl.c
+++ b/hw/nvme/ctrl.c
@@ -3772,14 +3772,8 @@ static void nvme_zone_reset_epilogue_cb(void *opaque,
int ret)
int64_t moff;
int count;
- if (ret < 0) {
- nvme_zone_reset_cb(iocb, ret);
- return;
- }
-
- if (!ns->lbaf.ms) {
- nvme_zone_reset_cb(iocb, 0);
- return;
+ if (ret < 0 || iocb->ret < 0 || !ns->lbaf.ms) {
+ goto out;
}
moff = nvme_moff(ns, iocb->zone->d.zslba);
@@ -3789,6 +3783,9 @@ static void nvme_zone_reset_epilogue_cb(void *opaque, int
ret)
BDRV_REQ_MAY_UNMAP,
nvme_zone_reset_cb, iocb);
return;
+
+out:
+ nvme_zone_reset_cb(iocb, ret);
}
static void nvme_zone_reset_cb(void *opaque, int ret)
@@ -3797,7 +3794,9 @@ static void nvme_zone_reset_cb(void *opaque, int ret)
NvmeRequest *req = iocb->req;
NvmeNamespace *ns = req->ns;
- if (ret < 0) {
+ if (iocb->ret < 0) {
+ goto done;
+ } else if (ret < 0) {
iocb->ret = ret;
goto done;
}
--
2.38.1
- [PATCH for-7.2 v2 0/6] hw/nvme: misc fixes, Klaus Jensen, 2022/11/10
- [PATCH for-7.2 v2 1/6] hw/nvme: fix accidental reintroduction of redundant code, Klaus Jensen, 2022/11/10
- [PATCH for-7.2 v2 2/6] hw/nvme: fix cancellation of format operations, Klaus Jensen, 2022/11/10
- [PATCH for-7.2 v2 4/6] hw/nvme: fix cancellation handling in zone reset,
Klaus Jensen <=
- [PATCH for-7.2 v2 6/6] hw/nvme: fix numzrwa handling, Klaus Jensen, 2022/11/10
- [PATCH for-7.2 v2 5/6] hw/nvme: fix cancellation handling in dsm, Klaus Jensen, 2022/11/10
- [PATCH for-7.2 v2 3/6] hw/nvme: fix flush cancel, Klaus Jensen, 2022/11/10