bcachefs: bch2_mark_snapshot() now called like other triggers
authorKent Overstreet <kent.overstreet@linux.dev>
Fri, 17 Feb 2023 05:39:12 +0000 (00:39 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:53 +0000 (17:09 -0400)
This fixes a bug where bch2_mark_snapshot() wasn't called for existing
snapshot nodes being updated when child nodes were added.

This led to the data update path thinking the key being updated was for
a snapshot that didn't have children, causing it to fail to insert
whiteouts when splitting existing extents.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/subvolume.c
fs/bcachefs/subvolume.h

index 1805c8542d65381605a5506a5c82554102524587..ba281104eb302bb0621aa026003b14ee67334ea3 100644 (file)
@@ -512,8 +512,7 @@ int bch2_snapshot_node_create(struct btree_trans *trans, u32 parent,
                n->v.pad        = 0;
                SET_BCH_SNAPSHOT_SUBVOL(&n->v, true);
 
-               ret   = bch2_trans_update(trans, &iter, &n->k_i, 0) ?:
-                       bch2_mark_snapshot(trans, bkey_s_c_null, bkey_i_to_s_c(&n->k_i), 0);
+               ret   = bch2_trans_update(trans, &iter, &n->k_i, 0);
                if (ret)
                        goto err;
 
index b6740eab78d3d588f0813e9a2433d45196d7271c..65f108a83835494fd2f6a0d7e1f52df7ca1d439b 100644 (file)
@@ -8,15 +8,15 @@
 void bch2_snapshot_to_text(struct printbuf *, struct bch_fs *, struct bkey_s_c);
 int bch2_snapshot_invalid(const struct bch_fs *, struct bkey_s_c,
                          unsigned, struct printbuf *);
+int bch2_mark_snapshot(struct btree_trans *, struct bkey_s_c,
+                      struct bkey_s_c, unsigned);
 
 #define bch2_bkey_ops_snapshot ((struct bkey_ops) {            \
        .key_invalid    = bch2_snapshot_invalid,                \
        .val_to_text    = bch2_snapshot_to_text,                \
+       .atomic_trigger = bch2_mark_snapshot,                   \
 })
 
-int bch2_mark_snapshot(struct btree_trans *, struct bkey_s_c,
-                      struct bkey_s_c, unsigned);
-
 static inline struct snapshot_t *snapshot_t(struct bch_fs *c, u32 id)
 {
        return genradix_ptr(&c->snapshots, U32_MAX - id);