Re: [PATCH 11/17] writeback: Use the folio_batch queue iterator

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon 18-12-23 16:35:47, Christoph Hellwig wrote:
> From: "Matthew Wilcox (Oracle)" <willy@xxxxxxxxxxxxx>
> 
> Instead of keeping our own local iterator variable, use the one just
> added to folio_batch.
> 
> Signed-off-by: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx>
> Signed-off-by: Christoph Hellwig <hch@xxxxxx>

Nice. Feel free to add:

Reviewed-by: Jan Kara <jack@xxxxxxx>

								Honza

> ---
>  mm/page-writeback.c | 19 +++++++++----------
>  1 file changed, 9 insertions(+), 10 deletions(-)
> 
> diff --git a/mm/page-writeback.c b/mm/page-writeback.c
> index c7983ea3040be4..70f42fd9a95b5d 100644
> --- a/mm/page-writeback.c
> +++ b/mm/page-writeback.c
> @@ -2397,13 +2397,19 @@ static pgoff_t wbc_end(struct writeback_control *wbc)
>  	return wbc->range_end >> PAGE_SHIFT;
>  }
>  
> -static void writeback_get_batch(struct address_space *mapping,
> +static struct folio *writeback_get_next(struct address_space *mapping,
>  		struct writeback_control *wbc)
>  {
> +	struct folio *folio = folio_batch_next(&wbc->fbatch);
> +
> +	if (folio)
> +		return folio;
> +
>  	folio_batch_release(&wbc->fbatch);
>  	cond_resched();
>  	filemap_get_folios_tag(mapping, &wbc->index, wbc_end(wbc),
>  			wbc_to_tag(wbc), &wbc->fbatch);
> +	return folio_batch_next(&wbc->fbatch);
>  }
>  
>  static bool should_writeback_folio(struct address_space *mapping,
> @@ -2473,7 +2479,6 @@ int write_cache_pages(struct address_space *mapping,
>  {
>  	int error;
>  	pgoff_t end;		/* Inclusive */
> -	int i = 0;
>  
>  	if (wbc->range_cyclic) {
>  		wbc->index = mapping->writeback_index; /* prev offset */
> @@ -2489,18 +2494,12 @@ int write_cache_pages(struct address_space *mapping,
>  	wbc->err = 0;
>  
>  	for (;;) {
> -		struct folio *folio;
> +		struct folio *folio = writeback_get_next(mapping, wbc);
>  		unsigned long nr;
>  
> -		if (i == wbc->fbatch.nr) {
> -			writeback_get_batch(mapping, wbc);
> -			i = 0;
> -		}
> -		if (wbc->fbatch.nr == 0)
> +		if (!folio)
>  			break;
>  
> -		folio = wbc->fbatch.folios[i++];
> -
>  		folio_lock(folio);
>  		if (!should_writeback_folio(mapping, wbc, folio)) {
>  			folio_unlock(folio);
> -- 
> 2.39.2
> 
-- 
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux