Skip to content

Commit 1708cc5

Browse files
Wang ShilongChris Mason
authored andcommitted
Btrfs: fix an oops when we fail to relocate tree blocks
During balance test, we hit an oops: [ 2013.841551] kernel BUG at fs/btrfs/relocation.c:1174! The problem is that if we fail to relocate tree blocks, we should update backref cache, otherwise, some pending nodes are not updated while snapshot check @cache->last_trans is within one transaction and won't update it and then oops happen. Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com> Signed-off-by: Josef Bacik <jbacik@fb.com> Signed-off-by: Chris Mason <clm@fb.com>
1 parent e77751a commit 1708cc5

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

‎fs/btrfs/relocation.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4009,6 +4009,12 @@ static noinline_for_stack int relocate_block_group(struct reloc_control *rc)
40094009
if (!RB_EMPTY_ROOT(&blocks)) {
40104010
ret = relocate_tree_blocks(trans, rc, &blocks);
40114011
if (ret < 0) {
4012+
/*
4013+
* if we fail to relocate tree blocks, force to update
4014+
* backref cache when committing transaction.
4015+
*/
4016+
rc->backref_cache.last_trans = trans->transid - 1;
4017+
40124018
if (ret != -EAGAIN) {
40134019
err = ret;
40144020
break;

0 commit comments

Comments
 (0)