History log of /linux-master/fs/bcachefs/util.h
Revision Date Author Comments
# 6088234c 05-Apr-2024 Kent Overstreet <kent.overstreet@linux.dev>

bcachefs: JOURNAL_SPACE_LOW

"bcachefs; Fix deadlock in bch2_btree_update_start()" was a significant
performance regression (nearly 50%) on multithreaded random writes with
fio.

The reason is that the journal watermark checks multiple things,
including the state of the btree write buffer, and on multithreaded
update heavy workloads we're bottleneked on write buffer flushing - we
don't want kicknig off btree updates to depend on the state of the write
buffer.

This isn't strictly correct; the interior btree update path does do
write buffer updates, but it's a tiny fraction of total accounting
updates and we're more concerned with space in the journal itself.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>


# a6c4162d 05-Apr-2024 Dan Carpenter <dan.carpenter@linaro.org>

bcachefs: fix ! vs ~ typo in __clear_bit_le64()

The ! was obviously intended to be ~. As it is, this function does
the equivalent to: "addr[bit / 64] = 0;".

Fixes: 27fcec6c27ca ("bcachefs: Clear recovery_passes_required as they complete without errors")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>


# ca1e02f7 22-Mar-2024 Kent Overstreet <kent.overstreet@linux.dev>

bcachefs: Etyzinger cleanups

Pull out eytzinger.c and kill eytzinger_cmp_fn. We now provide
eytzinger0_sort and eytzinger0_sort_r, which use the standard cmp_func_t
and cmp_r_func_t callbacks.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>


# 27fcec6c 30-Mar-2024 Kent Overstreet <kent.overstreet@linux.dev>

bcachefs: Clear recovery_passes_required as they complete without errors

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>


# a5860368 16-Mar-2024 Kent Overstreet <kent.overstreet@linux.dev>

bcachefs: Don't corrupt journal keys gap buffer when dropping alloc info

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>


# f1ca1abf 13-Mar-2024 Kent Overstreet <kent.overstreet@linux.dev>

bcachefs: pull out time_stats.[ch]

prep work for lifting out of fs/bcachefs/

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>


# cdce1094 11-Mar-2024 Kent Overstreet <kent.overstreet@linux.dev>

bcachefs: reconstruct_alloc cleanup

Now that we've got the errors_silent mechanism, we don't have to check
if the reconstruct_alloc option is set all over the place.

Also - users no longer have to explicitly select fsck and fix_errors.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>


# d6454799 02-Mar-2024 Kent Overstreet <kent.overstreet@linux.dev>

bcachefs: copy_(to|from)_user_errcode()

we've got some helpers that return errors sanely, move them to a more
common location for use in fs-ioctl.c

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>


# 69426613 23-Feb-2024 Kent Overstreet <kent.overstreet@linux.dev>

bcachefs: improve move_gap()

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>


# cb6fc943 01-Feb-2024 Kent Overstreet <kent.overstreet@linux.dev>

bcachefs: kill kvpmalloc()

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>


# 612e1110 21-Jan-2024 Kent Overstreet <kent.overstreet@linux.dev>

bcachefs: Add gfp flags param to bch2_prt_task_backtrace()

Fixes: e6a2566f7a00 ("bcachefs: Better journal tracepoints")
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Reported-by: smatch


# 189c176c 15-Jan-2024 Kent Overstreet <kent.overstreet@linux.dev>

bcachefs: Improve move_extent tracepoint

Also print out the data_opts, so that we can see what specifically is
being done to an extent.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>


# 1f5af5fc 05-Jan-2024 Kent Overstreet <kent.overstreet@linux.dev>

bcachefs: %pg is banished

not portable to userspace

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>


# c13fbb7d 04-Jan-2024 Kent Overstreet <kent.overstreet@linux.dev>

bcachefs: Improve would_deadlock trace event

We now include backtraces for every thread involved in the cycle.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>


# 806ebf2a 22-Dec-2023 Kent Overstreet <kent.overstreet@linux.dev>

bcachefs: Convert split_devs() to darray

Bit of cleanup & modernization: also moving this code to util.c, it'll
be used by userspace as well.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>


# 038fecc0 16-Dec-2023 Kent Overstreet <kent.overstreet@linux.dev>

bcachefs: qstr_eq()

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>


# 066a2646 09-Nov-2023 Kent Overstreet <kent.overstreet@linux.dev>

bcachefs: track_event_change()

This introduces a new helper for connecting time_stats to state changes,
i.e. when taking journal reservations is blocked for some reason.

We use this to track separately the different reasons the journal might
be blocked - i.e. space in the journal full, or the journal pin fifo
full.

