Commit Graph

5280 Commits

Author SHA1 Message Date
Kent Overstreet
a7c9add482 bcachefs: Include b->ob.nr in cached_btree_node_to_text()
We have a bug report that looks like we might be leaking open buckets -
let's check if they got left attached to the cached btree node.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-30 01:21:13 -04:00
Kent Overstreet
e87de7d491 bcachefs: Move devs_sorted to alloc_request
More stack usage work.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-30 01:21:13 -04:00
Kent Overstreet
ff6369da9a bcachefs: reduce stack usage in alloc_sectors_start()
with typical config options, variables in different inline functions
aren't sharing stack space - and these are slowpaths.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-30 01:21:13 -04:00
Kent Overstreet
eabef52ff8 bcachefs: bch2_alloc_v4_to_text()
Specialize the .to_text() for alloc_v4, to avoid the temporary on the
stack for conversion from old versions.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-30 01:21:13 -04:00
Kent Overstreet
0c34e7ff69 bcachefs: Tweak bch2_data_update_init() for stack usage
- Separate out a slowpath for bkey_nocow_lock()
- Don't call bch2_bkey_ptrs_c() or loop over pointers more than
  necessary

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-30 01:21:13 -04:00
Kent Overstreet
56e5c7f65f bcachefs: kill replicas_sectors arg to __trigger_extent()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-30 01:21:13 -04:00
Kent Overstreet
92caf17189 bcachefs: Don't stack allocate bch_writepage_state
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-30 01:21:12 -04:00
Kent Overstreet
cd831a9494 bcachefs: factor out break_cycle_fail()
More stack usage work.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-30 01:21:12 -04:00
Kent Overstreet
19c0a8aa8a bcachefs: btree_node_missing_err()
Factor out an error path for a small stack usage improvement.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-30 01:21:12 -04:00
Kent Overstreet
0d25264ecf bcachefs: Kill bkey_buf in btree_path_down()
Allocate some (smaller) temporary storage in btree_trans for this -
btree_path_down() is in our max-stack call stack.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-30 01:21:12 -04:00
Kent Overstreet
99813d88e3 bcachefs: Add missing error logging in delete_dead_inodes()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-30 01:21:12 -04:00
Kent Overstreet
f54b2a80d0 bcachefs: Fix misaligned bucket check in journal space calculations
Fix an assertion pop in the tiering_misaligned test: rounding down to
bucket size at the end of the journal space calculations leaves
cur_entry_sectors == 0, which is incorrect with !cur_entry_err.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-30 01:21:12 -04:00
Kent Overstreet
813825d241 bcachefs: Fix incorrect multiple dev check in journal write path
It's uncomon to have multiple devices with journalling only on a subset,
but can be specified with the 'data_allowed' option. We need to know if
we're doing data/metadata writes to multiple devices, as that requires
issuing flushes before the journal writes.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-30 01:21:12 -04:00
Kent Overstreet
327971cef5 bcachefs: Catch data_update_done events in trace_io_move_start_fail
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-30 01:21:12 -04:00
Kent Overstreet
c7897b5055 bcachefs: io_move_evacuate_bucket tracepoint, counter
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-30 01:21:12 -04:00
Kent Overstreet
060ff4b794 bcachefs: trace_io_move_pred
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-30 01:21:12 -04:00
Kent Overstreet
d6efd42a84 bcachefs: Fix infinite loop in journal_entry_btree_keys_to_text()
Fix an infinite loop when bkey_i->k.u64s is 0.

This only happens in userspace, where 'bcachefs list_journal' can print
the entire contents of the journal, and non-dirty entries aren't
validated.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-30 01:21:12 -04:00
Kent Overstreet
cd04497b10 bcachefs: Journal read error message improvements
- Don't print a checksum error when we first read a journal entry: we
  print a checksum error later if we'll be using the journal entry.

- Continuing with the theme of of improving error messages and grouping
  errors into a single log message per error, print a single 'checksum
  error' message per journal entry, and use bch2_journal_ptr_to_text()
  to print out where on the device it was.

- Factor out checksum error messages and checking for missing journal
  entries into helpers, bch2_journal_read() has gotten obnoxiously big.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-30 01:21:12 -04:00
Linus Torvalds
5e8bbb2caa Another set of timer API cleanups:
- Convert init_timer*(), try_to_del_timer_sync() and
    destroy_timer_on_stack() over to the canonical timer_*() namespace
    convention.
 
 There are is another large converstion pending, which has not been included
 because it would have caused a gazillion of merge conflicts in next. The
 conversion scripts will be run towards the end of the merge window and a
 pull request sent once all conflict dependencies have been merged.
 -----BEGIN PGP SIGNATURE-----
 
 iQJHBAABCgAxFiEEQp8+kY+LLUocC4bMphj1TA10mKEFAmgzgTkTHHRnbHhAbGlu
 dXRyb25peC5kZQAKCRCmGPVMDXSYodwVD/97rF1Juqm1JZNIZPN/vMqwCxRoUkc6
 tsK0+UC7UXusuJadxJ+Bsv25iPF+qejnThMU+SQ5yTVj/PNfxOe0WPdCEGGiL8Ye
 2JCk6GqSOB/360SlLmtR1B1xHDwsuuUcQTz0w57CH66HRV5vpoWSMSwj/ypy+8nU
 PlgjItaxdCKa9NJ+SUJZPWIxRkt/PsA1kwlV1OcxkgB++IiIHQEbPxECq9mlzWXF
 b4Sq/Sdf2OmEePN+DYoey4fneRwJnkjkeX/o+CqosCPHRIiWUlSu5W/lU5IYojM3
 s3XpMNNg/z8PMXR4JA2VaPYWLUZyBOs+3dM7Y6Am+z55EoxMxfzg6pGx2tfM4ftl
 vF8wG3Z1c9MmpLk+P9LatNvfHeVLNve8KgOLa5phMDQ/El/a8KqLu6HmRDPONvKp
 d6iXdPq1CP8P6jOtlFfzLmKPShgEcp+Zz9W3CaQR/0ZJEsEqrpKOLzdT86hJhBV0
 mBCdzixmGtKAh0BdPdmg2FCLScqER3HKIJhZSdV8I+jSETIHCuMiIfbMXR7iwm/H
 R1/ayvxrbc1mPseo28scqvo7m6cn5BFBxIUf4Sokp52ZCapz1v2aWzo4vHI0cTgT
 ZOjlTrf+fgYLn1dqdD45TJiQPnmRrw4dU+WWSFRFJY2qjfyucj80vdqdkE5zkp5b
 UPomlVimG4ccPg==
 =FHGU
 -----END PGP SIGNATURE-----

Merge tag 'timers-cleanups-2025-05-25' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull timer cleanups from Thomas Gleixner:
 "Another set of timer API cleanups:

    - Convert init_timer*(), try_to_del_timer_sync() and
      destroy_timer_on_stack() over to the canonical timer_*()
      namespace convention.

  There is another large conversion pending, which has not been included
  because it would have caused a gazillion of merge conflicts in next.
  The conversion scripts will be run towards the end of the merge window
  and a pull request sent once all conflict dependencies have been
  merged"

