Commit 6d828691 authored by Kent Overstreet's avatar Kent Overstreet
Browse files

bcachefs: Better write_super() error messages



When a superblock write is silently dropped or it's been modified by
another process we need to know which device it was.

Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 74768337
Loading
Loading
Loading
Loading
+15 −6
Original line number Diff line number Diff line
@@ -1020,26 +1020,35 @@ int bch2_write_super(struct bch_fs *c)
			continue;

		if (le64_to_cpu(ca->sb_read_scratch->seq) < ca->disk_sb.seq) {
			bch2_fs_fatal_error(c,
			struct printbuf buf = PRINTBUF;
			prt_char(&buf, ' ');
			prt_bdevname(&buf, ca->disk_sb.bdev);
			prt_printf(&buf,
				": Superblock write was silently dropped! (seq %llu expected %llu)",
				le64_to_cpu(ca->sb_read_scratch->seq),
				ca->disk_sb.seq);
			percpu_ref_put(&ca->io_ref);
			bch2_fs_fatal_error(c, "%s", buf.buf);
			printbuf_exit(&buf);
			ret = -BCH_ERR_erofs_sb_err;
			goto out;
		}

		if (le64_to_cpu(ca->sb_read_scratch->seq) > ca->disk_sb.seq) {
			bch2_fs_fatal_error(c,
			struct printbuf buf = PRINTBUF;
			prt_char(&buf, ' ');
			prt_bdevname(&buf, ca->disk_sb.bdev);
			prt_printf(&buf,
				": Superblock modified by another process (seq %llu expected %llu)",
				le64_to_cpu(ca->sb_read_scratch->seq),
				ca->disk_sb.seq);
			percpu_ref_put(&ca->io_ref);
			bch2_fs_fatal_error(c, "%s", buf.buf);
			printbuf_exit(&buf);
			ret = -BCH_ERR_erofs_sb_err;
			goto out;
		}
	}

	if (ret)
		goto out;

	do {
		wrote = false;
		darray_for_each(online_devices, cap) {