[PATCH v7 19/20] fs/dax: Properly refcount fs dax pages
David Hildenbrand
david at redhat.com
Tue Feb 11 06:01:28 AEDT 2025
>
> -static inline unsigned long dax_page_share_put(struct page *page)
> +static inline unsigned long dax_folio_put(struct folio *folio)
> {
> - WARN_ON_ONCE(!page->share);
> - return --page->share;
> + unsigned long ref;
> +
> + if (!dax_folio_is_shared(folio))
> + ref = 0;
> + else
> + ref = --folio->share;
> +
> + WARN_ON_ONCE(ref < 0);
> + if (!ref) {
> + folio->mapping = NULL;
> + if (folio_order(folio)) {
I'd have made this easier to read by doing
if (ref)
return ref;
folio->mapping = NULL;
order = folio_order(folio)
if (!order)
return 0;
pgmap = page_pgmap(&folio->page);
for (i = 0; i < (1UL << order); i++) {
// loop body see below
}
return 0;
In the context of similar split users and related discussions in the
future with memdescs -- see 89a41a0263293856678189981e5407375261c4ff --
I would further do within the loop (avoiding messing with page->
completely):
...
struct page *page = folio_page(folio, i);
/* Careful: see __split_huge_page_tail() */
struct folio *new_folio = (struct folio *)page;
ClearPageHead(page);
clear_compound_head(page);
new_folio->mapping = NULL;
/*
* Reset pgmap which was over-written by
* prep_compound_page().
*/
new_folio->pgmap = pgmap;
new_folio->share = 0;
WARN_ON_ONCE(folio_ref_count(new_folio));
...
I scanned over the other stuff in here, but I'm not an expert on the
pfn_t etc thingies.
--
Cheers,
David / dhildenb
More information about the Linuxppc-dev
mailing list