]> git.sesse.net Git - bcachefs-tools-debian/commitdiff
Update bcachefs sources to e990c131de fixup! bcachefs: BTREE_ID_snapshot_tree
authorKent Overstreet <kent.overstreet@linux.dev>
Mon, 8 May 2023 00:01:55 +0000 (20:01 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Mon, 8 May 2023 07:43:26 +0000 (03:43 -0400)
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
.bcachefs_revision
libbcachefs/journal_io.c
libbcachefs/replicas.c
libbcachefs/subvolume.c

index e5747fce31c81b1b0de1ae11b230919ce9668abd..10ddaf61ae32e2c999203db544651e8c3dc143d2 100644 (file)
@@ -1 +1 @@
-6a20aede294f72f3920146a352aa102a9fd3d0aa
+e990c131deed80152eaf640026edf792f6963031
index 38458ab0013d049d6b7cc3c6db990be1a09e2c95..ede9d198bb85186d60c68dbc0406d5ae568d892f 100644 (file)
@@ -1462,7 +1462,6 @@ static void journal_write_done(struct closure *cl)
        struct journal *j = container_of(cl, struct journal, io);
        struct bch_fs *c = container_of(j, struct bch_fs, journal);
        struct journal_buf *w = journal_last_unwritten_buf(j);
-       struct bch_replicas_padded replicas;
        union journal_res_state old, new;
        u64 v, seq;
        int err = 0;
@@ -1474,13 +1473,7 @@ static void journal_write_done(struct closure *cl)
        if (!w->devs_written.nr) {
                bch_err(c, "unable to write journal to sufficient devices");
                err = -EIO;
-       } else {
-               bch2_devlist_to_replicas(&replicas.e, BCH_DATA_journal,
-                                        w->devs_written);
-               if (bch2_mark_replicas(c, &replicas.e))
-                       err = -EIO;
        }
-
        if (err)
                bch2_fatal_error(c);
 
@@ -1672,6 +1665,7 @@ void bch2_journal_write(struct closure *cl)
        struct bch_fs *c = container_of(j, struct bch_fs, journal);
        struct bch_dev *ca;
        struct journal_buf *w = journal_last_unwritten_buf(j);
+       struct bch_replicas_padded replicas;
        struct jset_entry *start, *end;
        struct jset *jset;
        struct bio *bio;
@@ -1822,9 +1816,7 @@ retry_alloc:
                bch_err(c, "Unable to allocate journal write:\n%s",
                        journal_debug_buf.buf);
                printbuf_exit(&journal_debug_buf);
-               bch2_fatal_error(c);
-               continue_at(cl, journal_write_done, c->io_complete_wq);
-               return;
+               goto err;
        }
 
        w->devs_written = bch2_bkey_devs(bkey_i_to_s_c(&w->key));
@@ -1838,6 +1830,16 @@ retry_alloc:
        if (nr_rw_members > 1)
                w->separate_flush = true;
 
+       /*
+        * Mark journal replicas before we submit the write to guarantee
+        * recovery will find the journal entries after a crash.
+        */
+       bch2_devlist_to_replicas(&replicas.e, BCH_DATA_journal,
+                                w->devs_written);
+       ret = bch2_mark_replicas(c, &replicas.e);
+       if (ret)
+               goto err;
+
        if (!JSET_NO_FLUSH(jset) && w->separate_flush) {
                for_each_rw_member(ca, c, i) {
                        percpu_ref_get(&ca->io_ref);
index 8935ff5899c99debc21643781896dee8079eeeb6..8ae50dfd8c8c0f14e4ee6b764a9faa886c909b5f 100644 (file)
@@ -550,8 +550,14 @@ int bch2_replicas_gc_start(struct bch_fs *c, unsigned typemask)
        return 0;
 }
 
-/* New much simpler mechanism for clearing out unneeded replicas entries: */
-
+/*
+ * New much simpler mechanism for clearing out unneeded replicas entries - drop
+ * replicas entries that have 0 sectors used.
+ *
+ * However, we don't track sector counts for journal usage, so this doesn't drop
+ * any BCH_DATA_journal entries; the old bch2_replicas_gc_(start|end) mechanism
+ * is retained for that.
+ */
 int bch2_replicas_gc2(struct bch_fs *c)
 {
        struct bch_replicas_cpu new = { 0 };
index 68121df2db669ddef47c34ce2aac0196ac7fdda3..320e1a008764b38a44bdc47790c5994fca5d5dd0 100644 (file)
@@ -358,12 +358,18 @@ static int check_snapshot_tree(struct btree_trans *trans,
        if (ret && !bch2_err_matches(ret, ENOENT))
                goto err;
 
-       if (fsck_err_on(ret ||
-                       !bch2_snapshot_is_ancestor(c,
+       if (fsck_err_on(ret, c,
+                       "snapshot tree points to missing subvolume:\n  %s",
+                       (printbuf_reset(&buf),
+                        bch2_bkey_val_to_text(&buf, c, st.s_c), buf.buf)) ||
+           fsck_err_on(!bch2_snapshot_is_ancestor(c,
                                                   le32_to_cpu(subvol.snapshot),
-                                                  root_id) ||
-                       !BCH_SUBVOLUME_SNAP(&subvol), c,
-                       "snapshot tree points to missing/incorrect subvolume:\n  %s",
+                                                  root_id), c,
+                       "snapshot tree points to subvolume that does not point to snapshot in this tree:\n  %s",
+                       (printbuf_reset(&buf),
+                        bch2_bkey_val_to_text(&buf, c, st.s_c), buf.buf)) ||
+           fsck_err_on(BCH_SUBVOLUME_SNAP(&subvol), c,
+                       "snapshot tree points to snapshot subvolume:\n  %s",
                        (printbuf_reset(&buf),
                         bch2_bkey_val_to_text(&buf, c, st.s_c), buf.buf))) {
                struct bkey_i_snapshot_tree *u;
@@ -586,6 +592,7 @@ static int check_snapshot(struct btree_trans *trans,
                if (ret)
                        goto err;
        }
+       ret = 0;
 
        if (BCH_SNAPSHOT_DELETED(s.v))
                set_bit(BCH_FS_HAVE_DELETED_SNAPSHOTS, &c->flags);