diff mbox

[4/6] Btrfs: fix wrong max inline data size limit

Message ID 1405568654-22120-4-git-send-email-wangsl.fnst@cn.fujitsu.com (mailing list archive)
State Accepted
Headers show

Commit Message

Wang Shilong July 17, 2014, 3:44 a.m. UTC
inline data is stored from offset of @disk_bytenr in
struct btrfs_file_extent_item. So substracting total
size of struct btrfs_file_extent_item is wrong, fix it.

Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
---
 fs/btrfs/ctree.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

David Sterba July 24, 2014, 11:27 a.m. UTC | #1
On Thu, Jul 17, 2014 at 11:44:12AM +0800, Wang Shilong wrote:
> inline data is stored from offset of @disk_bytenr in
> struct btrfs_file_extent_item. So substracting total
> size of struct btrfs_file_extent_item is wrong, fix it.
> 
> Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>

Reviewed-by: David Sterba <dsterba@suse.cz>

>  #define BTRFS_MAX_INLINE_DATA_SIZE(r) (BTRFS_LEAF_DATA_SIZE(r) - \
>  					sizeof(struct btrfs_item) - \
> -					sizeof(struct btrfs_file_extent_item))
> +					offsetof(struct btrfs_file_extent_item, disk_bytenr))

This increases the limit of inline data by 24 bytes but fortunatelly
does not break existing filesystems because the
BTRFS_MAX_INLINE_DATA_SIZE is used at the time the inlining is decided.
IOW it is a bit pessimistic, the rest of the code uses the offsetof
value.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index be91397..22fbd04 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -394,7 +394,7 @@  struct btrfs_header {
 #define BTRFS_LEAF_DATA_SIZE(r) (__BTRFS_LEAF_DATA_SIZE(r->leafsize))
 #define BTRFS_MAX_INLINE_DATA_SIZE(r) (BTRFS_LEAF_DATA_SIZE(r) - \
 					sizeof(struct btrfs_item) - \
-					sizeof(struct btrfs_file_extent_item))
+					offsetof(struct btrfs_file_extent_item, disk_bytenr))
 #define BTRFS_MAX_XATTR_SIZE(r)	(BTRFS_LEAF_DATA_SIZE(r) - \
 				 sizeof(struct btrfs_item) -\
 				 sizeof(struct btrfs_dir_item))