From: kernel test robot <lkp@intel.com>
To: oe-kbuild@lists.linux.dev
Cc: lkp@intel.com, Dan Carpenter <error27@gmail.com>
Subject: [koverstreet-bcachefs:trace_sched_wakeup_backtrace 216/332] fs/bcachefs/data/ec/trigger.c:378 bch2_trigger_stripe() error: we previously assumed 'new_s' could be null (see line 356)
Date: Fri, 15 May 2026 03:26:50 +0800 [thread overview]
Message-ID: <202605150347.BGMlkbv9-lkp@intel.com> (raw)
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
TO: Kent Overstreet <kent.overstreet@linux.dev>
tree: https://github.com/koverstreet/bcachefs trace_sched_wakeup_backtrace
head: 9e7cbd4ad9c7a7ba461dbba9185628c006e200cd
commit: bde39b90107558a6e5c84934716bf171ced1cef5 [216/332] bcachefs: Split up data/ec.c
:::::: branch date: 3 months ago
:::::: commit date: 4 months ago
config: i386-randconfig-141-20260514 (https://download.01.org/0day-ci/archive/20260515/202605150347.BGMlkbv9-lkp@intel.com/config)
compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
smatch: v0.5.0-9185-gbcc58b9c
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202605150347.BGMlkbv9-lkp@intel.com/
smatch warnings:
fs/bcachefs/data/ec/trigger.c:378 bch2_trigger_stripe() error: we previously assumed 'new_s' could be null (see line 356)
vim +/new_s +378 fs/bcachefs/data/ec/trigger.c
bde39b90107558a Kent Overstreet 2026-01-17 314
bde39b90107558a Kent Overstreet 2026-01-17 315 int bch2_trigger_stripe(struct btree_trans *trans,
bde39b90107558a Kent Overstreet 2026-01-17 316 enum btree_id btree, unsigned level,
bde39b90107558a Kent Overstreet 2026-01-17 317 struct bkey_s_c old, struct bkey_s _new,
bde39b90107558a Kent Overstreet 2026-01-17 318 enum btree_iter_update_trigger_flags flags)
bde39b90107558a Kent Overstreet 2026-01-17 319 {
bde39b90107558a Kent Overstreet 2026-01-17 320 struct bkey_s_c new = _new.s_c;
bde39b90107558a Kent Overstreet 2026-01-17 321 struct bch_fs *c = trans->c;
bde39b90107558a Kent Overstreet 2026-01-17 322 u64 idx = new.k->p.offset;
bde39b90107558a Kent Overstreet 2026-01-17 323 const struct bch_stripe *old_s = old.k->type == KEY_TYPE_stripe
bde39b90107558a Kent Overstreet 2026-01-17 324 ? bkey_s_c_to_stripe(old).v : NULL;
bde39b90107558a Kent Overstreet 2026-01-17 325 const struct bch_stripe *new_s = new.k->type == KEY_TYPE_stripe
bde39b90107558a Kent Overstreet 2026-01-17 326 ? bkey_s_c_to_stripe(new).v : NULL;
bde39b90107558a Kent Overstreet 2026-01-17 327
bde39b90107558a Kent Overstreet 2026-01-17 328 if (unlikely(flags & BTREE_TRIGGER_check_repair))
bde39b90107558a Kent Overstreet 2026-01-17 329 return bch2_check_fix_ptrs(trans, btree, level, _new.s_c, flags);
bde39b90107558a Kent Overstreet 2026-01-17 330
bde39b90107558a Kent Overstreet 2026-01-17 331 BUG_ON(new_s && old_s &&
bde39b90107558a Kent Overstreet 2026-01-17 332 (new_s->nr_blocks != old_s->nr_blocks ||
bde39b90107558a Kent Overstreet 2026-01-17 333 new_s->nr_redundant != old_s->nr_redundant));
bde39b90107558a Kent Overstreet 2026-01-17 334
bde39b90107558a Kent Overstreet 2026-01-17 335 if (flags & BTREE_TRIGGER_transactional) {
bde39b90107558a Kent Overstreet 2026-01-17 336 u64 old_lru_pos = stripe_lru_pos(old_s);
bde39b90107558a Kent Overstreet 2026-01-17 337 u64 new_lru_pos = stripe_lru_pos(new_s);
bde39b90107558a Kent Overstreet 2026-01-17 338
bde39b90107558a Kent Overstreet 2026-01-17 339 if (new_lru_pos == STRIPE_LRU_POS_EMPTY &&
bde39b90107558a Kent Overstreet 2026-01-17 340 !bch2_stripe_is_open(c, idx)) {
bde39b90107558a Kent Overstreet 2026-01-17 341 _new.k->type = KEY_TYPE_deleted;
bde39b90107558a Kent Overstreet 2026-01-17 342 set_bkey_val_u64s(_new.k, 0);
bde39b90107558a Kent Overstreet 2026-01-17 343 new_s = NULL;
bde39b90107558a Kent Overstreet 2026-01-17 344 new_lru_pos = 0;
bde39b90107558a Kent Overstreet 2026-01-17 345 }
bde39b90107558a Kent Overstreet 2026-01-17 346
bde39b90107558a Kent Overstreet 2026-01-17 347 try(bch2_lru_change(trans,
bde39b90107558a Kent Overstreet 2026-01-17 348 BCH_LRU_STRIPE_FRAGMENTATION, idx,
bde39b90107558a Kent Overstreet 2026-01-17 349 old_lru_pos, new_lru_pos));
bde39b90107558a Kent Overstreet 2026-01-17 350 }
bde39b90107558a Kent Overstreet 2026-01-17 351
bde39b90107558a Kent Overstreet 2026-01-17 352 if (flags & (BTREE_TRIGGER_transactional|BTREE_TRIGGER_gc)) {
bde39b90107558a Kent Overstreet 2026-01-17 353 /*
bde39b90107558a Kent Overstreet 2026-01-17 354 * If the pointers aren't changing, we don't need to do anything:
bde39b90107558a Kent Overstreet 2026-01-17 355 */
bde39b90107558a Kent Overstreet 2026-01-17 @356 if (new_s && old_s &&
bde39b90107558a Kent Overstreet 2026-01-17 357 new_s->nr_blocks == old_s->nr_blocks &&
bde39b90107558a Kent Overstreet 2026-01-17 358 new_s->nr_redundant == old_s->nr_redundant &&
bde39b90107558a Kent Overstreet 2026-01-17 359 !memcmp(old_s->ptrs, new_s->ptrs,
bde39b90107558a Kent Overstreet 2026-01-17 360 new_s->nr_blocks * sizeof(struct bch_extent_ptr)))
bde39b90107558a Kent Overstreet 2026-01-17 361 return 0;
bde39b90107558a Kent Overstreet 2026-01-17 362
bde39b90107558a Kent Overstreet 2026-01-17 363 struct gc_stripe *gc = NULL;
bde39b90107558a Kent Overstreet 2026-01-17 364 if (flags & BTREE_TRIGGER_gc) {
bde39b90107558a Kent Overstreet 2026-01-17 365 gc = genradix_ptr_alloc(&c->ec.gc_stripes, idx, GFP_KERNEL);
bde39b90107558a Kent Overstreet 2026-01-17 366 if (!gc) {
bde39b90107558a Kent Overstreet 2026-01-17 367 bch_err(c, "error allocating memory for gc_stripes, idx %llu", idx);
bde39b90107558a Kent Overstreet 2026-01-17 368 return bch_err_throw(c, ENOMEM_mark_stripe);
bde39b90107558a Kent Overstreet 2026-01-17 369 }
bde39b90107558a Kent Overstreet 2026-01-17 370
bde39b90107558a Kent Overstreet 2026-01-17 371 /*
bde39b90107558a Kent Overstreet 2026-01-17 372 * This will be wrong when we bring back runtime gc: we should
bde39b90107558a Kent Overstreet 2026-01-17 373 * be unmarking the old key and then marking the new key
bde39b90107558a Kent Overstreet 2026-01-17 374 *
bde39b90107558a Kent Overstreet 2026-01-17 375 * Also: when we bring back runtime gc, locking
bde39b90107558a Kent Overstreet 2026-01-17 376 */
bde39b90107558a Kent Overstreet 2026-01-17 377 gc->alive = true;
bde39b90107558a Kent Overstreet 2026-01-17 @378 gc->sectors = le16_to_cpu(new_s->sectors);
bde39b90107558a Kent Overstreet 2026-01-17 379 gc->nr_blocks = new_s->nr_blocks;
bde39b90107558a Kent Overstreet 2026-01-17 380 gc->nr_redundant = new_s->nr_redundant;
bde39b90107558a Kent Overstreet 2026-01-17 381
bde39b90107558a Kent Overstreet 2026-01-17 382 for (unsigned i = 0; i < new_s->nr_blocks; i++)
bde39b90107558a Kent Overstreet 2026-01-17 383 gc->ptrs[i] = new_s->ptrs[i];
bde39b90107558a Kent Overstreet 2026-01-17 384
bde39b90107558a Kent Overstreet 2026-01-17 385 /*
bde39b90107558a Kent Overstreet 2026-01-17 386 * gc recalculates this field from stripe ptr
bde39b90107558a Kent Overstreet 2026-01-17 387 * references:
bde39b90107558a Kent Overstreet 2026-01-17 388 */
bde39b90107558a Kent Overstreet 2026-01-17 389 memset(gc->block_sectors, 0, sizeof(gc->block_sectors));
bde39b90107558a Kent Overstreet 2026-01-17 390 }
bde39b90107558a Kent Overstreet 2026-01-17 391
bde39b90107558a Kent Overstreet 2026-01-17 392 if (new_s) {
bde39b90107558a Kent Overstreet 2026-01-17 393 s64 sectors = (u64) le16_to_cpu(new_s->sectors) * new_s->nr_redundant;
bde39b90107558a Kent Overstreet 2026-01-17 394
bde39b90107558a Kent Overstreet 2026-01-17 395 struct disk_accounting_pos acc;
bde39b90107558a Kent Overstreet 2026-01-17 396 memset(&acc, 0, sizeof(acc));
bde39b90107558a Kent Overstreet 2026-01-17 397 acc.type = BCH_DISK_ACCOUNTING_replicas;
bde39b90107558a Kent Overstreet 2026-01-17 398 bch2_bkey_to_replicas(c, &acc.replicas, new);
bde39b90107558a Kent Overstreet 2026-01-17 399 try(bch2_disk_accounting_mod(trans, &acc, §ors, 1, gc));
bde39b90107558a Kent Overstreet 2026-01-17 400
bde39b90107558a Kent Overstreet 2026-01-17 401 if (gc)
bde39b90107558a Kent Overstreet 2026-01-17 402 unsafe_memcpy(&gc->r.e, &acc.replicas,
bde39b90107558a Kent Overstreet 2026-01-17 403 replicas_entry_bytes(&acc.replicas), "VLA");
bde39b90107558a Kent Overstreet 2026-01-17 404 }
bde39b90107558a Kent Overstreet 2026-01-17 405
bde39b90107558a Kent Overstreet 2026-01-17 406 if (old_s) {
bde39b90107558a Kent Overstreet 2026-01-17 407 s64 sectors = -((s64) le16_to_cpu(old_s->sectors)) * old_s->nr_redundant;
bde39b90107558a Kent Overstreet 2026-01-17 408
bde39b90107558a Kent Overstreet 2026-01-17 409 struct disk_accounting_pos acc;
bde39b90107558a Kent Overstreet 2026-01-17 410 memset(&acc, 0, sizeof(acc));
bde39b90107558a Kent Overstreet 2026-01-17 411 acc.type = BCH_DISK_ACCOUNTING_replicas;
bde39b90107558a Kent Overstreet 2026-01-17 412 bch2_bkey_to_replicas(c, &acc.replicas, old);
bde39b90107558a Kent Overstreet 2026-01-17 413 try(bch2_disk_accounting_mod(trans, &acc, §ors, 1, gc));
bde39b90107558a Kent Overstreet 2026-01-17 414 }
bde39b90107558a Kent Overstreet 2026-01-17 415
bde39b90107558a Kent Overstreet 2026-01-17 416 try(mark_stripe_buckets(trans, old, new, flags));
bde39b90107558a Kent Overstreet 2026-01-17 417 }
bde39b90107558a Kent Overstreet 2026-01-17 418
bde39b90107558a Kent Overstreet 2026-01-17 419 if ((flags & (BTREE_TRIGGER_atomic|BTREE_TRIGGER_gc)) == BTREE_TRIGGER_atomic) {
bde39b90107558a Kent Overstreet 2026-01-17 420 if (new_s && stripe_lru_pos(new_s) == 1)
bde39b90107558a Kent Overstreet 2026-01-17 421 bch2_do_stripe_deletes(c);
bde39b90107558a Kent Overstreet 2026-01-17 422 }
bde39b90107558a Kent Overstreet 2026-01-17 423
bde39b90107558a Kent Overstreet 2026-01-17 424 return 0;
bde39b90107558a Kent Overstreet 2026-01-17 425 }
bde39b90107558a Kent Overstreet 2026-01-17 426
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
reply other threads:[~2026-05-14 19:27 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=202605150347.BGMlkbv9-lkp@intel.com \
--to=lkp@intel.com \
--cc=error27@gmail.com \
--cc=oe-kbuild@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.