| 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 GPLv2. | 7 * This file is released under the GPLv2. |
| 8 */ | 8 */ |
| 9 #ifndef __LINUX_DM_BHT_H | 9 #ifndef __LINUX_DM_BHT_H |
| 10 #define __LINUX_DM_BHT_H | 10 #define __LINUX_DM_BHT_H |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 * | 76 * |
| 77 * The tree is built from the bottom up. A collection of data, | 77 * The tree is built from the bottom up. A collection of data, |
| 78 * external to the tree, is hashed and these hashes are stored | 78 * external to the tree, is hashed and these hashes are stored |
| 79 * as the blocks in the tree. For some number of these hashes, | 79 * as the blocks in the tree. For some number of these hashes, |
| 80 * a parent node is created by hashing them. These steps are | 80 * a parent node is created by hashing them. These steps are |
| 81 * repeated. | 81 * repeated. |
| 82 * | 82 * |
| 83 * TODO(wad): All hash storage memory is pre-allocated and freed once an | 83 * TODO(wad): All hash storage memory is pre-allocated and freed once an |
| 84 * entire branch has been verified. | 84 * entire branch has been verified. |
| 85 */ | 85 */ |
| 86 enum verify_mode { DM_BHT_REVERIFY_LEAVES = 0, DM_BHT_FULL_REVERIFY }; | |
| 87 struct dm_bht { | 86 struct dm_bht { |
| 88 /* Configured values */ | 87 /* Configured values */ |
| 89 /* ENFORCE: depth must be >= 2. */ | 88 /* ENFORCE: depth must be >= 2. */ |
| 90 unsigned int depth; /* Depth of the tree including the root */ | 89 unsigned int depth; /* Depth of the tree including the root */ |
| 91 unsigned int block_count; /* Number of blocks hashed */ | 90 unsigned int block_count; /* Number of blocks hashed */ |
| 92 char hash_alg[CRYPTO_MAX_ALG_NAME]; | 91 char hash_alg[CRYPTO_MAX_ALG_NAME]; |
| 93 int verify_mode; /* different verification modes */ | |
| 94 unsigned int entry_readahead; /* number of entries to attempt to | 92 unsigned int entry_readahead; /* number of entries to attempt to |
| 95 * pre-read in a level. | 93 * pre-read in a level. |
| 96 */ | 94 */ |
| 97 | 95 |
| 98 /* Computed values */ | 96 /* Computed values */ |
| 99 unsigned int node_count; /* Data size (in hashes) for each entry */ | 97 unsigned int node_count; /* Data size (in hashes) for each entry */ |
| 100 unsigned int node_count_shift; /* first bit set - 1 */ | 98 unsigned int node_count_shift; /* first bit set - 1 */ |
| 101 /* There is one per CPU so that verified can be simultaneous. */ | 99 /* There is one per CPU so that verified can be simultaneous. */ |
| 102 struct hash_desc *hash_desc; /* Container for the hash alg */ | 100 struct hash_desc *hash_desc; /* Container for the hash alg */ |
| 103 unsigned int digest_size; | 101 unsigned int digest_size; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 120 const char *alg_name); | 118 const char *alg_name); |
| 121 /* Destructor for struct dm_bht instances. Does not free @bht */ | 119 /* Destructor for struct dm_bht instances. Does not free @bht */ |
| 122 int dm_bht_destroy(struct dm_bht *bht); | 120 int dm_bht_destroy(struct dm_bht *bht); |
| 123 | 121 |
| 124 /* Basic accessors for struct dm_bht */ | 122 /* Basic accessors for struct dm_bht */ |
| 125 sector_t dm_bht_sectors(const struct dm_bht *bht); | 123 sector_t dm_bht_sectors(const struct dm_bht *bht); |
| 126 void dm_bht_set_entry_readahead(struct dm_bht *bht, | 124 void dm_bht_set_entry_readahead(struct dm_bht *bht, |
| 127 unsigned int readahead_count); | 125 unsigned int readahead_count); |
| 128 void dm_bht_set_read_cb(struct dm_bht *bht, dm_bht_callback read_cb); | 126 void dm_bht_set_read_cb(struct dm_bht *bht, dm_bht_callback read_cb); |
| 129 void dm_bht_set_write_cb(struct dm_bht *bht, dm_bht_callback write_cb); | 127 void dm_bht_set_write_cb(struct dm_bht *bht, dm_bht_callback write_cb); |
| 130 void dm_bht_set_verify_mode(struct dm_bht *bht, int verify_mode); | |
| 131 int dm_bht_set_root_hexdigest(struct dm_bht *bht, const u8 *hexdigest); | 128 int dm_bht_set_root_hexdigest(struct dm_bht *bht, const u8 *hexdigest); |
| 132 int dm_bht_root_hexdigest(struct dm_bht *bht, u8 *hexdigest, int available); | 129 int dm_bht_root_hexdigest(struct dm_bht *bht, u8 *hexdigest, int available); |
| 133 | 130 |
| 134 /* Functions for loading in data from disk for verification */ | 131 /* Functions for loading in data from disk for verification */ |
| 135 int dm_bht_populate(struct dm_bht *bht, void *read_cb_ctx, | 132 int dm_bht_populate(struct dm_bht *bht, void *read_cb_ctx, |
| 136 unsigned int block_index); | 133 unsigned int block_index); |
| 137 int dm_bht_verify_block(struct dm_bht *bht, unsigned int block_index, | 134 int dm_bht_verify_block(struct dm_bht *bht, unsigned int block_index, |
| 138 const void *block); | 135 const void *block); |
| 139 | 136 |
| 140 /* Functions for creating struct dm_bhts on disk. A newly created dm_bht | 137 /* Functions for creating struct dm_bhts on disk. A newly created dm_bht |
| 141 * should not be directly used for verification. (It should be repopulated.) | 138 * should not be directly used for verification. (It should be repopulated.) |
| 142 * In addition, these functions aren't meant to be called in parallel. | 139 * In addition, these functions aren't meant to be called in parallel. |
| 143 */ | 140 */ |
| 144 int dm_bht_compute(struct dm_bht *bht, void *read_cb_ctx); | 141 int dm_bht_compute(struct dm_bht *bht, void *read_cb_ctx); |
| 145 int dm_bht_sync(struct dm_bht *bht, void *write_cb_ctx); | 142 int dm_bht_sync(struct dm_bht *bht, void *write_cb_ctx); |
| 146 int dm_bht_store_block(struct dm_bht *bht, unsigned int block_index, | 143 int dm_bht_store_block(struct dm_bht *bht, unsigned int block_index, |
| 147 u8 *block_data); | 144 u8 *block_data); |
| 148 int dm_bht_zeroread_callback(void *ctx, sector_t start, u8 *dst, sector_t count, | 145 int dm_bht_zeroread_callback(void *ctx, sector_t start, u8 *dst, sector_t count, |
| 149 struct dm_bht_entry *entry); | 146 struct dm_bht_entry *entry); |
| 150 void dm_bht_read_completed(struct dm_bht_entry *entry, int status); | 147 void dm_bht_read_completed(struct dm_bht_entry *entry, int status); |
| 151 void dm_bht_write_completed(struct dm_bht_entry *entry, int status); | 148 void dm_bht_write_completed(struct dm_bht_entry *entry, int status); |
| 152 #endif /* __LINUX_DM_BHT_H */ | 149 #endif /* __LINUX_DM_BHT_H */ |
| OLD | NEW |