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 893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
904 } | 904 } |
905 sector += to_sector(PAGE_SIZE); | 905 sector += to_sector(PAGE_SIZE); |
906 } | 906 } |
907 } | 907 } |
908 | 908 |
909 return 0; | 909 return 0; |
910 } | 910 } |
911 EXPORT_SYMBOL(dm_bht_sync); | 911 EXPORT_SYMBOL(dm_bht_sync); |
912 | 912 |
913 /** | 913 /** |
| 914 * dm_bht_is_populated - check that entries from disk needed to verify a given |
| 915 * block are all ready |
| 916 * @bht: pointer to a dm_bht_create()d bht |
| 917 * @block_index:specific block data is expected from |
| 918 * |
| 919 * Callers may wish to call dm_bht_is_populated() when checking an io |
| 920 * for which entries were already pending. |
| 921 */ |
| 922 bool dm_bht_is_populated(struct dm_bht *bht, unsigned int block_index) |
| 923 { |
| 924 unsigned int depth; |
| 925 |
| 926 if (atomic_read(&bht->root_state) < DM_BHT_ENTRY_READY) |
| 927 return false; |
| 928 |
| 929 for (depth = bht->depth - 1; depth > 0; depth--) { |
| 930 struct dm_bht_entry *entry = dm_bht_get_entry(bht, depth, |
| 931 block_index); |
| 932 if (atomic_read(&entry->state) < DM_BHT_ENTRY_READY) |
| 933 return false; |
| 934 } |
| 935 |
| 936 return true; |
| 937 } |
| 938 EXPORT_SYMBOL(dm_bht_is_populated); |
| 939 |
| 940 /** |
914 * dm_bht_populate - reads entries from disk needed to verify a given block | 941 * dm_bht_populate - reads entries from disk needed to verify a given block |
915 * @bht: pointer to a dm_bht_create()d bht | 942 * @bht: pointer to a dm_bht_create()d bht |
916 * @read_cb_ctx:context used for all read_cb calls on this request | 943 * @read_cb_ctx:context used for all read_cb calls on this request |
917 * @block_index:specific block data is expected from | 944 * @block_index:specific block data is expected from |
918 * | 945 * |
919 * Callers may wish to call dm_bht_populate(0) immediately after initialization | 946 * Callers may wish to call dm_bht_populate(0) immediately after initialization |
920 * to start loading in all the level[0] entries. | 947 * to start loading in all the level[0] entries. |
921 */ | 948 */ |
922 int dm_bht_populate(struct dm_bht *bht, void *read_cb_ctx, | 949 int dm_bht_populate(struct dm_bht *bht, void *read_cb_ctx, |
923 unsigned int block_index) | 950 unsigned int block_index) |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1183 DMERR("no root digest exists to export"); | 1210 DMERR("no root digest exists to export"); |
1184 if (available > 0) | 1211 if (available > 0) |
1185 *hexdigest = 0; | 1212 *hexdigest = 0; |
1186 return -1; | 1213 return -1; |
1187 } | 1214 } |
1188 dm_bht_bin_to_hex(bht->root_digest, hexdigest, bht->digest_size); | 1215 dm_bht_bin_to_hex(bht->root_digest, hexdigest, bht->digest_size); |
1189 return 0; | 1216 return 0; |
1190 } | 1217 } |
1191 EXPORT_SYMBOL(dm_bht_root_hexdigest); | 1218 EXPORT_SYMBOL(dm_bht_root_hexdigest); |
1192 | 1219 |
OLD | NEW |