]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
5.15-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 18 Feb 2023 16:08:32 +0000 (17:08 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 18 Feb 2023 16:08:32 +0000 (17:08 +0100)
added patches:
mm-filemap-fix-page-end-in-filemap_get_read_batch.patch

queue-5.15/mm-filemap-fix-page-end-in-filemap_get_read_batch.patch [new file with mode: 0644]
queue-5.15/series

diff --git a/queue-5.15/mm-filemap-fix-page-end-in-filemap_get_read_batch.patch b/queue-5.15/mm-filemap-fix-page-end-in-filemap_get_read_batch.patch
new file mode 100644 (file)
index 0000000..2de6bd5
--- /dev/null
@@ -0,0 +1,57 @@
+From 5956592ce337330cdff0399a6f8b6a5aea397a8e Mon Sep 17 00:00:00 2001
+From: Qian Yingjin <qian@ddn.com>
+Date: Wed, 8 Feb 2023 10:24:00 +0800
+Subject: mm/filemap: fix page end in filemap_get_read_batch
+
+From: Qian Yingjin <qian@ddn.com>
+
+commit 5956592ce337330cdff0399a6f8b6a5aea397a8e upstream.
+
+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.
+
+Link: https://lkml.kernel.org/r/20230208022400.28962-1-coolqyj@163.com
+Fixes: cbd59c48ae2b ("mm/filemap: use head pages in generic_file_buffered_read")
+Signed-off-by: Qian Yingjin <qian@ddn.com>
+Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
+Cc: <stable@vger.kernel.org>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ mm/filemap.c |    5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+--- a/mm/filemap.c
++++ b/mm/filemap.c
+@@ -2538,18 +2538,19 @@ static int filemap_get_pages(struct kioc
+       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))
index b00b63edcb053362899deae395b1c2d933f4dd64..0f1e5290c8d81f299b8121a2d103ca39d715af06 100644 (file)
@@ -69,3 +69,4 @@ ixgbe-add-double-of-vlan-header-when-computing-the-max-mtu.patch
 ipv6-fix-datagram-socket-connection-with-dscp.patch
 ipv6-fix-tcp-socket-connection-with-dscp.patch
 nilfs2-fix-underflow-in-second-superblock-position-calculations.patch
+mm-filemap-fix-page-end-in-filemap_get_read_batch.patch