diff options
author | Daniel Hill <daniel@gluo.nz> | 2022-09-02 13:01:48 +1200 |
---|---|---|
committer | Daniel Hill <daniel@gluo.nz> | 2022-09-04 15:28:11 +1200 |
commit | 8a438c24d3db8930b0e64c8a383669874336d8a7 (patch) | |
tree | 91695229a6cf42f87b378c513b0dd6288e4525ce | |
parent | 1a49de478f852ed21a9686a8b0a27d9bb644adb0 (diff) |
bcachefs: misc debug crap
-rw-r--r-- | fs/bcachefs/backpointers.c | 6 | ||||
-rw-r--r-- | fs/bcachefs/backpointers.h | 3 | ||||
-rw-r--r-- | fs/bcachefs/move.c | 2 | ||||
-rw-r--r-- | fs/bcachefs/super.h | 6 |
4 files changed, 14 insertions, 3 deletions
diff --git a/fs/bcachefs/backpointers.c b/fs/bcachefs/backpointers.c index 029b1ec14283..3041512117f7 100644 --- a/fs/bcachefs/backpointers.c +++ b/fs/bcachefs/backpointers.c @@ -12,7 +12,7 @@ * Convert from pos in backpointer btree to pos of corresponding bucket in alloc * btree: */ -static inline struct bpos bp_pos_to_bucket(const struct bch_fs *c, +inline struct bpos bp_pos_to_bucket(const struct bch_fs *c, struct bpos bp_pos) { struct bch_dev *ca = bch_dev_bkey_exists(c, bp_pos.inode); @@ -452,6 +452,10 @@ int bch2_get_next_backpointer(struct btree_trans *trans, continue; *dst = *bkey_s_c_to_backpointer(k).v; + + if (bpos_cmp(bp_pos_to_bucket(c, k.k->p), bucket)) + BUG(); + *bp_offset = dst->bucket_offset + BACKPOINTER_OFFSET_MAX; goto out; } diff --git a/fs/bcachefs/backpointers.h b/fs/bcachefs/backpointers.h index fe42af296e9c..63f3bc4c4735 100644 --- a/fs/bcachefs/backpointers.h +++ b/fs/bcachefs/backpointers.h @@ -10,6 +10,9 @@ void bch2_backpointer_to_text(struct printbuf *, const struct bch_backpointer *) void bch2_backpointer_k_to_text(struct printbuf *, struct bch_fs *, struct bkey_s_c); void bch2_backpointer_swab(struct bkey_s); +struct bpos bp_pos_to_bucket(const struct bch_fs *, + struct bpos); + #define bch2_bkey_ops_backpointer (struct bkey_ops) { \ .key_invalid = bch2_backpointer_invalid, \ .val_to_text = bch2_backpointer_k_to_text, \ diff --git a/fs/bcachefs/move.c b/fs/bcachefs/move.c index 224700675604..766993813cbb 100644 --- a/fs/bcachefs/move.c +++ b/fs/bcachefs/move.c @@ -544,7 +544,7 @@ again: prt_str(&buf, "failed to evacuate bucket "); bch2_bkey_val_to_text(&buf, c, k); - bch2_trans_inconsistent(trans, "%s", buf.buf); + bch_err(c, "%s", buf.buf); printbuf_exit(&buf); } } diff --git a/fs/bcachefs/super.h b/fs/bcachefs/super.h index 8501adaff4c2..5a8104be692b 100644 --- a/fs/bcachefs/super.h +++ b/fs/bcachefs/super.h @@ -173,7 +173,11 @@ static inline struct bch_dev *bch2_get_next_online_dev(struct bch_fs *c, */ static inline struct bch_dev *bch_dev_bkey_exists(const struct bch_fs *c, unsigned idx) { - EBUG_ON(idx >= c->sb.nr_devices || !c->devs[idx]); + + if (idx >= c->sb.nr_devices || !c->devs[idx]) { + printk("bad bkey %ui", idx); + EBUG_ON(1); + } return rcu_dereference_check(c->devs[idx], 1); } |