Commit e7b854b1 authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: fiemap fixes

 - fiemap didn't know about inline extents, fixed
 - advancing to the next extent after we'd chased a pointer to the
   reflink btree was wrong, fixed
Signed-off-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 645d72aa
...@@ -831,7 +831,7 @@ static int bch2_fill_extent(struct bch_fs *c, ...@@ -831,7 +831,7 @@ static int bch2_fill_extent(struct bch_fs *c,
struct fiemap_extent_info *info, struct fiemap_extent_info *info,
struct bkey_s_c k, unsigned flags) struct bkey_s_c k, unsigned flags)
{ {
if (bkey_extent_is_data(k.k)) { if (bkey_extent_is_direct_data(k.k)) {
struct bkey_ptrs_c ptrs = bch2_bkey_ptrs_c(k); struct bkey_ptrs_c ptrs = bch2_bkey_ptrs_c(k);
const union bch_extent_entry *entry; const union bch_extent_entry *entry;
struct extent_ptr_decoded p; struct extent_ptr_decoded p;
...@@ -862,6 +862,12 @@ static int bch2_fill_extent(struct bch_fs *c, ...@@ -862,6 +862,12 @@ static int bch2_fill_extent(struct bch_fs *c,
} }
return 0; return 0;
} else if (bkey_extent_is_inline_data(k.k)) {
return fiemap_fill_next_extent(info,
bkey_start_offset(k.k) << 9,
0, k.k->size << 9,
flags|
FIEMAP_EXTENT_DATA_INLINE);
} else if (k.k->type == KEY_TYPE_reservation) { } else if (k.k->type == KEY_TYPE_reservation) {
return fiemap_fill_next_extent(info, return fiemap_fill_next_extent(info,
bkey_start_offset(k.k) << 9, bkey_start_offset(k.k) << 9,
...@@ -928,7 +934,6 @@ static int bch2_fiemap(struct inode *vinode, struct fiemap_extent_info *info, ...@@ -928,7 +934,6 @@ static int bch2_fiemap(struct inode *vinode, struct fiemap_extent_info *info,
sectors = min(sectors, k.k->size - offset_into_extent); sectors = min(sectors, k.k->size - offset_into_extent);
if (offset_into_extent)
bch2_cut_front(POS(k.k->p.inode, bch2_cut_front(POS(k.k->p.inode,
bkey_start_offset(k.k) + bkey_start_offset(k.k) +
offset_into_extent), offset_into_extent),
...@@ -947,10 +952,8 @@ static int bch2_fiemap(struct inode *vinode, struct fiemap_extent_info *info, ...@@ -947,10 +952,8 @@ static int bch2_fiemap(struct inode *vinode, struct fiemap_extent_info *info,
bkey_copy(prev.k, cur.k); bkey_copy(prev.k, cur.k);
have_extent = true; have_extent = true;
if (k.k->type == KEY_TYPE_reflink_v) bch2_btree_iter_set_pos(iter,
bch2_btree_iter_set_pos(iter, k.k->p); POS(iter->pos.inode, iter->pos.offset + sectors));
else
bch2_btree_iter_next(iter);
} }
if (ret == -EINTR) if (ret == -EINTR)
......
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