From patchwork Thu Jun 22 11:19:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukas Straub X-Patchwork-Id: 13288981 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D49A2EB64D8 for ; Thu, 22 Jun 2023 11:20:21 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qCILl-0002vH-J6; Thu, 22 Jun 2023 07:19:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qCILk-0002um-Mp; Thu, 22 Jun 2023 07:19:40 -0400 Received: from mout.web.de ([212.227.15.3]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qCILj-0004tM-3n; Thu, 22 Jun 2023 07:19:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=s29768273; t=1687432776; x=1688037576; i=lukasstraub2@web.de; bh=ddWbLBpQVuLtpgtxk3xEWBoFyEIL7NttvuUp3ALaQGo=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject; b=uH4zJ7soALs1WIp04BtTOZlf6c22EqLIw36jmvLWq9lv8mTq6cjSxTUwexJKkZu2Ho2TTo3 1/YflZQPa3jPG3WjKWJuoFtqEc6nLdwMf0yOX1yB4PUCz4xnknu2A5TQn+gSgezgFjivxzea/ If6myYte0lzoWN5ADOdTJ1UFCwAGsGcXUzZHRr/WDTFuu2F0b9DfaJ5Vt258GmJXqqa1SG2a4 xqHsyLK+9rMNx3LqSpOL8/jPWRq5e7dIb9S2KGxNqX2cdGpBbb+qUuancK8YxihT8ed+c0tgU JCN6taSqwt4yZd4hKWgdO25MEevlBKr7uxGlafs8KohaoMFN9KqA== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from mobian ([46.114.147.93]) by smtp.web.de (mrweb005 [213.165.67.108]) with ESMTPSA (Nemesis) id 1N8Elg-1pzHkd3o12-0148yX; Thu, 22 Jun 2023 13:19:36 +0200 Date: Thu, 22 Jun 2023 13:19:32 +0200 From: Lukas Straub To: qemu-devel Cc: qemu-block , John Snow , Hanna Reitz , Paolo Bonzini Subject: [PATCH 1/2] ide: Fix a rare hang during block draining Message-ID: MIME-Version: 1.0 X-Provags-ID: V03:K1:l8yVPj6Aa0iNe/BphBFKXUvUnHJ2BHRI8o54sDbhUDs2RQXvlzb ZyfBQkbmOZGP/Ag8CAScp2fY0RCR2H31AkuN8Sv0L0tUEll/ehKl/Od78aYNptnCB9I2dqS uylT76ukoqXkF0eZDNaxFM+hTE9Xu0oPnclEauMwYw+VZXFzKNRcQmojjN4WD1exdfhlg/O ThpLkpotvH0BIDogs4xrA== UI-OutboundReport: notjunk:1;M01:P0:4hMrkcvElhU=;2H5lg0HF+mJ+o05SwwJwEs+TXri sIX28w9AaDEkEsyPY4CfFi47o9WRaOF0ahFx9SXi+64dlhhBvgoRx1OSsviFgkSg1WpLGU+al W2iiBNNyuG3XEUuTXkx0UxFBtU6CAKcJG4c6J4dwEH4cFbDsWwUvXcGYzb61xOHQhSsKwIIKz z08e3QI/fO3vnkqBejAH+3I+i1ekdvqTXDS1rEoli6jwo5VP+sreVkKt7E/67FF23qEuAX9pX BnSptXJuJNj4saLYymLE3KFtZp1+x0C8mFa9Oz0/i4hYe/4EKsxILrym5+IzWWIftFirFyaYm dPNnVB6xhZPqqYq5v3ljdk/TBI3kLeJD9ZOYXdyMxkpjo9ZY+Evr3P7ERqOSPYdn8C6V3/8wf oNiS6uQO0fLV0G37i4Kkf16d6hmKJkQ0tSzv1MUtD1Vu4FxGH2bnkw4OLh0hPfiLG8Loo4ME0 fi1tijPDPFOcIGOoJ9yReLuUQ3cqOyGQ5kU5KSHbRWPNpmvIddJoX3odDktq97/ns461SW3GG ImKSJL8IVt7YeblAg2agjRKCTqUapkWp5ylVd/XT4MPewWM6KYC8KaiAm2XL6srJvhmAmMvqr TTg+y7KNaNyrm6GuV2071vsFl6jPfle1cqzhdOkVVb3nXpRRtFRm879nv2Bf0qFNcSPLIg0rZ BLTnDo61thd9qDNAyZVUHDVuCD5g4j/4z6Pt7WF21WvSjv/C+uoPbiz5UX7oq5h6or0Ev5c+M eN9HwvnrUWcOqX+YKnCUJjH8R39hY8m5F2/HBIlPYL7tkUlBQOz0s66pO6aZtMwh+Pmv18LDY doTKhPXu/9XiyuGRa2IRYwJKumRIf4Q90vHpEj6xcXfRq3OvzPMicXnOXmCdS4pwQBqoUM0h9 ag0mivQ7F8Hwm9FerqkzFHvf2ctWYL07yiL96LzKvfzq+oPvSkWEs8ggxv14zvbFWuNA9qfZu 6+e8Kg== Received-SPF: pass client-ip=212.227.15.3; envelope-from=lukasstraub2@web.de; helo=mout.web.de X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 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, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org If the guest issues a discard during a block drain section, the blk_aio_pdiscard() may not be processed, but queued instead. And so the callback will never be called to issue the bh and decrease the BB in-flight number again. This causes a hang in the drain code, since it will wait forever for the BB in-flight counter to decrease. This reverts commit 7e5cdb34 "ide: Increment BB in-flight counter for TRIM BH" to fix this hang. The bug fixed by that commit will be fixed differently in the next commit. Signed-off-by: Lukas Straub --- hw/ide/core.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/hw/ide/core.c b/hw/ide/core.c index de48ff9f86..d172e70f1e 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -436,16 +436,12 @@ static const AIOCBInfo trim_aiocb_info = { static void ide_trim_bh_cb(void *opaque) { TrimAIOCB *iocb = opaque; - BlockBackend *blk = iocb->s->blk; iocb->common.cb(iocb->common.opaque, iocb->ret); qemu_bh_delete(iocb->bh); iocb->bh = NULL; qemu_aio_unref(iocb); - - /* Paired with an increment in ide_issue_trim() */ - blk_dec_in_flight(blk); } static void ide_issue_trim_cb(void *opaque, int ret) @@ -516,9 +512,6 @@ BlockAIOCB *ide_issue_trim( IDEDevice *dev = s->unit ? s->bus->slave : s->bus->master; TrimAIOCB *iocb; - /* Paired with a decrement in ide_trim_bh_cb() */ - blk_inc_in_flight(s->blk); - iocb = blk_aio_get(&trim_aiocb_info, s->blk, cb, cb_opaque); iocb->s = s; iocb->bh = qemu_bh_new_guarded(ide_trim_bh_cb, iocb,