Chromium Code Reviews| 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; |