summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2016-09-05 18:54:51 -0800
committerKent Overstreet <kent.overstreet@gmail.com>2016-09-08 19:07:20 -0800
commitf4543f9c65ac340c38742d0307f6aeef080b7119 (patch)
treee969c31a0523944edf2e9333897b4a82a36f505d
parent6c4b58995eccba3dba5843ed13a1e284d8be2625 (diff)
bcache: fix tiering ratelimiting
-rw-r--r--drivers/md/bcache/tier.c39
1 files changed, 26 insertions, 13 deletions
diff --git a/drivers/md/bcache/tier.c b/drivers/md/bcache/tier.c
index a68726fedd5c..87f4971dfda7 100644
--- a/drivers/md/bcache/tier.c
+++ b/drivers/md/bcache/tier.c
@@ -349,6 +349,8 @@ static u64 read_tiering(struct cache_set *c)
trace_bcache_tiering_end(c, ctxt.sectors_moved, ctxt.keys_moved);
+ //pr_info("pred y %llu pred n %llu", c->tiering_pred_y, c->tiering_pred_n);
+
return ctxt.sectors_moved;
}
@@ -357,7 +359,7 @@ static int bch_tiering_thread(void *arg)
struct cache_set *c = arg;
struct io_clock *clock = &c->io_clock[WRITE];
struct cache *ca;
- u64 sectors, tier_capacity;
+ u64 tier_capacity, available_sectors;
unsigned long last;
unsigned i;
@@ -368,21 +370,32 @@ static int bch_tiering_thread(void *arg)
c->cache_tiers[1].nr_devices))
break;
- last = atomic_long_read(&clock->now);
-
- sectors = read_tiering(c);
+ while (1) {
+ last = atomic_long_read(&clock->now);
+
+ tier_capacity = available_sectors = 0;
+ rcu_read_lock();
+ group_for_each_cache_rcu(ca, &c->cache_tiers[0], i) {
+ tier_capacity +=
+ (ca->mi.nbuckets -
+ ca->mi.first_bucket) << ca->bucket_bits;
+ available_sectors +=
+ buckets_available_cache(ca) << ca->bucket_bits;
+ }
+ rcu_read_unlock();
- tier_capacity = 0;
- rcu_read_lock();
- group_for_each_cache_rcu(ca, &c->cache_tiers[0], i)
- tier_capacity +=
- (ca->mi.nbuckets -
- ca->mi.first_bucket) << ca->bucket_bits;
- rcu_read_unlock();
+ if (available_sectors < (tier_capacity >> 1))
+ break;
- if (sectors < tier_capacity >> 4)
bch_kthread_io_clock_wait(clock,
- last + (tier_capacity >> 5));
+ last +
+ available_sectors -
+ (tier_capacity >> 1));
+ if (kthread_should_stop())
+ return 0;
+ }
+
+ read_tiering(c);
}
return 0;