Skip to content

Commit 98fb679

Browse files
committed
Merge tag 'bcachefs-2025-03-31' of git://evilpiepirate.org/bcachefs
Pull more bcachefs updates from Kent Overstreet: "All bugfixes and logging improvements" * tag 'bcachefs-2025-03-31' of git://evilpiepirate.org/bcachefs: (35 commits) bcachefs: fix bch2_write_point_to_text() units bcachefs: Log original key being moved in data updates bcachefs: BCH_JSET_ENTRY_log_bkey bcachefs: Reorder error messages that include journal debug bcachefs: Don't use designated initializers for disk_accounting_pos bcachefs: Silence errors after emergency shutdown bcachefs: fix units in rebalance_status bcachefs: bch2_ioctl_subvolume_destroy() fixes bcachefs: Clear fs_path_parent on subvolume unlink bcachefs: Change btree_insert_node() assertion to error bcachefs: Better printing of inconsistency errors bcachefs: bch2_count_fsck_err() bcachefs: Better helpers for inconsistency errors bcachefs: Consistent indentation of multiline fsck errors bcachefs: Add an "ignore unknown" option to bch2_parse_mount_opts() bcachefs: bch2_time_stats_init_no_pcpu() bcachefs: Fix bch2_fs_get_tree() error path bcachefs: fix logging in journal_entry_err_msg() bcachefs: add missing newline in bch2_trans_updates_to_text() bcachefs: print_string_as_lines: fix extra newline ...
2 parents 4080cf0 + 650f535 commit 98fb679

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+856
-506
lines changed

fs/bcachefs/alloc_background.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,8 @@ int bch2_bucket_gens_init(struct bch_fs *c)
589589

