bcachefs: Better write_super() error messages
authorKent Overstreet <kent.overstreet@linux.dev>
Fri, 3 May 2024 18:17:54 +0000 (14:17 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Wed, 8 May 2024 21:29:17 +0000 (17:29 -0400)
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: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/super-io.c

index bfdb15e7d778e24e6d6d327168646d18b17f4464..1cadc99898f562485401309dd09ff9fca422a9f5 100644 (file)
@@ -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) {