Commit 2a4d84c1 authored by Josef Bacik's avatar Josef Bacik Committed by David Sterba

btrfs: move delayed ref flushing for qgroup into qgroup helper

The commit d6726335 ("btrfs: qgroup: Make snapshot accounting work
with new extent-oriented qgroup.") added a flush of the delayed refs
during snapshot creation in order to get the qgroup accounting properly.
However this code has changed and been moved to it's own helper that is
skipped if qgroups are turned off.  Move the flushing to the helper, as
we do not need it when qgroups are turned off.

Also add a comment explaining why it exists, and why it doesn't actually
save us.  This will be helpful later when we try to fix qgroup
accounting properly.
Signed-off-by: default avatarJosef Bacik <josef@toxicpanda.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent ad368f33
...@@ -1432,6 +1432,23 @@ static int qgroup_account_snapshot(struct btrfs_trans_handle *trans, ...@@ -1432,6 +1432,23 @@ static int qgroup_account_snapshot(struct btrfs_trans_handle *trans,
*/ */
record_root_in_trans(trans, src, 1); record_root_in_trans(trans, src, 1);
/*
* btrfs_qgroup_inherit relies on a consistent view of the usage for the
* src root, so we must run the delayed refs here.
*
* However this isn't particularly fool proof, because there's no
* synchronization keeping us from changing the tree after this point
* before we do the qgroup_inherit, or even from making changes while
* we're doing the qgroup_inherit. But that's a problem for the future,
* for now flush the delayed refs to narrow the race window where the
* qgroup counters could end up wrong.
*/
ret = btrfs_run_delayed_refs(trans, (unsigned long)-1);
if (ret) {
btrfs_abort_transaction(trans, ret);
goto out;
}
/* /*
* We are going to commit transaction, see btrfs_commit_transaction() * We are going to commit transaction, see btrfs_commit_transaction()
* comment for reason locking tree_log_mutex * comment for reason locking tree_log_mutex
...@@ -1685,12 +1702,6 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans, ...@@ -1685,12 +1702,6 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
goto fail; goto fail;
} }
ret = btrfs_run_delayed_refs(trans, (unsigned long)-1);
if (ret) {
btrfs_abort_transaction(trans, ret);
goto fail;
}
/* /*
* Do special qgroup accounting for snapshot, as we do some qgroup * Do special qgroup accounting for snapshot, as we do some qgroup
* snapshot hack to do fast snapshot. * snapshot hack to do fast snapshot.
......
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