On Wed, Nov 21, 2018 at 02:05:43PM -0500, Josef Bacik wrote:
> We still need to do all of the accounting cleanup for pending block
> groups if we abort.  So set the ret to trans->aborted so if we aborted
> the cleanup happens and everybody is happy.
> 
> Reviewed-by: Omar Sandoval <[email protected]>
> Signed-off-by: Josef Bacik <[email protected]>
> ---
>  fs/btrfs/extent-tree.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
> index b9b829c8825c..90423b6749b7 100644
> --- a/fs/btrfs/extent-tree.c
> +++ b/fs/btrfs/extent-tree.c
> @@ -10500,11 +10500,17 @@ void btrfs_create_pending_block_groups(struct 
> btrfs_trans_handle *trans)
>       struct btrfs_root *extent_root = fs_info->extent_root;
>       struct btrfs_block_group_item item;
>       struct btrfs_key key;
> -     int ret = 0;
> +     int ret;
>  
>       if (!trans->can_flush_pending_bgs)
>               return;
>  
> +     /*
> +      * If we aborted the transaction with pending bg's we need to just
> +      * cleanup the list and carry on.
> +      */
> +     ret = trans->aborted;

The cleanup is suitable for a separate helper that does only

while (!list_empty(&trans->new_bgs)) {
        list_del_init(&block_group->bg_list);
        btrfs_delayed_refs_rsv_release(fs_info, 1);
}

and does not rely on the transaction->abort in a function with 'create'
in it's name.

The related part is in a separate patch that ab-uses the fact that
setting ->abort will trigger the cleanup.

https://patchwork.kernel.org/patch/10693081/ will then simply call the
halper instead of

+       /* This cleans up the pending block groups list properly. */
+       if (!trans->aborted)
+               trans->aborted = ret;
+       btrfs_create_pending_block_groups(trans);

Setting aborted to an error code anywhere else than
__btrfs_abort_transaction does not sound right as it misses the whole
report.

Reply via email to