* tag 'timers-cleanups-2025-05-25' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  treewide, timers: Rename destroy_timer_on_stack() as timer_destroy_on_stack()
  treewide, timers: Rename try_to_del_timer_sync() as timer_delete_sync_try()
  timers: Rename init_timers() as timers_init()
  timers: Rename NEXT_TIMER_MAX_DELTA as TIMER_NEXT_MAX_DELTA
  timers: Rename __init_timer_on_stack() as __timer_init_on_stack()
  timers: Rename __init_timer() as __timer_init()
  timers: Rename init_timer_on_stack_key() as timer_init_key_on_stack()
  timers: Rename init_timer_key() as timer_init_key()
2025-05-27 08:31:21 -07:00
Kent Overstreet
72ab5136e8 bcachefs: Don't rewind to run a recovery pass we already ran
Fix a small regression from the "run recovery passes" rewrite, which
enabled async recovery passes.

This fixes getting stuck in a loop in recovery.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-27 00:03:45 -04:00
Kent Overstreet
686db67a8e bcachefs: Move unicode message to after the startup message
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-27 00:03:45 -04:00
Kent Overstreet
1cda5b88e6 bcachefs: Fix missing commit in check_dirents
Other repair code seems to be doing commits themselves, but
check_key_has_snapshot() does not.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-27 00:02:44 -04:00
Kent Overstreet
9e2c3c2ed4 bcachefs: Fix lost rebalance wakeups
Fix a missing wakeup in

'bcachefs set-file-option' -> xattr option update -> inode_write

this was missing because the wakeup needs to happen after transaction
commit. Also, add a 'kick' counter, to make sure we don't miss a wakeup
that occured right after we finished checking the rebalance_work btree.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-27 00:02:44 -04:00
Kent Overstreet
dc37dcca8c bcachefs: bch2_kthread_io_clock_wait_once()
Add a version of bch2_kthread_io_clock_wait() that only schedules once -
behaving more like schedule_timeout().

This will be used for fixing rebalance wakeups.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-27 00:02:44 -04:00
Kent Overstreet
ff875d4b47 bcachefs: Ensure we print output of run_recovery_pass if it errors
Also, don't error out in bucket_ref_update_err(): we don't want to
return -BCH_ERR_cannot_rewind_recovery if it's not an insert, if it's an
overwrite we continue.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-27 00:02:44 -04:00
Linus Torvalds
14418ddcc2 This update includes the following changes:
API:
 
 - Fix memcpy_sglist to handle partially overlapping SG lists.
 - Use memcpy_sglist to replace null skcipher.
 - Rename CRYPTO_TESTS to CRYPTO_BENCHMARK.
 - Flip CRYPTO_MANAGER_DISABLE_TEST into CRYPTO_SELFTESTS.
 - Hide CRYPTO_MANAGER.
 - Add delayed freeing of driver crypto_alg structures.
 
 Compression:
 
 - Allocate large buffers on first use instead of initialisation in scomp.
 - Drop destination linearisation buffer in scomp.
 - Move scomp stream allocation into acomp.
 - Add acomp scatter-gather walker.
 - Remove request chaining.
 - Add optional async request allocation.
 
 Hashing:
 
 - Remove request chaining.
 - Add optional async request allocation.
 - Move partial block handling into API.
 - Add ahash support to hmac.
 - Fix shash documentation to disallow usage in hard IRQs.
 
 Algorithms:
 
 - Remove unnecessary SIMD fallback code on x86 and arm/arm64.
 - Drop avx10_256 xts(aes)/ctr(aes) on x86.
 - Improve avx-512 optimisations for xts(aes).
 - Move chacha arch implementations into lib/crypto.
 - Move poly1305 into lib/crypto and drop unused Crypto API algorithm.
 - Disable powerpc/poly1305 as it has no SIMD fallback.
 - Move sha256 arch implementations into lib/crypto.
 - Convert deflate to acomp.
 - Set block size correctly in cbcmac.
 
 Drivers:
 
 - Do not use sg_dma_len before mapping in sun8i-ss.
 - Fix warm-reboot failure by making shutdown do more work in qat.
 - Add locking in zynqmp-sha.
 - Remove cavium/zip.
 - Add support for PCI device 0x17D8 to ccp.
 - Add qat_6xxx support in qat.
 - Add support for RK3576 in rockchip-rng.
 - Add support for i.MX8QM in caam.
 
 Others:
 
 - Fix irq_fpu_usable/kernel_fpu_begin inconsistency during CPU bring-up.
 - Add new SEV/SNP platform shutdown API in ccp.
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEn51F/lCuNhUwmDeSxycdCkmxi6cFAmgz47AACgkQxycdCkmx
 i6fvKRAAr4Xa903L0r1Q1P1alQqoFFCqimUWeH72m68LiWynHWi0lUo0z/+tKweg
 mnPStz7/Ha9HRHJjdNCMPnlJqXQDkuH3bIOuBJCwduDuhHo9VGOd46XGzmGMv3gb
 HKuZhI0lk7pznK3CSyD/2nHmbDCHD+7feTZSBMoN9mm875+aSoM6fdxgak8uPFcq
 KbB1L+hObTn2kAPSqRrNOR8/xG2N7hdH8eax7Li+LAtqYNVT5HvWVECsB/CKRPfB
 sgAv3UTzcIFapSSHUHaONppSeoqPAIAeV7SdQhJvlT+EUUR/h/B6+D9OUQQqbphQ
 LBalgTnqMKl0ymDEQFQ6QyYCat9ZfNmDft2WcXEsxc8PxImkgJI1W3B8O51sOjbG
 78D8JqVQ96dleo4FsBhM2wfG0b41JM6zU4raC4vS7a3qsUS+Q1MpehvcS1iORicy
 SpGdE8e7DLlxKhzWyW1xJnbrtMZDC7Sa2hUnxrvP0/xOvRhChKscRVtWcf0a5q7X
 8JmuvwVSOJuSbQ3MeFbQvpo5lR9+0WsNjM6e9miiH6Y7vZUKmWcq2yDp377qVzeh
 7NK6+OwGIQZZExrmtPw2BXwssT9Eg+ks6Y7g2Ne7yzvrjVNfEPY7Cws/5w7p8mRS
 qhrcpbJNFlWgD7YYkmGZFTQ8DCN25ipP8lklO/hbcfchqLE/o1o=
 =O8L5
 -----END PGP SIGNATURE-----

Merge tag 'v6.16-p1' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6

