* [PATCH] btrfs: fix ref-verify to catch operations on 0 ref extents
@ 2020-03-11 15:21 Josef Bacik
0 siblings, 0 replies; only message in thread
From: Josef Bacik @ 2020-03-11 15:21 UTC (permalink / raw)
To: linux-btrfs, kernel-team
I was trying to debug something stupid I did and 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. With this fix it blew
up when I did the stupid thing, and was able to undo my stupid thing.
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
fs/btrfs/ref-verify.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/fs/btrfs/ref-verify.c b/fs/btrfs/ref-verify.c
index 454a1015d026..679464e5f06a 100644
--- a/fs/btrfs/ref-verify.c
+++ b/fs/btrfs/ref-verify.c
@@ -803,6 +803,14 @@ int btrfs_ref_tree_mod(struct btrfs_fs_info *fs_info,
kfree(ref);
kfree(ra);
goto out_unlock;
+ } else if (be->num_refs == 0) {
+ btrfs_err(fs_info,
+"trying to do action %d for a bytenr that has 0 total references", action);
+ dump_block_entry(fs_info, be);
+ dump_ref_action(fs_info, ra);
+ kfree(ref);
+ kfree(ra);
+ goto out_unlock;
}
if (!parent) {
--
2.24.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2020-03-11 15:21 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-11 15:21 [PATCH] btrfs: fix ref-verify to catch operations on 0 ref extents Josef Bacik
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).