Re: [PATCH v14 076/138] mm/writeback: Add folio_redirty_for_writepage()

From: Vlastimil Babka
Date: Thu Aug 12 2021 - 12:30:56 EST


On 7/15/21 5:36 AM, Matthew Wilcox (Oracle) wrote:
> Reimplement redirty_page_for_writepage() as a wrapper around
> folio_redirty_for_writepage(). Account the number of pages in the
> folio, add kernel-doc and move the prototype to writeback.h.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx>
> Reviewed-by: Christoph Hellwig <hch@xxxxxx>

Acked-by: Vlastimil Babka <vbabka@xxxxxxx>

Nit:

> --- a/mm/page-writeback.c
> +++ b/mm/page-writeback.c
> @@ -2558,21 +2558,31 @@ void folio_account_redirty(struct folio *folio)
> }
> EXPORT_SYMBOL(folio_account_redirty);
>
> -/*
> - * When a writepage implementation decides that it doesn't want to write this
> - * page for some reason, it should redirty the locked page via
> - * redirty_page_for_writepage() and it should then unlock the page and return 0
> +/**
> + * folio_redirty_for_writepage - Decline to write a dirty folio.
> + * @wbc: The writeback control.
> + * @folio: The folio.
> + *
> + * When a writepage implementation decides that it doesn't want to write
> + * @folio for some reason, it should call this function, unlock @folio and
> + * return 0.

s/0/false

> + *
> + * Return: True if we redirtied the folio. False if someone else dirtied
> + * it first.
> */
> -int redirty_page_for_writepage(struct writeback_control *wbc, struct page *page)
> +bool folio_redirty_for_writepage(struct writeback_control *wbc,
> + struct folio *folio)
> {
> - int ret;
> + bool ret;
> + unsigned nr = folio_nr_pages(folio);
> +
> + wbc->pages_skipped += nr;
> + ret = filemap_dirty_folio(folio->mapping, folio);
> + folio_account_redirty(folio);
>
> - wbc->pages_skipped++;
> - ret = __set_page_dirty_nobuffers(page);
> - account_page_redirty(page);
> return ret;
> }
> -EXPORT_SYMBOL(redirty_page_for_writepage);
> +EXPORT_SYMBOL(folio_redirty_for_writepage);
>
> /**
> * folio_mark_dirty - Mark a folio as being modified.
>