Commit b6e9f16c authored by Nikolay Borisov's avatar Nikolay Borisov Committed by David Sterba

btrfs: replace open coded while loop with proper construct

btrfs_inc_block_group_ro wants to ensure that the current transaction is
not running dirty block groups, if it is it waits and loops again.
That logic is currently implemented using a goto label. Actually using
a proper do {} while() construct doesn't hurt readability nor does it
introduce excessive nesting and makes the relevant code stand out by
being encompassed in the loop construct. No functional changes.
Signed-off-by: default avatarNikolay Borisov <nborisov@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 20bbf20e
...@@ -2267,16 +2267,19 @@ int btrfs_inc_block_group_ro(struct btrfs_block_group *cache, ...@@ -2267,16 +2267,19 @@ int btrfs_inc_block_group_ro(struct btrfs_block_group *cache,
struct btrfs_trans_handle *trans; struct btrfs_trans_handle *trans;
u64 alloc_flags; u64 alloc_flags;
int ret; int ret;
bool dirty_bg_running;
again: do {
trans = btrfs_join_transaction(fs_info->extent_root); trans = btrfs_join_transaction(fs_info->extent_root);
if (IS_ERR(trans)) if (IS_ERR(trans))
return PTR_ERR(trans); return PTR_ERR(trans);
dirty_bg_running = false;
/* /*
* we're not allowed to set block groups readonly after the dirty * We're not allowed to set block groups readonly after the dirty
* block groups cache has started writing. If it already started, * block group cache has started writing. If it already started,
* back off and let this transaction commit * back off and let this transaction commit.
*/ */
mutex_lock(&fs_info->ro_block_group_mutex); mutex_lock(&fs_info->ro_block_group_mutex);
if (test_bit(BTRFS_TRANS_DIRTY_BG_RUN, &trans->transaction->flags)) { if (test_bit(BTRFS_TRANS_DIRTY_BG_RUN, &trans->transaction->flags)) {
...@@ -2288,8 +2291,9 @@ int btrfs_inc_block_group_ro(struct btrfs_block_group *cache, ...@@ -2288,8 +2291,9 @@ int btrfs_inc_block_group_ro(struct btrfs_block_group *cache,
ret = btrfs_wait_for_commit(fs_info, transid); ret = btrfs_wait_for_commit(fs_info, transid);
if (ret) if (ret)
return ret; return ret;
goto again; dirty_bg_running = true;
} }
} while (dirty_bg_running);
if (do_chunk_alloc) { if (do_chunk_alloc) {
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment