path: root/file-item.c
diff options
authorJosef Bacik <>2014-01-07 15:19:35 -0500
committerChris Mason <>2014-01-31 08:22:15 -0800
commit70749a77fe2b1c69d2ebe732de0d0ae53b967171 (patch)
tree9d750cf2568195033aeba0dd803fb52a7a2b8e2e /file-item.c
parentd04707f78735d6bb119a2d088f99547949a65f3c (diff)
Btrfs-progs: deal with invalid key orderings and bad orphan items V2
A user had a fs where the objectid of an orphan item was not the actual orphan item objectid. This screwed up fsck because the block has keys in the wrong order, also the fs scanning stuff will freak out because we have an inode with nlink 0 and no orphan item. So this patch is pretty big but is all related. 1) Deal with bad key ordering. We can easily fix this up, so fix the checking stuff to tell us exactly what it found when it said there was a problem. Then if it's bad key ordering we can reorder the keys and restart the scan. 2) Deal with bad keys. If we find an orphan item with the wrong objectid it's likely to screw with stuff, so keep track of these sort of things with a bad_item list and just run through and delete any objects that don't make sense. So far we just do this for orphan items but we could extend this as new stuff pops up. 3) Deal with missing orphan items. This is easy, if we have a file with i_nlink set to 0 and no orphan item we can just add an orphan item. 4) Add the infrastructure to corrupt actual key values. Needed this to create a test image to verify I was fixing things properly. This patch fixes the corrupt image I'm adding and passes the other make test tests. Thanks, Signed-off-by: Josef Bacik <> Signed-off-by: David Sterba <> Signed-off-by: Chris Mason <>
Diffstat (limited to 'file-item.c')
1 files changed, 1 insertions, 1 deletions
diff --git a/file-item.c b/file-item.c
index f53a5cab..6f3708b8 100644
--- a/file-item.c
+++ b/file-item.c
@@ -367,7 +367,7 @@ static noinline int truncate_one_csum(struct btrfs_trans_handle *trans,
key->offset = end_byte;
- ret = btrfs_set_item_key_safe(trans, root, path, key);
+ ret = btrfs_set_item_key_safe(root, path, key);
} else {