590590
int bch2_alloc_read(struct bch_fs *c)
591591
{
592+
down_read(&c->state_lock);
593+
592594
struct btree_trans *trans = bch2_trans_get(c);
593595
struct bch_dev *ca = NULL;
594596
int ret;
@@ -652,6 +654,7 @@ int bch2_alloc_read(struct bch_fs *c)
652654
bch2_dev_put(ca);
653655
bch2_trans_put(trans);
654656

657+
up_read(&c->state_lock);
655658
bch_err_fn(c, ret);
656659
return ret;
657660
}
@@ -673,8 +676,7 @@ static int __need_discard_or_freespace_err(struct btree_trans *trans,
673676
bch2_bkey_val_to_text(&buf, c, alloc_k);
674677

675678
int ret = __bch2_fsck_err(NULL, trans, flags, err_id,
676-
"bucket incorrectly %sset in %s btree\n"
677-
" %s",
679+
"bucket incorrectly %sset in %s btree\n%s",
678680
set ? "" : "un",
679681
bch2_btree_id_str(btree),
680682
buf.buf);
@@ -1027,7 +1029,7 @@ int bch2_trigger_alloc(struct btree_trans *trans,
10271029
bch2_dev_put(ca);
10281030
return ret;
10291031
invalid_bucket:
1030-
bch2_fs_inconsistent(c, "reference to invalid bucket\n %s",
1032+
bch2_fs_inconsistent(c, "reference to invalid bucket\n%s",
10311033
(bch2_bkey_val_to_text(&buf, c, new.s_c), buf.buf));
10321034
ret = -BCH_ERR_trigger_alloc;
10331035
goto err;
@@ -1201,8 +1203,7 @@ int bch2_check_alloc_key(struct btree_trans *trans,
12011203

12021204
if (fsck_err_on(a->gen != alloc_gen(k, gens_offset),
12031205
trans, bucket_gens_key_wrong,
1204-
"incorrect gen in bucket_gens btree (got %u should be %u)\n"
1205-
" %s",
1206+
"incorrect gen in bucket_gens btree (got %u should be %u)\n%s",
12061207
alloc_gen(k, gens_offset), a->gen,
12071208
(printbuf_reset(&buf),
12081209
bch2_bkey_val_to_text(&buf, c, alloc_k), buf.buf))) {
@@ -1260,7 +1261,7 @@ int bch2_check_alloc_hole_freespace(struct btree_trans *trans,
12601261
if (fsck_err_on(k.k->type != KEY_TYPE_set,
12611262
trans, freespace_hole_missing,
12621263
"hole in alloc btree missing in freespace btree\n"
1263-
" device %llu buckets %llu-%llu",
1264+
"device %llu buckets %llu-%llu",
12641265
freespace_iter->pos.inode,
12651266
freespace_iter->pos.offset,
12661267
end->offset)) {
@@ -1419,7 +1420,7 @@ int bch2_check_discard_freespace_key(struct btree_trans *trans, struct btree_ite
14191420
(state == BCH_DATA_free &&
14201421
genbits != alloc_freespace_genbits(*a))) {
14211422
if (fsck_err(trans, need_discard_freespace_key_bad,
1422-
"%s\n incorrectly set at %s:%llu:%llu:0 (free %u, genbits %llu should be %llu)",
1423+
"%s\nincorrectly set at %s:%llu:%llu:0 (free %u, genbits %llu should be %llu)",
14231424
(bch2_bkey_val_to_text(&buf, c, alloc_k), buf.buf),
14241425
bch2_btree_id_str(iter->btree_id),
14251426
iter->pos.inode,
@@ -1500,7 +1501,7 @@ int bch2_check_bucket_gens_key(struct btree_trans *trans,
15001501
struct bch_dev *ca = bch2_dev_tryget_noerror(c, k.k->p.inode);
15011502
if (!ca) {
15021503
if (fsck_err(trans, bucket_gens_to_invalid_dev,
1503-
"bucket_gens key for invalid device:\n %s",
1504+
"bucket_gens key for invalid device:\n%s",
15041505
(bch2_bkey_val_to_text(&buf, c, k), buf.buf)))
15051506
ret = bch2_btree_delete_at(trans, iter, 0);
15061507
goto out;
@@ -1509,7 +1510,7 @@ int bch2_check_bucket_gens_key(struct btree_trans *trans,
15091510
if (fsck_err_on(end <= ca->mi.first_bucket ||
15101511
start >= ca->mi.nbuckets,
15111512
trans, bucket_gens_to_invalid_buckets,
1512-
"bucket_gens key for invalid buckets:\n %s",
1513+
"bucket_gens key for invalid buckets:\n%s",
15131514
(bch2_bkey_val_to_text(&buf, c, k), buf.buf))) {
15141515
ret = bch2_btree_delete_at(trans, iter, 0);
15151516
goto out;
@@ -1712,8 +1713,7 @@ static int bch2_check_alloc_to_lru_ref(struct btree_trans *trans,
17121713

17131714
if (fsck_err_on(!a->io_time[READ],
17141715
trans, alloc_key_cached_but_read_time_zero,
1715-
"cached bucket with read_time 0\n"
1716-
" %s",
1716+
"cached bucket with read_time 0\n%s",
17171717
(printbuf_reset(&buf),
17181718
bch2_bkey_val_to_text(&buf, c, alloc_k), buf.buf))) {
17191719
struct bkey_i_alloc_v4 *a_mut =

fs/bcachefs/alloc_foreground.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1560,7 +1560,7 @@ static void bch2_write_point_to_text(struct printbuf *out, struct bch_fs *c,
15601560
unsigned i;
15611561

15621562
prt_printf(out, "%lu: ", wp->write_point);
1563-
prt_human_readable_u64(out, wp->sectors_allocated);
1563+
prt_human_readable_u64(out, wp->sectors_allocated << 9);
15641564

15651565
prt_printf(out, " last wrote: ");
15661566
bch2_pr_time_units(out, sched_clock() - wp->last_used);

fs/bcachefs/backpointers.c

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ static noinline int backpointer_mod_err(struct btree_trans *trans,
9696
{
9797
struct bch_fs *c = trans->c;
9898
struct printbuf buf = PRINTBUF;
99+
int ret = 0;
99100

100101
if (insert) {
101102
prt_printf(&buf, "existing backpointer found when inserting ");
@@ -125,17 +126,15 @@ static noinline int backpointer_mod_err(struct btree_trans *trans,
125126

126127
prt_printf(&buf, "for ");
127128
bch2_bkey_val_to_text(&buf, c, orig_k);
128-
129-
bch_err(c, "%s", buf.buf);
130129
}
131130

132-
printbuf_exit(&buf);
131+
if (c->curr_recovery_pass > BCH_RECOVERY_PASS_check_extents_to_backpointers &&
132+
__bch2_inconsistent_error(c, &buf))
133+
ret = -BCH_ERR_erofs_unfixed_errors;
133134

134-
if (c->curr_recovery_pass > BCH_RECOVERY_PASS_check_extents_to_backpointers) {
135-
return bch2_inconsistent_error(c) ? BCH_ERR_erofs_unfixed_errors : 0;
136-
} else {
137-
return 0;
138-
}
135+
bch_err(c, "%s", buf.buf);
136+
printbuf_exit(&buf);
137+
return ret;
139138
}
140139

141140
int bch2_bucket_backpointer_mod_nowritebuffer(struct btree_trans *trans,
@@ -210,19 +209,19 @@ static int backpointer_target_not_found(struct btree_trans *trans,
210209
if (ret)
211210
return ret;
212211

213-
prt_printf(&buf, "backpointer doesn't match %s it points to:\n ",
212+
prt_printf(&buf, "backpointer doesn't match %s it points to:\n",
214213
bp.v->level ? "btree node" : "extent");
215214
bch2_bkey_val_to_text(&buf, c, bp.s_c);
216215

217-
prt_printf(&buf, "\n ");
216+
prt_newline(&buf);
218217
bch2_bkey_val_to_text(&buf, c, target_k);
219218

220219
struct bkey_ptrs_c ptrs = bch2_bkey_ptrs_c(target_k);
221220
const union bch_extent_entry *entry;
222221
struct extent_ptr_decoded p;
223222
bkey_for_each_ptr_decode(target_k.k, ptrs, p, entry)
224223
if (p.ptr.dev == bp.k->p.inode) {
225-
prt_printf(&buf, "\n ");
224+
prt_newline(&buf);
226225
struct bkey_i_backpointer bp2;
227226
bch2_extent_ptr_to_bp(c, bp.v->btree_id, bp.v->level, target_k, p, entry, &bp2);
228227
bch2_bkey_val_to_text(&buf, c, bkey_i_to_s_c(&bp2.k_i));
@@ -443,12 +442,11 @@ static int check_extent_checksum(struct btree_trans *trans,
443442
if (ret)
444443
goto err;
445444

446-
prt_str(&buf, "extents pointing to same space, but first extent checksum bad:");
447-
prt_printf(&buf, "\n ");
445+
prt_printf(&buf, "extents pointing to same space, but first extent checksum bad:\n");
448446
bch2_btree_id_to_text(&buf, btree);
449447
prt_str(&buf, " ");
450448
bch2_bkey_val_to_text(&buf, c, extent);
451-
prt_printf(&buf, "\n ");
449+
prt_newline(&buf);
452450
bch2_btree_id_to_text(&buf, o_btree);
453451
prt_str(&buf, " ");
454452
bch2_bkey_val_to_text(&buf, c, extent2);
@@ -539,9 +537,9 @@ static int check_bp_exists(struct btree_trans *trans,
539537

540538
if (bch2_extents_match(orig_k, other_extent)) {
541539
printbuf_reset(&buf);
542-
prt_printf(&buf, "duplicate versions of same extent, deleting smaller\n ");
540+
prt_printf(&buf, "duplicate versions of same extent, deleting smaller\n");
543541
bch2_bkey_val_to_text(&buf, c, orig_k);
544-
prt_str(&buf, "\n ");
542+
prt_newline(&buf);
545543
bch2_bkey_val_to_text(&buf, c, other_extent);
546544
bch_err(c, "%s", buf.buf);
547545

@@ -580,20 +578,20 @@ static int check_bp_exists(struct btree_trans *trans,
580578
}
581579

582580
printbuf_reset(&buf);
583-
prt_printf(&buf, "duplicate extents pointing to same space on dev %llu\n ", bp->k.p.inode);
581+
prt_printf(&buf, "duplicate extents pointing to same space on dev %llu\n", bp->k.p.inode);
584582
bch2_bkey_val_to_text(&buf, c, orig_k);
585-
prt_str(&buf, "\n ");
583+
prt_newline(&buf);
586584
bch2_bkey_val_to_text(&buf, c, other_extent);
587585
bch_err(c, "%s", buf.buf);
588586
ret = -BCH_ERR_fsck_repair_unimplemented;
589587
goto err;
590588
missing:
591589
printbuf_reset(&buf);
592-
prt_str(&buf, "missing backpointer\n for: ");
590+
prt_str(&buf, "missing backpointer\nfor: ");
593591
bch2_bkey_val_to_text(&buf, c, orig_k);
594-
prt_printf(&buf, "\n want: ");
592+
prt_printf(&buf, "\nwant: ");
595593
bch2_bkey_val_to_text(&buf, c, bkey_i_to_s_c(&bp->k_i));
596-
prt_printf(&buf, "\n got: ");
594+
prt_printf(&buf, "\ngot: ");
597595
bch2_bkey_val_to_text(&buf, c, bp_k);
598596

599597
if (fsck_err(trans, ptr_to_missing_backpointer, "%s", buf.buf))
@@ -1023,7 +1021,7 @@ int bch2_check_extents_to_backpointers(struct bch_fs *c)
10231021
* Can't allow devices to come/go/resize while we have bucket bitmaps
10241022
* allocated
10251023
*/
1026-
lockdep_assert_held(&c->state_lock);
1024+
down_read(&c->state_lock);
10271025

10281026
for_each_member_device(c, ca) {
10291027
BUG_ON(ca->bucket_backpointer_mismatches);
@@ -1108,6 +1106,7 @@ int bch2_check_extents_to_backpointers(struct bch_fs *c)
11081106
ca->bucket_backpointer_mismatches = NULL;
11091107
}
11101108

1109+
up_read(&c->state_lock);
11111110
bch_err_fn(c, ret);
11121111
return ret;
11131112
}

fs/bcachefs/bcachefs_format.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1143,7 +1143,8 @@ static inline __u64 __bset_magic(struct bch_sb *sb)
11431143
x(log, 9) \
11441144
x(overwrite, 10) \
11451145
x(write_buffer_keys, 11) \
1146-
x(datetime, 12)
1146+
x(datetime, 12) \
1147+
x(log_bkey, 13)
11471148

11481149
enum bch_jset_entry_type {
11491150
#define x(f, nr) BCH_JSET_ENTRY_##f = nr,

fs/bcachefs/btree_cache.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1417,7 +1417,7 @@ void __bch2_btree_pos_to_text(struct printbuf *out, struct bch_fs *c,
14171417
prt_printf(out, "%u", r->level);
14181418
else
14191419
prt_printf(out, "(unknown)");
1420-
prt_printf(out, "\n ");
1420+
prt_newline(out);
14211421

14221422
bch2_bkey_val_to_text(out, c, k);
14231423
}

fs/bcachefs/btree_gc.c

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -213,15 +213,15 @@ static int btree_check_node_boundaries(struct btree_trans *trans, struct btree *
213213

214214
prt_printf(&buf, " at ");
215215
bch2_btree_id_level_to_text(&buf, b->c.btree_id, b->c.level);
216-
prt_printf(&buf, ":\n parent: ");
216+
prt_printf(&buf, ":\nparent: ");
217217
bch2_bkey_val_to_text(&buf, c, bkey_i_to_s_c(&b->key));
218218

219219
if (prev) {
220-
prt_printf(&buf, "\n prev: ");
220+
prt_printf(&buf, "\nprev: ");
221221
bch2_bkey_val_to_text(&buf, c, bkey_i_to_s_c(&prev->key));
222222
}
223223

224-
prt_str(&buf, "\n next: ");
224+
prt_str(&buf, "\nnext: ");
225225
bch2_bkey_val_to_text(&buf, c, bkey_i_to_s_c(&cur->key));
226226

227227
if (bpos_lt(expected_start, cur->data->min_key)) { /* gap */
@@ -280,12 +280,12 @@ static int btree_repair_node_end(struct btree_trans *trans, struct btree *b,
280280
if (bpos_eq(child->key.k.p, b->key.k.p))
281281
return 0;
282282

283-
prt_printf(&buf, " at ");
283+
prt_printf(&buf, "\nat: ");
284284
bch2_btree_id_level_to_text(&buf, b->c.btree_id, b->c.level);
285-
prt_printf(&buf, ":\n parent: ");
285+
prt_printf(&buf, "\nparent: ");
286286
bch2_bkey_val_to_text(&buf, c, bkey_i_to_s_c(&b->key));
287287

288-
prt_str(&buf, "\n child: ");
288+
prt_str(&buf, "\nchild: ");
289289
bch2_bkey_val_to_text(&buf, c, bkey_i_to_s_c(&child->key));
290290

291291
if (mustfix_fsck_err(trans, btree_node_topology_bad_max_key,
@@ -351,8 +351,7 @@ static int bch2_btree_repair_topology_recurse(struct btree_trans *trans, struct
351351

352352
if (mustfix_fsck_err_on(bch2_err_matches(ret, EIO),
353353
trans, btree_node_read_error,
354-
"Topology repair: unreadable btree node at\n"
355-
" %s",
354+
"Topology repair: unreadable btree node at\n%s",
356355
buf.buf)) {
357356
bch2_btree_node_evict(trans, cur_k.k);
358357
cur = NULL;
@@ -612,15 +611,15 @@ static int bch2_gc_mark_key(struct btree_trans *trans, enum btree_id btree_id,
612611
if (fsck_err_on(btree_id != BTREE_ID_accounting &&
613612
k.k->bversion.lo > atomic64_read(&c->key_version),
614613
trans, bkey_version_in_future,
615-
"key version number higher than recorded %llu\n %s",
614+
"key version number higher than recorded %llu\n%s",
616615
atomic64_read(&c->key_version),
617616
(bch2_bkey_val_to_text(&buf, c, k), buf.buf)))
618617
atomic64_set(&c->key_version, k.k->bversion.lo);
619618
}
620619

621620
if (mustfix_fsck_err_on(level && !bch2_dev_btree_bitmap_marked(c, k),
622621
trans, btree_bitmap_not_marked,
623-
"btree ptr not marked in member info btree allocated bitmap\n %s",
622+
"btree ptr not marked in member info btree allocated bitmap\n%s",
624623
(printbuf_reset(&buf),
625624
bch2_bkey_val_to_text(&buf, c, k),
626625
buf.buf))) {
@@ -1021,8 +1020,7 @@ int bch2_check_allocations(struct bch_fs *c)
10211020
{
10221021
int ret;
10231022

1024-
lockdep_assert_held(&c->state_lock);
1025-
1023+
down_read(&c->state_lock);
10261024
down_write(&c->gc_lock);
10271025

10281026
bch2_btree_interior_updates_flush(c);
@@ -1060,6 +1058,7 @@ int bch2_check_allocations(struct bch_fs *c)
10601058
percpu_up_write(&c->mark_lock);
10611059

10621060
up_write(&c->gc_lock);
1061+
up_read(&c->state_lock);
10631062

10641063
/*
10651064
* At startup, allocations can happen directly instead of via the

0 commit comments

Comments
 (0)