summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2016-02-23 11:01:13 -0900
committerKent Overstreet <kent.overstreet@gmail.com>2016-08-28 19:16:15 -0800
commit41d25a23991ff1138cdf4018e52221568c130aab (patch)
tree10a255c11e360d4495bec42e0e8fe7ad121ea798
parentc278f32ecef59798c207955e8a18b2702158779f (diff)
debug crap
-rw-r--r--fs/bcachefs/btree_gc.c4
-rw-r--r--fs/bcachefs/buckets.c26
-rw-r--r--fs/bcachefs/journal.c11
3 files changed, 38 insertions, 3 deletions
diff --git a/fs/bcachefs/btree_gc.c b/fs/bcachefs/btree_gc.c
index 532248778534..965b4a58ba9a 100644
--- a/fs/bcachefs/btree_gc.c
+++ b/fs/bcachefs/btree_gc.c
@@ -270,7 +270,9 @@ static void bch_mark_metadata(struct cache_set *c)
for (i = ca->prio_buckets;
i < ca->prio_buckets + prio_buckets(ca) * 2; i++)
- bch_mark_metadata_bucket(ca, &ca->buckets[*i], true);
+ if (*i)
+ bch_mark_metadata_bucket(ca, &ca->buckets[*i],
+ true);
spin_unlock(&ca->prio_buckets_lock);
}
diff --git a/fs/bcachefs/buckets.c b/fs/bcachefs/buckets.c
index 596d90034bbd..a7b8e7ce7ab1 100644
--- a/fs/bcachefs/buckets.c
+++ b/fs/bcachefs/buckets.c
@@ -275,6 +275,9 @@ static struct bucket_mark bch_bucket_mark_set(struct cache *ca,
struct bucket_stats_cache_set stats = { 0 };
struct bucket_mark old;
+ BUG_ON(g < ca->buckets + ca->mi.first_bucket ||
+ g >= ca->buckets + ca->mi.nbuckets);
+
old.counter = xchg(&g->mark.counter, new.counter);
bucket_stats_update(ca, old, new, may_make_unavailable, &stats);
@@ -302,6 +305,9 @@ static struct bucket_mark bch_bucket_mark_set(struct cache *ca,
do { \
u32 _v = READ_ONCE((g)->mark.counter); \
\
+ BUG_ON((g) < ca->buckets + ca->mi.first_bucket || \
+ (g) >= ca->buckets + ca->mi.nbuckets); \
+ \
do { \
new.counter = old.counter = _v; \
expr; \
@@ -624,6 +630,8 @@ void bch_unmark_open_bucket(struct cache *ca, struct bucket *g)
static u64 __recalc_sectors_available(struct cache_set *c)
{
+ BUG_ON(c->gc_pos.phase != GC_PHASE_DONE);
+
return c->online_capacity - cache_set_sectors_used(c);
}
@@ -669,6 +677,13 @@ int bch_disk_reservation_add(struct cache_set *c,
s64 sectors_available;
int ret;
+ //BUG_ON(sectors > S32_MAX);
+#if 0
+ u64 used;
+ if ((used = __cache_set_sectors_used(c)) > c->capacity)
+ panic("1: used %llu > capacity %llu\n", used, c->capacity);
+#endif
+
lg_local_lock(&c->bucket_stats_lock);
stats = this_cpu_ptr(c->bucket_stats_percpu);
@@ -695,6 +710,10 @@ out:
bch_cache_set_stats_verify(c);
lg_local_unlock(&c->bucket_stats_lock);
+#if 0
+ if ((used = __cache_set_sectors_used(c)) > c->capacity)
+ panic("2: used %llu > capacity %llu\n", used, c->capacity);
+#endif
return 0;
recalculate:
@@ -721,6 +740,11 @@ recalculate:
}
bch_cache_set_stats_verify(c);
+#if 0
+ if ((used = __cache_set_sectors_used(c)) > c->capacity)
+ panic("3: used %llu > capacity %llu ret %i sectors %u sectors_available %llu\n",
+ used, c->capacity, ret, sectors, sectors_available);
+#endif
lg_global_unlock(&c->bucket_stats_lock);
if (!(flags & BCH_DISK_RESERVATION_GC_LOCK_HELD))
up_read(&c->gc_lock);
@@ -751,7 +775,7 @@ void bch_capacity_update(struct cache_set *c, u64 new_capacity)
for_each_possible_cpu(cpu) {
stats = per_cpu_ptr(c->bucket_stats_percpu, cpu);
- stats->sectors_available_cache = 0;
+ stats->available_cache = 0;
}
c->online_capacity = new_capacity;
diff --git a/fs/bcachefs/journal.c b/fs/bcachefs/journal.c
index c0ea77524792..1b49c44f92c4 100644
--- a/fs/bcachefs/journal.c
+++ b/fs/bcachefs/journal.c
@@ -1367,7 +1367,16 @@ err:
bch_err(c, "journal replay error: %d", ret);
journal_entries_free(j, list);
-
+#if 0
+ {
+ struct bucket_stats_cache_set s =
+ __bch_bucket_stats_read_cache_set(c);
+ pr_info("post replay: meta %llu dirty %llu reserved %llu",
+ s.sectors_meta,
+ s.sectors_dirty,
+ s.sectors_reserved);
+ }
+#endif
return ret;
}