diff options
author | David Sterba <dsterba@suse.cz> | 2014-07-24 11:34:58 -0400 |
---|---|---|
committer | David Sterba <dsterba@suse.cz> | 2014-10-02 11:30:33 -0400 |
commit | 7ec20afbcb7b257aec82ea5d66e6b0b7499abaca (patch) | |
tree | 0c6cb50c4827741419d7224bbd9663822609c712 /fs/btrfs | |
parent | fb85fc9a675738ee2746b51c3aedde944b18ca02 (diff) |
btrfs: new define for the inline extent data start
Use a common definition for the inline data start so we don't have to
open-code it and introduce bugs like "Btrfs: fix wrong max inline data
size limit" fixed.
Signed-off-by: David Sterba <dsterba@suse.cz>
Diffstat (limited to 'fs/btrfs')
-rw-r--r-- | fs/btrfs/ctree.c | 3 | ||||
-rw-r--r-- | fs/btrfs/ctree.h | 16 |
2 files changed, 9 insertions, 10 deletions
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index 39021bf2df9a..533657c508e2 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c | |||
@@ -4625,8 +4625,7 @@ void btrfs_truncate_item(struct btrfs_root *root, struct btrfs_path *path, | |||
4625 | ptr = btrfs_item_ptr_offset(leaf, slot); | 4625 | ptr = btrfs_item_ptr_offset(leaf, slot); |
4626 | memmove_extent_buffer(leaf, ptr, | 4626 | memmove_extent_buffer(leaf, ptr, |
4627 | (unsigned long)fi, | 4627 | (unsigned long)fi, |
4628 | offsetof(struct btrfs_file_extent_item, | 4628 | BTRFS_FILE_EXTENT_INLINE_DATA_START); |
4629 | disk_bytenr)); | ||
4630 | } | 4629 | } |
4631 | } | 4630 | } |
4632 | 4631 | ||
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index dd79ba7ee3ea..bae025a20e63 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
@@ -385,9 +385,11 @@ struct btrfs_header { | |||
385 | sizeof(struct btrfs_key_ptr)) | 385 | sizeof(struct btrfs_key_ptr)) |
386 | #define __BTRFS_LEAF_DATA_SIZE(bs) ((bs) - sizeof(struct btrfs_header)) | 386 | #define __BTRFS_LEAF_DATA_SIZE(bs) ((bs) - sizeof(struct btrfs_header)) |
387 | #define BTRFS_LEAF_DATA_SIZE(r) (__BTRFS_LEAF_DATA_SIZE(r->nodesize)) | 387 | #define BTRFS_LEAF_DATA_SIZE(r) (__BTRFS_LEAF_DATA_SIZE(r->nodesize)) |
388 | #define BTRFS_FILE_EXTENT_INLINE_DATA_START \ | ||
389 | (offsetof(struct btrfs_file_extent_item, disk_bytenr)) | ||
388 | #define BTRFS_MAX_INLINE_DATA_SIZE(r) (BTRFS_LEAF_DATA_SIZE(r) - \ | 390 | #define BTRFS_MAX_INLINE_DATA_SIZE(r) (BTRFS_LEAF_DATA_SIZE(r) - \ |
389 | sizeof(struct btrfs_item) - \ | 391 | sizeof(struct btrfs_item) - \ |
390 | offsetof(struct btrfs_file_extent_item, disk_bytenr)) | 392 | BTRFS_FILE_EXTENT_INLINE_DATA_START) |
391 | #define BTRFS_MAX_XATTR_SIZE(r) (BTRFS_LEAF_DATA_SIZE(r) - \ | 393 | #define BTRFS_MAX_XATTR_SIZE(r) (BTRFS_LEAF_DATA_SIZE(r) - \ |
392 | sizeof(struct btrfs_item) -\ | 394 | sizeof(struct btrfs_item) -\ |
393 | sizeof(struct btrfs_dir_item)) | 395 | sizeof(struct btrfs_dir_item)) |
@@ -896,6 +898,8 @@ struct btrfs_file_extent_item { | |||
896 | /* | 898 | /* |
897 | * disk space consumed by the extent, checksum blocks are included | 899 | * disk space consumed by the extent, checksum blocks are included |
898 | * in these numbers | 900 | * in these numbers |
901 | * | ||
902 | * At this offset in the structure, the inline extent data start. | ||
899 | */ | 903 | */ |
900 | __le64 disk_bytenr; | 904 | __le64 disk_bytenr; |
901 | __le64 disk_num_bytes; | 905 | __le64 disk_num_bytes; |
@@ -3043,14 +3047,12 @@ BTRFS_SETGET_STACK_FUNCS(stack_file_extent_compression, | |||
3043 | static inline unsigned long | 3047 | static inline unsigned long |
3044 | btrfs_file_extent_inline_start(struct btrfs_file_extent_item *e) | 3048 | btrfs_file_extent_inline_start(struct btrfs_file_extent_item *e) |
3045 | { | 3049 | { |
3046 | unsigned long offset = (unsigned long)e; | 3050 | return (unsigned long)e + BTRFS_FILE_EXTENT_INLINE_DATA_START; |
3047 | offset += offsetof(struct btrfs_file_extent_item, disk_bytenr); | ||
3048 | return offset; | ||
3049 | } | 3051 | } |
3050 | 3052 | ||
3051 | static inline u32 btrfs_file_extent_calc_inline_size(u32 datasize) | 3053 | static inline u32 btrfs_file_extent_calc_inline_size(u32 datasize) |
3052 | { | 3054 | { |
3053 | return offsetof(struct btrfs_file_extent_item, disk_bytenr) + datasize; | 3055 | return BTRFS_FILE_EXTENT_INLINE_DATA_START + datasize; |
3054 | } | 3056 | } |
3055 | 3057 | ||
3056 | BTRFS_SETGET_FUNCS(file_extent_disk_bytenr, struct btrfs_file_extent_item, | 3058 | BTRFS_SETGET_FUNCS(file_extent_disk_bytenr, struct btrfs_file_extent_item, |
@@ -3080,9 +3082,7 @@ BTRFS_SETGET_FUNCS(file_extent_other_encoding, struct btrfs_file_extent_item, | |||
3080 | static inline u32 btrfs_file_extent_inline_item_len(struct extent_buffer *eb, | 3082 | static inline u32 btrfs_file_extent_inline_item_len(struct extent_buffer *eb, |
3081 | struct btrfs_item *e) | 3083 | struct btrfs_item *e) |
3082 | { | 3084 | { |
3083 | unsigned long offset; | 3085 | return btrfs_item_size(eb, e) - BTRFS_FILE_EXTENT_INLINE_DATA_START; |
3084 | offset = offsetof(struct btrfs_file_extent_item, disk_bytenr); | ||
3085 | return btrfs_item_size(eb, e) - offset; | ||
3086 | } | 3086 | } |
3087 | 3087 | ||
3088 | /* this returns the number of file bytes represented by the inline item. | 3088 | /* this returns the number of file bytes represented by the inline item. |