* [PATCH] btrfs: get rid of goto in alloc_test_extent_buffer()
@ 2025-04-25 7:23 Daniel Vacek
2025-04-25 11:39 ` David Sterba
0 siblings, 1 reply; 3+ messages in thread
From: Daniel Vacek @ 2025-04-25 7:23 UTC (permalink / raw)
To: Chris Mason, Josef Bacik, David Sterba
Cc: Daniel Vacek, linux-btrfs, linux-kernel
The `free_eb` label is used only once. Simplify by moving the code inplace.
Signed-off-by: Daniel Vacek <neelx@suse.com>
---
fs/btrfs/extent_io.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index ea38c73d4bc5f..20cdddd924852 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -3004,15 +3004,13 @@ struct extent_buffer *alloc_test_extent_buffer(struct btrfs_fs_info *fs_info,
goto again;
}
xa_unlock_irq(&fs_info->buffer_tree);
- goto free_eb;
+ btrfs_release_extent_buffer(eb);
+ return exists;
}
xa_unlock_irq(&fs_info->buffer_tree);
check_buffer_tree_ref(eb);
return eb;
-free_eb:
- btrfs_release_extent_buffer(eb);
- return exists;
#else
/* Stub to avoid linker error when compiled with optimizations turned off. */
return NULL;
--
2.47.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] btrfs: get rid of goto in alloc_test_extent_buffer()
2025-04-25 7:23 [PATCH] btrfs: get rid of goto in alloc_test_extent_buffer() Daniel Vacek
@ 2025-04-25 11:39 ` David Sterba
2025-04-30 14:23 ` David Sterba
0 siblings, 1 reply; 3+ messages in thread
From: David Sterba @ 2025-04-25 11:39 UTC (permalink / raw)
To: Daniel Vacek
Cc: Chris Mason, Josef Bacik, David Sterba, linux-btrfs, linux-kernel
On Fri, Apr 25, 2025 at 09:23:57AM +0200, Daniel Vacek wrote:
> The `free_eb` label is used only once. Simplify by moving the code inplace.
>
> Signed-off-by: Daniel Vacek <neelx@suse.com>
> ---
> fs/btrfs/extent_io.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
> index ea38c73d4bc5f..20cdddd924852 100644
> --- a/fs/btrfs/extent_io.c
> +++ b/fs/btrfs/extent_io.c
> @@ -3004,15 +3004,13 @@ struct extent_buffer *alloc_test_extent_buffer(struct btrfs_fs_info *fs_info,
> goto again;
> }
> xa_unlock_irq(&fs_info->buffer_tree);
> - goto free_eb;
> + btrfs_release_extent_buffer(eb);
> + return exists;
> }
> xa_unlock_irq(&fs_info->buffer_tree);
> check_buffer_tree_ref(eb);
>
> return eb;
> -free_eb:
> - btrfs_release_extent_buffer(eb);
So the xarray conversion removed the other use of the free_eb label and
calls btrfs_release_extent_buffer() + return. Doing the same here and
removing the label completely looks as an improvement, as the whole
function does direct returns instead of goto exit block.
Reviewed-by: David Sterba <dsterba@suse.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] btrfs: get rid of goto in alloc_test_extent_buffer()
2025-04-25 11:39 ` David Sterba
@ 2025-04-30 14:23 ` David Sterba
0 siblings, 0 replies; 3+ messages in thread
From: David Sterba @ 2025-04-30 14:23 UTC (permalink / raw)
To: David Sterba
Cc: Daniel Vacek, Chris Mason, Josef Bacik, David Sterba, linux-btrfs,
linux-kernel
On Fri, Apr 25, 2025 at 01:39:07PM +0200, David Sterba wrote:
> On Fri, Apr 25, 2025 at 09:23:57AM +0200, Daniel Vacek wrote:
> > The `free_eb` label is used only once. Simplify by moving the code inplace.
> >
> > Signed-off-by: Daniel Vacek <neelx@suse.com>
> > ---
> > fs/btrfs/extent_io.c | 6 ++----
> > 1 file changed, 2 insertions(+), 4 deletions(-)
> >
> > diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
> > index ea38c73d4bc5f..20cdddd924852 100644
> > --- a/fs/btrfs/extent_io.c
> > +++ b/fs/btrfs/extent_io.c
> > @@ -3004,15 +3004,13 @@ struct extent_buffer *alloc_test_extent_buffer(struct btrfs_fs_info *fs_info,
> > goto again;
> > }
> > xa_unlock_irq(&fs_info->buffer_tree);
> > - goto free_eb;
> > + btrfs_release_extent_buffer(eb);
> > + return exists;
> > }
> > xa_unlock_irq(&fs_info->buffer_tree);
> > check_buffer_tree_ref(eb);
> >
> > return eb;
> > -free_eb:
> > - btrfs_release_extent_buffer(eb);
>
> So the xarray conversion removed the other use of the free_eb label and
> calls btrfs_release_extent_buffer() + return. Doing the same here and
> removing the label completely looks as an improvement, as the whole
> function does direct returns instead of goto exit block.
>
> Reviewed-by: David Sterba <dsterba@suse.com>
Xarray conversion is now in for-next so I've added this patch too.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-04-30 14:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-25 7:23 [PATCH] btrfs: get rid of goto in alloc_test_extent_buffer() Daniel Vacek
2025-04-25 11:39 ` David Sterba
2025-04-30 14:23 ` David Sterba
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox