bcachefs: Improve error messages in superblock write path
authorKent Overstreet <kent.overstreet@gmail.com>
Sun, 2 Jan 2022 00:04:33 +0000 (19:04 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:21 +0000 (17:09 -0400)
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
fs/bcachefs/super-io.c

index 8928f1b..e0b1dfa 100644 (file)
@@ -754,11 +754,24 @@ int bch2_write_super(struct bch_fs *c)
        closure_sync(cl);
 
        for_each_online_member(ca, c, i) {
-               if (!ca->sb_write_error &&
-                   ca->disk_sb.seq !=
-                   le64_to_cpu(ca->sb_read_scratch->seq)) {
+               if (ca->sb_write_error)
+                       continue;
+
+               if (le64_to_cpu(ca->sb_read_scratch->seq) < ca->disk_sb.seq) {
+                       bch2_fs_fatal_error(c,
+                               "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);
+                       ret = -EROFS;
+                       goto out;
+               }
+
+               if (le64_to_cpu(ca->sb_read_scratch->seq) > ca->disk_sb.seq) {
                        bch2_fs_fatal_error(c,
-                               "Superblock modified by another process");
+                               "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);
                        ret = -EROFS;
                        goto out;