| 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 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 687 | 687 |
| 688 /* Keep the containing block of hashes to be verified in the | 688 /* Keep the containing block of hashes to be verified in the |
| 689 * next pass. | 689 * next pass. |
| 690 */ | 690 */ |
| 691 block = entry->nodes; | 691 block = entry->nodes; |
| 692 } while (--depth > 0 && state != DM_BHT_ENTRY_VERIFIED); | 692 } while (--depth > 0 && state != DM_BHT_ENTRY_VERIFIED); |
| 693 | 693 |
| 694 /* Mark path to leaf as verified. */ | 694 /* Mark path to leaf as verified. */ |
| 695 for (depth++; depth < bht->depth; depth++) { | 695 for (depth++; depth < bht->depth; depth++) { |
| 696 entry = dm_bht_get_entry(bht, depth, block_index); | 696 entry = dm_bht_get_entry(bht, depth, block_index); |
| 697 » » atomic_cmpxchg(&entry->state, | 697 » » /* At this point, entry can only be in VERIFIED or READY state. |
| 698 » » » DM_BHT_ENTRY_READY, | 698 » » * So it is safe to use atomic_set instead of atomic_cmpxchg. |
| 699 » » » DM_BHT_ENTRY_VERIFIED); | 699 » » */ |
| 700 » » atomic_set(&entry->state, DM_BHT_ENTRY_VERIFIED); |
| 700 } | 701 } |
| 701 | 702 |
| 702 DMDEBUG("verify_path: node %u is verified to root", block_index); | 703 DMDEBUG("verify_path: node %u is verified to root", block_index); |
| 703 return 0; | 704 return 0; |
| 704 | 705 |
| 705 mismatch: | 706 mismatch: |
| 706 DMERR("verify_path: failed to verify hash against parent (d=%u,bi=%u)", | 707 DMERR("verify_path: failed to verify hash against parent (d=%u,bi=%u)", |
| 707 depth, block_index); | 708 depth, block_index); |
| 708 return DM_BHT_ENTRY_ERROR_MISMATCH; | 709 return DM_BHT_ENTRY_ERROR_MISMATCH; |
| 709 } | 710 } |
| (...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1188 DMERR("no root digest exists to export"); | 1189 DMERR("no root digest exists to export"); |
| 1189 if (available > 0) | 1190 if (available > 0) |
| 1190 *hexdigest = 0; | 1191 *hexdigest = 0; |
| 1191 return -1; | 1192 return -1; |
| 1192 } | 1193 } |
| 1193 dm_bht_bin_to_hex(bht->root_digest, hexdigest, bht->digest_size); | 1194 dm_bht_bin_to_hex(bht->root_digest, hexdigest, bht->digest_size); |
| 1194 return 0; | 1195 return 0; |
| 1195 } | 1196 } |
| 1196 EXPORT_SYMBOL(dm_bht_root_hexdigest); | 1197 EXPORT_SYMBOL(dm_bht_root_hexdigest); |
| 1197 | 1198 |
| OLD | NEW |