From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=103.168.172.147 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796339848; b=4JgwWG0Mxa9EjTLCoFN8GWbl+iSEz7lDhsguEg/Ka+6C3cpMkG7kw9FJfRRR4i6Io/mF utz9G+KxJBd11fhPUDrm7RUJuMB3TWZpNONcYuA8B939XciIwMI52snJagePwNPDkWrsf NhEfytRj49bh1eA0qWXClSjvylFVWrTbdbGIORTh+NgOVBsgJgUMI2ZIJymoqrkCfuigJ zvkyAgE/nKiTRHm9/HK9siimBAaqqiex1mp3IeC3KtqlqyTpg4SXhuA+MqWErGL7uZRRx Cd/+irIoc9Q9laMsUgQPwVL3ruVZqKC4iEvQrC8PCLeRQ5kTJjaU1icud1SopyetpDA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796339848; h=DMARC-Filter:Received:Received:DKIM-Signature:DKIM-Signature: X-DKIM2-Info:DKIM2-Signature:X-DKIM2-Info:Message-Instance: X-ME-Sender:X-ME-Received:X-ME-Proxy-Cause:X-ME-Proxy:Feedback-ID: Received:Message-ID:Date:MIME-Version:User-Agent:Subject:To:Cc: References:From:Content-Language:In-Reply-To:Content-Type: Content-Transfer-Encoding; bh=NVrrWDXjuVmtSKs2Uy/3447ISGTe+jNwYV5/PIddAoY=; b=T5A2qOI07Mws7+j9bUzdN93+FlCymYlv2a+CjHDq56JaHQtyuqG3SnZZkyyMq8xqAJ2w 6YWVkFNRndo3xftwjzduBmoHtv3tsrQ7OGxZvQ+OFrt/sxpkJHzhE82YWRQO3wAX3+lbv 37AKY1VlxN4rfHKT7DjZsVes8MypK1GsU+E6FUTuCrSKDY0S3/dPj0/lTwjLE1tXoKdbM AIazUo2Viyh35L5EW/MKHCvJhkDHIrmP8wiWbLv8rVEez0FKPggNzO1yJfKmGq27u6P+o dyfLNDrj+lgTo/OeFDLUmGTRK1Z7CCPklZ/YAkjVXSgdjWIrd17gyCZmoEBr64Au1AQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=bsbernd.com; spf=pass smtp.mailfrom=bsbernd.com; dkim=pass header.d=bsbernd.com header.i=@bsbernd.com header.a=rsa-sha256 header.s=fm2 header.b=VyVqaUhl; dkim=pass header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=zjlhXWlT; arc=none smtp.remote-ip=103.168.172.147 Received: from fout-a4-smtp.messagingengine.com (fout-a4-smtp.messagingengine.com [103.168.172.147]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2C25A606A32D for ; Thu, 3 Dec 2026 23:17:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 2C25A606A32D Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=bsbernd.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bsbernd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=bsbernd.com header.i=@bsbernd.com header.a=rsa-sha256 header.s=fm2 header.b=VyVqaUhl; dkim=pass (2048-bit key, unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=zjlhXWlT Received: from phl-compute-01.internal (phl-compute-01.internal [10.202.2.41]) by mailfout.phl.internal (Postfix) with ESMTP id 52049EC017A for ; Thu, 3 Dec 2026 18:17:26 -0500 (EST) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-01.internal (MEProxy); Thu, 03 Dec 2026 18:17:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsbernd.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm2; t=1796339846; x=1796426246; bh=NVrrWDXjuVmtSKs2Uy/3447ISGTe+jNwYV5/PIddAoY=; b= VyVqaUhllSzkMHBsH0GfewzUrp0beL2PHtqN3PY3xUwp70CKQ+WO2Th0Ja/dUbRa TEwHqDdTmjKJHZm8e6R61Mq/lFdxaOW40XP3xH0KV8xXASCFxhCnx7epT0HhnyzE El+s9qUnRp5Ibrg+OSo61Q4CLNYfhY8pFu9rCouWTgJ/CXBaRiMKisac6ydqDnBV 1m0zAWHanHPj6eRyqQB3RTaqWZgqS64VlP1oo/AtMm4kAOSwqgx3GPHPDSO4Hgjl ar1gN7k9ufeLItqAJdTiVzPCHXmvSYGx44dYPH4Lmmjl+VlWs92Fi2k8/fpw/qiv JdhP3p4ZOiSnFq9yefQyPg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1796339846; x= 1796426246; bh=NVrrWDXjuVmtSKs2Uy/3447ISGTe+jNwYV5/PIddAoY=; b=z jlhXWlTCVbB+bSHU2Izm3j7KGrxXBt6N53oQydr/ub1q8l01SD3sMPLATKmYCKWB rlZi6p/xTKWGiNm8LgBcVk18dk81ZhvuBv0KLT3jzE1IH59k05YrnOkgx4FG/Szq ahDjBZzK5CCzXZAxrNNlpr97N8RjyADwkxnrcb+2JGtF/7mH7KoPqGXuK79axrLB clgcGLArOZk+tBoXaucw99udAokGPzg7NdTAFoiZD2Rk/czAj9KiqY3ZdGTDg6sm 26ozQfmlI0yTHzEPE5allXQTpBbTzgdyDV6DvzQGbIfSLRBH4325sLtEBK+FMI2m tSJ8LFL2ajkaiE113EYZQ== X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-09; repo=github.com/dkim2wg/interop; date=2026-11-03; sw=lmtpprox; action=sign d=bsbernd.com a=rsa-sha256; DKIM2-Signature: i=1; m=1; t=1796339846; d=bsbernd.com; mf=PGJlcm5kQGJzYmVybmQuY29tPg==; rt=PGxpbnV4LWtlcm5lbEB2Z2VyLmtlcm5lbC5vcmc+; s=fm2:rsa-sha256:jg0/FjR8X5Z5r7n3aCDw9bex7oU6oTQgouMo2kUdfCW+WA2 9QyBzYObrqEjxUjC2aebtTIdytXpJGbcl8/1FwdYQdDVzPJFjUnQRTBJo5kR2n9L HZX6AqlKgIHkYVuKrsmsJ2wAaVUDmP7j3Ifo59GjFua99+IWmOGzZrbLlyuezGQr xiPUysMfTiUqzFWddZhNpKEGXqgn62ZWZg67UBIH6D1/g+PhbG/SkENZCAHtQDG8 Uvsvwsee1MhtbylH4iY/UtEyxPxyMaBr5HG3wmoBTMEU66u+g5K/UD9nRpKL5Brp Q1Bf7oNL8ok2MaJo/jeGijN2auHWmoFmJTxbmSA==; X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-09; repo=github.com/dkim2wg/interop; date=2026-11-03; sw=lmtpprox; action=mi-m=1; hc=14; hn=cc,content-language,content-transfer-encoding,content-type, date,feedback-id,from,in-reply-to,message-id,mime-version, references,subject,to,user-agent; Message-Instance: m=1; h=sha256:a88VT1IRBPBXUCCO5IcsivNOHg73VqEqA56bZjYODv0=:2CRdvojrZEu6H0HqBeiB3gVN6vDEYD8MaCv1hv0IMrs=; X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTFx8hC/Ox7U9wA7dy7EZy6v/A+UaoAj2znHnSLCFL0e685COnAi0HejFsogkCzPr+ o+8LtrjJWuFPxI0qp9eAcNZ6UNC8menMJM0cdgiNuGOV9SZHgD7TtDAtegEN8w7W4E9qpl 7Jgy7tjTtZ0Pjt9p+0Rxh2pIwx+fGEhn73wvj+z9udSpTav4gNqy21SMHj1Y/bVZtFT6xB 8ko6SW0MQAAkfctS+3W1DIHu9nzjbl1MIjxm2D41bivCNJPsqrdlYuZM+R4DPNKyGLTV6b Dsx3HUrdRj0ZgOJnCZdLTQmHRQSTh9aMT4Spv5TSYrb27hK3gxPneqQRgraWVyz3dNWqbS xvispCZ4gwGz8UMCPqDOAZWX3/JBsctG5Rs0n/7r3nUlemsJHZR+2OAOk0GR2fotJukkW5 nEAZbniSTicGs1h6ItruxWx0OToggpnHM58b2A9t4Tvocv5OAvh0Le3XSfY43p7Fp3JU1Y B47Fr3B4myJqzLGkm+x8vva4bCNdCE9PAvfuDZDaK2Qvkz2esLouNt1TO88F77Tf6M3ezg GSgN3iZH03yoXRsD1vjqSwMHEs83j1iBI4cqn55wp6FoTtJ4aFie/bqGRfux3E7u3yL2S2 NfkZsIXNPUByNNXEZTM0xulzelKoTYg9EQaMDxFAJ40VvClQTJo0IJEV1Rfg X-ME-Proxy: Feedback-ID: i5c2e48a5:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 3 Dec 2026 18:17:24 -0500 (EST) Message-ID: Date: Fri, 4 Dec 2026 00:17:23 +0100 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] fuse: io-uring: end the request of a pending send on abort To: joberdorf@ddn.com, Joanne Koong , Miklos Szeredi , Pavel Begunkov , Luis Henriques Cc: Miklos Szeredi , Bernd Schubert , fuse-devel@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org References: <20261201-fuse-uring-abort-pending-send-v1-1-3386615f48c3@ddn.com> From: Bernd Schubert Content-Language: fr, en-US, de-DE, ru-RU In-Reply-To: <20261201-fuse-uring-abort-pending-send-v1-1-3386615f48c3@ddn.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Hi Justin, I will review before Monday. Please note that my DDN mail address still works, but likely not for long anymore. Thanks, Bend On 12/1/26 17:12, Justin Oberdorf via B4 Relay wrote: > From: Justin Oberdorf > > When a request is queued through io-uring and a ring entry is available, > fuse_uring_queue_fuse_req() (and fuse_uring_queue_bq_req()) assigns the > request to the entry and dispatches the send as task work in the server's > task (fuse_uring_dispatch_ent -> io_uring_cmd_complete_in_task). Until that > task work runs, the entry sits on ent_w_req_queue and the request is on no > list at all (fuse_uring_add_req_to_ring_ent() detaches it; it is hashed > into fpq->processing only by fuse_uring_send()). > > A stopped server never runs that task work: SIGSTOP, a frozen cgroup, a > debugger. That is exactly the server the request timeout is there for, and > fuse_uring_request_expired() does see the entry (ent_list_request_expired() > on ent_w_req_queue) and aborts the connection. But the abort ends nothing > for it: fuse_uring_abort_end_requests() ends only fuse_req_queue and > fuse_uring_teardown_entries() handles only ent_in_userspace and > ent_avail_queue. The caller stays in request_wait_answer() until the server > is continued or killed, and fuse_uring_async_stop_queues() logs > " ent-req-queue ... state=3" every 50 ms meanwhile. An idle server has > every entry available, so this is the common shape of a frozen server, and > the request timeout is ineffective for it. With FUSE_HAS_SYNCFS the caller > is sync(2): one stopped server pins every host-wide sync in D state. The > classic /dev/fuse transport leaves such a request on fiq->pending, which > the abort ends. > > Reproducer, with libfuse 3.18's example/passthrough_ll (its io-uring > queues run in the multi-threaded loop) and the timeout from the sysctl, so > no server option is involved: > > echo 10 > /proc/sys/fs/fuse/default_request_timeout > passthrough_ll -f -o io_uring -o source=/some/dir /mnt/x & > cat /mnt/x/file # the ring serves > kill -STOP $! > stat /mnt/x/file # from another shell > > v7.4-rc5: the stat hangs; from 5 s after the abort the kernel logs > " ent-req-queue ring=... state=3" every 50 ms; kill -CONT (or -KILL) > frees it - 45 s later in the run traced here. ftrace of that run: > fuse_uring_queue_fuse_req from stat on CPU 5, fuse_chan_abort from the > timeout work 15 s later, and the queue-5 thread's > fuse_uring_send_in_task only after SIGCONT. With this patch the stat > returns ECONNABORTED 15 s after it was issued (the timeout plus one check > period), the server still stopped. Our own server, which negotiates the > timeout at INIT, showed the same with sync(2) as the caller. > > Fix it in two halves that hand the entry over under the queue lock: > > - Entries dispatched to task work get a state of their own, > FRRS_FUSE_REQ_PENDING_SEND, set under the queue lock by the two > dispatching paths. The synchronous send in > fuse_uring_get_next_fuse_req() keeps FRRS_FUSE_REQ: it copies at once in > the server's own syscall. > > - fuse_uring_abort_end_requests() detaches and ends the requests of every > FRRS_FUSE_REQ_PENDING_SEND entry (fuse_dev_end_requests(), as for > fuse_req_queue). The entries stay for their task work. > > - fuse_uring_send_in_task() takes the queue lock first: on a live queue it > claims the entry (state FRRS_FUSE_REQ) and proceeds as before; on a > stopped queue, or on cancel, it releases the entry the way the cancel > branch did, ending the request only if the abort has not. > > ent_list_request_expired() tolerates an entry whose request the abort took > (a concurrent fusectl abort can race the timeout check there). > > The entry's cmd still completes only when its task work runs, so > fuse_uring_wait_stopped_queues() keeps its semantics: killing the stopped > server is what releases the ring, as before. > > Fixes: c2c9af9a0b13 ("fuse: Allow to queue fg requests through io-uring") > Cc: stable@vger.kernel.org > Signed-off-by: Justin Oberdorf > --- > Single patch; the description is in the commit message. > --- > fs/fuse/dev_uring.c | 89 ++++++++++++++++++++++++++++++++++++++++++--------- > fs/fuse/dev_uring_i.h | 6 ++++ > 2 files changed, 80 insertions(+), 15 deletions(-) > > diff --git a/fs/fuse/dev_uring.c b/fs/fuse/dev_uring.c > index 460776cd69cd..874ea0c2a561 100644 > --- a/fs/fuse/dev_uring.c > +++ b/fs/fuse/dev_uring.c > @@ -194,6 +194,40 @@ static void fuse_uring_abort_end_queue_requests(struct fuse_ring_queue *queue) > fuse_dev_end_requests(&req_list); > } > > +/* > + * End the requests of entries whose send is still pending as task work in > + * the server's task (fuse_uring_dispatch_ent). That task work does not run > + * while the server is stopped (SIGSTOP, a frozen cgroup) - exactly the case > + * the request timeout aborts the connection for - and nothing else would end > + * these requests: they are on no list, only reachable through their entry. > + * The entries stay for their task work, which finds the queue stopped and > + * releases them (fuse_uring_send_in_task). > + */ > +static void fuse_uring_abort_end_pending_send_requests(struct fuse_ring_queue *queue) > +{ > + struct fuse_ring_ent *ent; > + struct fuse_req *req; > + LIST_HEAD(req_list); > + > + spin_lock(&queue->lock); > + list_for_each_entry(ent, &queue->ent_w_req_queue, list) { > + if (ent->state != FRRS_FUSE_REQ_PENDING_SEND) > + continue; > + > + req = ent->fuse_req; > + if (WARN_ON_ONCE(!req)) > + continue; > + > + ent->fuse_req = NULL; > + /* detached since fuse_uring_add_req_to_ring_ent() */ > + list_add_tail(&req->list, &req_list); > + } > + spin_unlock(&queue->lock); > + > + /* must not hold queue lock to avoid order issues with fi->lock */ > + fuse_dev_end_requests(&req_list); > +} > + > void fuse_uring_abort_end_requests(struct fuse_ring *ring) > { > int qid; > @@ -213,6 +247,7 @@ void fuse_uring_abort_end_requests(struct fuse_ring *ring) > spin_unlock(&fch->bg_lock); > spin_unlock(&queue->lock); > fuse_uring_abort_end_queue_requests(queue); > + fuse_uring_abort_end_pending_send_requests(queue); > } > } > > @@ -225,7 +260,10 @@ static bool ent_list_request_expired(struct fuse_chan *fch, struct list_head *li > if (!ent) > return false; > > + /* NULL once an abort ended the request of a pending send */ > req = ent->fuse_req; > + if (!req) > + return false; > > return time_is_before_jiffies(req->create_time + > fch->timeout.req_timeout); > @@ -1745,9 +1783,19 @@ static void fuse_uring_send_in_task(struct io_tw_req tw_req, io_tw_token_t tw) > struct io_uring_cmd *cmd = io_uring_cmd_from_tw(tw_req); > struct fuse_ring_ent *ent = uring_cmd_to_ring_ent(cmd); > struct fuse_ring_queue *queue = ent->queue; > + struct fuse_req *req; > int err; > > - if (!tw.cancel) { > + spin_lock(&queue->lock); > + WARN_ON_ONCE(ent->state != FRRS_FUSE_REQ_PENDING_SEND); > + if (!tw.cancel && !queue->stopped) { > + /* > + * Claim the entry: from here on an abort leaves it and its > + * request to this path (fuse_uring_abort_end_pending_send_requests). > + */ > + ent->state = FRRS_FUSE_REQ; > + spin_unlock(&queue->lock); > + > err = fuse_uring_prepare_send(ent, ent->fuse_req, issue_flags); > if (err) { > if (!fuse_uring_get_next_fuse_req(ent, queue, > @@ -1756,21 +1804,28 @@ static void fuse_uring_send_in_task(struct io_tw_req tw_req, io_tw_token_t tw) > err = 0; > } > fuse_uring_send(ent, cmd, err, issue_flags); > - } else { > - err = -ECANCELED; > - > - spin_lock(&queue->lock); > - list_del_init(&ent->list); > - fuse_uring_recycle_buffer(ent); > - spin_unlock(&queue->lock); > - > - io_uring_cmd_done(cmd, err, issue_flags); > - > - fuse_uring_req_end(ent, ent->fuse_req, err, issue_flags); > - kfree(ent); > - if (atomic_dec_and_test(&queue->ring->queue_refs)) > - wake_up_all(&queue->ring->stop_waitq); > + return; > } > + > + /* > + * The task is dying (cancel) or the connection got aborted before the > + * send ran: release the entry. The abort may have ended the request > + * already (fuse_req is NULL then); end it here otherwise. > + */ > + err = tw.cancel ? -ECANCELED : -ENOTCONN; > + req = ent->fuse_req; > + list_del_init(&ent->list); > + fuse_uring_recycle_buffer(ent); > + spin_unlock(&queue->lock); > + > + io_uring_cmd_done(cmd, err, issue_flags); > + > + if (req) > + fuse_uring_req_end(ent, req, tw.cancel ? err : -ECONNABORTED, > + issue_flags); > + kfree(ent); > + if (atomic_dec_and_test(&queue->ring->queue_refs)) > + wake_up_all(&queue->ring->stop_waitq); > } > > static struct fuse_ring_queue *fuse_uring_task_to_queue(struct fuse_ring *ring) > @@ -1831,6 +1886,8 @@ void fuse_uring_queue_fuse_req(struct fuse_iqueue *fiq, struct fuse_req *req) > } > > fuse_uring_add_req_to_ring_ent(ent, req); > + /* sent by the server's task work; an abort before that ends the req */ > + ent->state = FRRS_FUSE_REQ_PENDING_SEND; > spin_unlock(&queue->lock); > fuse_uring_dispatch_ent(ent); > return; > @@ -1882,6 +1939,8 @@ bool fuse_uring_queue_bq_req(struct fuse_req *req) > list); > if (ent && req && !fuse_uring_prep_buffer(ent, req)) { > fuse_uring_add_req_to_ring_ent(ent, req); > + /* sent by the server's task work; an abort before that ends the req */ > + ent->state = FRRS_FUSE_REQ_PENDING_SEND; > spin_unlock(&queue->lock); > fuse_uring_dispatch_ent(ent); > } else { > diff --git a/fs/fuse/dev_uring_i.h b/fs/fuse/dev_uring_i.h > index 263d0f8b9714..95c182d5087b 100644 > --- a/fs/fuse/dev_uring_i.h > +++ b/fs/fuse/dev_uring_i.h > @@ -28,6 +28,12 @@ enum fuse_ring_req_state { > /* The ring entry got assigned a fuse req */ > FRRS_FUSE_REQ, > > + /* > + * The ring entry got assigned a fuse req and the send is pending as > + * task work in the server's task (fuse_uring_dispatch_ent) > + */ > + FRRS_FUSE_REQ_PENDING_SEND, > + > /* The ring entry is in or on the way to user space */ > FRRS_USERSPACE, > > > --- > base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244 > change-id: 20261201-fuse-uring-abort-pending-send-dc6919e986dc > > Best regards, > -- > Justin Oberdorf > >