Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp5795500ybc; Wed, 27 Nov 2019 09:31:52 -0800 (PST) X-Google-Smtp-Source: APXvYqzmRuYHIn3am7lXRGPqR2U0B2jl3J6+dzKl7wHcNd2f2eXwhWv0ofmWHg4psJLa8wqZrUEf X-Received: by 2002:a17:906:1fcf:: with SMTP id e15mr48609082ejt.317.1574875911936; Wed, 27 Nov 2019 09:31:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574875911; cv=none; d=google.com; s=arc-20160816; b=w92qUi6MQlJtbCpXmU9/ftiSgnOLsOG4yo4ubAGSEYzP+S4XRMRwUCuKGTME81M+DP FmDxpM1qf4WPqeo2zKwFIUm9mbk9Qbc6I0Svdp+xp+1cigeII2thZ7sfIeVDpYOnlfzm jgXrGkkxZ+od7mY0H91gl7cKkp89crvGZF63fpaonQ58hTzxTwfxAN5fY7eBh+nvQbcz /JY1xngYX0xjLXnRjNqC484HUfYGBihWwnDENAs/sH6uTMQjCoIw72JNOWDzm0lpDh2w WCoPgI3oI8ihj4vJ7CbYfOUkvxAycpADjzSTCpK3UPdXkxWtnwtcYRArkRuRb2JECHSG gZ+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=OHYvN6viznScLuFMhHh+plwLnzseinfGUfKYa/O5B9E=; b=IG4qAVChIQK4nMxwK3zBqBZvTWs8y4HIH09ZU9j0QsDFX7Cg86nigaobkNxsH9GQxl X1p51ju7pTmJQ20t/Z8A5Le25gG7OGCIid+Yw6O4omKb/aQ0O7azgjZyAmbPYWS3oehX mGgQeg39tCkNGMNJOWdhArF28+TB0xsxBTLkGeP+gp0bDsoxoiOZgu3F9DkqS5Z8J4qV 8MMH22NPS8lmrjl6AqCqdickM1fAA7z9JSNur9lB7uqEN9k6LRv2we7/4iuIdZ4fiyrp QIt+4tMCnEqXQLCcn9XSxhDQWtGY4mRYAyoAV6sMLmzpuhlC63bIJ70XdNH/cBFrLMRc jKAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b="d/o6EltX"; 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 d2si10008521ejr.371.2019.11.27.09.31.27; Wed, 27 Nov 2019 09:31:51 -0800 (PST) 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; dkim=pass header.i=@linux-foundation.org header.s=google header.b="d/o6EltX"; 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 S1727088AbfK0RaH (ORCPT + 99 others); Wed, 27 Nov 2019 12:30:07 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:32778 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726292AbfK0RaH (ORCPT ); Wed, 27 Nov 2019 12:30:07 -0500 Received: by mail-lj1-f193.google.com with SMTP id t5so25408637ljk.0 for ; Wed, 27 Nov 2019 09:30:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=OHYvN6viznScLuFMhHh+plwLnzseinfGUfKYa/O5B9E=; b=d/o6EltX2tOPVh+pCIPqROyyLmufd3KKhy4ZzU5rMuRlVV5+ZhuGOopgQYX4213Ruf 3geslrmCVOTUtkpnd80sPLQIxoMXA66iMjoQwR0w+MhfrWHNS9BTxZtIJ4r9oDphfitZ kSpLWposwiLF5+WA/vvyqLaAjNYels5rKVBPU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=OHYvN6viznScLuFMhHh+plwLnzseinfGUfKYa/O5B9E=; b=ddYUcA57aful/IMisC6wt5qTnMgM2FoFk36pLBpqU9w+TBQE7R0g2eBfZn7qOWdbPS a9m5Xx2gCj4hLeF1asEpN+f3c4zski7DDAlbZEXVRME3qQu9dMOOH8koy9RFQTGTdKxO 3RPmJ34zBnE4J8toW91Fi4aA9YwCWxkBXw9vqUDQqGj7SIuSI5sWDr4Gb8ZiwCgLcy+w AnwZdgLwjmn//uk0MXuiytDqSN0pj6Ku5toxlmclC5kebwzg2ZVH2ngnq42+TnVm+zJM TFThJkKx9e91TkC4YxZp0IaX3iCxbpSkiMPzDC3V8LOpvrBWxnE2JLd2DPXJ8gknxSRZ GnuA== X-Gm-Message-State: APjAAAVSFJHZaWnaTgzu7DCx5ns94pJl1Rg8K4by9g96GAUtqQ+lGQTv nRByC2QnPJDN43/9+XL6s1LcvrV8Hno= X-Received: by 2002:a05:651c:c4:: with SMTP id 4mr2668896ljr.171.1574875804590; Wed, 27 Nov 2019 09:30:04 -0800 (PST) Received: from mail-lj1-f169.google.com (mail-lj1-f169.google.com. [209.85.208.169]) by smtp.gmail.com with ESMTPSA id d17sm8504602lja.27.2019.11.27.09.30.01 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 27 Nov 2019 09:30:01 -0800 (PST) Received: by mail-lj1-f169.google.com with SMTP id n21so25342521ljg.12 for ; Wed, 27 Nov 2019 09:30:01 -0800 (PST) X-Received: by 2002:a2e:86c4:: with SMTP id n4mr17881292ljj.97.1574875800695; Wed, 27 Nov 2019 09:30:00 -0800 (PST) MIME-Version: 1.0 References: <157225677483.3442.4227193290486305330.stgit@buzz> <20191028124222.ld6u3dhhujfqcn7w@box> <20191028125702.xdfbs7rqhm3wer5t@box> <640bbe51-706b-8d9f-4abc-5f184de6a701@redhat.com> <22f04f02-86e4-b379-81c8-08c002a648f0@redhat.com> In-Reply-To: From: Linus Torvalds Date: Wed, 27 Nov 2019 09:29:44 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] mm/filemap: do not allocate cache pages beyond end of file at read To: Steven Whitehouse Cc: =?UTF-8?Q?Andreas_Gr=C3=BCnbacher?= , Konstantin Khlebnikov , "Kirill A. Shutemov" , Linux-MM , Andrew Morton , Linux Kernel Mailing List , linux-fsdevel , Alexander Viro , Johannes Weiner , "cluster-devel@redhat.com" , Ronnie Sahlberg , Steve French , Andreas Gruenbacher , Bob Peterson Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 27, 2019 at 7:42 AM Steven Whitehouse wrote: > > I'll leave the finer details to Andreas here, since it is his patch, and > hopefully we can figure out a good path forward. As mentioned, I don't _hate_ that patch (ok, I seem to have typoed it and said that I don't "gate" it ;), so if that's what you guys really want to do, I'm ok with it. But.. I do think you already get the data with the current case, from the "short read" thing. So just changing the current generic read function to check against the size first: --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2021,9 +2021,9 @@ static ssize_t generic_file_buffered_read(struct kiocb *iocb, unsigned int prev_offset; int error = 0; - if (unlikely(*ppos >= inode->i_sb->s_maxbytes)) + if (unlikely(*ppos >= inode->i_size)) return 0; - iov_iter_truncate(iter, inode->i_sb->s_maxbytes); + iov_iter_truncate(iter, inode->i_size); index = *ppos >> PAGE_SHIFT; prev_index = ra->prev_pos >> PAGE_SHIFT; and you're done. Nice and clean. Then in gfs2 you just notice the short read, and check at that point. Sure, you'll also cut read-ahead to the old size boundary, but does anybody _seriously_ believe that read-ahead matters when you hit the "some other node write more data, we're reading past the old end" case? I don't think that's the case. But I _can_ live with the patch that adds the extra "cached only" bit. It just honestly feels pointless. Linus