Pull crypto updates from Herbert Xu:
 "API:
   - Fix memcpy_sglist to handle partially overlapping SG lists
   - Use memcpy_sglist to replace null skcipher
   - Rename CRYPTO_TESTS to CRYPTO_BENCHMARK
   - Flip CRYPTO_MANAGER_DISABLE_TEST into CRYPTO_SELFTESTS
   - Hide CRYPTO_MANAGER
   - Add delayed freeing of driver crypto_alg structures

  Compression:
   - Allocate large buffers on first use instead of initialisation in scomp
   - Drop destination linearisation buffer in scomp
   - Move scomp stream allocation into acomp
   - Add acomp scatter-gather walker
   - Remove request chaining
   - Add optional async request allocation

  Hashing:
   - Remove request chaining
   - Add optional async request allocation
   - Move partial block handling into API
   - Add ahash support to hmac
   - Fix shash documentation to disallow usage in hard IRQs

  Algorithms:
   - Remove unnecessary SIMD fallback code on x86 and arm/arm64
   - Drop avx10_256 xts(aes)/ctr(aes) on x86
   - Improve avx-512 optimisations for xts(aes)
   - Move chacha arch implementations into lib/crypto
   - Move poly1305 into lib/crypto and drop unused Crypto API algorithm
   - Disable powerpc/poly1305 as it has no SIMD fallback
   - Move sha256 arch implementations into lib/crypto
   - Convert deflate to acomp
   - Set block size correctly in cbcmac

  Drivers:
   - Do not use sg_dma_len before mapping in sun8i-ss
   - Fix warm-reboot failure by making shutdown do more work in qat
   - Add locking in zynqmp-sha
   - Remove cavium/zip
   - Add support for PCI device 0x17D8 to ccp
   - Add qat_6xxx support in qat
   - Add support for RK3576 in rockchip-rng
   - Add support for i.MX8QM in caam

  Others:
   - Fix irq_fpu_usable/kernel_fpu_begin inconsistency during CPU bring-up
   - Add new SEV/SNP platform shutdown API in ccp"

* tag 'v6.16-p1' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (382 commits)
  x86/fpu: Fix irq_fpu_usable() to return false during CPU onlining
  crypto: qat - add missing header inclusion
  crypto: api - Redo lookup on EEXIST
  Revert "crypto: testmgr - Add hash export format testing"
  crypto: marvell/cesa - Do not chain submitted requests
  crypto: powerpc/poly1305 - add depends on BROKEN for now
  Revert "crypto: powerpc/poly1305 - Add SIMD fallback"
  crypto: ccp - Add missing tee info reg for teev2
  crypto: ccp - Add missing bootloader info reg for pspv5
  crypto: sun8i-ce - move fallback ahash_request to the end of the struct
  crypto: octeontx2 - Use dynamic allocated memory region for lmtst
  crypto: octeontx2 - Initialize cptlfs device info once
  crypto: xts - Only add ecb if it is not already there
  crypto: lrw - Only add ecb if it is not already there
  crypto: testmgr - Add hash export format testing
  crypto: testmgr - Use ahash for generic tfm
  crypto: hmac - Add ahash support
  crypto: testmgr - Ignore EEXIST on shash allocation
  crypto: algapi - Add driver template support to crypto_inst_setname
  crypto: shash - Set reqsize in shash_alg
  ...
2025-05-26 13:47:28 -07:00
Kent Overstreet
97e69f12ed bcachefs: Fix missing BTREE_UPDATE_internal_snapshot_node
Repair code will do updates on older snapshot versions, so needs the
correct annotation.

Reported-by: syzbot+42581416dba62b364750@syzkaller.appspotmail.com
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-25 03:22:18 -04:00
Kent Overstreet
7098ba57c4 bcachefs: fix REFLINK_P_MAY_UPDATE_OPTIONS
If we're doing a reflink copy of existing reflinked data, we may only
set REFLINK_P_MAY_UPDATE_OPTIONS if it was set on the reflink pointer
we're copying from.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-25 03:22:18 -04:00
Kent Overstreet
9caea9208f bcachefs: Don't mount bs > ps without TRANSPARENT_HUGEPAGE
Large folios aren't supported without TRANSPARENT_HUGEPAGE

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-23 22:00:07 -04:00
Kent Overstreet
3f2f028814 bcachefs: Fix btree_iter_next_node() for new locking asserts
We can't unlock a should_be_locked path unless we're in a transaction
restart.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-23 22:00:07 -04:00
Kent Overstreet
521f9584c2 bcachefs: Ensure we don't use a blacklisted journal seq
Different versions differ on the size of the blacklist range; it is
theoretically possible that we could end up with blacklisted journal
sequence numbers newer than the newest seq we find in the journal, and
pick a new start seq that's blacklisted.

Explicitly check for this in bch2_fs_journal_start().

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-23 19:52:31 -04:00
Kent Overstreet
9b133c0d74 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 <kent.overstreet@linux.dev>
2025-05-23 19:52:31 -04:00
Kent Overstreet
cade003209 bcachefs: Fix opts.recovery_pass_last
This was lost in the giant recovery pass rework - but it's used heavily
by bcachefs subcommand utilities.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-23 19:52:31 -04:00
Kent Overstreet
f351d91edd bcachefs: Fix allocate -> self healing path
When we go to allocate and find taht a bucket in the freespace btree is
actually allocated, we're supposed to return nonzero to tell the
allocator to skip it.

This fixes an emergency read only due to a bucket/ptr gen mismatch - we
also don't return the correct bucket gen when this happens.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-23 19:52:31 -04:00
Kent Overstreet
016c4b48b8 bcachefs: Fix endianness in casefold check/repair
Fixes: 010c894681 ("bcachefs: Check for casefolded dirents in non casefolded dirs")
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-23 19:52:31 -04:00
Kent Overstreet
b41ac97fe0 bcachefs: Path must be locked if trans->locked && should_be_locked
If path->should_be_locked is true, that means user code (of the btree
API) has seen, in this transaction, something guarded by the node this
path has locked, and we have to keep it locked until the end of the
transaction.

Assert that we're not violating this; should_be_locked should also be
cleared only in _very_ special situations.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-23 07:59:43 -04:00
Kent Overstreet
22e921a6f9 bcachefs: Simplify bch2_path_put()
Simplify the "do we need to keep this locked?" checks.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-23 07:59:43 -04:00
Kent Overstreet
80a160e494 bcachefs: Plumb btree_trans for more locking asserts
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-23 07:59:43 -04:00
Kent Overstreet
df92f3500b bcachefs: Clear trans->locked before unlock
We're adding new should_be_locked assertions: it's going to be illegal
to unlock a should_be_locked path when trans->locked is true.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-23 07:59:43 -04:00
Kent Overstreet
eb34365ada bcachefs: Clear should_be_locked before unlock in key_cache_drop()
We're adding new should_be_locked assertions, also add a comment
explaining why clearing should_be_locked is safe here.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-23 07:59:43 -04:00
Kent Overstreet
be9fecdcda bcachefs: bch2_path_get() reuses paths if upgrade_fails & !should_be_locked
Small additional optimization over the previous patch, bringing us
closer to the original behaviour, except when we need to clone to avoid
a transaction restart.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-23 07:59:43 -04:00
Kent Overstreet
aac49471b6 bcachefs: Give out new path if upgrade fails
Avoid transaction restarts due to failure to upgrade - we can traverse a
new iterator without a transaction restart.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-23 07:59:43 -04:00
Kent Overstreet
66782b2acb bcachefs: Fix btree_path_get_locks when not doing trans restart
btree_path_get_locks, on failure, shouldn't unlock if we're not issuing
a transaction restart: we might drop locks we're not supposed to (if
path->should_be_locked is set).

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-23 07:59:43 -04:00
Kent Overstreet
5b7b342c40 bcachefs: btree_node_locked_type_nowrite()
Small helper to improve locking assertions.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-23 07:59:43 -04:00
Kent Overstreet
659489f37b bcachefs: Kill bch2_path_put_nokeep()
bch2_path_put_nokeep() was intended for paths we wouldn't need to
preserve for a transaction restart - it always frees them right away
when the ref hits 0.

