@@ -65,11 +65,6 @@ const char *btrfs_super_csum_name(u16 csum_type)
return btrfs_csums[csum_type].name;
}
-size_t btrfs_super_num_csums(void)
-{
- return ARRAY_SIZE(btrfs_csums);
-}
-
u16 btrfs_csum_type_size(u16 csum_type)
{
return btrfs_csums[csum_type].size;
@@ -1064,7 +1064,6 @@ void btrfs_set_item_key_unsafe(struct btrfs_root *root,
u16 btrfs_super_csum_size(const struct btrfs_super_block *s);
const char *btrfs_super_csum_name(u16 csum_type);
u16 btrfs_csum_type_size(u16 csum_type);
-size_t btrfs_super_num_csums(void);
/* root-item.c */
int btrfs_add_root_ref(struct btrfs_trans_handle *trans,
@@ -1713,6 +1713,19 @@ struct btrfs_root *open_ctree_fd(int fp, const char *path, u64 sb_bytenr,
return info->fs_root;
}
+static bool btrfs_supported_super_csum(u16 csum_type)
+{
+ switch (csum_type) {
+ case BTRFS_CSUM_TYPE_CRC32:
+ case BTRFS_CSUM_TYPE_XXHASH:
+ case BTRFS_CSUM_TYPE_SHA256:
+ case BTRFS_CSUM_TYPE_BLAKE2:
+ return true;
+ default:
+ return false;
+ }
+}
+
/*
* Check if the super is valid:
* - nodesize/sectorsize - minimum, maximum, alignment
@@ -1737,7 +1750,7 @@ int btrfs_check_super(struct btrfs_super_block *sb, unsigned sbflags)
}
csum_type = btrfs_super_csum_type(sb);
- if (csum_type >= btrfs_super_num_csums()) {
+ if (!btrfs_supported_super_csum(csum_type)) {
error("unsupported checksum algorithm %u", csum_type);
return -EIO;
}
In the kernel we have a basic btrfs_supported_super_csum() helper in disk-io.c to validate the csum type. Update progs to do the same thing that the kernel does and then drop the btrfs_super_num_csums() helper as it doesn't exist upstream and is no longer used. Signed-off-by: Josef Bacik <josef@toxicpanda.com> --- kernel-shared/ctree.c | 5 ----- kernel-shared/ctree.h | 1 - kernel-shared/disk-io.c | 15 ++++++++++++++- 3 files changed, 14 insertions(+), 7 deletions(-)