[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231221114153.2ktiwixqedsk5adw@quack3>
Date: Thu, 21 Dec 2023 12:41:53 +0100
From: Jan Kara <jack@...e.cz>
To: Christoph Hellwig <hch@....de>
Cc: linux-mm@...ck.org, "Matthew Wilcox (Oracle)" <willy@...radead.org>,
Jan Kara <jack@...e.com>, David Howells <dhowells@...hat.com>,
Brian Foster <bfoster@...hat.com>, linux-fsdevel@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 13/17] writeback: Factor writeback_get_folio() out of
write_cache_pages()
On Mon 18-12-23 16:35:49, Christoph Hellwig wrote:
> From: "Matthew Wilcox (Oracle)" <willy@...radead.org>
>
> Move the loop for should-we-write-this-folio to its own function.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@...radead.org>
> Signed-off-by: Christoph Hellwig <hch@....de>
Looks good to me. Feel free to add:
Reviewed-by: Jan Kara <jack@...e.cz>
But I'd note that the call stack depth of similarly called helper functions
(with more to come later in the series) is getting a bit confusing. Maybe
we should inline writeback_get_next() into its single caller
writeback_get_folio() to reduce confusion a bit...
Honza
> +static struct folio *writeback_get_folio(struct address_space *mapping,
> + struct writeback_control *wbc)
> +{
> + struct folio *folio;
> +
> + for (;;) {
> + folio = writeback_get_next(mapping, wbc);
> + if (!folio)
> + return NULL;
> + folio_lock(folio);
> + if (likely(should_writeback_folio(mapping, wbc, folio)))
> + break;
> + folio_unlock(folio);
> + }
> +
> + trace_wbc_writepage(wbc, inode_to_bdi(mapping->host));
> + return folio;
> +}
> +
> static struct folio *writeback_iter_init(struct address_space *mapping,
> struct writeback_control *wbc)
> {
> @@ -2455,7 +2474,7 @@ static struct folio *writeback_iter_init(struct address_space *mapping,
>
> wbc->err = 0;
> folio_batch_init(&wbc->fbatch);
> - return writeback_get_next(mapping, wbc);
> + return writeback_get_folio(mapping, wbc);
> }
>
> /**
> @@ -2498,17 +2517,9 @@ int write_cache_pages(struct address_space *mapping,
>
> for (folio = writeback_iter_init(mapping, wbc);
> folio;
> - folio = writeback_get_next(mapping, wbc)) {
> + folio = writeback_get_folio(mapping, wbc)) {
> unsigned long nr;
>
> - folio_lock(folio);
> - if (!should_writeback_folio(mapping, wbc, folio)) {
> - folio_unlock(folio);
> - continue;
> - }
> -
> - trace_wbc_writepage(wbc, inode_to_bdi(mapping->host));
> -
> error = writepage(folio, wbc, data);
> nr = folio_nr_pages(folio);
> wbc->nr_to_write -= nr;
> --
> 2.39.2
>
--
Jan Kara <jack@...e.com>
SUSE Labs, CR
Powered by blists - more mailing lists