From nobody Tue Apr 15 14:48:20 2025 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1666898874; cv=none; d=zohomail.com; s=zohoarc; b=mlCj8Np3LF/wGAqieJHNPh06EsLS2V3oBr7zUuuHRWtav93hGdOZcYqxWH3dY4FNh7zuCSp/cGgIgsV1z4jJgNNejONe7MCZ/XmdgB424AHNDlI4xlqwIbcRtSX4BXkCfLeLM+2vAojsHO986JGNP69jJGTQLqYPgzgoQOeHQsE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666898874; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Ont5OY/p1dCszK0NdqMlPoyItWNOK6wvLadp9Tq8jhY=; b=AoGLJbN5Zf1l9wtokIMll7NM95odIHPWJP3gdpA9r6I92fRZBwJT6oWFa1YlGQ2lBcEdxJssF7Ilt3ev2vNvti3tUWE+C0OrNIc9YVeELraHT5bL42ehoF1LKuC0lw3V68yB3BpeVYD+LIuglngRDrrOlnhCY8rQjtxQjugngzQ= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666898874520448.87109261670116; Thu, 27 Oct 2022 12:27:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oo7lc-000245-2J; Thu, 27 Oct 2022 14:38:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oo7h7-0002Fs-Nl for qemu-devel@nongnu.org; Thu, 27 Oct 2022 14:33:38 -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 1oo7gl-0002fW-60 for qemu-devel@nongnu.org; Thu, 27 Oct 2022 14:33:18 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-25-fsN_soeoNiKV-0fRKkr9Sw-1; Thu, 27 Oct 2022 14:33:08 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 17E72185A78B; Thu, 27 Oct 2022 18:33:08 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.194.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 573F41121320; Thu, 27 Oct 2022 18:33:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666895590; 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=Ont5OY/p1dCszK0NdqMlPoyItWNOK6wvLadp9Tq8jhY=; b=Cc35LD+I7/6xON9xE68NuZ1jpLbirOyhq32812LmtIz2OhKlvgB10Cia9GbYE/xVPQCwKE krW9GRnCGjsUD0XvMSlS2iWsgnd1KttJikQONTyQp1HnWTgt6Gx6ubKepgFcdfWTDx3wif FNx35CVEX6LrL6lkDmtkz2QA/5srqas= X-MC-Unique: fsN_soeoNiKV-0fRKkr9Sw-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 58/58] block/block-backend: blk_set_enable_write_cache is IO_CODE Date: Thu, 27 Oct 2022 20:31:46 +0200 Message-Id: <20221027183146.463129-59-kwolf@redhat.com> In-Reply-To: <20221027183146.463129-1-kwolf@redhat.com> References: <20221027183146.463129-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.515, 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_H2=-0.001, SPF_HELO_NONE=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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1666898875844100003 Content-Type: text/plain; charset="utf-8" From: Emanuele Giuseppe Esposito blk_set_enable_write_cache() is defined as GLOBAL_STATE_CODE but can be invoked from iothreads when handling scsi requests. This triggers an assertion failure: 0x00007fd6c3515ce1 in raise () from /lib/x86_64-linux-gnu/libc.so.6 0x00007fd6c34ff537 in abort () from /lib/x86_64-linux-gnu/libc.so.6 0x00007fd6c34ff40f in ?? () from /lib/x86_64-linux-gnu/libc.so.6 0x00007fd6c350e662 in __assert_fail () from /lib/x86_64-linux-gnu/libc.so.6 0x000056149e2cea03 in blk_set_enable_write_cache (wce=3Dtrue, blk=3D0x5614= a01c27f0) at ../src/block/block-backend.c:1949 0x000056149e2d0a67 in blk_set_enable_write_cache (blk=3D0x5614a01c27f0, wce=3D) at ../src/block/block-backend.c:1951 0x000056149dfe9c59 in scsi_disk_apply_mode_select (p=3D0x7fd6b400c00e "\00= 4", page=3D, s=3D) at ../src/hw/scsi/scsi-disk= .c:1520 mode_select_pages (change=3Dtrue, len=3D18, p=3D0x7fd6b400c00e "\004", r= =3D0x7fd6b4001ff0) at ../src/hw/scsi/scsi-disk.c:1570 scsi_disk_emulate_mode_select (inbuf=3D, r=3D0x7fd6b4001ff0= ) at ../src/hw/scsi/scsi-disk.c:1640 scsi_disk_emulate_write_data (req=3D0x7fd6b4001ff0) at ../src/hw/scsi/scsi= -disk.c:1934 0x000056149e18ff16 in virtio_scsi_handle_cmd_req_submit (req=3D, req=3D, s=3D0x5614a12f16b0) at ../src/hw/scsi/virtio-scsi= .c:719 virtio_scsi_handle_cmd_vq (vq=3D0x7fd6bab92140, s=3D0x5614a12f16b0) at ../src/hw/scsi/virtio-scsi.c:761 virtio_scsi_handle_cmd (vq=3D, vdev=3D) at ../src/hw/scsi/virtio-scsi.c:775 virtio_scsi_handle_cmd (vdev=3D0x5614a12f16b0, vq=3D0x7fd6bab92140) at ../src/hw/scsi/virtio-scsi.c:765 0x000056149e1a8aa6 in virtio_queue_notify_vq (vq=3D0x7fd6bab92140) at ../src/hw/virtio/virtio.c:2365 0x000056149e3ccea5 in aio_dispatch_handler (ctx=3Dctx@entry=3D0x5614a01bab= e0, node=3D) at ../src/util/aio-posix.c:369 0x000056149e3cd868 in aio_dispatch_ready_handlers (ready_list=3D0x7fd6c09b= 2680, ctx=3D0x5614a01babe0) at ../src/util/aio-posix.c:399 aio_poll (ctx=3D0x5614a01babe0, blocking=3Dblocking@entry=3Dtrue) at ../src/util/aio-posix.c:713 0x000056149e2a7796 in iothread_run (opaque=3Dopaque@entry=3D0x56149ffde500= ) at ../src/iothread.c:67 0x000056149e3d0859 in qemu_thread_start (args=3D0x7fd6c09b26f0) at ../src/util/qemu-thread-posix.c:504 0x00007fd6c36b9ea7 in start_thread () from /lib/x86_64-linux-gnu/libpthrea= d.so.0 0x00007fd6c35d9aef in clone () from /lib/x86_64-linux-gnu/libc.so.6 Changing GLOBAL_STATE_CODE in IO_CODE is allowed, since GSC callers are allowed to call IO_CODE. Resolves: #1272 Signed-off-by: Emanuele Giuseppe Esposito Message-Id: <20221027072726.2681500-1-eesposit@redhat.com> Reviewed-by: Kevin Wolf Reviewed-by: Hanna Reitz Tested-by: Antoine Damhet Signed-off-by: Kevin Wolf --- block/block-backend.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/block-backend.c b/block/block-backend.c index 705afef9b3..ec17dc49a9 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -1944,7 +1944,7 @@ bool blk_enable_write_cache(BlockBackend *blk) =20 void blk_set_enable_write_cache(BlockBackend *blk, bool wce) { - GLOBAL_STATE_CODE(); + IO_CODE(); blk->enable_write_cache =3D wce; } =20 --=20 2.37.3