But since paths are shared, freeing unconditionally is a bug, the path
might have been used elsewhere and have should_be_locked set, i.e. we
need to keep it locked until the end of the transaction.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-23 07:59:43 -04:00
Kent Overstreet
2a6c0136ae bcachefs: bch2_journal_write_checksum()
We need to delay checksumming the journal write; we don't know the
blocksize until after we allocate the write.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-22 15:13:17 -04:00
Kent Overstreet
d385ca5603 bcachefs: Reduce stack usage in data_update_index_update()
Separate tracepoint message generation and other slowpath code into
non-inline functions, and use bch2_trans_log_str() instead of using a
printbuf for our journal message.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-22 15:13:17 -04:00
Kent Overstreet
7d886a82bf bcachefs: bch2_trans_log_str()
The data update path doesn't need a printbuf for its log message - this
will help reduce stack usage.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-22 15:13:17 -04:00
Kent Overstreet
4a9eb20efa bcachefs: Kill bkey_buf usage in data_update_index_update()
Reduce stack usage - bkey_buf has a 96 byte buffer on the stack, but the
btree_trans bump allocator works just fine here.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-22 15:13:17 -04:00
Kent Overstreet
bfc0c6fecf bcachefs: Drop empty accounting updates
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:19:24 -04:00
Kent Overstreet
136d082abc bcachefs: Improve trace_trans_restart_upgrade
- Convert to a 'fs_str' tracepoint that just emits as a string: this
  lets us build up the tracepoint with a printbuf, using our pretty
  printers, and they're much easier to manage

- Include locks_held, before and after

- Include the btree node pointer we failed on (error pointer, null, or
  real node)

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:15:11 -04:00
Kent Overstreet
f638b84224 bcachefs: fix bch2_inum_snapshot_to_path()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:15:11 -04:00
Kent Overstreet
2faa8ab0d0 bcachefs: fix duplicate printk
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:15:10 -04:00
Kent Overstreet
4ba99dde33 bcachefs: BCH_INODE_has_case_insensitive
Add a flag for tracking whether a directory has case-insensitive
descendents - so that overlayfs can disallow mounting, even though the
filesystem supports case insensitivity.

This is a new on disk format version, with a (cheap) upgrade to ensure
the flag is correctly set on existing inodes.

Create, rename and fssetxattr are all plumbed to ensure the new flag is
set, and we've got new fsck code that hooks into check_inode(0.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:15:10 -04:00
Kent Overstreet
77eac89c79 bcachefs: bch2_inode_find_by_inum_snapshot()
Move a fsck.c helper into inode.c, eliminate some duplicate and organize
the inode lookup helpers.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:15:09 -04:00
Kent Overstreet
77aeaa2f0f bcachefs: bch2_inum_snapshot_to_path()
Add a better helper for printing out paths of inodes when we don't know
the subvolume, for fsck.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:15:09 -04:00
Kent Overstreet
7c4f22af25 bcachefs: bch2_rename_trans() only runs rename-to-dir code if needed
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:15:08 -04:00
Kent Overstreet
011d644b76 bcachefs: subvol_inum_eq()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:15:08 -04:00
Kent Overstreet
c3a7fd95e0 bcachefs: Don't set bi_casefold on non directories
bi_casefold only makes sense for directories, and since it's one of the
variable length fields setting it unnecessarily wastes space.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:15:08 -04:00
Alan Huang
a96c5e5045 bcachefs: Remove duplicate call to bch2_trans_begin()
There is one in for_each_btree_key_max().

Signed-off-by: Alan Huang <mmpgouride@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:15:08 -04:00
Kent Overstreet
c631bb41f5 bcachefs: Call bch2_bkey_set_needs_rebalance() earlier in write path
There's no reason to be running this inside our transaction; it forces
us to copy the key we're updating to a temporary, which we'd like to
skip.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:15:07 -04:00
Kent Overstreet
f132a78095 bcachefs: Simplify bch2_extent_atomic_end()
It used to be that we had a fixed maximum number of btree paths to work
with - 64.

That's no longer the case, so bch2_extent_atomic_end() doesn't have to
be as strict.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:15:07 -04:00
Kent Overstreet
7fd643c032 bcachefs: Coalesce accounting in trans commit
Accounting has gotten quite heavy, and there's lots of redundancy in
accounting updates within a transaction, as we often add/delete multiple
extents that touch the same accountign counters.

This will reduce the amount of data that we journal, and reduce pressure
downstream on the btree write buffer.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:15:06 -04:00
Kent Overstreet
e8f9992b0a bcachefs: Split out accounting in transaction commit
There can be a lot of rendundancy in accounting updates within a single
btree transaction.

Split out accounting updates so that they can be deduped, in the next
commit.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:15:06 -04:00
Kent Overstreet
247abee6ae bcachefs: btree_trans_subbuf
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:15:06 -04:00
Kent Overstreet
81c42933a5 bcachefs: Make accounting mismatch errors more readable
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:15:06 -04:00
Kent Overstreet
51e23c9d60 bcachefs: async objs now support bch_write_ops
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:15:05 -04:00
Kent Overstreet
8c3fc7cca3 bcachefs: fix bch2_debugfs_flush_buf() when tabstops are in use
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:15:05 -04:00
Kent Overstreet
6b86da9282 bcachefs: fsck: Include loops in error messages
This fixes the subvol loop checking and directory loop checking to print
the loop.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:15:05 -04:00
Kent Overstreet
39cea302f1 bcachefs: bch2_check_bucket_backpointer_mismatch()
Detect buckets with missing backpointers, and run repair on demand.

__bch2_move_data_phys() now calls
bch2_check_bucket_backpointer_mismatch() as it walks buckets, which
checks for missing backpointers by comparing backpointers against bucket
sector counts.

When missing backpointers are detected, we kick off
bch2_check_extents_to_backpointers() asynchronously - right away if
we're trying to evacuate, or with a threshold if we're just running
copygc.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:15:04 -04:00
Kent Overstreet
15f969326e bcachefs: Improve bucket_bitmap code
Add some more helpers, and mismatches is now a superset of the empty
bitmap - simplifies most checks.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:15:04 -04:00
Kent Overstreet
06977ea82b bcachefs: Run recovery passes asynchronously
When we request a recovery pass to be run online, i.e. not during
recovery, if it's an online pass it'll now be run in the background,
instead of waiting for the next mount.

