Skip to content

Commit c5304dd

Browse files
committed
Merge tag 'for-5.7-rc1-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux
Pull btrfs fix from David Sterba: "A regression fix for a warning caused by running balance and snapshot creation in parallel" * tag 'for-5.7-rc1-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux: btrfs: fix setting last_trans for reloc roots
2 parents 5a32fe4 + aec7db3 commit c5304dd

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

fs/btrfs/relocation.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1527,8 +1527,7 @@ int btrfs_init_reloc_root(struct btrfs_trans_handle *trans,
15271527
int clear_rsv = 0;
15281528
int ret;
15291529

1530-
if (!rc || !rc->create_reloc_tree ||
1531-
root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID)
1530+
if (!rc)
15321531
return 0;
15331532

15341533
/*
@@ -1538,12 +1537,28 @@ int btrfs_init_reloc_root(struct btrfs_trans_handle *trans,
15381537
if (reloc_root_is_dead(root))
15391538
return 0;
15401539

1540+
/*
1541+
* This is subtle but important. We do not do
1542+
* record_root_in_transaction for reloc roots, instead we record their
1543+
* corresponding fs root, and then here we update the last trans for the
1544+
* reloc root. This means that we have to do this for the entire life
1545+
* of the reloc root, regardless of which stage of the relocation we are
1546+
* in.
1547+
*/
15411548
if (root->reloc_root) {
15421549
reloc_root = root->reloc_root;
15431550
reloc_root->last_trans = trans->transid;
15441551
return 0;
15451552
}
15461553

1554+
/*
1555+
* We are merging reloc roots, we do not need new reloc trees. Also
1556+
* reloc trees never need their own reloc tree.
1557+
*/
1558+
if (!rc->create_reloc_tree ||
1559+
root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID)
1560+
return 0;
1561+
15471562
if (!trans->reloc_reserved) {
15481563
rsv = trans->block_rsv;
15491564
trans->block_rsv = rc->block_rsv;

0 commit comments

Comments
 (0)