[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20200922075426.GA15112@quack2.suse.cz>
Date: Tue, 22 Sep 2020 09:54:26 +0200
From: Jan Kara <jack@...e.cz>
To: Matthew Wilcox <willy@...radead.org>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>,
Jan Kara <jack@...e.cz>, Dave Chinner <david@...morbit.com>,
Hugh Dickins <hughd@...gle.com>,
Amir Goldstein <amir73il@...il.com>,
Andreas Gruenbacher <agruenba@...hat.com>,
Theodore Tso <tytso@....edu>,
Martin Brandenburg <martin@...ibond.com>,
Mike Marshall <hubcap@...ibond.com>,
Damien Le Moal <damien.lemoal@....com>,
Jaegeuk Kim <jaegeuk@...nel.org>,
Qiuyang Sun <sunqiuyang@...wei.com>,
linux-xfs <linux-xfs@...r.kernel.org>,
linux-fsdevel <linux-fsdevel@...r.kernel.org>,
Linux MM <linux-mm@...ck.org>,
linux-kernel <linux-kernel@...r.kernel.org>,
"Kirill A. Shutemov" <kirill@...temov.name>,
Andrew Morton <akpm@...ux-foundation.org>,
Al Viro <viro@...iv.linux.org.uk>, nborisov@...e.de
Subject: Re: More filesystem need this fix (xfs: use MMAPLOCK around
filemap_map_pages())
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 <jack@...e.cz> 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 <jack@...e.com>
SUSE Labs, CR
Powered by blists - more mailing lists