X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=mm%2Ffilemap.c;h=322aea78058a07134a668306405016b5d987ea1f;hb=refs%2Fheads%2Fsandbox%2Flstelmach%2Fvirgl;hp=08341616ae7a1edf70b55c8bbc35a53a35ac57ab;hpb=95b8b5953a315081eadbadf49200e57d7e05aae7;p=platform%2Fkernel%2Flinux-starfive.git diff --git a/mm/filemap.c b/mm/filemap.c index 0834161..322aea7 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2569,18 +2569,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))