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=-5.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 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 0F5C3C4727C for ; Tue, 22 Sep 2020 07:54:31 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 175BD23A9C for ; Tue, 22 Sep 2020 07:54:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 175BD23A9C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 38A84900032; Tue, 22 Sep 2020 03:54:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 33A0A900012; Tue, 22 Sep 2020 03:54:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 228CA900032; Tue, 22 Sep 2020 03:54:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0160.hostedemail.com [216.40.44.160]) by kanga.kvack.org (Postfix) with ESMTP id 08484900012 for ; Tue, 22 Sep 2020 03:54:29 -0400 (EDT) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id C45F51EF1 for ; Tue, 22 Sep 2020 07:54:28 +0000 (UTC) X-FDA: 77289935016.20.pot75_06100e42714c Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin20.hostedemail.com (Postfix) with ESMTP id A4471180C07A3 for ; Tue, 22 Sep 2020 07:54:28 +0000 (UTC) X-HE-Tag: pot75_06100e42714c X-Filterd-Recvd-Size: 4092 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf29.hostedemail.com (Postfix) with ESMTP for ; Tue, 22 Sep 2020 07:54:28 +0000 (UTC) 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) 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 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