From: Hanna Czenczek Date: Mon, 10 Nov 2025 15:48:42 +0000 (+0100) Subject: nvme: Kick and check completions in BDS context X-Git-Tag: v10.2.0-rc1~5^2~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7a501bbd51941fb1867d78e6b0d1dc69e396b9e2;p=thirdparty%2Fqemu.git nvme: Kick and check completions in BDS context nvme_process_completion() must run in the main BDS context, so schedule a BH for requests that aren’t there. The context in which we kick does not matter, but let’s just keep kick and process_completion together for simplicity’s sake. (For what it’s worth, a quick fio bandwidth test indicates that on my test hardware, if anything, this may be a bit better than kicking immediately before scheduling a pure nvme_process_completion() BH. But I wouldn’t take more from those results than that it doesn’t really seem to matter either way.) Cc: qemu-stable@nongnu.org Signed-off-by: Hanna Czenczek Message-ID: <20251110154854.151484-8-hreitz@redhat.com> Reviewed-by: Stefan Hajnoczi Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- diff --git a/block/nvme.c b/block/nvme.c index 8df53ee4ca..7ed5f570bc 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -481,7 +481,7 @@ static void nvme_trace_command(const NvmeCmd *cmd) } } -static void nvme_deferred_fn(void *opaque) +static void nvme_kick_and_check_completions(void *opaque) { NVMeQueuePair *q = opaque; @@ -490,6 +490,18 @@ static void nvme_deferred_fn(void *opaque) nvme_process_completion(q); } +static void nvme_deferred_fn(void *opaque) +{ + NVMeQueuePair *q = opaque; + + if (qemu_get_current_aio_context() == q->s->aio_context) { + nvme_kick_and_check_completions(q); + } else { + aio_bh_schedule_oneshot(q->s->aio_context, + nvme_kick_and_check_completions, q); + } +} + static void nvme_submit_command(NVMeQueuePair *q, NVMeRequest *req, NvmeCmd *cmd, BlockCompletionFunc cb, void *opaque)