Skip to content

Commit b39c8f5

Browse files
josefbacikkdave
authored andcommitted
btrfs: fix ref-verify to catch operations on 0 ref extents
While debugging I noticed I wasn't getting ref verify errors before everything blew up. Turns out it's because we don't warn when we try to add a normal ref via btrfs_inc_ref() if the block entry exists but has 0 references. This is incorrect, we should never be doing anything other than adding a new extent once a block entry drops to 0 references. Signed-off-by: Josef Bacik <josef@toxicpanda.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 0a8068a commit b39c8f5

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

fs/btrfs/ref-verify.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -803,6 +803,15 @@ int btrfs_ref_tree_mod(struct btrfs_fs_info *fs_info,
803803
kfree(ref);
804804
kfree(ra);
805805
goto out_unlock;
806+
} else if (be->num_refs == 0) {
807+
btrfs_err(fs_info,
808+
"trying to do action %d for a bytenr that has 0 total references",
809+
action);
810+
dump_block_entry(fs_info, be);
811+
dump_ref_action(fs_info, ra);
812+
kfree(ref);
813+
kfree(ra);
814+
goto out_unlock;
806815
}
807816

808817
if (!parent) {

0 commit comments

Comments
 (0)