From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 51AB5C432C3 for ; Wed, 27 Nov 2019 17:30:09 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 10EA72073F for ; Wed, 27 Nov 2019 17:30:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="d/o6EltX" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 10EA72073F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 9E0AB6B04CF; Wed, 27 Nov 2019 12:30:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 96A0E6B04D0; Wed, 27 Nov 2019 12:30:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 831EB6B04D1; Wed, 27 Nov 2019 12:30:08 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0150.hostedemail.com [216.40.44.150]) by kanga.kvack.org (Postfix) with ESMTP id 6A17C6B04CF for ; Wed, 27 Nov 2019 12:30:08 -0500 (EST) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with SMTP id 285E34FE6 for ; Wed, 27 Nov 2019 17:30:08 +0000 (UTC) X-FDA: 76202745696.01.stick58_756fc89516254 X-HE-Tag: stick58_756fc89516254 X-Filterd-Recvd-Size: 5971 Received: from mail-lj1-f193.google.com (mail-lj1-f193.google.com [209.85.208.193]) by imf13.hostedemail.com (Postfix) with ESMTP for ; Wed, 27 Nov 2019 17:30:06 +0000 (UTC) Received: by mail-lj1-f193.google.com with SMTP id t5so25408654ljk.0 for ; Wed, 27 Nov 2019 09:30:06 -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=nBoqWZhmGQ8overMrSXIUtdz/aUhAzYlroAyTRLhq/8x5AuF+FWQv/GO1CDOL+LQtS er4QSJ87YtYALiuqDFehojLJYBlPnTaDRMlC2ZEgIX9PoEN5BblAQcAM9abPAZ8A7cVW k4fqCuVawfjgTT5fpjrfy69x8MHXgeVPVqquVpnBlbEGzfFACKxEBkxJ8U3mPigp+FA4 TaZKv5ZeaDWpiZ1eeCBW1OMcy2JNQKDehhbC2k3WayuHen/5EfxC7T3+1EEqu5h6pcOi UiYfTNjazJqd8tYbwPU5mQQcaGTsMiHkqTy6SFBlEUOJLaXoD4M1N8K8i8hrX60YkQJT F2rg== X-Gm-Message-State: APjAAAXRGbh7cUZln24Zkto/EY0IBBGL2KxNHOrNuvRWUDgISrl7E+CT U2D8CvfcZqJXB103ESvIxApV4PhRAEo= X-Google-Smtp-Source: APXvYqyJsiP1gZZ4xn/bqlwCtqfjI3xJyCi0EweLbWJcKo7BrHseLA92anoq+X7Uca4rvdyzySA3Hg== X-Received: by 2002:a2e:8805:: with SMTP id x5mr28398480ljh.44.1574875804731; Wed, 27 Nov 2019 09:30:04 -0800 (PST) Received: from mail-lj1-f180.google.com (mail-lj1-f180.google.com. [209.85.208.180]) by smtp.gmail.com with ESMTPSA id 28sm7307737lfy.38.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-f180.google.com with SMTP id e9so25356902ljp.13 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" X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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