]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
mm/readahead: add kerneldoc for read_pages
authorFrederick Mayle <fmayle@google.com>
Tue, 12 May 2026 20:31:35 +0000 (13:31 -0700)
committerAndrew Morton <akpm@linux-foundation.org>
Tue, 2 Jun 2026 22:22:14 +0000 (15:22 -0700)
Patch series "mm: document read_pages and simplify usage".

Add a kerneldoc for read_pages() to formalize an invariant and then use
it to simplify the callers in page_cache_ra_unbounded().

This patch (of 2):

Formalize one of the invariants provided by the current implementation so
that callers can depend on it, as discussed in [1].

Link: https://lore.kernel.org/all/20260501061146.6e61392d125cf1847d7cc181@linux-foundation.org/
Link: https://lore.kernel.org/20260512203154.754075-2-fmayle@google.com
Signed-off-by: Frederick Mayle <fmayle@google.com>
Cc: Jan Kara <jack@suse.cz>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/readahead.c

index 8c12b63ccd4a2e2f61b351ffb71ddf564d7c8f41..23bec54973084ee3677fc3361fe4fb496c2836a0 100644 (file)
@@ -146,6 +146,17 @@ file_ra_state_init(struct file_ra_state *ra, struct address_space *mapping)
 }
 EXPORT_SYMBOL_GPL(file_ra_state_init);
 
+/**
+ * read_pages() - Start IO for a contiguous range of allocated folios in the
+ *                page cache.
+ * @rac: Readahead control.
+ *
+ * When read_pages() returns, it is guaranteed that all of the folios will have
+ * been processed or removed so that ``readahead_count(rac) == 0``. However,
+ * that does not imply that ``readahead_index(rac)`` will be updated to point
+ * to the end of the originally requested range because, for example, the
+ * filesystem may expand the range upwards.
+ */
 static void read_pages(struct readahead_control *rac)
 {
        const struct address_space_operations *aops = rac->mapping->a_ops;