@@ -506,6 +506,7 @@ void page_cache_ra_order(struct readahead_control *ractl,
{
struct address_space *mapping = ractl->mapping;
pgoff_t index = readahead_index(ractl);
+ unsigned int min_order = mapping_min_folio_order(mapping);
pgoff_t limit = (i_size_read(mapping->host) - 1) >> PAGE_SHIFT;
pgoff_t mark = index + ra->size - ra->async_size;
int err = 0;
@@ -535,10 +536,16 @@ void page_cache_ra_order(struct readahead_control *ractl,
order = 0;
}
/* Don't allocate pages past EOF */
- while (index + (1UL << order) - 1 > limit) {
+ while (order > min_order && index + (1UL << order) - 1 > limit) {
if (--order == 1)
order = 0;
}
+
+ if (order < min_order)
+ order = min_order;
+
+ VM_BUG_ON(index & ((1UL << order) - 1));
+
err = ra_alloc_folio(ractl, index, mark, order, gfp);
if (err)
break;