]> git.ipfire.org Git - thirdparty/linux.git/commit
btrfs: allocate btrfs_inode::file_extent_tree only without NO_HOLES
authorDavid Sterba <dsterba@suse.com>
Thu, 30 Nov 2023 22:42:01 +0000 (23:42 +0100)
committerDavid Sterba <dsterba@suse.com>
Fri, 15 Dec 2023 21:59:01 +0000 (22:59 +0100)
commit637e6e0f50d20dcf2f37d62b3f9edf9567b69503
tree7f2a599b4204a511f56e3684af9580697f79e2fc
parented9b50a13edf442f5493603cc54f73bfc6eca1e9
btrfs: allocate btrfs_inode::file_extent_tree only without NO_HOLES

The file_extent_tree was added in 41a2ee75aab0 ("btrfs: introduce
per-inode file extent tree") so we have an explicit mapping of the file
extents to know where it is safe to update i_size. When the feature
NO_HOLES is enabled, and it's been a mkfs default since 5.15, the tree
is not necessary.

To save some space in the inode, allocate the tree only when necessary.
This reduces size by 16 bytes from 1096 to 1080 on a x86_64 release
config.

Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/btrfs_inode.h
fs/btrfs/extent-io-tree.c
fs/btrfs/file-item.c
fs/btrfs/inode.c