Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1461658imm; Thu, 19 Jul 2018 01:59:28 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeimlnjlLekpYKyzm0CTRW7zmjWSsGysGjtEY3FIi4Y7y9FEM7oQRpS/OBVQX9cn5rXBK++ X-Received: by 2002:a63:710d:: with SMTP id m13-v6mr9154595pgc.66.1531990768655; Thu, 19 Jul 2018 01:59:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531990768; cv=none; d=google.com; s=arc-20160816; b=X3rw5URPUnog83IvodPVrtwp/ycB+7oy4pEtxD7V1fEVcUlEpRhpGJcwX52QkD0tpC TFoxHTwz8C56MUNopWIFW8pSYUt5TObUU4t9kQdJHWakdfFDmXnOYLxUHtH1r6HhfC+n nBJHuKWuqYuliRMuz+fJXutZBe9UwlKjjfvYp5CWmp8//CYOUOFqa5e1YWH1yy51IzJl eJyh/Dq6I4OniSMuKrm3fPIKbwqJUDKNCl3IeNXAqhSC71ugxWdoYdRIKWBiirHQEXMg YQWc3asliKD6XimpmIT3Rm7GJX+CNIGq9PrvRMDRUt23XewYUaPL2vibtxwFxt/FH5IH kGcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=jIbuAnlLRCcYIj70yhf0aqGHlyicwhNEePQv0U8bkqg=; b=tWle7DGauy7/d75XbeaqGdLVgtWGFVmPd6CVpQi6c9BzZrNrTBMgFrxTCWYgzxZKIW Sa1tCsL97fMjk6MM6skJ9JIn87PaH/XU0A+k6EHLdsjVLE7GS6rih7JDKen/RpBllcDo uJl3Ysj8wuR7k0fybF7To0u942rTvGwXyoHUPXEF91fuKDwVw5vdAwsK/rEJLuw0BT2F jDUlvgB4Q7Znfha48ON+zHDBJThYM6+eYkgx9XOCPfY50khSOJ1FhR41CwK3xJDMI7RD p5Zf+aELrSWmQTrQMhlFVgpHqQ0hDNj9/UKCRL4U59GZZovFil6SCITE8UmRYE8OlmDw sizg== 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 k14-v6si5656851pfd.23.2018.07.19.01.59.13; Thu, 19 Jul 2018 01:59:28 -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 S1730491AbeGSJkW (ORCPT + 99 others); Thu, 19 Jul 2018 05:40:22 -0400 Received: from mx2.suse.de ([195.135.220.15]:36448 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726338AbeGSJkW (ORCPT ); Thu, 19 Jul 2018 05:40:22 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id AD1A3ADA5; Thu, 19 Jul 2018 08:58:12 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 322AF1E3C28; Thu, 19 Jul 2018 10:58:12 +0200 (CEST) Date: Thu, 19 Jul 2018 10:58:12 +0200 From: Jan Kara To: Chengguang Xu Cc: 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, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Al Viro Subject: Re: [PATCH] mm: adjust max read count in generic_file_buffered_read() Message-ID: <20180719085812.sjup2odrjyuigt3l@quack2.suse.cz> References: <20180719081726.3341-1-cgxu519@gmx.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180719081726.3341-1-cgxu519@gmx.com> User-Agent: NeoMutt/20170912 (1.9.0) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 19-07-18 16:17:26, Chengguang Xu wrote: > 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 Looks good to me. You can add: Reviewed-by: Jan Kara BTW, I can see you didn't include two (I'd say the most important ;) addresses to CC: Al Viro as a VFS maintainer and linux-fsdevel mailing list. Although this code resides in mm/ it is in fact a filesystem code. Added now. Honza > --- > 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 > -- Jan Kara SUSE Labs, CR