]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
netfs: release readahead folios on iterator preparation failure
authorYichong Chen <chenyichong@uniontech.com>
Mon, 27 Jul 2026 13:07:14 +0000 (14:07 +0100)
committerChristian Brauner <brauner@kernel.org>
Tue, 28 Jul 2026 13:42:31 +0000 (15:42 +0200)
netfs_prepare_read_iterator() batches readahead folios in put_batch so that
the folio references can be dropped after the I/O iterator has been
prepared.

If rolling_buffer_load_from_ra() fails after earlier folios have been
batched, the function returns immediately and leaves those references held.
Release the batch before returning the error.

Fixes: 06fa229ceb36 ("netfs: Abstract out a rolling folio buffer implementation")
Signed-off-by: Yichong Chen <chenyichong@uniontech.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Link: https://patch.msgid.link/20260727130716.1099906-4-dhowells@redhat.com
cc: Paulo Alcantara <pc@manguebit.org>
cc: netfs@lists.linux.dev
cc: linux-fsdevel@vger.kernel.org
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
fs/netfs/buffered_read.c

index 24a8a5418e31190355d56360ed5129835b12484d..3d86414ee40f5c6907f7926460216e0e59355ce3 100644 (file)
@@ -102,8 +102,10 @@ static ssize_t netfs_prepare_read_iterator(struct netfs_io_subrequest *subreq,
 
                        added = rolling_buffer_load_from_ra(&rreq->buffer, ractl,
                                                            &put_batch);
-                       if (added < 0)
+                       if (added < 0) {
+                               folio_batch_release(&put_batch);
                                return added;
+                       }
                        rreq->submitted += added;
                }
                folio_batch_release(&put_batch);