From nobody Sat May 30 18:34:27 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1779210262; cv=none; d=zohomail.com; s=zohoarc; b=hUdwRIyUWOnCBDdX6jCvijtg6P4WWzyJi6JAM0XkX2rfsyUVGkMdhCZOeIPT3zTFQO28qbrNsHKqnki36r5siP6V5+IQvHTXpIF9aMsS3THXvVY8U2VFn8tEESSGQw+WxuEuoZGsL3E176KJP2xqf0FGccf1RHHm6G7NH+KHSuA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779210262; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=EhiDhqiCb7FzuHBnUkHoGrC4DbGr7HjU+ndE2znl4j8=; b=lPZvwwqtCgucZbhmPiX+3I1UZj1eFXi7ooHD9Bcv4ZsgSqWXtEBhFhlOBX/DRjEHDvnAeS4Y39HTXPHgNokYkP3tZvCYL/oAsqOUHomT+IPjPmM/CTEC0eYSQzqmWAmvIcO8gyb+FdDId5rCWMFvYMI3GdTqYlTlOEXshIU78BY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1779210262263522.4575658723401; Tue, 19 May 2026 10:04:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wPNr9-0007zb-U8; Tue, 19 May 2026 13:03:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wPNr3-0007xm-8x for qemu-devel@nongnu.org; Tue, 19 May 2026 13:03:42 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wPNqw-00045x-Jy for qemu-devel@nongnu.org; Tue, 19 May 2026 13:03:40 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-153-NbqgNeN1OceaTsoiJBSCTw-1; Tue, 19 May 2026 13:03:31 -0400 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 363BE1956094; Tue, 19 May 2026 17:03:30 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.44.49.113]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7914B1684; Tue, 19 May 2026 17:03:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779210212; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EhiDhqiCb7FzuHBnUkHoGrC4DbGr7HjU+ndE2znl4j8=; b=aUZMMDaRHcef8HOrfEwFbdbEMLCvme5pJnXLfiAYeoIHA1Y3nyT/sUIGZNPukPPhLG2Xc0 Y+WL4Jn8JPnS8FcwEIUipgczCU9U41QEDlsXymZTKx4tyF8RmkSrVlAFtGiiOpQaGkRkL/ UWZkY4UpGS3U05ID8/yIEiGwq2/i810= X-MC-Unique: NbqgNeN1OceaTsoiJBSCTw-1 X-Mimecast-MFC-AGG-ID: NbqgNeN1OceaTsoiJBSCTw_1779210210 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 01/18] blkdebug: Add 'delay-ns' option Date: Tue, 19 May 2026 19:03:00 +0200 Message-ID: <20260519170317.345032-2-kwolf@redhat.com> In-Reply-To: <20260519170317.345032-1-kwolf@redhat.com> References: <20260519170317.345032-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1779210265650158500 Content-Type: text/plain; charset="utf-8" Sometimes reproducing a problem for debugging involves slow I/O, so let's add something to blkdebug to make I/O slow when we need it. This can be used either together with an error so that the request fails after the delay, or with errno=3D0, which allows the request to succeed after the delay. Signed-off-by: Kevin Wolf Message-ID: <20260421161132.99878-2-kwolf@redhat.com> Signed-off-by: Kevin Wolf --- qapi/block-core.json | 4 ++++ block/blkdebug.c | 15 ++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index 508b081ac16..0efd51787b4 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -3919,6 +3919,9 @@ # # @errno: error identifier (errno) to be returned; defaults to EIO # +# @delay-ns: request delay before completion in nanoseconds +# (default: 0, since: 11.1) +# # @sector: specifies the sector index which has to be affected in # order to actually trigger the event; defaults to "any sector" # @@ -3934,6 +3937,7 @@ '*state': 'int', '*iotype': 'BlkdebugIOType', '*errno': 'int', + '*delay-ns': 'int', '*sector': 'int', '*once': 'bool', '*immediately': 'bool' } } diff --git a/block/blkdebug.c b/block/blkdebug.c index fdc96d1f45d..78cc03746f0 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -95,6 +95,7 @@ typedef struct BlkdebugRule { int immediately; int once; int64_t offset; + int64_t delay_ns; } inject; struct { int new_state; @@ -144,6 +145,10 @@ static QemuOptsList inject_error_opts =3D { .name =3D "immediately", .type =3D QEMU_OPT_BOOL, }, + { + .name =3D "delay-ns", + .type =3D QEMU_OPT_NUMBER, + }, { /* end of list */ } }, }; @@ -216,6 +221,8 @@ static int add_rule(void *opaque, QemuOpts *opts, Error= **errp) rule->options.inject.once =3D qemu_opt_get_bool(opts, "once", 0); rule->options.inject.immediately =3D qemu_opt_get_bool(opts, "immediately", 0); + rule->options.inject.delay_ns =3D + qemu_opt_get_number(opts, "delay-ns", 0); sector =3D qemu_opt_get_number(opts, "sector", -1); rule->options.inject.offset =3D sector =3D=3D -1 ? -1 : sector * BDRV_SECTOR_SIZE; @@ -594,6 +601,7 @@ static int coroutine_fn rule_check(BlockDriverState *bs= , uint64_t offset, BlkdebugRule *rule; int error; bool immediately; + int64_t delay_ns; =20 qemu_mutex_lock(&s->lock); QSIMPLEQ_FOREACH(rule, &s->active_rules, active_next) { @@ -608,13 +616,14 @@ static int coroutine_fn rule_check(BlockDriverState *= bs, uint64_t offset, } } =20 - if (!rule || !rule->options.inject.error) { + if (!rule) { qemu_mutex_unlock(&s->lock); return 0; } =20 immediately =3D rule->options.inject.immediately; error =3D rule->options.inject.error; + delay_ns =3D rule->options.inject.delay_ns; =20 if (rule->options.inject.once) { QSIMPLEQ_REMOVE(&s->active_rules, rule, BlkdebugRule, active_next); @@ -622,6 +631,10 @@ static int coroutine_fn rule_check(BlockDriverState *b= s, uint64_t offset, } =20 qemu_mutex_unlock(&s->lock); + + if (delay_ns) { + qemu_co_sleep_ns(QEMU_CLOCK_REALTIME, delay_ns); + } if (!immediately) { aio_co_schedule(qemu_get_current_aio_context(), qemu_coroutine_sel= f()); qemu_coroutine_yield(); --=20 2.54.0 From nobody Sat May 30 18:34:27 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1779210423; cv=none; d=zohomail.com; s=zohoarc; b=RhTFNpMRUuixNg+ErxrKT6Cucq7yE95mBHeFLIwnQunxMx31XJRrJBJUucow55AZUIXDRIJ8RgzfBrEhkMrdiz5a+SmRlPE20m6GPLibefFfM/GIqOsJb3DlrzmVYNew0f/cQnq0RCwL6k9/kSkn6mjKucO+aTlW8wZfuU06bMs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779210423; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=cMT/antuLqZyS5oYFLZbd0Cv7OFEzbG2EjWvbMi6YI4=; b=Kp7gqjVI1LBeFahMXt7B6LBEbOGS3s0Gq5Yh8EAe/3d3jlR6Z4og/ZJrrHVhV2zsqNdzQ7pxdzD8cDV3fHwk5/XevU+6H6bCgIBE85UuAvsGGAPs2wfasFB8B0cTbAXGsRya1bPVmUxik/AC/cz/w7LvC20b3eDQ8V8ykwhNpE8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 177921042366144.53316029682401; Tue, 19 May 2026 10:07:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wPNrD-00082M-H3; Tue, 19 May 2026 13:03:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wPNr5-0007yL-8w for qemu-devel@nongnu.org; Tue, 19 May 2026 13:03:46 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wPNr0-0004CG-B9 for qemu-devel@nongnu.org; Tue, 19 May 2026 13:03:41 -0400 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-486-svxVMi4uNMOV_Vt8mxt83Q-1; Tue, 19 May 2026 13:03:33 -0400 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 01D0D19560A7; Tue, 19 May 2026 17:03:32 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.44.49.113]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A23E81681; Tue, 19 May 2026 17:03:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779210216; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cMT/antuLqZyS5oYFLZbd0Cv7OFEzbG2EjWvbMi6YI4=; b=c/yJRTFanzOmjU0U9LFYyxZOUUsgzwxl8y6RVMMNcIeyuJ4hudV6okucCxNsgdknA3Dm4X 72Y5EWCKAvTscDMFkZ1EmHIPFGhVmzzyWIzartvAmakCtguREYsjS/c1ipNqtAZEsb/jdR Qoiwvkd6jrkKrZSsENCTo+PopsxKtm8= X-MC-Unique: svxVMi4uNMOV_Vt8mxt83Q-1 X-Mimecast-MFC-AGG-ID: svxVMi4uNMOV_Vt8mxt83Q_1779210212 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 02/18] block: Add blk_co_start/end_request() and BDRV_REQ_NO_QUEUE Date: Tue, 19 May 2026 19:03:01 +0200 Message-ID: <20260519170317.345032-3-kwolf@redhat.com> In-Reply-To: <20260519170317.345032-1-kwolf@redhat.com> References: <20260519170317.345032-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1779210424884154100 Content-Type: text/plain; charset="utf-8" If a device uses blk_inc/dec_in_flight() in order to build macro operations that involve multiple requests for the block layer and that need to be completed as a unit before the BlockBackend can be considered drained, it sets the stage for a deadlock: When a drain is requested, the inner request at the BlockBackend level will be queued in blk_wait_while_drained() and wait until the drained section ends, but at the same time, drain_begin can only return if the whole macro operation at the device level has completed. Introduce a new interface to allow implementing the logic correctly: Instead of queueing individual requests, blk_co_start_request() calls blk_wait_while_drained() once at the beginning. The individual requests must then set BDRV_REQ_NO_QUEUE to avoid being queued and running into the deadlock; being wrapped in blk_co_start/end_request() makes sure that drain_begin waits for them and they don't sneak in when the BlockBackend is supposed to already be quiescent. Signed-off-by: Kevin Wolf Message-ID: <20260421161132.99878-3-kwolf@redhat.com> Signed-off-by: Kevin Wolf --- include/block/block-common.h | 11 ++++++++- include/system/block-backend-io.h | 2 ++ block/block-backend.c | 38 +++++++++++++++++++++++-------- 3 files changed, 41 insertions(+), 10 deletions(-) diff --git a/include/block/block-common.h b/include/block/block-common.h index c8c626daeaa..895ea175413 100644 --- a/include/block/block-common.h +++ b/include/block/block-common.h @@ -215,8 +215,17 @@ typedef enum { */ BDRV_REQ_NO_WAIT =3D 0x400, =20 + /* + * Used between blk_co_start_request() and blk_end_request() to avoid + * that the request waits in a drained BlockBackend until the drained + * section ends. Waiting would cause a deadlock because drain waits for + * blk_end_request() to be called, but the request never completes + * because it waits for the drain to end. + */ + BDRV_REQ_NO_QUEUE =3D 0x800, + /* Mask of valid flags */ - BDRV_REQ_MASK =3D 0x7ff, + BDRV_REQ_MASK =3D 0xfff, } BdrvRequestFlags; =20 #define BDRV_O_NO_SHARE 0x0001 /* don't share permissions */ diff --git a/include/system/block-backend-io.h b/include/system/block-backe= nd-io.h index 6d5ac476fc0..0248c1c36e2 100644 --- a/include/system/block-backend-io.h +++ b/include/system/block-backend-io.h @@ -71,6 +71,8 @@ BlockAIOCB *blk_aio_ioctl(BlockBackend *blk, unsigned lon= g int req, void *buf, =20 void blk_inc_in_flight(BlockBackend *blk); void blk_dec_in_flight(BlockBackend *blk); +void coroutine_fn blk_co_start_request(BlockBackend *blk); +void blk_end_request(BlockBackend *blk); =20 bool coroutine_fn GRAPH_RDLOCK blk_co_is_inserted(BlockBackend *blk); bool co_wrapper_mixed_bdrv_rdlock blk_is_inserted(BlockBackend *blk); diff --git a/block/block-backend.c b/block/block-backend.c index 99446571201..ee00440e28d 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -82,6 +82,7 @@ struct BlockBackend { QemuMutex queued_requests_lock; /* protects queued_requests */ CoQueue queued_requests; bool disable_request_queuing; /* atomic */ + int start_request_count; /* atomic */ =20 VMChangeStateEntry *vmsh; bool force_allow_inactivate; @@ -1306,10 +1307,16 @@ bool blk_in_drain(BlockBackend *blk) } =20 /* To be called between exactly one pair of blk_inc/dec_in_flight() */ -static void coroutine_fn blk_wait_while_drained(BlockBackend *blk) +static void coroutine_fn blk_wait_while_drained(BlockBackend *blk, + BdrvRequestFlags flags) { assert(blk->in_flight > 0); =20 + if (flags & BDRV_REQ_NO_QUEUE) { + assert(qatomic_read(&blk->start_request_count)); + return; + } + if (qatomic_read(&blk->quiesce_counter) && !qatomic_read(&blk->disable_request_queuing)) { /* @@ -1335,7 +1342,7 @@ blk_co_do_preadv_part(BlockBackend *blk, int64_t offs= et, int64_t bytes, BlockDriverState *bs; IO_CODE(); =20 - blk_wait_while_drained(blk); + blk_wait_while_drained(blk, flags); GRAPH_RDLOCK_GUARD(); =20 /* Call blk_bs() only after waiting, the graph may have changed */ @@ -1410,7 +1417,7 @@ blk_co_do_pwritev_part(BlockBackend *blk, int64_t off= set, int64_t bytes, BlockDriverState *bs; IO_CODE(); =20 - blk_wait_while_drained(blk); + blk_wait_while_drained(blk, flags); GRAPH_RDLOCK_GUARD(); =20 /* Call blk_bs() only after waiting, the graph may have changed */ @@ -1523,6 +1530,19 @@ void blk_dec_in_flight(BlockBackend *blk) aio_wait_kick(); } =20 +void coroutine_fn blk_co_start_request(BlockBackend *blk) +{ + blk_inc_in_flight(blk); + blk_wait_while_drained(blk, 0); + qatomic_inc(&blk->start_request_count); +} + +void blk_end_request(BlockBackend *blk) +{ + qatomic_dec(&blk->start_request_count); + blk_dec_in_flight(blk); +} + static void error_callback_bh(void *opaque) { struct BlockBackendAIOCB *acb =3D opaque; @@ -1741,7 +1761,7 @@ blk_co_do_ioctl(BlockBackend *blk, unsigned long int = req, void *buf) { IO_CODE(); =20 - blk_wait_while_drained(blk); + blk_wait_while_drained(blk, 0); GRAPH_RDLOCK_GUARD(); =20 if (!blk_co_is_available(blk)) { @@ -1788,7 +1808,7 @@ blk_co_do_pdiscard(BlockBackend *blk, int64_t offset,= int64_t bytes) int ret; IO_CODE(); =20 - blk_wait_while_drained(blk); + blk_wait_while_drained(blk, 0); GRAPH_RDLOCK_GUARD(); =20 ret =3D blk_check_byte_request(blk, offset, bytes); @@ -1834,7 +1854,7 @@ int coroutine_fn blk_co_pdiscard(BlockBackend *blk, i= nt64_t offset, static int coroutine_fn blk_co_do_flush(BlockBackend *blk) { IO_CODE(); - blk_wait_while_drained(blk); + blk_wait_while_drained(blk, 0); GRAPH_RDLOCK_GUARD(); =20 if (!blk_co_is_available(blk)) { @@ -2009,7 +2029,7 @@ int coroutine_fn blk_co_zone_report(BlockBackend *blk= , int64_t offset, IO_CODE(); =20 blk_inc_in_flight(blk); /* increase before waiting */ - blk_wait_while_drained(blk); + blk_wait_while_drained(blk, 0); GRAPH_RDLOCK_GUARD(); if (!blk_is_available(blk)) { blk_dec_in_flight(blk); @@ -2034,7 +2054,7 @@ int coroutine_fn blk_co_zone_mgmt(BlockBackend *blk, = BlockZoneOp op, IO_CODE(); =20 blk_inc_in_flight(blk); - blk_wait_while_drained(blk); + blk_wait_while_drained(blk, 0); GRAPH_RDLOCK_GUARD(); =20 ret =3D blk_check_byte_request(blk, offset, len); @@ -2058,7 +2078,7 @@ int coroutine_fn blk_co_zone_append(BlockBackend *blk= , int64_t *offset, IO_CODE(); =20 blk_inc_in_flight(blk); - blk_wait_while_drained(blk); + blk_wait_while_drained(blk, flags); GRAPH_RDLOCK_GUARD(); if (!blk_is_available(blk)) { blk_dec_in_flight(blk); --=20 2.54.0 From nobody Sat May 30 18:34:27 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1779210377; cv=none; d=zohomail.com; s=zohoarc; b=BLUYxYMa4P0Ifp1dPRD30j912gFK9QfcddqR/jhjMNtnEEPZPrxjh5FbkanZIFWgNlXaXpyOgViYS4+keyVUJAxiA/ZaqCzfZwY7KurZIE3qnJ+yCtWmF+1l1nRaD6IRJwfGDpIPY7B45y/P2ehpkHiNCJcZJCw61HMA91sdXVg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779210377; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=vV8PFEFEtrlmZr6WQFB2vue7IYo/JWXPVjwWM9yU1fk=; b=Mw5dq1Idpi7/cpxCGU19W7o6O7wDqld3jrYmn2LYpQxcV7XUKpMEGXDV7h51KcMbbYT+metqqYsQCPkvBuqm3T+88h6WqP29iADBbsZ9rXVKVveo4eZ60hP8e4bfibGZ8xKox7xmWdLnt6xrSZwwOEqILTNR0SO3rBbAecUgJnE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1779210377803456.227663363529; Tue, 19 May 2026 10:06:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wPNrB-00080s-NV; Tue, 19 May 2026 13:03:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wPNr5-0007yM-IT for qemu-devel@nongnu.org; Tue, 19 May 2026 13:03:46 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wPNr1-0004CM-8J for qemu-devel@nongnu.org; Tue, 19 May 2026 13:03:42 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-421-Y-eNIkPlOUyAAwZf2BzdeQ-1; Tue, 19 May 2026 13:03:34 -0400 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E4FD719560B5; Tue, 19 May 2026 17:03:33 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.44.49.113]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 940901681; Tue, 19 May 2026 17:03:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779210216; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vV8PFEFEtrlmZr6WQFB2vue7IYo/JWXPVjwWM9yU1fk=; b=X3Fn7YGoCKqygnnn1FZTx/wEfCr+nltj0AqjrIUFqqtPJAaOIcjzOBpgs8Z5i/KA9NYfrp 89nnLf7ZfshE1dl9+ZPpDj41LvV6sT0kX1qPWmRKe8mh4l5J8NaSkQjbxLqy9w/KKIUdpk y1aE5uF/AU6nGGhreh6Y8OcFR2ChOAw= X-MC-Unique: Y-eNIkPlOUyAAwZf2BzdeQ-1 X-Mimecast-MFC-AGG-ID: Y-eNIkPlOUyAAwZf2BzdeQ_1779210214 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 03/18] block: Add flags parameter to blk_*_pdiscard() Date: Tue, 19 May 2026 19:03:02 +0200 Message-ID: <20260519170317.345032-4-kwolf@redhat.com> In-Reply-To: <20260519170317.345032-1-kwolf@redhat.com> References: <20260519170317.345032-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1779210378676158500 Content-Type: text/plain; charset="utf-8" All existing callers pass 0, but we need a way to pass BDRV_REQ_NO_QUEUE for discard requests. Signed-off-by: Kevin Wolf Message-ID: <20260421161132.99878-4-kwolf@redhat.com> Signed-off-by: Kevin Wolf --- include/system/block-backend-io.h | 4 ++-- block/block-backend.c | 11 ++++++----- block/export/virtio-blk-handler.c | 2 +- block/mirror.c | 4 ++-- nbd/server.c | 2 +- qemu-io-cmds.c | 2 +- tests/unit/test-block-iothread.c | 4 ++-- 7 files changed, 15 insertions(+), 14 deletions(-) diff --git a/include/system/block-backend-io.h b/include/system/block-backe= nd-io.h index 0248c1c36e2..fd84723d9d0 100644 --- a/include/system/block-backend-io.h +++ b/include/system/block-backend-io.h @@ -218,9 +218,9 @@ int co_wrapper_mixed blk_zone_append(BlockBackend *blk,= int64_t *offset, BdrvRequestFlags flags); =20 int co_wrapper_mixed blk_pdiscard(BlockBackend *blk, int64_t offset, - int64_t bytes); + int64_t bytes, BdrvRequestFlags flags); int coroutine_fn blk_co_pdiscard(BlockBackend *blk, int64_t offset, - int64_t bytes); + int64_t bytes, BdrvRequestFlags flags); =20 int co_wrapper_mixed blk_flush(BlockBackend *blk); int coroutine_fn blk_co_flush(BlockBackend *blk); diff --git a/block/block-backend.c b/block/block-backend.c index ee00440e28d..37ba7e9fc40 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -1803,12 +1803,13 @@ BlockAIOCB *blk_aio_ioctl(BlockBackend *blk, unsign= ed long int req, void *buf, =20 /* To be called between exactly one pair of blk_inc/dec_in_flight() */ static int coroutine_fn -blk_co_do_pdiscard(BlockBackend *blk, int64_t offset, int64_t bytes) +blk_co_do_pdiscard(BlockBackend *blk, int64_t offset, int64_t bytes, + BdrvRequestFlags flags) { int ret; IO_CODE(); =20 - blk_wait_while_drained(blk, 0); + blk_wait_while_drained(blk, flags); GRAPH_RDLOCK_GUARD(); =20 ret =3D blk_check_byte_request(blk, offset, bytes); @@ -1824,7 +1825,7 @@ static void coroutine_fn blk_aio_pdiscard_entry(void = *opaque) BlkAioEmAIOCB *acb =3D opaque; BlkRwCo *rwco =3D &acb->rwco; =20 - rwco->ret =3D blk_co_do_pdiscard(rwco->blk, rwco->offset, acb->bytes); + rwco->ret =3D blk_co_do_pdiscard(rwco->blk, rwco->offset, acb->bytes, = 0); blk_aio_complete(acb); } =20 @@ -1838,13 +1839,13 @@ BlockAIOCB *blk_aio_pdiscard(BlockBackend *blk, } =20 int coroutine_fn blk_co_pdiscard(BlockBackend *blk, int64_t offset, - int64_t bytes) + int64_t bytes, BdrvRequestFlags flags) { int ret; IO_OR_GS_CODE(); =20 blk_inc_in_flight(blk); - ret =3D blk_co_do_pdiscard(blk, offset, bytes); + ret =3D blk_co_do_pdiscard(blk, offset, bytes, flags); blk_dec_in_flight(blk); =20 return ret; diff --git a/block/export/virtio-blk-handler.c b/block/export/virtio-blk-ha= ndler.c index 3dd6c43af1a..eaa6fc19067 100644 --- a/block/export/virtio-blk-handler.c +++ b/block/export/virtio-blk-handler.c @@ -122,7 +122,7 @@ virtio_blk_discard_write_zeroes(VirtioBlkHandler *handl= er, struct iovec *iov, } =20 if (blk_co_pdiscard(blk, sector << VIRTIO_BLK_SECTOR_BITS, - bytes) =3D=3D 0) { + bytes, 0) =3D=3D 0) { return VIRTIO_BLK_S_OK; } } diff --git a/block/mirror.c b/block/mirror.c index 2fcded9e93d..089856f4a84 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -454,7 +454,7 @@ static void coroutine_fn mirror_co_discard(void *opaque) *op->bytes_handled =3D op->bytes; op->is_in_flight =3D true; =20 - ret =3D blk_co_pdiscard(op->s->target, op->offset, op->bytes); + ret =3D blk_co_pdiscard(op->s->target, op->offset, op->bytes, 0); mirror_write_complete(op, ret); } =20 @@ -1532,7 +1532,7 @@ do_sync_target_write(MirrorBlockJob *job, MirrorMetho= d method, zero_bitmap_end - zero_bitmap_offset); } assert(!qiov); - ret =3D blk_co_pdiscard(job->target, offset, bytes); + ret =3D blk_co_pdiscard(job->target, offset, bytes, 0); break; =20 default: diff --git a/nbd/server.c b/nbd/server.c index 620097c58ca..78ec9844097 100644 --- a/nbd/server.c +++ b/nbd/server.c @@ -2990,7 +2990,7 @@ static coroutine_fn int nbd_handle_request(NBDClient = *client, "flush failed", errp); =20 case NBD_CMD_TRIM: - ret =3D blk_co_pdiscard(exp->common.blk, request->from, request->l= en); + ret =3D blk_co_pdiscard(exp->common.blk, request->from, request->l= en, 0); if (ret >=3D 0 && request->flags & NBD_CMD_FLAG_FUA) { ret =3D blk_co_flush(exp->common.blk); } diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c index 13e03301624..f6d077908f2 100644 --- a/qemu-io-cmds.c +++ b/qemu-io-cmds.c @@ -2201,7 +2201,7 @@ static int discard_f(BlockBackend *blk, int argc, cha= r **argv) } =20 clock_gettime(CLOCK_MONOTONIC, &t1); - ret =3D blk_pdiscard(blk, offset, bytes); + ret =3D blk_pdiscard(blk, offset, bytes, 0); clock_gettime(CLOCK_MONOTONIC, &t2); =20 if (ret < 0) { diff --git a/tests/unit/test-block-iothread.c b/tests/unit/test-block-iothr= ead.c index e26b3be5939..5273ff235a2 100644 --- a/tests/unit/test-block-iothread.c +++ b/tests/unit/test-block-iothread.c @@ -270,11 +270,11 @@ static void test_sync_op_blk_pdiscard(BlockBackend *b= lk) int ret; =20 /* Early success: UNMAP not supported */ - ret =3D blk_pdiscard(blk, 0, 512); + ret =3D blk_pdiscard(blk, 0, 512, 0); g_assert_cmpint(ret, =3D=3D, 0); =20 /* Early error: Negative offset */ - ret =3D blk_pdiscard(blk, -2, 512); + ret =3D blk_pdiscard(blk, -2, 512, 0); g_assert_cmpint(ret, =3D=3D, -EIO); } =20 --=20 2.54.0 From nobody Sat May 30 18:34:27 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1779210428; cv=none; d=zohomail.com; s=zohoarc; b=W9BJExl9Ji/U7qKeZ5VobWkSg3/lQpa8wDbtAYZPWNClW+2/rUwDxDw86Udp5pJm2C0DyRSZBcQyu5Y/yvK5MXaOjU8xdh4pZIAmOIK+rBmsd5gDj0O6d7eW4gLM8DpYG2+gGp8OTwjl1+vgpIvMnw+RUQWBthRwiE+rYyIx6+M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779210428; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=YoBzQot0sIcD2pxlSnw/1cyTfsK6JfUvPYD6dpUYLPY=; b=BXpd3A+GdB8YgDHh6R4HikamQkbQM7zWjz41laTW/vTEpIGm5pyT9c09FbAG0xSVGSNIpglPZokSxhx4tGILVbWFtml7gT6X33t/XwI4xRPUkpLOFixewnPnqiA0Nwnq9MX7Jok6SWjrPR+SrdOUy0ceurHym0P6Oac/YejFNvQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1779210428866131.9573126557533; Tue, 19 May 2026 10:07:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wPNrA-00080f-P9; Tue, 19 May 2026 13:03:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wPNr7-0007yb-CI for qemu-devel@nongnu.org; Tue, 19 May 2026 13:03:46 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wPNr3-0004De-Sg for qemu-devel@nongnu.org; Tue, 19 May 2026 13:03:43 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-207-yUXzXlhIOaGYexewPeBzqw-1; Tue, 19 May 2026 13:03:36 -0400 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A849018002C7; Tue, 19 May 2026 17:03:35 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.44.49.113]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 57FC91681; Tue, 19 May 2026 17:03:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779210220; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YoBzQot0sIcD2pxlSnw/1cyTfsK6JfUvPYD6dpUYLPY=; b=guxbeTc/cLLWhCkPYk5gtn/EyyWBeCzjgz6mSGKqEBjJJmbUPn5QzdQtvXR99t6JzHwVYi DJQQs6nfb7iAct6RQhlIID4d7mPXJUig/a5vX4x2nX1itW3/lINaFbsiFp3Yc2LmQKYePq 9dLZBim8MfGTuZg00/EGqda0zdcgz0s= X-MC-Unique: yUXzXlhIOaGYexewPeBzqw-1 X-Mimecast-MFC-AGG-ID: yUXzXlhIOaGYexewPeBzqw_1779210215 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 04/18] ide: Minimal fix for deadlock between TRIM and drain Date: Tue, 19 May 2026 19:03:03 +0200 Message-ID: <20260519170317.345032-5-kwolf@redhat.com> In-Reply-To: <20260519170317.345032-1-kwolf@redhat.com> References: <20260519170317.345032-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1779210429389158500 Content-Type: text/plain; charset="utf-8" The implementation of TRIM in IDE can chain multiple discard requests and uses blk_inc/dec_in_flight() to make sure that the whole TRIM operation has completed when the device needs to be quiescent (e.g. for the drain when performing an IDE reset, it would be bad if an IDE request like TRIM were still in flight). The problem is that each drain request calls blk_wait_while_drained() and when draining, it waits until the drained section ends. At the same time, drain_begin can only return if the whole TRIM operation has completed. This is a classic deadlock. Use blk_co_start/end_request() and BDRV_REQ_NO_QUEUE to avoid the problem. This requires moving the TRIM state machine to a coroutine. This commit does the minimal conversion so that we do have a coroutine that works for the fix, but it still looks much like a callback-based implementation. This will be cleaned up in the next patch. Cc: qemu-stable@nongnu.org Fixes: 7e5cdb345f77 ('ide: Increment BB in-flight counter for TRIM BH') Buglink: https://redhat.atlassian.net/browse/RHEL-121686 Signed-off-by: Kevin Wolf Message-ID: <20260421161132.99878-5-kwolf@redhat.com> Signed-off-by: Kevin Wolf --- hw/ide/core.c | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/hw/ide/core.c b/hw/ide/core.c index 7a15d6cac9b..48359c934c1 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -420,7 +420,6 @@ typedef struct TrimAIOCB { QEMUBH *bh; int ret; QEMUIOVector *qiov; - BlockAIOCB *aiocb; int i, j; } TrimAIOCB; =20 @@ -433,11 +432,6 @@ static void trim_aio_cancel(BlockAIOCB *acb) iocb->i =3D (iocb->qiov->iov[iocb->j].iov_len / 8) - 1; =20 iocb->ret =3D -ECANCELED; - - if (iocb->aiocb) { - blk_aio_cancel_async(iocb->aiocb); - iocb->aiocb =3D NULL; - } } =20 static const AIOCBInfo trim_aiocb_info =3D { @@ -456,15 +450,20 @@ static void ide_trim_bh_cb(void *opaque) iocb->bh =3D NULL; qemu_aio_unref(iocb); =20 - /* Paired with an increment in ide_issue_trim() */ - blk_dec_in_flight(blk); + /* Paired with blk_co_start_request in ide_trim_co_entry() */ + blk_end_request(blk); } =20 -static void ide_issue_trim_cb(void *opaque, int ret) +static void coroutine_fn ide_trim_co_entry(void *opaque) { TrimAIOCB *iocb =3D opaque; IDEState *s =3D iocb->s; + int ret =3D 0; + + /* Paired with blk_end_request in ide_trim_bh_cb() */ + blk_co_start_request(s->blk); =20 +loop: if (iocb->i >=3D 0) { if (ret >=3D 0) { block_acct_done(blk_get_stats(s->blk), &s->acct); @@ -499,11 +498,11 @@ static void ide_issue_trim_cb(void *opaque, int ret) count << BDRV_SECTOR_BITS, BLOCK_ACCT_UNM= AP); =20 /* Got an entry! Submit and exit. */ - iocb->aiocb =3D blk_aio_pdiscard(s->blk, - sector << BDRV_SECTOR_BITS, - count << BDRV_SECTOR_BITS, - ide_issue_trim_cb, opaque); - return; + ret =3D blk_co_pdiscard(s->blk, + sector << BDRV_SECTOR_BITS, + count << BDRV_SECTOR_BITS, + BDRV_REQ_NO_QUEUE); + goto loop; } =20 iocb->j++; @@ -514,7 +513,6 @@ static void ide_issue_trim_cb(void *opaque, int ret) } =20 done: - iocb->aiocb =3D NULL; if (iocb->bh) { replay_bh_schedule_event(iocb->bh); } @@ -527,9 +525,7 @@ BlockAIOCB *ide_issue_trim( IDEState *s =3D opaque; IDEDevice *dev =3D 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); + Coroutine *co; =20 iocb =3D blk_aio_get(&trim_aiocb_info, s->blk, cb, cb_opaque); iocb->s =3D s; @@ -539,7 +535,10 @@ BlockAIOCB *ide_issue_trim( iocb->qiov =3D qiov; iocb->i =3D -1; iocb->j =3D 0; - ide_issue_trim_cb(iocb, 0); + + co =3D qemu_coroutine_create(ide_trim_co_entry, iocb); + aio_co_enter(qemu_get_current_aio_context(), co); + return &iocb->common; } =20 --=20 2.54.0 From nobody Sat May 30 18:34:27 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1779210270; cv=none; d=zohomail.com; s=zohoarc; b=lMBZi2vEiT/LuMoXr7zbnkmqHxLEnnn68n9KnQVaTRZ0e6iDbG0roIRJrki8R0OU0oUAdm0gO05UZzW/qzpOPw1Z3BwY1LTgwqadzNJSA1eqzfpfAPasZ4nBeULTmci6sxgPo13K/QRmY6lmtefOqpytWm50ekaJOirLdXIbYUA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779210270; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=BCw1sY5/4UwF3/QxeUg8BO5jofp0826otZOMGqdzcdA=; b=UXOoxcEs8tKPnnmuomonkp9e3YCJ4n+IwhKoHy1bxs5NpOOLsmlYttmZTX7uk8+oZJ6ZL5+eTjV9HRhn5LNAq6CpO9I9J5Vlt3YYF+hP+sInL/KSHfyqd7wI3hD6Rxva4CXrVgLN3TyLqmBq8/70xyc2IaIqeW8p2BEXfQcQEp0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1779210270718383.30651806054425; Tue, 19 May 2026 10:04:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wPNrF-00083t-Bh; Tue, 19 May 2026 13:03:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wPNr8-0007yl-W6 for qemu-devel@nongnu.org; Tue, 19 May 2026 13:03:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wPNr5-0004Dp-56 for qemu-devel@nongnu.org; Tue, 19 May 2026 13:03:45 -0400 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-338-2yLXxW8ROMeqtyoIqNgdPw-1; Tue, 19 May 2026 13:03:38 -0400 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 81A7319560A1; Tue, 19 May 2026 17:03:37 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.44.49.113]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 1C6061684; Tue, 19 May 2026 17:03:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779210222; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BCw1sY5/4UwF3/QxeUg8BO5jofp0826otZOMGqdzcdA=; b=Z5YaSEu7+fHj5h9Ke+uuw2KMldARVdld2kCuVqCATkDKDJI94GZyaYA4bhSfdpcRxrwNbR MFDVCKR26ufpmMyo8A06iEPaiELyPbLvYJAeMjk7nhpuuCVLkJ+9+8hVmaOftZW/S+Fmge wnOwW+iSoji9kaAUuovU8vc6L5VsmlE= X-MC-Unique: 2yLXxW8ROMeqtyoIqNgdPw-1 X-Mimecast-MFC-AGG-ID: 2yLXxW8ROMeqtyoIqNgdPw_1779210217 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 05/18] ide: Clean up ide_trim_co_entry() to be idiomatic coroutine code Date: Tue, 19 May 2026 19:03:04 +0200 Message-ID: <20260519170317.345032-6-kwolf@redhat.com> In-Reply-To: <20260519170317.345032-1-kwolf@redhat.com> References: <20260519170317.345032-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1779210273141158500 Content-Type: text/plain; charset="utf-8" The previous commit did a minimal conversion of the callback based state machine for TRIM to a coroutine in order to fix a bug. Refactor it to actually look like normal coroutine based code, which improves its readability. Signed-off-by: Kevin Wolf Message-ID: <20260421161132.99878-6-kwolf@redhat.com> Signed-off-by: Kevin Wolf --- hw/ide/core.c | 87 +++++++++++++++++++++++---------------------------- 1 file changed, 39 insertions(+), 48 deletions(-) diff --git a/hw/ide/core.c b/hw/ide/core.c index 48359c934c1..f78b00220b8 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -420,18 +420,15 @@ typedef struct TrimAIOCB { QEMUBH *bh; int ret; QEMUIOVector *qiov; - int i, j; + bool canceled; } TrimAIOCB; =20 static void trim_aio_cancel(BlockAIOCB *acb) { TrimAIOCB *iocb =3D container_of(acb, TrimAIOCB, common); =20 - /* Exit the loop so ide_issue_trim_cb will not continue */ - iocb->j =3D iocb->qiov->niov - 1; - iocb->i =3D (iocb->qiov->iov[iocb->j].iov_len / 8) - 1; - - iocb->ret =3D -ECANCELED; + /* Exit the loop so ide_trim_co_entry will not continue */ + iocb->canceled =3D true; } =20 static const AIOCBInfo trim_aiocb_info =3D { @@ -458,60 +455,55 @@ static void coroutine_fn ide_trim_co_entry(void *opaq= ue) { TrimAIOCB *iocb =3D opaque; IDEState *s =3D iocb->s; - int ret =3D 0; + int i, j; + int ret; =20 /* Paired with blk_end_request in ide_trim_bh_cb() */ blk_co_start_request(s->blk); =20 -loop: - if (iocb->i >=3D 0) { - if (ret >=3D 0) { - block_acct_done(blk_get_stats(s->blk), &s->acct); - } else { - block_acct_failed(blk_get_stats(s->blk), &s->acct); - } - } + for (j =3D 0; j < iocb->qiov->niov; j++) { + for (i =3D 0; i < iocb->qiov->iov[j].iov_len / 8; i++) { + uint64_t *buffer =3D iocb->qiov->iov[j].iov_base; =20 - if (ret >=3D 0) { - while (iocb->j < iocb->qiov->niov) { - int j =3D iocb->j; - while (++iocb->i < iocb->qiov->iov[j].iov_len / 8) { - int i =3D iocb->i; - uint64_t *buffer =3D iocb->qiov->iov[j].iov_base; + /* 6-byte LBA + 2-byte range per entry */ + uint64_t entry =3D le64_to_cpu(buffer[i]); + uint64_t sector =3D entry & 0x0000ffffffffffffULL; + uint16_t count =3D entry >> 48; =20 - /* 6-byte LBA + 2-byte range per entry */ - uint64_t entry =3D le64_to_cpu(buffer[i]); - uint64_t sector =3D entry & 0x0000ffffffffffffULL; - uint16_t count =3D entry >> 48; + if (count =3D=3D 0) { + continue; + } =20 - if (count =3D=3D 0) { - continue; - } + if (iocb->canceled) { + iocb->ret =3D -ECANCELED; + goto done; + } =20 - if (!ide_sect_range_ok(s, sector, count)) { - block_acct_invalid(blk_get_stats(s->blk), BLOCK_ACCT_U= NMAP); - iocb->ret =3D -EINVAL; - goto done; - } + if (!ide_sect_range_ok(s, sector, count)) { + block_acct_invalid(blk_get_stats(s->blk), BLOCK_ACCT_UNMAP= ); + iocb->ret =3D -EINVAL; + goto done; + } =20 - block_acct_start(blk_get_stats(s->blk), &s->acct, - count << BDRV_SECTOR_BITS, BLOCK_ACCT_UNM= AP); + block_acct_start(blk_get_stats(s->blk), &s->acct, + count << BDRV_SECTOR_BITS, BLOCK_ACCT_UNMAP); =20 - /* Got an entry! Submit and exit. */ - ret =3D blk_co_pdiscard(s->blk, - sector << BDRV_SECTOR_BITS, - count << BDRV_SECTOR_BITS, - BDRV_REQ_NO_QUEUE); - goto loop; + /* Got an entry! Submit and exit. */ + ret =3D blk_co_pdiscard(s->blk, + sector << BDRV_SECTOR_BITS, + count << BDRV_SECTOR_BITS, + BDRV_REQ_NO_QUEUE); + if (ret >=3D 0) { + block_acct_done(blk_get_stats(s->blk), &s->acct); + } else { + iocb->ret =3D ret; + block_acct_failed(blk_get_stats(s->blk), &s->acct); + goto done; } - - iocb->j++; - iocb->i =3D -1; } - } else { - iocb->ret =3D ret; } =20 + iocb->ret =3D 0; done: if (iocb->bh) { replay_bh_schedule_event(iocb->bh); @@ -533,8 +525,7 @@ BlockAIOCB *ide_issue_trim( &DEVICE(dev)->mem_reentrancy_guard); iocb->ret =3D 0; iocb->qiov =3D qiov; - iocb->i =3D -1; - iocb->j =3D 0; + iocb->canceled =3D false; =20 co =3D qemu_coroutine_create(ide_trim_co_entry, iocb); aio_co_enter(qemu_get_current_aio_context(), co); --=20 2.54.0 From nobody Sat May 30 18:34:27 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1779210290; cv=none; d=zohomail.com; s=zohoarc; b=MfYUChBB34O1EAsY3luGesl92SIkowRi4WiTTR3BiyGCK3wkWXSbGusu/Xn5/CPeA2pe3aa/mWs7Nh9rQNdK48NAJ4JEzRjMJGQvGXYF9yyeVqmuujVmylprHbTJRmBvBR9srJZwdODK6s/ztYi3QeEY3LFw8rvBeHr07lsnODI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779210290; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=u08sXbsTytnmzswbd8VB8r41OWHdyyA5LD7RL28Hhjk=; b=g8ceZbXNv4HoHp/a2D4vQutNcKjFk8gcrj1D7+IyM8V7+2D92rHbhDbXDGu96gnimyVys6O/GPKFsHxb1AaTbjyi2LWtZ1p60gE5b/WmiGbDl8ztRyyKcgJ3Tzf667xH13H99koQUR7dJFa+68VDNTWf2E7H6p7gWETKZ91ByPQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1779210290556284.95421546977525; Tue, 19 May 2026 10:04:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wPNrG-00084V-0d; Tue, 19 May 2026 13:03:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wPNrA-0007zq-0a for qemu-devel@nongnu.org; Tue, 19 May 2026 13:03:48 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wPNr6-0004EL-V8 for qemu-devel@nongnu.org; Tue, 19 May 2026 13:03:46 -0400 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-449-EO0IATVzMYmEQbrQQcQNGA-1; Tue, 19 May 2026 13:03:40 -0400 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E271A19560BB; Tue, 19 May 2026 17:03:39 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.44.49.113]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D68A41687; Tue, 19 May 2026 17:03:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779210224; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=u08sXbsTytnmzswbd8VB8r41OWHdyyA5LD7RL28Hhjk=; b=Z17ZNZpD1UIYjX+fDeTBQ8wHo0Um1C/YOfbboJO82gpKI6soiV18sPbtvwvavemAWCst/S dHmwyp8izTsg1zLSRwyCvairaemM16JpONuwBGVFpXtOFKXKdqAHzWlNTfJ89SLGrBTS7L +a394t7Vk9KcedV+NTXOTRjtEY13nu8= X-MC-Unique: EO0IATVzMYmEQbrQQcQNGA-1 X-Mimecast-MFC-AGG-ID: EO0IATVzMYmEQbrQQcQNGA_1779210220 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 06/18] ide-test: Factor out wait_dma_completion() Date: Tue, 19 May 2026 19:03:05 +0200 Message-ID: <20260519170317.345032-7-kwolf@redhat.com> In-Reply-To: <20260519170317.345032-1-kwolf@redhat.com> References: <20260519170317.345032-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1779210292351154100 Content-Type: text/plain; charset="utf-8" Signed-off-by: Kevin Wolf Message-ID: <20260421161132.99878-7-kwolf@redhat.com> Signed-off-by: Kevin Wolf --- tests/qtest/ide-test.c | 48 +++++++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/tests/qtest/ide-test.c b/tests/qtest/ide-test.c index ceee444a9ec..c6dcb2c0745 100644 --- a/tests/qtest/ide-test.c +++ b/tests/qtest/ide-test.c @@ -200,6 +200,34 @@ static uint64_t trim_range_le(uint64_t sector, uint16_= t count) return cpu_to_le64(((uint64_t)count << 48) + sector); } =20 +static uint8_t wait_dma_completion(QTestState *qts, QPCIDevice *dev, + QPCIBar bmdma_bar, QPCIBar ide_bar) +{ + uint8_t status; + + /* Wait for the DMA transfer to complete */ + do { + status =3D qpci_io_readb(dev, bmdma_bar, bmreg_status); + } while ((status & (BM_STS_ACTIVE | BM_STS_INTR)) =3D=3D BM_STS_ACTIVE= ); + + g_assert_cmpint(qtest_get_irq(qts, IDE_PRIMARY_IRQ), =3D=3D, + !!(status & BM_STS_INTR)); + + /* Check IDE status code */ + assert_bit_set(qpci_io_readb(dev, ide_bar, reg_status), DRDY); + assert_bit_clear(qpci_io_readb(dev, ide_bar, reg_status), BSY | DRQ); + + /* Reading the status register clears the IRQ */ + g_assert(!qtest_get_irq(qts, IDE_PRIMARY_IRQ)); + + /* Stop DMA transfer if still active */ + if (status & BM_STS_ACTIVE) { + qpci_io_writeb(dev, bmdma_bar, bmreg_cmd, 0); + } + + return status; +} + static int send_dma_request(QTestState *qts, int cmd, uint64_t sector, int nb_sectors, PrdtEntry *prdt, int prdt_entr= ies, void(*post_exec)(QPCIDevice *dev, QPCIBar ide_= bar, @@ -280,25 +308,7 @@ static int send_dma_request(QTestState *qts, int cmd, = uint64_t sector, qpci_io_writeb(dev, bmdma_bar, bmreg_cmd, 0); } =20 - /* Wait for the DMA transfer to complete */ - do { - status =3D qpci_io_readb(dev, bmdma_bar, bmreg_status); - } while ((status & (BM_STS_ACTIVE | BM_STS_INTR)) =3D=3D BM_STS_ACTIVE= ); - - g_assert_cmpint(qtest_get_irq(qts, IDE_PRIMARY_IRQ), =3D=3D, - !!(status & BM_STS_INTR)); - - /* Check IDE status code */ - assert_bit_set(qpci_io_readb(dev, ide_bar, reg_status), DRDY); - assert_bit_clear(qpci_io_readb(dev, ide_bar, reg_status), BSY | DRQ); - - /* Reading the status register clears the IRQ */ - g_assert(!qtest_get_irq(qts, IDE_PRIMARY_IRQ)); - - /* Stop DMA transfer if still active */ - if (status & BM_STS_ACTIVE) { - qpci_io_writeb(dev, bmdma_bar, bmreg_cmd, 0); - } + status =3D wait_dma_completion(qts, dev, bmdma_bar, ide_bar); =20 free_pci_device(dev); =20 --=20 2.54.0 From nobody Sat May 30 18:34:27 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1779210261; cv=none; d=zohomail.com; s=zohoarc; b=RMqQigCpBjIn5bUY1HfGRtPsUocwvazU7Nnh2dSorxIGpJwQ/1KKYo+mdB7GayXEIKAoyB6LyCQPtrgb6xahGk+c9teYRc2H7nJjuy0ltb1zoCFjlETK+7tpX0zq0lYLzPpnqCDZi1SUIm3nk6OgPDxZ7z7F98GR6biA/Q2h7ac= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779210261; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Im6ugsy0Zg1kKOU/OXPyWYsPJt9DPoFm6c+xryieC9w=; b=JHdfN4FX8FLbNcXb1ojvV/LZ/C/Z0X9egSDaRe7FO4/y8smNWMeAFnlVfu1wSDRtk5Qk2rytTRjEb3peTVHnNT3HAXU6MbgOZCNfKNUGaaK87l9jk5XIH2E8Q71rpwZQQ8ekFWU8KgihJIH9uKjcOUO63Q7P05/cl6EuHcDLHVE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 177921026165289.60601206885269; Tue, 19 May 2026 10:04:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wPNrG-00084U-19; Tue, 19 May 2026 13:03:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wPNrB-00080m-EB for qemu-devel@nongnu.org; Tue, 19 May 2026 13:03:49 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wPNr8-0004Eo-PO for qemu-devel@nongnu.org; Tue, 19 May 2026 13:03:49 -0400 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-25-2uhkS721MESheI0fI1RsSw-1; Tue, 19 May 2026 13:03:42 -0400 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A9470195609D; Tue, 19 May 2026 17:03:41 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.44.49.113]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5658E1681; Tue, 19 May 2026 17:03:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779210226; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Im6ugsy0Zg1kKOU/OXPyWYsPJt9DPoFm6c+xryieC9w=; b=ddyAQe3bZLg+KZLorR1GGq3yI9idfwKvpN85LjW3HJfhUjdtoEb6SalDHoBH9f9AqEBGL8 rZ/Ft2GtvRRq7EoDsuOdZYuWz6cy+Mgpp9axT3WHoM6vLwmlBXBZlE04wUF8gFVElmr+1i oGSojuuzE2ekCruZLJWB+6Gx/Cl3N+4= X-MC-Unique: 2uhkS721MESheI0fI1RsSw-1 X-Mimecast-MFC-AGG-ID: 2uhkS721MESheI0fI1RsSw_1779210221 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 07/18] ide-test: Test reset during TRIM Date: Tue, 19 May 2026 19:03:06 +0200 Message-ID: <20260519170317.345032-8-kwolf@redhat.com> In-Reply-To: <20260519170317.345032-1-kwolf@redhat.com> References: <20260519170317.345032-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1779210264051154100 Content-Type: text/plain; charset="utf-8" This is a regression test for the bug fixed in the previous commits, a deadlock between the drain issued by an IDE reset and the TRIM state machine. Signed-off-by: Kevin Wolf Message-ID: <20260421161132.99878-8-kwolf@redhat.com> Signed-off-by: Kevin Wolf --- tests/qtest/ide-test.c | 95 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 87 insertions(+), 8 deletions(-) diff --git a/tests/qtest/ide-test.c b/tests/qtest/ide-test.c index c6dcb2c0745..721e78170bc 100644 --- a/tests/qtest/ide-test.c +++ b/tests/qtest/ide-test.c @@ -41,8 +41,11 @@ #define IDE_PCI_FUNC 1 =20 #define IDE_BASE 0x1f0 +#define IDE_BASE2 0x3f6 #define IDE_PRIMARY_IRQ 14 =20 +#define IDE_CTRL_RESET 0x04 + #define ATAPI_BLOCK_SIZE 2048 =20 /* How many bytes to receive via ATAPI PIO at one time. @@ -99,6 +102,7 @@ enum { =20 CMDF_ABORT =3D 0x100, CMDF_NO_BM =3D 0x200, + CMDF_NO_WAIT =3D 0x400, }; =20 enum { @@ -228,21 +232,21 @@ static uint8_t wait_dma_completion(QTestState *qts, Q= PCIDevice *dev, return status; } =20 -static int send_dma_request(QTestState *qts, int cmd, uint64_t sector, - int nb_sectors, PrdtEntry *prdt, int prdt_entr= ies, - void(*post_exec)(QPCIDevice *dev, QPCIBar ide_= bar, - uint64_t sector, int nb_secto= rs)) +static int send_dma_request_dev(QTestState *qts, QPCIDevice *dev, + QPCIBar bmdma_bar, QPCIBar ide_bar, int cm= d, + uint64_t sector, int nb_sectors, + PrdtEntry *prdt, int prdt_entries, + void(*post_exec)(QPCIDevice *dev, + QPCIBar ide_bar, + uint64_t sector, + int nb_sectors)) { - QPCIDevice *dev; - QPCIBar bmdma_bar, ide_bar; uintptr_t guest_prdt; size_t len; bool from_dev; uint8_t status; int flags; =20 - dev =3D get_pci_device(qts, &bmdma_bar, &ide_bar); - flags =3D cmd & ~0xff; cmd &=3D 0xff; =20 @@ -308,8 +312,28 @@ static int send_dma_request(QTestState *qts, int cmd, = uint64_t sector, qpci_io_writeb(dev, bmdma_bar, bmreg_cmd, 0); } =20 + if (flags & CMDF_NO_WAIT) { + return 0; + } + status =3D wait_dma_completion(qts, dev, bmdma_bar, ide_bar); =20 + return status; +} + +static int send_dma_request(QTestState *qts, int cmd, uint64_t sector, + int nb_sectors, PrdtEntry *prdt, int prdt_entr= ies, + void(*post_exec)(QPCIDevice *dev, QPCIBar ide_= bar, + uint64_t sector, int nb_secto= rs)) +{ + QPCIDevice *dev; + QPCIBar bmdma_bar, ide_bar; + uint8_t status; + + dev =3D get_pci_device(qts, &bmdma_bar, &ide_bar); + status =3D send_dma_request_dev(qts, dev, bmdma_bar, ide_bar, + cmd, sector, nb_sectors, prdt, prdt_entr= ies, + post_exec); free_pci_device(dev); =20 return status; @@ -457,6 +481,60 @@ static void test_bmdma_trim(void) test_bmdma_teardown(qts); } =20 +static void test_bmdma_trim_reset(void) +{ + QTestState *qts; + QPCIDevice *dev; + QPCIBar bmdma_bar, ide_bar, ide_bar2; + uint8_t status; + const uint64_t trim_range[] =3D { + trim_range_le(0, 2), + trim_range_le(6, 8), + }; + size_t len =3D 512; + uint8_t *buf; + uintptr_t guest_buf; + PrdtEntry prdt[1]; + + qts =3D ide_test_start( + "-blockdev file,filename=3D%s,node-name=3Dimg " + "-blockdev blkdebug,image=3Dimg,node-name=3Ddbg,discard=3Dunmap," + "inject-error.0.event=3Dnone,inject-error.0.iotype=3Ddiscard," + "inject-error.0.errno=3D0,inject-error.0.delay-ns=3D1000000 " + "-device ide-hd,drive=3Ddbg,bus=3Dide.0", + tmp_path[0]); + qtest_irq_intercept_in(qts, "ioapic"); + + guest_buf =3D guest_alloc(&guest_malloc, len); + prdt[0].addr =3D cpu_to_le32(guest_buf), + prdt[0].size =3D cpu_to_le32(len | PRDT_EOT), + + dev =3D get_pci_device(qts, &bmdma_bar, &ide_bar); + ide_bar2 =3D qpci_legacy_iomap(dev, IDE_BASE2); + + buf =3D g_malloc(len); + + /* TRIM request with two segments */ + *((uint64_t *)buf) =3D trim_range[0]; + *((uint64_t *)buf + 1) =3D trim_range[1]; + + qtest_memwrite(qts, guest_buf, buf, 2 * sizeof(uint64_t)); + + send_dma_request_dev(qts, dev, bmdma_bar, ide_bar, CMD_DSM | CMDF_NO_W= AIT, 0, 1, prdt, + ARRAY_SIZE(prdt), NULL); + + /* Reset the device while the first segment is in flight */ + qpci_io_writeb(dev, ide_bar2, 0, IDE_CTRL_RESET); + + status =3D wait_dma_completion(qts, dev, bmdma_bar, ide_bar); + g_assert_cmphex(status, =3D=3D, BM_STS_INTR); + assert_bit_clear(qpci_io_readb(dev, ide_bar, reg_status), DF | ERR); + + free_pci_device(dev); + g_free(buf); + test_bmdma_teardown(qts); +} + /* * This test is developed according to the Programming Interface for * Bus Master IDE Controller (Revision 1.0 5/16/94) @@ -1138,6 +1216,7 @@ int main(int argc, char **argv) =20 qtest_add_func("/ide/bmdma/simple_rw", test_bmdma_simple_rw); qtest_add_func("/ide/bmdma/trim", test_bmdma_trim); + qtest_add_func("/ide/bmdma/trim_reset", test_bmdma_trim_reset); qtest_add_func("/ide/bmdma/various_prdts", test_bmdma_various_prdts); qtest_add_func("/ide/bmdma/no_busmaster", test_bmdma_no_busmaster); =20 --=20 2.54.0 From nobody Sat May 30 18:34:27 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1779210359; cv=none; d=zohomail.com; s=zohoarc; b=FeyE1w01EnjHV9TM4D0sBoVEfeZrmCgctIPiG7xwN9i0KFjt5HjCLaVgspJ5f/WO/PPhnZb5PwHgn45Fj7RKmRLHkWsGEBozhQetCjkQc6tT5xygNrOxlaa6rTVh/7+T2XlTQAQ/DkGCz9XwkwLr8ZUyP3eFOl38k4RI4TFHUiU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779210359; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=zRHwts3yK2IB7U/9FOX5bkgSIpc5hL2zqRZ0C+LOXhM=; b=O1tpOeTpVtp7GeCEqbGL7/ViFiWr/5jsXtZJcDTmbr5VkwBRJI5tz6A8W0pUC9e5QLACH05rHWzbNfZ7bLnkPFTmRuEpMRZWfpDZCJBTPKWInFCr9LEhyaxjE9p8zR32C9O8Ym6jgiWUHO8VnIjdfn4L3qQt1eHYsROUTVxx4mM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1779210359215907.9298763269218; Tue, 19 May 2026 10:05:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wPNrL-00088M-6C; Tue, 19 May 2026 13:03:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wPNrG-00084X-0E for qemu-devel@nongnu.org; Tue, 19 May 2026 13:03:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wPNrA-0004F6-B1 for qemu-devel@nongnu.org; Tue, 19 May 2026 13:03:53 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-564-aDrVxf1mMhWAysRFZ7k02w-1; Tue, 19 May 2026 13:03:45 -0400 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4847B19560A6; Tue, 19 May 2026 17:03:44 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.44.49.113]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 223FC1684; Tue, 19 May 2026 17:03:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779210227; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zRHwts3yK2IB7U/9FOX5bkgSIpc5hL2zqRZ0C+LOXhM=; b=RMeRDqnYkLNLb23D4AQbj7eYzJpHKpNUR4WHcLhg4/MxvY7IoWaF2eVdw++z9GVA2vgfPQ E2D30EbxFWI3lYu207cwiN8tLgnve3nsHanGy9tb61UV5hVpvtQ6pmHS0URIpLaqLkb8kA ujLOxhzv6gBTkJd67Z7+3vQbTDGMZnA= X-MC-Unique: aDrVxf1mMhWAysRFZ7k02w-1 X-Mimecast-MFC-AGG-ID: aDrVxf1mMhWAysRFZ7k02w_1779210224 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 08/18] Remove the deprecated glusterfs block driver Date: Tue, 19 May 2026 19:03:07 +0200 Message-ID: <20260519170317.345032-9-kwolf@redhat.com> In-Reply-To: <20260519170317.345032-1-kwolf@redhat.com> References: <20260519170317.345032-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, WEIRD_PORT=0.001 autolearn=no 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1779210361837154100 From: Thomas Huth Glusterfs has been marked as deprecated since QEMU v9.2, and as far as I know, nobody spoke up 'til today that it should be kept. The listed e-mail address integration@gluster.org in our MAINTAINERS file seems to be bouncing nowadays, and looking at their website https://www.gluster.org/ the most recent news are from 2020 / 2021 ... so it seems like there is really hardly any interest in Glusterfs anymore. Thus it's time to remove the code now from QEMU. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Thomas Huth Message-ID: <20260511063013.39805-1-thuth@redhat.com> Signed-off-by: Kevin Wolf --- qapi/block-core.json | 52 - docs/about/deprecated.rst | 8 - docs/about/removed-features.rst | 7 + docs/system/device-url-syntax.rst.inc | 39 - docs/system/qemu-block-drivers.rst.inc | 84 - meson_options.txt | 2 - block/gluster.c | 1644 ----------------- tests/qtest/modules-test.c | 3 - MAINTAINERS | 6 - block/meson.build | 1 - meson.build | 47 - .../ci/setup/debian/debian-13-ppc64le.yaml | 1 - .../ci/setup/ubuntu/ubuntu-2404-aarch64.yaml | 1 - .../ci/setup/ubuntu/ubuntu-2404-s390x.yaml | 1 - scripts/coverity-scan/coverity-scan.docker | 1 - scripts/coverity-scan/run-coverity-scan | 2 +- scripts/meson-buildoptions.sh | 3 - .../dockerfiles/debian-amd64-cross.docker | 1 - .../dockerfiles/debian-arm64-cross.docker | 1 - .../dockerfiles/debian-mips64el-cross.docker | 1 - .../dockerfiles/debian-mipsel-cross.docker | 1 - .../dockerfiles/debian-ppc64el-cross.docker | 1 - .../dockerfiles/debian-riscv64-cross.docker | 1 - .../dockerfiles/debian-s390x-cross.docker | 1 - tests/docker/dockerfiles/debian.docker | 1 - .../dockerfiles/fedora-rust-nightly.docker | 1 - tests/docker/dockerfiles/fedora.docker | 1 - tests/docker/dockerfiles/opensuse-leap.docker | 1 - tests/docker/dockerfiles/ubuntu2204.docker | 1 - tests/lcitool/projects/qemu.yml | 1 - 30 files changed, 8 insertions(+), 1907 deletions(-) delete mode 100644 block/gluster.c diff --git a/qapi/block-core.json b/qapi/block-core.json index 0efd51787b4..1f87b078505 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -3334,18 +3334,12 @@ # # @snapshot-access: Since 7.0 # -# Features: -# -# @deprecated: Member @gluster is deprecated because GlusterFS -# development ceased. -# # Since: 2.9 ## { 'enum': 'BlockdevDriver', 'data': [ 'blkdebug', 'blklogwrites', 'blkreplay', 'blkverify', 'bochs', 'cloop', 'compress', 'copy-before-write', 'copy-on-read', 'dmg= ', 'file', 'snapshot-access', 'ftp', 'ftps', - {'name': 'gluster', 'features': [ 'deprecated' ] }, {'name': 'host_cdrom', 'if': 'HAVE_HOST_BLOCK_DEVICE' }, {'name': 'host_device', 'if': 'HAVE_HOST_BLOCK_DEVICE' }, 'http', 'https', @@ -4118,30 +4112,6 @@ '*rewrite-corrupted': 'bool', '*read-pattern': 'QuorumReadPattern' } } =20 -## -# @BlockdevOptionsGluster: -# -# Driver specific block device options for Gluster -# -# @volume: name of gluster volume where VM image resides -# -# @path: absolute path to image file in gluster volume -# -# @server: gluster servers description -# -# @debug: libgfapi log level (default '4' which is Error) (Since 2.8) -# -# @logfile: libgfapi log file (default /dev/stderr) (Since 2.8) -# -# Since: 2.9 -## -{ 'struct': 'BlockdevOptionsGluster', - 'data': { 'volume': 'str', - 'path': 'str', - 'server': ['SocketAddress'], - '*debug': 'int', - '*logfile': 'str' } } - ## # @BlockdevOptionsIoUring: # @@ -4875,7 +4845,6 @@ 'file': 'BlockdevOptionsFile', 'ftp': 'BlockdevOptionsCurlFtp', 'ftps': 'BlockdevOptionsCurlFtps', - 'gluster': 'BlockdevOptionsGluster', 'host_cdrom': { 'type': 'BlockdevOptionsFile', 'if': 'HAVE_HOST_BLOCK_DEVICE' }, 'host_device': { 'type': 'BlockdevOptionsFile', @@ -5146,26 +5115,6 @@ '*nocow': 'bool', '*extent-size-hint': 'size'} } =20 -## -# @BlockdevCreateOptionsGluster: -# -# Driver specific image creation options for gluster. -# -# @location: Where to store the new image file -# -# @size: Size of the virtual disk in bytes -# -# @preallocation: Preallocation mode for the new image (default: off; -# allowed values: off, falloc (if CONFIG_GLUSTERFS_FALLOCATE), -# full (if CONFIG_GLUSTERFS_ZEROFILL)) -# -# Since: 2.12 -## -{ 'struct': 'BlockdevCreateOptionsGluster', - 'data': { 'location': 'BlockdevOptionsGluster', - 'size': 'size', - '*preallocation': 'PreallocMode' } } - ## # @BlockdevCreateOptionsLUKS: # @@ -5593,7 +5542,6 @@ 'discriminator': 'driver', 'data': { 'file': 'BlockdevCreateOptionsFile', - 'gluster': 'BlockdevCreateOptionsGluster', 'luks': 'BlockdevCreateOptionsLUKS', 'nfs': 'BlockdevCreateOptionsNfs', 'parallels': 'BlockdevCreateOptionsParallels', diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst index bf6182d61c6..e64328c5b2b 100644 --- a/docs/about/deprecated.rst +++ b/docs/about/deprecated.rst @@ -382,14 +382,6 @@ Specifying the iSCSI password in plain text on the com= mand line using the used instead, to refer to a ``--object secret...`` instance that provides a password via a file, or encrypted. =20 -``gluster`` backend (since 9.2) -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -According to https://marc.info/?l=3Dfedora-devel-list&m=3D171934833215726 -the GlusterFS development effectively ended. Unless the development -gains momentum again, the QEMU project will remove the gluster backend -in a future release. - =20 Character device options '''''''''''''''''''''''' diff --git a/docs/about/removed-features.rst b/docs/about/removed-features.= rst index 9bd83b183f4..1ee4ab07944 100644 --- a/docs/about/removed-features.rst +++ b/docs/about/removed-features.rst @@ -1429,6 +1429,13 @@ The corresponding upstream server project is no long= er maintained. Users are recommended to switch to an alternative distributed block device driver such as RBD. =20 +``gluster`` backend (removed in 11.1) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +According to https://marc.info/?l=3Dfedora-devel-list&m=3D171934833215726 +the GlusterFS development effectively ended. + + VFIO devices ------------ =20 diff --git a/docs/system/device-url-syntax.rst.inc b/docs/system/device-url= -syntax.rst.inc index 996ce5418ff..3521a3d053f 100644 --- a/docs/system/device-url-syntax.rst.inc +++ b/docs/system/device-url-syntax.rst.inc @@ -85,45 +85,6 @@ These are specified using a special URL syntax. Currently authentication must be done using ssh-agent. Other authentication methods may be supported in future. =20 -``GlusterFS`` - GlusterFS is a user space distributed file system. QEMU supports the - use of GlusterFS volumes for hosting VM disk images using TCP and Unix - Domain Sockets transport protocols. - - Syntax for specifying a VM disk image on GlusterFS volume is - - .. parsed-literal:: - - URI: - gluster[+type]://[host[:port]]/volume/path[?socket=3D...][,debug=3DN= ][,logfile=3D...] - - JSON: - 'json:{"driver":"qcow2","file":{"driver":"gluster","volume":"testvol= ","path":"a.img","debug":N,"logfile":"...", - =C2=A0 "server":[{"type":"tcp","host"= :"...","port":"..."}, - =C2=A0 {"type":"unix","sock= et":"..."}]}}' - - Example - - .. parsed-literal:: - - URI: - |qemu_system| --drive file=3Dgluster://192.0.2.1/testvol/a.img, - =C2=A0 file.debug=3D9,file.logfile=3D/v= ar/log/qemu-gluster.log - - JSON: - |qemu_system| 'json:{"driver":"qcow2", - =C2=A0 "file":{"driver":"gluster", - =C2=A0 "volume":"testvol","path":"a= .img", - =C2=A0 "debug":9,"logfile":"/var/lo= g/qemu-gluster.log", - =C2=A0 "server":[{"type":"tcp","hos= t":"1.2.3.4","port":24007}, - =C2=A0 {"type":"unix","so= cket":"/var/run/glusterd.socket"}]}}' - |qemu_system| -drive driver=3Dqcow2,file.driver=3Dgluster,file.volum= e=3Dtestvol,file.path=3D/path/a.img, - =C2=A0 file.debug=3D9,file.logfi= le=3D/var/log/qemu-gluster.log, - =C2=A0 file.server.0.type=3Dtcp,= file.server.0.host=3D1.2.3.4,file.server.0.port=3D24007, - =C2=A0 file.server.1.type=3Dunix= ,file.server.1.socket=3D/var/run/glusterd.socket - - See also http://www.gluster.org. - ``HTTP/HTTPS/FTP/FTPS`` QEMU supports read-only access to files accessed over http(s) and ftp(s). diff --git a/docs/system/qemu-block-drivers.rst.inc b/docs/system/qemu-bloc= k-drivers.rst.inc index 384e95ba765..675daa72f97 100644 --- a/docs/system/qemu-block-drivers.rst.inc +++ b/docs/system/qemu-block-drivers.rst.inc @@ -665,90 +665,6 @@ systems as the package 'scsi-target-utils'. -boot d -drive file=3Discsi://127.0.0.1/iqn.qemu.test/1 \\ -cdrom iscsi://127.0.0.1/iqn.qemu.test/2 =20 -GlusterFS disk images -~~~~~~~~~~~~~~~~~~~~~ - -GlusterFS is a user space distributed file system. - -You can boot from the GlusterFS disk image with the command: - -URI: - -.. parsed-literal:: - - |qemu_system| -drive file=3Dgluster[+TYPE]://[HOST}[:PORT]]/VOLUME/PATH - [?socket=3D...][,file.debug=3D9][,file.logf= ile=3D...] - -JSON: - -.. parsed-literal:: - - |qemu_system| 'json:{"driver":"qcow2", - "file":{"driver":"gluster", - "volume":"testvol","path":"a.img","deb= ug":9,"logfile":"...", - "server":[{"type":"tcp","host":"...","= port":"..."}, - {"type":"unix","socket":"...= "}]}}' - -*gluster* is the protocol. - -*TYPE* specifies the transport type used to connect to gluster -management daemon (glusterd). Valid transport types are -tcp and unix. In the URI form, if a transport type isn't specified, -then tcp type is assumed. - -*HOST* specifies the server where the volume file specification for -the given volume resides. This can be either a hostname or an ipv4 address. -If transport type is unix, then *HOST* field should not be specified. -Instead *socket* field needs to be populated with the path to unix domain -socket. - -*PORT* is the port number on which glusterd is listening. This is optional -and if not specified, it defaults to port 24007. If the transport type is = unix, -then *PORT* should not be specified. - -*VOLUME* is the name of the gluster volume which contains the disk image. - -*PATH* is the path to the actual disk image that resides on gluster volume. - -*debug* is the logging level of the gluster protocol driver. Debug levels -are 0-9, with 9 being the most verbose, and 0 representing no debugging ou= tput. -The default level is 4. The current logging levels defined in the gluster = source -are 0 - None, 1 - Emergency, 2 - Alert, 3 - Critical, 4 - Error, 5 - Warni= ng, -6 - Notice, 7 - Info, 8 - Debug, 9 - Trace - -*logfile* is a commandline option to mention log file path which helps in -logging to the specified file and also help in persisting the gfapi logs. = The -default is stderr. - -You can create a GlusterFS disk image with the command: - -.. parsed-literal:: - - qemu-img create gluster://HOST/VOLUME/PATH SIZE - -Examples - -.. parsed-literal:: - - |qemu_system| -drive file=3Dgluster://1.2.3.4/testvol/a.img - |qemu_system| -drive file=3Dgluster+tcp://1.2.3.4/testvol/a.img - |qemu_system| -drive file=3Dgluster+tcp://1.2.3.4:24007/testvol/dir/a.img - |qemu_system| -drive file=3Dgluster+tcp://[1:2:3:4:5:6:7:8]/testvol/dir/= a.img - |qemu_system| -drive file=3Dgluster+tcp://[1:2:3:4:5:6:7:8]:24007/testvo= l/dir/a.img - |qemu_system| -drive file=3Dgluster+tcp://server.domain.com:24007/testvo= l/dir/a.img - |qemu_system| -drive file=3Dgluster+unix:///testvol/dir/a.img?socket=3D/= tmp/glusterd.socket - |qemu_system| -drive file=3Dgluster://1.2.3.4/testvol/a.img,file.debug= =3D9,file.logfile=3D/var/log/qemu-gluster.log - |qemu_system| 'json:{"driver":"qcow2", - "file":{"driver":"gluster", - "volume":"testvol","path":"a.img", - "debug":9,"logfile":"/var/log/qemu-glu= ster.log", - "server":[{"type":"tcp","host":"1.2.3.= 4","port":24007}, - {"type":"unix","socket":"/va= r/run/glusterd.socket"}]}}' - |qemu_system| -drive driver=3Dqcow2,file.driver=3Dgluster,file.volume=3D= testvol,file.path=3D/path/a.img, - file.debug=3D9,file.logfile=3D/var/= log/qemu-gluster.log, - file.server.0.type=3Dtcp,file.serve= r.0.host=3D1.2.3.4,file.server.0.port=3D24007, - file.server.1.type=3Dunix,file.serv= er.1.socket=3D/var/run/glusterd.socket - Secure Shell (ssh) disk images ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ =20 diff --git a/meson_options.txt b/meson_options.txt index ae17a3d8830..a07cb47d35e 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -160,8 +160,6 @@ option('curl', type : 'feature', value : 'auto', description: 'CURL block device driver') option('gio', type : 'feature', value : 'auto', description: 'use libgio for D-Bus support') -option('glusterfs', type : 'feature', value : 'auto', - description: 'Glusterfs block device driver') option('hv_balloon', type : 'feature', value : 'auto', description: 'hv-balloon driver (requires Glib 2.68+ GTree API)') option('libdw', type : 'feature', value : 'auto', diff --git a/block/gluster.c b/block/gluster.c deleted file mode 100644 index 279f650241c..00000000000 --- a/block/gluster.c +++ /dev/null @@ -1,1644 +0,0 @@ -/* - * GlusterFS backend for QEMU - * - * Copyright (C) 2012 Bharata B Rao - * - * This work is licensed under the terms of the GNU GPL, version 2 or late= r. - * See the COPYING file in the top-level directory. - * - */ - -#include "qemu/osdep.h" -#include "qemu/units.h" -#include -#include "block/block-io.h" -#include "block/block_int.h" -#include "block/qdict.h" -#include "qapi/error.h" -#include "qobject/qdict.h" -#include "qapi/qmp/qerror.h" -#include "qemu/error-report.h" -#include "qemu/module.h" -#include "qemu/option.h" -#include "qemu/cutils.h" - -#ifdef CONFIG_GLUSTERFS_FTRUNCATE_HAS_STAT -# define glfs_ftruncate(fd, offset) glfs_ftruncate(fd, offset, NULL, NULL) -#endif - -#define GLUSTER_OPT_FILENAME "filename" -#define GLUSTER_OPT_VOLUME "volume" -#define GLUSTER_OPT_PATH "path" -#define GLUSTER_OPT_TYPE "type" -#define GLUSTER_OPT_SERVER_PATTERN "server." -#define GLUSTER_OPT_HOST "host" -#define GLUSTER_OPT_PORT "port" -#define GLUSTER_OPT_TO "to" -#define GLUSTER_OPT_IPV4 "ipv4" -#define GLUSTER_OPT_IPV6 "ipv6" -#define GLUSTER_OPT_SOCKET "socket" -#define GLUSTER_OPT_DEBUG "debug" -#define GLUSTER_DEFAULT_PORT 24007 -#define GLUSTER_DEBUG_DEFAULT 4 -#define GLUSTER_DEBUG_MAX 9 -#define GLUSTER_OPT_LOGFILE "logfile" -#define GLUSTER_LOGFILE_DEFAULT "-" /* handled in libgfapi as /dev/std= err */ -/* - * Several versions of GlusterFS (3.12? -> 6.0.1) fail when the transfer s= ize - * is greater or equal to 1024 MiB, so we are limiting the transfer size t= o 512 - * MiB to avoid this rare issue. - */ -#define GLUSTER_MAX_TRANSFER (512 * MiB) - -#define GERR_INDEX_HINT "hint: check in 'server' array index '%d'\n" - -typedef struct GlusterAIOCB { - int64_t size; - int ret; - Coroutine *coroutine; -} GlusterAIOCB; - -typedef struct BDRVGlusterState { - struct glfs *glfs; - struct glfs_fd *fd; - char *logfile; - bool supports_seek_data; - int debug; -} BDRVGlusterState; - -typedef struct BDRVGlusterReopenState { - struct glfs *glfs; - struct glfs_fd *fd; -} BDRVGlusterReopenState; - - -typedef struct GlfsPreopened { - char *volume; - glfs_t *fs; - int ref; -} GlfsPreopened; - -typedef struct ListElement { - QLIST_ENTRY(ListElement) list; - GlfsPreopened saved; -} ListElement; - -static QLIST_HEAD(, ListElement) glfs_list; - -static QemuOptsList qemu_gluster_create_opts =3D { - .name =3D "qemu-gluster-create-opts", - .head =3D QTAILQ_HEAD_INITIALIZER(qemu_gluster_create_opts.head), - .desc =3D { - { - .name =3D BLOCK_OPT_SIZE, - .type =3D QEMU_OPT_SIZE, - .help =3D "Virtual disk size" - }, - { - .name =3D BLOCK_OPT_PREALLOC, - .type =3D QEMU_OPT_STRING, - .help =3D "Preallocation mode (allowed values: off" -#ifdef CONFIG_GLUSTERFS_FALLOCATE - ", falloc" -#endif -#ifdef CONFIG_GLUSTERFS_ZEROFILL - ", full" -#endif - ")" - }, - { - .name =3D GLUSTER_OPT_DEBUG, - .type =3D QEMU_OPT_NUMBER, - .help =3D "Gluster log level, valid range is 0-9", - }, - { - .name =3D GLUSTER_OPT_LOGFILE, - .type =3D QEMU_OPT_STRING, - .help =3D "Logfile path of libgfapi", - }, - { /* end of list */ } - } -}; - -static QemuOptsList runtime_opts =3D { - .name =3D "gluster", - .head =3D QTAILQ_HEAD_INITIALIZER(runtime_opts.head), - .desc =3D { - { - .name =3D GLUSTER_OPT_FILENAME, - .type =3D QEMU_OPT_STRING, - .help =3D "URL to the gluster image", - }, - { - .name =3D GLUSTER_OPT_DEBUG, - .type =3D QEMU_OPT_NUMBER, - .help =3D "Gluster log level, valid range is 0-9", - }, - { - .name =3D GLUSTER_OPT_LOGFILE, - .type =3D QEMU_OPT_STRING, - .help =3D "Logfile path of libgfapi", - }, - { /* end of list */ } - }, -}; - -static QemuOptsList runtime_json_opts =3D { - .name =3D "gluster_json", - .head =3D QTAILQ_HEAD_INITIALIZER(runtime_json_opts.head), - .desc =3D { - { - .name =3D GLUSTER_OPT_VOLUME, - .type =3D QEMU_OPT_STRING, - .help =3D "name of gluster volume where VM image resides", - }, - { - .name =3D GLUSTER_OPT_PATH, - .type =3D QEMU_OPT_STRING, - .help =3D "absolute path to image file in gluster volume", - }, - { - .name =3D GLUSTER_OPT_DEBUG, - .type =3D QEMU_OPT_NUMBER, - .help =3D "Gluster log level, valid range is 0-9", - }, - { /* end of list */ } - }, -}; - -static QemuOptsList runtime_type_opts =3D { - .name =3D "gluster_type", - .head =3D QTAILQ_HEAD_INITIALIZER(runtime_type_opts.head), - .desc =3D { - { - .name =3D GLUSTER_OPT_TYPE, - .type =3D QEMU_OPT_STRING, - .help =3D "inet|unix", - }, - { /* end of list */ } - }, -}; - -static QemuOptsList runtime_unix_opts =3D { - .name =3D "gluster_unix", - .head =3D QTAILQ_HEAD_INITIALIZER(runtime_unix_opts.head), - .desc =3D { - { - .name =3D GLUSTER_OPT_SOCKET, - .type =3D QEMU_OPT_STRING, - .help =3D "socket file path (legacy)", - }, - { - .name =3D GLUSTER_OPT_PATH, - .type =3D QEMU_OPT_STRING, - .help =3D "socket file path (QAPI)", - }, - { /* end of list */ } - }, -}; - -static QemuOptsList runtime_inet_opts =3D { - .name =3D "gluster_inet", - .head =3D QTAILQ_HEAD_INITIALIZER(runtime_inet_opts.head), - .desc =3D { - { - .name =3D GLUSTER_OPT_TYPE, - .type =3D QEMU_OPT_STRING, - .help =3D "inet|unix", - }, - { - .name =3D GLUSTER_OPT_HOST, - .type =3D QEMU_OPT_STRING, - .help =3D "host address (hostname/ipv4/ipv6 addresses)", - }, - { - .name =3D GLUSTER_OPT_PORT, - .type =3D QEMU_OPT_STRING, - .help =3D "port number on which glusterd is listening (default= 24007)", - }, - { - .name =3D "to", - .type =3D QEMU_OPT_NUMBER, - .help =3D "max port number, not supported by gluster", - }, - { - .name =3D "ipv4", - .type =3D QEMU_OPT_BOOL, - .help =3D "ipv4 bool value, not supported by gluster", - }, - { - .name =3D "ipv6", - .type =3D QEMU_OPT_BOOL, - .help =3D "ipv6 bool value, not supported by gluster", - }, - { /* end of list */ } - }, -}; - -static void glfs_set_preopened(const char *volume, glfs_t *fs) -{ - ListElement *entry =3D NULL; - - entry =3D g_new(ListElement, 1); - - entry->saved.volume =3D g_strdup(volume); - - entry->saved.fs =3D fs; - entry->saved.ref =3D 1; - - QLIST_INSERT_HEAD(&glfs_list, entry, list); -} - -static glfs_t *glfs_find_preopened(const char *volume) -{ - ListElement *entry; - - QLIST_FOREACH(entry, &glfs_list, list) { - if (strcmp(entry->saved.volume, volume) =3D=3D 0) { - entry->saved.ref++; - return entry->saved.fs; - } - } - - return NULL; -} - -static void glfs_clear_preopened(glfs_t *fs) -{ - ListElement *entry; - ListElement *next; - - if (fs =3D=3D NULL) { - return; - } - - QLIST_FOREACH_SAFE(entry, &glfs_list, list, next) { - if (entry->saved.fs =3D=3D fs) { - if (--entry->saved.ref) { - return; - } - - QLIST_REMOVE(entry, list); - - glfs_fini(entry->saved.fs); - g_free(entry->saved.volume); - g_free(entry); - } - } -} - -static int parse_volume_options(BlockdevOptionsGluster *gconf, const char = *path) -{ - const char *p, *q; - - if (!path) { - return -EINVAL; - } - - /* volume */ - p =3D q =3D path + strspn(path, "/"); - p +=3D strcspn(p, "/"); - if (*p =3D=3D '\0') { - return -EINVAL; - } - gconf->volume =3D g_strndup(q, p - q); - - /* path */ - p +=3D strspn(p, "/"); - if (*p =3D=3D '\0') { - return -EINVAL; - } - gconf->path =3D g_strdup(p); - return 0; -} - -/* - * file=3Dgluster[+transport]://[host[:port]]/volume/path[?socket=3D...] - * - * 'gluster' is the protocol. - * - * 'transport' specifies the transport type used to connect to gluster - * management daemon (glusterd). Valid transport types are - * tcp or unix. If a transport type isn't specified, then tcp type is assu= med. - * - * 'host' specifies the host where the volume file specification for - * the given volume resides. This can be either hostname or ipv4 address. - * If transport type is 'unix', then 'host' field should not be specified. - * The 'socket' field needs to be populated with the path to unix domain - * socket. - * - * 'port' is the port number on which glusterd is listening. This is optio= nal - * and if not specified, QEMU will send 0 which will make gluster to use t= he - * default port. If the transport type is unix, then 'port' should not be - * specified. - * - * 'volume' is the name of the gluster volume which contains the VM image. - * - * 'path' is the path to the actual VM image that resides on gluster volum= e. - * - * Examples: - * - * file=3Dgluster://1.2.3.4/testvol/a.img - * file=3Dgluster+tcp://1.2.3.4/testvol/a.img - * file=3Dgluster+tcp://1.2.3.4:24007/testvol/dir/a.img - * file=3Dgluster+tcp://host.domain.com:24007/testvol/dir/a.img - * file=3Dgluster+unix:///testvol/dir/a.img?socket=3D/tmp/glusterd.socket - */ -static int qemu_gluster_parse_uri(BlockdevOptionsGluster *gconf, - const char *filename) -{ - g_autoptr(GUri) uri =3D g_uri_parse(filename, G_URI_FLAGS_NONE, NULL); - g_autoptr(GHashTable) qp =3D NULL; - SocketAddress *gsconf; - bool is_unix =3D false; - const char *uri_scheme, *uri_query, *uri_server; - int uri_port, ret; - - if (!uri) { - return -EINVAL; - } - - gsconf =3D g_new0(SocketAddress, 1); - QAPI_LIST_PREPEND(gconf->server, gsconf); - - /* transport */ - uri_scheme =3D g_uri_get_scheme(uri); - if (!uri_scheme || !strcmp(uri_scheme, "gluster")) { - gsconf->type =3D SOCKET_ADDRESS_TYPE_INET; - } else if (!strcmp(uri_scheme, "gluster+tcp")) { - gsconf->type =3D SOCKET_ADDRESS_TYPE_INET; - } else if (!strcmp(uri_scheme, "gluster+unix")) { - gsconf->type =3D SOCKET_ADDRESS_TYPE_UNIX; - is_unix =3D true; - } else { - return -EINVAL; - } - - ret =3D parse_volume_options(gconf, g_uri_get_path(uri)); - if (ret < 0) { - return ret; - } - - uri_query =3D g_uri_get_query(uri); - if (uri_query) { - qp =3D g_uri_parse_params(uri_query, -1, "&", G_URI_PARAMS_NONE, N= ULL); - if (!qp) { - return -EINVAL; - } - ret =3D g_hash_table_size(qp); - if (ret > 1 || (is_unix && !ret) || (!is_unix && ret)) { - return -EINVAL; - } - } - - uri_server =3D g_uri_get_host(uri); - uri_port =3D g_uri_get_port(uri); - - if (is_unix) { - char *uri_socket =3D g_hash_table_lookup(qp, "socket"); - if (uri_server || uri_port !=3D -1 || !uri_socket) { - return -EINVAL; - } - gsconf->u.q_unix.path =3D g_strdup(uri_socket); - } else { - gsconf->u.inet.host =3D g_strdup(uri_server ? uri_server : "localh= ost"); - if (uri_port > 0) { - gsconf->u.inet.port =3D g_strdup_printf("%d", uri_port); - } else { - gsconf->u.inet.port =3D g_strdup_printf("%d", GLUSTER_DEFAULT_= PORT); - } - } - - return 0; -} - -static struct glfs *qemu_gluster_glfs_init(BlockdevOptionsGluster *gconf, - Error **errp) -{ - struct glfs *glfs; - int ret; - int old_errno; - SocketAddressList *server; - uint64_t port; - - glfs =3D glfs_find_preopened(gconf->volume); - if (glfs) { - return glfs; - } - - glfs =3D glfs_new(gconf->volume); - if (!glfs) { - goto out; - } - - glfs_set_preopened(gconf->volume, glfs); - - for (server =3D gconf->server; server; server =3D server->next) { - switch (server->value->type) { - case SOCKET_ADDRESS_TYPE_UNIX: - ret =3D glfs_set_volfile_server(glfs, "unix", - server->value->u.q_unix.path, 0); - break; - case SOCKET_ADDRESS_TYPE_INET: - if (parse_uint_full(server->value->u.inet.port, 10, &port) < 0= || - port > 65535) { - error_setg(errp, "'%s' is not a valid port number", - server->value->u.inet.port); - errno =3D EINVAL; - goto out; - } - ret =3D glfs_set_volfile_server(glfs, "tcp", - server->value->u.inet.host, - (int)port); - break; - case SOCKET_ADDRESS_TYPE_VSOCK: - case SOCKET_ADDRESS_TYPE_FD: - default: - abort(); - } - - if (ret < 0) { - goto out; - } - } - - ret =3D glfs_set_logging(glfs, gconf->logfile, gconf->debug); - if (ret < 0) { - goto out; - } - - ret =3D glfs_init(glfs); - if (ret) { - error_setg(errp, "Gluster connection for volume %s, path %s failed" - " to connect", gconf->volume, gconf->path); - for (server =3D gconf->server; server; server =3D server->next) { - if (server->value->type =3D=3D SOCKET_ADDRESS_TYPE_UNIX) { - error_append_hint(errp, "hint: failed on socket %s ", - server->value->u.q_unix.path); - } else { - error_append_hint(errp, "hint: failed on host %s and port = %s ", - server->value->u.inet.host, - server->value->u.inet.port); - } - } - - error_append_hint(errp, "Please refer to gluster logs for more inf= o\n"); - - /* glfs_init sometimes doesn't set errno although docs suggest tha= t */ - if (errno =3D=3D 0) { - errno =3D EINVAL; - } - - goto out; - } - return glfs; - -out: - if (glfs) { - old_errno =3D errno; - glfs_clear_preopened(glfs); - errno =3D old_errno; - } - return NULL; -} - -/* - * Convert the json formatted command line into qapi. -*/ -static int qemu_gluster_parse_json(BlockdevOptionsGluster *gconf, - QDict *options, Error **errp) -{ - QemuOpts *opts; - SocketAddress *gsconf =3D NULL; - SocketAddressList **tail; - QDict *backing_options =3D NULL; - Error *local_err =3D NULL; - const char *ptr; - int i, type, num_servers; - - /* create opts info from runtime_json_opts list */ - opts =3D qemu_opts_create(&runtime_json_opts, NULL, 0, &error_abort); - if (!qemu_opts_absorb_qdict(opts, options, errp)) { - goto out; - } - - num_servers =3D qdict_array_entries(options, GLUSTER_OPT_SERVER_PATTER= N); - if (num_servers < 1) { - error_setg(&local_err, QERR_MISSING_PARAMETER, "server"); - goto out; - } - - ptr =3D qemu_opt_get(opts, GLUSTER_OPT_VOLUME); - if (!ptr) { - error_setg(&local_err, QERR_MISSING_PARAMETER, GLUSTER_OPT_VOLUME); - goto out; - } - gconf->volume =3D g_strdup(ptr); - - ptr =3D qemu_opt_get(opts, GLUSTER_OPT_PATH); - if (!ptr) { - error_setg(&local_err, QERR_MISSING_PARAMETER, GLUSTER_OPT_PATH); - goto out; - } - gconf->path =3D g_strdup(ptr); - qemu_opts_del(opts); - tail =3D &gconf->server; - - for (i =3D 0; i < num_servers; i++) { - g_autofree char *str =3D g_strdup_printf(GLUSTER_OPT_SERVER_PATTER= N"%d.", - i); - qdict_extract_subqdict(options, &backing_options, str); - - /* create opts info from runtime_type_opts list */ - opts =3D qemu_opts_create(&runtime_type_opts, NULL, 0, &error_abor= t); - if (!qemu_opts_absorb_qdict(opts, backing_options, errp)) { - goto out; - } - - ptr =3D qemu_opt_get(opts, GLUSTER_OPT_TYPE); - if (!ptr) { - error_setg(&local_err, QERR_MISSING_PARAMETER, GLUSTER_OPT_TYP= E); - error_append_hint(&local_err, GERR_INDEX_HINT, i); - goto out; - - } - gsconf =3D g_new0(SocketAddress, 1); - if (!strcmp(ptr, "tcp")) { - ptr =3D "inet"; /* accept legacy "tcp" */ - } - type =3D qapi_enum_parse(&SocketAddressType_lookup, ptr, -1, NULL); - if (type !=3D SOCKET_ADDRESS_TYPE_INET - && type !=3D SOCKET_ADDRESS_TYPE_UNIX) { - error_setg(&local_err, - "Parameter '%s' may be 'inet' or 'unix'", - GLUSTER_OPT_TYPE); - error_append_hint(&local_err, GERR_INDEX_HINT, i); - goto out; - } - gsconf->type =3D type; - qemu_opts_del(opts); - - if (gsconf->type =3D=3D SOCKET_ADDRESS_TYPE_INET) { - /* create opts info from runtime_inet_opts list */ - opts =3D qemu_opts_create(&runtime_inet_opts, NULL, 0, &error_= abort); - if (!qemu_opts_absorb_qdict(opts, backing_options, errp)) { - goto out; - } - - ptr =3D qemu_opt_get(opts, GLUSTER_OPT_HOST); - if (!ptr) { - error_setg(&local_err, QERR_MISSING_PARAMETER, - GLUSTER_OPT_HOST); - error_append_hint(&local_err, GERR_INDEX_HINT, i); - goto out; - } - gsconf->u.inet.host =3D g_strdup(ptr); - ptr =3D qemu_opt_get(opts, GLUSTER_OPT_PORT); - if (!ptr) { - error_setg(&local_err, QERR_MISSING_PARAMETER, - GLUSTER_OPT_PORT); - error_append_hint(&local_err, GERR_INDEX_HINT, i); - goto out; - } - gsconf->u.inet.port =3D g_strdup(ptr); - - /* defend for unsupported fields in InetSocketAddress, - * i.e. @ipv4, @ipv6 and @to - */ - ptr =3D qemu_opt_get(opts, GLUSTER_OPT_TO); - if (ptr) { - gsconf->u.inet.has_to =3D true; - } - ptr =3D qemu_opt_get(opts, GLUSTER_OPT_IPV4); - if (ptr) { - gsconf->u.inet.has_ipv4 =3D true; - } - ptr =3D qemu_opt_get(opts, GLUSTER_OPT_IPV6); - if (ptr) { - gsconf->u.inet.has_ipv6 =3D true; - } - if (gsconf->u.inet.has_to) { - error_setg(&local_err, "Parameter 'to' not supported"); - goto out; - } - if (gsconf->u.inet.has_ipv4 || gsconf->u.inet.has_ipv6) { - error_setg(&local_err, "Parameters 'ipv4/ipv6' not support= ed"); - goto out; - } - qemu_opts_del(opts); - } else { - /* create opts info from runtime_unix_opts list */ - opts =3D qemu_opts_create(&runtime_unix_opts, NULL, 0, &error_= abort); - if (!qemu_opts_absorb_qdict(opts, backing_options, errp)) { - goto out; - } - - ptr =3D qemu_opt_get(opts, GLUSTER_OPT_PATH); - if (!ptr) { - ptr =3D qemu_opt_get(opts, GLUSTER_OPT_SOCKET); - } else if (qemu_opt_get(opts, GLUSTER_OPT_SOCKET)) { - error_setg(&local_err, - "Conflicting parameters 'path' and 'socket'"); - error_append_hint(&local_err, GERR_INDEX_HINT, i); - goto out; - } - if (!ptr) { - error_setg(&local_err, QERR_MISSING_PARAMETER, - GLUSTER_OPT_PATH); - error_append_hint(&local_err, GERR_INDEX_HINT, i); - goto out; - } - gsconf->u.q_unix.path =3D g_strdup(ptr); - qemu_opts_del(opts); - } - - QAPI_LIST_APPEND(tail, gsconf); - gsconf =3D NULL; - - qobject_unref(backing_options); - backing_options =3D NULL; - } - - return 0; - -out: - error_propagate(errp, local_err); - qapi_free_SocketAddress(gsconf); - qemu_opts_del(opts); - qobject_unref(backing_options); - errno =3D EINVAL; - return -errno; -} - -/* Converts options given in @filename and the @options QDict into the QAPI - * object @gconf. */ -static int qemu_gluster_parse(BlockdevOptionsGluster *gconf, - const char *filename, - QDict *options, Error **errp) -{ - int ret; - if (filename) { - ret =3D qemu_gluster_parse_uri(gconf, filename); - if (ret < 0) { - error_setg(errp, "invalid URI %s", filename); - error_append_hint(errp, "Usage: file=3Dgluster[+transport]://" - "[host[:port]]volume/path[?socket=3D..= .]" - "[,file.debug=3DN]" - "[,file.logfile=3D/path/filename.log]\= n"); - return ret; - } - } else { - ret =3D qemu_gluster_parse_json(gconf, options, errp); - if (ret < 0) { - error_append_hint(errp, "Usage: " - "-drive driver=3Dqcow2,file.driver=3Dgluster," - "file.volume=3Dtestvol,file.path=3D/path/a.qc= ow2" - "[,file.debug=3D9]" - "[,file.logfile=3D/path/filename.log]," - "file.server.0.type=3Dinet," - "file.server.0.host=3D1.2.3.4," - "file.server.0.port=3D24007," - "file.server.1.transport=3Dunix," - "file.server.1.path=3D/var/run/glusterd.socke= t ..." - "\n"); - return ret; - } - } - - return 0; -} - -static struct glfs *qemu_gluster_init(BlockdevOptionsGluster *gconf, - const char *filename, - QDict *options, Error **errp) -{ - int ret; - - ret =3D qemu_gluster_parse(gconf, filename, options, errp); - if (ret < 0) { - errno =3D -ret; - return NULL; - } - - return qemu_gluster_glfs_init(gconf, errp); -} - -/* - * AIO callback routine called from GlusterFS thread. - */ -static void gluster_finish_aiocb(struct glfs_fd *fd, ssize_t ret, -#ifdef CONFIG_GLUSTERFS_IOCB_HAS_STAT - struct glfs_stat *pre, struct glfs_stat *= post, -#endif - void *arg) -{ - GlusterAIOCB *acb =3D (GlusterAIOCB *)arg; - - if (!ret || ret =3D=3D acb->size) { - acb->ret =3D 0; /* Success */ - } else if (ret < 0) { - acb->ret =3D -errno; /* Read/Write failed */ - } else { - acb->ret =3D -EIO; /* Partial read/write - fail it */ - } - - /* - * Safe to call: The coroutine will yield exactly once awaiting this - * scheduling, and the context is its own context, so it will be sched= uled - * once it does yield. - * - * (aio_co_wake() would call qemu_get_current_aio_context() to check w= hether - * we are in the same context, but we are not in a qemu thread, so we = cannot - * do that. Use aio_co_schedule() directly.) - */ - aio_co_schedule(qemu_coroutine_get_aio_context(acb->coroutine), - acb->coroutine); -} - -static void qemu_gluster_parse_flags(int bdrv_flags, int *open_flags) -{ - assert(open_flags !=3D NULL); - - *open_flags |=3D O_BINARY; - - if (bdrv_flags & BDRV_O_RDWR) { - *open_flags |=3D O_RDWR; - } else { - *open_flags |=3D O_RDONLY; - } - - if ((bdrv_flags & BDRV_O_NOCACHE)) { - *open_flags |=3D O_DIRECT; - } -} - -/* - * Do SEEK_DATA/HOLE to detect if it is functional. Older broken versions = of - * gfapi incorrectly return the current offset when SEEK_DATA/HOLE is used. - * - Corrected versions return -1 and set errno to EINVAL. - * - Versions that support SEEK_DATA/HOLE correctly, will return -1 and set - * errno to ENXIO when SEEK_DATA is called with a position of EOF. - */ -static bool qemu_gluster_test_seek(struct glfs_fd *fd) -{ - off_t ret =3D 0; - -#if defined SEEK_HOLE && defined SEEK_DATA - off_t eof; - - eof =3D glfs_lseek(fd, 0, SEEK_END); - if (eof < 0) { - /* this should never occur */ - return false; - } - - /* this should always fail with ENXIO if SEEK_DATA is supported */ - ret =3D glfs_lseek(fd, eof, SEEK_DATA); -#endif - - return (ret < 0) && (errno =3D=3D ENXIO); -} - -static int qemu_gluster_open(BlockDriverState *bs, QDict *options, - int bdrv_flags, Error **errp) -{ - BDRVGlusterState *s =3D bs->opaque; - int open_flags =3D 0; - int ret =3D 0; - BlockdevOptionsGluster *gconf =3D NULL; - QemuOpts *opts; - const char *filename, *logfile; - - opts =3D qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); - if (!qemu_opts_absorb_qdict(opts, options, errp)) { - ret =3D -EINVAL; - goto out; - } - - warn_report_once("'gluster' is deprecated"); - - filename =3D qemu_opt_get(opts, GLUSTER_OPT_FILENAME); - - s->debug =3D qemu_opt_get_number(opts, GLUSTER_OPT_DEBUG, - GLUSTER_DEBUG_DEFAULT); - if (s->debug < 0) { - s->debug =3D 0; - } else if (s->debug > GLUSTER_DEBUG_MAX) { - s->debug =3D GLUSTER_DEBUG_MAX; - } - - gconf =3D g_new0(BlockdevOptionsGluster, 1); - gconf->debug =3D s->debug; - gconf->has_debug =3D true; - - logfile =3D qemu_opt_get(opts, GLUSTER_OPT_LOGFILE); - s->logfile =3D g_strdup(logfile ? logfile : GLUSTER_LOGFILE_DEFAULT); - - gconf->logfile =3D g_strdup(s->logfile); - - s->glfs =3D qemu_gluster_init(gconf, filename, options, errp); - if (!s->glfs) { - ret =3D -errno; - goto out; - } - -#ifdef CONFIG_GLUSTERFS_XLATOR_OPT - /* Without this, if fsync fails for a recoverable reason (for instance, - * ENOSPC), gluster will dump its cache, preventing retries. This mea= ns - * almost certain data loss. Not all gluster versions support the - * 'resync-failed-syncs-after-fsync' key value, but there is no way to - * discover during runtime if it is supported (this api returns succes= s for - * unknown key/value pairs) */ - ret =3D glfs_set_xlator_option(s->glfs, "*-write-behind", - "resync-failed-syncs-after-fsync= ", - "on"); - if (ret < 0) { - error_setg_errno(errp, errno, "Unable to set xlator key/value pair= "); - ret =3D -errno; - goto out; - } -#endif - - qemu_gluster_parse_flags(bdrv_flags, &open_flags); - - s->fd =3D glfs_open(s->glfs, gconf->path, open_flags); - ret =3D s->fd ? 0 : -errno; - - if (ret =3D=3D -EACCES || ret =3D=3D -EROFS) { - /* Try to degrade to read-only, but if it doesn't work, still use = the - * normal error message. */ - bdrv_graph_rdlock_main_loop(); - if (bdrv_apply_auto_read_only(bs, NULL, NULL) =3D=3D 0) { - open_flags =3D (open_flags & ~O_RDWR) | O_RDONLY; - s->fd =3D glfs_open(s->glfs, gconf->path, open_flags); - ret =3D s->fd ? 0 : -errno; - } - bdrv_graph_rdunlock_main_loop(); - } - - s->supports_seek_data =3D qemu_gluster_test_seek(s->fd); - -out: - qemu_opts_del(opts); - qapi_free_BlockdevOptionsGluster(gconf); - if (!ret) { - return ret; - } - g_free(s->logfile); - if (s->fd) { - glfs_close(s->fd); - } - - glfs_clear_preopened(s->glfs); - - return ret; -} - -static void qemu_gluster_refresh_limits(BlockDriverState *bs, Error **errp) -{ - bs->bl.max_transfer =3D GLUSTER_MAX_TRANSFER; - bs->bl.max_pdiscard =3D MIN(SIZE_MAX, INT64_MAX); -} - -static int qemu_gluster_reopen_prepare(BDRVReopenState *state, - BlockReopenQueue *queue, Error **er= rp) -{ - int ret =3D 0; - BDRVGlusterState *s; - BDRVGlusterReopenState *reop_s; - BlockdevOptionsGluster *gconf; - int open_flags =3D 0; - - assert(state !=3D NULL); - assert(state->bs !=3D NULL); - - s =3D state->bs->opaque; - - state->opaque =3D g_new0(BDRVGlusterReopenState, 1); - reop_s =3D state->opaque; - - qemu_gluster_parse_flags(state->flags, &open_flags); - - gconf =3D g_new0(BlockdevOptionsGluster, 1); - gconf->debug =3D s->debug; - gconf->has_debug =3D true; - gconf->logfile =3D g_strdup(s->logfile); - - /* - * If 'state->bs->exact_filename' is empty, 'state->options' should co= ntain - * the JSON parameters already parsed. - */ - if (state->bs->exact_filename[0] !=3D '\0') { - reop_s->glfs =3D qemu_gluster_init(gconf, state->bs->exact_filenam= e, NULL, - errp); - } else { - reop_s->glfs =3D qemu_gluster_init(gconf, NULL, state->options, er= rp); - } - if (reop_s->glfs =3D=3D NULL) { - ret =3D -errno; - goto exit; - } - -#ifdef CONFIG_GLUSTERFS_XLATOR_OPT - ret =3D glfs_set_xlator_option(reop_s->glfs, "*-write-behind", - "resync-failed-syncs-after-fsync", "on"); - if (ret < 0) { - error_setg_errno(errp, errno, "Unable to set xlator key/value pair= "); - ret =3D -errno; - goto exit; - } -#endif - - reop_s->fd =3D glfs_open(reop_s->glfs, gconf->path, open_flags); - if (reop_s->fd =3D=3D NULL) { - /* reops->glfs will be cleaned up in _abort */ - ret =3D -errno; - goto exit; - } - -exit: - /* state->opaque will be freed in either the _abort or _commit */ - qapi_free_BlockdevOptionsGluster(gconf); - return ret; -} - -static void qemu_gluster_reopen_commit(BDRVReopenState *state) -{ - BDRVGlusterReopenState *reop_s =3D state->opaque; - BDRVGlusterState *s =3D state->bs->opaque; - - - /* close the old */ - if (s->fd) { - glfs_close(s->fd); - } - - glfs_clear_preopened(s->glfs); - - /* use the newly opened image / connection */ - s->fd =3D reop_s->fd; - s->glfs =3D reop_s->glfs; - - g_free(state->opaque); - state->opaque =3D NULL; -} - - -static void qemu_gluster_reopen_abort(BDRVReopenState *state) -{ - BDRVGlusterReopenState *reop_s =3D state->opaque; - - if (reop_s =3D=3D NULL) { - return; - } - - if (reop_s->fd) { - glfs_close(reop_s->fd); - } - - glfs_clear_preopened(reop_s->glfs); - - g_free(state->opaque); - state->opaque =3D NULL; -} - -#ifdef CONFIG_GLUSTERFS_ZEROFILL -static coroutine_fn int qemu_gluster_co_pwrite_zeroes(BlockDriverState *bs, - int64_t offset, - int64_t bytes, - BdrvRequestFlags fla= gs) -{ - int ret; - GlusterAIOCB acb; - BDRVGlusterState *s =3D bs->opaque; - - acb.size =3D bytes; - acb.ret =3D 0; - acb.coroutine =3D qemu_coroutine_self(); - - ret =3D glfs_zerofill_async(s->fd, offset, bytes, gluster_finish_aiocb= , &acb); - if (ret < 0) { - return -errno; - } - - qemu_coroutine_yield(); - return acb.ret; -} -#endif - -static int qemu_gluster_do_truncate(struct glfs_fd *fd, int64_t offset, - PreallocMode prealloc, Error **errp) -{ - int64_t current_length; - - current_length =3D glfs_lseek(fd, 0, SEEK_END); - if (current_length < 0) { - error_setg_errno(errp, errno, "Failed to determine current size"); - return -errno; - } - - if (current_length > offset && prealloc !=3D PREALLOC_MODE_OFF) { - error_setg(errp, "Cannot use preallocation for shrinking files"); - return -ENOTSUP; - } - - if (current_length =3D=3D offset) { - return 0; - } - - switch (prealloc) { -#ifdef CONFIG_GLUSTERFS_FALLOCATE - case PREALLOC_MODE_FALLOC: - if (glfs_fallocate(fd, 0, current_length, offset - current_length)= ) { - error_setg_errno(errp, errno, "Could not preallocate data"); - return -errno; - } - break; -#endif /* CONFIG_GLUSTERFS_FALLOCATE */ -#ifdef CONFIG_GLUSTERFS_ZEROFILL - case PREALLOC_MODE_FULL: - if (glfs_ftruncate(fd, offset)) { - error_setg_errno(errp, errno, "Could not resize file"); - return -errno; - } - if (glfs_zerofill(fd, current_length, offset - current_length)) { - error_setg_errno(errp, errno, "Could not zerofill the new area= "); - return -errno; - } - break; -#endif /* CONFIG_GLUSTERFS_ZEROFILL */ - case PREALLOC_MODE_OFF: - if (glfs_ftruncate(fd, offset)) { - error_setg_errno(errp, errno, "Could not resize file"); - return -errno; - } - break; - default: - error_setg(errp, "Unsupported preallocation mode: %s", - PreallocMode_str(prealloc)); - return -EINVAL; - } - - return 0; -} - -static int qemu_gluster_co_create(BlockdevCreateOptions *options, - Error **errp) -{ - BlockdevCreateOptionsGluster *opts =3D &options->u.gluster; - struct glfs *glfs; - struct glfs_fd *fd =3D NULL; - int ret =3D 0; - - assert(options->driver =3D=3D BLOCKDEV_DRIVER_GLUSTER); - - glfs =3D qemu_gluster_glfs_init(opts->location, errp); - if (!glfs) { - ret =3D -errno; - goto out; - } - - fd =3D glfs_creat(glfs, opts->location->path, - O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, S_IRUSR | S_I= WUSR); - if (!fd) { - ret =3D -errno; - goto out; - } - - ret =3D qemu_gluster_do_truncate(fd, opts->size, opts->preallocation, = errp); - -out: - if (fd) { - if (glfs_close(fd) !=3D 0 && ret =3D=3D 0) { - ret =3D -errno; - } - } - glfs_clear_preopened(glfs); - return ret; -} - -static int coroutine_fn qemu_gluster_co_create_opts(BlockDriver *drv, - const char *filename, - QemuOpts *opts, - Error **errp) -{ - BlockdevCreateOptions *options; - BlockdevCreateOptionsGluster *gopts; - BlockdevOptionsGluster *gconf; - char *tmp =3D NULL; - Error *local_err =3D NULL; - int ret; - - options =3D g_new0(BlockdevCreateOptions, 1); - options->driver =3D BLOCKDEV_DRIVER_GLUSTER; - gopts =3D &options->u.gluster; - - gconf =3D g_new0(BlockdevOptionsGluster, 1); - gopts->location =3D gconf; - - gopts->size =3D ROUND_UP(qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0= ), - BDRV_SECTOR_SIZE); - - tmp =3D qemu_opt_get_del(opts, BLOCK_OPT_PREALLOC); - gopts->preallocation =3D qapi_enum_parse(&PreallocMode_lookup, tmp, - PREALLOC_MODE_OFF, &local_err); - g_free(tmp); - if (local_err) { - error_propagate(errp, local_err); - ret =3D -EINVAL; - goto fail; - } - - gconf->debug =3D qemu_opt_get_number_del(opts, GLUSTER_OPT_DEBUG, - GLUSTER_DEBUG_DEFAULT); - if (gconf->debug < 0) { - gconf->debug =3D 0; - } else if (gconf->debug > GLUSTER_DEBUG_MAX) { - gconf->debug =3D GLUSTER_DEBUG_MAX; - } - gconf->has_debug =3D true; - - gconf->logfile =3D qemu_opt_get_del(opts, GLUSTER_OPT_LOGFILE); - if (!gconf->logfile) { - gconf->logfile =3D g_strdup(GLUSTER_LOGFILE_DEFAULT); - } - - ret =3D qemu_gluster_parse(gconf, filename, NULL, errp); - if (ret < 0) { - goto fail; - } - - ret =3D qemu_gluster_co_create(options, errp); - if (ret < 0) { - goto fail; - } - - ret =3D 0; -fail: - qapi_free_BlockdevCreateOptions(options); - return ret; -} - -static coroutine_fn int qemu_gluster_co_rw(BlockDriverState *bs, - int64_t sector_num, int nb_sect= ors, - QEMUIOVector *qiov, int write) -{ - int ret; - GlusterAIOCB acb; - BDRVGlusterState *s =3D bs->opaque; - size_t size =3D nb_sectors * BDRV_SECTOR_SIZE; - off_t offset =3D sector_num * BDRV_SECTOR_SIZE; - - acb.size =3D size; - acb.ret =3D 0; - acb.coroutine =3D qemu_coroutine_self(); - - if (write) { - ret =3D glfs_pwritev_async(s->fd, qiov->iov, qiov->niov, offset, 0, - gluster_finish_aiocb, &acb); - } else { - ret =3D glfs_preadv_async(s->fd, qiov->iov, qiov->niov, offset, 0, - gluster_finish_aiocb, &acb); - } - - if (ret < 0) { - return -errno; - } - - qemu_coroutine_yield(); - return acb.ret; -} - -static coroutine_fn int qemu_gluster_co_truncate(BlockDriverState *bs, - int64_t offset, - bool exact, - PreallocMode prealloc, - BdrvRequestFlags flags, - Error **errp) -{ - BDRVGlusterState *s =3D bs->opaque; - return qemu_gluster_do_truncate(s->fd, offset, prealloc, errp); -} - -static coroutine_fn int qemu_gluster_co_readv(BlockDriverState *bs, - int64_t sector_num, - int nb_sectors, - QEMUIOVector *qiov) -{ - return qemu_gluster_co_rw(bs, sector_num, nb_sectors, qiov, 0); -} - -static coroutine_fn int qemu_gluster_co_writev(BlockDriverState *bs, - int64_t sector_num, - int nb_sectors, - QEMUIOVector *qiov, - int flags) -{ - return qemu_gluster_co_rw(bs, sector_num, nb_sectors, qiov, 1); -} - -static void qemu_gluster_close(BlockDriverState *bs) -{ - BDRVGlusterState *s =3D bs->opaque; - - g_free(s->logfile); - if (s->fd) { - glfs_close(s->fd); - s->fd =3D NULL; - } - glfs_clear_preopened(s->glfs); -} - -static coroutine_fn int qemu_gluster_co_flush_to_disk(BlockDriverState *bs) -{ - int ret; - GlusterAIOCB acb; - BDRVGlusterState *s =3D bs->opaque; - - acb.size =3D 0; - acb.ret =3D 0; - acb.coroutine =3D qemu_coroutine_self(); - - ret =3D glfs_fsync_async(s->fd, gluster_finish_aiocb, &acb); - if (ret < 0) { - ret =3D -errno; - goto error; - } - - qemu_coroutine_yield(); - if (acb.ret < 0) { - ret =3D acb.ret; - goto error; - } - - return acb.ret; - -error: - /* Some versions of Gluster (3.5.6 -> 3.5.8?) will not retain its cache - * after a fsync failure, so we have no way of allowing the guest to s= afely - * continue. Gluster versions prior to 3.5.6 don't retain the cache - * either, but will invalidate the fd on error, so this is again our o= nly - * option. - * - * The 'resync-failed-syncs-after-fsync' xlator option for the - * write-behind cache will cause later gluster versions to retain its - * cache after error, so long as the fd remains open. However, we - * currently have no way of knowing if this option is supported. - * - * TODO: Once gluster provides a way for us to determine if the option - * is supported, bypass the closure and setting drv to NULL. */ - qemu_gluster_close(bs); - bs->drv =3D NULL; - return ret; -} - -#ifdef CONFIG_GLUSTERFS_DISCARD -static coroutine_fn int qemu_gluster_co_pdiscard(BlockDriverState *bs, - int64_t offset, int64_t b= ytes) -{ - int ret; - GlusterAIOCB acb; - BDRVGlusterState *s =3D bs->opaque; - - assert(bytes <=3D SIZE_MAX); /* rely on max_pdiscard */ - - acb.size =3D 0; - acb.ret =3D 0; - acb.coroutine =3D qemu_coroutine_self(); - - ret =3D glfs_discard_async(s->fd, offset, bytes, gluster_finish_aiocb,= &acb); - if (ret < 0) { - return -errno; - } - - qemu_coroutine_yield(); - return acb.ret; -} -#endif - -static int64_t coroutine_fn qemu_gluster_co_getlength(BlockDriverState *bs) -{ - BDRVGlusterState *s =3D bs->opaque; - int64_t ret; - - ret =3D glfs_lseek(s->fd, 0, SEEK_END); - if (ret < 0) { - return -errno; - } else { - return ret; - } -} - -static int64_t coroutine_fn -qemu_gluster_co_get_allocated_file_size(BlockDriverState *bs) -{ - BDRVGlusterState *s =3D bs->opaque; - struct stat st; - int ret; - - ret =3D glfs_fstat(s->fd, &st); - if (ret < 0) { - return -errno; - } else { - return st.st_blocks * 512; - } -} - -/* - * Find allocation range in @bs around offset @start. - * May change underlying file descriptor's file offset. - * If @start is not in a hole, store @start in @data, and the - * beginning of the next hole in @hole, and return 0. - * If @start is in a non-trailing hole, store @start in @hole and the - * beginning of the next non-hole in @data, and return 0. - * If @start is in a trailing hole or beyond EOF, return -ENXIO. - * If we can't find out, return a negative errno other than -ENXIO. - * - * (Shamefully copied from file-posix.c, only minuscule adaptions.) - */ -static int find_allocation(BlockDriverState *bs, off_t start, - off_t *data, off_t *hole) -{ - BDRVGlusterState *s =3D bs->opaque; - - if (!s->supports_seek_data) { - goto exit; - } - -#if defined SEEK_HOLE && defined SEEK_DATA - off_t offs; - - /* - * SEEK_DATA cases: - * D1. offs =3D=3D start: start is in data - * D2. offs > start: start is in a hole, next data at offs - * D3. offs < 0, errno =3D ENXIO: either start is in a trailing hole - * or start is beyond EOF - * If the latter happens, the file has been truncated behind - * our back since we opened it. All bets are off then. - * Treating like a trailing hole is simplest. - * D4. offs < 0, errno !=3D ENXIO: we learned nothing - */ - offs =3D glfs_lseek(s->fd, start, SEEK_DATA); - if (offs < 0) { - return -errno; /* D3 or D4 */ - } - - if (offs < start) { - /* This is not a valid return by lseek(). We are safe to just ret= urn - * -EIO in this case, and we'll treat it like D4. Unfortunately so= me - * versions of gluster server will return offs < start, so an ass= ert - * here will unnecessarily abort QEMU. */ - return -EIO; - } - - if (offs > start) { - /* D2: in hole, next data at offs */ - *hole =3D start; - *data =3D offs; - return 0; - } - - /* D1: in data, end not yet known */ - - /* - * SEEK_HOLE cases: - * H1. offs =3D=3D start: start is in a hole - * If this happens here, a hole has been dug behind our back - * since the previous lseek(). - * H2. offs > start: either start is in data, next hole at offs, - * or start is in trailing hole, EOF at offs - * Linux treats trailing holes like any other hole: offs =3D=3D - * start. Solaris seeks to EOF instead: offs > start (blech). - * If that happens here, a hole has been dug behind our back - * since the previous lseek(). - * H3. offs < 0, errno =3D ENXIO: start is beyond EOF - * If this happens, the file has been truncated behind our - * back since we opened it. Treat it like a trailing hole. - * H4. offs < 0, errno !=3D ENXIO: we learned nothing - * Pretend we know nothing at all, i.e. "forget" about D1. - */ - offs =3D glfs_lseek(s->fd, start, SEEK_HOLE); - if (offs < 0) { - return -errno; /* D1 and (H3 or H4) */ - } - - if (offs < start) { - /* This is not a valid return by lseek(). We are safe to just ret= urn - * -EIO in this case, and we'll treat it like H4. Unfortunately so= me - * versions of gluster server will return offs < start, so an ass= ert - * here will unnecessarily abort QEMU. */ - return -EIO; - } - - if (offs > start) { - /* - * D1 and H2: either in data, next hole at offs, or it was in - * data but is now in a trailing hole. In the latter case, - * all bets are off. Treating it as if it there was data all - * the way to EOF is safe, so simply do that. - */ - *data =3D start; - *hole =3D offs; - return 0; - } - - /* D1 and H1 */ - return -EBUSY; -#endif - -exit: - return -ENOTSUP; -} - -/* - * Returns the allocation status of the specified offset. - * - * The block layer guarantees 'offset' and 'bytes' are within bounds. - * - * 'pnum' is set to the number of bytes (including and immediately followi= ng - * the specified offset) that are known to be in the same - * allocated/unallocated state. - * - * 'bytes' is a soft cap for 'pnum'. If the information is free, 'pnum' m= ay - * well exceed it. - * - * (Based on raw_co_block_status() from file-posix.c.) - */ -static int coroutine_fn qemu_gluster_co_block_status(BlockDriverState *bs, - unsigned int mode, - int64_t offset, - int64_t bytes, - int64_t *pnum, - int64_t *map, - BlockDriverState **fi= le) -{ - BDRVGlusterState *s =3D bs->opaque; - off_t data =3D 0, hole =3D 0; - int ret =3D -EINVAL; - - assert(QEMU_IS_ALIGNED(offset | bytes, bs->bl.request_alignment)); - - if (!s->fd) { - return ret; - } - - if (!(mode & BDRV_WANT_ZERO)) { - *pnum =3D bytes; - *map =3D offset; - *file =3D bs; - return BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID; - } - - ret =3D find_allocation(bs, offset, &data, &hole); - if (ret =3D=3D -ENXIO) { - /* Trailing hole */ - *pnum =3D bytes; - ret =3D BDRV_BLOCK_ZERO; - } else if (ret < 0) { - /* No info available, so pretend there are no holes */ - *pnum =3D bytes; - ret =3D BDRV_BLOCK_DATA; - } else if (data =3D=3D offset) { - /* On a data extent, compute bytes to the end of the extent, - * possibly including a partial sector at EOF. */ - *pnum =3D hole - offset; - - /* - * We are not allowed to return partial sectors, though, so - * round up if necessary. - */ - if (!QEMU_IS_ALIGNED(*pnum, bs->bl.request_alignment)) { - int64_t file_length =3D qemu_gluster_co_getlength(bs); - if (file_length > 0) { - /* Ignore errors, this is just a safeguard */ - assert(hole =3D=3D file_length); - } - *pnum =3D ROUND_UP(*pnum, bs->bl.request_alignment); - } - - ret =3D BDRV_BLOCK_DATA; - } else { - /* On a hole, compute bytes to the beginning of the next extent. = */ - assert(hole =3D=3D offset); - *pnum =3D data - offset; - ret =3D BDRV_BLOCK_ZERO; - } - - *map =3D offset; - *file =3D bs; - - return ret | BDRV_BLOCK_OFFSET_VALID; -} - - -static const char *const gluster_strong_open_opts[] =3D { - GLUSTER_OPT_VOLUME, - GLUSTER_OPT_PATH, - GLUSTER_OPT_TYPE, - GLUSTER_OPT_SERVER_PATTERN, - GLUSTER_OPT_HOST, - GLUSTER_OPT_PORT, - GLUSTER_OPT_TO, - GLUSTER_OPT_IPV4, - GLUSTER_OPT_IPV6, - GLUSTER_OPT_SOCKET, - - NULL -}; - -static BlockDriver bdrv_gluster =3D { - .format_name =3D "gluster", - .protocol_name =3D "gluster", - .instance_size =3D sizeof(BDRVGlusterState), - .bdrv_open =3D qemu_gluster_open, - .bdrv_reopen_prepare =3D qemu_gluster_reopen_prepare, - .bdrv_reopen_commit =3D qemu_gluster_reopen_commit, - .bdrv_reopen_abort =3D qemu_gluster_reopen_abort, - .bdrv_close =3D qemu_gluster_close, - .bdrv_co_create =3D qemu_gluster_co_create, - .bdrv_co_create_opts =3D qemu_gluster_co_create_opts, - .bdrv_co_getlength =3D qemu_gluster_co_getlength, - .bdrv_co_get_allocated_file_size =3D qemu_gluster_co_get_allocated_fil= e_size, - .bdrv_co_truncate =3D qemu_gluster_co_truncate, - .bdrv_co_readv =3D qemu_gluster_co_readv, - .bdrv_co_writev =3D qemu_gluster_co_writev, - .bdrv_co_flush_to_disk =3D qemu_gluster_co_flush_to_disk, -#ifdef CONFIG_GLUSTERFS_DISCARD - .bdrv_co_pdiscard =3D qemu_gluster_co_pdiscard, -#endif -#ifdef CONFIG_GLUSTERFS_ZEROFILL - .bdrv_co_pwrite_zeroes =3D qemu_gluster_co_pwrite_zeroes, -#endif - .bdrv_co_block_status =3D qemu_gluster_co_block_status, - .bdrv_refresh_limits =3D qemu_gluster_refresh_limits, - .create_opts =3D &qemu_gluster_create_opts, - .strong_runtime_opts =3D gluster_strong_open_opts, -}; - -static BlockDriver bdrv_gluster_tcp =3D { - .format_name =3D "gluster", - .protocol_name =3D "gluster+tcp", - .instance_size =3D sizeof(BDRVGlusterState), - .bdrv_open =3D qemu_gluster_open, - .bdrv_reopen_prepare =3D qemu_gluster_reopen_prepare, - .bdrv_reopen_commit =3D qemu_gluster_reopen_commit, - .bdrv_reopen_abort =3D qemu_gluster_reopen_abort, - .bdrv_close =3D qemu_gluster_close, - .bdrv_co_create =3D qemu_gluster_co_create, - .bdrv_co_create_opts =3D qemu_gluster_co_create_opts, - .bdrv_co_getlength =3D qemu_gluster_co_getlength, - .bdrv_co_get_allocated_file_size =3D qemu_gluster_co_get_allocated_fil= e_size, - .bdrv_co_truncate =3D qemu_gluster_co_truncate, - .bdrv_co_readv =3D qemu_gluster_co_readv, - .bdrv_co_writev =3D qemu_gluster_co_writev, - .bdrv_co_flush_to_disk =3D qemu_gluster_co_flush_to_disk, -#ifdef CONFIG_GLUSTERFS_DISCARD - .bdrv_co_pdiscard =3D qemu_gluster_co_pdiscard, -#endif -#ifdef CONFIG_GLUSTERFS_ZEROFILL - .bdrv_co_pwrite_zeroes =3D qemu_gluster_co_pwrite_zeroes, -#endif - .bdrv_co_block_status =3D qemu_gluster_co_block_status, - .bdrv_refresh_limits =3D qemu_gluster_refresh_limits, - .create_opts =3D &qemu_gluster_create_opts, - .strong_runtime_opts =3D gluster_strong_open_opts, -}; - -static BlockDriver bdrv_gluster_unix =3D { - .format_name =3D "gluster", - .protocol_name =3D "gluster+unix", - .instance_size =3D sizeof(BDRVGlusterState), - .bdrv_open =3D qemu_gluster_open, - .bdrv_reopen_prepare =3D qemu_gluster_reopen_prepare, - .bdrv_reopen_commit =3D qemu_gluster_reopen_commit, - .bdrv_reopen_abort =3D qemu_gluster_reopen_abort, - .bdrv_close =3D qemu_gluster_close, - .bdrv_co_create =3D qemu_gluster_co_create, - .bdrv_co_create_opts =3D qemu_gluster_co_create_opts, - .bdrv_co_getlength =3D qemu_gluster_co_getlength, - .bdrv_co_get_allocated_file_size =3D qemu_gluster_co_get_allocated_fil= e_size, - .bdrv_co_truncate =3D qemu_gluster_co_truncate, - .bdrv_co_readv =3D qemu_gluster_co_readv, - .bdrv_co_writev =3D qemu_gluster_co_writev, - .bdrv_co_flush_to_disk =3D qemu_gluster_co_flush_to_disk, -#ifdef CONFIG_GLUSTERFS_DISCARD - .bdrv_co_pdiscard =3D qemu_gluster_co_pdiscard, -#endif -#ifdef CONFIG_GLUSTERFS_ZEROFILL - .bdrv_co_pwrite_zeroes =3D qemu_gluster_co_pwrite_zeroes, -#endif - .bdrv_co_block_status =3D qemu_gluster_co_block_status, - .bdrv_refresh_limits =3D qemu_gluster_refresh_limits, - .create_opts =3D &qemu_gluster_create_opts, - .strong_runtime_opts =3D gluster_strong_open_opts, -}; - -static void bdrv_gluster_init(void) -{ - bdrv_register(&bdrv_gluster_unix); - bdrv_register(&bdrv_gluster_tcp); - bdrv_register(&bdrv_gluster); -} - -block_init(bdrv_gluster_init); diff --git a/tests/qtest/modules-test.c b/tests/qtest/modules-test.c index be2575ae6d7..040251c11ec 100644 --- a/tests/qtest/modules-test.c +++ b/tests/qtest/modules-test.c @@ -22,9 +22,6 @@ int main(int argc, char *argv[]) #ifdef CONFIG_CURL "block-", "curl", #endif -#ifdef CONFIG_GLUSTERFS - "block-", "gluster", -#endif #ifdef CONFIG_LIBISCSI "block-", "iscsi", #endif diff --git a/MAINTAINERS b/MAINTAINERS index eda1e84268a..ba6055619bd 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -4268,12 +4268,6 @@ L: qemu-block@nongnu.org S: Odd Fixes F: block/curl.c =20 -GLUSTER -L: qemu-block@nongnu.org -L: integration@gluster.org -S: Odd Fixes -F: block/gluster.c - Null Block Driver M: Fam Zheng L: qemu-block@nongnu.org diff --git a/block/meson.build b/block/meson.build index 34b1b2a3063..bc419aebf08 100644 --- a/block/meson.build +++ b/block/meson.build @@ -109,7 +109,6 @@ modsrc =3D [] foreach m : [ [blkio, 'blkio', files('blkio.c')], [curl, 'curl', files('curl.c')], - [glusterfs, 'gluster', files('gluster.c')], [libiscsi, 'iscsi', files('iscsi.c')], [libnfs, 'nfs', files('nfs.c')], [libssh, 'ssh', files('ssh.c')], diff --git a/meson.build b/meson.build index 37060c030ed..70613bf4afc 100644 --- a/meson.build +++ b/meson.build @@ -1662,43 +1662,6 @@ if not get_option('rbd').auto() or have_block endif endif =20 -glusterfs =3D not_found -glusterfs_ftruncate_has_stat =3D false -glusterfs_iocb_has_stat =3D false -if not get_option('glusterfs').auto() or have_block - glusterfs =3D dependency('glusterfs-api', version: '>=3D3', - required: get_option('glusterfs'), - method: 'pkg-config') - if glusterfs.found() - glusterfs_ftruncate_has_stat =3D cc.links(''' - #include - - int - main(void) - { - /* new glfs_ftruncate() passes two additional args */ - return glfs_ftruncate(NULL, 0, NULL, NULL); - } - ''', dependencies: glusterfs) - glusterfs_iocb_has_stat =3D cc.links(''' - #include - - /* new glfs_io_cbk() passes two additional glfs_stat structs */ - static void - glusterfs_iocb(glfs_fd_t *fd, ssize_t ret, struct glfs_stat *prestat= , struct glfs_stat *poststat, void *data) - {} - - int - main(void) - { - glfs_io_cbk iocb =3D &glusterfs_iocb; - iocb(NULL, 0 , NULL, NULL, NULL); - return 0; - } - ''', dependencies: glusterfs) - endif -endif - hv_balloon =3D false if get_option('hv_balloon').allowed() and have_system if cc.links(''' @@ -2478,15 +2441,6 @@ config_host_data.set('CONFIG_CURL', curl.found()) config_host_data.set('CONFIG_CURSES', curses.found()) config_host_data.set('CONFIG_GBM', gbm.found()) config_host_data.set('CONFIG_GIO', gio.found()) -config_host_data.set('CONFIG_GLUSTERFS', glusterfs.found()) -if glusterfs.found() - config_host_data.set('CONFIG_GLUSTERFS_XLATOR_OPT', glusterfs.version().= version_compare('>=3D4')) - config_host_data.set('CONFIG_GLUSTERFS_DISCARD', glusterfs.version().ver= sion_compare('>=3D5')) - config_host_data.set('CONFIG_GLUSTERFS_FALLOCATE', glusterfs.version().v= ersion_compare('>=3D6')) - config_host_data.set('CONFIG_GLUSTERFS_ZEROFILL', glusterfs.version().ve= rsion_compare('>=3D6')) - config_host_data.set('CONFIG_GLUSTERFS_FTRUNCATE_HAS_STAT', glusterfs_ft= runcate_has_stat) - config_host_data.set('CONFIG_GLUSTERFS_IOCB_HAS_STAT', glusterfs_iocb_ha= s_stat) -endif config_host_data.set('CONFIG_GTK', gtk.found()) config_host_data.set('CONFIG_VTE', vte.found()) config_host_data.set('CONFIG_HEXAGON_IDEF_PARSER', get_option('hexagon_ide= f_parser')) @@ -5014,7 +4968,6 @@ if host_os =3D=3D 'windows' endif endif summary_info +=3D {'seccomp support': seccomp} -summary_info +=3D {'GlusterFS support': glusterfs} summary_info +=3D {'hv-balloon support': hv_balloon} summary_info +=3D {'TPM support': have_tpm} summary_info +=3D {'IGVM support': igvm} diff --git a/scripts/ci/setup/debian/debian-13-ppc64le.yaml b/scripts/ci/se= tup/debian/debian-13-ppc64le.yaml index b16d6d58f8e..e64321357da 100644 --- a/scripts/ci/setup/debian/debian-13-ppc64le.yaml +++ b/scripts/ci/setup/debian/debian-13-ppc64le.yaml @@ -50,7 +50,6 @@ packages: - libgbm-dev - libgcrypt20-dev - libglib2.0-dev - - libglusterfs-dev - libgnutls28-dev - libgtk-3-dev - libgtk-vnc-2.0-dev diff --git a/scripts/ci/setup/ubuntu/ubuntu-2404-aarch64.yaml b/scripts/ci/= setup/ubuntu/ubuntu-2404-aarch64.yaml index b58fcda0fa3..12b0e38a220 100644 --- a/scripts/ci/setup/ubuntu/ubuntu-2404-aarch64.yaml +++ b/scripts/ci/setup/ubuntu/ubuntu-2404-aarch64.yaml @@ -50,7 +50,6 @@ packages: - libgbm-dev - libgcrypt20-dev - libglib2.0-dev - - libglusterfs-dev - libgnutls28-dev - libgtk-3-dev - libgtk-vnc-2.0-dev diff --git a/scripts/ci/setup/ubuntu/ubuntu-2404-s390x.yaml b/scripts/ci/se= tup/ubuntu/ubuntu-2404-s390x.yaml index fa439db4ca1..56299f4cc2b 100644 --- a/scripts/ci/setup/ubuntu/ubuntu-2404-s390x.yaml +++ b/scripts/ci/setup/ubuntu/ubuntu-2404-s390x.yaml @@ -50,7 +50,6 @@ packages: - libgbm-dev - libgcrypt20-dev - libglib2.0-dev - - libglusterfs-dev - libgnutls28-dev - libgtk-3-dev - libgtk-vnc-2.0-dev diff --git a/scripts/coverity-scan/coverity-scan.docker b/scripts/coverity-= scan/coverity-scan.docker index a349578526d..93e558c8623 100644 --- a/scripts/coverity-scan/coverity-scan.docker +++ b/scripts/coverity-scan/coverity-scan.docker @@ -61,7 +61,6 @@ exec "$@"' > /usr/bin/nosync && \ glib2-static \ glibc-langpack-en \ glibc-static \ - glusterfs-api-devel \ gnutls-devel \ gtk3-devel \ hostname \ diff --git a/scripts/coverity-scan/run-coverity-scan b/scripts/coverity-sca= n/run-coverity-scan index 9b89a3303f5..2f9ccd5e44b 100755 --- a/scripts/coverity-scan/run-coverity-scan +++ b/scripts/coverity-scan/run-coverity-scan @@ -427,7 +427,7 @@ echo "Configuring..." --enable-libiscsi --enable-seccomp \ --enable-tpm --enable-libssh --enable-lzo --enable-snappy --enable-bzi= p2 \ --enable-numa --enable-rdma --enable-smartcard --enable-virglrenderer \ - --enable-mpath --enable-glusterfs \ + --enable-mpath \ --enable-virtfs --enable-zstd =20 echo "Running cov-build..." diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh index 23c960b2482..c003985047c 100644 --- a/scripts/meson-buildoptions.sh +++ b/scripts/meson-buildoptions.sh @@ -121,7 +121,6 @@ meson_options_help() { printf "%s\n" ' gcrypt libgcrypt cryptography support' printf "%s\n" ' gettext Localization of the GTK+ user interface' printf "%s\n" ' gio use libgio for D-Bus support' - printf "%s\n" ' glusterfs Glusterfs block device driver' printf "%s\n" ' gnutls GNUTLS cryptography support' printf "%s\n" ' gtk GTK+ user interface' printf "%s\n" ' guest-agent Build QEMU Guest Agent' @@ -330,8 +329,6 @@ _meson_option_parse() { --disable-gettext) printf "%s" -Dgettext=3Ddisabled ;; --enable-gio) printf "%s" -Dgio=3Denabled ;; --disable-gio) printf "%s" -Dgio=3Ddisabled ;; - --enable-glusterfs) printf "%s" -Dglusterfs=3Denabled ;; - --disable-glusterfs) printf "%s" -Dglusterfs=3Ddisabled ;; --enable-gnutls) printf "%s" -Dgnutls=3Denabled ;; --disable-gnutls) printf "%s" -Dgnutls=3Ddisabled ;; --enable-gtk) printf "%s" -Dgtk=3Denabled ;; diff --git a/tests/docker/dockerfiles/debian-amd64-cross.docker b/tests/doc= ker/dockerfiles/debian-amd64-cross.docker index 6fad808e1b6..35c593502fc 100644 --- a/tests/docker/dockerfiles/debian-amd64-cross.docker +++ b/tests/docker/dockerfiles/debian-amd64-cross.docker @@ -108,7 +108,6 @@ RUN export DEBIAN_FRONTEND=3Dnoninteractive && \ libgbm-dev:amd64 \ libgcrypt20-dev:amd64 \ libglib2.0-dev:amd64 \ - libglusterfs-dev:amd64 \ libgnutls28-dev:amd64 \ libgtk-3-dev:amd64 \ libgtk-vnc-2.0-dev:amd64 \ diff --git a/tests/docker/dockerfiles/debian-arm64-cross.docker b/tests/doc= ker/dockerfiles/debian-arm64-cross.docker index 889d8a1a755..d188d538365 100644 --- a/tests/docker/dockerfiles/debian-arm64-cross.docker +++ b/tests/docker/dockerfiles/debian-arm64-cross.docker @@ -108,7 +108,6 @@ RUN export DEBIAN_FRONTEND=3Dnoninteractive && \ libgbm-dev:arm64 \ libgcrypt20-dev:arm64 \ libglib2.0-dev:arm64 \ - libglusterfs-dev:arm64 \ libgnutls28-dev:arm64 \ libgtk-3-dev:arm64 \ libgtk-vnc-2.0-dev:arm64 \ diff --git a/tests/docker/dockerfiles/debian-mips64el-cross.docker b/tests/= docker/dockerfiles/debian-mips64el-cross.docker index 90a2ef15574..d139c10c555 100644 --- a/tests/docker/dockerfiles/debian-mips64el-cross.docker +++ b/tests/docker/dockerfiles/debian-mips64el-cross.docker @@ -106,7 +106,6 @@ RUN export DEBIAN_FRONTEND=3Dnoninteractive && \ libgbm-dev:mips64el \ libgcrypt20-dev:mips64el \ libglib2.0-dev:mips64el \ - libglusterfs-dev:mips64el \ libgnutls28-dev:mips64el \ libgtk-3-dev:mips64el \ libgtk-vnc-2.0-dev:mips64el \ diff --git a/tests/docker/dockerfiles/debian-mipsel-cross.docker b/tests/do= cker/dockerfiles/debian-mipsel-cross.docker index b7e36b3d974..2cfc33e8249 100644 --- a/tests/docker/dockerfiles/debian-mipsel-cross.docker +++ b/tests/docker/dockerfiles/debian-mipsel-cross.docker @@ -106,7 +106,6 @@ RUN export DEBIAN_FRONTEND=3Dnoninteractive && \ libgbm-dev:mipsel \ libgcrypt20-dev:mipsel \ libglib2.0-dev:mipsel \ - libglusterfs-dev:mipsel \ libgnutls28-dev:mipsel \ libgtk-3-dev:mipsel \ libgtk-vnc-2.0-dev:mipsel \ diff --git a/tests/docker/dockerfiles/debian-ppc64el-cross.docker b/tests/d= ocker/dockerfiles/debian-ppc64el-cross.docker index a70fbee0c1d..7198036380b 100644 --- a/tests/docker/dockerfiles/debian-ppc64el-cross.docker +++ b/tests/docker/dockerfiles/debian-ppc64el-cross.docker @@ -108,7 +108,6 @@ RUN export DEBIAN_FRONTEND=3Dnoninteractive && \ libgbm-dev:ppc64el \ libgcrypt20-dev:ppc64el \ libglib2.0-dev:ppc64el \ - libglusterfs-dev:ppc64el \ libgnutls28-dev:ppc64el \ libgtk-3-dev:ppc64el \ libgtk-vnc-2.0-dev:ppc64el \ diff --git a/tests/docker/dockerfiles/debian-riscv64-cross.docker b/tests/d= ocker/dockerfiles/debian-riscv64-cross.docker index 9ada5ecce0d..eb49da9781a 100644 --- a/tests/docker/dockerfiles/debian-riscv64-cross.docker +++ b/tests/docker/dockerfiles/debian-riscv64-cross.docker @@ -108,7 +108,6 @@ RUN export DEBIAN_FRONTEND=3Dnoninteractive && \ libgbm-dev:riscv64 \ libgcrypt20-dev:riscv64 \ libglib2.0-dev:riscv64 \ - libglusterfs-dev:riscv64 \ libgnutls28-dev:riscv64 \ libgtk-3-dev:riscv64 \ libgtk-vnc-2.0-dev:riscv64 \ diff --git a/tests/docker/dockerfiles/debian-s390x-cross.docker b/tests/doc= ker/dockerfiles/debian-s390x-cross.docker index a1de94ff9aa..f4c7896a75f 100644 --- a/tests/docker/dockerfiles/debian-s390x-cross.docker +++ b/tests/docker/dockerfiles/debian-s390x-cross.docker @@ -108,7 +108,6 @@ RUN export DEBIAN_FRONTEND=3Dnoninteractive && \ libgbm-dev:s390x \ libgcrypt20-dev:s390x \ libglib2.0-dev:s390x \ - libglusterfs-dev:s390x \ libgnutls28-dev:s390x \ libgtk-3-dev:s390x \ libgtk-vnc-2.0-dev:s390x \ diff --git a/tests/docker/dockerfiles/debian.docker b/tests/docker/dockerfi= les/debian.docker index c34923b253d..85b78f7e5f8 100644 --- a/tests/docker/dockerfiles/debian.docker +++ b/tests/docker/dockerfiles/debian.docker @@ -56,7 +56,6 @@ RUN export DEBIAN_FRONTEND=3Dnoninteractive && \ libgbm-dev \ libgcrypt20-dev \ libglib2.0-dev \ - libglusterfs-dev \ libgnutls28-dev \ libgtk-3-dev \ libgtk-vnc-2.0-dev \ diff --git a/tests/docker/dockerfiles/fedora-rust-nightly.docker b/tests/do= cker/dockerfiles/fedora-rust-nightly.docker index 8766f952ac8..5e88354f133 100644 --- a/tests/docker/dockerfiles/fedora-rust-nightly.docker +++ b/tests/docker/dockerfiles/fedora-rust-nightly.docker @@ -50,7 +50,6 @@ exec "$@"\n' > /usr/bin/nosync && \ glib2-static \ glibc-langpack-en \ glibc-static \ - glusterfs-api-devel \ gnutls-devel \ gtk-vnc2-devel \ gtk3-devel \ diff --git a/tests/docker/dockerfiles/fedora.docker b/tests/docker/dockerfi= les/fedora.docker index ec787aa7027..393ac0cce73 100644 --- a/tests/docker/dockerfiles/fedora.docker +++ b/tests/docker/dockerfiles/fedora.docker @@ -50,7 +50,6 @@ exec "$@"\n' > /usr/bin/nosync && \ glib2-static \ glibc-langpack-en \ glibc-static \ - glusterfs-api-devel \ gnutls-devel \ gtk-vnc2-devel \ gtk3-devel \ diff --git a/tests/docker/dockerfiles/opensuse-leap.docker b/tests/docker/d= ockerfiles/opensuse-leap.docker index 66e90fa3634..4b126b7e7de 100644 --- a/tests/docker/dockerfiles/opensuse-leap.docker +++ b/tests/docker/dockerfiles/opensuse-leap.docker @@ -34,7 +34,6 @@ RUN zypper update -y && \ glib2-devel \ glibc-locale \ glibc-static \ - glusterfs-devel \ gtk-vnc-devel \ gtk3-devel \ hostname \ diff --git a/tests/docker/dockerfiles/ubuntu2204.docker b/tests/docker/dock= erfiles/ubuntu2204.docker index fb5b03e7a1b..4617bbe1f65 100644 --- a/tests/docker/dockerfiles/ubuntu2204.docker +++ b/tests/docker/dockerfiles/ubuntu2204.docker @@ -55,7 +55,6 @@ RUN export DEBIAN_FRONTEND=3Dnoninteractive && \ libgbm-dev \ libgcrypt20-dev \ libglib2.0-dev \ - libglusterfs-dev \ libgnutls28-dev \ libgtk-3-dev \ libgtk-vnc-2.0-dev \ diff --git a/tests/lcitool/projects/qemu.yml b/tests/lcitool/projects/qemu.= yml index 131d9c4ec81..7d185cda3cc 100644 --- a/tests/lcitool/projects/qemu.yml +++ b/tests/lcitool/projects/qemu.yml @@ -31,7 +31,6 @@ packages: - glib2 - glib2-native - glib2-static - - glusterfs - gnutls - gtk3 - gtk-vnc --=20 2.54.0 From nobody Sat May 30 18:34:27 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1779210301; cv=none; d=zohomail.com; s=zohoarc; b=ezUaj+QOUiBa7+vUgf/QbkDOOXAnO/bj42olTAVzugGGqyev21WDBfdk9axALTPzJ2cXrnx9CHlaky/ljAM2zfnY+iuXO6rqN4TyB7E2MuoV2CFUvV8MfYPdAoBOk35ZpLhKkVyx13vXohLGZ4yvdRhQutBc6/geMweuGwzy1bc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779210301; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ZDiZvBOqCXe32Q96JaL0aL7xIlLVDLDQPmEuMhV6wbY=; b=ma3WUErMEFgNcjgeQGrnF7r02TDhOed2CC53fzr+H/OwDC2ao+aTybdgQ77/JD50EVGk51vwfH8EqIKgdJEPck2LSfhpxH8Qu1AgVfc6MIa9qG9Y4xlOsssrtjyVr0eKV+AsQG1dl8gxoVLiGXvGCrJCHgrqsZBWHCZZwF/cDgY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1779210301311269.7246278866255; Tue, 19 May 2026 10:05:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wPNrI-00086p-Tj; Tue, 19 May 2026 13:03:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wPNrF-00083v-CX for qemu-devel@nongnu.org; Tue, 19 May 2026 13:03:53 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wPNrD-0004Fr-2q for qemu-devel@nongnu.org; Tue, 19 May 2026 13:03:53 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-473-2iu0oAtiN_CjbxtOh_FMhQ-1; Tue, 19 May 2026 13:03:47 -0400 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 155F21956095; Tue, 19 May 2026 17:03:46 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.44.49.113]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id AEF901687; Tue, 19 May 2026 17:03:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779210230; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZDiZvBOqCXe32Q96JaL0aL7xIlLVDLDQPmEuMhV6wbY=; b=WtCNHKrGPiB6oeVwoK3pvOmQvUA0dcd2rjLAv+2vVWniqsi5TQRWSddt2m1W7vZ0twLeWS 9Ehk3VGlKfTC/MFQaHVjkiV36cveber7+aDne2Z+UlPva6yQs41tHh3Yx/OuMXzARIOXtC ujs0B17PZcz5MDxWhCZiKr0snTKJ8Ag= X-MC-Unique: 2iu0oAtiN_CjbxtOh_FMhQ-1 X-Mimecast-MFC-AGG-ID: 2iu0oAtiN_CjbxtOh_FMhQ_1779210226 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 09/18] MAINTAINERS: Add myself as maintainer for replication Date: Tue, 19 May 2026 19:03:08 +0200 Message-ID: <20260519170317.345032-10-kwolf@redhat.com> In-Reply-To: <20260519170317.345032-1-kwolf@redhat.com> References: <20260519170317.345032-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1779210303446158500 Content-Type: text/plain; charset="utf-8" From: Lukas Straub I recently took up maintainership for the orphaned COLO migraion component. Here I take over maintainership for replication which is another important component for COLO. Signed-off-by: Lukas Straub Message-ID: <20260425-replication_maintainer-v1-1-f6ab019ff0ca@web.de> Reviewed-by: Zhang Chen Acked-by: Peter Xu Signed-off-by: Kevin Wolf --- MAINTAINERS | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index ba6055619bd..634ceb2abed 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -4429,7 +4429,8 @@ F: block/export/vduse-blk.c F: block/export/vduse-blk.h =20 Replication -S: Orphan +M: Lukas Straub +S: Maintained F: replication* F: block/replication.c F: tests/unit/test-replication.c --=20 2.54.0 From nobody Sat May 30 18:34:27 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1779210352; cv=none; d=zohomail.com; s=zohoarc; b=iqwE8h6JqpwuMPMR3ZCw8KYdraghotll8Dvz6JGT+I2F5O8ZJ6Eykl7cy5jKjfiuoWRPpp5uxpUfQDvMqtwHwZwi+Be0c3e/70zAFGlDjBKQ6yeU7g5DLr//iELEg518Ein+LyQG2kwd/euZLzawa+AQEcAtRiSydSgTF2OBuqI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779210352; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=NhBVkRU7VVikTbkJi1mS0Rc4eTMWQV0X8lbyRLGHevk=; b=CM1z8smRezi0kGwuHF0aYydnDs32PEkRcU+7aKY5CwixRV99WbwMBW6q7xq7jxBO/uBJmdgsGqvGv0sZ/v9R36UsaTQ6kzqhGuyDMibo+Ar677BQpHYRx7Az1QpTTTwfOxsQk4l1Bw5mpVic8e3BOAL3O2NTTv1ybIwRghNEI7M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1779210352102694.5135418008599; Tue, 19 May 2026 10:05:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wPNrI-00086q-TF; Tue, 19 May 2026 13:03:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wPNrG-00084s-7f for qemu-devel@nongnu.org; Tue, 19 May 2026 13:03:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wPNrE-0004Ge-PP for qemu-devel@nongnu.org; Tue, 19 May 2026 13:03:53 -0400 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-88-kMu-mDvrOo-PzLQv_Fqv5g-1; Tue, 19 May 2026 13:03:48 -0400 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E46EA195609D; Tue, 19 May 2026 17:03:47 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.44.49.113]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7BEEE1681; Tue, 19 May 2026 17:03:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779210232; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NhBVkRU7VVikTbkJi1mS0Rc4eTMWQV0X8lbyRLGHevk=; b=GAqP2P/raumFfS97e7S3eXs3lVdOLuXBiyEojyTXoiS6MrVu48d1N6DoiBAp47cmp6/F/Y iSV0MdypNbYxUnU2nG53yn4xVweOuvswx8UQvyO+9Mt+UNZMGKGm4C3XdAOwR9ExPNqLWt J8N53nL08ZSozZAjbhy/wH878Dq0zxE= X-MC-Unique: kMu-mDvrOo-PzLQv_Fqv5g-1 X-Mimecast-MFC-AGG-ID: kMu-mDvrOo-PzLQv_Fqv5g_1779210228 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 10/18] MAINTAINERS: Rename Replication -> COLO block replication Date: Tue, 19 May 2026 19:03:09 +0200 Message-ID: <20260519170317.345032-11-kwolf@redhat.com> In-Reply-To: <20260519170317.345032-1-kwolf@redhat.com> References: <20260519170317.345032-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1779210353382154100 Content-Type: text/plain; charset="utf-8" From: Lukas Straub Give it a more descriptive name. Signed-off-by: Lukas Straub Message-ID: <20260425-replication_maintainer-v1-2-f6ab019ff0ca@web.de> Reviewed-by: Zhang Chen Acked-by: Peter Xu Signed-off-by: Kevin Wolf --- MAINTAINERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index 634ceb2abed..b75f3222f2f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -4428,7 +4428,7 @@ F: subprojects/libvduse/ F: block/export/vduse-blk.c F: block/export/vduse-blk.h =20 -Replication +COLO block replication M: Lukas Straub S: Maintained F: replication* --=20 2.54.0 From nobody Sat May 30 18:34:27 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1779210377; cv=none; d=zohomail.com; s=zohoarc; b=HE3DHqC2j3GQLOC+iTv6GGoUYBz+Ez4z4AV+spOmS8kJA8P9VNHaYSZFSgG4AkfzzpxtV3MVgcLru1t3GPpfq8btnuZjQfb53rZ6/hq8/874u5wUvNxfGCTfCZ0krfAktxG31ESH9KsYXvUZOnz4dmB6wptXtb43yKDp186Stwk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779210377; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=1AH5az7khb5tHxCCsE9fq8iMXZ1Gsct4n9e5LQg79iI=; b=LnHEBKoOuY2cbP7Poh1q/a7ATNVYC0JSVj029YMJhfHIrZV/+C3hVKlv+um10LeDOipEZkh9mu8xKt0S+wm9uGYNpCes+fmWfo5LRrr+k2HUyYItexozTgw4+pttBtSNJGEBut3pK7xnpNi3/nfGhxZoqyhWA67+UpdhaBIkeAo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1779210377282195.96017426343678; Tue, 19 May 2026 10:06:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wPNrj-0008DR-BJ; Tue, 19 May 2026 13:04:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wPNrI-00086H-0I for qemu-devel@nongnu.org; Tue, 19 May 2026 13:03:56 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wPNrG-0004IN-H4 for qemu-devel@nongnu.org; Tue, 19 May 2026 13:03:55 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-93-1RtbaCCKOEacnnL8jE3iDg-1; Tue, 19 May 2026 13:03:50 -0400 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A8F7D18002CB; Tue, 19 May 2026 17:03:49 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.44.49.113]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 55BD01681; Tue, 19 May 2026 17:03:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779210233; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1AH5az7khb5tHxCCsE9fq8iMXZ1Gsct4n9e5LQg79iI=; b=S5Yp7ontSAQoUPwQsT++TJA/wKYcDDUbeWB0scJnYKz0nj8PcgxFDgUBRUlrW6IdpMTmGn yXFUO3rxoJDloEPE0i1OFkDFT+aOJiEXyr93KJQCtwgExSaYxcECbJgx9hx0bGjpBjzYO6 XXfUEo/xtkwK/G9u2wSTFxxUJPDjGH0= X-MC-Unique: 1RtbaCCKOEacnnL8jE3iDg-1 X-Mimecast-MFC-AGG-ID: 1RtbaCCKOEacnnL8jE3iDg_1779210229 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 11/18] block: Create DEFAULT_BLOCK_CONF macro Date: Tue, 19 May 2026 19:03:10 +0200 Message-ID: <20260519170317.345032-12-kwolf@redhat.com> In-Reply-To: <20260519170317.345032-1-kwolf@redhat.com> References: <20260519170317.345032-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1779210379933154100 Content-Type: text/plain; charset="utf-8" The property default values from include/hw/block/block.h were duplicated in scsi_bus_legacy_handle_cmdline(), allowing them to go out of sync easily. There doesn't seem a good way to avoid the duplication, but moving them next to each other in the header file should help to avoid this problem in the future. Signed-off-by: Kevin Wolf Message-ID: <20260410152314.86412-2-kwolf@redhat.com> Signed-off-by: Kevin Wolf --- include/hw/block/block.h | 7 +++++++ hw/scsi/scsi-bus.c | 7 +------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/include/hw/block/block.h b/include/hw/block/block.h index 7dc19d8a453..e0a427039ee 100644 --- a/include/hw/block/block.h +++ b/include/hw/block/block.h @@ -51,6 +51,13 @@ static inline unsigned int get_physical_block_exp(BlockC= onf *conf) return exp; } =20 +#define DEFAULT_BLOCK_CONF (BlockConf) { \ + .bootindex =3D -1, \ + .share_rw =3D false, \ + .rerror =3D BLOCKDEV_ON_ERROR_AUTO, \ + .werror =3D BLOCKDEV_ON_ERROR_AUTO, \ +} + #define DEFINE_BLOCK_PROPERTIES_BASE(_state, _conf) \ DEFINE_PROP_ON_OFF_AUTO("backend_defaults", _state, \ _conf.backend_defaults, ON_OFF_AUTO_AUTO), \ diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c index 1a6b181b9d6..dccb2f25b2a 100644 --- a/hw/scsi/scsi-bus.c +++ b/hw/scsi/scsi-bus.c @@ -485,12 +485,7 @@ void scsi_bus_legacy_handle_cmdline(SCSIBus *bus) Location loc; DriveInfo *dinfo; int unit; - BlockConf conf =3D { - .bootindex =3D -1, - .share_rw =3D false, - .rerror =3D BLOCKDEV_ON_ERROR_AUTO, - .werror =3D BLOCKDEV_ON_ERROR_AUTO, - }; + BlockConf conf =3D DEFAULT_BLOCK_CONF; =20 loc_push_none(&loc); for (unit =3D 0; unit <=3D bus->info->max_target; unit++) { --=20 2.54.0 From nobody Sat May 30 18:34:27 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1779210364; cv=none; d=zohomail.com; s=zohoarc; b=n45gsWOdQDWHmH884mUp12bzTH+C01fS6RaQKcAvSbbGrYX02mqQ0Fo0+wBQoBxqItyvWl8Yr7BpqNBd+sdonRify/IjSX5NHz+Ryh+HjScPoILh3igqfgDMbsMKMVXdkLNGxBsI9Fu74Hidmo1QPx8ltVJPCfqSADo/1lY2XAU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779210364; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=NmZO1DnCQFJvIPMAXOKqvGPa8liadj2g4sH8wSYFG6o=; b=fn0af6SVuYng8GcLC7M2HYmdDOVhWtKF0AFekU8uPc79VeaM2DW1WlGy2WAxb5PSWU2bcqcRTDqybT5PCjAtvBTia1vTrZEjIXpDTOMwSpX/g/dkrwVHUspip9PksZN0dJFPptDXkVv6HKmUKYbNRNOyuRU+yY5aH+bU93jk9Mg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17792103646341011.7469939238035; Tue, 19 May 2026 10:06:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wPNrJ-000875-Sp; Tue, 19 May 2026 13:03:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wPNrH-00086G-VN for qemu-devel@nongnu.org; Tue, 19 May 2026 13:03:55 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wPNrG-0004IJ-Hk for qemu-devel@nongnu.org; Tue, 19 May 2026 13:03:55 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-339-bUshOFFXNkWollXftYJvpg-1; Tue, 19 May 2026 13:03:52 -0400 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6D5181800343; Tue, 19 May 2026 17:03:51 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.44.49.113]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 19DA61681; Tue, 19 May 2026 17:03:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779210233; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NmZO1DnCQFJvIPMAXOKqvGPa8liadj2g4sH8wSYFG6o=; b=YTJXnQKQAxpdMnvU+DQLhS+WlLz/3zAvrxI/Ec1VGCm+MaKXVPnu8IHxKaOpctCQYg+U/R AUHBGBUlCeOyV3T0CyzR2S7gYFVd12jsoO0TLH2HaOKPw9uhiQSao6cuQRBL6kIaa6qxpD FfqE9XjejpCOaOYYZ8XcNqhEW6Bcn0Q= X-MC-Unique: bUshOFFXNkWollXftYJvpg-1 X-Mimecast-MFC-AGG-ID: bUshOFFXNkWollXftYJvpg_1779210231 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 12/18] block: Add more defaults to DEFAULT_BLOCK_CONF Date: Tue, 19 May 2026 19:03:11 +0200 Message-ID: <20260519170317.345032-13-kwolf@redhat.com> In-Reply-To: <20260519170317.345032-1-kwolf@redhat.com> References: <20260519170317.345032-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1779210365667154100 Content-Type: text/plain; charset="utf-8" discard_granularity was missing from this, which means that SCSI disks created with -drive if=3Dscsi would default to 0 (i.e. disabling discards) instead of -1, which makes scsi-hd automatically pick a granularity and is the default of the corresponding qdev property for -device scsi-hd. This was broken in QEMU 9.0 with commit 3089637. Also set other fields whose default isn't an obvious 0. These are not actual bug fixes because ON_OFF_AUTO_AUTO in fact happens to be 0, but it's better not to rely on the order of enums. Cc: qemu-stable@nongnu.org Fixes: 308963746169 ('scsi: Don't ignore most usb-storage properties') Reported-by: Lexi Winter Signed-off-by: Kevin Wolf Message-ID: <20260410152314.86412-3-kwolf@redhat.com> Signed-off-by: Kevin Wolf --- include/hw/block/block.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/hw/block/block.h b/include/hw/block/block.h index e0a427039ee..df941df19f2 100644 --- a/include/hw/block/block.h +++ b/include/hw/block/block.h @@ -53,7 +53,12 @@ static inline unsigned int get_physical_block_exp(BlockC= onf *conf) =20 #define DEFAULT_BLOCK_CONF (BlockConf) { \ .bootindex =3D -1, \ + .backend_defaults =3D ON_OFF_AUTO_AUTO, \ + .discard_granularity =3D -1, \ + .wce =3D ON_OFF_AUTO_AUTO, \ .share_rw =3D false, \ + .account_invalid =3D ON_OFF_AUTO_AUTO, \ + .account_failed =3D ON_OFF_AUTO_AUTO, \ .rerror =3D BLOCKDEV_ON_ERROR_AUTO, \ .werror =3D BLOCKDEV_ON_ERROR_AUTO, \ } --=20 2.54.0 From nobody Sat May 30 18:34:27 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1779210377; cv=none; d=zohomail.com; s=zohoarc; b=jD4Fv5vSfewNI8X37EQJa6Q5v6+8ZdnAZRxuEOf2NbTlZcx32QuvZUTjA9ZeGFtwzr/bE3f2VAIdOwAFcU1BNEB1jQrsb2dE/b7eH4RJJo9p3rKAaVWZ7c1zbSxjel8gUwULXmVIN5re7gI/SIgxti8pF4h177veruIQ6bmFqNo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779210377; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=bLQ5ZwtzDEpEqGCjen6mnUTp57q/yeGQzUBReZKdzMs=; b=jV3xCbbG5uZN+YnaVXywxx5PEnzD2bCiILAJTracyR6MrZhJNfAicYV3HGQOsQDZ16DgxwySX25J+hcbA63n2yCDQDkCocFWvPb9zyvuXIdyqPkivXyLe1IF/zlAxQ+OtG86WR7TmdI2JTcoHor5XkUGBEGvRSLl4nWMpRWRnU8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1779210377567625.4254651166399; Tue, 19 May 2026 10:06:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wPNrj-0008DO-BR; Tue, 19 May 2026 13:04:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wPNrO-00088r-Dh for qemu-devel@nongnu.org; Tue, 19 May 2026 13:04:04 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wPNrK-0004KV-5H for qemu-devel@nongnu.org; Tue, 19 May 2026 13:03:59 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-180-H-lDc5n0O7KpFEmWkVJ0wg-1; Tue, 19 May 2026 13:03:54 -0400 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4344619560AD; Tue, 19 May 2026 17:03:53 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.44.49.113]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D40991681; Tue, 19 May 2026 17:03:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779210237; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bLQ5ZwtzDEpEqGCjen6mnUTp57q/yeGQzUBReZKdzMs=; b=Pp1aJ2S4WTRy5GacNtfelN1klTO/RBxo3UOqZRnyzQCvPRHKXKvda9ObQ+1+VsZ9MQgQ3A egFxQJGiR4xmjfrvqxOCkEwtY5Wt3X9knYUhbSFWZI2zrMiiAbncfrYQXckAos2zrsSxVm t3nlc/bzJkd4+p59BoYs9ELMS+yuC+Y= X-MC-Unique: H-lDc5n0O7KpFEmWkVJ0wg-1 X-Mimecast-MFC-AGG-ID: H-lDc5n0O7KpFEmWkVJ0wg_1779210233 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 13/18] commit: Drain nodes across all of bdrv_commit() Date: Tue, 19 May 2026 19:03:12 +0200 Message-ID: <20260519170317.345032-14-kwolf@redhat.com> In-Reply-To: <20260519170317.345032-1-kwolf@redhat.com> References: <20260519170317.345032-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1779210378656158500 Content-Type: text/plain; charset="utf-8" The whole implementation of bdrv_commit() is only correct if no new writes come in while it's running: It has only a single loop checking the allocation status for each block and finally calls bdrv_make_empty() without checking if that throws away any new changes. We already have to drain while taking the graph write lock. Just extend the drained section to all of bdrv_commit() to make sure that we don't get any inconsistencies. Signed-off-by: Kevin Wolf Message-ID: <20260427170520.101242-2-kwolf@redhat.com> Reviewed-by: Denis V. Lunev Tested-by: Denis V. Lunev Signed-off-by: Kevin Wolf --- block/commit.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/block/commit.c b/block/commit.c index 0d9e1a16d7a..c5e3ef03a21 100644 --- a/block/commit.c +++ b/block/commit.c @@ -518,6 +518,7 @@ int bdrv_commit(BlockDriverState *bs) if (!drv) return -ENOMEDIUM; =20 + bdrv_drain_all_begin(); bdrv_graph_rdlock_main_loop(); =20 backing_file_bs =3D bdrv_cow_bs(bs); @@ -549,6 +550,10 @@ int bdrv_commit(BlockDriverState *bs) BLK_PERM_ALL); backing =3D blk_new(ctx, BLK_PERM_WRITE | BLK_PERM_RESIZE, BLK_PERM_AL= L); =20 + /* We drained all nodes, but still make requests through BlockBackends= */ + blk_set_disable_request_queuing(src, true); + blk_set_disable_request_queuing(backing, true); + ret =3D blk_insert_bs(src, bs, &local_err); if (ret < 0) { error_report_err(local_err); @@ -565,7 +570,7 @@ int bdrv_commit(BlockDriverState *bs) =20 bdrv_graph_rdunlock_main_loop(); =20 - bdrv_graph_wrlock_drained(); + bdrv_graph_wrlock(); bdrv_set_backing_hd(commit_top_bs, backing_file_bs, &error_abort); bdrv_set_backing_hd(bs, commit_top_bs, &error_abort); bdrv_graph_wrunlock(); @@ -647,7 +652,7 @@ ro_cleanup: blk_unref(backing); =20 bdrv_graph_rdunlock_main_loop(); - bdrv_graph_wrlock_drained(); + bdrv_graph_wrlock(); if (bdrv_cow_bs(bs) !=3D backing_file_bs) { bdrv_set_backing_hd(bs, backing_file_bs, &error_abort); } @@ -663,6 +668,7 @@ ro_cleanup: =20 out: bdrv_graph_rdunlock_main_loop(); + bdrv_drain_all_end(); =20 return ret; } --=20 2.54.0 From nobody Sat May 30 18:34:27 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1779210347; cv=none; d=zohomail.com; s=zohoarc; b=SnMYWrpS20+P0YT7UlANZ93QiWGE0GKTwr4j01ke0rzQNfqVfBQMCxrulUxaCwJ+FViVOngRPc4UupcKtvzIhEUnjuXISqKDC7/a+yW0Ibr/G7rZncpqCy3+3oI9+7JOBNKpMwksUHfYCczDKBT0KzCe00r1W1FdAA0L5VloPuw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779210347; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ljPMsHaTOASelJyrTH89CAlt54Pd7Kc2MO3sIPNTZf0=; b=VBzrMRYCp3waGxEZVSMTqllYVPeeYXDWXDycq5gSTt3NawNIiW0cUzqrxFOQRVcgXmg9eJf8GVRubhOHiBy6Fzqv1Oir8YzvC3z5cEhiVYRgvN+u6pGTnpidxFQOY3q7BcbCYgOnEorsUiq/gp+qzxbMOAoOQNAiB6BI3eHLidM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1779210347698885.0515948877247; Tue, 19 May 2026 10:05:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wPNra-0008C5-VW; Tue, 19 May 2026 13:04:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wPNrP-00088x-IO for qemu-devel@nongnu.org; Tue, 19 May 2026 13:04:04 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wPNrM-0004Mj-TH for qemu-devel@nongnu.org; Tue, 19 May 2026 13:04:03 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-382-dpEr_eqPN0y5b5LeGVuukA-1; Tue, 19 May 2026 13:03:55 -0400 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id EA1F618005B2; Tue, 19 May 2026 17:03:54 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.44.49.113]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 988791681; Tue, 19 May 2026 17:03:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779210239; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ljPMsHaTOASelJyrTH89CAlt54Pd7Kc2MO3sIPNTZf0=; b=QxHdVyx0ODLH53CrMMGyoYcgwDQnJge98NCicuJ8wW5Mq+T+85qjK+0egEM9TB0CTG9eDh M9P69R9gUJillDiXCqpaKESPBYL2Me2F9V/xe1F7pDvfWFKObyQv+1owsylkDOCCrwlhSy jhl8vmS/oAEWH2+/EBu8FDBQNQQAtIw= X-MC-Unique: dpEr_eqPN0y5b5LeGVuukA-1 X-Mimecast-MFC-AGG-ID: dpEr_eqPN0y5b5LeGVuukA_1779210235 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 14/18] qemu-io: Add 'aio_discard' command Date: Tue, 19 May 2026 19:03:13 +0200 Message-ID: <20260519170317.345032-15-kwolf@redhat.com> In-Reply-To: <20260519170317.345032-1-kwolf@redhat.com> References: <20260519170317.345032-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1779210349355154100 Content-Type: text/plain; charset="utf-8" Testing interactions between multiple requests that include discard requests require that qemu-io can do the discard asynchronously, like it already does for reads and writes. To this effect, add an 'aio_discard' command. Signed-off-by: Kevin Wolf Message-ID: <20260427170520.101242-3-kwolf@redhat.com> Reviewed-by: Denis V. Lunev Tested-by: Denis V. Lunev Signed-off-by: Kevin Wolf --- qemu-io-cmds.c | 115 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c index f6d077908f2..de4c1966fea 100644 --- a/qemu-io-cmds.c +++ b/qemu-io-cmds.c @@ -2218,6 +2218,120 @@ static int discard_f(BlockBackend *blk, int argc, c= har **argv) return 0; } =20 +static void aio_discard_help(void) +{ + printf( +"\n" +" asynchronously discards a range of bytes from the given offset\n" +"\n" +" Example:\n" +" 'aio_discard 512 1k' - discards 1 kilobyte from 512 bytes into the file\= n" +"\n" +" Discards a segment of the currently open file.\n" +" -C, -- report statistics in a machine parsable format\n" +" -q, -- quiet mode, do not show I/O statistics\n" +" The discard is performed asynchronously and the aio_flush command must b= e\n" +" used to ensure all outstanding aio requests have been completed.\n" +" Note that due to its asynchronous nature, this command will be\n" +" considered successful once the request is submitted, independently\n" +" of potential I/O errors.\n" +"\n"); +} + +static int aio_discard_f(BlockBackend *blk, int argc, char **argv); + +static const cmdinfo_t aio_discard_cmd =3D { + .name =3D "aio_discard", + .cfunc =3D aio_discard_f, + .perm =3D BLK_PERM_WRITE, + .argmin =3D 2, + .argmax =3D -1, + .args =3D "[-Cq] off len", + .oneline =3D "asynchronously discards a number of bytes", + .help =3D aio_discard_help, +}; + +static void aio_discard_done(void *opaque, int ret) +{ + struct aio_ctx *ctx =3D opaque; + struct timespec t2; + + clock_gettime(CLOCK_MONOTONIC, &t2); + + if (ret < 0) { + printf("aio_discard failed: %s\n", strerror(-ret)); + block_acct_failed(blk_get_stats(ctx->blk), &ctx->acct); + goto out; + } + + block_acct_done(blk_get_stats(ctx->blk), &ctx->acct); + + if (ctx->qflag) { + goto out; + } + + /* Finally, report back -- -C gives a parsable format */ + t2 =3D tsub(t2, ctx->t1); + print_report("discarded ", &t2, ctx->offset, ctx->qiov.size, + ctx->qiov.size, 1, ctx->Cflag); +out: + g_free(ctx); +} + +static int aio_discard_f(BlockBackend *blk, int argc, char **argv) +{ + int c, ret; + int64_t count; + struct aio_ctx *ctx =3D g_new0(struct aio_ctx, 1); + + ctx->blk =3D blk; + + while ((c =3D getopt(argc, argv, "Cq")) !=3D -1) { + switch (c) { + case 'C': + ctx->Cflag =3D true; + break; + case 'q': + ctx->qflag =3D true; + break; + default: + g_free(ctx); + qemuio_command_usage(&aio_discard_cmd); + return -EINVAL; + } + } + + if (optind !=3D argc - 2) { + g_free(ctx); + qemuio_command_usage(&aio_discard_cmd); + return -EINVAL; + } + + ctx->offset =3D cvtnum(argv[optind]); + if (ctx->offset < 0) { + ret =3D ctx->offset; + print_cvtnum_err(ret, argv[optind]); + g_free(ctx); + return ret; + } + optind++; + + count =3D cvtnum(argv[optind]); + if (count < 0) { + print_cvtnum_err(count, argv[optind]); + g_free(ctx); + return count; + } + + clock_gettime(CLOCK_MONOTONIC, &ctx->t1); + ctx->qiov.size =3D count; + block_acct_start(blk_get_stats(blk), &ctx->acct, ctx->qiov.size, + BLOCK_ACCT_UNMAP); + blk_aio_pdiscard(blk, ctx->offset, count, aio_discard_done, ctx); + + return 0; +} + static int alloc_f(BlockBackend *blk, int argc, char **argv) { BlockDriverState *bs =3D blk_bs(blk); @@ -2800,6 +2914,7 @@ static void __attribute((constructor)) init_qemuio_co= mmands(void) qemuio_add_command(&length_cmd); qemuio_add_command(&info_cmd); qemuio_add_command(&discard_cmd); + qemuio_add_command(&aio_discard_cmd); qemuio_add_command(&alloc_cmd); qemuio_add_command(&map_cmd); qemuio_add_command(&reopen_cmd); --=20 2.54.0 From nobody Sat May 30 18:34:27 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1779210300; cv=none; d=zohomail.com; s=zohoarc; b=XH4HfOITE1TnFgi4MukcdT4mrf1qeD1gUsgjLEl7xCcsFsG3k7X8i/yxqQmfeMveCpLiN/9nCwcrhZ6G8L33CMwBrn18/RkkmnH2wfsLrXY0tmx9Wq91dPH3w+jySVJ88c7siyNvI5/cGJbQLZkHOBWlEZpiD0r5eEBEPK9fBR0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779210300; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Z4/SuyQT4c25nLjf32oOO7pmyp/Ryy5z/5FjiQtnlRc=; b=NDw9X/SknAHogMrfF3xYfswy4p9V4t54gvsooTBjWwEdZYMe5/+BXoGnhwYPSmAn0/G08XPWdgNYJEMhLt5m0cNskM/iIemtfj3ulPwQ/FJllntD+Wyz97L/p3rlMwwsrsrEofGuhnisbQF+bN4GyNfE+l+Zq3uPI85DncVM5ss= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1779210300605283.33248163856774; Tue, 19 May 2026 10:05:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wPNrU-0008B1-Vw; Tue, 19 May 2026 13:04:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wPNrQ-00088y-B4 for qemu-devel@nongnu.org; Tue, 19 May 2026 13:04:04 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wPNrN-0004Ml-GT for qemu-devel@nongnu.org; Tue, 19 May 2026 13:04:03 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-647-86BOZv1lOpmxX3NrY1AlSw-1; Tue, 19 May 2026 13:03:57 -0400 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id AF28A1800367; Tue, 19 May 2026 17:03:56 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.44.49.113]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5E9591681; Tue, 19 May 2026 17:03:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779210239; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Z4/SuyQT4c25nLjf32oOO7pmyp/Ryy5z/5FjiQtnlRc=; b=V+CgiViiXxXIwxViwUqbam+fzP8xIoV1x4vvM/l4WJgv3R4Qexj+Dtuedvniv6yXxBO3xU cjr4MBf4wId/NC9P2lRIVf/pJy6MrJSjo6UFs6L1Pi9+gpMFAS7OstYUnBRVS4aUIVmN0F /Y3jKGf/TzB2NQKwan7KbQhp8hXsgvY= X-MC-Unique: 86BOZv1lOpmxX3NrY1AlSw-1 X-Mimecast-MFC-AGG-ID: 86BOZv1lOpmxX3NrY1AlSw_1779210236 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 15/18] qcow2: Fix corruption on discard during write with COW Date: Tue, 19 May 2026 19:03:14 +0200 Message-ID: <20260519170317.345032-16-kwolf@redhat.com> In-Reply-To: <20260519170317.345032-1-kwolf@redhat.com> References: <20260519170317.345032-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1779210302505154100 Content-Type: text/plain; charset="utf-8" Most code in qcow2 that accesses (and potentially modifies) L2 tables does so while holding s->lock. There is one exception, which is allocating writes. They hold the lock initially while allocating clusters, but drop it for writing the guest payload before taking the lock again for updating the L2 tables. This allows concurrent requests that touch other parts of the image file to continue in parallel and is an important performance optimisation. However, this means that other requests that run while the lock is dropped for writing guest data must synchronise with the list of allocating requests in s->cluster_allocs and wait if they would overlap. For writes, this is done in handle_dependencies(), but discard and write zeros operations neglect to synchronise with s->cluster_allocs. This means that discard can free a cluster whose L2 entry will already be modified in qcow2_alloc_cluster_link_l2() by a previously started write. In the case of a pre-allocated zero cluster that is in the process of being overwritten, this means that discard can lead to a situation where the cluster is still mapped (because the write will restore the L2 entry just without the zero flag), but its refcount has been decreased, resulting in a corrupted image. Add the missing synchronisation to qcow2_cluster_discard() and qcow2_subcluster_zeroize() to fix the problem. Cc: qemu-stable@nongnu.org Reported-by: Denis V. Lunev Signed-off-by: Kevin Wolf Message-ID: <20260427170520.101242-4-kwolf@redhat.com> Reviewed-by: Denis V. Lunev Tested-by: Denis V. Lunev Signed-off-by: Kevin Wolf --- block/qcow2-cluster.c | 52 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 49 insertions(+), 3 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index c655bf6df42..8b1e80bd0b3 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -1392,6 +1392,9 @@ count_single_write_clusters(BlockDriverState *bs, int= nb_clusters, * the same cluster. In this case we need to wait until the previous * request has completed and updated the L2 table accordingly. * + * If allow_shortening =3D=3D true, instead of waiting for a dependency, *= cur_bytes + * can be shortened so that the cluster allocations don't overlap. + * * Returns: * 0 if there was no dependency. *cur_bytes indicates the number of * bytes from guest_offset that can be read before the next @@ -1403,7 +1406,9 @@ count_single_write_clusters(BlockDriverState *bs, int= nb_clusters, */ static int coroutine_fn handle_dependencies(BlockDriverState *bs, uint64_t guest_offset, - uint64_t *cur_bytes, QCowL2Met= a **m) + uint64_t *cur_bytes, + bool allow_shortening, + QCowL2Meta **m) { BDRVQcow2State *s =3D bs->opaque; QCowL2Meta *old_alloc; @@ -1434,7 +1439,7 @@ static int coroutine_fn handle_dependencies(BlockDriv= erState *bs, =20 /* Conflict */ =20 - if (start < old_start) { + if (start < old_start && allow_shortening) { /* Stop at the start of a running allocation */ bytes =3D old_start - start; } else { @@ -1469,6 +1474,29 @@ static int coroutine_fn handle_dependencies(BlockDri= verState *bs, return 0; } =20 +static void coroutine_mixed_fn wait_for_dependencies(BlockDriverState *bs, + uint64_t guest_offset, + uint64_t bytes) +{ + BDRVQcow2State *s =3D bs->opaque; + QCowL2Meta *m =3D NULL; + int ret; + + /* + * Discard has some non-coroutine callers (creating internal snapshots= and + * make empty). They are calling from qemu-img or in a drained section= , so + * we know that no writes can be in progress. + */ + if (!qemu_in_coroutine()) { + assert(QLIST_EMPTY(&s->cluster_allocs)); + return; + } + + do { + ret =3D handle_dependencies(bs, guest_offset, &bytes, false, &m); + } while (ret =3D=3D -EAGAIN); +} + /* * Checks how many already allocated clusters that don't require a new * allocation there are at the given guest_offset (up to *bytes). @@ -1840,7 +1868,7 @@ again: * the right synchronisation between the in-flight request= and * the new one. */ - ret =3D handle_dependencies(bs, start, &cur_bytes, m); + ret =3D handle_dependencies(bs, start, &cur_bytes, true, m); if (ret =3D=3D -EAGAIN) { /* Currently handle_dependencies() doesn't yield if we already= had * an allocation. If it did, we would have to clean up the L2M= eta @@ -2000,6 +2028,15 @@ int qcow2_cluster_discard(BlockDriverState *bs, uint= 64_t offset, int64_t cleared; int ret; =20 + /* + * If we're touching a cluster for which allocating writes are in flig= ht, + * wait for them to complete to avoid conflicting metadata updates. + * + * We don't need to allocate a QCowL2Meta for the discard operation be= cause + * s->lock is held for the duration of the whole operation. + */ + wait_for_dependencies(bs, offset, bytes); + /* Caller must pass aligned values, except at image end */ assert(QEMU_IS_ALIGNED(offset, s->cluster_size)); assert(QEMU_IS_ALIGNED(end_offset, s->cluster_size) || @@ -2160,6 +2197,15 @@ int coroutine_fn qcow2_subcluster_zeroize(BlockDrive= rState *bs, uint64_t offset, int64_t cleared; int ret; =20 + /* + * If we're touching a cluster for which allocating writes are in flig= ht, + * wait for them to complete to avoid conflicting metadata updates. + * + * We don't need to allocate a QCowL2Meta for the zeroize operation be= cause + * s->lock is held for the duration of the whole operation. + */ + wait_for_dependencies(bs, offset, bytes); + /* If we have to stay in sync with an external data file, zero out * s->data_file first. */ if (data_file_is_raw(bs)) { --=20 2.54.0 From nobody Sat May 30 18:34:27 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1779210380; cv=none; d=zohomail.com; s=zohoarc; b=eoU+02rGfsmYiKOddI7I0z4aUmpwAbjey77Wp+c/KkSHRYRdpO6P9Ar4Vif05cYw4DipFMbi6XWuIWSpo6IDJXM4BQ0didGzErZL3N8Stq/WDELK12T+FUNsXWHotIGhqS1/pqZm35HU1ap1s5nAd1yNRKK5d0uSLuLap18ejMw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779210380; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=NZVyKjVuKwvuLMZ/vk7nWxnwB8LvuhUMA0Yuiyi00do=; b=IfuA0oEJ5e92CE/gDEts9aUnocXILO7OzhnPTY6TK8auo+91qnUCT7pcrmEVQIx8CU06dJXz1eWFlus5ogvCG9bmxAOrXYS+vG911veJSC/nLzmYoTgfBai1OKegrySqsRRjzL2vJAy812ipi1yUk/yYgREXtFpCtMI+Lr6x+cM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1779210380951123.34139986715275; Tue, 19 May 2026 10:06:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wPNrb-0008CE-1l; Tue, 19 May 2026 13:04:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wPNrR-00089h-0v for qemu-devel@nongnu.org; Tue, 19 May 2026 13:04:05 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wPNrN-0004Mu-Sr for qemu-devel@nongnu.org; Tue, 19 May 2026 13:04:04 -0400 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-614-VAscOHj0Pay1hkUESJ-dPg-1; Tue, 19 May 2026 13:03:59 -0400 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 75501195606F; Tue, 19 May 2026 17:03:58 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.44.49.113]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 236241684; Tue, 19 May 2026 17:03:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779210241; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NZVyKjVuKwvuLMZ/vk7nWxnwB8LvuhUMA0Yuiyi00do=; b=T6GdbWlTgdbCDJPHoDQsBwUVTtSRmMJDIepTICpD4EdBLWAZ56NmJuPQvAap7lXi9damU6 oLEDCHY0Z+lbuYhesJDjEIfu2f/E5IJ/Sf/32raTw/Ue4c+b0soQQLHaqklD6kB+zS8AIF a+ArVO+wwtSEhF8DmpIHk4Ur4DR7fbI= X-MC-Unique: VAscOHj0Pay1hkUESJ-dPg-1 X-Mimecast-MFC-AGG-ID: VAscOHj0Pay1hkUESJ-dPg_1779210238 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 16/18] iotests/046: Test that discard/write_zeroes wait for dependencies Date: Tue, 19 May 2026 19:03:15 +0200 Message-ID: <20260519170317.345032-17-kwolf@redhat.com> In-Reply-To: <20260519170317.345032-1-kwolf@redhat.com> References: <20260519170317.345032-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1779210382007154100 Content-Type: text/plain; charset="utf-8" This is a regression test for the bug fixed in the previous commit where discard and write_zeroes operations wouldn't consider their dependencies in s->cluster_allocs. Without the fix, this results in a corrupted image. Signed-off-by: Kevin Wolf Message-ID: <20260427170520.101242-5-kwolf@redhat.com> Reviewed-by: Denis V. Lunev Tested-by: Denis V. Lunev Signed-off-by: Kevin Wolf --- tests/qemu-iotests/046 | 46 ++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/046.out | 36 +++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+) diff --git a/tests/qemu-iotests/046 b/tests/qemu-iotests/046 index 4c9ed4d26e1..e03dd401479 100755 --- a/tests/qemu-iotests/046 +++ b/tests/qemu-iotests/046 @@ -184,6 +184,48 @@ aio_write -P 160 0x104000 0x18000 resume A aio_flush EOF + +# Create a pre-allocated zero cluster, then start a write on it and discar= d it +# before the L2 update is made +cat < (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1779210282833355.61456614202837; Tue, 19 May 2026 10:04:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wPNrl-0008Ih-BM; Tue, 19 May 2026 13:04:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wPNrT-0008AX-4Q for qemu-devel@nongnu.org; Tue, 19 May 2026 13:04:07 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wPNrR-0004Nq-Cd for qemu-devel@nongnu.org; Tue, 19 May 2026 13:04:06 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-618-dfZOGB84NDu2DO4SySfFHA-1; Tue, 19 May 2026 13:04:01 -0400 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6A2BC18005B3; Tue, 19 May 2026 17:04:00 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.44.49.113]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id DCF4C1684; Tue, 19 May 2026 17:03:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779210244; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=06IwaCK6uoA4GQaGnFk7LeWoE13yL3/b3GgPq0TR6UY=; b=HPY9ovxrzH7iQ01bRfoUyZpUKCIVMvQ+/x9/VvLS96xzniFeKuIdTZwwXJcGAzyDhDEKjN Gxt2bAvYiWrXrecUUZHxg5e8G31Ptlseh0TDrQpyylO6ugmWRsvlpN++El8G0GQ+ealvcw jCS06BJUKP34OWEvEkW7Cf2uY0HTkyc= X-MC-Unique: dfZOGB84NDu2DO4SySfFHA-1 X-Mimecast-MFC-AGG-ID: dfZOGB84NDu2DO4SySfFHA_1779210240 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 17/18] block/graph-lock: fix missed wakeup in bdrv_graph_co_rdunlock() Date: Tue, 19 May 2026 19:03:16 +0200 Message-ID: <20260519170317.345032-18-kwolf@redhat.com> In-Reply-To: <20260519170317.345032-1-kwolf@redhat.com> References: <20260519170317.345032-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1779210284377154100 Content-Type: text/plain; charset="utf-8" From: "Denis V. Lunev" tests/qemu-iotests/tests/iothreads-create reproduces the hang on master under `stress-ng --cpu $(nproc) --timeout 0`. The iotest's vm.run_job() times out and qemu stays permanently stuck in ppoll(timeout=3D-1) inside bdrv_graph_wrlock_drained -> blk_remove_bs during qemu_cleanup(). The timing window is narrow on modern bare-metal hardware and much wider in a VM guest; downstream trees that still use plain bdrv_graph_wrlock() in blk_remove_bs() hit it on the first iteration under the same stress. bdrv_graph_wrlock() zeroes has_writer around its AIO_WAIT_WHILE loop so that callbacks dispatched by aio_poll() can still take the read lock on the fast path. The rdunlock side, however, only kicks a waiting writer when has_writer is observed set; a reader that drops its lock inside the polling window silently returns and nothing ever wakes the writer: main thread iothread0 coroutine ----------- ------------------- bdrv_graph_wrlock: rdlock held, reader_count=3D1 bdrv_drain_all_begin_nopoll has_writer =3D 0 AIO_WAIT_WHILE_UNLOCKED( NULL, reader_count >=3D 1): num_waiters++ smp_mb aio_poll(main_ctx, true) --> bdrv_graph_co_rdunlock: (ppoll, blocked) reader_count-- -> 0 smp_mb read has_writer =3D 0 skip aio_wait_kick() return reader_count is now 0 and num_waiters is still 1, but no BH, fd or timer on the main AioContext will fire -- the only entity that could kick just decided it did not have to. Main stays in ppoll() holding BQL, so RCU, VCPUs and any iothread path that needs BQL stall behind it. The hang is final; no timeout, no forward progress, no recovery as there is no other source of wake up inside qemu_cleanup(). bdrv_drain_all_begin() does not close the race on its own: it quiesces in-flight I/O, but graph readers also include non-I/O coroutines (block-job cleanup, virtio-scsi polling) that drain does not evict. The bdrv_graph_wrlock_drained() wrapper narrows the window but does not eliminate it; every plain bdrv_graph_wrlock() site is exposed on the same basis. Drop the has_writer check in bdrv_graph_co_rdunlock() and call aio_wait_kick() unconditionally. The helper itself loads num_waiters atomically and only schedules a dummy BH when a waiter exists, so the change is a no-op on the no-writer path and closes the missed-wakeup on the writer path. Signed-off-by: Denis V. Lunev Cc: Kevin Wolf Cc: Hanna Reitz Cc: Stefan Hajnoczi Cc: Fiona Ebner Message-ID: <20260424103917.248668-2-den@openvz.org> Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- block/graph-lock.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/block/graph-lock.c b/block/graph-lock.c index b7319473a17..f2501d75fbe 100644 --- a/block/graph-lock.c +++ b/block/graph-lock.c @@ -278,14 +278,12 @@ void coroutine_fn bdrv_graph_co_rdunlock(void) smp_mb(); =20 /* - * has_writer =3D=3D 0: this means reader will read reader_count decre= ased - * has_writer =3D=3D 1: we don't know if writer read reader_count old = or - * new. Therefore, kick again so on next iteration - * writer will for sure read the updated value. + * Always kick: bdrv_graph_wrlock() zeroes has_writer while polling (to + * let callbacks take the reader lock via the fast path), so we cannot + * rely on has_writer to detect a waiting writer. aio_wait_kick() is a + * no-op when no one is waiting, so it is cheap in the common case. */ - if (qatomic_read(&has_writer)) { - aio_wait_kick(); - } + aio_wait_kick(); } =20 void bdrv_graph_rdlock_main_loop(void) --=20 2.54.0 From nobody Sat May 30 18:34:27 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1779210371; cv=none; d=zohomail.com; s=zohoarc; b=CFeNP2l5SMbsHgqgOz4gQGZBNSg+lc++enDSeitgs6Q2IPpGHTRvKRZ1cSX2HNmZ+bDGCccvDcWrztlas/HBWm7zyKopIMsMxB8mW60Ex7JWSnl4Z4WFTlZQTL+LHzy4BxkuwMepwdRJyOTIXydM5DHqhQ9uHIrxTOXZoJDcUXg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779210371; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=EmVRTZeE1PnX8kRbjuyEss4QuQxjLGaPYaUkMd0dC14=; b=EOKN7GdhHe1E611w1AsWXuaqHUm1KDgqPRysLGfqSrI6z6XmNDGmVmQdqxezeQQ3CeSJoh0n2jvp+863dqAfPPilMQ5djPqw7JoPwFThHbe+Wt2BcB73n+FU+uKb+8p/ZnKq61vYLydDYriEzu/CTnQTcFPZZ6jgwgrTgqZSsAQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1779210371246648.6232558049196; Tue, 19 May 2026 10:06:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wPNrm-0008Jv-VZ; Tue, 19 May 2026 13:04:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wPNrT-0008Ap-6J for qemu-devel@nongnu.org; Tue, 19 May 2026 13:04:07 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wPNrR-0004Ny-Mj for qemu-devel@nongnu.org; Tue, 19 May 2026 13:04:06 -0400 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-653-1vYVohO2N8CHweDJMH4hhA-1; Tue, 19 May 2026 13:04:03 -0400 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4676A19560A7; Tue, 19 May 2026 17:04:02 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.44.49.113]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D094F1684; Tue, 19 May 2026 17:04:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779210245; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EmVRTZeE1PnX8kRbjuyEss4QuQxjLGaPYaUkMd0dC14=; b=iSuN42kn57odYbVlC8ykS8+ap0KWqMWsIixIpipcbP3OhOIs08C4D26YDBJybfbZVDudSq lWZpRdfP7nk6xaWjpJ8Iis6oJYeL71687jTKAkiEU5GGPFHhSnx/cHGZ8oc7J427Eh00VL ntBpxydXtI6k+25CKHCUhWCwOP/trKI= X-MC-Unique: 1vYVohO2N8CHweDJMH4hhA-1 X-Mimecast-MFC-AGG-ID: 1vYVohO2N8CHweDJMH4hhA_1779210242 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 18/18] block: Improve readability in HMP 'info blockstats' output Date: Tue, 19 May 2026 19:03:17 +0200 Message-ID: <20260519170317.345032-19-kwolf@redhat.com> In-Reply-To: <20260519170317.345032-1-kwolf@redhat.com> References: <20260519170317.345032-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1779210372567158500 Content-Type: text/plain; charset="utf-8" Instead of a long line with key=3Dvalue pairs for each block device, switch to a tabular form with aligned values. This makes it much easier to find the relevant information in the output. Signed-off-by: Kevin Wolf Message-ID: <20260512112759.66038-1-kwolf@redhat.com> Signed-off-by: Kevin Wolf --- block/monitor/block-hmp-cmds.c | 38 ++++++++++++++++------------------ 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c index 1fd28d59eb1..69ade0534f1 100644 --- a/block/monitor/block-hmp-cmds.c +++ b/block/monitor/block-hmp-cmds.c @@ -794,30 +794,28 @@ void hmp_info_blockstats(Monitor *mon, const QDict *q= dict) continue; } =20 - monitor_printf(mon, "%s:", stats->value->device); - monitor_printf(mon, " rd_bytes=3D%" PRId64 - " wr_bytes=3D%" PRId64 - " rd_operations=3D%" PRId64 - " wr_operations=3D%" PRId64 - " flush_operations=3D%" PRId64 - " wr_total_time_ns=3D%" PRId64 - " rd_total_time_ns=3D%" PRId64 - " flush_total_time_ns=3D%" PRId64 - " rd_merged=3D%" PRId64 - " wr_merged=3D%" PRId64 - " idle_time_ns=3D%" PRId64 - "\n", + monitor_printf(mon, "%s%s: idle_time_ns=3D%" PRId64 "\n", + stats !=3D stats_list ? "\n" : "", + stats->value->device, + stats->value->stats->idle_time_ns); + monitor_printf(mon, " %24s %16s %24s %10s\n", "bytes", + "operations", "total_time_ns", "merged"); + monitor_printf(mon, "Read: %24" PRId64 " %16" PRId64 " %24" PRId64 + " %10" PRId64 "\n", stats->value->stats->rd_bytes, - stats->value->stats->wr_bytes, stats->value->stats->rd_operations, + stats->value->stats->rd_total_time_ns, + stats->value->stats->rd_merged); + monitor_printf(mon, "Write: %24" PRId64 " %16" PRId64 " %24" PRId64 + " %10" PRId64 "\n", + stats->value->stats->wr_bytes, stats->value->stats->wr_operations, - stats->value->stats->flush_operations, stats->value->stats->wr_total_time_ns, - stats->value->stats->rd_total_time_ns, - stats->value->stats->flush_total_time_ns, - stats->value->stats->rd_merged, - stats->value->stats->wr_merged, - stats->value->stats->idle_time_ns); + stats->value->stats->wr_merged); + monitor_printf(mon, "Flush: %24s %16" PRId64 " %24" PRId64 "\n", + "", + stats->value->stats->flush_operations, + stats->value->stats->flush_total_time_ns); } =20 qapi_free_BlockStatsList(stats_list); --=20 2.54.0