btrfs: store precalculated csum_size in fs_info
authorDavid Sterba <dsterba@suse.com>
Thu, 2 Jul 2020 09:10:18 +0000 (11:10 +0200)
committerDavid Sterba <dsterba@suse.com>
Tue, 8 Dec 2020 14:53:58 +0000 (15:53 +0100)
In many places we need the checksum size and it is inefficient to read
it from the raw superblock. Store the value into fs_info, actual use
will be in followup patches.  The size is u32 as it allows to generate
better assembly than with u16.

Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/ctree.h
fs/btrfs/disk-io.c

index b94b4fe0fa96eb01e5ff954ad868d711f26dec45..3d06596b8746841b4dbe9373bf83d6ffb1fa49d9 100644 (file)
@@ -937,6 +937,7 @@ struct btrfs_fs_info {
        u32 sectorsize;
        /* ilog2 of sectorsize, use to avoid 64bit division */
        u32 sectorsize_bits;
+       u32 csum_size;
        u32 stripesize;
 
        /* Block groups and devices containing active swapfiles. */
index 25889a2362e21887012425fd4465568e2b7d9bc6..475bd197c4825a740838f1e79356f224445bc530 100644 (file)
@@ -3080,6 +3080,7 @@ int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device
        fs_info->nodesize = nodesize;
        fs_info->sectorsize = sectorsize;
        fs_info->sectorsize_bits = ilog2(sectorsize);
+       fs_info->csum_size = btrfs_super_csum_size(disk_super);
        fs_info->stripesize = stripesize;
 
        /*