FAILED: patch "[PATCH] mm/filemap: fix page end in filemap_get_read_batch" failed to apply to 5.15-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 5.15-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
Possible dependencies:
5956592ce337 ("mm/filemap: fix page end in filemap_get_read_batch") 25d6a23e8d28 ("filemap: Convert filemap_get_read_batch() to use a folio_batch") d996fc7f615f ("filemap: Convert filemap_read() to use a folio") 65bca53b5f63 ("filemap: Convert filemap_get_pages to use folios") a5d4ad098528 ("filemap: Convert filemap_create_page to folio") 9d427b4eb456 ("filemap: Convert filemap_read_page to take a folio") bdb729329769 ("filemap: Convert filemap_get_read_batch to use folios") 512b7931ad05 ("Merge branch 'akpm' (patches from Andrew)")
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 5956592ce337330cdff0399a6f8b6a5aea397a8e Mon Sep 17 00:00:00 2001
From: Qian Yingjin <[email protected]>
Date: Wed, 8 Feb 2023 10:24:00 +0800
Subject: [PATCH] mm/filemap: fix page end in filemap_get_read_batch
I was running traces of the read code against an RAID storage system to understand why read requests were being misaligned against the underlying RAID strips. I found that the page end offset calculation in filemap_get_read_batch() was off by one.
When a read is submitted with end offset 1048575, then it calculates the end page for read of 256 when it should be 255. "last_index" is the index of the page beyond the end of the read and it should be skipped when get a batch of pages for read in @filemap_get_read_batch().
The below simple patch fixes the problem. This code was introduced in kernel 5.12.
mm/filemap.c +3 -2
@@ -2588,18 +2588,19 @@ static int filemap_get_pages(struct kiocb *iocb, struct iov_iter *iter,struct folio *folio;int err =0 ; +/* "last_index" is the index of the page beyond the end of the read */ last_index =DIV_ROUND_UP (iocb->ki_pos + iter->count,PAGE_SIZE ); retry:if (fatal_signal_pending (current))return -EINTR ; -filemap_get_read_batch (mapping, index, last_index, fbatch); +filemap_get_read_batch (mapping, index, last_index -1 , fbatch);if (!folio_batch_count (fbatch)) {if (iocb->ki_flags &IOCB_NOIO )return -EAGAIN ;page_cache_sync_readahead (mapping, ra, filp, index, last_index - index); -filemap_get_read_batch (mapping, index, last_index, fbatch); +filemap_get_read_batch (mapping, index, last_index -1 , fbatch); }if (!folio_batch_count (fbatch)) {if (iocb->ki_flags & (IOCB_NOWAIT |IOCB_WAITQ ))
Matthew Wilcox
maintainerQuoted 5 lines · On Sat, Feb 18, 2023 at 09:02:42AM +0100, [email protected] wrote:
The patch below does not apply to the 5.15-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
Here's a patch for 5.15-stable, generated against v5.15.94
mm/filemap.c +3 -2
@@ -2538,18 +2538,19 @@ static int filemap_get_pages(struct kiocb *iocb, struct iov_iter *iter,struct page *page;int err =0 ; +/* "last_index" is the index of the page beyond the end of the read */ last_index =DIV_ROUND_UP (iocb->ki_pos + iter->count,PAGE_SIZE ); retry:if (fatal_signal_pending (current))return -EINTR ; -filemap_get_read_batch (mapping, index, last_index, pvec); +filemap_get_read_batch (mapping, index, last_index -1 , pvec);if (!pagevec_count (pvec)) {if (iocb->ki_flags &IOCB_NOIO )return -EAGAIN ;page_cache_sync_readahead (mapping, ra, filp, index, last_index - index); -filemap_get_read_batch (mapping, index, last_index, pvec); +filemap_get_read_batch (mapping, index, last_index -1 , pvec); }if (!pagevec_count (pvec)) {if (iocb->ki_flags & (IOCB_NOWAIT |IOCB_WAITQ ))
Quoted 69 lines
Possible dependencies:
5956592ce337("mm/filemap: fix page end infilemap_get_read_batch")25d6a23e8d28("filemap: Convertfilemap_get_read_batch()to use afolio_batch")d996fc7f615f("filemap: Convertfilemap_read()to use a folio")65bca53b5f63("filemap: Convertfilemap_get_pagesto use folios")a5d4ad098528("filemap: Convertfilemap_create_pageto folio")9d427b4eb456("filemap: Convertfilemap_read_pageto take a folio")bdb729329769("filemap: Convertfilemap_get_read_batchto use folios")512b7931ad05("Merge branch 'akpm' (patches from Andrew)")thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
Quoted 1 line
From
5956592ce337330cdff0399a6f8b6a5aea397a8eMon Sep 17 00:00:00 2001From: Qian Yingjin <[email protected]>
Date: Wed, 8 Feb 2023 10:24:00 +0800
Subject: [PATCH] mm/filemap: fix page end infilemap_get_read_batchI was running traces of the read code against an RAID storage system to understand why read requests were being misaligned against the underlying RAID strips. I found that the page end offset calculation in
filemap_get_read_batch()was off by one.When a read is submitted with end offset 1048575, then it calculates the end page for read of 256 when it should be 255. "
last_index" is the index of the page beyond the end of the read and it should be skipped when get a batch of pages for read in @filemap_get_read_batch().The below simple patch fixes the problem. This code was introduced in kernel 5.12.
Fixes cbd59c48ae2b ("mm/filemap: use head pages in generic_file_buffered_read")Signed-off-by Qian Yingjin <[email protected]>Reviewed-by Matthew Wilcox (Oracle) <[email protected]>Cc <[email protected]>Signed-off-by Andrew Morton <[email protected]>mm/filemap.c +3
-2@@ -2588,18 +2588,19 @@ static int filemap_get_pages(struct kiocb *iocb, struct iov_iter *iter,struct folio *folio;int err =0 ; +/* "last_index" is the index of the page beyond the end of the read */ last_index =DIV_ROUND_UP (iocb->ki_pos + iter->count,PAGE_SIZE ); retry:if (fatal_signal_pending (current))return -EINTR ; -filemap_get_read_batch (mapping, index, last_index, fbatch); +filemap_get_read_batch (mapping, index, last_index -1 , fbatch);if (!folio_batch_count (fbatch)) {if (iocb->ki_flags &IOCB_NOIO )return -EAGAIN ;page_cache_sync_readahead (mapping, ra, filp, index, last_index - index); -filemap_get_read_batch (mapping, index, last_index, fbatch); +filemap_get_read_batch (mapping, index, last_index -1 , fbatch); }if (!folio_batch_count (fbatch)) {if (iocb->ki_flags & (IOCB_NOWAIT |IOCB_WAITQ ))
Greg KH
maintainerQuoted 8 lines · Matthew Wilcox
Quoted 5 lines · On Sat, Feb 18, 2023 at 09:02:42AM +0100, [email protected] wrote:
The patch below does not apply to the 5.15-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.Here's a patch for 5.15-stable, generated against v5.15.94
Now queued up, thanks.
greg k-h