Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(394)

Side by Side Diff: drivers/md/dm-bht.c

Issue 6250155: CHROMIUM: verity: remove stale code/comments from earlier bitmap design (Closed) Base URL: http://git.chromium.org/git/kernel.git@master
Patch Set: Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | include/linux/dm-bht.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 /* Each dm_bht_entry->nodes is one page. The node code tracks 281 /* Each dm_bht_entry->nodes is one page. The node code tracks
282 * how many nodes fit into one entry where a node is a single 282 * how many nodes fit into one entry where a node is a single
283 * hash (message digest). 283 * hash (message digest).
284 */ 284 */
285 bht->node_count_shift = fls(PAGE_SIZE / bht->digest_size) - 1; 285 bht->node_count_shift = fls(PAGE_SIZE / bht->digest_size) - 1;
286 /* Round down to the nearest power of two. This makes indexing 286 /* Round down to the nearest power of two. This makes indexing
287 * into the tree much less painful. 287 * into the tree much less painful.
288 */ 288 */
289 bht->node_count = 1 << bht->node_count_shift; 289 bht->node_count = 1 << bht->node_count_shift;
290 290
291 /* TODO(wad) if node_count < DM_BHT_MAX_NODE_COUNT, then retry with
292 * node_count_shift-1.
293 */
294 if (bht->node_count > DM_BHT_MAX_NODE_COUNT) {
295 DMERR("node_count maximum node bitmap size");
296 status = -EINVAL;
297 goto bad_node_count;
298 }
299
300 /* This is unlikely to happen, but with 64k pages, who knows. */ 291 /* This is unlikely to happen, but with 64k pages, who knows. */
301 if (bht->node_count > UINT_MAX / bht->digest_size) { 292 if (bht->node_count > UINT_MAX / bht->digest_size) {
302 DMERR("node_count * hash_len exceeds UINT_MAX!"); 293 DMERR("node_count * hash_len exceeds UINT_MAX!");
303 status = -EINVAL; 294 status = -EINVAL;
304 goto bad_node_count; 295 goto bad_node_count;
305 } 296 }
306 /* Ensure that we can safely shift by this value. */ 297 /* Ensure that we can safely shift by this value. */
307 if (depth * bht->node_count_shift >= sizeof(unsigned int) * 8) { 298 if (depth * bht->node_count_shift >= sizeof(unsigned int) * 8) {
308 DMERR("specified depth and node_count_shift is too large"); 299 DMERR("specified depth and node_count_shift is too large");
309 status = -EINVAL; 300 status = -EINVAL;
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 return 1; 618 return 1;
628 } 619 }
629 620
630 /* Index into the entry data */ 621 /* Index into the entry data */
631 index = (block_index % bht->node_count) * bht->digest_size; 622 index = (block_index % bht->node_count) * bht->digest_size;
632 if (memcmp(&entry->nodes[index], digest, bht->digest_size)) { 623 if (memcmp(&entry->nodes[index], digest, bht->digest_size)) {
633 DMCRIT("digest mismatch for block %u", block_index); 624 DMCRIT("digest mismatch for block %u", block_index);
634 dm_bht_log_mismatch(bht, &entry->nodes[index], digest); 625 dm_bht_log_mismatch(bht, &entry->nodes[index], digest);
635 return DM_BHT_ENTRY_ERROR_MISMATCH; 626 return DM_BHT_ENTRY_ERROR_MISMATCH;
636 } 627 }
637 /* TODO(wad) update bht->block_bitmap here or in the caller */
638 return 0; 628 return 0;
639 } 629 }
640 630
641 /* Walk all entries at level 0 to compute the root digest. 631 /* Walk all entries at level 0 to compute the root digest.
642 * 0 on success. 632 * 0 on success.
643 */ 633 */
644 static int dm_bht_compute_root(struct dm_bht *bht, u8 *digest) 634 static int dm_bht_compute_root(struct dm_bht *bht, u8 *digest)
645 { 635 {
646 struct dm_bht_entry *entry; 636 struct dm_bht_entry *entry;
647 unsigned int count; 637 unsigned int count;
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after
1294 DMERR("no root digest exists to export"); 1284 DMERR("no root digest exists to export");
1295 if (available > 0) 1285 if (available > 0)
1296 *hexdigest = 0; 1286 *hexdigest = 0;
1297 return -1; 1287 return -1;
1298 } 1288 }
1299 dm_bht_bin_to_hex(bht->root_digest, hexdigest, bht->digest_size); 1289 dm_bht_bin_to_hex(bht->root_digest, hexdigest, bht->digest_size);
1300 return 0; 1290 return 0;
1301 } 1291 }
1302 EXPORT_SYMBOL(dm_bht_root_hexdigest); 1292 EXPORT_SYMBOL(dm_bht_root_hexdigest);
1303 1293
OLDNEW
« no previous file with comments | « no previous file | include/linux/dm-bht.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698