aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/bcache/super.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/md/bcache/super.c')
-rw-r--r--drivers/md/bcache/super.c24
1 files changed, 9 insertions, 15 deletions
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index 2d4a56219ec7..a8c57d59a726 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -541,9 +541,6 @@ static void prio_io(struct cache *ca, uint64_t bucket, unsigned long rw)
541 closure_sync(cl); 541 closure_sync(cl);
542} 542}
543 543
544#define buckets_free(c) "free %zu, free_inc %zu, unused %zu", \
545 fifo_used(&c->free), fifo_used(&c->free_inc), fifo_used(&c->unused)
546
547void bch_prio_write(struct cache *ca) 544void bch_prio_write(struct cache *ca)
548{ 545{
549 int i; 546 int i;
@@ -554,10 +551,6 @@ void bch_prio_write(struct cache *ca)
554 551
555 lockdep_assert_held(&ca->set->bucket_lock); 552 lockdep_assert_held(&ca->set->bucket_lock);
556 553
557 for (b = ca->buckets;
558 b < ca->buckets + ca->sb.nbuckets; b++)
559 b->disk_gen = b->gen;
560
561 ca->disk_buckets->seq++; 554 ca->disk_buckets->seq++;
562 555
563 atomic_long_add(ca->sb.bucket_size * prio_buckets(ca), 556 atomic_long_add(ca->sb.bucket_size * prio_buckets(ca),
@@ -601,14 +594,17 @@ void bch_prio_write(struct cache *ca)
601 594
602 mutex_lock(&ca->set->bucket_lock); 595 mutex_lock(&ca->set->bucket_lock);
603 596
604 ca->need_save_prio = 0;
605
606 /* 597 /*
607 * Don't want the old priorities to get garbage collected until after we 598 * Don't want the old priorities to get garbage collected until after we
608 * finish writing the new ones, and they're journalled 599 * finish writing the new ones, and they're journalled
609 */ 600 */
610 for (i = 0; i < prio_buckets(ca); i++) 601 for (i = 0; i < prio_buckets(ca); i++) {
602 if (ca->prio_last_buckets[i])
603 __bch_bucket_free(ca,
604 &ca->buckets[ca->prio_last_buckets[i]]);
605
611 ca->prio_last_buckets[i] = ca->prio_buckets[i]; 606 ca->prio_last_buckets[i] = ca->prio_buckets[i];
607 }
612} 608}
613 609
614static void prio_read(struct cache *ca, uint64_t bucket) 610static void prio_read(struct cache *ca, uint64_t bucket)
@@ -639,7 +635,7 @@ static void prio_read(struct cache *ca, uint64_t bucket)
639 } 635 }
640 636
641 b->prio = le16_to_cpu(d->prio); 637 b->prio = le16_to_cpu(d->prio);
642 b->gen = b->disk_gen = b->last_gc = b->gc_gen = d->gen; 638 b->gen = b->last_gc = b->gc_gen = d->gen;
643 } 639 }
644} 640}
645 641
@@ -1606,7 +1602,7 @@ static void run_cache_set(struct cache_set *c)
1606 goto err; 1602 goto err;
1607 1603
1608 bch_journal_mark(c, &journal); 1604 bch_journal_mark(c, &journal);
1609 bch_btree_gc_finish(c); 1605 bch_initial_gc_finish(c);
1610 pr_debug("btree_check() done"); 1606 pr_debug("btree_check() done");
1611 1607
1612 /* 1608 /*
@@ -1648,7 +1644,7 @@ static void run_cache_set(struct cache_set *c)
1648 ca->sb.d[j] = ca->sb.first_bucket + j; 1644 ca->sb.d[j] = ca->sb.first_bucket + j;
1649 } 1645 }
1650 1646
1651 bch_btree_gc_finish(c); 1647 bch_initial_gc_finish(c);
1652 1648
1653 err = "error starting allocator thread"; 1649 err = "error starting allocator thread";
1654 for_each_cache(ca, c, i) 1650 for_each_cache(ca, c, i)
@@ -1794,7 +1790,6 @@ void bch_cache_release(struct kobject *kobj)
1794 vfree(ca->buckets); 1790 vfree(ca->buckets);
1795 1791
1796 free_heap(&ca->heap); 1792 free_heap(&ca->heap);
1797 free_fifo(&ca->unused);
1798 free_fifo(&ca->free_inc); 1793 free_fifo(&ca->free_inc);
1799 1794
1800 for (i = 0; i < RESERVE_NR; i++) 1795 for (i = 0; i < RESERVE_NR; i++)
@@ -1831,7 +1826,6 @@ static int cache_alloc(struct cache_sb *sb, struct cache *ca)
1831 !init_fifo(&ca->free[RESERVE_MOVINGGC], free, GFP_KERNEL) || 1826 !init_fifo(&ca->free[RESERVE_MOVINGGC], free, GFP_KERNEL) ||
1832 !init_fifo(&ca->free[RESERVE_NONE], free, GFP_KERNEL) || 1827 !init_fifo(&ca->free[RESERVE_NONE], free, GFP_KERNEL) ||
1833 !init_fifo(&ca->free_inc, free << 2, GFP_KERNEL) || 1828 !init_fifo(&ca->free_inc, free << 2, GFP_KERNEL) ||
1834 !init_fifo(&ca->unused, free << 2, GFP_KERNEL) ||
1835 !init_heap(&ca->heap, free << 3, GFP_KERNEL) || 1829 !init_heap(&ca->heap, free << 3, GFP_KERNEL) ||
1836 !(ca->buckets = vzalloc(sizeof(struct bucket) * 1830 !(ca->buckets = vzalloc(sizeof(struct bucket) *
1837 ca->sb.nbuckets)) || 1831 ca->sb.nbuckets)) ||