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

Side by Side Diff: dm-bht.c

Issue 6675058: verity: remove entry_readahead (Closed) Base URL: http://git.chromium.org/git/dm-verity.git@master
Patch Set: Created 9 years, 8 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 | « dm-bht.h ('k') | no next file » | 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 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 } 310 }
311 311
312 /* Setup callback stubs */ 312 /* Setup callback stubs */
313 bht->read_cb = &dm_bht_read_callback_stub; 313 bht->read_cb = &dm_bht_read_callback_stub;
314 bht->write_cb = &dm_bht_write_callback_stub; 314 bht->write_cb = &dm_bht_write_callback_stub;
315 315
316 status = dm_bht_initialize_entries(bht); 316 status = dm_bht_initialize_entries(bht);
317 if (status) 317 if (status)
318 goto bad_entries_alloc; 318 goto bad_entries_alloc;
319 319
320 bht->entry_readahead = 0;
321 return 0; 320 return 0;
322 321
323 bad_entries_alloc: 322 bad_entries_alloc:
324 while (bht->depth-- > 0) 323 while (bht->depth-- > 0)
325 kfree(bht->levels[bht->depth].entries); 324 kfree(bht->levels[bht->depth].entries);
326 bad_node_count: 325 bad_node_count:
327 kfree(bht->levels); 326 kfree(bht->levels);
328 bad_level_alloc: 327 bad_level_alloc:
329 bad_block_count: 328 bad_block_count:
330 bad_depth: 329 bad_depth:
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after
1004 read_status = dm_bht_maybe_read_entries(bht, read_cb_ctx, 1003 read_status = dm_bht_maybe_read_entries(bht, read_cb_ctx,
1005 depth, entry_index, 1004 depth, entry_index,
1006 1, false); 1005 1, false);
1007 if (unlikely(read_status < 0)) { 1006 if (unlikely(read_status < 0)) {
1008 DMCRIT("failure occurred reading entry %u depth %u", 1007 DMCRIT("failure occurred reading entry %u depth %u",
1009 entry_index, depth); 1008 entry_index, depth);
1010 return read_status; 1009 return read_status;
1011 } 1010 }
1012 /* Accrue return code flags */ 1011 /* Accrue return code flags */
1013 populated |= read_status; 1012 populated |= read_status;
1014
1015 /* Attempt to pull in up to entry_readahead extra entries on
1016 * this I/O call iff we're doing the read right now. This
1017 * helps optimize sequential access to the mapped drive.
1018 */
1019 if (bht->entry_readahead &&
1020 (read_status & DM_BHT_ENTRY_REQUESTED)) {
1021 unsigned int readahead_count;
1022 entry_index++;
1023 readahead_count = min(bht->entry_readahead,
1024 level->count - entry_index);
1025 /* The result is completely ignored since this call is
1026 * critical for the current request.
1027 */
1028 if (readahead_count)
1029 dm_bht_maybe_read_entries(bht, read_cb_ctx,
1030 depth, entry_index,
1031 readahead_count,
1032 true);
1033 }
1034 } 1013 }
1035 1014
1036 /* All nodes are ready. The hash for the block_index can be verified */ 1015 /* All nodes are ready. The hash for the block_index can be verified */
1037 return populated; 1016 return populated;
1038 } 1017 }
1039 EXPORT_SYMBOL(dm_bht_populate); 1018 EXPORT_SYMBOL(dm_bht_populate);
1040 1019
1041 1020
1042 /** 1021 /**
1043 * dm_bht_verify_block - checks that all nodes in the path for @block are valid 1022 * dm_bht_verify_block - checks that all nodes in the path for @block are valid
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1153 * @bht: pointer to a dm_bht_create()d bht 1132 * @bht: pointer to a dm_bht_create()d bht
1154 * @write_cb: callback function used for all write requests by @bht 1133 * @write_cb: callback function used for all write requests by @bht
1155 */ 1134 */
1156 void dm_bht_set_write_cb(struct dm_bht *bht, dm_bht_callback write_cb) 1135 void dm_bht_set_write_cb(struct dm_bht *bht, dm_bht_callback write_cb)
1157 { 1136 {
1158 bht->write_cb = write_cb; 1137 bht->write_cb = write_cb;
1159 } 1138 }
1160 EXPORT_SYMBOL(dm_bht_set_write_cb); 1139 EXPORT_SYMBOL(dm_bht_set_write_cb);
1161 1140
1162 /** 1141 /**
1163 * dm_bht_set_entry_readahead - set verify mode
1164 * @bht: pointer to a dm_bht_create()d bht
1165 * @readahead_count: number of entries to readahead from a given level
1166 */
1167 void dm_bht_set_entry_readahead(struct dm_bht *bht,
1168 unsigned int readahead_count)
1169 {
1170 bht->entry_readahead = readahead_count;
1171 }
1172 EXPORT_SYMBOL(dm_bht_set_entry_readahead);
1173
1174 /**
1175 * dm_bht_set_root_hexdigest - sets an unverified root digest hash from hex 1142 * dm_bht_set_root_hexdigest - sets an unverified root digest hash from hex
1176 * @bht: pointer to a dm_bht_create()d bht 1143 * @bht: pointer to a dm_bht_create()d bht
1177 * @hexdigest: array of u8s containing the new digest in binary 1144 * @hexdigest: array of u8s containing the new digest in binary
1178 * Returns non-zero on error. hexdigest should be NUL terminated. 1145 * Returns non-zero on error. hexdigest should be NUL terminated.
1179 */ 1146 */
1180 int dm_bht_set_root_hexdigest(struct dm_bht *bht, const u8 *hexdigest) 1147 int dm_bht_set_root_hexdigest(struct dm_bht *bht, const u8 *hexdigest)
1181 { 1148 {
1182 if (!bht->root_digest) { 1149 if (!bht->root_digest) {
1183 DMCRIT("No allocation for root digest. Call dm_bht_create"); 1150 DMCRIT("No allocation for root digest. Call dm_bht_create");
1184 return -1; 1151 return -1;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1218 if (!bht->root_digest) { 1185 if (!bht->root_digest) {
1219 DMERR("no root digest exists to export"); 1186 DMERR("no root digest exists to export");
1220 if (available > 0) 1187 if (available > 0)
1221 *hexdigest = 0; 1188 *hexdigest = 0;
1222 return -1; 1189 return -1;
1223 } 1190 }
1224 dm_bht_bin_to_hex(bht->root_digest, hexdigest, bht->digest_size); 1191 dm_bht_bin_to_hex(bht->root_digest, hexdigest, bht->digest_size);
1225 return 0; 1192 return 0;
1226 } 1193 }
1227 EXPORT_SYMBOL(dm_bht_root_hexdigest); 1194 EXPORT_SYMBOL(dm_bht_root_hexdigest);
1228
OLDNEW
« no previous file with comments | « dm-bht.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698