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

Unified Diff: dm-bht.c

Issue 6721017: verity: short circuit once you hit a verified node (Closed) Base URL: http://git.chromium.org/git/dm-verity.git@master
Patch Set: Created 9 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dm-bht.c
diff --git a/dm-bht.c b/dm-bht.c
index 46b03c09702bd31ad8319228c24112164c31cac7..4c262a54d0cbd35fca49e0a1c690bccd53628bc6 100644
--- a/dm-bht.c
+++ b/dm-bht.c
@@ -691,12 +691,13 @@ static int dm_bht_verify_path(struct dm_bht *bht, unsigned int block_index)
int state;
DMDEBUG("verify_path for b=%u on d=%d", block_index, depth);
+ /* TODO(msb,wad): would be nice to avoid two atomic reads */
Paul T 2011/03/23 17:19:28 I'd like to understand this comment better. From w
state = atomic_read(&entry->state);
if (state == DM_BHT_ENTRY_VERIFIED) {
- DMDEBUG("verify_path node %u is verified in parent",
+ DMDEBUG("verify_path node %u is verified to root",
block_index);
- entry = dm_bht_get_entry(bht, --depth, block_index);
- continue;
+ depth++; /* avoid an extra cmpxchg */
+ break;
} else if (state <= DM_BHT_ENTRY_ERROR) {
DMCRIT("entry(d=%u,b=%u) is in an error state: %d",
depth, block_index, state);
@@ -726,12 +727,15 @@ static int dm_bht_verify_path(struct dm_bht *bht, unsigned int block_index)
goto mismatch;
}
+ entry = parent;
+ depth--;
+ }
+ /* Mark path to leaf as verified. */
+ for (; depth < bht->depth; depth++) {
+ entry = dm_bht_get_entry(bht, depth, block_index);
atomic_cmpxchg(&entry->state,
DM_BHT_ENTRY_READY,
DM_BHT_ENTRY_VERIFIED);
-
- entry = parent;
- depth--;
}
return 0;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698