From: Nikolay Borisov Date: Wed, 7 Feb 2018 09:19:10 +0000 (+0200) Subject: btrfs: Don't hardcode the csum size in btrfs_ordered_sum_size X-Git-Tag: v4.19~990^2~185 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=af89e0dc2ce3177d07c4af4028b8a7b88733d07e;p=platform%2Fkernel%2Flinux-rpi3.git btrfs: Don't hardcode the csum size in btrfs_ordered_sum_size Currently the function uses a hardcoded value for the checksum size of a sector. This is fine, given that we currently support only a single algorithm, whose checksum is 4 bytes == sizeof(u32). Despite not having other algorithms, btrfs' design supports using a different algorithm whith different space requirements. To future-proof the code query the size of the currently used algorithm from the in-memory copy of the super block. No functional changes. Signed-off-by: Nikolay Borisov Reviewed-by: Qu Wenruo Reviewed-by: Su Yue Signed-off-by: David Sterba --- diff --git a/fs/btrfs/ordered-data.h b/fs/btrfs/ordered-data.h index 56c4c0e..c53e2cf 100644 --- a/fs/btrfs/ordered-data.h +++ b/fs/btrfs/ordered-data.h @@ -151,7 +151,9 @@ static inline int btrfs_ordered_sum_size(struct btrfs_fs_info *fs_info, unsigned long bytes) { int num_sectors = (int)DIV_ROUND_UP(bytes, fs_info->sectorsize); - return sizeof(struct btrfs_ordered_sum) + num_sectors * sizeof(u32); + int csum_size = btrfs_super_csum_size(fs_info->super_copy); + + return sizeof(struct btrfs_ordered_sum) + num_sectors * csum_size; } static inline void