mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-12 13:55:32 +00:00
bcache: update bch_bkey_try_merge
Added generic header checks to bch_bkey_try_merge, which then calls the bkey specific function Removed extraneous checks from bch_extent_merge Signed-off-by: Nicholas Swenson <nks@daterainc.com>
This commit is contained in:
parent
829a60b905
commit
0f49cf3d83
3 changed files with 28 additions and 16 deletions
|
@ -773,6 +773,33 @@ static void bch_bset_fix_lookup_table(struct btree_keys *b,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Tries to merge l and r: l should be lower than r
|
||||||
|
* Returns true if we were able to merge. If we did merge, l will be the merged
|
||||||
|
* key, r will be untouched.
|
||||||
|
*/
|
||||||
|
bool bch_bkey_try_merge(struct btree_keys *b, struct bkey *l, struct bkey *r)
|
||||||
|
{
|
||||||
|
if (!b->ops->key_merge)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Generic header checks
|
||||||
|
* 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)))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return b->ops->key_merge(b, l, r);
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(bch_bkey_try_merge);
|
||||||
|
|
||||||
void bch_bset_insert(struct btree_keys *b, struct bkey *where,
|
void bch_bset_insert(struct btree_keys *b, struct bkey *where,
|
||||||
struct bkey *insert)
|
struct bkey *insert)
|
||||||
{
|
{
|
||||||
|
|
|
@ -287,6 +287,7 @@ void bch_btree_keys_init(struct btree_keys *, const struct btree_keys_ops *,
|
||||||
void bch_bset_init_next(struct btree_keys *, struct bset *, uint64_t);
|
void bch_bset_init_next(struct btree_keys *, struct bset *, uint64_t);
|
||||||
void bch_bset_build_written_tree(struct btree_keys *);
|
void bch_bset_build_written_tree(struct btree_keys *);
|
||||||
void bch_bset_fix_invalidated_key(struct btree_keys *, struct bkey *);
|
void bch_bset_fix_invalidated_key(struct btree_keys *, struct bkey *);
|
||||||
|
bool bch_bkey_try_merge(struct btree_keys *, struct bkey *, struct bkey *);
|
||||||
void bch_bset_insert(struct btree_keys *, struct bkey *, struct bkey *);
|
void bch_bset_insert(struct btree_keys *, struct bkey *, struct bkey *);
|
||||||
unsigned bch_btree_insert_key(struct btree_keys *, struct bkey *,
|
unsigned bch_btree_insert_key(struct btree_keys *, struct bkey *,
|
||||||
struct bkey *);
|
struct bkey *);
|
||||||
|
@ -299,17 +300,6 @@ enum {
|
||||||
BTREE_INSERT_STATUS_FRONT_MERGE,
|
BTREE_INSERT_STATUS_FRONT_MERGE,
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
* Tries to merge l and r: l should be lower than r
|
|
||||||
* Returns true if we were able to merge. If we did merge, l will be the merged
|
|
||||||
* key, r will be untouched.
|
|
||||||
*/
|
|
||||||
static inline bool bch_bkey_try_merge(struct btree_keys *b,
|
|
||||||
struct bkey *l, struct bkey *r)
|
|
||||||
{
|
|
||||||
return b->ops->key_merge ? b->ops->key_merge(b, l, r) : false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Btree key iteration */
|
/* Btree key iteration */
|
||||||
|
|
||||||
struct btree_iter {
|
struct btree_iter {
|
||||||
|
|
|
@ -575,11 +575,6 @@ static bool bch_extent_merge(struct btree_keys *bk, struct bkey *l, struct bkey
|
||||||
if (key_merging_disabled(b->c))
|
if (key_merging_disabled(b->c))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (KEY_PTRS(l) != KEY_PTRS(r) ||
|
|
||||||
KEY_DIRTY(l) != KEY_DIRTY(r) ||
|
|
||||||
bkey_cmp(l, &START_KEY(r)))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
for (i = 0; i < KEY_PTRS(l); i++)
|
for (i = 0; i < KEY_PTRS(l); i++)
|
||||||
if (l->ptr[i] + PTR(0, KEY_SIZE(l), 0) != r->ptr[i] ||
|
if (l->ptr[i] + PTR(0, KEY_SIZE(l), 0) != r->ptr[i] ||
|
||||||
PTR_BUCKET_NR(b->c, l, i) != PTR_BUCKET_NR(b->c, r, i))
|
PTR_BUCKET_NR(b->c, l, i) != PTR_BUCKET_NR(b->c, r, i))
|
||||||
|
|
Loading…
Reference in a new issue