We need to stop any other delayed refs flushing operations from happening if we're flushing delayed refs for transaction commit as we don't want the lock contention to make everything go slower, especially the transaction commit. Signed-off-by: Josef Bacik <josef@xxxxxxxxxxxxxx> --- fs/btrfs/transaction.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index 53af0f55f5f9..cff767722a75 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c @@ -2037,6 +2037,13 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans) btrfs_trans_release_metadata(trans); trans->block_rsv = NULL; + /* + * set the flushing flag so procs in this transaction have to + * start sending their work down. + */ + cur_trans->delayed_refs.flushing = 1; + smp_wmb(); + /* make a pass through all the delayed refs we have so far * any runnings procs may add more while we are here */ @@ -2048,13 +2055,6 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans) cur_trans = trans->transaction; - /* - * set the flushing flag so procs in this transaction have to - * start sending their work down. - */ - cur_trans->delayed_refs.flushing = 1; - smp_wmb(); - btrfs_create_pending_block_groups(trans); ret = btrfs_run_delayed_refs(trans, 0); -- 2.24.1
