Re: [PATCH 1/5] btrfs: factor out dirty-clearing part of btrfs_clear_buffer_dirty

Qu Wenruo <[email protected]>
Newsgroups org.kernel.vger.linux-btrfs
Message-ID <[email protected]>

在 2026/7/16 21:26, Johannes Thumshirn 写道:
> Split the dirty-clearing part of btrfs_clear_buffer_dirty() into a helper so
> a later caller can reuse it while bypassing the zoned zero-out deferral.
> No functional change.

I'd prefer fold this patch into the user.

> 
> Signed-off-by: Johannes Thumshirn <[email protected]>
> ---
>   fs/btrfs/extent_io.c | 47 +++++++++++++++++++++++++-------------------
>   1 file changed, 27 insertions(+), 20 deletions(-)
> 
> diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
> index 647b109ef61b..4dd8fc5ad247 100644
> --- a/fs/btrfs/extent_io.c
> +++ b/fs/btrfs/extent_io.c
> @@ -3788,6 +3788,32 @@ void free_extent_buffer_stale(struct extent_buffer *eb)
>   	release_extent_buffer(eb);
>   }
>   
> +static void __btrfs_clear_buffer_dirty(struct extent_buffer *eb)

Not sure if we still allow double underline function names.

Thanks,
Qu

> +{
> +	struct btrfs_fs_info *fs_info = eb->fs_info;
> +
> +	if (!test_and_clear_bit(EXTENT_BUFFER_DIRTY, &eb->bflags))
> +		return;
> +
> +	buffer_tree_clear_mark(eb, PAGECACHE_TAG_DIRTY);
> +	percpu_counter_add_batch(&fs_info->dirty_metadata_bytes, -(s64)eb->len,
> +				 fs_info->dirty_metadata_batch);
> +
> +	for (int i = 0; i < num_extent_folios(eb); i++) {
> +		struct folio *folio = eb->folios[i];
> +		bool last;
> +
> +		if (!folio_test_dirty(folio))
> +			continue;
> +		folio_lock(folio);
> +		last = btrfs_meta_folio_clear_and_test_dirty(folio, eb);
> +		if (last)
> +			btrfs_clear_folio_dirty_tag(folio);
> +		folio_unlock(folio);
> +	}
> +	WARN_ON(refcount_read(&eb->refs) == 0);
> +}
> +
>   void btrfs_clear_buffer_dirty(struct btrfs_trans_handle *trans,
>   			      struct extent_buffer *eb)
>   {
> @@ -3812,26 +3838,7 @@ void btrfs_clear_buffer_dirty(struct btrfs_trans_handle *trans,
>   		return;
>   	}
>   
> -	if (!test_and_clear_bit(EXTENT_BUFFER_DIRTY, &eb->bflags))
> -		return;
> -
> -	buffer_tree_clear_mark(eb, PAGECACHE_TAG_DIRTY);
> -	percpu_counter_add_batch(&fs_info->dirty_metadata_bytes, -(s64)eb->len,
> -				 fs_info->dirty_metadata_batch);
> -
> -	for (int i = 0; i < num_extent_folios(eb); i++) {
> -		struct folio *folio = eb->folios[i];
> -		bool last;
> -
> -		if (!folio_test_dirty(folio))
> -			continue;
> -		folio_lock(folio);
> -		last = btrfs_meta_folio_clear_and_test_dirty(folio, eb);
> -		if (last)
> -			btrfs_clear_folio_dirty_tag(folio);
> -		folio_unlock(folio);
> -	}
> -	WARN_ON(refcount_read(&eb->refs) == 0);
> +	__btrfs_clear_buffer_dirty(eb);
>   }
>   
>   void set_extent_buffer_dirty(struct extent_buffer *eb)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.