From: Paulo Alcantara <pc@manguebit.org>
To: linux-cifs@vger.kernel.org, netfs@lists.linux.dev,
David Howells <dhowells@redhat.com>
Cc: Namjae Jeon <linkinjeon@kernel.org>,
Ronnie Sahlberg <ronniesahlberg@gmail.com>,
Shyam Prasad N <sprasad@microsoft.com>,
Tom Talpey <tom@talpey.com>, Bharath SM <bharathsm@microsoft.com>,
Christian Brauner <brauner@kernel.org>,
stable@vger.kernel.org
Subject: [PATCH v7 03/19] netfs: keep the prepare_read errno when abandoning read retries
Date: Fri, 6 Nov 2026 20:18:11 -0300 [thread overview]
Message-ID: <20261106231827.2604956-4-pc@manguebit.org> (raw)
In-Reply-To: <20261106231827.2604956-1-pc@manguebit.org>
When ->prepare_read() fails while retrying a read,
netfs_retry_read_subrequests() marks the subrequest failed and abandons
the rest, which overwrites the error of every failed subrequest with
-ENOMEM. The reader then gets -ENOMEM for e.g. a handle that couldn't be
reopened (-EHOSTDOWN, -ENOENT), a credit wait interrupted by a signal
(-ERESTARTSYS) or umount -f (-EIO). The first pass doesn't have this
problem, as netfs_cancel_read() keeps the errno.
Record the errno of ->prepare_read() in the subrequest and keep the error
of subrequests that already failed, using -ENOMEM only for those
abandoned while still waiting for a retry.
Fixes: ee4cdf7ba857 ("netfs: Speed up buffered reading")
Signed-off-by: Paulo Alcantara <pc@manguebit.org>
Cc: stable@vger.kernel.org
---
fs/netfs/read_retry.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/fs/netfs/read_retry.c b/fs/netfs/read_retry.c
index 5bd8dee5a834..8a722995fa9d 100644
--- a/fs/netfs/read_retry.c
+++ b/fs/netfs/read_retry.c
@@ -28,6 +28,7 @@ static void netfs_retry_read_subrequests(struct netfs_io_request *rreq)
struct netfs_io_subrequest *subreq;
struct netfs_io_stream *stream = &rreq->io_streams[0];
struct list_head *next;
+ int ret;
_enter("R=%x", rreq->debug_id);
@@ -140,8 +141,11 @@ static void netfs_retry_read_subrequests(struct netfs_io_request *rreq)
/* Renegotiate max_len (rsize) */
stream->sreq_max_len = subreq->len;
- if (rreq->netfs_ops->prepare_read &&
- rreq->netfs_ops->prepare_read(subreq) < 0) {
+ ret = 0;
+ if (rreq->netfs_ops->prepare_read)
+ ret = rreq->netfs_ops->prepare_read(subreq);
+ if (ret < 0) {
+ subreq->error = ret;
trace_netfs_sreq(subreq, netfs_sreq_trace_reprep_failed);
__set_bit(NETFS_SREQ_FAILED, &subreq->flags);
goto abandon;
@@ -221,7 +225,9 @@ static void netfs_retry_read_subrequests(struct netfs_io_request *rreq)
part = netfs_limit_iter(&source, 0, part, stream->sreq_max_segs);
netfs_stat(&netfs_n_rh_download);
- if (rreq->netfs_ops->prepare_read(subreq) < 0) {
+ ret = rreq->netfs_ops->prepare_read(subreq);
+ if (ret < 0) {
+ subreq->error = ret;
trace_netfs_sreq(subreq, netfs_sreq_trace_reprep_failed);
__set_bit(NETFS_SREQ_FAILED, &subreq->flags);
goto abandon;
@@ -257,7 +263,9 @@ static void netfs_retry_read_subrequests(struct netfs_io_request *rreq)
if (!test_bit(NETFS_SREQ_FAILED, &subreq->flags) &&
!test_bit(NETFS_SREQ_NEED_RETRY, &subreq->flags))
continue;
- subreq->error = -ENOMEM;
+ if (!subreq->error ||
+ !test_bit(NETFS_SREQ_FAILED, &subreq->flags))
+ subreq->error = -ENOMEM;
__set_bit(NETFS_SREQ_FAILED, &subreq->flags);
__clear_bit(NETFS_SREQ_NEED_RETRY, &subreq->flags);
}
--
2.56.0
next prev parent reply other threads:[~2026-11-06 23:18 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-06 23:18 [PATCH v7 00/19] smb: client: fix data loss in writeback Paulo Alcantara
2026-11-06 23:18 ` [PATCH v7 01/19] smb: client: don't write back through O_DIRECT handles Paulo Alcantara
2026-11-06 23:18 ` [PATCH v7 02/19] netfs: preserve prepare_write errno on reissue Paulo Alcantara
2026-11-06 23:18 ` Paulo Alcantara [this message]
2026-11-06 23:18 ` [PATCH v7 04/19] netfs: don't hang a read whose retry is abandoned Paulo Alcantara
2026-11-06 23:18 ` [PATCH v7 05/19] smb: client: let umount -f abort retried reads and writes Paulo Alcantara
2026-11-06 23:18 ` [PATCH v7 06/19] smb: client: don't give up writeback on the first replayable error Paulo Alcantara
2026-11-06 23:18 ` [PATCH v7 07/19] smb: client: don't retry failed writes forever regardless of mount options Paulo Alcantara
2026-11-06 23:18 ` [PATCH v7 08/19] smb: client: don't spend read retries on reads cut short by a reconnect Paulo Alcantara
2026-11-06 23:18 ` [PATCH v7 09/19] smb: client: don't block dying tasks waiting for writeback on close Paulo Alcantara
2026-11-06 23:18 ` [PATCH v7 10/19] smb: client: issue writes from a worker if the task is dying Paulo Alcantara
2026-11-06 23:18 ` [PATCH v7 11/19] smb: client: don't fail writeback preparation " Paulo Alcantara
2026-11-06 23:18 ` [PATCH v7 12/19] smb: client: retry writeback on interrupts and allocation failures Paulo Alcantara
2026-11-06 23:18 ` [PATCH v7 13/19] smb: client: don't block dying tasks waiting for writeback on fsync Paulo Alcantara
2026-11-06 23:18 ` [PATCH v7 14/19] smb: client: retry writes that couldn't be issued due to a reconnect Paulo Alcantara
2026-11-06 23:18 ` [PATCH v7 15/19] smb: client: retry writeback after losing the connection, share or handle Paulo Alcantara
2026-11-06 23:18 ` [PATCH v7 16/19] smb: client: let umount -f stop waiting for reconnects on hard mounts Paulo Alcantara
2026-11-06 23:18 ` [PATCH v7 17/19] smb: client: don't replay handle reopens inside SMB2_open() Paulo Alcantara
2026-11-06 23:18 ` [PATCH v7 18/19] smb: client: fail writeback sends and reopens fast when the server is gone Paulo Alcantara
2026-11-06 23:18 ` [PATCH v7 19/19] smb: client: stop reconnecting and replaying during a forced unmount Paulo Alcantara
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261106231827.2604956-4-pc@manguebit.org \
--to=pc@manguebit.org \
--cc=bharathsm@microsoft.com \
--cc=brauner@kernel.org \
--cc=dhowells@redhat.com \
--cc=linkinjeon@kernel.org \
--cc=linux-cifs@vger.kernel.org \
--cc=netfs@lists.linux.dev \
--cc=ronniesahlberg@gmail.com \
--cc=sprasad@microsoft.com \
--cc=stable@vger.kernel.org \
--cc=tom@talpey.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox