summaryrefslogtreecommitdiff
path: root/fs/bcachefs
AgeCommit message (Collapse)AuthorFilesLines
2024-03-14bcachefs: Add journal.blocked to journal_debug_to_text()Kent Overstreet1-0/+1
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-03-14bcachefs: Fix journal_buf bitfield accessesKent Overstreet2-6/+13
All jounal_buf bitfield updates must happen under the journal lock - perhaps we should just switch these to atomic bit flags. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-03-14bcachefs: Split out discard fastpathKent Overstreet3-7/+146
Buckets usually can't be discarded until the transaction that made them empty has been committed in the journal. Tracing has indicated that we're queuing the discard worker excessively, only for it to skip over many buckets that are still waiting on a journal commit, discarding only one or two buckets per iteration. We want to switch to only queuing the discard worker after a journal flush write, but there's an important optimization we need to preserve: if a bucket becomes empty and it was never committed in the journal while it was in use, we want to discard it and reuse it right away - since overwriting it before the previous writes are flushed from the device cache eans those writes only cost bus bandwidth. So, this patch implements a fast path for buckets that can be discarded right away. We need new locking between the two discard workers; the new list of buckets being discarded provides that locking. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-03-14bcachefs: improve bch2_journal_buf_to_text()Kent Overstreet1-9/+24
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-03-14bcachefs: Drop redundant btree_path_downgrade()sKent Overstreet1-1/+2
If a path doesn't have any active references, we shouldn't downgrade it; it'll either be reused, possibly with intent refs again, or dropped at bch2_trans_begin() time. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-03-14bcachefs: rebalance_status now shows correct unitsDaniel Hill1-2/+2
Signed-off-by: Daniel Hill <daniel@gluo.nz> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-03-14bcachefs: more informative write path error messageKent Overstreet1-5/+11
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-03-14bcachefs: check_path() now only needs to walk up to subvolume rootKent Overstreet1-3/+3
Now that checking subvolume structure is a separate pass, the main check_directory_connectivity() pass only needs to walk up to a given inode's subvolume root. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-03-14bcachefs: bch2_check_subvolume_structure()Kent Overstreet3-27/+135
Now that we've got bch_subvolume.fs_path_parent, it's easy to write subvolume Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-03-14bcachefs: omit alignment attribute on big endian struct bkeyThomas Bertschinger1-2/+35
This is needed for building Rust bindings on big endian architectures like s390x. Currently this is only done in userspace, but it might happen in-kernel in the future. When creating a Rust binding for struct bkey, the "packed" attribute is needed to get a type with the correct member offsets in the big endian case. However, rustc does not allow types to have both a "packed" and "align" attribute. Thus, in order to get a Rust type compatible with the C type, we must omit the "aligned" attribute in C. This does not affect the struct's size or member offsets, only its toplevel alignment, which should be an acceptable impact. The little endian version can have the "align" attribute because the "packed" attr is redundant, and rust-bindgen will omit the "packed" attr when an "align" attr is present and it can do so without changing a type's layout Signed-off-by: Thomas Bertschinger <tahbertschinger@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-03-14bcachefs: bch2_trigger_alloc() handles state changes betterKent Overstreet1-8/+13
bch2_trigger_alloc() kicks off certain tasks on bucket state changes; e.g. triggering the bucket discard worker and the invalidate worker. We've observed the discard worker running too often - most runs it doesn't do any work, according to the tracepoint - so clearly, we're kicking it off too often. This adds an explicit statechange() macro to make these checks more precise. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-03-14bcachefs: bch2_print_opts()Kent Overstreet3-6/+27
Make sure early error messages get redirected, for kernel-fsck-from-userland. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-03-14bcachefs: Improve error messages in device remove pathKent Overstreet1-5/+5
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-03-14bcachefs: Use kvzalloc() when dynamically allocating btree pathsKent Overstreet1-2/+2
THis silences a mm/page_alloc.c warning about allocating more than a page with GFP_NOFAIL - and there's no reason for this to not have a vmalloc fallback anyways. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-03-14bcachefs: Track iter->ip_allocated at bch2_trans_copy_iter()Kent Overstreet1-0/+3
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-03-14bcachefs: Save key_cache_path in peek_slot()Kent Overstreet1-0/+1
When bch2_btree_iter_peek_slot() clones the iterator to search for the next key, and then discovers that the key from the cloned iterator is the key we want to return - we also want to save the iter->key_cache_path as well, for the update path. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-03-14bcachefs: Pin btree cache in ram for random access in fsckKent Overstreet5-91/+72
Various phases of fsck involve checking references from one btree to another: this means doing a sequential scan of one btree, and then mostly random access into the second. This is particularly painful for checking extents <-> backpointers; we can prefetch btree node access on the sequential scan, but not on the random access portion, and this is particularly painful on spinning rust, where we'd like to keep the pipeline fairly full of btree node reads so that the elevator can reduce seeking. This patch implements prefetching and pinning of the portion of the btree that we'll be doing random access to. We already calculate how much of the random access btree will fit in memory so it's a fairly straightforward change. This will put more pressure on system memory usage, so we introduce a new option, fsck_memory_usage_percent, which is the percentage of total system ram that fsck is allowed to pin. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-03-14bcachefs: Check for subvolume children when deleting subvolumesKent Overstreet5-9/+32
Recursively destroying subvolumes isn't allowed yet. Fixes: https://github.com/koverstreet/bcachefs/issues/634 Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-03-14bcachefs: BTREE_ID_subvolume_childrenKent Overstreet7-3/+114
Add a btree to record a parent -> child subvolume relationships, according to the filesystem heirarchy. The subvolume_children btree is a bitset btree: if a bit is set at pos p, that means p.offset is a child of subvolume p.inode. This will be used for efficiently listing subvolumes, as well as recursive deletion. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-03-14bcachefs: bch_subvolume::fs_path_parentKent Overstreet7-13/+88
Record the filesystem path heirarchy for subvolumes in bch_subvolume Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-03-14bcachefs: bch2_btree_bit_mod()Kent Overstreet2-0/+22
Provide a non-write buffer version of bch2_btree_bit_mod_buffered(), for the subvolume children btree. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-03-14bcachefs: bch2_btree_bit_mod -> bch2_btree_bit_mod_bufferedKent Overstreet5-9/+11
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-03-14bcachefs: Correctly reattach subvolumesKent Overstreet3-10/+28
Subvolumes need special handling to reattach - we always reattach them in the root subvolume's lost+found, and they need a slightly different kind of dirent. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-03-14bcachefs: check_path() now prints full inode when reattachingKent Overstreet1-8/+18
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-03-14bcachefs: Pass inode bkey to check_path()Kent Overstreet2-29/+40
prep work for improving logging/error messages Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-03-14bcachefs: Fix path where dirent -> subvol missing and we don't fixKent Overstreet1-4/+9
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-03-14bcachefs: bch_subvolume::parent -> creation_parentKent Overstreet2-13/+13
bit of renaming, prep for adding a fs path parent Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-03-14bcachefs: Repair subvol dirents that point to non subvolsKent Overstreet1-0/+6
when repair switches d_type to or from DT_SUBVOL, we need to update the target accordingly Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-03-14bcachefs: check dirent->d_parent_subvolKent Overstreet1-4/+57
Check that d_parent_subvol makes sense - the dirent's snapshot must be visible in d_parent_subvol (i.e. an ancestor of d_parent_subvol's snapshot) in order to be visible. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-03-14bcachefs: check inode->bi_parent_subvol against direntKent Overstreet2-23/+14
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-03-14bcachefs: delete duplicated checks in check_dirent_to_subvol()Kent Overstreet1-23/+4
these were already checked in check_subvol() Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-03-14bcachefs: simplify check_dirent_inode_dirent()Kent Overstreet1-58/+56
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-03-14bcachefs: check bi_parent_subvol in check_inode()Kent Overstreet1-0/+10
check for inodes with a nonzero bi_parent_subvol field that aren't actually subvolume roots Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-03-14bcachefs: better log message in lookup_inode_for_snapshot()Kent Overstreet1-21/+24
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-03-14bcachefs: check_inode_dirent_inode()Kent Overstreet1-36/+89
check that if an inode has a backpointer, the dirent it points to points back to it. We do this in check_dirent_inode_dirent(), but only for inodes that have dirents that point to them - we also have to do the check starting from the inode to catch inodes that don't have dirents that point to them. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-03-14bcachefs: Check subvol <-> inode pointers in check_inode()Kent Overstreet1-0/+25
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-03-14bcachefs: Check subvol <-> inode pointers in check_subvol()Kent Overstreet3-1/+34
Subvolumes and subvolume root inodes point to each other: this verifies the subvolume -> inode -> subvolme path. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-03-14bcachefs: Kill more -EIO error codesKent Overstreet11-20/+27
This converts -EIOs related to btree node errors to private error codes, which will help with some ongoing debugging by giving us better error messages. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-03-14bcachefs: thread_with_file: add f_ops.flushKent Overstreet3-7/+32
Add a flush op, to return the exit code via close(). Also update bcachefs usage to use this to return fsck exit codes. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-03-14bcachefs: thread_with_file: Fix missing va_end()Kent Overstreet1-0/+2
Fixes: https://lore.kernel.org/linux-bcachefs/202402131603.E953E2CF@keescook/T/#u Reported-by: coverity scan Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-03-14bcachefs: thread_with_file: allow ioctls against these filesDarrick J. Wong2-0/+13
Make it so that a thread_with_stdio user can handle ioctls against the file descriptor. Signed-off-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-03-14bcachefs: thread_with_file: create ops structure for thread_with_stdioDarrick J. Wong3-22/+28
Create an ops structure so we can add more file-based functionality in the next few patches. Signed-off-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-03-14bcachefs: thread_with_file: fix various printf problemsDarrick J. Wong2-20/+37
Experimentally fix some problems with stdio_redirect_vprintf by creating a MOO variant with which we can experiment. We can't do a GFP_KERNEL allocation while holding the spinlock, and I don't like how the printf function can silently truncate the output if memory allocation fails. Signed-off-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-03-14bcachefs: thread_with_file: allow creation of readonly filesDarrick J. Wong2-0/+39
Create a new run_thread_with_stdout function that opens a file in O_RDONLY mode so that the kernel can write things to userspace but userspace cannot write to the kernel. This will be used to convey xfs health event information to userspace. Signed-off-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-03-14bcachefs: thread_with_stdio: suppress hung task warningKent Overstreet1-2/+15
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-03-14bcachefs: thread_with_stdio: Mark completed in ->release()Kent Overstreet1-4/+10
This fixes stdio_redirect_read() getting stuck, not noticing that the pipe has been closed. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-03-14bcachefs: Thread with file documentationKent Overstreet2-7/+40
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-03-14bcachefs: thread_with_stdio: fix bch2_stdio_redirect_readline()Kent Overstreet1-11/+22
This fixes a bug where we'd return data without waiting for a newline, if data was present but a newline was not. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-03-14bcachefs: thread_with_stdio: kill thread_with_stdio_done()Kent Overstreet3-22/+23
Move the cleanup code to a wrapper function, where we can call it after the thread_with_stdio fn exits. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-03-14bcachefs: thread_with_stdio: convert to darrayKent Overstreet4-100/+160
- eliminate the dependency on printbufs, so that we can lift thread_with_file for use in xfs - add a nonblocking parameter to stdio_redirect_printf(), and either block if the buffer is full or drop it on the floor - don't buffer infinitely Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>