Skip to content

Commit f49d2c9

Browse files
author
Kent Overstreet
committed
bcachefs: Warn on attempting a move with no replicas
Instead of popping an assert in bch2_write(), WARN and print out some debugging info. Signed-off-by: Kent Overstreet <[email protected]>
1 parent ad8b68c commit f49d2c9

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

fs/bcachefs/data_update.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,16 @@ int bch2_data_update_init(struct btree_trans *trans,
677677
if (!(durability_have + durability_removing))
678678
m->op.nr_replicas = max((unsigned) m->op.nr_replicas, 1);
679679

680+
if (!m->op.nr_replicas) {
681+
struct printbuf buf = PRINTBUF;
682+
683+
bch2_data_update_to_text(&buf, m);
684+
WARN(1, "trying to move an extent, but nr_replicas=0\n%s", buf.buf);
685+
printbuf_exit(&buf);
686+
ret = -BCH_ERR_data_update_done;
687+
goto done;
688+
}
689+
680690
m->op.nr_replicas_required = m->op.nr_replicas;
681691

682692
if (reserve_sectors) {

0 commit comments

Comments
 (0)