Skip to content

Commit f648b6c

Browse files
author
Kent Overstreet
committed
bcachefs: Fix missing alloc_data_type_set()
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>
1 parent 339b84a commit f648b6c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

fs/bcachefs/alloc_background.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -776,6 +776,7 @@ int bch2_trigger_alloc(struct btree_trans *trans,
776776
!bch2_bucket_is_open_safe(c, new.k->p.inode, new.k->p.offset)) {
777777
new_a->gen++;
778778
SET_BCH_ALLOC_V4_NEED_INC_GEN(new_a, false);
779+
alloc_data_type_set(new_a, new_a->data_type);
779780
}
780781

781782
if (old_a->data_type != new_a->data_type ||
@@ -1796,8 +1797,9 @@ static int bch2_discard_one_bucket(struct btree_trans *trans,
17961797
}
17971798

17981799
SET_BCH_ALLOC_V4_NEED_DISCARD(&a->v, false);
1799-
alloc_data_type_set(&a->v, a->v.data_type);
18001800
write:
1801+
alloc_data_type_set(&a->v, a->v.data_type);
1802+
18011803
ret = bch2_trans_update(trans, &iter, &a->k_i, 0) ?:
18021804
bch2_trans_commit(trans, NULL, NULL,
18031805
BCH_WATERMARK_btree|

0 commit comments

Comments
 (0)