To avoid situations where recovery passes are running continuously, this
also includes ratelimiting: if the RUN_RECOVERY_PASS_ratelimit flag is
passed, the pass may be deferred until later - depending on the runtime
and last run stats in the recovery_passes superblock section.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:15:04 -04:00
Kent Overstreet
d4b30ed90c bcachefs: bch2_run_explicit_recovery_pass() cleanup
Consolidate the run_explicit_recovery_pass() interfaces by adding a
flags parameter; this will also let us add a RUN_RECOVERY_PASS_ratelimit
flag.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:15:04 -04:00
Kent Overstreet
06266465cc bcachefs: bch2_recovery_pass_status_to_text()
Show recovery pass status in sysfs - important now that we're running
them automatically in the background.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:15:03 -04:00
Kent Overstreet
7ed4c14e20 bcachefs: Reduce usage of recovery.curr_pass
We want recovery.curr_pass to be private to the recovery passes code,
for better showing recovery pass status; also, it may rewind and is
generally not the correct member to use.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:15:03 -04:00
Kent Overstreet
ab35552030 bcachefs: __bch2_run_recovery_passes()
Consolidate bch2_run_recovery_passes() and
bch2_run_online_recovery_passes(), prep work for automatically
scheduling and running recovery passes in the background.

- Now takes a mask of which passes to run, automatic background repair
  will pass in sb.recovery_passes_required.

- Skips passes that are failing: a pass that failed may be reattempted
  after another pass succeeds (some passes depend on repair done by
  other passes for successful completion).

- bch2_recovery_passes_match() helper to skip alloc passes on a
  filesystem without alloc info.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:15:03 -04:00
Kent Overstreet
68708efcac bcachefs: struct bch_fs_recovery
bch_fs has gotten obnoxiously big, let's start organizing thins a bit
better.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:15:03 -04:00
Kent Overstreet
878713b5f5 bcachefs: kill copy in bch2_disk_accounting_mod()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:15:02 -04:00
Kent Overstreet
295dbf50e5 bcachefs: Optimize bch2_trans_start_alloc_update()
Avoid doing more updates if we already have one.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:15:02 -04:00
Kent Overstreet
9469556a5f bcachefs: btree key cache asserts
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:15:02 -04:00
Kent Overstreet
a78a11900e bcachefs: journal path now uses discard_opt_enabled()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:15:01 -04:00
Kent Overstreet
8a6fa52e07 bcachefs: relock_fail tracepoint now includes btree
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:15:01 -04:00
Kent Overstreet
84b9f17195 bcachefs: do_rebalance_scan() now only updates bch_extent_rebalance
This ensures that our pending rebalance work accounting is accurate
quickly.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:15:01 -04:00
Kent Overstreet
bde41d9a58 bcachefs: better error message for subvol_fs_path_parent_wrong
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:15:00 -04:00
Kent Overstreet
fdd0807f81 bcachefs: Improve bch2_repair_inode_hash_info()
Improve this so it can be used by fsck.c check_inode(); it provides a
much better error message than the check_inode() version.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:15:00 -04:00
Kent Overstreet
123d2d09ff bcachefs: bch2_inode_find_snapshot_root()
Factor out a small common helper.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:59 -04:00
Alan Huang
4a67b94bd8 bcachefs: Early return to avoid unnecessary lock
Signed-off-by: Alan Huang <mmpgouride@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:59 -04:00
Alan Huang
688321f97e bcachefs: Kill BTREE_TRIGGER_bucket_invalidate
Signed-off-by: Alan Huang <mmpgouride@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:59 -04:00
Kent Overstreet
e882906929 bcachefs: Fix opt hooks in sysfs for non sb option
We weren't checking if the option changed for non-superblock options -
this led to rebalance not waking up when enabling the
"rebalance_enabled" option.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:59 -04:00
Kent Overstreet
648c1142c9 bcachefs: fix can_write_extent()
Failing to check the return value of bch2_dev_rcu(): we could
(technically) race with device removal.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:58 -04:00
Kent Overstreet
c7378d0e5e bcachefs: Add tracepoint, counter for io_move_created_rebalance
Internal moves shouldn't add new rebalance_work, but it's been reported
that this seems to be happening. Add a tracepoint and counter so we can
see what's going on.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:58 -04:00
Kent Overstreet
e4e513f2d5 bcachefs: move_buckets in rhashtable when allocated
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:58 -04:00
Kent Overstreet
fb7e78cc25 bcachefs: Move pending buckets queue to buckets_in_flight
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:57 -04:00
Kent Overstreet
49188a9313 bcachefs: kill move_bucket_in_flight
Small cleanup/simplification, and prep work for the next patch, which
will add checking if buckets don't get evacuated because they're missing
backpointers.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:57 -04:00
Kent Overstreet
b42fac043f bcachefs: bch2_fs_emergency_read_only2()
More error message cleanup: instead of multiple printk()s per error, we
want to be building up a single error message in a printbuf, so that it
can be printed with indenting that shows grouping and avoid errors
getting interspersed or lost in the log.

This gets rid of most calls to bch2_fs_emergency_read_only(). We still
have calls to
 - bch2_fatal_error()
 - bch2_fs_fatal_error()
 - bch2_fs_fatal_err_on()

that need work.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:56 -04:00
Kent Overstreet
ac4c7ac90e bcachefs: Extra write buffer asserts
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:56 -04:00
Kent Overstreet
7ad7497862 bcachefs: add missing locking in bch2_write_point_to_text()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:56 -04:00
Kent Overstreet
177ac4925f bcachefs: Don't rewind recovery if not in recovery
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:56 -04:00
Kent Overstreet
367cad0966 bcachefs: Rename fsck_running, recovery_running flags
Slightly more readable.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:56 -04:00
Kent Overstreet
5b1247ca5f bcachefs: debug_check_bkey_unpack
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:55 -04:00
Kent Overstreet
34aeb820f9 bcachefs: debug_check_bset_lookups
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:55 -04:00
Kent Overstreet
c4e3889440 bcachefs: debug_check_iterators no longer requires BCACHEFS_DEBUG
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:55 -04:00
Kent Overstreet
110bb6cb8b bcachefs: debug_check_btree_locking modparam
Don't put btree locking asserts behind CONFIG_BCACHEFS_DEBUG, put them
behind a module parameter.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:54 -04:00
Kent Overstreet
2842515575 bcachefs: Debug params are now static_keys
We'd like users to be able to debug without building custom kernels, so
this will help us get rid of CONFIG_BCACHEFS_DEBUG, at least for most
things.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:54 -04:00
Kent Overstreet
b51b4055c3 bcachefs: Slim down inlined part of bch2_btree_path_upgrade()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:53 -04:00
Kent Overstreet
001c1d146f bcachefs: online_fsck_mutex -> run_recovery_passes_lock
Prep work for automatically running recovery passes asynchronously.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:53 -04:00
Kent Overstreet
e21f997721 bcachefs: bch_sb_field_recovery_passes
New superblock section for statistics on recovery passes - last time
ran (successfully), last runtime.

