Index: dm-bht.c |
diff --git a/dm-bht.c b/dm-bht.c |
index 1665c742a81bab770ffb0b60c89f1b0d07424dcc..1d68af4d8a338912a348ac3bf52d85b066165869 100644 |
--- a/dm-bht.c |
+++ b/dm-bht.c |
@@ -204,8 +204,8 @@ static int dm_bht_write_callback_stub(void *ctx, sector_t start, |
* Callers can offset into devices by storing the data in the io callbacks. |
* TODO(wad) bust up into smaller helpers |
*/ |
-int dm_bht_create(struct dm_bht *bht, unsigned int depth, |
- unsigned int block_count, const char *alg_name) |
+int dm_bht_create(struct dm_bht *bht, unsigned int block_count, |
+ const char *alg_name) |
{ |
int status = 0; |
int cpu = 0; |
@@ -282,24 +282,8 @@ int dm_bht_create(struct dm_bht *bht, unsigned int depth, |
goto bad_node_count; |
} |
- /* if depth == 0, create a "regular" trie with a single root block */ |
- if (depth == 0) |
- depth = DIV_ROUND_UP(fls(block_count - 1), |
- bht->node_count_shift); |
- if (depth > UINT_MAX / sizeof(struct dm_bht_level)) { |
- DMERR("bht depth is invalid: %u", depth); |
- status = -EINVAL; |
- goto bad_depth; |
- } |
- DMDEBUG("Setting depth to %u.", depth); |
- bht->depth = depth; |
- |
- /* Ensure that we can safely shift by this value. */ |
- if (depth * bht->node_count_shift >= sizeof(unsigned int) * 8) { |
Will Drewry
2011/04/07 22:45:17
You'll probably still want this check. While node
Mandeep Singh Baines
2011/04/08 14:28:40
You're right. There is a chance. My reasoning was:
|
- DMERR("specified depth and node_count_shift is too large"); |
- status = -EINVAL; |
- goto bad_node_count; |
- } |
+ bht->depth = DIV_ROUND_UP(fls(block_count - 1), bht->node_count_shift); |
+ DMDEBUG("Setting depth to %u.", bht->depth); |
/* Allocate levels. Each level of the tree may have an arbitrary number |
* of dm_bht_entry structs. Each entry contains node_count nodes. |
@@ -307,7 +291,8 @@ int dm_bht_create(struct dm_bht *bht, unsigned int depth, |
* nodes on the subsequent level or of a specific block on disk. |
*/ |
bht->levels = (struct dm_bht_level *) |
- kcalloc(depth, sizeof(struct dm_bht_level), GFP_KERNEL); |
+ kcalloc(bht->depth, |
+ sizeof(struct dm_bht_level), GFP_KERNEL); |
if (!bht->levels) { |
DMERR("failed to allocate tree levels"); |
status = -ENOMEM; |
@@ -331,7 +316,6 @@ bad_entries_alloc: |
bad_node_count: |
bad_level_alloc: |
bad_block_count: |
-bad_depth: |
kfree(bht->root_digest); |
bad_root_digest_alloc: |
bad_digest_len: |