From nobody Sat Apr 11 23:03:15 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=1773069036; cv=none; d=zohomail.com; s=zohoarc; b=Eu2JuWTWisekHqvev8OxF5vGvndgp2C1kNDWYMzksKWv/x6+C0CArRoe07LmWC6uP9v0a/v0hUkR2zDiWIoBn3g15PehBLalscA7uR2M+Pr9/3xfjPgcAviKYq91iQlVmU4qv2gph0JOg30lrVlzstcViDOvQhJnkQ2RM5bRS5g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1773069036; 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=HZlCiaeoLEleGjH47/mJTlqebumMXTgkps2WXMv7tSY=; b=UHXW7L1GHr8yxo25a3+klTIXSzmJRHq9NqPYub3gKCMUXJaS3cdiQevWPQZfKKpv8ELxNZqoTCYFRfK5FR9jXLRR/tl4iJST9W9qm/DRIvrFr3vxu4IYycw6AlQA8ieikbW0JVToLj7NF8E+vW7VdP2ZJB4vds6OqunCLl4zeXA= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1773069036549281.4746768305745; Mon, 9 Mar 2026 08:10:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vzcEk-0000t5-NK; Mon, 09 Mar 2026 11:09:38 -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 1vzcEj-0000sN-Ko for qemu-devel@nongnu.org; Mon, 09 Mar 2026 11:09:37 -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 1vzcEi-0008NX-5k for qemu-devel@nongnu.org; Mon, 09 Mar 2026 11:09:37 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-142-m9fzkmZONp6jbylB1WExnQ-1; Mon, 09 Mar 2026 11:09:34 -0400 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4837bfcfe0dso138889525e9.1 for ; Mon, 09 Mar 2026 08:09:34 -0700 (PDT) Received: from localhost (p200300cfd737d0cf29d515fbd6051d53.dip0.t-ipconnect.de. [2003:cf:d737:d0cf:29d5:15fb:d605:1d53]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4853c784813sm63858295e9.5.2026.03.09.08.09.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Mar 2026 08:09:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1773068975; 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=HZlCiaeoLEleGjH47/mJTlqebumMXTgkps2WXMv7tSY=; b=cSjpR5YT53tT0T4RVWi/GPDjzvwZZMtXREbX40Cpq4cPwfln4mRWZbvlYY65Qx4kodoJSm ZSmOAYs6tnGQ6XnuDWg8ApK6LQ5lXh8gFuRzzHvKk+iXT7promK5MWYOEVq+CspNgTCGdk 0yBvUkN1CAPZEVzMAPIFE+q7sVWgQNM= X-MC-Unique: m9fzkmZONp6jbylB1WExnQ-1 X-Mimecast-MFC-AGG-ID: m9fzkmZONp6jbylB1WExnQ_1773068973 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1773068973; x=1773673773; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HZlCiaeoLEleGjH47/mJTlqebumMXTgkps2WXMv7tSY=; b=AS0WBVDWJDL8uBkiWaDVuGXwk6J09GKnnFqaKxB6M6fMuOYccsEc720/SSzHnY983V TC6AiDPBhIh19g8EZ5N1Qswy80f9ac1qCjpqot5DxCD25PKk2UO5ZzOPmABmu9f0t6lr 7t8MY3yAwB5tXSoR675Xo8s9EQZZ+Xhu/sT3BogPfINy9v48E21vv3sF+Q6Agqdp6sqd RrxzjddOqVITKqJSXexH1N5sp37XCKqbQBVph/MJa1bxqBLPBGESC5RPqb63ZJIvTfs7 z1gH8Vi+roG/1J5XkspmZmOlkJTqzgHpKxpVWP8G0LnjkPQKlYJMPp8E475Lsmq687H4 e3NA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773068973; x=1773673773; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=HZlCiaeoLEleGjH47/mJTlqebumMXTgkps2WXMv7tSY=; b=KkNtbjjB6N1Bd/BAaH0F6ZZF2UtkBBKdbqkXVtP6IGSoNvEr6nH+5umFv+3wgqcJO2 VzM8uK2SlWjiPZsUyiKHEIXleTll3W/UVf/SXxvtzXGdeNe8EodJQ2wPWe0/x2qBZiDs OqRZNNQ0fUhzhxQcUdzwj22v6kZ7e+h3kAk9ovUS1nCwHSrp2riJXCjd6F6VuzFAgXEJ 3Zw/QKIHlf50dPrpJPh5TjJMnaiq7HBs2P+E+zvXwsMbGOUa4ReJtZXqO6RNc+ANd8N/ xDcq5LSmnG08SV3YMDu5zW/b+vyeShSBaUzWclMmwdtUUWZHZr2YwIDKPDEp3/5tPbDI 01WA== X-Gm-Message-State: AOJu0YyT0D9LOpq84A4kFJ8PwLYV1a59/l15uAgsdCVSDYXWBDrGN06+ QFK4au+DUvE0Iw8txok9Tdo4MfCCaPqg412w7kX4iC6cHMToOHc5iwTwDhFju8Z+XtQ15tRRj0r /Q6Ms+8tSwHTFgglL0P/hADOkDNAEm8vbQKCAAsTw71OpWSg/3MPE+M1/ X-Gm-Gg: ATEYQzwdpi+fHRoUhW5FXSYcg4y82kwFuyi0naoVkAUH3nzoFdMgyHCuxjwYWUgg0Ar CqQvfKW/y4tyQJeiMCv1HvEUdaevIa7rmWvEDRjgAgUphZeO5/GrFRz1rR9l0CEa/yktqDZSdH7 lqK0a4GFOcU4wedDTchAlh8KbQYnpg14mUTfvhtb+t9qTOY6xXGAvNfV2FSlQ7rivtFZyAsVV++ 0rgxagCDz1hXNYq8ZkKW5V/wc015NHcrLXaOBrJxU74uDW+YviXo3E1R9XbpU5OZaVwfVHetn5V wyop83avAJw5KPvrpjp8j0y059B92mY6b8JXZwD7NyfeePhPHUtGg6Y0aLYaARChlWfb4A7G01o j0Mg5DaH/PYVDSgTqoHNU08yapiFuYDt3X8x5WPGeZ/wd5LRAkskojatsHUZhalW2juqNrWSCF/ 3YCI6n X-Received: by 2002:a05:600c:8219:b0:485:2fd9:3d4a with SMTP id 5b1f17b1804b1-4852fd94025mr124078925e9.22.1773068972965; Mon, 09 Mar 2026 08:09:32 -0700 (PDT) X-Received: by 2002:a05:600c:8219:b0:485:2fd9:3d4a with SMTP id 5b1f17b1804b1-4852fd94025mr124078275e9.22.1773068972488; Mon, 09 Mar 2026 08:09:32 -0700 (PDT) From: Hanna Czenczek To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, Hanna Czenczek , Kevin Wolf , Brian Song Subject: [PATCH v5 11/25] fuse: Add halted flag Date: Mon, 9 Mar 2026 16:08:42 +0100 Message-ID: <20260309150856.26800-12-hreitz@redhat.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260309150856.26800-1-hreitz@redhat.com> References: <20260309150856.26800-1-hreitz@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=hreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -3 X-Spam_score: -0.4 X-Spam_bar: / X-Spam_report: (-0.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_VALIDITY_RPBL_BLOCKED=0.819, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.903, 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: 1773069038629158500 Content-Type: text/plain; charset="utf-8" This is a flag that we will want when processing FUSE requests ourselves: When the kernel sends us e.g. a truncated request (i.e. we receive less data than the request's indicated length), we cannot rely on subsequent data to be valid. Then, we are going to set this flag, halting all FUSE request processing. We plan to only use this flag in cases that would effectively be kernel bugs. While not necessary yet, access the flag atomically so that it will be safe to use once we introduce multi-threading. (Right now, the flag is unused because libfuse still does our request processing.) Signed-off-by: Hanna Czenczek --- block/export/fuse.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/block/export/fuse.c b/block/export/fuse.c index fc75a5e74d..f6a5f4fa0a 100644 --- a/block/export/fuse.c +++ b/block/export/fuse.c @@ -53,6 +53,13 @@ typedef struct FuseExport { unsigned int in_flight; /* atomic */ bool mounted, fd_handler_set_up; =20 + /* + * Set when there was an unrecoverable error and no requests should be= read + * from the device anymore (basically only in case of something we wou= ld + * consider a kernel bug). Access atomically. + */ + bool halted; + char *mountpoint; bool writable; bool growable; @@ -69,6 +76,7 @@ static const struct fuse_lowlevel_ops fuse_ops; =20 static void fuse_export_shutdown(BlockExport *exp); static void fuse_export_delete(BlockExport *exp); +static void fuse_export_halt(FuseExport *exp) G_GNUC_UNUSED; =20 static void init_exports_table(void); =20 @@ -99,6 +107,10 @@ static void fuse_dec_in_flight(FuseExport *exp) =20 static void fuse_attach_handlers(FuseExport *exp) { + if (qatomic_read(&exp->halted)) { + return; + } + aio_set_fd_handler(exp->common.ctx, fuse_session_fd(exp->fuse_session), read_from_fuse_export, NULL, NULL, NULL, exp); @@ -322,6 +334,10 @@ static void read_from_fuse_export(void *opaque) FuseExport *exp =3D opaque; int ret; =20 + if (unlikely(qatomic_read(&exp->halted))) { + return; + } + fuse_inc_in_flight(exp); =20 do { @@ -380,6 +396,20 @@ static void fuse_export_delete(BlockExport *blk_exp) g_free(exp->mountpoint); } =20 +/** + * Halt the export: Detach FD handlers, and set exp->halted to true, preve= nting + * fuse_attach_handlers() from re-attaching them, therefore stopping all f= urther + * request processing. + * + * Call this function when an unrecoverable error happens that makes proce= ssing + * all future requests unreliable. + */ +static void fuse_export_halt(FuseExport *exp) +{ + qatomic_set(&exp->halted, true); + fuse_detach_handlers(exp); +} + /** * Check whether @path points to a regular file. If not, put an * appropriate message into *errp. --=20 2.53.0