Btrfs: wrap repeated code into scrub_blocked_if_needed()
Just wrap same code into one function scrub_blocked_if_needed(). This make a change that we will move waiting (@workers_pending = 0) before we can wake up commiting transaction(atomic_inc(@scrub_paused)), we must take carefully to not deadlock here. Thread 1 Thread 2 |->btrfs_commit_transaction() |->set trans type(COMMIT_DOING) |->btrfs_scrub_paused()(blocked) |->join_transaction(blocked) Move btrfs_scrub_paused() before setting trans type which means we can still join a transaction when commiting_transaction is blocked. Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com> Suggested-by: Miao Xie <miaox@cn.fujitsu.com> Signed-off-by: Josef Bacik <jbacik@fb.com> Signed-off-by: Chris Mason <clm@fb.com>
This commit is contained in:

committed by
Chris Mason

parent
3cb0929ad2
commit
cb7ab02156
@@ -1748,6 +1748,8 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
|
||||
goto cleanup_transaction;
|
||||
|
||||
btrfs_wait_delalloc_flush(root->fs_info);
|
||||
|
||||
btrfs_scrub_pause(root);
|
||||
/*
|
||||
* Ok now we need to make sure to block out any other joins while we
|
||||
* commit the transaction. We could have started a join before setting
|
||||
@@ -1812,7 +1814,6 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
|
||||
|
||||
WARN_ON(cur_trans != trans->transaction);
|
||||
|
||||
btrfs_scrub_pause(root);
|
||||
/* btrfs_commit_tree_roots is responsible for getting the
|
||||
* various roots consistent with each other. Every pointer
|
||||
* in the tree of tree roots has to point to the most up to date
|
||||
|
Reference in New Issue
Block a user