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 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 } | 434 } |
435 | 435 |
436 /** | 436 /** |
437 * dm_bht_read_completed | 437 * dm_bht_read_completed |
438 * @entry: pointer to the entry that's been loaded | 438 * @entry: pointer to the entry that's been loaded |
439 * @status: I/O status. Non-zero is failure. | 439 * @status: I/O status. Non-zero is failure. |
440 * MUST always be called after a read_cb completes. | 440 * MUST always be called after a read_cb completes. |
441 */ | 441 */ |
442 void dm_bht_read_completed(struct dm_bht_entry *entry, int status) | 442 void dm_bht_read_completed(struct dm_bht_entry *entry, int status) |
443 { | 443 { |
444 int state; | |
445 if (status) { | 444 if (status) { |
446 /* TODO(wad) add retry support */ | 445 /* TODO(wad) add retry support */ |
447 DMCRIT("an I/O error occurred while reading entry"); | 446 DMCRIT("an I/O error occurred while reading entry"); |
448 atomic_set(&entry->state, DM_BHT_ENTRY_ERROR_IO); | 447 atomic_set(&entry->state, DM_BHT_ENTRY_ERROR_IO); |
449 /* entry->nodes will be freed later */ | 448 /* entry->nodes will be freed later */ |
450 return; | 449 return; |
451 } | 450 } |
452 » state = atomic_cmpxchg(&entry->state, | 451 » BUG_ON(atomic_read(&entry->state) != DM_BHT_ENTRY_PENDING); |
453 » » » » DM_BHT_ENTRY_PENDING, | 452 » atomic_set(&entry->state, DM_BHT_ENTRY_READY); |
454 » » » » DM_BHT_ENTRY_READY); | |
455 » if (state != DM_BHT_ENTRY_PENDING) { | |
456 » » DMCRIT("state changed on entry out from under io"); | |
457 » » BUG(); | |
458 » } | |
459 } | 453 } |
460 EXPORT_SYMBOL(dm_bht_read_completed); | 454 EXPORT_SYMBOL(dm_bht_read_completed); |
461 | 455 |
462 /** | 456 /** |
463 * dm_bht_write_completed | 457 * dm_bht_write_completed |
464 * @entry: pointer to the entry that's been loaded | 458 * @entry: pointer to the entry that's been loaded |
465 * @status: I/O status. Non-zero is failure. | 459 * @status: I/O status. Non-zero is failure. |
466 * Should be called after a write_cb completes. Currently only catches | 460 * Should be called after a write_cb completes. Currently only catches |
467 * errors which more writers don't care about. | 461 * errors which more writers don't care about. |
468 */ | 462 */ |
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1189 DMERR("no root digest exists to export"); | 1183 DMERR("no root digest exists to export"); |
1190 if (available > 0) | 1184 if (available > 0) |
1191 *hexdigest = 0; | 1185 *hexdigest = 0; |
1192 return -1; | 1186 return -1; |
1193 } | 1187 } |
1194 dm_bht_bin_to_hex(bht->root_digest, hexdigest, bht->digest_size); | 1188 dm_bht_bin_to_hex(bht->root_digest, hexdigest, bht->digest_size); |
1195 return 0; | 1189 return 0; |
1196 } | 1190 } |
1197 EXPORT_SYMBOL(dm_bht_root_hexdigest); | 1191 EXPORT_SYMBOL(dm_bht_root_hexdigest); |
1198 | 1192 |
OLD | NEW |