Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

btrfs: add a btrfs_csum_type_size helper

This is needed in btrfs-progs for the tools that convert the checksum
types for file systems and a few other things. We don't have it in the
kernel as we just want to get the size for the super blocks type.
However I don't want to have to manually add this every time we sync
ctree.c into btrfs-progs, so add the helper in the kernel with a note so
it doesn't get removed by a later cleanup.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: David Sterba <dsterba@suse.com>

authored by

Josef Bacik and committed by
David Sterba
b3cbfb0d a95b7f93

+8 -1
+7 -1
fs/btrfs/ctree.c
··· 150 150 nr_items * sizeof(struct btrfs_item)); 151 151 } 152 152 153 + /* This exists for btrfs-progs usages. */ 154 + u16 btrfs_csum_type_size(u16 type) 155 + { 156 + return btrfs_csums[type].size; 157 + } 158 + 153 159 int btrfs_super_csum_size(const struct btrfs_super_block *s) 154 160 { 155 161 u16 t = btrfs_super_csum_type(s); 156 162 /* 157 163 * csum type is validated at mount time 158 164 */ 159 - return btrfs_csums[t].size; 165 + return btrfs_csum_type_size(t); 160 166 } 161 167 162 168 const char *btrfs_super_csum_name(u16 csum_type)
+1
fs/btrfs/ctree.h
··· 701 701 return root->root_key.objectid == BTRFS_DATA_RELOC_TREE_OBJECTID; 702 702 } 703 703 704 + u16 btrfs_csum_type_size(u16 type); 704 705 int btrfs_super_csum_size(const struct btrfs_super_block *s); 705 706 const char *btrfs_super_csum_name(u16 csum_type); 706 707 const char *btrfs_super_csum_driver(u16 csum_type);