提交 617c54a8 编写于 作者: N Nikolay Borisov 提交者: David Sterba

btrfs: Make btrfs_async_run_delayed_root use a loop rather than multiple labels

Currently btrfs_async_run_delayed_root's implementation uses 3 goto
labels to mimic the functionality of a simple do {} while loop. Refactor
the function to use a do {} while construct, making intention clear and
code easier to follow. No functional changes.
Signed-off-by: NNikolay Borisov <nborisov@suse.com>
Reviewed-by: NQu Wenruo <wqu@suse.com>
Signed-off-by: NDavid Sterba <dsterba@suse.com>
上级 d3fac6ba
...@@ -1302,20 +1302,25 @@ static void btrfs_async_run_delayed_root(struct btrfs_work *work) ...@@ -1302,20 +1302,25 @@ static void btrfs_async_run_delayed_root(struct btrfs_work *work)
if (!path) if (!path)
goto out; goto out;
again: do {
if (atomic_read(&delayed_root->items) < BTRFS_DELAYED_BACKGROUND / 2) if (atomic_read(&delayed_root->items) <
goto free_path; BTRFS_DELAYED_BACKGROUND / 2)
break;
delayed_node = btrfs_first_prepared_delayed_node(delayed_root); delayed_node = btrfs_first_prepared_delayed_node(delayed_root);
if (!delayed_node) if (!delayed_node)
goto free_path; break;
path->leave_spinning = 1; path->leave_spinning = 1;
root = delayed_node->root; root = delayed_node->root;
trans = btrfs_join_transaction(root); trans = btrfs_join_transaction(root);
if (IS_ERR(trans)) if (IS_ERR(trans)) {
goto release_path; btrfs_release_path(path);
btrfs_release_prepared_delayed_node(delayed_node);
total_done++;
continue;
}
block_rsv = trans->block_rsv; block_rsv = trans->block_rsv;
trans->block_rsv = &root->fs_info->delayed_block_rsv; trans->block_rsv = &root->fs_info->delayed_block_rsv;
...@@ -1326,16 +1331,13 @@ static void btrfs_async_run_delayed_root(struct btrfs_work *work) ...@@ -1326,16 +1331,13 @@ static void btrfs_async_run_delayed_root(struct btrfs_work *work)
btrfs_end_transaction(trans); btrfs_end_transaction(trans);
btrfs_btree_balance_dirty_nodelay(root->fs_info); btrfs_btree_balance_dirty_nodelay(root->fs_info);
release_path:
btrfs_release_path(path); btrfs_release_path(path);
btrfs_release_prepared_delayed_node(delayed_node);
total_done++; total_done++;
btrfs_release_prepared_delayed_node(delayed_node); } while ((async_work->nr == 0 && total_done < BTRFS_DELAYED_WRITEBACK)
if ((async_work->nr == 0 && total_done < BTRFS_DELAYED_WRITEBACK) || || total_done < async_work->nr);
total_done < async_work->nr)
goto again;
free_path:
btrfs_free_path(path); btrfs_free_path(path);
out: out:
wake_up(&delayed_root->wait); wake_up(&delayed_root->wait);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册