{"id":2225817,"url":"http://patchwork.ozlabs.org/api/patches/2225817/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260421161132.99878-4-kwolf@redhat.com/","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/projects/14/?format=json","name":"QEMU Development","link_name":"qemu-devel","list_id":"qemu-devel.nongnu.org","list_email":"qemu-devel@nongnu.org","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20260421161132.99878-4-kwolf@redhat.com>","list_archive_url":null,"date":"2026-04-21T16:11:28","name":"[3/7] block: Add flags parameter to blk_*_pdiscard()","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"1c2f2c981ebb321e894a46b592973b2575aa3deb","submitter":{"id":2714,"url":"http://patchwork.ozlabs.org/api/people/2714/?format=json","name":"Kevin Wolf","email":"kwolf@redhat.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260421161132.99878-4-kwolf@redhat.com/mbox/","series":[{"id":500847,"url":"http://patchwork.ozlabs.org/api/series/500847/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/list/?series=500847","date":"2026-04-21T16:11:27","name":"ide: Fix deadlock between TRIM and drain","version":1,"mbox":"http://patchwork.ozlabs.org/series/500847/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2225817/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2225817/checks/","tags":{},"related":[],"headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=Ak03Jnnz;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists1p.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)"],"Received":["from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g0S8W6m7fz1yKF\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 22 Apr 2026 02:13:47 +1000 (AEST)","from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists1p.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1wFDiE-0001SU-C3; Tue, 21 Apr 2026 12:12:34 -0400","from eggs.gnu.org ([2001:470:142:3::10])\n by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <kwolf@redhat.com>) id 1wFDi3-0001PT-Nd\n for qemu-devel@nongnu.org; Tue, 21 Apr 2026 12:12:24 -0400","from us-smtp-delivery-124.mimecast.com ([170.10.129.124])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <kwolf@redhat.com>) id 1wFDhz-0000In-S6\n for qemu-devel@nongnu.org; Tue, 21 Apr 2026 12:12:23 -0400","from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com\n (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by\n relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n cipher=TLS_AES_256_GCM_SHA384) id us-mta-307-xx__dSBGOTqP3JBQmVcE7Q-1; Tue,\n 21 Apr 2026 12:12:09 -0400","from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com\n (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest\n SHA256)\n (No client certificate requested)\n by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS\n id 63DBA19560B7; Tue, 21 Apr 2026 16:12:08 +0000 (UTC)","from merkur.fritz.box (unknown [10.44.49.173])\n by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP\n id 9651D1800660; Tue, 21 Apr 2026 16:12:06 +0000 (UTC)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1776787938;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:cc:mime-version:mime-version:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=WhqC91BLULK2bubCupahOYep/yxmCAr4UDM1WsqQ1NI=;\n b=Ak03Jnnz2H0HfUHsuyHeepkQkN0noJe6qEh6AB9mh8iPgCgBjHoktho56OkDaVz2nqGG2t\n tukukMxIN2VNhBLAK7w/u0gkwTMQiMrSu7Ll4eMVmHWlMTMAMeWy/iK9Gy0l2WJDCeJ30d\n cAb75nqLgLbTmEIVPhOjGoQ2/eb8rlU=","X-MC-Unique":"xx__dSBGOTqP3JBQmVcE7Q-1","X-Mimecast-MFC-AGG-ID":"xx__dSBGOTqP3JBQmVcE7Q_1776787928","From":"Kevin Wolf <kwolf@redhat.com>","To":"qemu-block@nongnu.org","Cc":"kwolf@redhat.com, hreitz@redhat.com, jsnow@redhat.com,\n qemu-devel@nongnu.org, qemu-stable@nongnu.org","Subject":"[PATCH 3/7] block: Add flags parameter to blk_*_pdiscard()","Date":"Tue, 21 Apr 2026 18:11:28 +0200","Message-ID":"<20260421161132.99878-4-kwolf@redhat.com>","In-Reply-To":"<20260421161132.99878-1-kwolf@redhat.com>","References":"<20260421161132.99878-1-kwolf@redhat.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","X-Scanned-By":"MIMEDefang 3.4.1 on 10.30.177.111","Received-SPF":"pass client-ip=170.10.129.124; envelope-from=kwolf@redhat.com;\n helo=us-smtp-delivery-124.mimecast.com","X-Spam_score_int":"-20","X-Spam_score":"-2.1","X-Spam_bar":"--","X-Spam_report":"(-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001,\n DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,\n RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001,\n SPF_HELO_PASS=-0.001,\n SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no","X-Spam_action":"no action","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"qemu development <qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<https://lists.nongnu.org/archive/html/qemu-devel>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org"},"content":"All existing callers pass 0, but we need a way to pass BDRV_REQ_NO_QUEUE\nfor discard requests.\n\nSigned-off-by: Kevin Wolf <kwolf@redhat.com>\n---\n include/system/block-backend-io.h |  4 ++--\n block/block-backend.c             | 11 ++++++-----\n block/export/virtio-blk-handler.c |  2 +-\n block/mirror.c                    |  4 ++--\n nbd/server.c                      |  2 +-\n qemu-io-cmds.c                    |  2 +-\n tests/unit/test-block-iothread.c  |  4 ++--\n 7 files changed, 15 insertions(+), 14 deletions(-)","diff":"diff --git a/include/system/block-backend-io.h b/include/system/block-backend-io.h\nindex 0248c1c36e2..fd84723d9d0 100644\n--- a/include/system/block-backend-io.h\n+++ b/include/system/block-backend-io.h\n@@ -218,9 +218,9 @@ int co_wrapper_mixed blk_zone_append(BlockBackend *blk, int64_t *offset,\n                                          BdrvRequestFlags flags);\n \n int co_wrapper_mixed blk_pdiscard(BlockBackend *blk, int64_t offset,\n-                                  int64_t bytes);\n+                                  int64_t bytes, BdrvRequestFlags flags);\n int coroutine_fn blk_co_pdiscard(BlockBackend *blk, int64_t offset,\n-                                 int64_t bytes);\n+                                 int64_t bytes, BdrvRequestFlags flags);\n \n int co_wrapper_mixed blk_flush(BlockBackend *blk);\n int coroutine_fn blk_co_flush(BlockBackend *blk);\ndiff --git a/block/block-backend.c b/block/block-backend.c\nindex ee00440e28d..37ba7e9fc40 100644\n--- a/block/block-backend.c\n+++ b/block/block-backend.c\n@@ -1803,12 +1803,13 @@ BlockAIOCB *blk_aio_ioctl(BlockBackend *blk, unsigned long int req, void *buf,\n \n /* To be called between exactly one pair of blk_inc/dec_in_flight() */\n static int coroutine_fn\n-blk_co_do_pdiscard(BlockBackend *blk, int64_t offset, int64_t bytes)\n+blk_co_do_pdiscard(BlockBackend *blk, int64_t offset, int64_t bytes,\n+                   BdrvRequestFlags flags)\n {\n     int ret;\n     IO_CODE();\n \n-    blk_wait_while_drained(blk, 0);\n+    blk_wait_while_drained(blk, flags);\n     GRAPH_RDLOCK_GUARD();\n \n     ret = blk_check_byte_request(blk, offset, bytes);\n@@ -1824,7 +1825,7 @@ static void coroutine_fn blk_aio_pdiscard_entry(void *opaque)\n     BlkAioEmAIOCB *acb = opaque;\n     BlkRwCo *rwco = &acb->rwco;\n \n-    rwco->ret = blk_co_do_pdiscard(rwco->blk, rwco->offset, acb->bytes);\n+    rwco->ret = blk_co_do_pdiscard(rwco->blk, rwco->offset, acb->bytes, 0);\n     blk_aio_complete(acb);\n }\n \n@@ -1838,13 +1839,13 @@ BlockAIOCB *blk_aio_pdiscard(BlockBackend *blk,\n }\n \n int coroutine_fn blk_co_pdiscard(BlockBackend *blk, int64_t offset,\n-                                 int64_t bytes)\n+                                 int64_t bytes, BdrvRequestFlags flags)\n {\n     int ret;\n     IO_OR_GS_CODE();\n \n     blk_inc_in_flight(blk);\n-    ret = blk_co_do_pdiscard(blk, offset, bytes);\n+    ret = blk_co_do_pdiscard(blk, offset, bytes, flags);\n     blk_dec_in_flight(blk);\n \n     return ret;\ndiff --git a/block/export/virtio-blk-handler.c b/block/export/virtio-blk-handler.c\nindex 3dd6c43af1a..eaa6fc19067 100644\n--- a/block/export/virtio-blk-handler.c\n+++ b/block/export/virtio-blk-handler.c\n@@ -122,7 +122,7 @@ virtio_blk_discard_write_zeroes(VirtioBlkHandler *handler, struct iovec *iov,\n         }\n \n         if (blk_co_pdiscard(blk, sector << VIRTIO_BLK_SECTOR_BITS,\n-                            bytes) == 0) {\n+                            bytes, 0) == 0) {\n             return VIRTIO_BLK_S_OK;\n         }\n     }\ndiff --git a/block/mirror.c b/block/mirror.c\nindex 2fcded9e93d..089856f4a84 100644\n--- a/block/mirror.c\n+++ b/block/mirror.c\n@@ -454,7 +454,7 @@ static void coroutine_fn mirror_co_discard(void *opaque)\n     *op->bytes_handled = op->bytes;\n     op->is_in_flight = true;\n \n-    ret = blk_co_pdiscard(op->s->target, op->offset, op->bytes);\n+    ret = blk_co_pdiscard(op->s->target, op->offset, op->bytes, 0);\n     mirror_write_complete(op, ret);\n }\n \n@@ -1532,7 +1532,7 @@ do_sync_target_write(MirrorBlockJob *job, MirrorMethod method,\n                          zero_bitmap_end - zero_bitmap_offset);\n         }\n         assert(!qiov);\n-        ret = blk_co_pdiscard(job->target, offset, bytes);\n+        ret = blk_co_pdiscard(job->target, offset, bytes, 0);\n         break;\n \n     default:\ndiff --git a/nbd/server.c b/nbd/server.c\nindex 620097c58ca..78ec9844097 100644\n--- a/nbd/server.c\n+++ b/nbd/server.c\n@@ -2990,7 +2990,7 @@ static coroutine_fn int nbd_handle_request(NBDClient *client,\n                                       \"flush failed\", errp);\n \n     case NBD_CMD_TRIM:\n-        ret = blk_co_pdiscard(exp->common.blk, request->from, request->len);\n+        ret = blk_co_pdiscard(exp->common.blk, request->from, request->len, 0);\n         if (ret >= 0 && request->flags & NBD_CMD_FLAG_FUA) {\n             ret = blk_co_flush(exp->common.blk);\n         }\ndiff --git a/qemu-io-cmds.c b/qemu-io-cmds.c\nindex 13e03301624..f6d077908f2 100644\n--- a/qemu-io-cmds.c\n+++ b/qemu-io-cmds.c\n@@ -2201,7 +2201,7 @@ static int discard_f(BlockBackend *blk, int argc, char **argv)\n     }\n \n     clock_gettime(CLOCK_MONOTONIC, &t1);\n-    ret = blk_pdiscard(blk, offset, bytes);\n+    ret = blk_pdiscard(blk, offset, bytes, 0);\n     clock_gettime(CLOCK_MONOTONIC, &t2);\n \n     if (ret < 0) {\ndiff --git a/tests/unit/test-block-iothread.c b/tests/unit/test-block-iothread.c\nindex e26b3be5939..5273ff235a2 100644\n--- a/tests/unit/test-block-iothread.c\n+++ b/tests/unit/test-block-iothread.c\n@@ -270,11 +270,11 @@ static void test_sync_op_blk_pdiscard(BlockBackend *blk)\n     int ret;\n \n     /* Early success: UNMAP not supported */\n-    ret = blk_pdiscard(blk, 0, 512);\n+    ret = blk_pdiscard(blk, 0, 512, 0);\n     g_assert_cmpint(ret, ==, 0);\n \n     /* Early error: Negative offset */\n-    ret = blk_pdiscard(blk, -2, 512);\n+    ret = blk_pdiscard(blk, -2, 512, 0);\n     g_assert_cmpint(ret, ==, -EIO);\n }\n \n","prefixes":["3/7"]}