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: Josef Bacik <jbacik@fusionio.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
This commit is contained in:
parent
b76bb70136
commit
8ca15e05e6
@ -36,16 +36,23 @@ static int check_extent_in_eb(struct btrfs_key *key, struct extent_buffer *eb,
|
||||
u64 extent_item_pos,
|
||||
struct extent_inode_elem **eie)
|
||||
{
|
||||
u64 data_offset;
|
||||
u64 data_len;
|
||||
u64 offset = 0;
|
||||
struct extent_inode_elem *e;
|
||||
|
||||
data_offset = btrfs_file_extent_offset(eb, fi);
|
||||
data_len = btrfs_file_extent_num_bytes(eb, fi);
|
||||
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_len;
|
||||
|
||||
if (extent_item_pos < data_offset ||
|
||||
extent_item_pos >= data_offset + data_len)
|
||||
return 1;
|
||||
data_offset = btrfs_file_extent_offset(eb, fi);
|
||||
data_len = btrfs_file_extent_num_bytes(eb, fi);
|
||||
|
||||
if (extent_item_pos < data_offset ||
|
||||
extent_item_pos >= data_offset + data_len)
|
||||
return 1;
|
||||
offset = extent_item_pos - data_offset;
|
||||
}
|
||||
|
||||
e = kmalloc(sizeof(*e), GFP_NOFS);
|
||||
if (!e)
|
||||
@ -53,7 +60,7 @@ static int check_extent_in_eb(struct btrfs_key *key, struct extent_buffer *eb,
|
||||
|
||||
e->next = *eie;
|
||||
e->inum = key->objectid;
|
||||
e->offset = key->offset + (extent_item_pos - data_offset);
|
||||
e->offset = key->offset + offset;
|
||||
*eie = e;
|
||||
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user