Skip to content

Commit a0f15c2

Browse files
committed
Merge: Backport revert of commit "readahead: properly shorten readahead when falling back to do_page_cache_ra()"
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-10/-/merge_requests/166 Upstream found out that this commit can cause an integer underflow in the fs readahead code, which causes it to read a huge amount of data, from the storage device, stalling IO on the host, which in turn can in some extreme cases (e.g using NFS or a hard disk) even cause I/O timeouts. In our case this caused VMs after v2v conversion to fail to finish first boot script and bluescreen or otherwise hang during its execution because they started to timeout on I/O. JIRA: https://issues.redhat.com/browse/RHEL-55724 JIRA: https://issues.redhat.com/browse/RHEL-56929 Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com> Approved-by: Vitaly Kuznetsov <vkuznets@redhat.com> Approved-by: Herton R. Krzesinski <herton@redhat.com> Approved-by: Rafael Aquini <raquini@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: Jan Stancek <jstancek@redhat.com>
2 parents 8fd2866 + 04be1a8 commit a0f15c2

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

mm/readahead.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -453,8 +453,7 @@ void page_cache_ra_order(struct readahead_control *ractl,
453453
struct file_ra_state *ra, unsigned int new_order)
454454
{
455455
struct address_space *mapping = ractl->mapping;
456-
pgoff_t start = readahead_index(ractl);
457-
pgoff_t index = start;
456+
pgoff_t index = readahead_index(ractl);
458457
unsigned int min_order = mapping_min_folio_order(mapping);
459458
pgoff_t limit = (i_size_read(mapping->host) - 1) >> PAGE_SHIFT;
460459
pgoff_t mark = index + ra->size - ra->async_size;
@@ -517,7 +516,7 @@ void page_cache_ra_order(struct readahead_control *ractl,
517516
if (!err)
518517
return;
519518
fallback:
520-
do_page_cache_ra(ractl, ra->size - (index - start), ra->async_size);
519+
do_page_cache_ra(ractl, ra->size, ra->async_size);
521520
}
522521

523522
static unsigned long ractl_max_pages(struct readahead_control *ractl,

0 commit comments

Comments
 (0)