This will be used by self healing code to determine when to kick off
potentially expensive recovery passes.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:53 -04:00
Kent Overstreet
20a4b7f3b8 bcachefs: recovery_passes_types.h -> recovery_passes_format.h
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:52 -04:00
Kent Overstreet
3b7b0c3996 bcachefs: print label correctly in sb_member_to_text()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:52 -04:00
Kent Overstreet
13ffcbae86 bcachefs: "buckets with backpointer mismatches" now allocated on demand
More self healing work: we're going to be calling
check_bucket_backpointer_mismatch() at runtime, outside of fsck.

Then when we need to we'll kick off the full
check_extents_to_backpointers recovery pass.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:52 -04:00
Kent Overstreet
7f9dada701 bcachefs: delete dead items in bch_dev
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:51 -04:00
Kent Overstreet
3ffda8c219 bcachefs: kill dead code in move_data_phys()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:50 -04:00
Kent Overstreet
82067c9169 bcachefs: buckets_in_flight on stack
copygc runs with a full stack available, there's no reason to
dynamically allocate this.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:50 -04:00
Kent Overstreet
1dfa01ef24 bcachefs: bch2_copygc_dev_wait_amount()
Factor out the per-device calculations, for better introspection.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:50 -04:00
Kent Overstreet
970dde8271 bcachefs: Add missing include
fix debug build in userspace

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:50 -04:00
Kent Overstreet
8c69e2b52e bcachefs: Knob for manual snapshot deletion
Add 'opts.snapshot_deletion_enabled', enabled by default.

This may be turned off so that the new sysfs knob,
'internal/trigger_delete_dead_snapshots', may be used instead - this
will allow snapshot deletion to be profiled more easily.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:49 -04:00
Kent Overstreet
a8539ad8fa bcachefs: bcachefs_metadata_version_fast_device_removal
Fast device removal, that uses backpointers to find pointers to the
device being removed instead of a full metadata scan.

This requires BCH_SB_MEMBER_DELETED_UUID, which is an incompatible
change - hence the version number bump. We don't fully trust
backpointers, so we don't want to reuse device indexes until after a
fsck has verified that there aren't any pointers to removed devices.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:49 -04:00
Kent Overstreet
09fa6c3039 bcachefs: bch2_dev_data_drop_by_backpointers()
Currently, device removal has to scan all metadata for pointers to the
device being removed.

Add a new method, with the same interface as bch2_dev_data_drop(), that
scans by backpointers instead - this will drastically speed up device
removal.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:49 -04:00
Kent Overstreet
b3f80d0923 bcachefs: BCH_SB_MEMBER_DELETED_UUID
Add a sentinal value for devices that have been removed, but don't want
to reuse their index until a fsck has completed.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:49 -04:00
Kent Overstreet
66e9a7f139 bcachefs: bch2_dev_remove_stripes() respects degraded flags
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:48 -04:00
Kent Overstreet
96fc7d8adb bcachefs: opts.rebalance_on_ac_only
Add an option for setting rebalance to only run when connected to mains
power.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:48 -04:00
Kent Overstreet
502222041c bcachefs: __bch2_fs_free() cleanup
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:47 -04:00
Kent Overstreet
39430cfd27 bcachefs: Improve bch2_extent_ptr_set_cached()
Preferentially keep existing cached pointers instead of adding new ones.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:47 -04:00
Kent Overstreet
fbe728f956 bcachefs: improve check_inode_hash_info_matches_root() error message
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:47 -04:00
Kent Overstreet
84bd6afee1 bcachefs: inline bch2_ob_ptr()
This was an oversight, we want bch2_alloc_sectors_append_ptrs_inlined()
fully inlined.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:46 -04:00
Kent Overstreet
e02888faab bcachefs: bch2_dev_in_target() no longer takes rcu_read_lock()
Minor optimization, the caller generally has it already.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:45 -04:00
Kent Overstreet
7d4f2687ef bcachefs: bch2_journal_write() refactoring
Make the locking easier to follow; also take io_refs earlier, in
__journal_write_alloc().

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:45 -04:00
Kent Overstreet
88f62ed60c bcachefs: delete_dead_snapshot_keys_v2()
Since extents, dirents and xattrs require an inode with the
corresponding snapshot ID to exists, we can avoid a lot of scanning by
only scanning those trees for keys to process if the correspending inode
exists.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:45 -04:00
Kent Overstreet
e9756dd29f bcachefs: bcachefs_metadata_version_snapshot_deletion_v2
We're going to be speeding up snapshot deletion, by only having it
process the extents/dirents/xattrs btrees if an inode of a given
snapshot ID was present.

This raises the possibility of 'bkey_in_missing_snapshot' errors popping
up, if we ever accidentally don't do the corresponding inode update, or
if the new algorithm has bugs.

So instead of deleting snapshot IDs, add a new deleted flag, so that
'key in missing snapshot' errors can more definitively tell what
happened and automatically repair.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:45 -04:00
Kent Overstreet
08d14d90a4 bcachefs: BCH_SNAPSHOT_DELETED -> BCH_SNAPSHOT_WILL_DELETE
We're going to be speeding up snapshot deletion, by only having it
process the extents/dirents/xattrs btrees if an inode of a given
snapshot ID was present.

This raises the possibility of 'bkey_in_missing_snapshot' errors popping
up, if we ever accidentally don't do the corresponding inode update, or
if the new algorithm has bugs.

So we'll want to be able to differentiate more definitively between
'snapshot went missing' (and perhaps needs to be reconstructed), and
'key in snapshot that was deleted'.

So instead of deleting snapshot IDs, we'll be adding a new deleted flag
and leaving them permanently.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:44 -04:00
Kent Overstreet
3f8e977265 bcachefs: Skip unrelated snapshot trees in snapshot deletion
Don't scan keys in inodes for which the snapshot tree doesn't match any
we're deleting from.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:43 -04:00
Kent Overstreet
0afdf4969e bcachefs: BCH_FSCK_ERR_snapshot_key_missing_inode_snapshot
We're going to be doing some snapshot deletion performance improvements,
and those will strictly require that if an extent/dirent/xattr is
present, an inode is present in that snapshot ID.

We already check for this, but we don't repair it on disk: this patch
adds that repair and turns it into a real fsck_err().

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:43 -04:00
Kent Overstreet
855070dc0b bcachefs: get_inodes_all_snapshots() now includes whiteouts
The next patch is going to change lookup_inode_for_snapshot to
rigorously require that a extent/dirent/xattr keys have a corresponding
inode key present - whiteouts included, so this simplifies the checks
lookup_inode_for_snapshot() will have to do.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:43 -04:00
Kent Overstreet
a9421140fc bcachefs: bch2_inode_unpack() cleanup
bi_snapshot is now handled like other fields

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:43 -04:00
Kent Overstreet
00757984d5 bcachefs: Improve bch2_request_incompat_feature() message
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:42 -04:00
Alan Huang
3c97ebea61 bcachefs: Fix inconsistent req->ec
There is req->ec = erasure_code above.

