summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSlava Pestov <sp@daterainc.com>2015-02-03 17:41:57 -0800
committerKent Overstreet <kmo@daterainc.com>2015-02-12 23:43:48 -0800
commit68560fb51e5da0ff214dc971868243a299b598c5 (patch)
tree6e3368a7c146e36faaeba072bcf43bc2f0537c01
parentbbe83d0d7c8be022dbd96603360fbe8824325863 (diff)
bcache: make discard work like it did before when version is zero
- list_extents ioctl skips discard keys with zero version - inserting discard key with zero version unconditionally deletes overlapping keys Change-Id: Iff4053a5b446d9114e7ddcb764f15f6f49d6d3ab
-rw-r--r--drivers/md/bcache/extents.c2
-rw-r--r--drivers/md/bcache/ioctl.c6
2 files changed, 7 insertions, 1 deletions
diff --git a/drivers/md/bcache/extents.c b/drivers/md/bcache/extents.c
index 775560b63145..56a922a64a57 100644
--- a/drivers/md/bcache/extents.c
+++ b/drivers/md/bcache/extents.c
@@ -1147,7 +1147,7 @@ bool bch_insert_fixup_extent(struct btree *b, struct bkey *insert,
&inserted, res))
continue;
- if (k->size &&
+ if (k->size && insert->version &&
insert->version < k->version) {
handle_existing_key_newer(b, iter, insert, k,
&inserted, res);
diff --git a/drivers/md/bcache/ioctl.c b/drivers/md/bcache/ioctl.c
index fbb7f5f30a9a..c2bd70a51d7a 100644
--- a/drivers/md/bcache/ioctl.c
+++ b/drivers/md/bcache/ioctl.c
@@ -265,6 +265,7 @@ static int __bch_list_keys(struct cache_set *c, struct bch_ioctl_list_keys *i)
struct btree_iter iter;
const struct bkey *k;
int ret = 0;
+ unsigned type;
BKEY_PADDED(k) prev_key;
if (i->btree_id != BTREE_ID_EXTENTS &&
@@ -274,6 +275,8 @@ static int __bch_list_keys(struct cache_set *c, struct bch_ioctl_list_keys *i)
for_each_btree_key(&iter, c, i->btree_id, k, i->start) {
BKEY_PADDED(k) tmp;
+ type = k->type;
+
if (bkey_cmp(bkey_start_pos(k), i->end) >= 0)
break;
@@ -284,6 +287,9 @@ static int __bch_list_keys(struct cache_set *c, struct bch_ioctl_list_keys *i)
}
if (i->btree_id == BTREE_ID_EXTENTS) {
+ if (type == KEY_TYPE_DISCARD && k->version == 0)
+ continue;
+
if (k != &tmp.k) {
bkey_copy(&tmp.k, k);
k = &tmp.k;