From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=109.224.244.118 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795977202; b=B2L6lqDEYGOfolQfcdhu2cgcFYPMMc5icR7CYgwtI4oiBmMN5z2+fCOAJSxxLxZyxZah To12cb43P8AEOb43I0RJsC1/D4bX15S6Myet1ET7gb0DHj0rZO7TcGzfzhTwBbHXxFeS1 Js1mNOIxuQzHUgazOsPszgf8YkmUsfvSxA7OU+XH5A5SCn7NpHSRh2qzIA/djVWx4Z/iZ f2Jh5eKImsJCuuAcGv5ps6mBUqqg9okev66oTKyZJcFZjgxMW5GUdShhzdbLLmCiwt2Mf LflZWU7IyrR69UpJ4Eff+ogYFBRhkXiS8w9UFoFlaTBQrKB0SsoysDd3eQ7vqWDpeeg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795977202; h=DMARC-Filter:DKIM-Signature:Date:To:From:Cc:Subject:Message-ID: In-Reply-To:References:Feedback-ID:X-Pm-Message-ID:MIME-Version: Content-Type:Content-Transfer-Encoding; bh=a5t20UfVOIgMgAH8ZeWf5IVTnjdRsIDHZ2irY81aIGE=; b=k+qJ0+cklA9Mvgty0OBHmqXMB6dLBN32P5CBcYsAFpH4uxrjyxzQJnPH8tGe5cefSWRR yh2nXaQdb4YkvAkwAM5iDVkImsE260iWs5Wa2oqmhqt0CrxDp3m6F9BFBb78vw1cyxg+m MGf3R9oS7QlnB6PTKWEPFg72l214vv0ah1JnIlmFdzFYUUgxUPoyzon68Of4N11SETlbG TRCfURtX83AXOlJZpQcGAF8K2eW9ybvAlN2bOdQMKoMdTjWt0lzEF2qfdU8nkuwRMM3OU cBcDd5HlVljofFZpKgzxR1z3Eo6KQgG8VJBqXkPm65j0qLKRAoNNE6cHdU/3sL0Cxmg== 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=BOegisBz; arc=none smtp.remote-ip=109.224.244.118 Received: from mail-244118.protonmail.ch (mail-244118.protonmail.ch [109.224.244.118]) (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 9A6F1606A323 for ; Sun, 29 Nov 2026 18:33:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 9A6F1606A323 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=BOegisBz DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=a7snv.com; s=protonmail; t=1795977199; x=1796236399; bh=a5t20UfVOIgMgAH8ZeWf5IVTnjdRsIDHZ2irY81aIGE=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=BOegisBzHcjUDs4jEbHqyIP5o+FOHe7BZPsYWfy/MIleWHaX0BoeWXk5vpSi/me4K WI5T9sUTpmm7X1srlfp4fFLsmjS5QG2zG3zKx/WVE3Khnr4UBbLiIlr1hx7pqLsKYE NdRiEG10UZURZFGMbvvSU8Bm6mbjXgy5huANaDgj3ZkWBuHGzrvn4kpIXCcSsnNmHE 7FDX5tNyLQg/gFh9CSsEVZh2JSK07qJ4uwgQ0VhOk2L1FjR39ghZ04D4AnyxBt2rHd cSPjYsbfO5u4eQZPcuxnaY4F88HjGY/Dio4ddwBNxVTrk2NsI6x9qx5a9zDhhuBIx0 9X3vD7Iq0EUsQ== Date: Sun, 29 Nov 2026 18:33:14 +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 1/3] io_uring/rw: don't reissue requests that were issued blocking Message-ID: <20261129183214.3303492-2-arsenova@a7snv.com> In-Reply-To: <20261129183214.3303492-1-arsenova@a7snv.com> References: <20261129183214.3303492-1-arsenova@a7snv.com> Feedback-ID: 235448903:user:proton X-Pm-Message-ID: fdf4dae7fbabb899efae62bee4c5b28a66c5f483 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 io_rw_should_reissue() decides whether a read or write that completed with -EAGAIN or -EOPNOTSUPP is retried from io-wq. It uses io_wq_current_is_worker() to tell whether the request has already been issued from blocking context. That only works when ->ki_complete() runs in the io-wq worker that issued the request. When the completion runs anywhere else, for example in the block layer completion path, in the iomap s_dio_done_wq worker, or in a FUSE server thread answering an async direct I/O request, the check is false and the request is reissued even though the previous attempt was already a blocking one. If the lower layer keeps returning the same error, the request is reissued forever and its CQE is never posted. Before v6.14 such completions were not reissued: io_rw_should_reissue() returned false outside the submitting thread group and outside task context, and a reissue flagged from an async completion was not acted upon. The two commits in the Fixes tags made these completions reissue from io-wq, which is what the nvme multipath retry from a kworker needs. The kiocb already records how the request was issued: __io_read() and io_write() set IOCB_NOWAIT for a nonblocking attempt and clear it for a blocking one. Use that instead. A request that was issued nonblocking can still be reissued once from io-wq, so the nvme multipath case keeps working, and so does the LVM snapshot case, where REQ_NOWAIT bios fail with -EOPNOTSUPP while the snapshot is being created. That retry was restored by commit 927069c4ac2c ("Revert "io_uring/rw: drop -EOPNOTSUPP check in __io_c= omplete_rw_common()""). IOPOLL requests keep their current behaviour. This can be reproduced with NVMe fault injection. NVME_SC_INVALID_OPCODE with DNR set is mapped to BLK_STS_NOTSUPP: cd /sys/kernel/debug/nvme0n1/fault_inject echo 0x02 > opcode; echo 0x01 > status; echo 1 > dont_retry echo 20 > times; echo 100 > probability fio --name=3Dr --ioengine=3Dio_uring --direct=3D1 --rw=3Dread --bs=3D4k \ --size=3D4k --filename=3D/dev/nvme0n1 Without this patch the single 4 KiB read uses up all 20 injected failures, then completes successfully, and fio reports no error; the loop is only bounded by the injection count. With this patch the read fails with -EOPNOTSUPP after two attempts, one nonblocking and one blocking. The same holds for an ext4 file on that device. Both kernels were tested in QEMU. The patched kernel was also tested on a KIOXIA BG5, with the same result. A FUSE server with FUSE_ASYNC_DIO and FOPEN_DIRECT_IO that answers READ with -EAGAIN or -EOPNOTSUPP shows the same loop for IORING_OP_READ. Fixes: d803d123948f ("io_uring/rw: handle -EAGAIN retry at IO completion ti= me") Fixes: b08e02045002 ("io_uring/rw: don't gate retry on completion context") Cc: stable@vger.kernel.org Signed-off-by: Yun Wang --- io_uring/rw.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/io_uring/rw.c b/io_uring/rw.c index 3a8559ff4dc6..7917d1536c47 100644 --- a/io_uring/rw.c +++ b/io_uring/rw.c @@ -490,8 +490,10 @@ static bool io_rw_should_reissue(struct io_kiocb *req) =20 =09if (!S_ISBLK(mode) && !S_ISREG(mode)) =09=09return false; -=09if ((req->flags & REQ_F_NOWAIT) || (io_wq_current_is_worker() && -=09 !(req->flags & REQ_F_IOPOLL))) +=09if ((req->flags & REQ_F_NOWAIT) || +=09 (!(req->flags & REQ_F_IOPOLL) && +=09 (io_wq_current_is_worker() || +=09 !(rw->kiocb.ki_flags & IOCB_NOWAIT)))) =09=09return false; =09/* =09 * If ref is dying, we might be running poll reap from the exit work. --=20 2.56.1