diff options
author | Nicholas Swenson <nks@daterainc.com> | 2013-10-14 21:53:16 -0400 |
---|---|---|
committer | Kent Overstreet <kmo@daterainc.com> | 2014-01-08 16:05:14 -0500 |
commit | 0f49cf3d83fbf038534c9302095b66b07b9838c3 (patch) | |
tree | 539bb39097a9e06b998be0586bd47dd385f02bab /drivers/md | |
parent | 829a60b9055c319f3656a01eb8cb78b1b86232ef (diff) |
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>
Diffstat (limited to 'drivers/md')
-rw-r--r-- | drivers/md/bcache/bset.c | 27 | ||||
-rw-r--r-- | drivers/md/bcache/bset.h | 12 | ||||
-rw-r--r-- | drivers/md/bcache/extents.c | 5 |
3 files changed, 28 insertions, 16 deletions
diff --git a/drivers/md/bcache/bset.c b/drivers/md/bcache/bset.c index 4a7113236034..7f8a7bd21503 100644 --- a/drivers/md/bcache/bset.c +++ b/drivers/md/bcache/bset.c | |||
@@ -773,6 +773,33 @@ static void bch_bset_fix_lookup_table(struct btree_keys *b, | |||
773 | } | 773 | } |
774 | } | 774 | } |
775 | 775 | ||
776 | /* | ||
777 | * Tries to merge l and r: l should be lower than r | ||
778 | * Returns true if we were able to merge. If we did merge, l will be the merged | ||
779 | * key, r will be untouched. | ||
780 | */ | ||
781 | bool bch_bkey_try_merge(struct btree_keys *b, struct bkey *l, struct bkey *r) | ||
782 | { | ||
783 | if (!b->ops->key_merge) | ||
784 | return false; | ||
785 | |||
786 | /* | ||
787 | * Generic header checks | ||
788 | * Assumes left and right are in order | ||
789 | * Left and right must be exactly aligned | ||
790 | */ | ||
791 | if (KEY_U64s(l) != KEY_U64s(r) || | ||
792 | KEY_DELETED(l) != KEY_DELETED(r) || | ||
793 | KEY_CACHED(l) != KEY_CACHED(r) || | ||
794 | KEY_VERSION(l) != KEY_VERSION(r) || | ||
795 | KEY_CSUM(l) != KEY_CSUM(r) || | ||
796 | bkey_cmp(l, &START_KEY(r))) | ||
797 | return false; | ||
798 | |||
799 | return b->ops->key_merge(b, l, r); | ||
800 | } | ||
801 | EXPORT_SYMBOL(bch_bkey_try_merge); | ||
802 | |||
776 | void bch_bset_insert(struct btree_keys *b, struct bkey *where, | 803 | void bch_bset_insert(struct btree_keys *b, struct bkey *where, |
777 | struct bkey *insert) | 804 | struct bkey *insert) |
778 | { | 805 | { |
diff --git a/drivers/md/bcache/bset.h b/drivers/md/bcache/bset.h index 759df830bb14..487373057c09 100644 --- a/drivers/md/bcache/bset.h +++ b/drivers/md/bcache/bset.h | |||
@@ -287,6 +287,7 @@ void bch_btree_keys_init(struct btree_keys *, const struct btree_keys_ops *, | |||
287 | void bch_bset_init_next(struct btree_keys *, struct bset *, uint64_t); | 287 | void bch_bset_init_next(struct btree_keys *, struct bset *, uint64_t); |
288 | void bch_bset_build_written_tree(struct btree_keys *); | 288 | void bch_bset_build_written_tree(struct btree_keys *); |
289 | void bch_bset_fix_invalidated_key(struct btree_keys *, struct bkey *); | 289 | void bch_bset_fix_invalidated_key(struct btree_keys *, struct bkey *); |
290 | bool bch_bkey_try_merge(struct btree_keys *, struct bkey *, struct bkey *); | ||
290 | void bch_bset_insert(struct btree_keys *, struct bkey *, struct bkey *); | 291 | void bch_bset_insert(struct btree_keys *, struct bkey *, struct bkey *); |
291 | unsigned bch_btree_insert_key(struct btree_keys *, struct bkey *, | 292 | unsigned bch_btree_insert_key(struct btree_keys *, struct bkey *, |
292 | struct bkey *); | 293 | struct bkey *); |
@@ -299,17 +300,6 @@ enum { | |||
299 | BTREE_INSERT_STATUS_FRONT_MERGE, | 300 | BTREE_INSERT_STATUS_FRONT_MERGE, |
300 | }; | 301 | }; |
301 | 302 | ||
302 | /* | ||
303 | * Tries to merge l and r: l should be lower than r | ||
304 | * Returns true if we were able to merge. If we did merge, l will be the merged | ||
305 | * key, r will be untouched. | ||
306 | */ | ||
307 | static inline bool bch_bkey_try_merge(struct btree_keys *b, | ||
308 | struct bkey *l, struct bkey *r) | ||
309 | { | ||
310 | return b->ops->key_merge ? b->ops->key_merge(b, l, r) : false; | ||
311 | } | ||
312 | |||
313 | /* Btree key iteration */ | 303 | /* Btree key iteration */ |
314 | 304 | ||
315 | struct btree_iter { | 305 | struct btree_iter { |
diff --git a/drivers/md/bcache/extents.c b/drivers/md/bcache/extents.c index d6de3c76a87b..7d73d8625522 100644 --- a/drivers/md/bcache/extents.c +++ b/drivers/md/bcache/extents.c | |||
@@ -575,11 +575,6 @@ static bool bch_extent_merge(struct btree_keys *bk, struct bkey *l, struct bkey | |||
575 | if (key_merging_disabled(b->c)) | 575 | if (key_merging_disabled(b->c)) |
576 | return false; | 576 | return false; |
577 | 577 | ||
578 | if (KEY_PTRS(l) != KEY_PTRS(r) || | ||
579 | KEY_DIRTY(l) != KEY_DIRTY(r) || | ||
580 | bkey_cmp(l, &START_KEY(r))) | ||
581 | return false; | ||
582 | |||
583 | for (i = 0; i < KEY_PTRS(l); i++) | 578 | for (i = 0; i < KEY_PTRS(l); i++) |
584 | if (l->ptr[i] + PTR(0, KEY_SIZE(l), 0) != r->ptr[i] || | 579 | if (l->ptr[i] + PTR(0, KEY_SIZE(l), 0) != r->ptr[i] || |
585 | PTR_BUCKET_NR(b->c, l, i) != PTR_BUCKET_NR(b->c, r, i)) | 580 | PTR_BUCKET_NR(b->c, l, i) != PTR_BUCKET_NR(b->c, r, i)) |