summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2015-08-21 00:32:22 -0800
committerKent Overstreet <kent.overstreet@gmail.com>2016-10-07 09:21:28 -0800
commit0a882e3975049518da4c71dfce5998fa53edb10e (patch)
tree097b575daaca54d3cc0384c5b679495776cd3ee7
parentad6d9b7d545817af82f635659ca720377caab230 (diff)
bcache: mark cache slots used in gc
also make sure we drop pointers for devices that have been removed Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
-rw-r--r--drivers/md/bcache/bcache.h1
-rw-r--r--drivers/md/bcache/btree.c8
-rw-r--r--drivers/md/bcache/extents.c3
3 files changed, 11 insertions, 1 deletions
diff --git a/drivers/md/bcache/bcache.h b/drivers/md/bcache/bcache.h
index 73d0369b2222..a12529df2e39 100644
--- a/drivers/md/bcache/bcache.h
+++ b/drivers/md/bcache/bcache.h
@@ -652,6 +652,7 @@ struct cache_set {
struct cache __rcu *cache[MAX_CACHES_PER_SET];
struct cache_member *members;
+ unsigned long cache_slots_used[BITS_TO_LONGS(MAX_CACHES_PER_SET)];
struct cache_sb sb;
size_t nbuckets;
diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c
index c6bf44079511..e4a4a24f2a3b 100644
--- a/drivers/md/bcache/btree.c
+++ b/drivers/md/bcache/btree.c
@@ -1488,7 +1488,10 @@ u8 __bch_btree_mark_key(struct cache_set *c, int level, struct bkey *k)
rcu_read_lock();
- for (i = bch_extent_ptrs(k) - 1; i >= 0; --i)
+ for (i = bch_extent_ptrs(k) - 1; i >= 0; --i) {
+ if (PTR_DEV(k, i) < MAX_CACHES_PER_SET)
+ __set_bit(PTR_DEV(k, i), c->cache_slots_used);
+
if ((ca = PTR_CACHE(c, k, i))) {
g = PTR_BUCKET(c, ca, k, i);
@@ -1506,6 +1509,7 @@ u8 __bch_btree_mark_key(struct cache_set *c, int level, struct bkey *k)
replicas_found++;
}
+ }
rcu_read_unlock();
@@ -1970,6 +1974,8 @@ static void btree_gc_start(struct cache_set *c)
c->gc_cur_key = ZERO_KEY;
write_sequnlock(&c->gc_cur_lock);
+ memset(c->cache_slots_used, 0, sizeof(c->cache_slots_used));
+
for_each_cache(ca, c, i)
for_each_bucket(g, ca) {
g->last_gc = ca->bucket_gens[g - ca->buckets];
diff --git a/drivers/md/bcache/extents.c b/drivers/md/bcache/extents.c
index 43b855d42fe9..e7a0aa525627 100644
--- a/drivers/md/bcache/extents.c
+++ b/drivers/md/bcache/extents.c
@@ -98,6 +98,9 @@ static bool should_drop_ptr(struct cache_set *c, const struct bkey *k,
if (PTR_DEV(k, ptr) > c->sb.nr_in_set)
return true;
+ if (bch_is_zero(c->members[PTR_DEV(k, ptr)].uuid.b, sizeof(uuid_le)))
+ return true;
+
return (ca = PTR_CACHE(c, k, ptr)) &&
ptr_stale(c, ca, k, ptr);
}