]> www.infradead.org Git - users/hch/configfs.git/commitdiff
bcachefs: Fix bch2_bucket_gens_init()
authorKent Overstreet <kent.overstreet@linux.dev>
Mon, 19 Aug 2024 00:38:49 +0000 (20:38 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Thu, 22 Aug 2024 06:07:22 +0000 (02:07 -0400)
Comparing the wrong bpos - this was missed because normally
bucket_gens_init() runs on brand new filesystems, but this bug caused it
to overwrite bucket_gens keys with 0s when upgrading ancient
filesystems.

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

index 488d0710f7b997ee2f9315ecba49e1f10d2ba1e4..ac933142aedab9a239a933189bfb7878d683201d 100644 (file)
@@ -556,7 +556,7 @@ int bch2_bucket_gens_init(struct bch_fs *c)
                struct bpos pos = alloc_gens_pos(iter.pos, &offset);
                int ret2 = 0;
 
-               if (have_bucket_gens_key && bkey_cmp(iter.pos, pos)) {
+               if (have_bucket_gens_key && !bkey_eq(g.k.p, pos)) {
                        ret2 =  bch2_btree_insert_trans(trans, BTREE_ID_bucket_gens, &g.k_i, 0) ?:
                                bch2_trans_commit(trans, NULL, NULL, BCH_TRANS_COMMIT_no_enospc);
                        if (ret2)