[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20201221145835.GB874@casper.infradead.org>
Date: Mon, 21 Dec 2020 14:58:35 +0000
From: Matthew Wilcox <willy@...radead.org>
To: Jan Kara <jack@...e.cz>
Cc: linux-fsdevel@...r.kernel.org, linux-ext4@...r.kernel.org,
Jan Kara <jack@...e.com>, Theodore Ts'o <tytso@....edu>,
Andreas Dilger <adilger.kernel@...ger.ca>
Subject: Re: set_page_dirty vs truncate
On Mon, Dec 21, 2020 at 03:12:57PM +0100, Jan Kara wrote:
> But overall even with GUP woes fixed up, set_page_dirty() called by a PUP
> user could still see already truncated page. So it has to deal with it.
Thanks! That was really helpful. We have a number of currently-buggy
filesystems which assume they can do inode = page->mapping->host without
checking that page->mapping is not NULL.
Anyway, since I'm changing the set_page_dirty signature for folios,
this feels like the right time to pass in the page's mapping.
__set_page_dirty() rechecks the mapping under the i_pages lock, so we
won't do anything inappropriate if the page has been truncated.
You can find the whole thing at
https://git.infradead.org/users/willy/pagecache.git/shortlog/refs/heads/folio
but the important bit is:
- /* Set a page dirty. Return true if this dirtied it */
- int (*set_page_dirty)(struct page *page);
+ /* Set a folio dirty. Return true if this dirtied it */
+ bool (*set_page_dirty)(struct address_space *, struct folio *);
I'm kind of tempted to rename it to ->dirty_folio(), but I'm also fine
with leaving it this way.
Powered by blists - more mailing lists