Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

netfs: Fix read abandonment during retry

Under certain circumstances, all the remaining subrequests from a read
request will get abandoned during retry. The abandonment process expects
the 'subreq' variable to be set to the place to start abandonment from, but
it doesn't always have a useful value (it will be uninitialised on the
first pass through the loop and it may point to a deleted subrequest on
later passes).

Fix the first jump to "abandon:" to set subreq to the start of the first
subrequest expected to need retry (which, in this abandonment case, turned
out unexpectedly to no longer have NEED_RETRY set).

Also clear the subreq pointer after discarding superfluous retryable
subrequests to cause an oops if we do try to access it.

Fixes: ee4cdf7ba857 ("netfs: Speed up buffered reading")
Signed-off-by: David Howells <dhowells@redhat.com>
Link: https://patch.msgid.link/3775287.1773848338@warthog.procyon.org.uk
Reviewed-by: Paulo Alcantara (Red Hat) <pc@manguebit.org>
cc: Paulo Alcantara <pc@manguebit.org>
cc: netfs@lists.linux.dev
cc: linux-fsdevel@vger.kernel.org
Signed-off-by: Christian Brauner <brauner@kernel.org>

authored by

David Howells and committed by
Christian Brauner
7e575234 8fb6857f

+4 -1
+4 -1
fs/netfs/read_retry.c
··· 93 93 from->start, from->transferred, from->len); 94 94 95 95 if (test_bit(NETFS_SREQ_FAILED, &from->flags) || 96 - !test_bit(NETFS_SREQ_NEED_RETRY, &from->flags)) 96 + !test_bit(NETFS_SREQ_NEED_RETRY, &from->flags)) { 97 + subreq = from; 97 98 goto abandon; 99 + } 98 100 99 101 list_for_each_continue(next, &stream->subrequests) { 100 102 subreq = list_entry(next, struct netfs_io_subrequest, rreq_link); ··· 180 178 if (subreq == to) 181 179 break; 182 180 } 181 + subreq = NULL; 183 182 continue; 184 183 } 185 184