]> git.dujemihanovic.xyz Git - linux.git/commitdiff
bcachefs: Fix missing alloc_data_type_set()
authorKent Overstreet <kent.overstreet@linux.dev>
Thu, 20 Jun 2024 14:04:35 +0000 (10:04 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Fri, 21 Jun 2024 14:17:07 +0000 (10:17 -0400)
Incorrect bucket state transition in the discard path; when incrementing
a bucket's generation number that had already been discarded, we were
forgetting to check if it should be need_gc_gens, not free.

This was caught by the .invalid checks in the transaction commit path,
causing us to go emergency read only.

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

index 7b5909764d148170c0acf52ce75d3bb1bde7fee3..e5e7d33f4a5ef95033aa170e2d736fc19e5922d2 100644 (file)
@@ -776,6 +776,7 @@ int bch2_trigger_alloc(struct btree_trans *trans,
                    !bch2_bucket_is_open_safe(c, new.k->p.inode, new.k->p.offset)) {
                        new_a->gen++;
                        SET_BCH_ALLOC_V4_NEED_INC_GEN(new_a, false);
+                       alloc_data_type_set(new_a, new_a->data_type);
                }
 
                if (old_a->data_type != new_a->data_type ||
@@ -1796,8 +1797,9 @@ static int bch2_discard_one_bucket(struct btree_trans *trans,
        }
 
        SET_BCH_ALLOC_V4_NEED_DISCARD(&a->v, false);
-       alloc_data_type_set(&a->v, a->v.data_type);
 write:
+       alloc_data_type_set(&a->v, a->v.data_type);
+
        ret =   bch2_trans_update(trans, &iter, &a->k_i, 0) ?:
                bch2_trans_commit(trans, NULL, NULL,
                                  BCH_WATERMARK_btree|