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=1796049463; b=5lyFk/q/QDmshNc6kopsSQ85v4o8n4VMJEYvqOZ8ZYQFmxL7OOcDtZUx6jhNT+DHAB1l OGQ9dsnGORdc8Xa25SSyhYQsY+gh3Ra/gZdCsUbER0HyoIhYPs19trUeyHuvTO0zqEYYr p91h9nwB/YzMeIkrn8ubV4/vA87fxISiw6KFSf5mZUY6toAdtj41a9snujuBMkv2DcEs4 VH+JgfttE3Zous2pPjPJu/kS3e432mKwhyV1SxVIZZiuWf/ApvxN8AFkUZwwTxZOZ7DCg 9xMyC2yBax865rUl7Pa4ygb1kt4pLXX0Tij6/sqrAjpWd/dDsgjhByCZgfdOyfaJU5A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796049463; h=DMARC-Filter:DKIM-Signature: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=XAAvFSOJWbbCg6wnnL9FV2x0nkp4Bx8SiZ+42CWmyIql3cevwxfjx9UeMqOSxhlCSQrS B97/0w5u/qQfuPGPG8MgRWLXGL50eLMYr410KLZmoqJpWXxgOETmFMooCyJOIHEs7vdv+ w+UZAIngp+KvNUiHnF010BvHqiZwELR2pZu6Nesqr/xfLz0+l/foTeNAe+kHgcQ9Y8ZKC +qxsuO7M3kwRAX3gBrXPqCDB44D8oMwLLAV7cyFuId6fW+t8PG4km82XGs5hKoJYElw8/ CJRRzXFI10N8xhN+tY5MHMzgTKO8LT/cgHbAw8t8f3NnLYiHE9v/QwKP0UcfgnWf6lw== 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=EA4d0o1y; 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 22DA5606A697 for ; Mon, 30 Nov 2026 14:37:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 22DA5606A697 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=EA4d0o1y DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796049457; 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=EA4d0o1yKpwPQS/MxX/6cT3FH7jLLAyiMbVgO+Ov41u9/uQZW5faIRwZkl/IUwMtuZZgfr 0am9cOtn1t692hEsqYHcIV3l/FlOy/xQGkHaijf3JqVaqKnL4JimOw+SFwYrrpnHEBFYII 68RcZHI2i79TApvUWSQ1+mZMx1XdZIs= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-684-lDEYmHxvP7WPmdyiWgbujA-1; Mon, 30 Nov 2026 14:37:35 +0000 X-MC-Unique: lDEYmHxvP7WPmdyiWgbujA-1 X-Mimecast-MFC-AGG-ID: lDEYmHxvP7WPmdyiWgbujA_1796049453 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-4aae099f5baso5257157f8f.1 for ; Mon, 30 Nov 2026 06:37:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796049453; x=1796654253; 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=Q7DX/BE+URcgy4iezERENnnhJ2dojkVEMjmqXhkoCPgehgdnqWvhSjgS7v3OeJIQto HxBVIbu+iLpUZMpCnecTB/FQVV5QbSycYCo0DTWtUh0mQ/sSN/Yvz49W23BKAUdn4Neq 4yMsD9qKCnKuQaqnhzoM9MQrSY4IuK87+CE3H6wYgoZVsSytocRUKHBBnp8Lr0eX5Me9 Qo5zVCsu+7IRDSLK3RIyskv83CmDMewRynXRHVH6/wMqvPoV+TNyDFscko6dAMgW/cXK 8uoKJuyuNo5FKcgn13j8ddXOSjFGKUUbbG73ZjS+BAn9BPYWYvOT7YVkykDIy6EfcmyQ uOvQ== X-Forwarded-Encrypted: i=1; AL+hErFF8q+QdojXNuvjoonOPVcLrvMb5Lm8HRozcuAzu9QxvY8ulFkWrIPCWnbfmLXRZb30WXj1p3jjiZZVP0OLVQ==@lists.linux.dev X-Gm-Message-State: APuU4Z87Y7cYGtGe/ZQZ3WsiZRZvi3DWQyExreuE+tuddHrhGjEwC86+ la5JbI6CwrA3xIgimXyZdBTU3H9OtOyvvlnIMLSgTMMNxh4Wqso8FY/0y8wTYZ07i1qDvs5KTBz Lx1q/6NrQRyfGySoeynGlBxw4ZIXs8a7GziCNwW3zY77Xvh29RK5eHRG27yU6ZOS+Avy4 X-Gm-Gg: AZFdTZeMq0vCP4K7Cg4+YgLkVbVvR+RQ02bI0UTNHdr87dj1XECdajK0TgN6zgQpT+X xWftxLPRwKdQnLWIN1gdxWglndCdHMMGIHNkPeW2RYwOlFcywVzl/w8L9Jp1fil5rjwaGC4HabV jlbsrRz5MqXyP9R0mbod+xUWaJFCF2FJmypN8iW3CrfwkPlkoLGaOz+AbHLcjuHwukMMZedH+EM iIJpoadxh2tVVzOzZUePkNZFEfbr5NKTLwgbcNatDMnoA1GWZY3qUpQKXsjDf3sCGiVj/xjRHpl ojiRPyOziT6/UYaY1etk3SUWNgGs7l4aeyvlaQkQz6VwdXf0SBuHxQY5ZHw3ot/L3tjDhxYyOrY J2ZejAQSmVNtn6V04r4mLrzix5XwIqfnth7ey+d+IOGSp98NbHFSlOMgjaPP2vfycqRBMDayN6+ 6bPE+v9NQUrvNgdD64P5gPllKlDNhqnYvCagYnKuyV X-Received: by 2002:a05:6000:2883:b0:4a4:39bb:970d with SMTP id ffacd0b85a97d-4abab02c469mr63981851f8f.2.1796049452912; Mon, 30 Nov 2026 06:37:32 -0800 (PST) X-Received: by 2002:a05:6000:2883:b0:4a4:39bb:970d with SMTP id ffacd0b85a97d-4abab02c469mr63981806f8f.2.1796049452476; Mon, 30 Nov 2026 06:37:32 -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-4ab6b110c3csm62452044f8f.36.2026.11.30.06.37.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 06:37:32 -0800 (PST) From: Miklos Szeredi To: fuse-devel@lists.linux.dev, virtualization@lists.linux.dev Cc: Li Wang , German Maglione , Stefan Hajnoczi Subject: [PATCH v2 3/4] virtiofs: retry request submission from the worker on -ENOMEM Date: Mon, 30 Nov 2026 15:37:19 +0100 Message-ID: <20261130143728.326871-3-mszeredi@redhat.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261130143728.326871-1-mszeredi@redhat.com> References: <20261130143728.326871-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: 4ZhptYTMwjz49wqPl69hdZ-ekVvaBT1Alj29krMROOA_1796049453 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