Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 The Chromium OS Authors <chromium-os-dev@chromium.org> | 2 * Copyright (C) 2010 The Chromium OS Authors <chromium-os-dev@chromium.org> |
| 3 * | 3 * |
| 4 * Device-Mapper block hash tree interface. | 4 * Device-Mapper block hash tree interface. |
| 5 * See Documentation/device-mapper/dm-bht.txt for details. | 5 * See Documentation/device-mapper/dm-bht.txt for details. |
| 6 * | 6 * |
| 7 * This file is released under the GPL. | 7 * This file is released under the GPL. |
| 8 */ | 8 */ |
| 9 | 9 |
| 10 #include <asm/atomic.h> | 10 #include <asm/atomic.h> |
| (...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 827 */ | 827 */ |
| 828 int dm_bht_compute(struct dm_bht *bht, void *read_cb_ctx) | 828 int dm_bht_compute(struct dm_bht *bht, void *read_cb_ctx) |
| 829 { | 829 { |
| 830 int depth, r; | 830 int depth, r; |
| 831 | 831 |
| 832 for (depth = bht->depth - 2; depth >= 0; depth--) { | 832 for (depth = bht->depth - 2; depth >= 0; depth--) { |
| 833 struct dm_bht_level *level = dm_bht_get_level(bht, depth); | 833 struct dm_bht_level *level = dm_bht_get_level(bht, depth); |
| 834 struct dm_bht_level *child_level = level + 1; | 834 struct dm_bht_level *child_level = level + 1; |
| 835 struct dm_bht_entry *entry = level->entries; | 835 struct dm_bht_entry *entry = level->entries; |
| 836 struct dm_bht_entry *child = child_level->entries; | 836 struct dm_bht_entry *child = child_level->entries; |
| 837 unsigned int count = min(bht->node_count, child_level->count); | |
| 838 unsigned int i, j; | 837 unsigned int i, j; |
| 839 | 838 |
| 840 r = dm_bht_maybe_read_entries(bht, read_cb_ctx, depth, | 839 r = dm_bht_maybe_read_entries(bht, read_cb_ctx, depth, |
| 841 0, level->count, true); | 840 0, level->count, true); |
| 842 if (r < 0) { | 841 if (r < 0) { |
| 843 DMCRIT("an error occurred while reading entry"); | 842 DMCRIT("an error occurred while reading entry"); |
| 844 goto out; | 843 goto out; |
| 845 } | 844 } |
| 846 | 845 |
| 847 for (i = 0; i < level->count; i++, entry++) { | 846 for (i = 0; i < level->count; i++, entry++) { |
| 847 unsigned int count = bht->node_count; | |
| 848 if (i == (level->count - 1)) | |
|
Will Drewry
2011/03/25 02:52:49
Could this just be:
unsigned int count = child_lev
| |
| 849 count = child_level->count % bht->node_count; | |
| 850 if (count == 0) | |
| 851 count = bht->node_count; | |
| 848 for (j = 0; j < count; j++, child++) { | 852 for (j = 0; j < count; j++, child++) { |
| 849 u8 *block = child->nodes; | 853 u8 *block = child->nodes; |
| 850 u8 *digest = dm_bht_node(bht, entry, j); | 854 u8 *digest = dm_bht_node(bht, entry, j); |
| 851 | 855 |
| 852 r = dm_bht_compute_hash(bht, block, digest); | 856 r = dm_bht_compute_hash(bht, block, digest); |
| 853 if (r) { | 857 if (r) { |
| 854 DMERR("Failed to update (d=%u,i=%u)", | 858 DMERR("Failed to update (d=%u,i=%u)", |
| 855 depth, i); | 859 depth, i); |
| 856 goto out; | 860 goto out; |
| 857 } | 861 } |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1187 DMERR("no root digest exists to export"); | 1191 DMERR("no root digest exists to export"); |
| 1188 if (available > 0) | 1192 if (available > 0) |
| 1189 *hexdigest = 0; | 1193 *hexdigest = 0; |
| 1190 return -1; | 1194 return -1; |
| 1191 } | 1195 } |
| 1192 dm_bht_bin_to_hex(bht->root_digest, hexdigest, bht->digest_size); | 1196 dm_bht_bin_to_hex(bht->root_digest, hexdigest, bht->digest_size); |
| 1193 return 0; | 1197 return 0; |
| 1194 } | 1198 } |
| 1195 EXPORT_SYMBOL(dm_bht_root_hexdigest); | 1199 EXPORT_SYMBOL(dm_bht_root_hexdigest); |
| 1196 | 1200 |
| OLD | NEW |