linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH] mm/filemap: fix page end in filemap_get_read_batch
       [not found] <20230104032124.72483-1-coolqyj@163.com>
@ 2023-01-04 14:36 ` Matthew Wilcox
  2023-01-05 12:11   ` 回复: " Qian Yingjin
  0 siblings, 1 reply; 2+ messages in thread
From: Matthew Wilcox @ 2023-01-04 14:36 UTC (permalink / raw)
  To: coolqyj; +Cc: linux-fsdevel, linux-mm, stable, qian

On Wed, Jan 04, 2023 at 11:21:24AM +0800, coolqyj@163.com wrote:
> From: Qian Yingjin <qian@ddn.com>
> 
> 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.

Thanks for diagnosing & sending a patch.  However, I'd really prefer
to work in terms of 'max' instead of 'last_index' in that function.
Would this work for you?

+++ b/mm/filemap.c
@@ -2595,13 +2595,13 @@ static int filemap_get_pages(struct kiocb *iocb, struct iov_iter *iter,
        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))



^ permalink raw reply	[flat|nested] 2+ messages in thread

* 回复: [PATCH] mm/filemap: fix page end in filemap_get_read_batch
  2023-01-04 14:36 ` [PATCH] mm/filemap: fix page end in filemap_get_read_batch Matthew Wilcox
@ 2023-01-05 12:11   ` Qian Yingjin
  0 siblings, 0 replies; 2+ messages in thread
From: Qian Yingjin @ 2023-01-05 12:11 UTC (permalink / raw)
  To: Matthew Wilcox, coolqyj; +Cc: linux-fsdevel, linux-mm, stable

[-- Attachment #1: Type: text/plain, Size: 2416 bytes --]

Hi Matthew,

Thank you for your quick reply!
I am okey with your modification.

Regards,
Yingjin
________________________________
发件人: Matthew Wilcox <willy@infradead.org>
发送时间: 2023年1月4日 22:36
收件人: coolqyj@163.com <coolqyj@163.com>
抄送: linux-fsdevel@vger.kernel.org <linux-fsdevel@vger.kernel.org>; linux-mm@kvack.org <linux-mm@kvack.org>; stable@vger.kernel.org <stable@vger.kernel.org>; Qian Yingjin <qian@ddn.com>
主题: Re: [PATCH] mm/filemap: fix page end in filemap_get_read_batch

[????????? willy@infradead.org ????????? https://aka.ms/LearnAboutSenderIdentification?????????????]

On Wed, Jan 04, 2023 at 11:21:24AM +0800, coolqyj@163.com wrote:
> From: Qian Yingjin <qian@ddn.com>
>
> 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.

Thanks for diagnosing & sending a patch.  However, I'd really prefer
to work in terms of 'max' instead of 'last_index' in that function.
Would this work for you?

+++ b/mm/filemap.c
@@ -2595,13 +2595,13 @@ static int filemap_get_pages(struct kiocb *iocb, struct iov_iter *iter,
        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))


[-- Attachment #2: Type: text/html, Size: 5492 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-01-05 12:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20230104032124.72483-1-coolqyj@163.com>
2023-01-04 14:36 ` [PATCH] mm/filemap: fix page end in filemap_get_read_batch Matthew Wilcox
2023-01-05 12:11   ` 回复: " Qian Yingjin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox