aboutsummaryrefslogtreecommitdiff
path: root/fs/bcachefs/dirent.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* bcachefs: bch2_subvolume_get()Kent Overstreet2023-10-221-23/+4
| | | | | | Factor out a little helper. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
* bcachefs: Snapshot creation, deletionKent Overstreet2023-10-221-8/+0
| | | | | | | | | | | This is the final patch in the patch series implementing snapshots. This patch implements two new ioctls that work like creation and deletion of directories, but fancier. - BCH_IOCTL_SUBVOLUME_CREATE, for creating new subvolumes and snaphots - BCH_IOCTL_SUBVOLUME_DESTROY, for deleting subvolumes and snapshots Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
* bcachefs: Plumb through subvolume idKent Overstreet2023-10-221-35/+72
| | | | | | | | | | | | | | To implement snapshots, we need every filesystem btree operation (every btree operation without a subvolume) to start by looking up the subvolume and getting the current snapshot ID, with bch2_subvolume_get_snapshot() - then, that snapshot ID is used for doing btree lookups in BTREE_ITER_FILTER_SNAPSHOTS mode. This patch adds those bch2_subvolume_get_snapshot() calls, and also switches to passing around a subvol_inum instead of just an inode number. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
* bcachefs: Add support for dirents that point to subvolumesKent Overstreet2023-10-221-18/+87
| | | | | | | | | | | | Dirents currently always point to inodes. Subvolumes add a new type of dirent, with d_type DT_SUBVOL, that instead points to an entry in the subvolumes btree, and the subvolume has a pointer to the root inode. This patch adds bch2_dirent_read_target() to get the inode (and potentially subvolume) a dirent points to, and changes existing code to use that instead of reading from d_inum directly. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
* bcachefs: Subvolumes, snapshotsKent Overstreet2023-10-221-2/+3
| | | | | | | | This patch adds subvolume.c - support for the subvolumes and snapshots btrees and related data types and on disk data structures. The next patches will start hooking up this new code to existing code. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
* bcachefs: btree_pathKent Overstreet2023-10-221-39/+38
| | | | | | | | | | | | | | | This splits btree_iter into two components: btree_iter is now the externally visible componont, and it points to a btree_path which is now reference counted. This means we no longer have to clone iterators up front if they might be mutated - btree_path can be shared by multiple iterators, and cloned if an iterator would mutate a shared btree_path. This will help us use iterators more efficiently, as well as slimming down the main long lived state in btree_trans, and significantly cleans up the logic for iterator lifetimes. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: Always check for transaction restartsKent Overstreet2023-10-221-3/+15
| | | | | | | On transaction restart iterators won't be locked anymore - make sure we're always checking for errors. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
* bcachefs: Ensure bad d_type doesn't oops in bch2_dirent_to_text()Kent Overstreet2023-10-221-1/+4
| | | | Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
* bcachefs: bch2_d_types[]Kent Overstreet2023-10-221-1/+1
| | | | | | Add readable names for d_type, and use it in dirent_to_text(). Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
* bcachefs: Fix inode backpointers in RENAME_OVERWRITEKent Overstreet2023-10-221-1/+4
| | | | | | | When we delete the dirent an inode points to, we need to zero out the backpointer fields - this was missed in the RENAME_OVERWRITE case. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
* bcachefs: Move some dirent checks to bch2_dirent_invalid()Kent Overstreet2023-10-221-5/+13
| | | | | Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: Inode backpointersKent Overstreet2023-10-221-6/+12
| | | | | | | | | | | | | | | | | This patch adds two new inode fields, bi_dir and bi_dir_offset, that point back to the inode's dirent. Since we're only adding fields for a single backpointer, files that have been hardlinked won't necessarily have valid backpointers: we also add a new inode flag, BCH_INODE_BACKPTR_UNTRUSTED, that's set if an inode has ever had multiple links to it. That's ok, because we only really need this functionality for directories, which can never have multiple hardlinks - when we add subvolumes, we'll need a way to enemurate and print subvolumes, and this will let us reconstruct a path to a subvolume root given a subvolume root inode. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: Require all btree iterators to be freedKent Overstreet2023-10-221-0/+3
| | | | | | | | We keep running into occasional bugs with btree transaction iterators overflowing - this will make those bugs more visible. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: Rename BTREE_ID enums for consistency with other enumsKent Overstreet2023-10-221-3/+3
| | | | | Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: Rename KEY_TYPE_whiteout -> KEY_TYPE_hash_whiteoutKent Overstreet2023-10-221-2/+2
| | | | | | | | Snapshots are going to need a different whiteout key type. Also, switch to using BCH_BKEY_TYPES() to define the bkey value accessors. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: Print out d_type in dirent_to_text()Kent Overstreet2023-10-221-1/+1
| | | | | Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: Kill TRANS_RESET_MEM|TRANS_RESET_ITERSKent Overstreet2023-10-221-18/+27
| | | | | | | | | | | All iterators should be released now with bch2_trans_iter_put(), so TRANS_RESET_ITERS shouldn't be needed anymore, and TRANS_RESET_MEM is always used. Also convert more code to __bch2_trans_do(). Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: Don't call trans_iter_put() on error pointerKent Overstreet2023-10-221-1/+3
| | | | | Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: Split out btree_trigger_flagsKent Overstreet2023-10-221-3/+3
| | | | | | | | | | The trigger flags really belong with individual btree_insert_entries, not the transaction commit flags - this splits out those flags and unifies them with the BCH_BUCKET_MARK flags. Todo - split out btree_trigger.c from buckets.c Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: Convert all bch2_trans_commit() users to BTREE_INSERT_ATOMICKent Overstreet2023-10-221-12/+0
| | | | | | | | | BTREE_INSERT_ATOMIC should really be the default mode, and there's not that much code that doesn't need it - so this is prep work for getting rid of the flag. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: Refactor bch2_readdir() a bitKent Overstreet2023-10-221-12/+7
| | | | | | The tweaks to ctx->pos handling are also to help the fuse port Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: Can't be holding read locks while taking write locksKent Overstreet2023-10-221-3/+4
| | | | Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: Factor out fs-common.cKent Overstreet2023-10-221-55/+42
| | | | | | | | This refactoring makes the code easier to understand by separating the bcachefs btree transactional code from the linux VFS code - but more importantly, it's also to share code with the fuse port. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: Kill deferred btree updatesKent Overstreet2023-10-221-5/+4
| | | | | | Will be replaced by cached btree iterators Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: More work to avoid transaction restartsKent Overstreet2023-10-221-2/+2
| | | | Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: Return errors from for_each_btree_key()Kent Overstreet2023-10-221-10/+7
| | | | Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: Fsck locking improvementsKent Overstreet2023-10-221-6/+13
| | | | Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: Only get btree iters from btree transactionsKent Overstreet2023-10-221-6/+13
| | | | Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: convert bch2_btree_insert_at() usage to bch2_trans_commit()Kent Overstreet2023-10-221-2/+2
| | | | Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: Make bkey types globally uniqueKent Overstreet2023-10-221-47/+25
| | | | | | | | | | this lets us get rid of a lot of extra switch statements - in a lot of places we dispatch on the btree node type, and then the key type, so this is a nice cleanup across a lot of code. Also improve the on disk format versioning stuff. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: revamp to_text methodsKent Overstreet2023-10-221-9/+6
| | | | Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: Dirent repair codeKent Overstreet2023-10-221-13/+1
| | | | | | | | | | | | | There was a bug for awhile in previous kernels where we weren't computing dirent name lengths correctly and we weren't zeroing out padding at the end of dirents (due to struct bch_dirent changing size by adding __attribute__((aligned)), and not updating other code to use offsetof). This patch fixes dirents with junk at the end, by going off of the dirent's hash. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: fix bch2_val_to_text()Kent Overstreet2023-10-221-7/+9
| | | | | | was returning wrong value Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: bch2_trans_update() now takes struct btree_insert_entryKent Overstreet2023-10-221-3/+5
| | | | Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
* bcachefs: Initial commitKent Overstreet2023-10-221-0/+426
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>