linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Chengguang Xu <cgxu519@gmx.com>
To: akpm@linux-foundation.org, jack@suse.cz,
	mgorman@techsingularity.net, jlayton@redhat.com,
	ak@linux.intel.com, mawilcox@microsoft.com,
	tim.c.chen@linux.intel.com
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Chengguang Xu <cgxu519@gmx.com>
Subject: [PATCH] mm: adjust max read count in generic_file_buffered_read()
Date: Thu, 19 Jul 2018 16:17:26 +0800	[thread overview]
Message-ID: <20180719081726.3341-1-cgxu519@gmx.com> (raw)

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

             reply	other threads:[~2018-07-19  8:18 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-19  8:17 Chengguang Xu [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180719081726.3341-1-cgxu519@gmx.com \
    --to=cgxu519@gmx.com \
    --cc=ak@linux.intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=jack@suse.cz \
    --cc=jlayton@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mawilcox@microsoft.com \
    --cc=mgorman@techsingularity.net \
    --cc=tim.c.chen@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox