aboutsummaryrefslogtreecommitdiff
path: root/fs/bcachefs/fsck.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* bcachefs: Don't delete open files in online fsckKent Overstreet2024-09-091-0/+18
| | | | | | | | | If a file is unlinked but still open, we don't want online fsck to delete it - or fun inconsistencies will happen. https://github.com/koverstreet/bcachefs/issues/727 Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: add missing inode_walker_exit()Kent Overstreet2024-08-221-0/+2
| | | | | | fix a small leak Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: Fix double assignment in check_dirent_to_subvol()Yuesong Li2024-08-221-1/+0
| | | | | | | ret was assigned twice in check_dirent_to_subvol(). Reported by cocci. Signed-off-by: Yuesong Li <liyuesong@vivo.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: fix missing bch2_err_str()Kent Overstreet2024-08-221-2/+1
| | | | Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: More informative error message in reattach_inode()Kent Overstreet2024-07-221-2/+5
| | | | Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: fsck_err() may now take a btree_transKent Overstreet2024-07-141-39/+42
| | | | | | | | | fsck_err() now optionally takes a btree_trans; if the current thread has one, it is required that it be passed. The next patch will use this to unlock when waiting for user input. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: check_key_has_inode()Kent Overstreet2024-07-141-92/+111
| | | | | | | Consolidate duplicated checks for extents/dirents/xattrs - these keys should all have a corresponding inode of the correct type. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: fix stack frame size in fsck.cKent Overstreet2024-06-101-0/+3
| | | | | | | fsck.c always runs top of the stack so we're not too concerned here; noinline_for_stack is sufficient Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: Run check_key_has_snapshot in snapshot_delete_keys()Kent Overstreet2024-05-281-23/+4
| | | | | | | delete_dead_snapshots now runs before the main fsck.c passes which check for keys for invalid snapshots; thus, it needs those checks as well. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: Fix lookup_first_inode() when inode_generations are presentKent Overstreet2024-05-281-14/+10
| | | | | | | | | This function is used for finding the hash seed (which is the same in all versions of an inode in different snapshots): ff an inode has been deleted in a child snapshot we need to iterate until we find a live version. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: check for inodes that should have backpointers in fsckKent Overstreet2024-05-081-0/+10
| | | | Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: Rip bch2_snapshot_equiv() out of fsckKent Overstreet2024-05-081-90/+30
| | | | | | | | | | | Originally, when deleting snapshots we didn't collapse redundant snapshot nodes; thus, the notion of a class of equivalent snapshot nodes leaked into fsck. Now we do, so snapshot ID equivalence classes are purely local to snapshot deletion. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: iter/update/trigger/str_hash flag cleanupKent Overstreet2024-05-081-37/+37
| | | | | | | | | | | Combine iter/update/trigger/str_hash flags into a single enum, and x-macroize them for a to_text() function later. These flags are all for a specific iter/key/update context, so it makes sense to group them together - iter/update/trigger flags were already given distinct bits, this cleans up and unifies that handling. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: bch2_hash_lookup() now returns bkey_s_cKent Overstreet2024-05-081-4/+4
| | | | | | small cleanup Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: reconstruct_inode()Kent Overstreet2024-04-031-2/+50
| | | | | | | If an inode is missing, but corresponding extents and dirent still exist, it's well worth recreating it - this does so. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: Subvolume reconstructionKent Overstreet2024-04-031-19/+148
| | | | | | We can now recreate missing subvolumes from dirents and/or inodes. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: ratelimit informational fsck errorsKent Overstreet2024-04-021-4/+4
| | | | Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: Fix overlapping extent repairKent Overstreet2024-04-011-4/+6
| | | | | | | overlapping extent repair was colliding with extent past end of inode checks - don't update "extent ends at" until we know we have an extent. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: Fix remove_dirent()Kent Overstreet2024-04-011-3/+4
| | | | | | We were missing an iter_traverse(). Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: Split out recovery_passes.cKent Overstreet2024-03-311-1/+1
| | | | | | | | | | | We've grown a fair amount of code for managing recovery passes; tracking which ones we're running, which ones need to be run, and flagging in the superblock which ones need to be run on the next recovery. So it's worth splitting out into its own file, this code is pretty different from the code in recovery.c. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: Fix use after free in check_root_trans()Kent Overstreet2024-03-311-7/+11
| | | | Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: Fix spurious -BCH_ERR_transaction_restart_nestedKent Overstreet2024-03-171-8/+21
| | | | | | | | | We only need to return transaction_restart_nested when we're inside a context that's handling transaction restarts. Also, add a missing check_subdir_count() call. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: Fix check_key_has_snapshot() callKent Overstreet2024-03-171-1/+3
| | | | Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: check_path() now only needs to walk up to subvolume rootKent Overstreet2024-03-131-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>
* bcachefs: bch2_check_subvolume_structure()Kent Overstreet2024-03-131-27/+133
| | | | | | | 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>
* bcachefs: bch_subvolume::fs_path_parentKent Overstreet2024-03-131-6/+27
| | | | | | Record the filesystem path heirarchy for subvolumes in bch_subvolume Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: Correctly reattach subvolumesKent Overstreet2024-03-131-5/+23
| | | | | | | | 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>
* bcachefs: check_path() now prints full inode when reattachingKent Overstreet2024-03-131-8/+18
| | | | Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: Pass inode bkey to check_path()Kent Overstreet2024-03-131-29/+26
| | | | | | prep work for improving logging/error messages Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: Fix path where dirent -> subvol missing and we don't fixKent Overstreet2024-03-131-4/+9
| | | | Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: Repair subvol dirents that point to non subvolsKent Overstreet2024-03-131-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>
* bcachefs: check dirent->d_parent_subvolKent Overstreet2024-03-131-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>
* bcachefs: check inode->bi_parent_subvol against direntKent Overstreet2024-03-131-22/+13
| | | | Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: delete duplicated checks in check_dirent_to_subvol()Kent Overstreet2024-03-131-23/+4
| | | | | | these were already checked in check_subvol() Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: simplify check_dirent_inode_dirent()Kent Overstreet2024-03-131-58/+56
| | | | Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: check bi_parent_subvol in check_inode()Kent Overstreet2024-03-131-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>
* bcachefs: better log message in lookup_inode_for_snapshot()Kent Overstreet2024-03-131-21/+24
| | | | Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: check_inode_dirent_inode()Kent Overstreet2024-03-131-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>
* bcachefs: Check subvol <-> inode pointers in check_inode()Kent Overstreet2024-03-131-0/+25
| | | | Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: factor out check_inode_backpointer()Kent Overstreet2024-03-101-9/+29
| | | | Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: Factor out check_subvol_dirent()Kent Overstreet2024-03-101-48/+57
| | | | | | Going to be adding more code here for checking subvol structure. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: move fsck_write_inode() to inode.cKent Overstreet2024-03-101-40/+13
| | | | Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: bch2_hash_set_snapshot() -> bch2_hash_set_in_snapshot()Kent Overstreet2024-03-101-4/+3
| | | | | | Minor renaming for clarity, bit of refactoring. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: fix check_inode_deleted_list()Kent Overstreet2024-03-101-6/+3
| | | | | | | check_inode_deleted_list() returns true if the inode is on the deleted list; check_inode() was checking the return code incorrectly. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: __lookup_dirent() works in snapshot, not subvolKent Overstreet2024-01-251-11/+12
| | | | | | | | | | | | | Add a new helper, bch2_hash_lookup_in_snapshot(), for when we're not operating in a subvolume and already have a snapshot ID, and then use it in lookup_lostfound() -> __lookup_dirent(). This is a bugfix - lookup_lostfound() doesn't take a subvolume ID, we were passing a nonsense subvolume ID before, and don't have one to pass since we may be operating in an interior snapshot node that doesn't have a subvolume ID. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: fsck_err()s don't need to manually check c->sb.version anymoreKent Overstreet2024-01-051-9/+7
| | | | Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: check_directory_structure() can now be run onlineKent Overstreet2024-01-011-66/+40
| | | | | | | | Now that we have dynamically resizable btree paths, check_directory_structure() can check one path - inode up to the root - in a single transaction. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: Fix reattach_inode() for snapshotsKent Overstreet2024-01-011-46/+60
| | | | | | | | | | | | | reattach_inode() was broken w.r.t. snapshots - we'd lookup the subvolume to look up lost+found, but if we're in an interior node snapshot that didn't make any sense. Instead, this adds a dirent path for creating in a specific snapshot, skipping the subvolume; and we also make sure to create lost+found in the root snapshot, to avoid conflicts with lost+found being created in overlapping snapshots. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: Clean up btree_transKent Overstreet2024-01-011-1/+1
| | | | Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: btree_iter -> btree_path_idx_tKent Overstreet2024-01-011-1/+1
| | | | Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>