summaryrefslogtreecommitdiff
path: root/btrfsck.h
diff options
context:
space:
mode:
Diffstat (limited to 'btrfsck.h')
-rw-r--r--btrfsck.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/btrfsck.h b/btrfsck.h
index 0882a383..e16f52f5 100644
--- a/btrfsck.h
+++ b/btrfsck.h
@@ -142,6 +142,23 @@ static inline unsigned long btrfs_chunk_record_size(int num_stripes)
}
void free_chunk_cache_tree(struct cache_tree *chunk_cache);
+/*
+ * Function to check validation for num_stripes, or it can call
+ * float point error for 0 division
+ * return < 0 for invalid combination
+ * return 0 for valid combination
+ */
+static inline int check_num_stripes(u64 type, int num_stripes)
+{
+ if (num_stripes == 0)
+ return -1;
+ if (type & BTRFS_BLOCK_GROUP_RAID5 && num_stripes <= 1)
+ return -1;
+ if (type & BTRFS_BLOCK_GROUP_RAID6 && num_stripes <= 2)
+ return -1;
+ return 0;
+}
+
u64 calc_stripe_length(u64 type, u64 length, int num_stripes);
/* For block group tree */
static inline void block_group_tree_init(struct block_group_tree *tree)