bcache: Add bch_bkey_equal_header()

Checks if two keys have equivalent header fields.
(good enough for replacement or merging)

Used in bch_bkey_try_merge, and replacing a key
in the btree.

Signed-off-by: Nicholas Swenson <nks@daterainc.com>
Signed-off-by: Kent Overstreet <kmo@daterainc.com>
This commit is contained in:
Nicholas Swenson
2013-11-11 19:36:25 -08:00
committed by Kent Overstreet
parent 0f49cf3d83
commit 3bdad1e40d
3 changed files with 11 additions and 8 deletions

View File

@@ -788,12 +788,8 @@ bool bch_bkey_try_merge(struct btree_keys *b, struct bkey *l, struct bkey *r)
* Assumes left and right are in order
* Left and right must be exactly aligned
*/
if (KEY_U64s(l) != KEY_U64s(r) ||
KEY_DELETED(l) != KEY_DELETED(r) ||
KEY_CACHED(l) != KEY_CACHED(r) ||
KEY_VERSION(l) != KEY_VERSION(r) ||
KEY_CSUM(l) != KEY_CSUM(r) ||
bkey_cmp(l, &START_KEY(r)))
if (!bch_bkey_equal_header(l, r) ||
bkey_cmp(l, &START_KEY(r)))
return false;
return b->ops->key_merge(b, l, r);