Re: [RFC PATCH 7/8] btrfs: simplify return path via cleanup.h

From: David Sterba

Date: Thu Nov 13 2025 - 03:54:07 EST


On Thu, Nov 13, 2025 at 07:20:01AM +1030, Qu Wenruo wrote:
> > --- a/fs/btrfs/extent-tree.c
> > +++ b/fs/btrfs/extent-tree.c
> > @@ -1878,16 +1878,14 @@ static int cleanup_ref_head(struct btrfs_trans_handle *trans,
> > * and then re-check to make sure nobody got added.
> > */
> > spin_unlock(&head->lock);
> > - spin_lock(&delayed_refs->lock);
> > - spin_lock(&head->lock);
> > - if (!RB_EMPTY_ROOT(&head->ref_tree.rb_root) || head->extent_op) {
> > - spin_unlock(&head->lock);
> > - spin_unlock(&delayed_refs->lock);
> > - return 1;
> > + {
>
> There are some internal discussion about such anonymous code block usage.
>
> Although I support such usage, especially when it can reduce the
> lifespan of local variables, it's not a commonly accepted pattern yet.

And the discussion is going great, I think we wont't find a consensus
without somebody either missing a coding pattern (you) or suffering to
look at such code each time (me). Others have similar mixed feelings
about the guards use.