Also do some cleanup and improvements on the time stats code.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>


# 560661d4 30-Dec-2023 Kent Overstreet <kent.overstreet@linux.dev>

bcachefs: prt_bitflags_vector()

similar to prt_bitflags(), but for ulong arrays

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>


# 59154f2c 31-Oct-2023 Kent Overstreet <kent.overstreet@linux.dev>

bcachefs: bch2_prt_datetime()

Improved, better named version of pr_time().

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>


# 96dea3d5 12-Sep-2023 Kent Overstreet <kent.overstreet@linux.dev>

bcachefs: Fix W=12 build errors

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>


# 8e877caa 16-Aug-2023 Kent Overstreet <kent.overstreet@linux.dev>

bcachefs: Split out snapshot.c

subvolume.c has gotten a bit large, this splits out a separate file just
for managing snapshot trees - BTREE_ID_snapshots.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>


# 1e81f89b 06-Aug-2023 Kent Overstreet <kent.overstreet@linux.dev>

bcachefs: Fix assorted checkpatch nits

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>


# a0668d77 26-Apr-2023 Kent Overstreet <kent.overstreet@linux.dev>

bcachefs: Fix a userspace build error

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>


# 8fcdf814 27-Feb-2023 Kent Overstreet <kent.overstreet@linux.dev>

bcachefs: Improved copygc pipelining

This improves copygc pipelining across multiple buckets: we now track
each in flight bucket we're evacuating, with separate moving_contexts.

This means that whereas previously we had to wait for outstanding moves
to complete to ensure we didn't try to evacuate the same bucket twice,
we can now just check buckets we want to evacuate against the pending
list.

This also mean we can run the verify_bucket_evacuated() check without
killing pipelining - meaning it can now always be enabled, not just on
debug builds.

This is going to be important for the upcoming erasure coding work,
where moving IOs that are being erasure coded will now skip the initial
replication step; instead the IOs will wait on the stripe to complete.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>


# b1cfe5ed 01-Mar-2023 Kent Overstreet <kent.overstreet@linux.dev>

bcachefs: Improve dev_alloc_debug_to_text()

Now we also print the number of buckets reserved for each watermark.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>


# 3ea4219d 12-Feb-2023 Kent Overstreet <kent.overstreet@linux.dev>

bcachefs: New backtrace utility code

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>


# 961cbdef 13-Nov-2022 Kent Overstreet <kent.overstreet@linux.dev>

bcachefs: Delete atomic_inc_bug()

These were wrappers around atomic operations that verified that the
counter wasn't negative, but they're dead code - delete.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>


# bf8f8b20 11-Aug-2022 Daniel Hill <daniel@gluo.nz>

bcachefs: time stats now uses the mean_and_variance module.

Signed-off-by: Daniel Hill <daniel@gluo.nz>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>


# 1148a97f 09-Oct-2022 Kent Overstreet <kent.overstreet@linux.dev>

bcachefs: Print cycle on unrecoverable deadlock

Some lock operations can't fail; a cycle of nofail locks is impossible
to recover from. So we want to get rid of these nofail locking
operations, but as this is tricky it'll be done incrementally.

If such a cycle happens, this patch prints out which codepaths are
involved so we know what to work on next.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>


# a8f35428 25-Sep-2022 Kent Overstreet <kent.overstreet@linux.dev>

bcachefs: bch2_print_string_as_lines()

This adds a helper for printing a large buffer one line at a time, to
avoid the 1k printk limit.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>


# d0b50524 14-Aug-2022 Kent Overstreet <kent.overstreet@gmail.com>

bcachefs: bch2_bkey_packed_to_binary_text()

For debugging the eytzinger search tree code, and low level bkey packing
code, it can be helpful to see things in binary: this patch improves our
helpers for doing so.

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>


# 401ec4db 03-Feb-2023 Kent Overstreet <kent.overstreet@linux.dev>

bcachefs: Printbuf rework

This converts bcachefs to the modern printbuf interface/implementation,
synced with the version to be submitted upstream.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>


# d1d7737f 03-Apr-2022 Kent Overstreet <kent.overstreet@gmail.com>

bcachefs: Gap buffer for journal keys

Btree updates before we go RW work by inserting into the array of keys
that journal replay will insert - but inserting into a flat array is
O(n), meaning if btree_gc needs to update many alloc keys, we're O(n^2).

Fortunately, the updates btree_gc does happens in sequential order,
which means a gap buffer works nicely here - this patch implements a gap
buffer for journal keys.

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>


# c32fc674 02-Apr-2022 Kent Overstreet <kent.overstreet@gmail.com>

