Skip to content

Commit 8080ff5

Browse files
committed
Merge tag 'bcachefs-2025-01-29' of git://evilpiepirate.org/bcachefs
Pull bcachefs fixes from Kent Overstreet: - second half of a fix for a bug that'd been causing oopses on filesystems using snapshots with memory pressure (key cache fills for snaphots btrees are tricky) - build fix for strange compiler configurations that double stack frame size - "journal stuck timeout" now takes into account device latency: this fixes some spurious warnings, and the main remaining source of SRCU lock hold time warnings (I'm no longer seeing this in my CI, so any users still seeing this should definitely ping me) - fix for slow/hanging unmounts (" Improve journal pin flushing") - some more tracepoint fixes/improvements, to chase down the "rebalance isn't making progress" issues * tag 'bcachefs-2025-01-29' of git://evilpiepirate.org/bcachefs: bcachefs: Improve trace_move_extent_finish bcachefs: Fix trace_copygc bcachefs: Journal writes are now IOPRIO_CLASS_RT bcachefs: Improve journal pin flushing bcachefs: fix bch2_btree_node_flags bcachefs: rebalance, copygc enabled are runtime opts bcachefs: Improve decompression error messages bcachefs: bset_blacklisted_journal_seq is now AUTOFIX bcachefs: "Journal stuck" timeout now takes into account device latency bcachefs: Reduce stack frame size of __bch2_str_hash_check_key() bcachefs: Fix btree_trans_peek_key_cache()
2 parents 72deda0 + 5d9ccda commit 8080ff5

21 files changed

+275
-159
lines changed

fs/bcachefs/btree_cache.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ do { \
2424
} while (0)
2525

