bcachefs: refactor fiemap processing into extent helper and struct
authorBrian Foster <bfoster@redhat.com>
Mon, 15 Jan 2024 19:27:49 +0000 (14:27 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Thu, 24 Apr 2025 23:10:29 +0000 (19:10 -0400)
commit2d55a637095d0eaaad609b8a518589ead34487b3
tree5803dd390ebb3a2a7cf6877bb4315c8e944c909b
parentd020a9fb11bd85f4f16392e2a44c46ae9778b3ee
bcachefs: refactor fiemap processing into extent helper and struct

The bulk of the loop in bch2_fiemap() involves processing the
current extent key from the iter, including following indirections
and trimming the extent size and such. This patch makes a few
changes to reduce the size of the loop and facilitate future changes
to support delalloc extents.

Define a new bch_fiemap_extent structure to wrap the bkey buffer
that holds the extent key to report to userspace along with
associated fiemap flags. Update bch2_fill_extent() to take the
bch_fiemap_extent as a param instead of the individual fields.
Finally, lift the bulk of the extent processing into a
bch2_fiemap_extent() helper that takes the current key and formats
the bch_fiemap_extent appropriately for the fill function.

No functional changes intended by this patch.

Signed-off-by: Brian Foster <bfoster@redhat.com>
fs/bcachefs/fs.c