]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
btrfs: Get rid of the confusing btrfs_file_extent_inline_len
authorQu Wenruo <wqu@suse.com>
Wed, 6 Jun 2018 07:41:49 +0000 (15:41 +0800)
committerKhalid Elmously <khalid.elmously@canonical.com>
Fri, 13 Mar 2020 04:31:00 +0000 (00:31 -0400)
commit5149773bc37e28ba92f799616a374afc097903f0
tree4f9e981ae525859435206c2dd7f6e28eaca2bbe5
parent535b9c405a01e7bb5f716866264a4bad452cf15b
btrfs: Get rid of the confusing btrfs_file_extent_inline_len

BugLink: https://bugs.launchpad.net/bugs/1866678
[ Upstream commit e41ca5897489b1c18af75ff0cc8f5c80260b3281 ]

We used to call btrfs_file_extent_inline_len() to get the uncompressed
data size of an inlined extent.

However this function is hiding evil, for compressed extent, it has no
choice but to directly read out ram_bytes from btrfs_file_extent_item.
While for uncompressed extent, it uses item size to calculate the real
data size, and ignoring ram_bytes completely.

In fact, for corrupted ram_bytes, due to above behavior kernel
btrfs_print_leaf() can't even print correct ram_bytes to expose the bug.

Since we have the tree-checker to verify all EXTENT_DATA, such mismatch
can be detected pretty easily, thus we can trust ram_bytes without the
evil btrfs_file_extent_inline_len().

Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
fs/btrfs/ctree.h
fs/btrfs/file-item.c
fs/btrfs/file.c
fs/btrfs/inode.c
fs/btrfs/print-tree.c
fs/btrfs/send.c
fs/btrfs/tree-log.c
include/trace/events/btrfs.h