Commit 8ca15e05 authored by Josef Bacik's avatar Josef Bacik Committed by Chris Mason

Btrfs: fix backref walking when we hit a compressed extent

If you do btrfs inspect-internal logical-resolve on a compressed extent that has
been partly overwritten it won't find anything.  This is because we try and
match the extent offset we've searched for based on the extent offset in the
data extent entry.  However this doesn't work for compressed extents because the
offsets are for the uncompressed size, not the compressed size.  So instead only
do this check if we are not compressed, that way we can get an actual entry for
the physical offset rather than nothing for compressed.  Thanks,
Signed-off-by: default avatarJosef Bacik <jbacik@fusionio.com>
Signed-off-by: default avatarChris Mason <chris.mason@fusionio.com>
parent b76bb701
...@@ -36,9 +36,14 @@ static int check_extent_in_eb(struct btrfs_key *key, struct extent_buffer *eb, ...@@ -36,9 +36,14 @@ static int check_extent_in_eb(struct btrfs_key *key, struct extent_buffer *eb,
u64 extent_item_pos, u64 extent_item_pos,
struct extent_inode_elem **eie) struct extent_inode_elem **eie)
{ {
u64 offset = 0;
struct extent_inode_elem *e;
if (!btrfs_file_extent_compression(eb, fi) &&
!btrfs_file_extent_encryption(eb, fi) &&
!btrfs_file_extent_other_encoding(eb, fi)) {
u64 data_offset; u64 data_offset;
u64 data_len; u64 data_len;
struct extent_inode_elem *e;
data_offset = btrfs_file_extent_offset(eb, fi); data_offset = btrfs_file_extent_offset(eb, fi);
data_len = btrfs_file_extent_num_bytes(eb, fi); data_len = btrfs_file_extent_num_bytes(eb, fi);
...@@ -46,6 +51,8 @@ static int check_extent_in_eb(struct btrfs_key *key, struct extent_buffer *eb, ...@@ -46,6 +51,8 @@ static int check_extent_in_eb(struct btrfs_key *key, struct extent_buffer *eb,
if (extent_item_pos < data_offset || if (extent_item_pos < data_offset ||
extent_item_pos >= data_offset + data_len) extent_item_pos >= data_offset + data_len)
return 1; return 1;
offset = extent_item_pos - data_offset;
}
e = kmalloc(sizeof(*e), GFP_NOFS); e = kmalloc(sizeof(*e), GFP_NOFS);
if (!e) if (!e)
...@@ -53,7 +60,7 @@ static int check_extent_in_eb(struct btrfs_key *key, struct extent_buffer *eb, ...@@ -53,7 +60,7 @@ static int check_extent_in_eb(struct btrfs_key *key, struct extent_buffer *eb,
e->next = *eie; e->next = *eie;
e->inum = key->objectid; e->inum = key->objectid;
e->offset = key->offset + (extent_item_pos - data_offset); e->offset = key->offset + offset;
*eie = e; *eie = e;
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment