Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3759718pxk; Tue, 22 Sep 2020 01:35:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwMpHSMqQV2pQmfOC94H7ARZb5t13oPwqOnimif/gCcaEfRQr7ovmL9fToETSLUNEwrXG+R X-Received: by 2002:a17:906:8258:: with SMTP id f24mr3540860ejx.551.1600763723090; Tue, 22 Sep 2020 01:35:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600763723; cv=none; d=google.com; s=arc-20160816; b=Tc7ZAaTNhw9zYmR0nkbz0QGVVn7Ql8OIMb9YVllrOaFqxnOpx2cRqoR1RLZg2R4Ym9 kYFb3Ok16UQCNBEGD0CBfGJ53f29rdBT0YWg2rydAe/NAzzkPRWRj8Q/aQssQY6ZiMuP Nsd4iEbI6KC1j78wAHpAG0S8OPSBuFTNC29nnQspdMCCiO0090ZxlnMAfx0wpYeYi6x/ mWG84g/2/7/fkWxmjuPT1BRDQPKvqhNWQ69MOPM3J+6N7a5OU+JRHKnTt6TlklWO3bgu O7KsZotNrexJUt6jTzCVuU+VQbxucplxy3AxY6vEET38nUXkzGwwNdcxCxZ5ySuRJk9z lEdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=gNfs1q72bwkEHz+cQRncVU2qAyjsODh+BKtZ4o87m/c=; b=xiPiZVyls3/unxsBvo3/NtuX2RyVpMCW7eGA1XExIoCuOZnZ8Pv1BEXfdceUfSz23P t27CD/ap7uFdksKac0ommeadlh5yjMTKmRYr7c+nKoK+P1Dw9c7Oe7+9bJjD67yobyr2 C0miwheZoMg/NhX0bsnM4bDzPkEWF4hAyJ0yRZ7RCA+FP+SeRnml/5N4g3LU7+hLssBA MgwTNklRF+OiIvsrhkkXKOgqWvVKmF79Zjjpbp1Fv1jH767WegnS6iIqIRxNBa1Bz8z/ UYA5IjO9+uEnCw65FRkEz+ffeOx79KXJAJj1BoGA6wfkeR5b46MFFQpjer60GxMOYyyG lhcQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c9si10230485edt.107.2020.09.22.01.34.59; Tue, 22 Sep 2020 01:35:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726577AbgIVHy3 (ORCPT + 99 others); Tue, 22 Sep 2020 03:54:29 -0400 Received: from mx2.suse.de ([195.135.220.15]:59102 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726442AbgIVHy2 (ORCPT ); Tue, 22 Sep 2020 03:54:28 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 8E840ACC2; Tue, 22 Sep 2020 07:55:03 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 7D0771E12E3; Tue, 22 Sep 2020 09:54:26 +0200 (CEST) Date: Tue, 22 Sep 2020 09:54:26 +0200 From: Jan Kara To: Matthew Wilcox Cc: Linus Torvalds , Jan Kara , Dave Chinner , Hugh Dickins , Amir Goldstein , Andreas Gruenbacher , Theodore Tso , Martin Brandenburg , Mike Marshall , Damien Le Moal , Jaegeuk Kim , Qiuyang Sun , linux-xfs , linux-fsdevel , Linux MM , linux-kernel , "Kirill A. Shutemov" , Andrew Morton , Al Viro , nborisov@suse.de Subject: Re: More filesystem need this fix (xfs: use MMAPLOCK around filemap_map_pages()) Message-ID: <20200922075426.GA15112@quack2.suse.cz> References: <20200916155851.GA1572@quack2.suse.cz> <20200917014454.GZ12131@dread.disaster.area> <20200917064532.GI12131@dread.disaster.area> <20200921082600.GO12131@dread.disaster.area> <20200921091143.GB5862@quack2.suse.cz> <20200921175943.GW32101@casper.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200921175943.GW32101@casper.infradead.org> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon 21-09-20 18:59:43, Matthew Wilcox wrote: > On Mon, Sep 21, 2020 at 09:20:25AM -0700, Linus Torvalds wrote: > > On Mon, Sep 21, 2020 at 2:11 AM Jan Kara wrote: > > > > > > Except that on truncate, we have to unmap these > > > anonymous pages in private file mappings as well... > > > > I'm actually not 100% sure we strictly would need to care. > > > > Once we've faulted in a private file mapping page, that page is > > "ours". That's kind of what MAP_PRIVATE means. > > > > If we haven't written to it, we do keep things coherent with the file, > > but that's actually not required by POSIX afaik - it's a QoI issue, > > and a lot of (bad) Unixes didn't do it at all. > > So as long as truncate _clears_ the pages it truncates, I think we'd > > actually be ok. > > We don't even need to do that ... > > "If the size of the mapped file changes after the call to mmap() > as a result of some other operation on the mapped file, the effect of > references to portions of the mapped region that correspond to added or > removed portions of the file is unspecified." > > https://pubs.opengroup.org/onlinepubs/9699919799/functions/mmap.html > > As you say, there's a QoI here, and POSIX permits some shockingly > bad and useless implementations. Something from ftruncate(2) POSIX definition [1] for comparison: If the effect of ftruncate() is to decrease the size of a memory mapped file or a shared memory object and whole pages beyond the new end were previously mapped, then the whole pages beyond the new end shall be discarded. References to discarded pages shall result in the generation of a SIGBUS signal. [1] https://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html Now pick... ;) Honza -- Jan Kara SUSE Labs, CR