]> git.baikalelectronics.ru Git - kernel.git/commit
btrfs: move common NOCOW checks against a file extent into a helper
authorFilipe Manana <fdmanana@suse.com>
Wed, 30 Mar 2022 14:31:06 +0000 (15:31 +0100)
committerDavid Sterba <dsterba@suse.com>
Mon, 16 May 2022 15:03:11 +0000 (17:03 +0200)
commitd119c9f57d2f4a4c97f4819facb99b4f07f09295
tree5d3a2354640d652579d1510c3e66b574dafeb473
parentc35a32c35a5264820e191e28dd28c1f52ea0c4f7
btrfs: move common NOCOW checks against a file extent into a helper

Verifying if we can do a NOCOW write against a range fully or partially
covered by a file extent item requires verifying several constraints, and
these are currently duplicated at two different places: can_nocow_extent()
and run_delalloc_nocow().

This change moves those checks into a common helper function to avoid
duplication. It adds some comments and also preserves all existing
behaviour like for example can_nocow_extent() treating errors from the
calls to btrfs_cross_ref_exist() and csum_exist_in_range() as meaning
we can not NOCOW, instead of propagating the error back to the caller.
That specific behaviour is questionable but also reasonable to some
degree.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/inode.c