summaryrefslogtreecommitdiff
path: root/ctree.h
diff options
context:
space:
mode:
authorFilipe David Borba Manana <fdmanana@gmail.com>2014-04-08 18:25:43 +0100
committerDavid Sterba <dsterba@suse.cz>2014-04-11 19:47:29 +0200
commitc17d0a73c11d7cdbdf1582408ec6d168876160ea (patch)
tree63e639784898055188a608ff08ab8f54bad79d62 /ctree.h
parentd2334781fde887ed4e541c6794970ae942f81f23 (diff)
downloadbtrfs-progs-c17d0a73c11d7cdbdf1582408ec6d168876160ea.tar.gz
Btrfs-progs: update btrfs_file_extent_inline_len to match kernel version
The following kernel commit changed the definition of the inline function btrfs_file_extent_inline_len(): commit 514ac8ad8793a097c0c9d89202c642479d6dfa34 Author: Chris Mason <clm@fb.com> Date: Fri Jan 3 21:07:00 2014 -0800 Btrfs: don't use ram_bytes for uncompressed inline items If we truncate an uncompressed inline item, ram_bytes isn't updated to reflect the new size. The fixe uses the size directly from the item header when reading uncompressed inlines, and also fixes truncate to update the size as it goes. Not having this new definition implies that the restore tool might misbehave when restoring files with an inline extent that got truncated on a kernel older than release 3.14. Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com> Signed-off-by: David Sterba <dsterba@suse.cz>
Diffstat (limited to 'ctree.h')
-rw-r--r--ctree.h31
1 files changed, 22 insertions, 9 deletions
diff --git a/ctree.h b/ctree.h
index 45f2faf..a4d2cd1 100644
--- a/ctree.h
+++ b/ctree.h
@@ -2094,15 +2094,6 @@ BTRFS_SETGET_STACK_FUNCS(stack_qgroup_limit_rsv_referenced,
BTRFS_SETGET_STACK_FUNCS(stack_qgroup_limit_rsv_exclusive,
struct btrfs_qgroup_limit_item, rsv_exclusive, 64);
-/* this returns the number of file bytes represented by the inline item.
- * If an item is compressed, this is the uncompressed size
- */
-static inline u32 btrfs_file_extent_inline_len(struct extent_buffer *eb,
- struct btrfs_file_extent_item *e)
-{
- return btrfs_file_extent_ram_bytes(eb, e);
-}
-
/*
* this returns the number of bytes used by the item on disk, minus the
* size of any extent headers. If a file is compressed on disk, this is
@@ -2116,6 +2107,28 @@ static inline u32 btrfs_file_extent_inline_item_len(struct extent_buffer *eb,
return btrfs_item_size(eb, e) - offset;
}
+/* this returns the number of file bytes represented by the inline item.
+ * If an item is compressed, this is the uncompressed size
+ */
+static inline u32 btrfs_file_extent_inline_len(struct extent_buffer *eb,
+ int slot,
+ struct btrfs_file_extent_item *fi)
+{
+ /*
+ * return the space used on disk if this item isn't
+ * compressed or encoded
+ */
+ if (btrfs_file_extent_compression(eb, fi) == 0 &&
+ btrfs_file_extent_encryption(eb, fi) == 0 &&
+ btrfs_file_extent_other_encoding(eb, fi) == 0) {
+ return btrfs_file_extent_inline_item_len(eb,
+ btrfs_item_nr(slot));
+ }
+
+ /* otherwise use the ram bytes field */
+ return btrfs_file_extent_ram_bytes(eb, fi);
+}
+
static inline u32 btrfs_level_size(struct btrfs_root *root, int level) {
if (level == 0)
return root->leafsize;