[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220418121204.075353134@linuxfoundation.org>
Date: Mon, 18 Apr 2022 14:09:45 +0200
From: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To: linux-kernel@...r.kernel.org
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
stable@...r.kernel.org,
Johannes Thumshirn <johannes.thumshirn@....com>,
Naohiro Aota <naohiro.aota@....com>,
David Sterba <dsterba@...e.com>
Subject: [PATCH 5.17 016/219] btrfs: return allocated block group from do_chunk_alloc()
From: Naohiro Aota <naohiro.aota@....com>
commit 820c363bd526ec8e133e4b84e6ad1fda12023b4b upstream.
Return the allocated block group from do_chunk_alloc(). This is a
preparation patch for the next patch.
CC: stable@...r.kernel.org # 5.16+
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@....com>
Tested-by: Johannes Thumshirn <johannes.thumshirn@....com>
Signed-off-by: Naohiro Aota <naohiro.aota@....com>
Signed-off-by: David Sterba <dsterba@...e.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
---
fs/btrfs/block-group.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
--- a/fs/btrfs/block-group.c
+++ b/fs/btrfs/block-group.c
@@ -3427,7 +3427,7 @@ int btrfs_force_chunk_alloc(struct btrfs
return btrfs_chunk_alloc(trans, alloc_flags, CHUNK_ALLOC_FORCE);
}
-static int do_chunk_alloc(struct btrfs_trans_handle *trans, u64 flags)
+static struct btrfs_block_group *do_chunk_alloc(struct btrfs_trans_handle *trans, u64 flags)
{
struct btrfs_block_group *bg;
int ret;
@@ -3514,7 +3514,11 @@ static int do_chunk_alloc(struct btrfs_t
out:
btrfs_trans_release_chunk_metadata(trans);
- return ret;
+ if (ret)
+ return ERR_PTR(ret);
+
+ btrfs_get_block_group(bg);
+ return bg;
}
/*
@@ -3629,6 +3633,7 @@ int btrfs_chunk_alloc(struct btrfs_trans
{
struct btrfs_fs_info *fs_info = trans->fs_info;
struct btrfs_space_info *space_info;
+ struct btrfs_block_group *ret_bg;
bool wait_for_alloc = false;
bool should_alloc = false;
int ret = 0;
@@ -3722,9 +3727,14 @@ int btrfs_chunk_alloc(struct btrfs_trans
force_metadata_allocation(fs_info);
}
- ret = do_chunk_alloc(trans, flags);
+ ret_bg = do_chunk_alloc(trans, flags);
trans->allocating_chunk = false;
+ if (IS_ERR(ret_bg))
+ ret = PTR_ERR(ret_bg);
+ else
+ btrfs_put_block_group(ret_bg);
+
spin_lock(&space_info->lock);
if (ret < 0) {
if (ret == -ENOSPC)
Powered by blists - more mailing lists