summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZach Brown <zab@redhat.com>2013-08-14 16:16:38 -0700
committerDavid Sterba <dsterba@suse.cz>2013-09-03 19:41:06 +0200
commit47c072c2d85a786c5290e0bc5d2e3110bc806ca1 (patch)
tree6e9573ed1fe0da7ba9eecc0dba656958c75acfee
parent2cd95f945a61c433bd8a2ac6be2909009ae69e20 (diff)
btrfs-progs: fix extent key endian bug in repair
Extents rebuilt from backrefs can have their objectid mangled. The code tried to build a disk_key by hand and got the swabbing backwards. Signed-off-by: Zach Brown <zab@redhat.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
-rw-r--r--cmds-check.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/cmds-check.c b/cmds-check.c
index 2318aed5..2d5162c8 100644
--- a/cmds-check.c
+++ b/cmds-check.c
@@ -3931,9 +3931,12 @@ static int record_extent(struct btrfs_trans_handle *trans,
bi = (struct btrfs_tree_block_info *)(ei + 1);
memset_extent_buffer(leaf, 0, (unsigned long)bi,
sizeof(*bi));
- memset(&copy_key, 0, sizeof(copy_key));
- copy_key.objectid = le64_to_cpu(rec->info_objectid);
+ btrfs_set_disk_key_objectid(&copy_key,
+ rec->info_objectid);
+ btrfs_set_disk_key_type(&copy_key, 0);
+ btrfs_set_disk_key_offset(&copy_key, 0);
+
btrfs_set_tree_block_level(leaf, bi, rec->info_level);
btrfs_set_tree_block_key(leaf, bi, &copy_key);