2626
const char * const bch2_btree_node_flags[] = {
27-
#define x(f) #f,
27+
"typebit",
28+
"typebit",
29+
"typebit",
30+
#define x(f) [BTREE_NODE_##f] = #f,
2831
BTREE_FLAGS()
2932
#undef x
3033
NULL

fs/bcachefs/btree_iter.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2239,8 +2239,6 @@ struct bkey_s_c btree_trans_peek_key_cache(struct btree_iter *iter, struct bpos
22392239
if (unlikely(ret))
22402240
return bkey_s_c_err(ret);
22412241

2242-
btree_path_set_should_be_locked(trans, trans->paths + iter->key_cache_path);
2243-
22442242
k = bch2_btree_path_peek_slot(trans->paths + iter->key_cache_path, &u);
22452243
if (!k.k)
22462244
return k;
@@ -2251,6 +2249,7 @@ struct bkey_s_c btree_trans_peek_key_cache(struct btree_iter *iter, struct bpos
22512249

22522250
iter->k = u;
22532251
k.k = &iter->k;
2252+
btree_path_set_should_be_locked(trans, trans->paths + iter->key_cache_path);
22542253
return k;
22552254
}
22562255

fs/bcachefs/btree_key_cache.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,10 @@ static noinline int btree_key_cache_fill(struct btree_trans *trans,
291291
struct btree_path *ck_path,
292292
unsigned flags)
293293
{
294-
if (flags & BTREE_ITER_cached_nofill)
294+
if (flags & BTREE_ITER_cached_nofill) {
295+
ck_path->l[0].b = NULL;
295296
return 0;
297+
}
296298

297299
struct bch_fs *c = trans->c;
298300
struct btree_iter iter;

fs/bcachefs/btree_trans_commit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ static __always_inline int bch2_trans_journal_res_get(struct btree_trans *trans,
348348
unsigned flags)
349349
{
350350
return bch2_journal_res_get(&trans->c->journal, &trans->journal_res,
351-
trans->journal_u64s, flags);
351+
trans->journal_u64s, flags, trans);
352352
}
353353

354354
#define JSET_ENTRY_LOG_U64s 4

fs/bcachefs/compress.c

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "compress.h"
55
#include "error.h"
66
#include "extents.h"
7+
#include "io_write.h"
78
#include "opts.h"
89
#include "super-io.h"
910

@@ -254,29 +255,41 @@ static int __bio_uncompress(struct bch_fs *c, struct bio *src,
254255
goto out;
255256
}
256257

257-
int bch2_bio_uncompress_inplace(struct bch_fs *c, struct bio *bio,
258-
struct bch_extent_crc_unpacked *crc)
258+
int bch2_bio_uncompress_inplace(struct bch_write_op *op,
259+
struct bio *bio)
259260
{
261+
struct bch_fs *c = op->c;
262+
struct bch_extent_crc_unpacked *crc = &op->crc;
260263
struct bbuf data = { NULL };
261264
size_t dst_len = crc->uncompressed_size << 9;
265+
int ret = 0;
262266

263267
/* bio must own its pages: */
264268
BUG_ON(!bio->bi_vcnt);
265269
BUG_ON(DIV_ROUND_UP(crc->live_size, PAGE_SECTORS) > bio->bi_max_vecs);
266270

267271
if (crc->uncompressed_size << 9 > c->opts.encoded_extent_max ||
268272
crc->compressed_size << 9 > c->opts.encoded_extent_max) {
269-
bch_err(c, "error rewriting existing data: extent too big");
273+
struct printbuf buf = PRINTBUF;
274+
bch2_write_op_error(&buf, op);
275+
prt_printf(&buf, "error rewriting existing data: extent too big");
276+
bch_err_ratelimited(c, "%s", buf.buf);
277+
printbuf_exit(&buf);
270278
return -EIO;
271279
}
272280

273281
data = __bounce_alloc(c, dst_len, WRITE);
274282

275283
if (__bio_uncompress(c, bio, data.b, *crc)) {
276-
if (!c->opts.no_data_io)
277-
bch_err(c, "error rewriting existing data: decompression error");
278-
bio_unmap_or_unbounce(c, data);
279-
return -EIO;
284+
if (!c->opts.no_data_io) {
285+
struct printbuf buf = PRINTBUF;
286+
bch2_write_op_error(&buf, op);
287+
prt_printf(&buf, "error rewriting existing data: decompression error");
288+
bch_err_ratelimited(c, "%s", buf.buf);
289+
printbuf_exit(&buf);
290+
}
291+
ret = -EIO;
292+
goto err;
280293
}
281294

282295
/*
@@ -293,9 +306,9 @@ int bch2_bio_uncompress_inplace(struct bch_fs *c, struct bio *bio,
293306
crc->uncompressed_size = crc->live_size;
294307
crc->offset = 0;
295308
crc->csum = (struct bch_csum) { 0, 0 };
296-
309+
err:
297310
bio_unmap_or_unbounce(c, data);
298-
return 0;
311+
return ret;
299312
}
300313

301314
int bch2_bio_uncompress(struct bch_fs *c, struct bio *src,

fs/bcachefs/compress.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ static inline enum bch_compression_type bch2_compression_opt_to_type(unsigned v)
4747
return __bch2_compression_opt_to_type[bch2_compression_decode(v).type];
4848
}
4949

50-
int bch2_bio_uncompress_inplace(struct bch_fs *, struct bio *,
51-
struct bch_extent_crc_unpacked *);
50+
struct bch_write_op;
51+
int bch2_bio_uncompress_inplace(struct bch_write_op *, struct bio *);
5252
int bch2_bio_uncompress(struct bch_fs *, struct bio *, struct bio *,
5353
struct bvec_iter, struct bch_extent_crc_unpacked);
5454
unsigned bch2_bio_compress(struct bch_fs *, struct bio *, size_t *,

fs/bcachefs/data_update.c

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,28 @@ static bool bkey_nocow_lock(struct bch_fs *c, struct moving_context *ctxt, struc
9191
return true;
9292
}
9393

94-
static void trace_move_extent_finish2(struct bch_fs *c, struct bkey_s_c k)
94+
static noinline void trace_move_extent_finish2(struct data_update *u,
95+
struct bkey_i *new,
96+
struct bkey_i *insert)
9597
{
96-
if (trace_move_extent_finish_enabled()) {
97-
struct printbuf buf = PRINTBUF;
98+
struct bch_fs *c = u->op.c;
99+
struct printbuf buf = PRINTBUF;
98100

99-
bch2_bkey_val_to_text(&buf, c, k);
100-
trace_move_extent_finish(c, buf.buf);
101-
printbuf_exit(&buf);
102-
}
101+
prt_newline(&buf);
102+
103+
bch2_data_update_to_text(&buf, u);
104+
prt_newline(&buf);
105+
106+
prt_str_indented(&buf, "new replicas:\t");
107+
bch2_bkey_val_to_text(&buf, c, bkey_i_to_s_c(new));
108+
prt_newline(&buf);
109+
110+
prt_str_indented(&buf, "insert:\t");
111+
bch2_bkey_val_to_text(&buf, c, bkey_i_to_s_c(insert));
112+
prt_newline(&buf);
113+
114+
trace_move_extent_finish(c, buf.buf);
115+
printbuf_exit(&buf);
103116
}
104117

105118
static void trace_move_extent_fail2(struct data_update *m,
@@ -372,7 +385,8 @@ static int __bch2_data_update_index_update(struct btree_trans *trans,
372385
bch2_btree_iter_set_pos(&iter, next_pos);
373386

374387
this_cpu_add(c->counters[BCH_COUNTER_move_extent_finish], new->k.size);
375-
trace_move_extent_finish2(c, bkey_i_to_s_c(&new->k_i));
388+
if (trace_move_extent_finish_enabled())
389+
trace_move_extent_finish2(m, &new->k_i, insert);
376390
}
377391
err:
378392
if (bch2_err_matches(ret, BCH_ERR_transaction_restart))
@@ -525,34 +539,38 @@ void bch2_data_update_opts_to_text(struct printbuf *out, struct bch_fs *c,
525539
struct data_update_opts *data_opts)
526540
{
527541
printbuf_tabstop_push(out, 20);
528-
prt_str(out, "rewrite ptrs:\t");
542+
543+
prt_str_indented(out, "rewrite ptrs:\t");
529544
bch2_prt_u64_base2(out, data_opts->rewrite_ptrs);
530545
prt_newline(out);
531546

532-
prt_str(out, "kill ptrs:\t");
547+
prt_str_indented(out, "kill ptrs:\t");
533548
bch2_prt_u64_base2(out, data_opts->kill_ptrs);
534549
prt_newline(out);
535550

536-
prt_str(out, "target:\t");
551+
prt_str_indented(out, "target:\t");
537552
bch2_target_to_text(out, c, data_opts->target);
538553
prt_newline(out);
539554

540-
prt_str(out, "compression:\t");
555+
prt_str_indented(out, "compression:\t");
541556
bch2_compression_opt_to_text(out, io_opts->background_compression);
542557
prt_newline(out);
543558

544-
prt_str(out, "opts.replicas:\t");
559+
prt_str_indented(out, "opts.replicas:\t");
545560
prt_u64(out, io_opts->data_replicas);
561+
prt_newline(out);
546562

547-
prt_str(out, "extra replicas:\t");
563+
prt_str_indented(out, "extra replicas:\t");
548564
prt_u64(out, data_opts->extra_replicas);
549565
}
550566

551567
void bch2_data_update_to_text(struct printbuf *out, struct data_update *m)
552568
{
553-
bch2_bkey_val_to_text(out, m->op.c, bkey_i_to_s_c(m->k.k));
554-
prt_newline(out);
555569
bch2_data_update_opts_to_text(out, m->op.c, &m->op.opts, &m->data_opts);
570+
prt_newline(out);
571+
572+
prt_str_indented(out, "old key:\t");
573+
bch2_bkey_val_to_text(out, m->op.c, bkey_i_to_s_c(m->k.k));
556574
}
557575

558576
int bch2_extent_drop_ptrs(struct btree_trans *trans,

fs/bcachefs/debug.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "extents.h"
2121
#include "fsck.h"
2222
#include "inode.h"
23+
#include "journal_reclaim.h"
2324
#include "super.h"
2425

2526
#include <linux/console.h>

fs/bcachefs/io_write.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ static void __bch2_write_op_error(struct printbuf *out, struct bch_write_op *op,
406406
op->flags & BCH_WRITE_MOVE ? "(internal move)" : "");
407407
}
408408

409-
static void bch2_write_op_error(struct printbuf *out, struct bch_write_op *op)
409+
void bch2_write_op_error(struct printbuf *out, struct bch_write_op *op)
410410
{
411411
__bch2_write_op_error(out, op, op->pos.offset);
412412
}
@@ -873,7 +873,7 @@ static enum prep_encoded_ret {
873873
if (bch2_crc_cmp(op->crc.csum, csum) && !c->opts.no_data_io)
874874
return PREP_ENCODED_CHECKSUM_ERR;
875875

876-
if (bch2_bio_uncompress_inplace(c, bio, &op->crc))
876+
if (bch2_bio_uncompress_inplace(op, bio))
877877
return PREP_ENCODED_ERR;
878878
}
879879

fs/bcachefs/io_write.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ static inline void bch2_latency_acct(struct bch_dev *ca, u64 submit_time, int rw
2020
void bch2_submit_wbio_replicas(struct bch_write_bio *, struct bch_fs *,
2121
enum bch_data_type, const struct bkey_i *, bool);
2222

23+
void bch2_write_op_error(struct printbuf *out, struct bch_write_op *op);
24+
2325
#define BCH_WRITE_FLAGS() \
2426
x(ALLOC_NOWAIT) \
2527
x(CACHED) \

0 commit comments

Comments
 (0)