Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1433103imm; Thu, 19 Jul 2018 01:19:57 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdypNufjaDaoq/yui8vTNwOnbQcZpv1Mm6ROCgf/Tqm2Qez5aatgmUC2n4oCUhlyPhUd51a X-Received: by 2002:a63:3046:: with SMTP id w67-v6mr4479910pgw.176.1531988397090; Thu, 19 Jul 2018 01:19:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531988397; cv=none; d=google.com; s=arc-20160816; b=H+Z4w9MOLbTF9PkW5Amxrk+NIF0R5wOLtiMakvUisryhNSo1x14t68Py0fvAFA9LIP azVx+y37EbDqFvr0G9VB0ICS7Mpxhf4Ehjf54C4hyAdYJjj/Alzpoqe5n1jezfuallvu s4v58Tl3QNfzGuUWKsBEGsHlqNAWOXGDJpQiN/CF1WgDH6AQqSxAhIb4FPdQeGtK6S0F 3aHqbbxYGIOgcqS0oi5cACkBhy1NEcQB/DsJLT0Mp6jwRiHHk2LpMGJy624MkkHnzCZs p9Lrw58h6si6xQNG0bmXrIrfhDhge9RYvtXQgUrlpjyrGF9U2VtYI/JXj1GGt1hv5Lm3 Zv7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=NsorCaxonhYhaFffIhvT8/k0ksK0boLd1AKSU7YMhtw=; b=oM+ye0Wv+Sy7u8k1GnKMLsodcAgfrmN0KjWvnQ92JIPvwJUbYAdhOikgEbpQo11det C3+1Wls1XmkNiAsSOnoFGvx/7m7pySnvQ7pcnNECJYl2xKK0Odssv5S6yNyDb1S1vCdk M8891xv5Ch3rfvOU5MeIG1mDhy4TpxD7NYCulGr0n7vo+TY12z1KwNqeoXh7mRSM7WFf 5qAmxL69DNt+iJTLEe3RNDpDEJxyOWEkX+d3RI5YAtVZzGSGuTnYOaYqOzSuVOH/SNyb FQiorAWtY/oZaegHV6ZanSavQLF/apB/c0VqVBwB4Jqyc+rVj4uphgX287HHid232TxV KzlA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e9-v6si5229518plk.130.2018.07.19.01.19.42; Thu, 19 Jul 2018 01:19:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731301AbeGSJBG (ORCPT + 99 others); Thu, 19 Jul 2018 05:01:06 -0400 Received: from mout.gmx.net ([212.227.17.21]:58621 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727268AbeGSJBG (ORCPT ); Thu, 19 Jul 2018 05:01:06 -0400 Received: from x201.localdomain ([220.112.58.66]) by mail.gmx.com (mrgmx103 [212.227.17.174]) with ESMTPSA (Nemesis) id 0M5MIN-1fxTNL40rf-00zTUC; Thu, 19 Jul 2018 10:18:53 +0200 From: Chengguang Xu 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 Subject: [PATCH] mm: adjust max read count in generic_file_buffered_read() Date: Thu, 19 Jul 2018 16:17:26 +0800 Message-Id: <20180719081726.3341-1-cgxu519@gmx.com> X-Mailer: git-send-email 2.17.1 X-Provags-ID: V03:K1:vUaRjAszsrA+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k= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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