Kent Overstreet
40574946b8
bcachefs: Better bucket alloc tracepoints
...
Tracepoints are garbage, and perf trace even cuts off some of our
fields.
Much nicer to just trace a string, and then we can build nicely
formatted output with printbufs.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-05-08 17:29:24 -04:00
Kent Overstreet
6202569777
bcachefs: Move nocow unlock to bch2_write_endio()
...
This fixes a lifetime issue; bch2_nocow_write_unlock() uses
PTR_BUCKET_POS(), which needs the device - but we drop our ref to the
device in bch2_write_endio().
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-05-08 17:29:24 -04:00
Kent Overstreet
b6d29b5869
bcachefs: kill bch2_dev_bkey_exists() in journal_ptrs_to_text()
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-05-08 17:29:24 -04:00
Kent Overstreet
f4301b635a
bcachefs: kill bch2_dev_bkey_exists() in discard_one_bucket_fast()
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-05-08 17:29:24 -04:00
Kent Overstreet
bc3204c80a
bcachefs: kill bch2_dev_bkey_exists() in check_alloc_info()
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-05-08 17:29:24 -04:00
Kent Overstreet
d8585a79be
bcachefs: bch2_dev_have_ref()
...
bch2_dev_bkey_exists() is going away; bch2_dev_have_ref() documents that
we're looking up a device without checking if it's present because we
have a reference to it already.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-05-08 17:29:24 -04:00
Kent Overstreet
222eacabc1
bcachefs: kill bch2_dev_bkey_exists() in data_update_init()
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-05-08 17:29:23 -04:00
Kent Overstreet
a9422fd404
bcachefs: kill bch2_dev_bkey_exists() in bkey_pick_read_device()
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-05-08 17:29:23 -04:00
Kent Overstreet
db39a35dde
bcachefs: pass bch_dev to read_from_stale_dirty_pointer()
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-05-08 17:29:23 -04:00
Kent Overstreet
78e9b548f3
bcachefs: bch2_dev_bucket_exists() uses bch2_dev_rcu()
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-05-08 17:29:23 -04:00
Kent Overstreet
ad897d241b
bcachefs: kill bch2_dev_bkey_exists() in btree_gc.c
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-05-08 17:29:23 -04:00
Kent Overstreet
9cadb4ea56
bcachefs: bch2_extent_normalize() -> bch2_dev_rcu()
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-05-08 17:29:23 -04:00
Kent Overstreet
8e3cc2003f
bcachefs: bch2_bkey_has_target() -> bch2_dev_rcu()
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-05-08 17:29:23 -04:00
Kent Overstreet
8feecbed24
bcachefs: extent_ptr_invalid() -> bch2_dev_rcu()
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-05-08 17:29:23 -04:00
Kent Overstreet
3858aa4268
bcachefs: ptr_stale() -> dev_ptr_stale()
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-05-08 17:29:23 -04:00
Kent Overstreet
302c980a81
bcachefs: extent_ptr_durability() -> bch2_dev_rcu()
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-05-08 17:29:23 -04:00
Kent Overstreet
3793b3f91f
bcachefs: bch2_extent_merge() -> bch2_dev_rcu()
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-05-08 17:29:23 -04:00
Kent Overstreet
c387d84413
bcachefs: ec_validate_checksums() -> bch2_dev_tryget()
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-05-08 17:29:23 -04:00
Kent Overstreet
8783856ab1
bcachefs: ob_dev()
...
Wrapper around bch2_dev_have_ref() for open_buckets; we do guarantee
that the device an open_bucket points to exists.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-05-08 17:29:23 -04:00
Kent Overstreet
dbd0408087
bcachefs: move replica_set from bch_dev to bch_fs
...
This is needed for the next patch - the write submit path has to be able
to allocate a replica bio even when we weren't able to get a ref on the
device.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-05-08 17:29:23 -04:00
Kent Overstreet
633cf06944
bcachefs: Kill bch2_dev_bkey_exists() in backpointer code
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-05-08 17:29:23 -04:00
Kent Overstreet
1f2f92ec3f
bcachefs: PTR_BUCKET_POS() now takes bch_dev
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-05-08 17:29:23 -04:00
Kent Overstreet
fa6cce09f0
bcachefs: bch2_dev_iterate()
...
New helper for getting refs to devices as we iterate.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-05-08 17:29:23 -04:00
Kent Overstreet
cb4d340a10
bcachefs: bch2_evacuate_bucket() -> bch2_dev_tryget()
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-05-08 17:29:23 -04:00
Kent Overstreet
07d7c4da7b
bcachefs: bch2_bucket_ref_update() now takes bch_dev
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-05-08 17:29:23 -04:00
Kent Overstreet
a7f1c26f59
bcachefs: bch2_trigger_alloc() -> bch2_dev_tryget()
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-05-08 17:29:23 -04:00
Kent Overstreet
9b3059a1b3
bcachefs: bch2_check_alloc_key() -> bch2_dev_tryget_noerror()
...
More elimination of bch2_dev_bkey_exists() usage.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-05-08 17:29:22 -04:00
Kent Overstreet
4cd91e2f87
bcachefs: Convert to bch2_dev_tryget_noerror()
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-05-08 17:29:22 -04:00
Kent Overstreet
b07eb8252f
bcachefs: bch2_dev_tryget()
...
Most uses of bch2_dev_bkey_exists() are going away, where we assume that
because a key references a device the device most exist - instead, we'll
be explicitly checking if the device exists and getting a reference to
it.
This adds the new helpers.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-05-08 17:29:22 -04:00
Kent Overstreet
6349b07c25
bcachefs: bch2_have_enough_devs() checks for nonexistent device
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-05-08 17:29:22 -04:00
Kent Overstreet
adf81796ee
bcachefs: journal_replay_entry_early() checks for nonexistent device
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-05-08 17:29:22 -04:00
Kent Overstreet
13a16dabde
bcachefs: bch2_dev_btree_bitmap_marked() -> bch2_dev_rcu()
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-05-08 17:29:22 -04:00
Kent Overstreet
267039d0fc
bcachefs: Pass device to bch2_bucket_do_index()
...
Eliminating bch2_dev_bkey_exists() uses and replacing them with proper
checks; this one was unnecessary since the caller already has it.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-05-08 17:29:22 -04:00
Kent Overstreet
f5faf43f85
bcachefs: Pass device to bch2_alloc_write_key()
...
More elimating bch2_dev_bkey_exists()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-05-08 17:29:22 -04:00
Kent Overstreet
23f308ae19
bcachefs: bch2_dev_safe() -> bch2_dev_rcu()
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-05-08 17:29:22 -04:00
Kent Overstreet
552aa54865
bcachefs: Debug asserts for ca->ref
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-05-08 17:29:22 -04:00
Kent Overstreet
f295298b8c
bcachefs: New helpers for device refcounts
...
This will be used in the next patch for adding some new debug mode
asserts.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-05-08 17:29:22 -04:00
Kent Overstreet
e98786ea85
bcachefs: bch2_print_allocator_stuck()
...
If we block on the allocator for more than 10 seconds, print out some
useful debugging info.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-05-08 17:29:22 -04:00
Kent Overstreet
9a768ab75b
bcachefs: bch2_bkey_drop_ptrs() declares loop iter
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-05-08 17:29:22 -04:00
Kent Overstreet
b895c70326
bcachefs: x-macroize journal flags enums
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-05-08 17:29:22 -04:00
Kent Overstreet
3a718c0647
bcachefs: On device add, prefer unused slots
...
We can't strictly guarantee that no pointers refer to nonexistent
devices - we attempt to, but we need to be safe when the filesystem is
corrupt.
Therefore, change device_add to try to pick a slot that's never been
used, or the slot that's been unused the longest.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-05-08 17:29:22 -04:00
Kent Overstreet
ffcbec6076
bcachefs: Kill opts.buckets_nouse
...
Now explicitly allocate and free the buckets_nouse bitmap - this is
going to be used for online fsck.
To go RW when we haven't check allocations, we'll do a much slimmed down
version that just initializes the buckets_nouse bitmaps.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-05-08 17:29:22 -04:00
Kent Overstreet
abe2f470bc
bcachefs: simplify bch2_trans_start_alloc_update()
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-05-08 17:29:22 -04:00
Kent Overstreet
0acf2169a5
bcachefs: __mark_stripe_bucket() now takes bch_alloc_v4
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-05-08 17:29:21 -04:00
Kent Overstreet
be11ae16c4
bcachefs: __mark_pointer now takes bch_alloc_v4
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-05-08 17:29:21 -04:00
Kent Overstreet
c02eb9e891
bcachefs: kill bch2_dev_usage_update_m()
...
by using bucket_m_to_alloc() more, we can get some nice code cleanup.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-05-08 17:29:21 -04:00
Kent Overstreet
fa9bb741fe
bcachefs: alloc_data_type_set()
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-05-08 17:29:21 -04:00
Kent Overstreet
2685c67d12
bcachefs: dirty_sectors -> replicas_sectors
...
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-05-08 17:29:21 -04:00
Kent Overstreet
d3c44cfd5e
bcachefs: delete old gen check bch2_alloc_write_key()
...
this was from metadata only gc - we don't need it anymore
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-05-08 17:29:21 -04:00
Youling Tang
75a53a0a23
bcachefs: Correct the FS_IOC_GETFLAGS to FS_IOC32_GETFLAGS in bch2_compat_fs_ioctl()
...
It should be FS_IOC32_GETFLAGS instead of FS_IOC_GETFLAGS in
compat ioctl.
Signed-off-by: Youling Tang <tangyouling@kylinos.cn >
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev >
2024-05-08 17:29:21 -04:00