Signed-off-by: Alan Huang <mmpgouride@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:42 -04:00
Kent Overstreet
6f2bbd5747 bcachefs: kill inode_walker_entry.snapshot
redundant

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:41 -04:00
Kent Overstreet
7b8c41c178 bcachefs: Add comments for inode snapshot requirements
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:41 -04:00
Kent Overstreet
15dbd0d814 bcachefs: snapshot delete progress indicator
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:40 -04:00
Kent Overstreet
e3006cb010 bcachefs: Don't emit bch_sb_field_members_v1 if not required
In 'bcachefs_metadata_extent_flags', we stopped requireding members_v1
to be present - only that either v1 or v2 is present.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:40 -04:00
Alan Huang
9180c5f918 bcachefs: Rename x_name to x_name_and_value
The flexible array contains name and value, the x_name is misleading.

Signed-off-by: Alan Huang <mmpgouride@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:39 -04:00
Kent Overstreet
a42f709f9a bcachefs: Improve bch2_disk_groups_to_text()
Print out the actual name of each path/label, instead of just the
integer indexes.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:39 -04:00
Kent Overstreet
8a6b883e78 bcachefs: Fix setting ca->name in device add
Device add doesn't get the devide index and attach to the filesystem
until after attaching the block device, and setting the device name from
the block device name - these needs some minor tweaks.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:39 -04:00
Kent Overstreet
5ce11d9d1b bcachefs: sysfs trigger_recalc_capacity
For bug diagnosis

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:38 -04:00
Gustavo A. R. Silva
ae0386e111 bcachefs: Avoid -Wflex-array-member-not-at-end warnings
-Wflex-array-member-not-at-end was introduced in GCC-14, and we are
getting ready to enable it, globally.

Refactor a couple of structs that contain flexible arrays in the
middle by replacing them with unions.

So, with these changes, fix the following warnings:

fs/bcachefs/disk_accounting.c:429:51: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
fs/bcachefs/ec_types.h:8:41: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:38 -04:00
Kent Overstreet
98e5e36d8c bcachefs: bch2_dev_add() can run on a non-started fs
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:37 -04:00
Kent Overstreet
a349868b5e bcachefs: bch2_fs_open() now takes a darray
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:37 -04:00
Kent Overstreet
cf95296295 bcachefs: bch2_trans_update_ip()
Allow btree_insert_entry.ip_allocated to be passed in, so we get better
info on where alloc updates are coming from.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:37 -04:00
Kent Overstreet
7677859a47 bcachefs: Run most explicit recovery passes persistent
If we detect an error that requires running a recovery pass, and we're
not in recovery, we won't be able to fix it until the next mount - make
sure we're noting in the superblock that it needs to run.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:37 -04:00
Kent Overstreet
aff2b6a7fc bcachefs: provide unlocked version of run_explicit_recovery_pass_persistent
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:36 -04:00
Kent Overstreet
c21f41f690 bcachefs: bch2_dirent_to_text() shows casefolded dirents
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:36 -04:00
Kent Overstreet
cd3cdb1ef7 bcachefs: Single err message for btree node reads
Like we just did with the data read path, emit a single error message
per btree node reads, nicely formatted, with all the actions we took
grouped together.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:35 -04:00
Kent Overstreet
9c2472658b bcachefs: bch2_mark_btree_validate_failure()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:35 -04:00
Kent Overstreet
d31f155964 bcachefs: bch2_fsck_err_opt()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:34 -04:00
Kent Overstreet
600a9207c8 bcachefs: Plumb printbuf through bch2_btree_lost_data()
Part of the ongoing project to improve error messages by building them
up in printbufs and emitting them all at once, so that we can easily see
what events are related in the log.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:34 -04:00
Kent Overstreet
300904700f bcachefs: kill bch2_run_explicit_recovery_pass_persistent()
No longer has users, so we can kill it and rename
bch2_run_explicit_recovery_pass_persistent_locked().

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:33 -04:00
Kent Overstreet
3aecbb01a1 bcachefs: Remove redundant calls to btree_lost_data()
The btree node read path calls this before returning the read error.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:33 -04:00
Kent Overstreet
3be132f93c bcachefs: bch2_btree_lost_data() now handles snapshots tree
We have a consolidated places for "this btree lost data, run this
repair", so use it.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:33 -04:00
Kent Overstreet
b3bbd47f83 bcachefs: Kill redundant error message in topology repair
The btree node read path already logs btree node read errors, this isn't
needed.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:32 -04:00
Kent Overstreet
156d9e8341 bcachefs: Emit a single log message on data read error
Instead of emitting a message immediately when we get an error in the
read path, and then another at the end if we successfully retry - emit
one single log message before returning from bch2_rbio_retry().

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:32 -04:00
Kent Overstreet
353b89c6e6 bcachefs: bch2_io_failures_to_text()
Pretty printer for bch_io_failures, to be used for better read error
messages.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:31 -04:00
Kent Overstreet
dbc18c97f1 bcachefs: print_string_as_lines: avoid printing empty line
If the final line in in the message to be printed is blang, don't print
it.

This happens with indented printbufs - after a newline we emit spaces up
to the indent level.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:31 -04:00
Kent Overstreet
41e51769b8 bcachefs: Make various async objs visible in debugfs
Add async objs list for
- promote_op
- bch_read_bio
- btree_read_bio
- btree_write_bio

This gets us introspection on in-flight async ops, and because under the
hood it uses fast_lists (percpu slot buffer on top of a radix tree),
it'll be fast enough to enable in production.

This will be very helpful for debugging "something got stuck" issues,
which have been cropping up from time to time (in the CI, especially
with folio writeback).

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:30 -04:00
Kent Overstreet
0499a82b18 bcachefs: Async object debugging
Debugging infrastructure for async objs: this lets us easily create
fast_lists for various object types so they'll be visible in debugfs.

Add new object types to the BCH_ASYNC_OBJS_TYPES() enum, and drop a
pretty-printer wrapper in async_objs.c.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:29 -04:00
Kent Overstreet
d49bafdc5d bcachefs: fast_list
A fast "list" data structure, which is actually a radix tree, with an
IDA for slot allocation and a percpu buffer on top of that.

Items cannot be added or moved to the head or tail, only added at some
(arbitrary) position and removed. The advantage is that adding, removing
and iteration is generally lockless, only hitting the lock in ida when
the percpu buffer is full or empty.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:29 -04:00
Kent Overstreet
989b4c375a bcachefs: bch2_read_bio_to_text
Pretty printer for struct bch_read_bio.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:29 -04:00
Kent Overstreet
5f0de475f9 bcachefs: bch2_bio_to_text()
Pretty printer for struct bio, to be used for async object debugging.

This is pretty minimal, we'll add more to it as we discover what we
need.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:28 -04:00
Kent Overstreet
cca2c0d224 bcachefs: bch_dev.io_ref -> enumerated_ref
Convert device IO refs to enumerated_refs, for easier debugging of
refcount issues.

