mirror of
https://github.com/torvalds/linux.git
synced 2026-11-06 21:58:01 +01:00
btrfs: qgroup: fix swapped blocks existence check when tracing after COW
In btrfs_qgroup_trace_subtree_after_cow(), after we erase the swapped
block, iterate over all possible tree levels to check if we sill have
other swapped blocks. However the check is wrong, it considers that there
are other swapped blocks if any rbtree for any level is empty, instead of
not empty. As a consequence we set blocks->swapped to true basically every
time since we always find an empty rbtree at least at level 7, since in
practice it's nearly impossible to find such a huge btree. This makes
every future call to btrfs_qgroup_trace_subtree_after_cow() do an
unnecessary rbtree search instead of returning immediately.
Fix this by updating the condition to set swapped to true if we find an
rbtree that is not empty.
Fixes: f616f5cd9d ("btrfs: qgroup: Use delayed subtree rescan for balance")
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
9421d1897b
commit
0388b5bd3a
|
|
@ -160,7 +160,7 @@ enum {
|
|||
*/
|
||||
struct btrfs_qgroup_swapped_blocks {
|
||||
spinlock_t lock;
|
||||
/* RM_EMPTY_ROOT() of above blocks[] */
|
||||
/* True if any of the rbtrees in the blocks array below is not empty. */
|
||||
bool swapped;
|
||||
struct rb_root blocks[BTRFS_MAX_LEVEL];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -4913,7 +4913,7 @@ int btrfs_qgroup_trace_subtree_after_cow(struct btrfs_trans_handle *trans,
|
|||
/* Found one, remove it from @blocks first and update blocks->swapped */
|
||||
rb_erase(&block->node, &blocks->blocks[level]);
|
||||
for (i = 0; i < BTRFS_MAX_LEVEL; i++) {
|
||||
if (RB_EMPTY_ROOT(&blocks->blocks[i])) {
|
||||
if (!RB_EMPTY_ROOT(&blocks->blocks[i])) {
|
||||
swapped = true;
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user