bcachefs: Fix pr_buf() calls

In a few places we were passing a variable to pr_buf() for the format
string - oops.

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>


# b17d3cec 31-Oct-2022 Kent Overstreet <kent.overstreet@linux.dev>

bcachefs: Run btree updates after write out of write_point

In the write path, after the write to the block device(s) complete we
have to punt to process context to do the btree update.

Instead of using the work item embedded in op->cl, this patch switches
to a per write-point work item. This helps with two different issues:

- lock contention: btree updates to the same writepoint will (usually)
be updating the same alloc keys
- context switch overhead: when we're bottlenecked on btree updates,
having a thread (running out of a work item) checking the write point
for completed ops is cheaper than queueing up a new work item and
waking up a kworker.

In an arbitrary benchmark, 4k random writes with fio running inside a
VM, this patch resulted in a 10% improvement in total iops.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>


# 30690c44 27-Mar-2022 Kent Overstreet <kent.overstreet@gmail.com>

bcachefs: Heap code fix

When deleting an entry from a heap that was at entry h->used - 1, we'd
end up calling heap_sift() on an entry outside the heap - the entry we
just removed - which would end up re-adding it to the heap and deleting
something we didn't want to delete. Oops...

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>


# 3756111d 21-Mar-2022 Kent Overstreet <kent.overstreet@gmail.com>

bcachefs: Add printf format attribute to bch2_pr_buf()

This tells the compiler to check printf format strings, and catches a
few bugs.

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>


# 590b91cf 07-Mar-2022 Kent Overstreet <kent.overstreet@gmail.com>

bcachefs: Revert UUID format-specifier change

"bcachefs: Log & error message improvements" accidentally changed the
format specifier we use for converting UUIDs to strings, which broke
mounting of encrypted filesystems - this patch reverts that change.

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>


# 07b8121f 06-Mar-2022 Kent Overstreet <kent.overstreet@gmail.com>

bcachefs: Fix pr_tab_rjust()

pr_tab_rjust() was broken and leaving a null somewhere in the output
string - this patch fixes it and simplifies it a bit.

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>


# fa8e94fa 25-Feb-2022 Kent Overstreet <kent.overstreet@gmail.com>

bcachefs: Heap allocate printbufs

This patch changes printbufs dynamically allocate and reallocate a
buffer as needed. Stack usage has become a bit of a problem, and a major
cause of that has been static size string buffers on the stack.

The most involved part of this refactoring is that printbufs must now be
exited with printbuf_exit().

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>


# 2be7b16e 25-Feb-2022 Kent Overstreet <kent.overstreet@gmail.com>

bcachefs: Convert bch2_pd_controller_print_debug() to a printbuf

Fewer random on-stack char arrays.

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>


# 702a4ef0 22-Feb-2022 Kent Overstreet <kent.overstreet@gmail.com>

bcachefs: Add tabstops to printbufs

Now, when outputting to printbufs, we can set tabstops and left or right
justify text to them - this is to be used by the userspace 'bcachefs fs
usage' command.

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>


# 12bf93a4 20-Feb-2022 Kent Overstreet <kent.overstreet@gmail.com>

bcachefs: Add .to_text() methods for all superblock sections

This patch improves the superblock .to_text() methods and adds methods
for all types that were missing them. It also improves printbufs by
allowing them to specfiy what units we want to be printing in, and adds
new wrapper methods for unifying our kernel and userspace environments.

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>


# d4b69152 20-Feb-2022 Kent Overstreet <kent.overstreet@gmail.com>

bcachefs: Kill bch_scnmemcpy()

bch_scnmemcpy was for printing length-limited strings that might not
have a terminating null - turns out sprintf & pr_buf can do this with
%.*s.

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>


# e7bc7cdf 16-Feb-2022 Kent Overstreet <kent.overstreet@gmail.com>

bcachefs: Improve journal_entry_btree_keys_to_text()

This improves the formatting of journal_entry_btree_keys_to_text() by
putting each key on its own line.

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>


# 03ea3962 04-Jan-2022 Kent Overstreet <kent.overstreet@gmail.com>

bcachefs: Log & error message improvements

- Add a shim uuid_unparse_lower() in the kernel, since %pU doesn't work
in userspace

- We don't need to print the bcachefs: or the filesystem name prefix in
userspace

- Improve a few error messages

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>


# 7279c1a2 23-Nov-2021 Kent Overstreet <kent.overstreet@gmail.com>

bcachefs: Kill PAGE_SECTOR_SHIFT

Replace it with the new, standard PAGE_SECTORS_SHIFT

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>