Simple conversion: enumerate all users and convert to the new helpers.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:28 -04:00
Kent Overstreet
c9b1d94a21 bcachefs: bch_fs.writes -> enumerated_refs
Drop the single-purpose write ref code in bcachefs.h, and convert to
enumarated refs.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:27 -04:00
Kent Overstreet
f5241e4127 bcachefs: enumerated_ref.c
Factor out the debug code for rw filesystem refs into a small library.

In release mode an enumerated ref is a normal percpu refcount, but in
debug mode all enumerated users of the ref get their own atomic_long_t
ref - making it much easier to chase down refcount usage bugs for when a
refcount has many users.

For debugging, we have enumerated_ref_to_text(), which prints the
current value of each different user.

Additionally, in debug mode enumerated_ref_stop() has a 10 second
timeout, after which it will dump outstanding refcounts.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:27 -04:00
Kent Overstreet
6d67de1079 bcachefs: for_each_rw_member_rcu()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:27 -04:00
Kent Overstreet
e14e06e91d bcachefs: __bch2_fs_read_write() no longer depends on io_ref
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:26 -04:00
Kent Overstreet
9fa4a8a3bd bcachefs: for_each_online_member_rcu()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:26 -04:00
Kent Overstreet
2483dd1243 bcachefs: recalc_capacity() no longer depends on io_ref
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:25 -04:00
Kent Overstreet
c53be0ffaa bcachefs: bch2_target_to_text() no longer depends on io_ref
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:25 -04:00
Kent Overstreet
834f9475aa bcachefs: bch2_check_rebalance_work()
Add a pass for checking the rebalance_work btree.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:24 -04:00
Alan Huang
09279bba72 bcachefs: Kill dead code
Signed-off-by: Alan Huang <mmpgouride@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:24 -04:00
Kent Overstreet
62095464e9 bcachefs: Fix struct with flex member ABI warning
This pops up when buliding in userspace.

The structs aren't actually variable length, but no way to tell the
compiler that...

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:24 -04:00
Kent Overstreet
fe27298b92 bcachefs: bch2_move_data_btree() can now walk roots
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:22 -04:00
Kent Overstreet
3484840ece bcachefs: bch2_move_data_btree() can move btree nodes
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:22 -04:00
Kent Overstreet
7a274285d3 bcachefs: plumb btree_id through move_pred_fd
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:22 -04:00
Kent Overstreet
f3c8eaf7a1 bcachefs: Plumb target parameter through btree_node_rewrite_pos()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:21 -04:00
Kent Overstreet
ecedc87cfa bcachefs: export bch2_move_data_phys()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:21 -04:00
Kent Overstreet
0ca375b177 bcachefs: BCH_MEMBER_RESIZE_ON_MOUNT
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:21 -04:00
Kent Overstreet
530112d88e bcachefs: BCH_FEATURE_small_image
We can't go RW if it's an image file that hasn't been resized.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:20 -04:00
Kent Overstreet
203852d9db bcachefs: BCH_FEATURE_no_alloc_info
If a filesystem is going to only be used read-only, and will be a
deployable image, we can strip out alloc info for a substantial
reduction in metadata size - around half, due to backpointers.

Alloc info will be regenerated on first read-write mount.

Remounting RW is disallowed for now, since we don't yet have
check_allocations running in RW mode.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:20 -04:00
Kent Overstreet
576493133f bcachefs: Print features on startup with -o verbose
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:20 -04:00
Kent Overstreet
0dc73809e9 bcachefs: Shrink superblock downgrade table
Don't generate entries for versions that won't be able to mount.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:20 -04:00
Kent Overstreet
1c8dfd7ba5 bcachefs: sb_validate() no longer requires members_v1
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:19 -04:00
Kent Overstreet
d12bd41018 bcachefs: Add a recovery pass for making sure root inode is readable
If the root inode/subvolume is unreadable we can repair automatically -
but only if we're still in recovery, so that we can rewind to the
appropriate recovery pass.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:19 -04:00
Kent Overstreet
bdad8962c9 bcachefs: Flag for repair on missing subvolume
Instead of going emegency read only with a bch2_fs_inconsistent() call,
log the error and recovery pass appropriately.

If we're still in recovery it'll be repaired immediately, otherwise
it'll be repaired on the next mount.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:18 -04:00
Kent Overstreet
ebf561b208 bcachefs: print_str_as_lines() -> print_str()
bch2_print_string_as_lines() is a low level helper that allows messages
longer than 1k to be printed without truncation.

But we should always be printing with the helpers that take a filesystem
object, if we're in fsck they direct output to the userspace process
controlling fsck instead of the dmesg log.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:18 -04:00
Kent Overstreet
040c762152 bcachefs: bch2_dev_missing_bkey()
Part of the ongoing project to kill off bch2_(fs|trans)_inconsistent
calls - they generally need to be replaced with either

- a fsck_err() call that can repair the error, or

- logging an error of the appropriate type in the superblock, and
  flagging the appropriate recovery pass to repair the error

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:17 -04:00
Kent Overstreet
2085325171 bcachefs: Simplify bch2_count_fsck_err()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:17 -04:00
Kent Overstreet
bb36a12921 bcachefs: bch2_run_explicit_recovery_pass_printbuf()
We prefer helpers that emit log messages to printbufs rather than
printing them directly; that way, we can ensure that different log
messages from the same event are grouped together and formatted
appropriately in the dmesg log.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:16 -04:00
Kent Overstreet
5022d0e183 bcachefs: Incompatible features may now be enabled at runtime
version_upgrade is now a runtime option.

In the future we'll want to add compatible upgrades at runtime, and call
the full check_version_upgrade() when the option changes, but we don't
have compatible optional upgrades just yet.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:16 -04:00
Kent Overstreet
c79eb06da4 bcachefs: Clean up option pre/post hooks, small fixes
The helpers are now:
- bch2_opt_hook_pre_set()
- bch2_opts_hooks_pre_set()
- bch2_opt_hook_post_set

Fix a bug where the filesystem discard option would incorrectly be
changed when setting the device option, and don't trigger rebalance
scans unnecessarily (when options aren't changing).

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:16 -04:00
Kent Overstreet
83ecd1b122 bcachefs: Use drop_locks_do() in bch2_inode_hash_find()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:16 -04:00
Kent Overstreet
c02e5b5728 bcachefs: Single device mode
Single device filesystems are now identified by the block device name,
not the UUID - and single device filesystems with the same UUID can be
mounted simultaneously, without any special options.

This allocates a new bit in the superblock, BCH_SB_MULTI_DEVICE, which
indicates whether a filesystem has ever been multi device.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:15 -04:00
Kent Overstreet
58c36e6710 bcachefs: Initialize c->name earlier on single dev filesystems
On single device filesystems, c->name contains the block device name,
not the UUID.

Initialize this earlier, so that single device mode can use it for
initializing sysfs/debugfs.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 20:14:15 -04:00