summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2016-04-16 20:18:14 -0800
committerKent Overstreet <kent.overstreet@gmail.com>2016-10-07 12:36:14 -0800
commit669bebb00474c2c9eb613de8f5e82f14c31a66fd (patch)
tree79c6d9ee61dc216ba0a83e22f1c351a4ceff79f3
parent046380d08452eeb7e5d831c32128b786e238d5da (diff)
bcache: fix extent_cleanup_crcs()
-rw-r--r--drivers/md/bcache/extents.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/drivers/md/bcache/extents.c b/drivers/md/bcache/extents.c
index 1c04c629cea4..169182992e75 100644
--- a/drivers/md/bcache/extents.c
+++ b/drivers/md/bcache/extents.c
@@ -199,26 +199,25 @@ static void extent_cleanup_crcs(struct bkey_s_extent e)
if (!extent_entry_is_crc(crc))
goto next;
- if (next != extent_entry_last(e) &&
- extent_entry_is_crc(next)) {
- /*
- * Two crc entries right after the other, the first one
- * doesn't have any pointers and we can just drop it:
- */
+ if (next == extent_entry_last(e)) {
+ /* crc entry with no pointers after it: */
+ goto drop;
+ }
+
+ if (extent_entry_is_crc(next)) {
+ /* no pointers before next crc entry: */
goto drop;
}
if (prev && crc_cmp(crc, prev)) {
- /*
- * This crc entry is identical to the previous one, drop
- * it:
- */
+ /* identical to previous crc entry: */
goto drop;
}
if (!prev &&
!crc_to_64((void *) crc).csum_type &&
!crc_to_64((void *) crc).compression_type){
+ /* null crc entry: */
extent_adjust_pointers(e, crc);
goto drop;
}
@@ -232,6 +231,8 @@ drop:
(void *) extent_entry_last(e) - (void *) next);
e.k->u64s -= crc_u64s;
}
+
+ EBUG_ON(bkey_val_u64s(e.k) && !bch_extent_nr_ptrs(e.c));
}
void bch_extent_drop_ptr(struct bkey_s_extent e, struct bch_extent_ptr *ptr)
@@ -1716,8 +1717,7 @@ bool bch_extent_normalize(struct cache_set *c, struct bkey_s k)
bch_extent_drop_stale(c, e);
extent_sort_ptrs(c, e);
- if (!bch_extent_nr_ptrs(e.c)) {
- set_bkey_val_u64s(e.k, 0);
+ if (!bkey_val_u64s(e.k)) {
if (bkey_extent_is_cached(e.k)) {
k.k->type = KEY_TYPE_DISCARD;
if (!k.k->version)