| 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 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 /* The leaves contain the block hashes */ | 599 /* The leaves contain the block hashes */ |
| 600 depth = bht->depth - 1; | 600 depth = bht->depth - 1; |
| 601 | 601 |
| 602 /* Index into the bottom level. Each entry in this level contains | 602 /* Index into the bottom level. Each entry in this level contains |
| 603 * nodes whose hashes are the direct hashes of one block of data on | 603 * nodes whose hashes are the direct hashes of one block of data on |
| 604 * disk. | 604 * disk. |
| 605 */ | 605 */ |
| 606 index = block_index >> bht->node_count_shift; | 606 index = block_index >> bht->node_count_shift; |
| 607 entry = &bht->levels[depth].entries[index]; | 607 entry = &bht->levels[depth].entries[index]; |
| 608 | 608 |
| 609 » *entry_state = atomic_read(&entry->state); | 609 » /* This call is only safe if all nodes along the path |
| 610 » if (*entry_state <= DM_BHT_ENTRY_ERROR) { | 610 » * are already populated (i.e. READY) via dm_bht_populate. |
| 611 » » DMCRIT("leaf entry for block %u is invalid", | 611 » */ |
| 612 » » block_index); | 612 » BUG_ON(atomic_read(&entry->state) < DM_BHT_ENTRY_READY); |
| 613 » » return *entry_state; | |
| 614 » } | |
| 615 » if (*entry_state <= DM_BHT_ENTRY_PENDING) { | |
| 616 » » DMERR("leaf data not yet loaded for block %u", | |
| 617 » » block_index); | |
| 618 » » return 1; | |
| 619 » } | |
| 620 | 613 |
| 621 /* Index into the entry data */ | 614 /* Index into the entry data */ |
| 622 index = (block_index % bht->node_count) * bht->digest_size; | 615 index = (block_index % bht->node_count) * bht->digest_size; |
| 623 if (memcmp(&entry->nodes[index], digest, bht->digest_size)) { | 616 if (memcmp(&entry->nodes[index], digest, bht->digest_size)) { |
| 624 DMCRIT("digest mismatch for block %u", block_index); | 617 DMCRIT("digest mismatch for block %u", block_index); |
| 625 dm_bht_log_mismatch(bht, &entry->nodes[index], digest); | 618 dm_bht_log_mismatch(bht, &entry->nodes[index], digest); |
| 626 return DM_BHT_ENTRY_ERROR_MISMATCH; | 619 return DM_BHT_ENTRY_ERROR_MISMATCH; |
| 627 } | 620 } |
| 628 return 0; | 621 return 0; |
| 629 } | 622 } |
| (...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1278 DMERR("no root digest exists to export"); | 1271 DMERR("no root digest exists to export"); |
| 1279 if (available > 0) | 1272 if (available > 0) |
| 1280 *hexdigest = 0; | 1273 *hexdigest = 0; |
| 1281 return -1; | 1274 return -1; |
| 1282 } | 1275 } |
| 1283 dm_bht_bin_to_hex(bht->root_digest, hexdigest, bht->digest_size); | 1276 dm_bht_bin_to_hex(bht->root_digest, hexdigest, bht->digest_size); |
| 1284 return 0; | 1277 return 0; |
| 1285 } | 1278 } |
| 1286 EXPORT_SYMBOL(dm_bht_root_hexdigest); | 1279 EXPORT_SYMBOL(dm_bht_root_hexdigest); |
| 1287 | 1280 |
| OLD | NEW |