# 0423fb71 12-Jun-2021 Kent Overstreet <kent.overstreet@gmail.com>

bcachefs: Keep a sorted list of btree iterators

This will be used to make other operations on btree iterators within a
transaction more efficient, and enable some other improvements to how we
manage btree iterators.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>


# 109a4277 10-Jun-2021 Kent Overstreet <kent.overstreet@gmail.com>

bcachefs: Don't disable preemption unnecessarily

Small improvements to some percpu utility code.

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>


# ded54580 16-Dec-2020 Kent Overstreet <kent.overstreet@gmail.com>

bcachefs: Check for duplicate device ptrs in bch2_bkey_ptrs_invalid()

This is something we clearly should be checking for, but weren't -
oops.

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>


# 7807e143 25-Jul-2020 Kent Overstreet <kent.overstreet@gmail.com>

bcachefs: Convert various code to printbuf

printbufs know how big the buffer is that was allocated, so we can get
rid of the random PAGE_SIZEs all over the place.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>


# 03c8c747 13-Nov-2019 Kent Overstreet <kent.overstreet@gmail.com>

bcachefs: Make memcpy_to_bio() param const

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>


# e3728b500 11-Oct-2019 Justin Husted <sigstop@gmail.com>

bcachefs: Initialize padding space after alloc bkey

Packed bkeys are padded up to 64 bit alignment, but the alloc bkey type
was not clearing the pad bytes after the last data byte. This left the
key possibly containing some random garbage at the end.

This problem was found using valgrind.

This patch also changes a path with the inode bkey to clear in the same
way.

Signed-off-by: Justin Husted <sigstop@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>


# b8098f36 22-Oct-2019 Kent Overstreet <kent.overstreet@gmail.com>

bcachefs: Don't use rep movsq for small memcopies

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>


# 0fd7263e 04-Jul-2019 Kent Overstreet <kent.overstreet@gmail.com>

bcachefs: kill bio_for_each_contig_segment()

With multipage bvecs it's not needed anymore

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>


# 885678f6 03-Jul-2019 Kent Overstreet <kent.overstreet@gmail.com>

bcachefs: Kill direct access to bi_io_vec

Switch to always using bio_add_page(), which merges contiguous pages now
that we have multipage bvecs.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>


# 5e82a9a1 10-Feb-2019 Kent Overstreet <kent.overstreet@gmail.com>

bcachefs: Write out fs usage consistently

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>


# 3ea2b1e1 12-Apr-2019 Kent Overstreet <kent.overstreet@gmail.com>

bcachefs: cmp_int()

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>


# 4c97e04a 06-Feb-2019 Kent Overstreet <kent.overstreet@gmail.com>

bcachefs: percpu utility code

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>


# 7ef2a73a 21-Jan-2019 Kent Overstreet <kent.overstreet@gmail.com>

bcachefs: Fix check for if extent update is allocating

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>


# 000de459 13-Jan-2019 Kent Overstreet <kent.overstreet@gmail.com>

bcachefs: fixes for getting stuck flushing journal pins

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>


# 23f80d2b 17-Dec-2018 Kent Overstreet <kent.overstreet@gmail.com>

bcachefs: Factor out acc_u64s()

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>


# 0b847a19 18-Dec-2018 Kent Overstreet <kent.overstreet@gmail.com>

bcachefs: Lots of option handling improvements

Add helptext to option definitions - so we can unify the option
handling with the format command

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>


# 319f9ac3 08-Nov-2018 Kent Overstreet <kent.overstreet@gmail.com>

bcachefs: revamp to_text methods

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>


# 75369d4e 08-Nov-2018 Kent Overstreet <kent.overstreet@gmail.com>

bcachefs: delete some dead code

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>


# 198d6700 21-Oct-2018 Kent Overstreet <kent.overstreet@gmail.com>

bcachefs: add functionality for heaps to update backpointers

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>


# 71c9e0ba 27-Sep-2018 Kent Overstreet <kent.overstreet@gmail.com>

bcachefs: bch2_extent_ptr_decoded_append()

This new helper for the move path avoids creating a new CRC entry when
we already have one that matches the pointer being added.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>


# c2fcff59 25-Sep-2018 Kent Overstreet <kent.overstreet@gmail.com>

bcachefs: Fix suspend when moving data faster than ratelimit

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>


# 1c6fdbd8 17-Mar-2017 Kent Overstreet <kent.overstreet@gmail.com>

bcachefs: Initial commit

Initially forked from drivers/md/bcache, bcachefs is a new copy-on-write
filesystem with every feature you could possibly want.

Website: https://bcachefs.org

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>