]> git.baikalelectronics.ru Git - kernel.git/commit
mm/filemap: fix page end in filemap_get_read_batch
authorQian Yingjin <qian@ddn.com>
Wed, 8 Feb 2023 02:24:00 +0000 (10:24 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 Feb 2023 11:59:49 +0000 (12:59 +0100)
commitb8013fcd3edd7192a20eacdc7e57944c5bdd34f8
tree78d1e24260dc057bff83efe0c45370a5c4d52d97
parent47f1e83e06dc39dfff9b2893c6a1c55e2b06e623
mm/filemap: fix page end in filemap_get_read_batch

commit 90e2150b8cccbd39025a2b8274858a32ef4d3bd0 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: 84937931f5f1 ("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