Matthew Wilcox <willy@xxxxxxxxxxxxx> wrote: > On Mon, Nov 14, 2022 at 04:02:20PM +0000, David Howells wrote: > > +++ b/mm/filemap.c > > @@ -3941,6 +3941,10 @@ bool filemap_release_folio(struct folio *folio, gfp_t gfp) > > struct address_space * const mapping = folio->mapping; > > > > BUG_ON(!folio_test_locked(folio)); > > + if ((!mapping || !mapping_release_always(mapping)) > > + && !folio_test_private(folio) && > > + !folio_test_private_2(folio)) > > + return true; > > Why do you need to test 'mapping' here? Why does the function do: if (mapping && mapping->a_ops->release_folio) later then? There are callers of the function, such as shrink_folio_list(), that seem to think that folio->mapping might be NULL. > Also this is the most inconsistent style ... Yeah, I accidentally pushed the '&&' onto the next line. > > @@ -276,7 +275,7 @@ static long mapping_evict_folio(struct address_space *mapping, > > if (folio_ref_count(folio) > > > folio_nr_pages(folio) + folio_has_private(folio) + 1) > > I think this line is incorrect, right? You don't increment the folio > refcount just because the folio has private2 set, do you? Errr, yes: static inline void folio_start_fscache(struct folio *folio) { VM_BUG_ON_FOLIO(folio_test_private_2(folio), folio); folio_get(folio); folio_set_private_2(folio); } Someone insisted - might even have been you;-) I'm working on getting rid of the use of PG_private_2 from the network filesystems, but it's still in progress. Kind of blocked on the iov_iter stuff. > > return 0; > > - if (folio_has_private(folio) && !filemap_release_folio(folio, 0)) > > + if (!filemap_release_folio(folio, 0)) > > return 0; > > > > return remove_mapping(mapping, folio); > > Can we get rid of folio_has_private() That would be nice, but there are still places that check it, and until we get rid of the use of PG_private_2, we can't reduce it to just a check on PG_private. Truncate, for example, checks it to see if it should can ->invalidate_folio(). It's only used in mm/, so it could be moved into mm/internal.h. > / page_has_private() now? That's used in some a number of places outside of mm/. The arch/s390/ usage is just to calculate the expected refcount. I wonder if calculation of the expected refcount could be potted into a function as it's performed in a number of places - though the expectation isn't always the same. Ext3 and fuse both use it - but those probably need to check PG_private_2 and could use a "folio_test_private()" function when fully foliated. David -- Linux-cachefs mailing list Linux-cachefs@xxxxxxxxxx https://listman.redhat.com/mailman/listinfo/linux-cachefs