]> git.hungrycats.org Git - linux/commitdiff
btrfs: new define for the inline extent data start
authorDavid Sterba <dsterba@suse.cz>
Thu, 24 Jul 2014 15:34:58 +0000 (17:34 +0200)
committerZygo Blaxell <zblaxell@serenity.furryterror.org>
Fri, 23 Jan 2015 13:14:54 +0000 (08:14 -0500)
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>
(cherry picked from commit 7ec20afbcb7b257aec82ea5d66e6b0b7499abaca)

fs/btrfs/ctree.c
fs/btrfs/ctree.h

index 6648da53686852701a5f307e89927c068937fcbd..d1a0885b4dc03867aab5b4d1f98a472b92053585 100644 (file)
@@ -4604,8 +4604,7 @@ void btrfs_truncate_item(struct btrfs_root *root, struct btrfs_path *path,
                                ptr = btrfs_item_ptr_offset(leaf, slot);
                                memmove_extent_buffer(leaf, ptr,
                                      (unsigned long)fi,
-                                     offsetof(struct btrfs_file_extent_item,
-                                                disk_bytenr));
+                                     BTRFS_FILE_EXTENT_INLINE_DATA_START);
                        }
                }
 
index cea9010a41775ac6e5828aea5823eacd236f2d47..5fc4373c95b16f6b181686135934fd20102a4986 100644 (file)
@@ -385,9 +385,11 @@ struct btrfs_header {
                                     sizeof(struct btrfs_key_ptr))
 #define __BTRFS_LEAF_DATA_SIZE(bs) ((bs) - sizeof(struct btrfs_header))
 #define BTRFS_LEAF_DATA_SIZE(r) (__BTRFS_LEAF_DATA_SIZE(r->nodesize))
+#define BTRFS_FILE_EXTENT_INLINE_DATA_START            \
+               (offsetof(struct btrfs_file_extent_item, disk_bytenr))
 #define BTRFS_MAX_INLINE_DATA_SIZE(r) (BTRFS_LEAF_DATA_SIZE(r) - \
                                        sizeof(struct btrfs_item) - \
-                                       offsetof(struct btrfs_file_extent_item, disk_bytenr))
+                                       BTRFS_FILE_EXTENT_INLINE_DATA_START)
 #define BTRFS_MAX_XATTR_SIZE(r)        (BTRFS_LEAF_DATA_SIZE(r) - \
                                 sizeof(struct btrfs_item) -\
                                 sizeof(struct btrfs_dir_item))
@@ -896,6 +898,8 @@ struct btrfs_file_extent_item {
        /*
         * disk space consumed by the extent, checksum blocks are included
         * in these numbers
+        *
+        * At this offset in the structure, the inline extent data start.
         */
        __le64 disk_bytenr;
        __le64 disk_num_bytes;
@@ -3043,14 +3047,12 @@ BTRFS_SETGET_STACK_FUNCS(stack_file_extent_compression,
 static inline unsigned long
 btrfs_file_extent_inline_start(struct btrfs_file_extent_item *e)
 {
-       unsigned long offset = (unsigned long)e;
-       offset += offsetof(struct btrfs_file_extent_item, disk_bytenr);
-       return offset;
+       return (unsigned long)e + BTRFS_FILE_EXTENT_INLINE_DATA_START;
 }
 
 static inline u32 btrfs_file_extent_calc_inline_size(u32 datasize)
 {
-       return offsetof(struct btrfs_file_extent_item, disk_bytenr) + datasize;
+       return BTRFS_FILE_EXTENT_INLINE_DATA_START + datasize;
 }
 
 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,
 static inline u32 btrfs_file_extent_inline_item_len(struct extent_buffer *eb,
                                                    struct btrfs_item *e)
 {
-       unsigned long offset;
-       offset = offsetof(struct btrfs_file_extent_item, disk_bytenr);
-       return btrfs_item_size(eb, e) - offset;
+       return btrfs_item_size(eb, e) - BTRFS_FILE_EXTENT_INLINE_DATA_START;
 }
 
 /* this returns the number of file bytes represented by the inline item.