]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
btrfs: initialize inode::file_extent_tree after i_mode has been set
authoraustinchang <austinchang@synology.com>
Thu, 11 Sep 2025 06:06:29 +0000 (06:06 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Sep 2025 09:16:46 +0000 (11:16 +0200)
commite8f496001e0c7832d188ab91fea294e19a128202
treeefe4ddad426b5e29c043891b31abff3670c4b8ef
parent8ae09726773a5a01fc5206e7b9beec8c3c512091
btrfs: initialize inode::file_extent_tree after i_mode has been set

commit 8679d2687c351824d08cf1f0e86f3b65f22a00fe upstream.

btrfs_init_file_extent_tree() uses S_ISREG() to determine if the file is
a regular file. In the beginning of btrfs_read_locked_inode(), the i_mode
hasn't been read from inode item, then file_extent_tree won't be used at
all in volumes without NO_HOLES.

Fix this by calling btrfs_init_file_extent_tree() after i_mode is
initialized in btrfs_read_locked_inode().

Fixes: 3d7db6e8bd22e6 ("btrfs: don't allocate file extent tree for non regular files")
CC: stable@vger.kernel.org # 6.12+
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: austinchang <austinchang@synology.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/btrfs/delayed-inode.c
fs/btrfs/inode.c