diff options
-rw-r--r-- | drivers/md/bcache/bcache.h | 2 | ||||
-rw-r--r-- | drivers/md/bcache/bset.c | 7 | ||||
-rw-r--r-- | drivers/md/bcache/btree.c | 3 | ||||
-rw-r--r-- | drivers/md/bcache/super.c | 8 | ||||
-rw-r--r-- | drivers/md/bcache/util.c | 12 | ||||
-rw-r--r-- | drivers/md/bcache/util.h | 1 |
6 files changed, 17 insertions, 16 deletions
diff --git a/drivers/md/bcache/bcache.h b/drivers/md/bcache/bcache.h index 322735547eab..816d07958fac 100644 --- a/drivers/md/bcache/bcache.h +++ b/drivers/md/bcache/bcache.h | |||
@@ -666,11 +666,9 @@ struct cache_set { | |||
666 | unsigned congested_read_threshold_us; | 666 | unsigned congested_read_threshold_us; |
667 | unsigned congested_write_threshold_us; | 667 | unsigned congested_write_threshold_us; |
668 | 668 | ||
669 | spinlock_t sort_time_lock; | ||
670 | struct time_stats sort_time; | 669 | struct time_stats sort_time; |
671 | struct time_stats btree_gc_time; | 670 | struct time_stats btree_gc_time; |
672 | struct time_stats btree_split_time; | 671 | struct time_stats btree_split_time; |
673 | spinlock_t btree_read_time_lock; | ||
674 | struct time_stats btree_read_time; | 672 | struct time_stats btree_read_time; |
675 | struct time_stats try_harder_time; | 673 | struct time_stats try_harder_time; |
676 | 674 | ||
diff --git a/drivers/md/bcache/bset.c b/drivers/md/bcache/bset.c index b0fe0dc59ee6..14573391206b 100644 --- a/drivers/md/bcache/bset.c +++ b/drivers/md/bcache/bset.c | |||
@@ -1077,11 +1077,8 @@ static void __btree_sort(struct btree *b, struct btree_iter *iter, | |||
1077 | if (b->written) | 1077 | if (b->written) |
1078 | bset_build_written_tree(b); | 1078 | bset_build_written_tree(b); |
1079 | 1079 | ||
1080 | if (!start) { | 1080 | if (!start) |
1081 | spin_lock(&b->c->sort_time_lock); | ||
1082 | bch_time_stats_update(&b->c->sort_time, start_time); | 1081 | bch_time_stats_update(&b->c->sort_time, start_time); |
1083 | spin_unlock(&b->c->sort_time_lock); | ||
1084 | } | ||
1085 | } | 1082 | } |
1086 | 1083 | ||
1087 | void bch_btree_sort_partial(struct btree *b, unsigned start) | 1084 | void bch_btree_sort_partial(struct btree *b, unsigned start) |
@@ -1128,9 +1125,7 @@ void bch_btree_sort_into(struct btree *b, struct btree *new) | |||
1128 | 1125 | ||
1129 | btree_mergesort(b, new->sets->data, &iter, false, true); | 1126 | btree_mergesort(b, new->sets->data, &iter, false, true); |
1130 | 1127 | ||
1131 | spin_lock(&b->c->sort_time_lock); | ||
1132 | bch_time_stats_update(&b->c->sort_time, start_time); | 1128 | bch_time_stats_update(&b->c->sort_time, start_time); |
1133 | spin_unlock(&b->c->sort_time_lock); | ||
1134 | 1129 | ||
1135 | bkey_copy_key(&new->key, &b->key); | 1130 | bkey_copy_key(&new->key, &b->key); |
1136 | new->sets->size = 0; | 1131 | new->sets->size = 0; |
diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c index adc5bb0d8e92..1a7530cd1407 100644 --- a/drivers/md/bcache/btree.c +++ b/drivers/md/bcache/btree.c | |||
@@ -317,10 +317,7 @@ void bch_btree_node_read(struct btree *b) | |||
317 | goto err; | 317 | goto err; |
318 | 318 | ||
319 | bch_btree_node_read_done(b); | 319 | bch_btree_node_read_done(b); |
320 | |||
321 | spin_lock(&b->c->btree_read_time_lock); | ||
322 | bch_time_stats_update(&b->c->btree_read_time, start_time); | 320 | bch_time_stats_update(&b->c->btree_read_time, start_time); |
323 | spin_unlock(&b->c->btree_read_time_lock); | ||
324 | 321 | ||
325 | return; | 322 | return; |
326 | err: | 323 | err: |
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c index 041dd9d1d882..4813ef67cef5 100644 --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c | |||
@@ -1435,9 +1435,13 @@ struct cache_set *bch_cache_set_alloc(struct cache_sb *sb) | |||
1435 | init_waitqueue_head(&c->try_wait); | 1435 | init_waitqueue_head(&c->try_wait); |
1436 | init_waitqueue_head(&c->bucket_wait); | 1436 | init_waitqueue_head(&c->bucket_wait); |
1437 | closure_init_unlocked(&c->uuid_write); | 1437 | closure_init_unlocked(&c->uuid_write); |
1438 | spin_lock_init(&c->sort_time_lock); | ||
1439 | mutex_init(&c->sort_lock); | 1438 | mutex_init(&c->sort_lock); |
1440 | spin_lock_init(&c->btree_read_time_lock); | 1439 | |
1440 | spin_lock_init(&c->sort_time.lock); | ||
1441 | spin_lock_init(&c->btree_gc_time.lock); | ||
1442 | spin_lock_init(&c->btree_split_time.lock); | ||
1443 | spin_lock_init(&c->btree_read_time.lock); | ||
1444 | spin_lock_init(&c->try_harder_time.lock); | ||
1441 | 1445 | ||
1442 | bch_moving_init_cache_set(c); | 1446 | bch_moving_init_cache_set(c); |
1443 | 1447 | ||
diff --git a/drivers/md/bcache/util.c b/drivers/md/bcache/util.c index 420dad545c7d..462214eeacbe 100644 --- a/drivers/md/bcache/util.c +++ b/drivers/md/bcache/util.c | |||
@@ -168,10 +168,14 @@ int bch_parse_uuid(const char *s, char *uuid) | |||
168 | 168 | ||
169 | void bch_time_stats_update(struct time_stats *stats, uint64_t start_time) | 169 | void bch_time_stats_update(struct time_stats *stats, uint64_t start_time) |
170 | { | 170 | { |
171 | uint64_t now = local_clock(); | 171 | uint64_t now, duration, last; |
172 | uint64_t duration = time_after64(now, start_time) | 172 | |
173 | spin_lock(&stats->lock); | ||
174 | |||
175 | now = local_clock(); | ||
176 | duration = time_after64(now, start_time) | ||
173 | ? now - start_time : 0; | 177 | ? now - start_time : 0; |
174 | uint64_t last = time_after64(now, stats->last) | 178 | last = time_after64(now, stats->last) |
175 | ? now - stats->last : 0; | 179 | ? now - stats->last : 0; |
176 | 180 | ||
177 | stats->max_duration = max(stats->max_duration, duration); | 181 | stats->max_duration = max(stats->max_duration, duration); |
@@ -188,6 +192,8 @@ void bch_time_stats_update(struct time_stats *stats, uint64_t start_time) | |||
188 | } | 192 | } |
189 | 193 | ||
190 | stats->last = now ?: 1; | 194 | stats->last = now ?: 1; |
195 | |||
196 | spin_unlock(&stats->lock); | ||
191 | } | 197 | } |
192 | 198 | ||
193 | /** | 199 | /** |
diff --git a/drivers/md/bcache/util.h b/drivers/md/bcache/util.h index 8ce5aab55962..362c4b3f8b4a 100644 --- a/drivers/md/bcache/util.h +++ b/drivers/md/bcache/util.h | |||
@@ -378,6 +378,7 @@ ssize_t bch_snprint_string_list(char *buf, size_t size, const char * const list[ | |||
378 | ssize_t bch_read_string_list(const char *buf, const char * const list[]); | 378 | ssize_t bch_read_string_list(const char *buf, const char * const list[]); |
379 | 379 | ||
380 | struct time_stats { | 380 | struct time_stats { |
381 | spinlock_t lock; | ||
381 | /* | 382 | /* |
382 | * all fields are in nanoseconds, averages are ewmas stored left shifted | 383 | * all fields are in nanoseconds, averages are ewmas stored left shifted |
383 | * by 8 | 384 | * by 8 |