diff options
Diffstat (limited to 'fs/bcachefs')
-rw-r--r-- | fs/bcachefs/bset.c | 29 | ||||
-rw-r--r-- | fs/bcachefs/bset.h | 3 | ||||
-rw-r--r-- | fs/bcachefs/btree_io.c | 21 |
3 files changed, 43 insertions, 10 deletions
diff --git a/fs/bcachefs/bset.c b/fs/bcachefs/bset.c index bb73ba9017b0..16eaab773a9c 100644 --- a/fs/bcachefs/bset.c +++ b/fs/bcachefs/bset.c @@ -52,13 +52,13 @@ struct bset_tree *bch2_bkey_to_bset(struct btree *b, struct bkey_packed *k) * by the time we actually do the insert will all be deleted. */ -void bch2_dump_bset(struct bch_fs *c, struct btree *b, - struct bset *i, unsigned set) +void bch2_bset_to_text(struct printbuf *out, + struct bch_fs *c, struct btree *b, + struct bset *i, unsigned set) { struct bkey_packed *_k, *_n; struct bkey uk, n; struct bkey_s_c k; - struct printbuf buf = PRINTBUF; if (!i->u64s) return; @@ -68,15 +68,16 @@ void bch2_dump_bset(struct bch_fs *c, struct btree *b, _k = _n) { _n = bkey_p_next(_k); + prt_printf(out, "block %u key %5zu: \n", set, + _k->_data - i->_data); + k = bkey_disassemble(b, _k, &uk); - printbuf_reset(&buf); if (c) - bch2_bkey_val_to_text(&buf, c, k); + bch2_bkey_val_to_text(out, c, k); else - bch2_bkey_to_text(&buf, k.k); - printk(KERN_ERR "block %u key %5zu: %s\n", set, - _k->_data - i->_data, buf.buf); + bch2_bkey_to_text(out, k.k); + prt_newline(out); if (_n == vstruct_last(i)) continue; @@ -84,14 +85,22 @@ void bch2_dump_bset(struct bch_fs *c, struct btree *b, n = bkey_unpack_key(b, _n); if (bpos_lt(n.p, k.k->p)) { - printk(KERN_ERR "Key skipped backwards\n"); + prt_printf(out, "Key skipped backwards\n"); continue; } if (!bkey_deleted(k.k) && bpos_eq(n.p, k.k->p)) - printk(KERN_ERR "Duplicate keys\n"); + prt_printf(out, "Duplicate keys\n"); } +} + +void bch2_dump_bset(struct bch_fs *c, struct btree *b, + struct bset *i, unsigned set) +{ + struct printbuf buf = PRINTBUF; + bch2_bset_to_text(&buf, c, b, i, set); + bch2_print_string_as_lines(KERN_ERR, buf.buf); printbuf_exit(&buf); } diff --git a/fs/bcachefs/bset.h b/fs/bcachefs/bset.h index 632c2b8c5460..27f7cc27c9e9 100644 --- a/fs/bcachefs/bset.h +++ b/fs/bcachefs/bset.h @@ -510,6 +510,9 @@ void bch2_bfloat_to_text(struct printbuf *, struct btree *, /* Debug stuff */ +void bch2_bset_to_text(struct printbuf *, + struct bch_fs *, struct btree *, + struct bset *, unsigned); void bch2_dump_bset(struct bch_fs *, struct btree *, struct bset *, unsigned); void bch2_dump_btree_node(struct bch_fs *, struct btree *); void bch2_dump_btree_node_iter(struct btree *, struct btree_node_iter *); diff --git a/fs/bcachefs/btree_io.c b/fs/bcachefs/btree_io.c index a6ac68fe90fb..29a81439e050 100644 --- a/fs/bcachefs/btree_io.c +++ b/fs/bcachefs/btree_io.c @@ -2007,6 +2007,27 @@ do_write: /* buffer must be a multiple of the block size */ bytes = round_up(bytes, block_bytes(c)); + if (bytes > btree_bytes(c)) { + struct printbuf buf = PRINTBUF; + + prt_printf(&buf, "bytes to write %u greater than btree bytes %zu\n", + bytes, btree_bytes(c)); + prt_printf(&buf, "whiteout_u64s %u\n", b->whiteout_u64s); + + for_each_bset(b, t) { + i = bset(b, t); + + if (!bset_written(b, i)) + bch2_bset_to_text(&buf, c, b, i, t - b->set); + } + + bch2_print_string_as_lines(KERN_ERR, buf.buf); + printbuf_exit(&buf); + bch2_fatal_error(c); + sectors_to_write = 1; + goto err; + } + data = btree_bounce_alloc(c, bytes, &used_mempool); if (!b->written) { |