From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=79.135.106.117 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795977178; b=RBW5e2fJJhD0aQrCiJyrbcmsdI+la7WU56SHFlyt9UZX+kXafXO06/1YBBRD/JPyyvHL eP++hr2Oxtn9YGmmswL/Id+a84Uon28urnyva9WOR6TLHM9kVe9D+5Go6Yvk//cudONVl F8YqK6bvLQR20SMHnhOu73pLz2hFquby/YI6AcdPRCuMPrZTnEBxtVG4EppzAoGReJRnY 9WB2RiyGwF2qjB9zrebBDd3fF2/TMDpMn5cklo8E9HVIiXVhvYjym19xAGrHmsrKAKaD+ ZNq1BuU12WJLWHAlV+4VrHat4LOSudqHq5qrJibOdcXmtYvn6g/vrNUEvLg+gBUcGFQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795977178; h=DMARC-Filter:DKIM-Signature:Date:To:From:Cc:Subject:Message-ID: Feedback-ID:X-Pm-Message-ID:MIME-Version:Content-Type: Content-Transfer-Encoding; bh=Pt9fUbhlxGiViQXVbRRyAUJQ/OoOw4xPrWdKgob+HPY=; b=QF2yXVKAwjq6Lq1UhuFb3zTIOvft4zKDPEF0ey16hsyEdjDfezlUhEvPikbp0E82w2Mt MOv5NoDkIFLhBaidLCTQ28PKaLwv4PbL45bVdeJcBS4/L4kuOgxZMbxF+HcLr++f3PMXb 7GIrSnSts4QmviEQfjyrhC6qYyiTYQ/2DIAnubJWCPRDz9Flr3gApuvyrp6qKCNAMMENO hXFjMI4FnQpDLy6UEIZDCfMoO5pG/n9lbGbdz25JOgund4Zop40fFovgLHXruL6/whjHa 2PswmG3/vLpYK4PlHHb7aXntu20LC0DiJ8MVmTrELuZF+AhYEznfUO1qNE/h1Z71zmw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=a7snv.com; spf=pass smtp.mailfrom=a7snv.com; dkim=pass header.d=a7snv.com header.i=@a7snv.com header.a=rsa-sha256 header.s=protonmail header.b=SZEDIQ2n; arc=none smtp.remote-ip=79.135.106.117 Received: from mail-106117.protonmail.ch (mail-106117.protonmail.ch [79.135.106.117]) (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 7DE34606A323 for ; Sun, 29 Nov 2026 18:32:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 7DE34606A323 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=a7snv.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=a7snv.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=a7snv.com header.i=@a7snv.com header.a=rsa-sha256 header.s=protonmail header.b=SZEDIQ2n DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=a7snv.com; s=protonmail; t=1795977175; x=1796236375; bh=Pt9fUbhlxGiViQXVbRRyAUJQ/OoOw4xPrWdKgob+HPY=; h=Date:To:From:Cc:Subject:Message-ID:Feedback-ID:From:To:Cc:Date: Subject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector; b=SZEDIQ2n/W0MydP0UPK4GwJbvyALXKkxXhuOVcb6NoLpETaaHRF6GpAt5WQldvNbk OGV2ueq0+39sEbZa1SbQnu+SVCtgBTVvKt40enW2Z6dj5C5baEOP2HZmKqga7ulAKI ogw5/sZMl4WAvtkAvvNGhaMKzqKeay53l9kg3Rf7xCvpDPVTO8YIC8bTf9qdCfwmVS VPJnNINXVWulhNX+wopaVlEuW6LslDXjRlxey3zYKn8W6VDzZIjnG+Ol6T3Jlvw4pr pOdjK0XRMVDBOUpfPxigtj6cc+aRjrXXAX5QFEUwC7Cd5MXYqmXJ2mGsC5v0djZFXP sd8fvAmW2Otpg== Date: Sun, 29 Nov 2026 18:32:49 +0000 To: Jens Axboe From: Yun Wang Cc: Pavel Begunkov , Hao Xu , Mengmeng Zhao , io-uring@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 0/3] io_uring/rw: bound the -EAGAIN/-EOPNOTSUPP reissue Message-ID: <20261129183214.3303492-1-arsenova@a7snv.com> Feedback-ID: 235448903:user:proton X-Pm-Message-ID: 673be16cc206dc5df02eb3e16a36f3e7f7cb00ca 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 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable A read or write that completes with -EAGAIN or -EOPNOTSUPP from a nonblocking attempt is reissued from io-wq. This series fixes two cases where that reissue has no bound, and stops the retry for dma-buf requests, where it can never succeed. I found this while testing the ext4 dma-buf series [1] for bugs. A direct read into a dma-buf registered buffer that covers [mapped | hole] of a sparse file fails with -EOPNOTSUPP at the hole every time. The completion runs outside io-wq, so io_rw_should_reissue() lets the request be reissued again and again, and the CQE is never posted. An 8 KiB read of 4 KiB of data followed by a hole took 348 device reads instead of 2 before it returned. A read of 2 MiB of data followed by a hole had not returned after 5 seconds and had read 15.6 GiB (15932 MiB) from the device by then. Only exiting the ring stops it. The loop is not specific to dma-buf or ext4. It happens whenever the completion of a blocking attempt keeps returning -EAGAIN or -EOPNOTSUPP and does not run in the io-wq worker that issued it. On v7.4-rc2 it can be reproduced on a raw NVMe namespace with fault injection (see patch 1), or with a FUSE server that uses FUSE_ASYNC_DIO and FOPEN_DIRECT_IO. The loop exists since v6.14. Before that, these completions were not reissued at all. Patch 1 makes io_rw_should_reissue() look at IOCB_NOWAIT in the kiocb instead of at the current thread. A request is still reissued once after a nonblocking attempt, so the nvme multipath case from commit b08e02045002 and the LVM snapshot case from commit 927069c4ac2c keep working. Patch 2 clears REQ_F_FORCE_ASYNC on reissue. Without it, an IOSQE_ASYNC request on a pollable file (FUSE) is issued nonblocking again from io-wq, and patch 1 alone does not stop the loop. Patch 3 stops converting -EOPNOTSUPP to -EAGAIN, and stops reissuing, for REQ_F_DMABUF requests. dma-buf I/O has no buffered fallback, so the blocking retry fails the same way. This costs a second device read, and with RWF_NOWAIT the application is told to retry something that cannot succeed. Unlike patches 1 and 2, this is only a cost and not a loop, so it is not marked for stable. Patches 1 and 2 are needed together to fix the loop for every case. Patch 3 is independent of them. Testing, all on v7.4-rc2 unless noted: - NVMe fault injection in QEMU, raw device and ext4: without the series a single 4 KiB read uses up every injected failure and then succeeds. With it, the read fails with -EOPNOTSUPP after two attempts, or one with IOSQE_ASYNC. The patched kernel gives the same result on a KIOXIA BG5. - FUSE reproducer, default and IOSQE_ASYNC, with -EAGAIN and -EOPNOTSUPP: without the series the request is reissued until the reproducer's server gives up after 20 failures (21 READs). With it, the server sees 2 READs. Also run with KASAN and lockdep: no reports. - dma-buf on a raw NVMe namespace (patch 3): see the patch. A buffered write from user memory to the same device is still retried and succeeds. - With the ext4 dma-buf series: the sparse-file read above returns after two device reads with patches 1 and 2, and after one with patch 3. The series is based on v7.4-rc2 and also applies to io_uring-7.4. Patches 2 and 3 conflict with the io_req_{set,clear}_flags() conversion in for-7.5/io_uring. I can rebase them onto it if you prefer. On tool use: Gemini (gemini-4-neon-high) found the IOSQE_ASYNC path that my first version of patch 1 missed, which patch 2 fixes. The patches, the changelogs and this cover letter were written with AI assistance (Claude, claude-opus-5-5). Claude was also used to build the tests that do not depend on the ext4 series (NVMe fault injection, FUSE, dma-buf on a raw NVMe namespace), to check that the problem is not caused by that series. I reviewed the patches and the test results. [1] https://lore.kernel.org/all/20261113070621.273953-1-mengmeng.zhao@linux= .dev/ Yun Wang (3): io_uring/rw: don't reissue requests that were issued blocking io_uring: clear REQ_F_FORCE_ASYNC when reissuing a request io_uring/rw: don't retry dma-buf requests that fail with -EOPNOTSUPP io_uring/io_uring.c | 2 +- io_uring/rw.c | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) base-commit: 7475ea8b58616b33c04afb976cf0fbaad9dd63fb --=20 2.56.1