Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F177629907
D60228.1794889254.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None
D60228.1794889254.diff
View Options
diff --git a/usr.sbin/bhyve/pci_nvme.c b/usr.sbin/bhyve/pci_nvme.c
--- a/usr.sbin/bhyve/pci_nvme.c
+++ b/usr.sbin/bhyve/pci_nvme.c
@@ -209,6 +209,7 @@
STAILQ_ENTRY(pci_nvme_ioreq) link;
struct nvme_submission_queue *nvme_sq;
uint16_t sqid;
+ uint32_t resets;
/* command information */
uint16_t opc;
@@ -336,6 +337,7 @@
struct pci_nvme_ioreq *ioreqs;
STAILQ_HEAD(, pci_nvme_ioreq) ioreqs_free; /* free list of ioreqs */
uint32_t pending_ios;
+ uint32_t resets;
uint32_t ioslots;
sem_t iosemlock;
@@ -1012,6 +1014,9 @@
DPRINTF("%s", __func__);
+ /* The I/O requests in flight belong to the controller that was. */
+ sc->resets++;
+
sc->regs.cap_lo = (ZERO_BASED(sc->max_qentries) & NVME_CAP_LO_REG_MQES_MASK) |
NVMEF(NVME_CAP_LO_REG_CQR, 1) |
NVMEF(NVME_CAP_LO_REG_TO, 60);
@@ -2286,6 +2291,23 @@
}
}
+/*
+ * Post the completion of an I/O request, unless the controller was reset
+ * after the request was issued: the queues of that time are gone, and a
+ * completion queue with the same ID is a new queue that the guest does not
+ * expect this completion in.
+ */
+static void
+pci_nvme_ioreq_completion(struct pci_nvme_softc *sc, struct pci_nvme_ioreq *req,
+ uint16_t status)
+{
+ pthread_mutex_lock(&sc->mtx);
+ if (req->resets == sc->resets)
+ pci_nvme_set_completion(sc, req->nvme_sq, req->sqid, req->cid,
+ status);
+ pthread_mutex_unlock(&sc->mtx);
+}
+
static void
pci_nvme_release_ioreq(struct pci_nvme_softc *sc, struct pci_nvme_ioreq *req)
{
@@ -2321,6 +2343,7 @@
STAILQ_REMOVE_HEAD(&sc->ioreqs_free, link);
req->sc = sc;
+ req->resets = sc->resets;
sc->pending_ios++;
@@ -2340,7 +2363,6 @@
pci_nvme_io_done(struct blockif_req *br, int err)
{
struct pci_nvme_ioreq *req = br->br_param;
- struct nvme_submission_queue *sq = req->nvme_sq;
uint16_t code, status;
DPRINTF("%s error %d %s", __func__, err, strerror(err));
@@ -2350,7 +2372,7 @@
status = 0;
pci_nvme_status_genc(&status, code);
- pci_nvme_set_completion(req->sc, sq, req->sqid, req->cid, status);
+ pci_nvme_ioreq_completion(req->sc, req, status);
pci_nvme_stats_write_read_update(req->sc, req->opc,
req->bytes, status);
pci_nvme_release_ioreq(req->sc, req);
@@ -2565,6 +2587,9 @@
pci_nvme_status_genc(&status, NVME_SC_INTERNAL_DEVICE_ERROR);
} else if ((req->prev_gpaddr + 1) == (req->prev_size)) {
pci_nvme_status_genc(&status, NVME_SC_SUCCESS);
+ } else if (req->resets != sc->resets) {
+ /* The controller was reset: leave the remaining ranges. */
+ pci_nvme_status_genc(&status, NVME_SC_SUCCESS);
} else {
struct iovec *iov = req->io_req.br_iov;
@@ -2582,8 +2607,7 @@
}
if (done) {
- pci_nvme_set_completion(sc, req->nvme_sq, req->sqid, req->cid,
- status);
+ pci_nvme_ioreq_completion(sc, req, status);
pci_nvme_release_ioreq(sc, req);
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Nov 17, 4:20 AM (9 h, 31 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
40117261
Default Alt Text
D60228.1794889254.diff (2 KB)
Attached To
Mode
D60228: bhyve: nvme: drop the completions of commands from before a reset
Attached
Detach File
Event Timeline