From nobody Fri May 17 02:41:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1611753662; cv=none; d=zohomail.com; s=zohoarc; b=m3GK7vacun58QlOWC1Eb3jBuORxNru/V1XPHvLXkTVXQX9AGz6uaW0yHkS/hnrrBqSVApZSYaCGdcmIXmfzEEJqF9/jn93enw3JaVoEo9NwngrmdCVdnJot4keKumq4aRysz+tt9aCURBQDR9UI3BWgq6dwvJq6abadCBpTyGJY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611753662; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=JTXajVu16svdd6jD5HRi0+16ZJvVl3ij2UxeDbUY1NI=; b=AJzeMlGCqU/nEd6o5z0AmGeWv58mLuxuJwXvDRXzJmOguIScsX42vKb4HpluZZgY6d6p6C8hcTH99/Et2kXD4pbitOS7eZc3LpuCqIAddkDujQiKdkDY3OL8o09/cZD/Z+RykKAYqMiHfsvJTqRXAwMhkC2+50TXNpJ0mTm7TI0= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1611753661786542.2183341730218; Wed, 27 Jan 2021 05:21:01 -0800 (PST) Received: from localhost ([::1]:34030 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l4kkl-0008KD-QB for importer@patchew.org; Wed, 27 Jan 2021 08:20:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:39248) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l4kfF-0007SW-Fj; Wed, 27 Jan 2021 08:15:17 -0500 Received: from wout4-smtp.messagingengine.com ([64.147.123.20]:47029) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l4kfC-0000ff-Bz; Wed, 27 Jan 2021 08:15:17 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 973E3EAE; Wed, 27 Jan 2021 08:15:09 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Wed, 27 Jan 2021 08:15:10 -0500 Received: from apples.local (80-167-98-190-cable.dk.customer.tdc.net [80.167.98.190]) by mail.messagingengine.com (Postfix) with ESMTPA id 2102624005D; Wed, 27 Jan 2021 08:15:07 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irrelevant.dk; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; s=fm2; bh=JTXajVu16svdd6jD5HRi0+16ZJ vVl3ij2UxeDbUY1NI=; b=QGZDNAOzWuLvKcgdRYtlT7Z0Ps0tiL/z3DKAiUxirk QZo4r0yTmFMNLbHrEVARl+68uCLhzaphZFu4csotk7vU/ObdN+HZ7iy7HZu9t9sO PjE8HZRAVFq/o5h9lPlkIoH09wclE+ZjLFtDZKnTxR2wWxJCQV7SrTsFFxTghM/I J2l46RGh4kDAbAxuUtCqqvX2C+MCd3Xnd2gBSBvRX8/QMF5Vu8E8BlVjFP/reJ7g VRQ1yhotwh7urQpgcvLq0/lud1WONrmAQI3xX8PjThjp2i9mZ3v4mCQqHDQ0NY0b oDLqAAOKd8fASBT1cRQ5tHprhHGAanbEamzjLyNjEAug== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=JTXajVu16svdd6jD5 HRi0+16ZJvVl3ij2UxeDbUY1NI=; b=phWAr1I0gxKiSxHrqw7lW9ce5Pj76bsia TvxALy2QSFhlYGHqot6em7gRE4Lu89Kr/bFZoruadUeT4ZHBx4+xnWKLsCArZdcF PfsqWNJ3wkhwKJJ76xZow+Dpu/+rxjpG+qYVTO393Y1x/WOhRPIrOF35TH5PpNmF QqPgJF3pxWYqZX70T9gsw/jvY4tBy5zjH/JFOlxbqeT1MuWOH1iko/v20/w+dMlE 6NCtGrEliJdklbF7xTgEpH1s6PuonnIStzo7db9/NNtoaeqYw1IBXMMDMm0Bng5X NgqcNGwI3HanKVM5dqBDDd1I811xio/99m2y86X60K7oZkF2QIQuw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrvdekgdegkecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgggfestdekredtredttdenucfhrhhomhepmfhlrghushculfgv nhhsvghnuceoihhtshesihhrrhgvlhgvvhgrnhhtrdgukheqnecuggftrfgrthhtvghrnh epfeevledvieekudeuffetgeegfeehvdffffejueeuleduhedvgeejveejhfdtteehnecu kfhppeektddrudeijedrleekrdduledtnecuvehluhhsthgvrhfuihiivgeptdenucfrrg hrrghmpehmrghilhhfrhhomhepihhtshesihhrrhgvlhgvvhgrnhhtrdgukh X-ME-Proxy: From: Klaus Jensen To: qemu-devel@nongnu.org Subject: [PATCH] hw/block/nvme: drain namespaces on sq deletion Date: Wed, 27 Jan 2021 14:15:05 +0100 Message-Id: <20210127131505.394550-1-its@irrelevant.dk> X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=64.147.123.20; envelope-from=its@irrelevant.dk; helo=wout4-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-block@nongnu.org, Klaus Jensen , Max Reitz , Keith Busch , Klaus Jensen Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Klaus Jensen For most commands, when issuing an AIO, the BlockAIOCB is stored in the NvmeRequest aiocb pointer when the AIO is issued. The purpose of storing this is to allow the AIO to be cancelled when deleting submission queues (it is currently not used for Abort). Since the addition of the Dataset Management command and Zoned Namespaces, NvmeRequests may involve more than one AIO and the AIOs are issued without saving a reference to the BlockAIOCB. This is a problem since nvme_del_sq will attempt to cancel outstanding AIOs, potentially with an invalid BlockAIOCB. Fix this by instead of explicitly cancelling the requests, just allow the AIOs to complete by draining the namespace blockdevs. Signed-off-by: Klaus Jensen --- hw/block/nvme.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/hw/block/nvme.c b/hw/block/nvme.c index 316858fd8adf..91f6fb6da1e2 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -403,6 +403,7 @@ static void nvme_req_clear(NvmeRequest *req) { req->ns =3D NULL; req->opaque =3D NULL; + req->aiocb =3D NULL; memset(&req->cqe, 0x0, sizeof(req->cqe)); req->status =3D NVME_SUCCESS; } @@ -2396,6 +2397,7 @@ static uint16_t nvme_del_sq(NvmeCtrl *n, NvmeRequest = *req) NvmeSQueue *sq; NvmeCQueue *cq; uint16_t qid =3D le16_to_cpu(c->qid); + int i; =20 if (unlikely(!qid || nvme_check_sqid(n, qid))) { trace_pci_nvme_err_invalid_del_sq(qid); @@ -2404,12 +2406,18 @@ static uint16_t nvme_del_sq(NvmeCtrl *n, NvmeReques= t *req) =20 trace_pci_nvme_del_sq(qid); =20 - sq =3D n->sq[qid]; - while (!QTAILQ_EMPTY(&sq->out_req_list)) { - r =3D QTAILQ_FIRST(&sq->out_req_list); - assert(r->aiocb); - blk_aio_cancel(r->aiocb); + for (i =3D 1; i <=3D n->num_namespaces; i++) { + NvmeNamespace *ns =3D nvme_ns(n, i); + if (!ns) { + continue; + } + + nvme_ns_drain(ns); } + + sq =3D n->sq[qid]; + assert(QTAILQ_EMPTY(&sq->out_req_list)); + if (!nvme_check_cqid(n, sq->cqid)) { cq =3D n->cq[sq->cqid]; QTAILQ_REMOVE(&cq->sq_list, sq, entry); --=20 2.30.0