Skip to content

Commit 9b133c0

Browse files
author
Kent Overstreet
committed
bcachefs: Small check_fix_ptr fixes
We don't want to change the bucket gen, on gen mismatch: it's possible to have multiple btree nodes with different gens in the same bucket that we want to keep, if we have to recover from btree node scan. It's also not necessary to set g->gen_valid; add a comment to that effect. Signed-off-by: Kent Overstreet <[email protected]>
1 parent cade003 commit 9b133c0

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

fs/bcachefs/buckets.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,14 @@ static int bch2_check_fix_ptr(struct btree_trans *trans,
156156
g->gen_valid = true;
157157
g->gen = p.ptr.gen;
158158
} else {
159+
/* this pointer will be dropped */
159160
*do_update = true;
161+
goto out;
160162
}
161163
}
162164

165+
/* g->gen_valid == true */
166+
163167
if (fsck_err_on(gen_cmp(p.ptr.gen, g->gen) > 0,
164168
trans, ptr_gen_newer_than_bucket_gen,
165169
"bucket %u:%zu data type %s ptr gen in the future: %u > %u\n"
@@ -172,15 +176,13 @@ static int bch2_check_fix_ptr(struct btree_trans *trans,
172176
if (!p.ptr.cached &&
173177
(g->data_type != BCH_DATA_btree ||
174178
data_type == BCH_DATA_btree)) {
175-
g->gen_valid = true;
176-
g->gen = p.ptr.gen;
177-
g->data_type = 0;
179+
g->data_type = data_type;
178180
g->stripe_sectors = 0;
179181
g->dirty_sectors = 0;
180182
g->cached_sectors = 0;
181-
} else {
182-
*do_update = true;
183183
}
184+
185+
*do_update = true;
184186
}
185187

186188
if (fsck_err_on(gen_cmp(g->gen, p.ptr.gen) > BUCKET_GC_GEN_MAX,
@@ -217,9 +219,8 @@ static int bch2_check_fix_ptr(struct btree_trans *trans,
217219
bch2_data_type_str(data_type),
218220
(printbuf_reset(&buf),
219221
bch2_bkey_val_to_text(&buf, c, k), buf.buf))) {
220-
if (data_type == BCH_DATA_btree) {
221-
g->gen_valid = true;
222-
g->gen = p.ptr.gen;
222+
if (!p.ptr.cached &&
223+
data_type == BCH_DATA_btree) {
223224
g->data_type = data_type;
224225
g->stripe_sectors = 0;
225226
g->dirty_sectors = 0;

0 commit comments

Comments
 (0)