diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2016-10-10 01:15:34 -0800 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@gmail.com> | 2016-10-10 01:17:03 -0800 |
commit | bbd636ddcd421511b0e5d1a6a41d004366990cab (patch) | |
tree | 256178164a5b35eeefe2f489852d2e4bcbd25c98 | |
parent | ae51f287770eb254ec26ff7473dd644c88e0c858 (diff) |
bcache: rip out generational gc
generational copygc has the side effect of potentially fragmenting data,
we probably don't do it by default, if at all
-rw-r--r-- | drivers/md/bcache/alloc.c | 4 | ||||
-rw-r--r-- | drivers/md/bcache/bcache.h | 8 | ||||
-rw-r--r-- | drivers/md/bcache/movinggc.c | 38 | ||||
-rw-r--r-- | drivers/md/bcache/movinggc.h | 3 | ||||
-rw-r--r-- | drivers/md/bcache/super.c | 9 |
5 files changed, 12 insertions, 50 deletions
diff --git a/drivers/md/bcache/alloc.c b/drivers/md/bcache/alloc.c index 3b6ad78ecb9e..ce335693bb44 100644 --- a/drivers/md/bcache/alloc.c +++ b/drivers/md/bcache/alloc.c @@ -1671,9 +1671,7 @@ void bch_cache_allocator_stop(struct cache *ca) for (i = 0; i < ARRAY_SIZE(c->write_points); i++) bch_stop_write_point(ca, &c->write_points[i]); - for (i = 0; i < ARRAY_SIZE(ca->gc_buckets); i++) - bch_stop_write_point(ca, &ca->gc_buckets[i]); - + bch_stop_write_point(ca, &ca->copygc_write_point); bch_stop_write_point(ca, &c->promote_write_point); bch_stop_write_point(ca, &ca->tiering_write_point); bch_stop_write_point(ca, &c->migration_write_point); diff --git a/drivers/md/bcache/bcache.h b/drivers/md/bcache/bcache.h index fee1c37a9486..36bf8841c3d4 100644 --- a/drivers/md/bcache/bcache.h +++ b/drivers/md/bcache/bcache.h @@ -437,13 +437,7 @@ struct cache { struct write_point tiering_write_point; unsigned tiering_stripe_size; - /* - * open buckets used in moving garbage collection - * NOTE: GC_GEN == 0 signifies no moving gc, so accessing the - * gc_buckets array is always GC_GEN-1. - */ -#define NUM_GC_GENS 8 - struct write_point gc_buckets[NUM_GC_GENS]; + struct write_point copygc_write_point; struct journal_device journal; diff --git a/drivers/md/bcache/movinggc.c b/drivers/md/bcache/movinggc.c index 1e6661b00ab9..e8221054a7a8 100644 --- a/drivers/md/bcache/movinggc.c +++ b/drivers/md/bcache/movinggc.c @@ -49,20 +49,16 @@ static int issue_moving_gc_move(struct cache *ca, struct cache_set *c = ca->set; const struct bch_extent_ptr *ptr; struct moving_io *io; - unsigned gen; extent_for_each_ptr(bkey_s_c_to_extent(k), ptr) if ((ca->sb.nr_this_dev == ptr->dev) && - (gen = PTR_BUCKET(ca, ptr)->copygc_gen)) + PTR_BUCKET(ca, ptr)->copygc_gen) goto found; /* We raced - bucket's been reused */ return 0; found: - gen--; - BUG_ON(gen > ARRAY_SIZE(ca->gc_buckets)); - - io = moving_io_alloc(c, q, &ca->gc_buckets[gen], k, ptr); + io = moving_io_alloc(c, q, &ca->copygc_write_point, k, ptr); if (!io) { trace_bcache_moving_gc_alloc_fail(c, k.k->size); return -ENOMEM; @@ -135,7 +131,7 @@ static void bch_moving_gc(struct cache *ca) { struct cache_set *c = ca->set; struct bucket *g; - u64 sectors_to_move, sectors_gen, gen_current, sectors_total; + u64 sectors_to_move; size_t buckets_to_move, buckets_unused = 0; struct bucket_heap_entry e; unsigned sectors_used, i; @@ -209,32 +205,10 @@ static void bch_moving_gc(struct cache *ca) sectors_to_move -= e.val; } - buckets_to_move = ca->heap.used; - - /* - * resort by write_prio to group into generations, attempts to - * keep hot and cold data in the same locality. - */ - - for (i = 0; i < ca->heap.used; i++) { - struct bucket_heap_entry *e = &ca->heap.data[i]; - - e->val = (c->prio_clock[WRITE].hand - e->g->write_prio); - } - - heap_resort(&ca->heap, bucket_max_cmp); - - sectors_gen = sectors_to_move / NUM_GC_GENS; - gen_current = 1; - sectors_total = 0; + for (i = 0; i < ca->heap.used; i++) + ca->heap.data[i].g->copygc_gen = 1; - while (heap_pop(&ca->heap, e, bucket_max_cmp)) { - sectors_total += bucket_sectors_used(e.g); - e.g->copygc_gen = gen_current; - if (gen_current < NUM_GC_GENS && - sectors_total >= sectors_gen * gen_current) - gen_current++; - } + buckets_to_move = ca->heap.used; mutex_unlock(&ca->set->bucket_lock); mutex_unlock(&ca->heap_lock); diff --git a/drivers/md/bcache/movinggc.h b/drivers/md/bcache/movinggc.h index 45496a31a95f..6ee8db55f44a 100644 --- a/drivers/md/bcache/movinggc.h +++ b/drivers/md/bcache/movinggc.h @@ -21,8 +21,7 @@ * fragmentation from the multiple write points for each generation: */ #define COPYGC_SECTORS_PER_ITER(ca) \ - ((ca)->mi.bucket_size * \ - (COPYGC_BUCKETS_PER_ITER(ca) - (NUM_GC_GENS - 1))) + ((ca)->mi.bucket_size * COPYGC_BUCKETS_PER_ITER(ca)) int bch_moving_init_cache(struct cache *); void bch_moving_gc_stop(struct cache *); diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c index d1e95f10b488..ea4ced7b5de0 100644 --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c @@ -1953,8 +1953,7 @@ static const char *cache_alloc(struct bcache_superblock *sb, ca->bucket_bits = ilog2(ca->mi.bucket_size); /* XXX: tune these */ - movinggc_reserve = max_t(size_t, NUM_GC_GENS * 4, - ca->mi.nbuckets >> 7); + movinggc_reserve = max_t(size_t, 16, ca->mi.nbuckets >> 7); reserve_none = max_t(size_t, 4, ca->mi.nbuckets >> 9); /* * free_inc must be smaller than the copygc reserve: if it was bigger, @@ -1996,10 +1995,8 @@ static const char *cache_alloc(struct bcache_superblock *sb, total_reserve += ca->free[i].size; pr_debug("%zu buckets reserved", total_reserve); - for (i = 0; i < ARRAY_SIZE(ca->gc_buckets); i++) { - ca->gc_buckets[i].reserve = RESERVE_MOVINGGC; - ca->gc_buckets[i].group = &ca->self; - } + ca->copygc_write_point.reserve = RESERVE_MOVINGGC; + ca->copygc_write_point.group = &ca->self; ca->tiering_write_point.reserve = RESERVE_NONE; ca->tiering_write_point.group = &ca->self; |