From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796122744; b=wwOhnrrrvUDmbWnWm6paawpCNl3MOFAPy6Dg63odV6IOC4GQ7id01QQf9nkruu7t/BSz ZNaYSY+95c9Pj7w+AbEZY1HHl7XrcgOY5tdimX/4u1qbpVP7FBJQXuKt2gljiZQObr1uQ E4y0WEM7V+P3WqM/IBQ9QCkXXC8aqbxovKf6yLLTUnGGDzEdN2hIS4nvsj5b9S8Hap6ko 9wtEa9/gaw91vzncvy7hg1u/xMf4EJAOi+uutjGd6PL7B1Pu50ViXD6Rv1lT4SYW32xep GG+06TIRmuaaD+2k9u7Xxm9uXBWTIOAYojg1ybnqD+d4jcYilnS/AVLl8Jeml0f9ySw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796122744; h=DMARC-Filter:DKIM-Signature:X-MC-Rep:Received:X-MC-Unique: X-Mimecast-MFC-AGG-ID:Received:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received: X-Received:Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:X-Mimecast-Spam-Score: X-Mimecast-MFC-PROC-ID:X-Mimecast-Originator: Content-Transfer-Encoding:content-type; bh=ZY7nsKyFQVIp49kpKGxWxV831YSfshYCBXzx2OAg65E=; b=pWH+kbi/2uR/x9bJ4yv39XDHwt2NvNKbdfvFlZ6LOsy95tOCjnaUi6hCF9cZik3pF3gY Iisch9lVY5hpLIE9HTQhD3MogPvPShonNdQsR0KTd0KWbP/+VZ8cjEP9bJ9tyNSZa70GZ dRLqr1JC9+spNo1eQwI+VAgjGwv7D3kOxfKL2o73nhOW6mOaaQ0ldM3042w8AQK7dN2gX Mc86fnpIxPIUwk7R6E6+DoAmBe56sgQ9x/m7IKENLUefUZee9GIlEIV35CwzeyCrczGVK 4/g1e4cMST0WKdwIeFVaktiecypL+Q/Bd8MduVH2yBlichS9hGkUP6PJtfYpiFWgNwg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=PuotqWcg; arc=none smtp.remote-ip=170.10.133.124 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AA023606A327 for ; Tue, 1 Dec 2026 10:59:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org AA023606A327 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=PuotqWcg DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796122743; 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=ZY7nsKyFQVIp49kpKGxWxV831YSfshYCBXzx2OAg65E=; b=PuotqWcgDtC36tXOvTpon6W2t/EZrgt0Kuf8Y1pAKJgXTsiesG6XwAuytxFYF1cDki9Trj iKNLMKHCG414wrC7bQUcaMOfF/CZ9Rvqjwn/Cr3/f94u5aEr1LcN6ppVwiaN+/BknB5dAb sqdDa4exuhF4pcIBbset7SmXbkIJqo4= X-MC-Rep: binary re single Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-348-RnPJ46O1PWuNWsPAk_tkxQ-1; Tue, 1 Dec 2026 10:59:00 +0000 X-MC-Unique: RnPJ46O1PWuNWsPAk_tkxQ-1 X-Mimecast-MFC-AGG-ID: RnPJ46O1PWuNWsPAk_tkxQ_1796122740 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-4915ba023d4so7494654f8f.0 for ; Tue, 01 Dec 2026 02:59:00 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796122739; x=1796727539; 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:content-type; bh=ZY7nsKyFQVIp49kpKGxWxV831YSfshYCBXzx2OAg65E=; b=aO3xL67ekI1cgwYgo8tKAvJWHlCjjbkUb+AWBPSGHWIiSw/Sq6U1IIb+NEiypixwnf OxYwZDEzZSivAdKiyRuZKegxQDUXuOoGJPYSj56mNnKPDfRZVrT+mz3nRcYesOmKGSVz oGiaHwmWUVJqAntmhYH5LVmH+ttQlDlz1zFOzi5psRWdhm68RMBv9zecaH6M68kpifVR vcYT0JDVzNYBOECl02/rcdb9kzuJ/LtkYCj0XgS9vKyKr6d5HIz0kumOYgl4h4JnWwaE jPhRMpHE51C+j6CXThS1fwBNTywKGGDy0XBk5WGAfzrCRm8edmfHraDqbpI6slonJkcg Y2Zw== X-Forwarded-Encrypted: i=1; AL+hErFHLb4d962DKbd6MoiHzNIbipoIeqFOOzNuwv+GwGGKkYfaAZ0fLZ3AbGpH46lajzKHbePaM/NTXKqzkYqI0A==@lists.linux.dev X-Gm-Message-State: APuU4Z+tKGDfefq6JTJileh/fewcPiAsd74F9RdfxKHvjj1ag5hELPin BwKjVKVzZX/jZUk78ITdEmScaHXJQCht84GrXT6jBVie9f/PFI7EJRI7Xj6UHRGf/zVaZfApfnj Js9qgf8yDiKkRLTAehvmAR75DyGqDTNrL1wj54Ld3YqrvUFJDl7/lHMyWWBQCLN3LJgqD X-Gm-Gg: AZFdTZe3fxFe+YXjYWmFBAqaByba3/ypFGGxo0wf2G0l2xpiqInon3dqgl87wPktt+r wHU5DShvlrF9GTORv8HuIsB2rcDhAakkaFWZzX4WHgYHkcA1lZx10CfxduhXaVmKEXHfx7Ksddm zMmE2+Y1CbnjSZ1NGIj3qxdc1ZfALuIjvUhj+9WElU/Np+eAMeYY7sZxXxtT+MScqpeoYCP9OqO ZRqbYp5fvlnm2nzpH53k9MjGsUJMTh28HCewnXsRv2UqWmfptH8YKcMIWVjFQQv6yBM6032PUGG T6eT/MPSdXyMTL6Yn4Z8i+po13gAVdLMo62HUEbq97Z5/mpXfPRnyHlysDGcRklMv+zlb2Ci18u 4zsu8jhjWezOaBLigXRPR8y5GIsJmMkFnI69wloMkesO7OL0qjcxQam75HZQJzKJelkksItVrqS +oFTlpHxZgsFwiyXwLRWN3etBpPXdeLVCkAj1MD/vD X-Received: by 2002:a05:6000:47d4:b0:493:8c32:94 with SMTP id ffacd0b85a97d-4abb400ae31mr46544643f8f.38.1796122739491; Tue, 01 Dec 2026 02:58:59 -0800 (PST) X-Received: by 2002:a05:6000:47d4:b0:493:8c32:94 with SMTP id ffacd0b85a97d-4abb400ae31mr46544621f8f.38.1796122739074; Tue, 01 Dec 2026 02:58:59 -0800 (PST) Received: from mszeredi-thinkpadt14gen6.redhat.corp (193-226-214-34.pool.digikabel.hu. [193.226.214.34]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4ab69bf685asm72464829f8f.20.2026.12.01.02.58.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2026 02:58:58 -0800 (PST) From: Miklos Szeredi To: fuse-devel@lists.linux.dev, virtualization@lists.linux.dev Cc: Li Wang , German Maglione , Stefan Hajnoczi Subject: [PATCH v3 3/5] virtiofs: retry request submission from the worker on -ENOMEM Date: Tue, 1 Dec 2026 11:58:51 +0100 Message-ID: <20261201105855.430993-3-mszeredi@redhat.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261201105855.430993-1-mszeredi@redhat.com> References: <20261201105855.430993-1-mszeredi@redhat.com> X-Mailing-List: virtualization@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: l53gIlUzNAcWuh6gkr9OlWns8LxWMTI6wa7Pl65qs0M_1796122740 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true virtio_fs_send_req() enqueues with GFP_ATOMIC, because it may be called with fc->chan->bg_lock held. The sg arrays and, via copy_args_to_argbuf(), the bounce buffer are allocated with those flags, so under memory pressure a request can be failed with -ENOMEM even though nothing is wrong with it. The buffer is as large as the request arguments, so this is not limited to tiny allocations: FUSE_REMOVEMAPPING, for example, can ask for just over 4 KiB, an order-1 allocation out of the atomic reserves with no reclaim. A virtqueue that is merely full is already handled gracefully: -ENOSPC puts the request on fsvq->queued_reqs and virtio_fs_request_dispatch_work() retries it with GFP_KERNEL under memalloc_nofs_save(). A failed atomic allocation is just as transient, so treat it the same way instead of ending the request. Unlike -ENOSPC there is no completion to kick the worker afterwards, so schedule it here. virtqueue_add_sgs() can also report -ENOMEM, but only for a DMA mapping failure, which the retry will not fix (failure to allocate the indirect descriptor table falls back to direct descriptors and does not return -ENOMEM). Such a request is retried once and then ended with -ENOMEM by the worker, so the two cases are not worth telling apart. virtio_fs_enqueue_req() queues on -ENOSPC only after checking fsvq->connected under fsvq->lock; do the same here and fail the request with -ENOTCONN if the queue is gone. req->argbuf has already been freed and cleared on the error path, so the retry reallocates it. Fixes: a62a8ef9d97d ("virtio-fs: add virtiofs filesystem") Reviewed-by: Li Wang Signed-off-by: Miklos Szeredi --- fs/fuse/virtio_fs.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/fs/fuse/virtio_fs.c b/fs/fuse/virtio_fs.c index 8bd63c6165d2..6ddb2f181a16 100644 --- a/fs/fuse/virtio_fs.c +++ b/fs/fuse/virtio_fs.c @@ -1586,6 +1586,23 @@ static void virtio_fs_send_req(struct fuse_iqueue *fiq, struct fuse_req *req) */ return; } + if (ret == -ENOMEM) { + /* + * Only the GFP_ATOMIC allocation failed. Hand the + * request to the dispatch worker, which retries with + * GFP_KERNEL, rather than failing it outright. + */ + spin_lock(&fsvq->lock); + if (fsvq->connected) { + list_add_tail(&req->list, &fsvq->queued_reqs); + inc_in_flight_req(fsvq); + schedule_work(&fsvq->dispatch_work); + spin_unlock(&fsvq->lock); + return; + } + spin_unlock(&fsvq->lock); + ret = -ENOTCONN; + } req->out.h.error = ret; pr_err("virtio-fs: virtio_fs_enqueue_req() failed %d\n", ret); -- 2.56.1