diff options
author | Josef Bacik <jbacik@fusionio.com> | 2013-11-13 21:11:49 -0500 |
---|---|---|
committer | Chris Mason <clm@fb.com> | 2014-01-28 16:19:21 -0500 |
commit | e20d6c5ba38d066c7dc0f7d3b68da14b9ae7fe37 (patch) | |
tree | c25250525b3580d0e6652e6053ad54d7bf97b26a | |
parent | 16e7549f045d33b0c5b0ebf19d08439e9221d40c (diff) |
Btrfs: fix check-integrity to look at the referenced data properly
We were looking at file_extent_num_bytes unconditionally when looking at
referenced data bytes, but this isn't correct for compression. Fix this by
checking the compression of the file extent we are and setting num_bytes to
disk_num_bytes in the case of compression so that we are marking the proper
bytes as referenced. This fixes check_int_data freaking out when running
btrfs/004. Thanks,
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Signed-off-by: Chris Mason <clm@fb.com>
-rw-r--r-- | fs/btrfs/check-integrity.c | 12 | ||||
-rw-r--r-- | fs/btrfs/ctree.h | 4 |
2 files changed, 12 insertions, 4 deletions
diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c index 131d82800b3a..160fb509d720 100644 --- a/fs/btrfs/check-integrity.c +++ b/fs/btrfs/check-integrity.c | |||
@@ -1456,10 +1456,14 @@ static int btrfsic_handle_extent_data( | |||
1456 | btrfsic_read_from_block_data(block_ctx, &file_extent_item, | 1456 | btrfsic_read_from_block_data(block_ctx, &file_extent_item, |
1457 | file_extent_item_offset, | 1457 | file_extent_item_offset, |
1458 | sizeof(struct btrfs_file_extent_item)); | 1458 | sizeof(struct btrfs_file_extent_item)); |
1459 | next_bytenr = btrfs_stack_file_extent_disk_bytenr(&file_extent_item) + | 1459 | next_bytenr = btrfs_stack_file_extent_disk_bytenr(&file_extent_item); |
1460 | btrfs_stack_file_extent_offset(&file_extent_item); | 1460 | if (btrfs_stack_file_extent_compression(&file_extent_item) == |
1461 | generation = btrfs_stack_file_extent_generation(&file_extent_item); | 1461 | BTRFS_COMPRESS_NONE) { |
1462 | num_bytes = btrfs_stack_file_extent_num_bytes(&file_extent_item); | 1462 | next_bytenr += btrfs_stack_file_extent_offset(&file_extent_item); |
1463 | num_bytes = btrfs_stack_file_extent_num_bytes(&file_extent_item); | ||
1464 | } else { | ||
1465 | num_bytes = btrfs_stack_file_extent_disk_num_bytes(&file_extent_item); | ||
1466 | } | ||
1463 | generation = btrfs_stack_file_extent_generation(&file_extent_item); | 1467 | generation = btrfs_stack_file_extent_generation(&file_extent_item); |
1464 | 1468 | ||
1465 | if (state->print_mask & BTRFSIC_PRINT_MASK_VERY_VERBOSE) | 1469 | if (state->print_mask & BTRFSIC_PRINT_MASK_VERY_VERBOSE) |
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 8be78f7d57e1..1aafccda05d1 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
@@ -2927,6 +2927,10 @@ BTRFS_SETGET_STACK_FUNCS(stack_file_extent_generation, | |||
2927 | struct btrfs_file_extent_item, generation, 64); | 2927 | struct btrfs_file_extent_item, generation, 64); |
2928 | BTRFS_SETGET_STACK_FUNCS(stack_file_extent_num_bytes, | 2928 | BTRFS_SETGET_STACK_FUNCS(stack_file_extent_num_bytes, |
2929 | struct btrfs_file_extent_item, num_bytes, 64); | 2929 | struct btrfs_file_extent_item, num_bytes, 64); |
2930 | BTRFS_SETGET_STACK_FUNCS(stack_file_extent_disk_num_bytes, | ||
2931 | struct btrfs_file_extent_item, disk_num_bytes, 64); | ||
2932 | BTRFS_SETGET_STACK_FUNCS(stack_file_extent_compression, | ||
2933 | struct btrfs_file_extent_item, compression, 8); | ||
2930 | 2934 | ||
2931 | static inline unsigned long | 2935 | static inline unsigned long |
2932 | btrfs_file_extent_inline_start(struct btrfs_file_extent_item *e) | 2936 | btrfs_file_extent_inline_start(struct btrfs_file_extent_item *e) |