linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: adjust max read count in generic_file_buffered_read()
@ 2018-07-19  8:17 Chengguang Xu
  2018-07-19  8:58 ` Jan Kara
  0 siblings, 1 reply; 8+ messages in thread
From: Chengguang Xu @ 2018-07-19  8:17 UTC (permalink / raw)
  To: akpm, jack, mgorman, jlayton, ak, mawilcox, tim.c.chen
  Cc: linux-mm, linux-kernel, Chengguang Xu

When we try to truncate read count in generic_file_buffered_read(),
should deliver (sb->s_maxbytes - offset) as maximum count not
sb->s_maxbytes itself.

Signed-off-by: Chengguang Xu <cgxu519@gmx.com>
---
 mm/filemap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/filemap.c b/mm/filemap.c
index 52517f28e6f4..5c2d481d21cf 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -2064,7 +2064,7 @@ static ssize_t generic_file_buffered_read(struct kiocb *iocb,
 
 	if (unlikely(*ppos >= inode->i_sb->s_maxbytes))
 		return 0;
-	iov_iter_truncate(iter, inode->i_sb->s_maxbytes);
+	iov_iter_truncate(iter, inode->i_sb->s_maxbytes - *ppos);
 
 	index = *ppos >> PAGE_SHIFT;
 	prev_index = ra->prev_pos >> PAGE_SHIFT;
-- 
2.17.1


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

end of thread, other threads:[~2018-08-08  8:57 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-19  8:17 [PATCH] mm: adjust max read count in generic_file_buffered_read() Chengguang Xu
2018-07-19  8:58 ` Jan Kara
2018-07-20 23:14   ` Andrew Morton
2018-08-06 10:22     ` Jan Kara
2018-08-06 22:59       ` Andrew Morton
2018-08-07 13:54         ` Jan Kara
2018-08-08  0:57           ` cgxu519
2018-08-08  8:57             ` Jan Kara

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).