From patchwork Thu Jul 19 08:17:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengguang Xu X-Patchwork-Id: 10533775 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DC8B4600D0 for ; Thu, 19 Jul 2018 08:19:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CB3122937E for ; Thu, 19 Jul 2018 08:19:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BF5A82932F; Thu, 19 Jul 2018 08:19:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,FREEMAIL_FROM, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 52CE92932F for ; Thu, 19 Jul 2018 08:19:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5A10F6B000C; Thu, 19 Jul 2018 04:19:00 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 529B76B000D; Thu, 19 Jul 2018 04:19:00 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3CD8F6B000E; Thu, 19 Jul 2018 04:19:00 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wm0-f72.google.com (mail-wm0-f72.google.com [74.125.82.72]) by kanga.kvack.org (Postfix) with ESMTP id CD3126B000C for ; Thu, 19 Jul 2018 04:18:59 -0400 (EDT) Received: by mail-wm0-f72.google.com with SMTP id o25-v6so2046957wmh.1 for ; Thu, 19 Jul 2018 01:18:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id; bh=NsorCaxonhYhaFffIhvT8/k0ksK0boLd1AKSU7YMhtw=; b=RGDYLRx93/qj8hUdrZYQkOZI5RowdUhQMo+Qqh1fDHAl0MNP+pRvdwppAfUgaqehcA LDng7R8boqC5qu1vqCrTZQfmctfLS8iM2Y3CfeoX1Q8ePrZKH85GnfajDS5ug//Qisec YIab9rqbizhQd75hXmu2+9Di2c+4Z8zhjmreGWQy04n22IZq6MzB/WbDaoKXUBoX0zfY MOaom+Id9JFT5dCRKuIdGSGRB6VAWFLGrJ/b/vpm+liMNM0aoAhvj3Znj/zirg8IgWeP z6/CfQHBFKkwXx9MmhHplr9qpC054ScpZ80JJLeSH2N7OlUyp548VsC8yQMEQYZOvqqF tUjw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of cgxu519@gmx.com designates 212.227.17.21 as permitted sender) smtp.mailfrom=cgxu519@gmx.com X-Gm-Message-State: AOUpUlFtBRa87LNn9DtP28mlTZTmlkiDufwKi3imXj2er9YOGbrbyLhp sjE8OaSMaRXNqwAZWt1JF3FyC6tkVb+vqAUJT+Mpvt1NKppI3kPGyt4edtU8M00Qq70stae/G9q kN0vmSXHYYIxYkjYZ0GTUDMr4JKvZgtj/l6np3mPSLVmBRCy1HCGqBrnbLrN/9O3PTQ== X-Received: by 2002:a1c:8b0d:: with SMTP id n13-v6mr3298801wmd.46.1531988339338; Thu, 19 Jul 2018 01:18:59 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcSt/+GiBV0AcMT4Nbtw9S/UhIAUKcNV9a3U3GVH0Xdl/X87ov9KrXmbCtlQgmViKRVBkAo X-Received: by 2002:a1c:8b0d:: with SMTP id n13-v6mr3298775wmd.46.1531988338601; Thu, 19 Jul 2018 01:18:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531988338; cv=none; d=google.com; s=arc-20160816; b=f+urjiFdWz9CzHEZZESMFdHWXyJIH/SFdctZNH2Pq86D9Pbc/LbGW3LITwJ7iX1+jE fiG2F8pYAADXE2ABCsuEVPOa9Iu9rcgTfYlmd+TYPZ1XBm69w66h7Mm4dCAvWJJwYvbj i0LfZhoO8rkEU8qFPGSnUHpB3RIxM27mehN0Fx8v0yLC1m2Cne3qkJF+JBqxBMoyZKnR j2oz3cXfGnsJd7JyHV9nTkQ1GMObE8QRz03Ps4pW3lbbb3fOfRyd1HibZQxgswMNKoml q+scs30K8V+Sx09R0/tRbIfFqxNTGFnB2DYbiAa3K0qjAACzgzvCPlI7C+SPMDvHf/36 a7dQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:arc-authentication-results; bh=NsorCaxonhYhaFffIhvT8/k0ksK0boLd1AKSU7YMhtw=; b=YiOpAmjJc7/MF8IqMeAEqnkI8bWoIy1ukts1gZgRYXCGPBRf0MpY456hnzxnl1U6DW ukyKnsHEY4uuFnemSOxTiDcfAOVz3ELp/zJb080U3dfcB5+7G4cKdV22eIZINBRudJqF e4ESaOLJTiqjOvj2zLXjHd4iG0DZ4wxnnM//EgGAxvC5Iw0ObKIQWKTe+6jAK2lPx9dC C+Ej6aWqblqxEabfpf2ACpNv3QVam1vYaGObuXdc2ZWINaaBo5DE48R6Jv//C4+oamnt dxNcR2b6E3KqI3yI6z/7C79EZSGnmSP1UeqGCSV1Ny2NnUbPaRk8uYGQydb2B4ZAMRk0 KyuQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of cgxu519@gmx.com designates 212.227.17.21 as permitted sender) smtp.mailfrom=cgxu519@gmx.com Received: from mout.gmx.net (mout.gmx.net. [212.227.17.21]) by mx.google.com with ESMTPS id q6-v6si4711679wrj.176.2018.07.19.01.18.58 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Jul 2018 01:18:58 -0700 (PDT) Received-SPF: pass (google.com: domain of cgxu519@gmx.com designates 212.227.17.21 as permitted sender) client-ip=212.227.17.21; Authentication-Results: mx.google.com; spf=pass (google.com: domain of cgxu519@gmx.com designates 212.227.17.21 as permitted sender) smtp.mailfrom=cgxu519@gmx.com 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+f+IbVOq7BtUA8fsuvc0whhVq6Z7wC0bFJSU7adj bxiJ5WLma2wtUUBfMs2uVHsDFZwVSnT0jhTcTxw1XFgnFtnwvTR10B6dl5mVpPhhhAc3wsy 2Z8WDtWWUrUS4g1X2y0/nrFM5bKRx/Wf+zwZxTFb/04sip2FiPH3sFQprVaWExjBkoXepdf NnnN9m1BSMwF7ddUJFZbg== X-UI-Out-Filterresults: notjunk:1; V01:K0:73aCmyVpLvs=:HOIJUJfRfNIaXrpQKITfxR Cyg84OXU3GnvOuqzyl48vXPal34FgU4+9Uh8BBKy6sSzb8p5QlYiKmj2FWl/A4TFeuAv8/Ild 2xZhlSYJmOpl4CxfnFdrREZ89LbSMTCMTwZdCNrHKbEhJjRXaM9Y2JfvTNPX39P4rZALxCdJr pa+mmuvPUXy3M9fPeS5cHlG6jyYBf54dDAYhqAaPMqVa4cRbIOcWn3jxj9g4/Wt75F6QdEbO0 Q+tnmUKvRkVkO918ia8hsynHYzdC2wnCnslco6gqFqOH2+DjGVazu0VPNlXrKcDIAmWdWAXt1 fr+SwWwGxP5dtSE+k5QPD4wDRuc3BmT59IKK3pYU2QH6Igon/Xil8sicb8QGLFxhDLJhUvn8M rkKm+AWg3SI2xBXtBX33xw6829EWlDz9x+Emh82e8pAfNkkQ0A/aPbJaaJd4IFEy27lNlAFN7 TwMEjjgPvpw+K9BkzWVPJL+nb6UTIM8MvSNkXiEDgXvo5a7+HgpQipPwP8+DgkUq2v+//niOP jeTog0EJLIPlxjB6/Uu0jJqrzFekGwCKkdBTUHb0IBE7+Wm7xZ48BVmX25i+MDMDvmqECTonH lNde/+223l6/2Qv8wIXpdsNXyUyPnfZ0pJC4ZzH6RjvRgkws1/rYgmxak1jTABdmieSDqrQXC 3V8q1xrX4defV1Eq3Q8qRYK8MRNOrWni0YTB5ihaUbBHfWLhlFrYN8yE3WwJoR7kpXpfWE+s6 FkUJ5kbXpanADyRBTdLZ+bfblUpB3jqIX9lHsVJkBtaJrUSNgGvEg8ObA/k= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000013, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Jan Kara --- 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;