aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2023-05-07 20:01:55 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2023-05-08 03:43:26 -0400
commitc08971632cf3133545259ec5fa008201ca169582 (patch)
tree185ce5f2cc14c54dd3a28ef90403ae6ffda6687c
parent6b1f79d5df9f2735192ed1a40c711cf131d4f43e (diff)
downloadbcachefs-tools-c08971632cf3133545259ec5fa008201ca169582.tar.gz
Update bcachefs sources to e990c131de fixup! bcachefs: BTREE_ID_snapshot_tree
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r--.bcachefs_revision2
-rw-r--r--libbcachefs/journal_io.c22
-rw-r--r--libbcachefs/replicas.c10
-rw-r--r--libbcachefs/subvolume.c17
4 files changed, 33 insertions, 18 deletions
diff --git a/.bcachefs_revision b/.bcachefs_revision
index e5747fce..10ddaf61 100644
--- a/.bcachefs_revision
+++ b/.bcachefs_revision
@@ -1 +1 @@
-6a20aede294f72f3920146a352aa102a9fd3d0aa
+e990c131deed80152eaf640026edf792f6963031
diff --git a/libbcachefs/journal_io.c b/libbcachefs/journal_io.c
index 38458ab0..ede9d198 100644
--- a/libbcachefs/journal_io.c
+++ b/libbcachefs/journal_io.c
@@ -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);
diff --git a/libbcachefs/replicas.c b/libbcachefs/replicas.c
index 8935ff58..8ae50dfd 100644
--- a/libbcachefs/replicas.c
+++ b/libbcachefs/replicas.c
@@ -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 };
diff --git a/libbcachefs/subvolume.c b/libbcachefs/subvolume.c
index 68121df2..320e1a00 100644
--- a/libbcachefs/subvolume.c
+++ b/libbcachefs/subvolume.c
@@ -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);