id
stringlengths
40
40
instruction
stringlengths
68
308
input
stringlengths
17
33.4k
output
stringlengths
100
30k
41f9b7d39fb11c9f306809681bb6991ac96f9b2e
Analyze and fix the following issue in the Linux kernel code: bcachefs: Move bch2_evict_subvolume_inodes() to fs.c
Problem Details: This fixes building in userspace - code that's coupled to the kernel VFS interface should live in fs.c Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/fs.c b/fs/bcachefs/fs.c index c325e5c4325c..7647e117013d 100644 --- a/fs/bcachefs/fs.c +++ b/fs/bcachefs/fs.c @@ -1292,12 +1292,6 @@ static int bch2_vfs_write_inode(struct inode *vinode, return ret; } -static int bch2_drop_inode(struct inode *vinode) -{ - - return generic_drop_inod...
6b3d8b8992e59d3a145f67173a0d75fa25e6e750
Analyze and fix the following issue in the Linux kernel code: bcachefs: Don't run triggers in fix_reflink_p_key()
Problem Details: It seems some users have reflink pointers which span many indirect extents, from a short window in time when merging of reflink pointers was allowed. Now, we're seeing transaction path overflows in fix_reflink_p(), the code path to clear out the reflink_p fields now used for front/back pad - but, we d...
```diff diff --git a/fs/bcachefs/fsck.c b/fs/bcachefs/fsck.c index 197b9079e2b8..a61d380a47b6 100644 --- a/fs/bcachefs/fsck.c +++ b/fs/bcachefs/fsck.c @@ -2258,7 +2258,7 @@ static int fix_reflink_p_key(struct btree_trans *trans, struct btree_iter *iter) u->v.front_pad = 0; u->v.back_pad = 0; - return bch2_trans_u...
d121172561d670c8152559614b3575322d709d8d
Analyze and fix the following issue in the Linux kernel code: bcachefs: More general fix for transaction paths overflow
Problem Details: for_each_btree_key() now calls bch2_trans_begin() as needed; that means, we can also call it when we're in danger of overflowing transaction paths. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/btree_iter.h b/fs/bcachefs/btree_iter.h index e58cad4b8fc6..16fa0fe1c5b7 100644 --- a/fs/bcachefs/btree_iter.h +++ b/fs/bcachefs/btree_iter.h @@ -329,8 +329,9 @@ __bch2_btree_iter_peek_and_restart(struct btree_trans *trans, { struct bkey_s_c k; - while (k = __bch2_btree_iter_peek(i...
396a887d8fdf37d9e3e9a5b2db823184f8ec2eaa
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix fsck path for refink pointers
Problem Details: The way __bch2_mark_reflink_p returns errors was clashing with returning the number of sectors processed - we weren't returning FSCK_ERR_EXIT correctly. Fix this by only using the return code for errors, which actually ends up simplifying the overall logic. Signed-off-by: Kent Overstreet <kent.overst...
```diff diff --git a/fs/bcachefs/buckets.c b/fs/bcachefs/buckets.c index ee1c71e011c7..2982f71bcf2d 100644 --- a/fs/bcachefs/buckets.c +++ b/fs/bcachefs/buckets.c @@ -1112,61 +1112,47 @@ static int bch2_mark_reservation(struct bch_fs *c, } static s64 __bch2_mark_reflink_p(struct bch_fs *c, struct bkey_s_c_reflink_p...
23af498cc44bc7615f3f208f39daab637bcac023
Analyze and fix the following issue in the Linux kernel code: bcachefs: Ensure we flush btree updates in evacuate path
Problem Details: This fixes a possible race where we fail to remove a device because of btree nodes still on it, that are being deleted by in flight btree updates. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/move.c b/fs/bcachefs/move.c index 1d7b8696af01..5f50b66fe206 100644 --- a/fs/bcachefs/move.c +++ b/fs/bcachefs/move.c @@ -932,6 +932,10 @@ next: if (ret) bch_err(c, "error %i in bch2_move_btree", ret); + /* flush relevant btree updates */ + closure_wait_event(&c->btree_interior_u...
979735df980972dc9ffdaca8a5171664ac658248
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix bch2_btree_iter_next_node()
Problem Details: We were modifying state, then return -EINTR, causing us to skip nodes - ouch. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index 189c020d289a..c1dc33248265 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -1462,6 +1462,11 @@ static int btree_path_traverse_one(struct btree_trans *trans, unsigned depth_want = path->level; int ret = 0; + if (...
114eea75c73dfd95ae529eb841aad0330793f446
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix dev accounting after device add
Problem Details: This is a hacky but effective fix to device usage stats for superblock and journal being wrong on a newly added device (following the comment that already told us how it needed to be done!) Reported-by: Chris Webb <chris@arachsys.com> Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/super.c b/fs/bcachefs/super.c index db38d6b0f2ad..d17e4f005b3f 100644 --- a/fs/bcachefs/super.c +++ b/fs/bcachefs/super.c @@ -1591,6 +1591,8 @@ int bch2_dev_add(struct bch_fs *c, const char *path) struct bch_dev *ca = NULL; struct bch_sb_field_members *mi; struct bch_member dev_mi...
ab44d7bdeebe316a03f37c08c1f66c13ea9aa5d5
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix a transaction path overflow
Problem Details: readdir() in a directory with many subvolumes could overflow transaction paths - this is a simple hack around the issue. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/dirent.c b/fs/bcachefs/dirent.c index 2ab9cbaf71f2..6be3ec4ec4a6 100644 --- a/fs/bcachefs/dirent.c +++ b/fs/bcachefs/dirent.c @@ -529,6 +529,15 @@ retry: vfs_d_type(dirent.v->d_type))) break; ctx->pos = dirent.k->p.offset + 1; + + /* + * read_target looks up subvolum...
de924abbe7a62bdeb6baaba0f2fe2d1c64ef888b
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix error handling in bch2_trans_extent_merging
Problem Details: The back merging case wasn't returning errors correctly. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/btree_update_leaf.c b/fs/bcachefs/btree_update_leaf.c index b344979ca7ed..22fce150781e 100644 --- a/fs/bcachefs/btree_update_leaf.c +++ b/fs/bcachefs/btree_update_leaf.c @@ -1058,7 +1058,7 @@ static int bch2_trans_update_extent(struct btree_trans *trans, if (bch2_bkey_maybe_mergable(...
e5fa91d7ac88ac6a8385c14dbc8dcbe1a053e62f
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix restart handling in for_each_btree_key()
Problem Details: Code that uses for_each_btree_key often wants transaction restarts to be handled locally and not returned. Originally, we wouldn't return transaction restarts if there was a single iterator in the transaction - the reasoning being if there weren't other iterators being invalidated, and the current iter...
```diff diff --git a/fs/bcachefs/bcachefs_format.h b/fs/bcachefs/bcachefs_format.h index 4b2bf8f7b28a..6ed3ca075ba0 100644 --- a/fs/bcachefs/bcachefs_format.h +++ b/fs/bcachefs/bcachefs_format.h @@ -1041,8 +1041,6 @@ LE64_BITMASK(BCH_MEMBER_DATA_ALLOWED, struct bch_member, flags[0], 15, 20) LE64_BITMASK(BCH_MEMBER_GRO...
521b80676927df6b4ad4fc87b7756aad43b96d12
Analyze and fix the following issue in the Linux kernel code: bcachefs: Delete dentry when deleting snapshots
Problem Details: This fixes a bug where subsequently doing creates with the same name fails. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/fs-ioctl.c b/fs/bcachefs/fs-ioctl.c index ae402d350d4c..a12b591ec9ca 100644 --- a/fs/bcachefs/fs-ioctl.c +++ b/fs/bcachefs/fs-ioctl.c @@ -422,6 +422,7 @@ static long bch2_ioctl_subvolume_destroy(struct bch_fs *c, struct file *filp, struct bch_ioctl_subvolume arg) { struct path p...
6e0c886d3ccd81d87054269b96de6e4eb6ba0edd
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix check_path() for snapshots
Problem Details: check_path() wasn't checking the snapshot ID when checking for directory structure loops - so, snapshots would cause us to detect a loop that wasn't actually a loop. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/fsck.c b/fs/bcachefs/fsck.c index c99e1514fd4f..d6f37b9e00fb 100644 --- a/fs/bcachefs/fsck.c +++ b/fs/bcachefs/fsck.c @@ -1357,10 +1357,10 @@ static int check_dirent_target(struct btree_trans *trans, } if (fsck_err_on(!backpointer_exists, c, - "inode %llu has wrong backpointe...
6d76aefea1902a11c47e20fec5495d30a39891f3
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix for leaking of reflinked extents
Problem Details: When a reflink pointer points to only part of an indirect extent, and then that indirect extent is fragmented (e.g. by copygc), if the reflink pointer only points to one of the fragments we leak a reference. Fix this by storing front/back pad values in reflink pointers - when inserting reflink pointes...
```diff diff --git a/fs/bcachefs/bcachefs_format.h b/fs/bcachefs/bcachefs_format.h index 579acb69115d..4b2bf8f7b28a 100644 --- a/fs/bcachefs/bcachefs_format.h +++ b/fs/bcachefs/bcachefs_format.h @@ -917,15 +917,24 @@ struct bch_stripe { struct bch_reflink_p { struct bch_val v; __le64 idx; - __le64 v2; -}; + /...
bfe88863cf3063204fc49a04307fa6635554d6e3
Analyze and fix the following issue in the Linux kernel code: bcachefs: New on disk format to fix reflink_p pointers
Problem Details: We had a bug where reflink_p pointers weren't being initialized to 0, and when we started using the second word, things broke badly. This patch revs the on disk format version and adds cleanup code to zero out the second word of reflink_p pointers before we start using it. Signed-off-by: Kent Overstr...
```diff diff --git a/fs/bcachefs/bcachefs_format.h b/fs/bcachefs/bcachefs_format.h index 54023edc995e..579acb69115d 100644 --- a/fs/bcachefs/bcachefs_format.h +++ b/fs/bcachefs/bcachefs_format.h @@ -917,10 +917,7 @@ struct bch_stripe { struct bch_reflink_p { struct bch_val v; __le64 idx; - - __le32 reservatio...
b71717dac64d76879ba3c70cfcfccf57991205f8
Analyze and fix the following issue in the Linux kernel code: bcachefs: Handle transaction restarts in bch2_blacklist_entries_gc()
Problem Details: It shouldn't be necessary when we're only using a single iterator and not doing updates, but that's harder to debug at the moment. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/journal_seq_blacklist.c b/fs/bcachefs/journal_seq_blacklist.c index f84a63ac15af..79bc0e49389b 100644 --- a/fs/bcachefs/journal_seq_blacklist.c +++ b/fs/bcachefs/journal_seq_blacklist.c @@ -253,12 +253,21 @@ void bch2_blacklist_entries_gc(struct work_struct *work) struct btree_iter i...
488f97764a9adb68d2ebec0a6e5b96f0f0a7bf38
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix check_path() across subvolumes
Problem Details: Checking of directory structure across subvolumes was broken - we need to look up the snapshot ID of the parent subvolume when crossing subvol boundaries. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/fsck.c b/fs/bcachefs/fsck.c index 208bf6df82b5..826a3577ee93 100644 --- a/fs/bcachefs/fsck.c +++ b/fs/bcachefs/fsck.c @@ -1050,6 +1050,8 @@ static int inode_backpointer_exists(struct btree_trans *trans, { struct btree_iter iter; struct bkey_s_c k; + u32 target_subvol, target_snapsh...
ca130b9c5e120994483a34c72526dcd4bf308d84
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix a cache coherency bug in bch2_subvolume_create()
Problem Details: Subvolume deletion doesn't flush & evict the btree key cache - ideally it would, but that's tricky, so instead bch2_subvolume_create() needs to make sure the slot doesn't exist in the key cache to avoid triggering assertions. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/subvolume.c b/fs/bcachefs/subvolume.c index d1c111050c35..9bd8d61c96fe 100644 --- a/fs/bcachefs/subvolume.c +++ b/fs/bcachefs/subvolume.c @@ -886,6 +886,7 @@ int bch2_subvolume_create(struct btree_trans *trans, u64 inode, u32 *new_snapshotid, bool ro) { + struct bch_fs *c =...
6a0f414e2018fe7a2b001fbc8ccd4a8f4f946214
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix compiler warnings
Problem Details: Type size_t is architecture-specific. Fix warnings for some non-amd64 arches. Signed-off-by: Brett Holman <bholman.devel@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/journal_reclaim.c b/fs/bcachefs/journal_reclaim.c index 54d8e2f32a37..0bc4681ccc24 100644 --- a/fs/bcachefs/journal_reclaim.c +++ b/fs/bcachefs/journal_reclaim.c @@ -653,7 +653,7 @@ static int __bch2_journal_reclaim(struct journal *j, bool direct) atomic_long_read(&c->btree_key_cac...
70d61a7036c8d046889a4bf4eda504a6a56b2642
Analyze and fix the following issue in the Linux kernel code: bcachefs: Zero out reflink_p val in bch2_make_extent_indirect()
Problem Details: This bug was only discovered when we started using the 2nd word in the val, which should have been zeroed out as those fields had never been used before - ouch. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/reflink.c b/fs/bcachefs/reflink.c index 92ff609453b8..c63c95fc49b1 100644 --- a/fs/bcachefs/reflink.c +++ b/fs/bcachefs/reflink.c @@ -166,9 +166,15 @@ static int bch2_make_extent_indirect(struct btree_trans *trans, if (ret) goto err; + /* + * orig is in a bkey_buf which statical...
bd547c8acb1aa76ceab1987109ac6ceae698fcc9
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix __bch2_dirent_read_target()
Problem Details: We were shadowing our exist status, oops Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/dirent.c b/fs/bcachefs/dirent.c index c7344ac87fcd..cd5468b15ba2 100644 --- a/fs/bcachefs/dirent.c +++ b/fs/bcachefs/dirent.c @@ -183,6 +183,7 @@ int __bch2_dirent_read_target(struct btree_trans *trans, u32 *subvol, u32 *snapshot, u64 *inum, bool is_fsck) { + struct...
edeb986b017e9489add4daa7e61bc79cdbfb913c
Analyze and fix the following issue in the Linux kernel code: bcachefs: Don't allocate too-big bios
Problem Details: This fixes a null ptr deref in bio_alloc_bioset() -> biovec_slab() Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/io.c b/fs/bcachefs/io.c index 002fd35e6bfe..ea2adcc213d0 100644 --- a/fs/bcachefs/io.c +++ b/fs/bcachefs/io.c @@ -782,6 +782,8 @@ static struct bio *bch2_write_bio_alloc(struct bch_fs *c, ? ((unsigned long) buf & (PAGE_SIZE - 1)) : 0), PAGE_SIZE); + pages = min...
b9a7d8ac5f6d66619de8a4e37b23574d1ca107cf
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix implementation of KEY_TYPE_error
Problem Details: When force-removing a device, we were silently dropping extents that we no longer had pointers for - we should have been switching them to KEY_TYPE_error, so that reads for data that was lost return errors. This patch adds the logic for switching a key to KEY_TYPE_error to bch2_bkey_drop_ptr(), and im...
```diff diff --git a/fs/bcachefs/btree_gc.c b/fs/bcachefs/btree_gc.c index f14667390e2c..dbf44704d0fc 100644 --- a/fs/bcachefs/btree_gc.c +++ b/fs/bcachefs/btree_gc.c @@ -1767,7 +1767,6 @@ static int bch2_gc_btree_gens(struct bch_fs *c, enum btree_id btree_id) bch2_bkey_buf_reassemble(&sk, c, k); bch2_extent_no...
776eaddb2cef366b16dac8857899dbb4cc5dfdb1
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix deletion in __bch2_dev_usrdata_drop()
Problem Details: With snapshots, __bch2_dev_usr_data_drop() now uses an ALL_SNAPSHOTS iterator, which isn't an extent iterator - meaning we shouldn't be inserting whiteouts with nonzero size to delete. This fixes a bug where we go RO because we tried to insert an invalid key in the device remove path. Signed-off-by: K...
```diff diff --git a/fs/bcachefs/migrate.c b/fs/bcachefs/migrate.c index 9f9eb799337e..94d5d99ffd2a 100644 --- a/fs/bcachefs/migrate.c +++ b/fs/bcachefs/migrate.c @@ -73,6 +73,15 @@ static int __bch2_dev_usrdata_drop(struct bch_fs *c, unsigned dev_idx, int flags */ bch2_extent_normalize(c, bkey_i_to_s(sk.k)); ...
e8bde78a178798a414289f2ad5c1f015d8d53139
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix rereplicate_pred()
Problem Details: It was switching off of the key type incorrectly - this code must've been quite old, and not rereplicating anything that wasn't a btree_ptr_v1 or a plain old extent. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/move.c b/fs/bcachefs/move.c index 5e61cd431ef9..fbb6c043ad9b 100644 --- a/fs/bcachefs/move.c +++ b/fs/bcachefs/move.c @@ -946,16 +946,9 @@ static enum data_cmd rereplicate_pred(struct bch_fs *c, void *arg, struct data_opts *data_opts) { unsigned nr_good = bch2_bkey_durabil...
7bd68c73044f1ba39f505082bbed3b2e26f69a13
Analyze and fix the following issue in the Linux kernel code: bcachefs: Snapshot deletion fix
Problem Details: When we delete a snapshot, we unlink the inode but we don't want to run the inode_rm path - the unlink path deletes the subvolume directly, which does everything we need. Also allowing the inode_rm path to run was getting us "missing subvolume" errors. There's still another bug with snapshot deletion:...
```diff diff --git a/fs/bcachefs/fs-common.c b/fs/bcachefs/fs-common.c index 00c7ba17f6c8..c49de741e1e3 100644 --- a/fs/bcachefs/fs-common.c +++ b/fs/bcachefs/fs-common.c @@ -267,18 +267,33 @@ int bch2_unlink_trans(struct btree_trans *trans, if (ret) goto err; - if (deleting_snapshot == 1 && !inode_u->bi_subvol)...
107fe5af562303cda985c6bb72d36dbcd2076f06
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix a pcpu var splat
Problem Details: this_cpu_ptr() emits a warning when used without preemption disabled - harmless in this case, as we have other locking where bch2_acc_percpu_u64s() is used. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/util.c b/fs/bcachefs/util.c index f287bca8498d..8211c9a1b6cb 100644 --- a/fs/bcachefs/util.c +++ b/fs/bcachefs/util.c @@ -893,9 +893,14 @@ void eytzinger0_find_test(void) */ u64 *bch2_acc_percpu_u64s(u64 __percpu *p, unsigned nr) { - u64 *ret = this_cpu_ptr(p); + u64 *ret; int cpu...
4b09ef12e76c3c0e37ecce6c1e33243d65026398
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix bch2_move_btree()
Problem Details: bch2_trans_begin() is now required for transaction restarts. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/move.c b/fs/bcachefs/move.c index 2e7d8e2fe331..5e61cd431ef9 100644 --- a/fs/bcachefs/move.c +++ b/fs/bcachefs/move.c @@ -883,9 +883,11 @@ static int bch2_move_btree(struct bch_fs *c, id++) { stats->btree_id = id; - for_each_btree_node(&trans, iter, id, - id == start...
56767d66e888e0e998eabbbcffa5c6da49ef5402
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fixes for usrdata/metadata drop paths
Problem Details: These paths weren't updated for btree_path and snapshots - a couple of minor fixes. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/migrate.c b/fs/bcachefs/migrate.c index 7c764ee4ea09..9f9eb799337e 100644 --- a/fs/bcachefs/migrate.c +++ b/fs/bcachefs/migrate.c @@ -51,7 +51,8 @@ static int __bch2_dev_usrdata_drop(struct bch_fs *c, unsigned dev_idx, int flags BTREE_ITER_PREFETCH| BTREE_ITER_ALL_SNAP...
d697b9abbae2f2c387aaa4e702afe12e31984a18
Analyze and fix the following issue in the Linux kernel code: bcachefs: More btree iterator fixes
Problem Details: - check for getting to the end of the btree in bch2_path_verify_locks and __btree_path_traverse_all(), this fixes an infinite loop in __btree_path_traverse_all(). - relax requirement in bch2_btree_node_upgrade() that we must want an intent lock, this fixes bugs with paths that point to interi...
```diff diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index 042b8bdf4445..b086f05b117b 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -170,11 +170,20 @@ static bool bch2_btree_node_upgrade(struct btree_trans *trans, { struct btree *b = path->l[level].b; - EBUG_ON(btree_l...
502027a8b2c0f0d46daf948cd1315694a46294e3
Analyze and fix the following issue in the Linux kernel code: bcachefs: Ensure btree_path consistent with node iterators
Problem Details: Btree node iterators want the interior btree_path to point to the same pos as the returned btree node - this fixes a regression from the introduction of btree_path, where rewriting/updating keys of btree nodes (e.g. in bch2_dev_metadata_drop()) via btree node iterators. Signed-off-by: Kent Overstreet ...
```diff diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index df542a59fe12..042b8bdf4445 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -1875,13 +1875,14 @@ bch2_btree_iter_traverse(struct btree_iter *iter) struct btree *bch2_btree_iter_peek_node(struct btree_iter *iter) { ...
a9cb0a6706038292bbc22f50546859783ac492bc
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix bch2_dev_remove_alloc()
Problem Details: It was missing a lockrestart_do(), to call bch2_trans_begin() and also handle transaction restarts. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/super.c b/fs/bcachefs/super.c index a861ec32dbde..db38d6b0f2ad 100644 --- a/fs/bcachefs/super.c +++ b/fs/bcachefs/super.c @@ -1458,15 +1458,18 @@ static int bch2_dev_remove_alloc(struct bch_fs *c, struct bch_dev *ca) bch2_trans_init(&trans, c, 0, 0); for (i = 0; i < ca->mi.nbucket...
69294246b7a441a112d1a550ffc8e4e1e45142a4
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix allocator shutdown error message
Problem Details: We return 1 to indicate kthread_should_stop() returned true - we shouldn't be printing an error. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/alloc_background.c b/fs/bcachefs/alloc_background.c index 54fbfb22d671..fc1b4b354b05 100644 --- a/fs/bcachefs/alloc_background.c +++ b/fs/bcachefs/alloc_background.c @@ -857,10 +857,10 @@ static int bch2_invalidate_buckets(struct bch_fs *c, struct bch_dev *ca) /* If we used NOWAIT, do...
e59a4d787507592ea19dbf48bc71b3120ff5df4d
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix a spurious fsck error
Problem Details: We were getting spurious "multiple types of data in same bucket" errors in fsck, because the check was running for (cached) stale pointers - oops. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/btree_gc.c b/fs/bcachefs/btree_gc.c index 66367ab9f20a..f14667390e2c 100644 --- a/fs/bcachefs/btree_gc.c +++ b/fs/bcachefs/btree_gc.c @@ -504,22 +504,6 @@ static int bch2_check_fix_ptrs(struct bch_fs *c, enum btree_id btree_id, struct bucket *g2 = PTR_BUCKET(ca, &p.ptr, false); en...
ea0531f84eec65a1204a13167965bc151e0f072c
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix check_inode_update_hardlinks()
Problem Details: We were incorrectly using bch2_inode_write(), which gets the snapshot ID from the iterator, with a BTREE_ITER_ALL_SNAPSHOTS iterator - fortunately caught by an assertion in the update path. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/fsck.c b/fs/bcachefs/fsck.c index 16a1eae9b374..3622fb4d18e2 100644 --- a/fs/bcachefs/fsck.c +++ b/fs/bcachefs/fsck.c @@ -2094,11 +2094,7 @@ static int check_nlinks_update_hardlinks(struct bch_fs *c, bch2_inode_nlink_get(&u), link->count)) { bch2_inode_nlink_set(&u, link->count...
71ed0056dc1f03346eabcdaa37272041e5d52fe9
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix an assertion
Problem Details: We can end up in a strange situation where a btree_path points to a node being freed even after pointers to it should have been replaced by pointers to the new node - if the btree node has been reused since the pointer to it was created. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/btree_update_interior.c b/fs/bcachefs/btree_update_interior.c index 73a79563487d..978bb56275de 100644 --- a/fs/bcachefs/btree_update_interior.c +++ b/fs/bcachefs/btree_update_interior.c @@ -165,7 +165,8 @@ static void bch2_btree_node_free_inmem(struct btree_trans *trans, struct btree_...
6f83cb84bb74cd766f888380cfb5f9268e55d9f1
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix unit & perf tests for snapshots
Problem Details: This finishes updating the unit & perf tests for snapshots - btrees that use snapshots now always require the snapshot field of the start position to be a valid snapshot ID. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/tests.c b/fs/bcachefs/tests.c index 1b583b134853..6023661ece16 100644 --- a/fs/bcachefs/tests.c +++ b/fs/bcachefs/tests.c @@ -14,12 +14,14 @@ static void delete_test_keys(struct bch_fs *c) int ret; ret = bch2_btree_delete_range(c, BTREE_ID_extents, - POS(0, 0), POS(0, U64...
3074bc0f7de749440c5e2b01a03ee2226fe69b52
Analyze and fix the following issue in the Linux kernel code: Revert "bcachefs: Add more assertions for locking btree iterators out of order"
Problem Details: Figured out the bug we were chasing, and it had nothing to do with locking btree iterators/paths out of order. This reverts commit ff08733dd298c969aec7c7828095458f73fd5374. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index fbe1a1170df6..4cfd793f85e7 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -157,7 +157,7 @@ bool __bch2_btree_node_relock(struct btree_trans *trans, if (six_relock_type(&b->c.lock, want, path->l[level].lock_seq) || ...
c79272d1e4bb2ff65f4d68f193239d900658c5e6
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix some compiler warnings
Problem Details: gcc couldn't always deduce that written wasn't used uninitialized Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/btree_io.c b/fs/bcachefs/btree_io.c index f51dd3ec0797..f01f78952942 100644 --- a/fs/bcachefs/btree_io.c +++ b/fs/bcachefs/btree_io.c @@ -1251,7 +1251,7 @@ static void btree_node_read_all_replicas_done(struct closure *cl) bool dump_bset_maps = false; bool have_retry = false; int r...
caaa66aa546a27e75fb3cf32df1906140f85f1c9
Analyze and fix the following issue in the Linux kernel code: bcachefs: Better approach to write vs. read lock deadlocks
Problem Details: Instead of unconditionally upgrading read locks to intent locks in do_bch2_trans_commit(), this patch changes the path that takes write locks to first trylock, and then if trylock fails check if we have a conflicting read lock, and restart the transaction if necessary. Signed-off-by: Kent Overstreet <...
```diff diff --git a/fs/bcachefs/btree_update_leaf.c b/fs/bcachefs/btree_update_leaf.c index 576f0739fdbd..ab5cca892e1a 100644 --- a/fs/bcachefs/btree_update_leaf.c +++ b/fs/bcachefs/btree_update_leaf.c @@ -545,6 +545,54 @@ static inline void normalize_read_intent_locks(struct btree_trans *trans) bch2_trans_verify_lo...
b301105b48d2805ca0e29b1b0f660cf2232511ee
Analyze and fix the following issue in the Linux kernel code: bcachefs: normalize_read_intent_locks
Problem Details: This is a new approach to avoiding the self deadlock we'd get if we tried to take a write lock on a node while holding a read lock - we simply upgrade the readers to intent. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/btree_update_leaf.c b/fs/bcachefs/btree_update_leaf.c index eb4217a3b719..576f0739fdbd 100644 --- a/fs/bcachefs/btree_update_leaf.c +++ b/fs/bcachefs/btree_update_leaf.c @@ -48,14 +48,12 @@ static inline bool same_leaf_as_next(struct btree_trans *trans, insert_l(&i[0])->b == insert_l...
068bcaa589e268fe0bca1f972b3a08a18be8c5dc
Analyze and fix the following issue in the Linux kernel code: bcachefs: Add more assertions for locking btree iterators out of order
Problem Details: btree_path_traverse_all() traverses btree iterators in sorted order, and thus shouldn't see transaction restarts due to potential deadlocks - but sometimes we do. This patch adds some more assertions and tracks some more state to help track this down. Signed-off-by: Kent Overstreet <kent.overstreet@gm...
```diff diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index a856f5e90727..edb4084f7b90 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -17,8 +17,6 @@ #include <linux/prefetch.h> -static inline void btree_trans_sort_paths(struct btree_trans *); - static inline void btree_...
8f54337dc6825f323f7761c182d98efdd180ce70
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix initialization of bch_write_op.nonce
Problem Details: If an extent ends up with a replica that is encrypted an a replica that isn't encrypted (due the user changing options), and then copygc/rebalance moves one of the replicas by reading from the unencrypted replica, we had a bug where we wouldn't correctly initialize op->nonce - for each crc field in an ...
```diff diff --git a/fs/bcachefs/move.c b/fs/bcachefs/move.c index c804af8b81de..3c2e566beb2d 100644 --- a/fs/bcachefs/move.c +++ b/fs/bcachefs/move.c @@ -220,11 +220,6 @@ void bch2_migrate_read_done(struct migrate_write *m, struct bch_read_bio *rbio) m->op.crc = rbio->pick.crc; m->op.wbio.bio.bi_iter.bi_size = m->...
cab8e233734d89cd3c857ee42fe26e49f57d5e75
Analyze and fix the following issue in the Linux kernel code: bcachefs: Add an assertion for removing btree nodes from cache
Problem Details: Chasing a bug that has something to do with the btree node cache. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/btree_cache.c b/fs/bcachefs/btree_cache.c index 354c75f59730..c94ed4da1ca4 100644 --- a/fs/bcachefs/btree_cache.c +++ b/fs/bcachefs/btree_cache.c @@ -129,7 +129,8 @@ struct btree *__bch2_btree_node_mem_alloc(struct bch_fs *c) void bch2_btree_node_hash_remove(struct btree_cache *bc, s...
84841b0d1320c2084facb2f040d6ac0dfced943e
Analyze and fix the following issue in the Linux kernel code: bcachefs: bch2_dump_trans_iters_updates()
Problem Details: This factors out bch2_dump_trans_iters_updates() from the iter alloc overflow path, and makes some small improvements to what it prints. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index ee3b4098fa76..5bb714d1525b 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -2256,33 +2256,30 @@ int bch2_trans_iter_free(struct btree_trans *trans, } noinline __cold -static void btree_trans_iter_alloc_fail(struct...
dc02bed6d9b8c85a8db686fecac5749fbde8cba1
Analyze and fix the following issue in the Linux kernel code: bcachefs: Free iterator if we have duplicate
Problem Details: This helps - but does not fully fix - the outstanding "transaction iterator overflow" bugs. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index f38f231fb296..c97569450741 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -2204,6 +2204,22 @@ static inline void __bch2_trans_iter_free(struct btree_trans *trans, btree_trans_verify_sorted_refs(trans); } +static...
f4ccfe07e20e52a5f6ace9ef995bca1c07a70fac
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix unhandled transaction restart in bch2_gc_btree_gens()
Problem Details: This fixes https://github.com/koverstreet/bcachefs/issues/305 Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/btree_gc.c b/fs/bcachefs/btree_gc.c index 2a84685f4e60..4a3f39a619a1 100644 --- a/fs/bcachefs/btree_gc.c +++ b/fs/bcachefs/btree_gc.c @@ -1736,8 +1736,14 @@ static int bch2_gc_btree_gens(struct bch_fs *c, enum btree_id btree_id) BTREE_ITER_ALL_SNAPSHOTS); while ((bch2_trans_...
fd0bd123d5bc11d665ad0e80eaf4b458619f8b3d
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix 32 bit build failures
Problem Details: This fix replaces multiple 64 bit divisions with do_div() equivalents. Signed-off-by: Brett Holman <bholman.devel@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/buckets.c b/fs/bcachefs/buckets.c index e00c02dcb63e..d7994229ad5a 100644 --- a/fs/bcachefs/buckets.c +++ b/fs/bcachefs/buckets.c @@ -670,7 +670,7 @@ static s64 ptr_disk_sectors(s64 sectors, struct extent_ptr_decoded p) return p.crc.compression_type && p.crc.compression_type != B...
62df3d443c389115f1664676ef75ba0fd157c2a4
Analyze and fix the following issue in the Linux kernel code: bcachefs: Disk space accounting fix
Problem Details: DIV_ROUND_UP() wasn't doing what we wanted when passing it negative numbers - fix it by just not passing it negative numbers anymore. Also, no need to do the scaling by compression ratio for incompressible data. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/buckets.c b/fs/bcachefs/buckets.c index 71900e7e921f..e00c02dcb63e 100644 --- a/fs/bcachefs/buckets.c +++ b/fs/bcachefs/buckets.c @@ -666,7 +666,10 @@ void bch2_mark_metadata_bucket(struct bch_fs *c, struct bch_dev *ca, static s64 ptr_disk_sectors(s64 sectors, struct extent_ptr_decod...
8ddef4d6ccedcd571c9b81f6cd8dff8ddcdb918a
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix a valgrind conditional jump
Problem Details: Valgrind was complaining about a jump depending on uninitialized memory - we weren't, but this change makes the code less confusing for valgrind to follow. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/varint.c b/fs/bcachefs/varint.c index 6955ff5dc19c..e87da470c581 100644 --- a/fs/bcachefs/varint.c +++ b/fs/bcachefs/varint.c @@ -97,7 +97,7 @@ int bch2_varint_encode_fast(u8 *out, u64 v) int bch2_varint_decode_fast(const u8 *in, const u8 *end, u64 *out) { u64 v = get_unaligned_le64...
d2c50773946dfc21021c18c03aa35f1ccb47669a
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix btree_trans_peek_updates()
Problem Details: Should have been using bpos_cmp(), not bkey_cmp(). Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index c14be8093116..fa19ef141252 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -1727,8 +1727,7 @@ static inline bool btree_iter_set_pos_to_prev_leaf(struct btree_iter *iter) return ret; } -static noinline struct bkey...
3737e0ddfbce4791a6415fa685e235b03924ff01
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix an unhandled transaction restart
Problem Details: __bch2_read() -> __bch2_read_extent() -> bch2_bucket_io_time_reset() may cause a transaction restart, which we don't return an error for because it doesn't prevent us from making forward progress on the read we're submitting. Instead, change __bch2_read() and bchfs_read() to check for transaction rest...
```diff diff --git a/fs/bcachefs/fs-io.c b/fs/bcachefs/fs-io.c index 30e5acd2e97c..9ac10b72d1cf 100644 --- a/fs/bcachefs/fs-io.c +++ b/fs/bcachefs/fs-io.c @@ -791,6 +791,15 @@ retry: unsigned bytes, sectors, offset_into_extent; enum btree_id data_btree = BTREE_ID_extents; + /* + * read_extent -> io_time_rese...
877da05ffb13c1a998070707e0d15df0167f9364
Analyze and fix the following issue in the Linux kernel code: bcachefs: Zero out mem_ptr field in btree ptr keys from journal replay
Problem Details: This fixes a bad ptr deref on recovery from unclean shutdown in bch2_btree_node_get_noiter(). Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/recovery.c b/fs/bcachefs/recovery.c index 84e224fb0d01..afb72648fe54 100644 --- a/fs/bcachefs/recovery.c +++ b/fs/bcachefs/recovery.c @@ -39,6 +39,20 @@ static void drop_alloc_keys(struct journal_keys *keys) keys->nr = dst; } +/* + * Btree node pointers have a field to stack a poin...
a32b9573c742c9a9289aa26e0a28d0f9a9c439a4
Analyze and fix the following issue in the Linux kernel code: bcachefs: Add an option for btree node mem ptr optimization
Problem Details: bch2_btree_node_ptr_v2 has a field for stashing a pointer to the in memory btree node; this is safe because we clear this field when reading in nodes from disk and we never free in memory btree nodes - but, we have bug reports that indicate something might be faulty with this optimization, so let's add...
```diff diff --git a/fs/bcachefs/btree_cache.c b/fs/bcachefs/btree_cache.c index 6d5cf2a5a159..818b8df063da 100644 --- a/fs/bcachefs/btree_cache.c +++ b/fs/bcachefs/btree_cache.c @@ -767,9 +767,11 @@ struct btree *bch2_btree_node_get(struct btree_trans *trans, struct btree_iter * EBUG_ON(level >= BTREE_MAX_DEPTH); ...
ed5580b43b083a96fe2cbcf6b1cfe340fa52fca2
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix a btree iterator leak
Problem Details: Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/btree_update_leaf.c b/fs/bcachefs/btree_update_leaf.c index c9de49286fb7..18f4ba1e305c 100644 --- a/fs/bcachefs/btree_update_leaf.c +++ b/fs/bcachefs/btree_update_leaf.c @@ -858,8 +858,10 @@ static int extent_handle_overwrites(struct btree_trans *trans, BTREE_ITER_NOT_EXTENTS|...
eb7f44db8da087e571f82eb7a8b9d9336bee60f1
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fixes for unit tests
Problem Details: The unit tests hadn't been updated for various recent btree changes - this patch makes them work again. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/tests.c b/fs/bcachefs/tests.c index a8b8e3a072ad..9c7812f62935 100644 --- a/fs/bcachefs/tests.c +++ b/fs/bcachefs/tests.c @@ -34,6 +34,7 @@ static int test_delete(struct bch_fs *c, u64 nr) int ret; bkey_cookie_init(&k.k_i); + k.k.p.snapshot = U32_MAX; bch2_trans_init(&trans, c...
71f892a48239a7ec025fdd7f88d252823fe9bff4
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix bch2_btree_iter_rewind()
Problem Details: We'd hit a BUG() when rewinding at the start of the btree on btrees with snapshots. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index 22419929ac1b..745bf48241fd 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -1622,7 +1622,9 @@ inline bool bch2_btree_iter_advance(struct btree_iter *iter) inline bool bch2_btree_iter_rewind(struct btree_iter *iter) ...
5aab66353423f6398975ed9d7174f58628f6eb19
Analyze and fix the following issue in the Linux kernel code: bcachefs: Tighten up btree_iter locking assertions
Problem Details: We weren't correctly verifying that we had interior node intent locks - this patch also fixes bugs uncovered by the new assertions. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/btree_cache.c b/fs/bcachefs/btree_cache.c index 430d5951263f..19afbdcae5e4 100644 --- a/fs/bcachefs/btree_cache.c +++ b/fs/bcachefs/btree_cache.c @@ -698,7 +698,9 @@ static noinline struct btree *bch2_btree_node_fill(struct bch_fs *c, * currently fails for iterators that aren't point...
5468f1195dcfb9256b46484822dde31c9ec0af1e
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix a memory leak in the dio write path
Problem Details: There were some error paths where we were leaking page refs - oops. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/fs-io.c b/fs/bcachefs/fs-io.c index bcf954a2394f..30c12864d537 100644 --- a/fs/bcachefs/fs-io.c +++ b/fs/bcachefs/fs-io.c @@ -1826,8 +1826,6 @@ static long bch2_dio_write_loop(struct dio_write *dio) struct bch_inode_info *inode = file_bch_inode(req->ki_filp); struct bch_fs *c = inod...
9f6e1f7bb0e136871159a71d2bcd31c5dd8cbe81
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix an allocator shutdown deadlock
Problem Details: On fstest generic/388, we were seeing sporadic deadlocks in the emergency shutdown, where we'd get stuck shutting down the allocator because bch2_btree_update_start() -> bch2_btree_reserve_get() allocated and then deallocated some btree nodes, putting them back on the btree_reserve_cache, after the all...
```diff diff --git a/fs/bcachefs/btree_update_interior.c b/fs/bcachefs/btree_update_interior.c index 37dadbae41e5..0b78fb9d3561 100644 --- a/fs/bcachefs/btree_update_interior.c +++ b/fs/bcachefs/btree_update_interior.c @@ -948,13 +948,6 @@ bch2_btree_update_start(struct btree_iter *iter, unsigned level, closure_ini...
2e655e6de202d891f0232cfd3c56b8f8c176cf99
Analyze and fix the following issue in the Linux kernel code: bcachefs: Add open_buckets to sysfs
Problem Details: This is to help debug a rare shutdown deadlock in the allocator code - the btree code is leaking open_buckets. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/alloc_background.c b/fs/bcachefs/alloc_background.c index 15f9adf0876a..fc20649b19cf 100644 --- a/fs/bcachefs/alloc_background.c +++ b/fs/bcachefs/alloc_background.c @@ -1232,3 +1232,22 @@ void bch2_fs_allocator_background_init(struct bch_fs *c) { spin_lock_init(&c->freelist_lock); ...
19d5432445fd0898231063518c375f7551d7c3d2
Analyze and fix the following issue in the Linux kernel code: bcachefs: Really don't hold btree locks while btree IOs are in flight
Problem Details: This is something we've attempted to stick to for quite some time, as it helps guarantee filesystem latency - but there's a few remaining paths that this patch fixes. This is also necessary for an upcoming patch to update btree pointers after every btree write - since the btree write completion path w...
```diff diff --git a/fs/bcachefs/btree_cache.c b/fs/bcachefs/btree_cache.c index 15f597ab03e7..051d2867ad63 100644 --- a/fs/bcachefs/btree_cache.c +++ b/fs/bcachefs/btree_cache.c @@ -187,6 +187,17 @@ static int __btree_node_reclaim(struct bch_fs *c, struct btree *b, bool flush) int ret = 0; lockdep_assert_held(&b...
c21affdd06661c8eb73c71fc54cdb8ec921b968f
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix bch2_btree_iter_peek_slot() assertion
Problem Details: This assertion is checking that what the iterator points to is consistent with iter->real_pos, and since it's an internal btree ordering property it should be using bpos_cmp. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index 8d42feae070a..1592929178bf 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -1859,7 +1859,7 @@ struct bkey_s_c bch2_btree_iter_peek_slot(struct btree_iter *iter) switch (btree_iter_type(iter)) { case BTREE_ITER_K...
a515d0a50c6e8bb9b8ce58d6e396b4c5eeea6905
Analyze and fix the following issue in the Linux kernel code: bcachefs: Enforce SYS_CAP_ADMIN within ioctls
Problem Details: bch2_fs_ioctl() didn't distinguish between unsupported ioctls and those which the current user is unauthorised to perform. That kept the code simple but meant that, for example, an unprivileged TIOCGWINSZ ioctl on a bcachefs file would return -EPERM instead of the expected -ENOTTY. The same call made ...
```diff diff --git a/fs/bcachefs/chardev.c b/fs/bcachefs/chardev.c index 99f112072ae5..c1d8143b3fd8 100644 --- a/fs/bcachefs/chardev.c +++ b/fs/bcachefs/chardev.c @@ -157,6 +157,9 @@ static long bch2_ioctl_query_uuid(struct bch_fs *c, #if 0 static long bch2_ioctl_start(struct bch_fs *c, struct bch_ioctl_start arg) {...
508b1f71396486648e3d42d1814e7f148fbb7751
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix bch2_btree_iter_peek_prev()
Problem Details: In !BTREE_ITER_IS_EXTENTS mode, we shouldn't be looking at k->size, i.e. we shouldn't use bkey_start_pos(). Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index cf26da1ab895..31d8c89ae255 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -1779,7 +1779,7 @@ struct bkey_s_c bch2_btree_iter_peek_prev(struct btree_iter *iter) if (!k.k || ((iter->flags & BTREE_ITER_IS_EXTE...
31029f2f70e6abc833ceefb0f32adf4e7bf42235
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix bch2_acl_chmod() cleanup on error
Problem Details: Avoid calling kfree on the returned error pointer if bch2_acl_from_disk fails. Signed-off-by: Dan Robertson <dan@dlrobertson.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/acl.c b/fs/bcachefs/acl.c index be31d27443bc..1642518d3233 100644 --- a/fs/bcachefs/acl.c +++ b/fs/bcachefs/acl.c @@ -372,7 +372,7 @@ int bch2_acl_chmod(struct btree_trans *trans, acl = bch2_acl_from_disk(xattr_val(xattr.v), le16_to_cpu(xattr.v->x_val_len)); ret = PTR_ERR_OR_ZER...
fdc6b08451167bfc1ae260b252ad2bf2f9735f50
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix shift-by-64 in bch2_bkey_format_validate()
Problem Details: We need to ensure that packed formats can't represent fields larger than the unpacked format, which is a bit tricky since the calculations can also overflow a u64. This patch fixes a shift and simplifies the overall calculations. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/bkey.c b/fs/bcachefs/bkey.c index 5de88a93f33f..3e62eeb6774e 100644 --- a/fs/bcachefs/bkey.c +++ b/fs/bcachefs/bkey.c @@ -623,22 +623,22 @@ const char *bch2_bkey_format_validate(struct bkey_format *f) if (f->nr_fields != BKEY_NR_FIELDS) return "incorrect number of fields"; + /* +...
78d66ab1ca541ba95a9ad89780466398b348c230
Analyze and fix the following issue in the Linux kernel code: bcachefs: fix truncate without a size change
Problem Details: Do not attempt to shortcut a truncate when the given new size is the same as the current size. There may be blocks allocated to the file that extend beyond the i_size. The ctime and mtime should not be updated in this case. Signed-off-by: Dan Robertson <dan@dlrobertson.com> Signed-off-by: Kent Overstr...
```diff diff --git a/fs/bcachefs/fs-io.c b/fs/bcachefs/fs-io.c index a25c3b70ef74..bcf954a2394f 100644 --- a/fs/bcachefs/fs-io.c +++ b/fs/bcachefs/fs-io.c @@ -2305,16 +2305,17 @@ int bch2_truncate(struct mnt_idmap *idmap, int ret = 0; /* - * Don't update timestamps if we're not doing anything: + * If the trunca...
6f152b0f375450b72724b6eb2ec00f7669fc910e
Analyze and fix the following issue in the Linux kernel code: bcachefs: fix ifdef for x86_64 asm
Problem Details: The implementation of prefetch_four_cachelines should use ifdef CONFIG_X86_64 to conditionally compile x86_64 asm. Signed-off-by: Dan Robertson <dan@dlrobertson.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/bset.c b/fs/bcachefs/bset.c index 84c4664c9912..9484f28be6de 100644 --- a/fs/bcachefs/bset.c +++ b/fs/bcachefs/bset.c @@ -1181,7 +1181,7 @@ static struct bkey_packed *bset_search_write_set(const struct btree *b, static inline void prefetch_four_cachelines(void *p) { -#if CONFIG_X86_...
729608a606fdef3dc97762081442d7b4a40d16a4
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix unused variable warning when !BCACHEFS_DEBUG
Problem Details: Signed-off-by: Christopher James Halse Rogers <raof@ubuntu.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index e9351632cc03..cf26da1ab895 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -1549,7 +1549,9 @@ struct btree *bch2_btree_iter_next_node(struct btree_iter *iter) static void btree_iter_set_search_pos(struct btree_iter...
50ad5d097977dc5c688e7a1a6dc2e74c37da5adf
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix btree_node_read_all_replicas() error handling
Problem Details: We weren't checking bch2_btree_node_read_done() for errors, oops. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/btree_io.c b/fs/bcachefs/btree_io.c index 4ffdc11f4d9a..6274211d09f1 100644 --- a/fs/bcachefs/btree_io.c +++ b/fs/bcachefs/btree_io.c @@ -1187,31 +1187,27 @@ static void btree_node_read_all_replicas_done(struct closure *cl) container_of(cl, struct btree_node_read_all, cl); struct b...
68a507a2e8cdc9b90599bb5d220a696abdc54838
Analyze and fix the following issue in the Linux kernel code: bcachefs: fix truncate with ATTR_MODE
Problem Details: After the v5.12 rebase, we started oopsing when truncate was passed ATTR_MODE, due to not passing mnt_userns to setattr_copy(). This refactors things so that truncate/extend finish by using bch2_setattr_nonsize(), which solves the problem. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/fs-io.c b/fs/bcachefs/fs-io.c index 0ffc3971d1b2..a25c3b70ef74 100644 --- a/fs/bcachefs/fs-io.c +++ b/fs/bcachefs/fs-io.c @@ -2252,11 +2252,11 @@ static int bch2_truncate_page(struct bch_inode_info *inode, loff_t from) from, round_up(from, PAGE_SIZE)); } -static int bch2_ext...
2ed5cd508d0b893ded6a1ba586f7c6cd7a95cc36
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix a memory leak in dio write path
Problem Details: Commit c42bca92be928ce7dece5fc04cf68d0e37ee6718 "bio: don't copy bvec for direct IO" changed bio_iov_iter_get_pages() to point bio->bi_iovec at the incoming biovec, meaning if we already allocated one, it'll be leaked. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/fs-io.c b/fs/bcachefs/fs-io.c index 132ff0497b39..e39e22581e4b 100644 --- a/fs/bcachefs/fs-io.c +++ b/fs/bcachefs/fs-io.c @@ -2025,7 +2025,9 @@ ssize_t bch2_direct_write(struct kiocb *req, struct iov_iter *iter) } bio = bio_alloc_bioset(NULL, - iov_iter_npages(iter, BIO_M...
120f63e321fa9fdb1837dd64fcd50e2b144b0d6d
Analyze and fix the following issue in the Linux kernel code: bcachefs: fix a possible bcachefs checksum mapping error opt-checksum enum to type-checksum enum
Problem Details: This fixes some rare cases where the metadata checksum option specified may map to the wrong actual checksum type. Signed-off-by: Janpieter Sollie <janpieter.sollie@edpnet.be> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/super-io.c b/fs/bcachefs/super-io.c index fc6fb302706a..403e77e2c515 100644 --- a/fs/bcachefs/super-io.c +++ b/fs/bcachefs/super-io.c @@ -684,7 +684,7 @@ static void write_one_super(struct bch_fs *c, struct bch_dev *ca, unsigned idx) sb->offset = sb->layout.sb_offset[idx]; - SET_B...
044c8c9e05bc87cdc610eb320e8fdc694f3866df
Analyze and fix the following issue in the Linux kernel code: bcachefs: mount: fix null deref with null devname
Problem Details: - Fix null deref on mount when given a null device name. - Move the dev_name checks to return EINVAL when it is invalid. Signed-off-by: Dan Robertson <dan@dlrobertson.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/fs.c b/fs/bcachefs/fs.c index 99885fb97aa2..efb467316756 100644 --- a/fs/bcachefs/fs.c +++ b/fs/bcachefs/fs.c @@ -1325,9 +1325,6 @@ static char **split_devs(const char *_dev_name, unsigned *nr) char *dev_name = NULL, **devs = NULL, *s; size_t i, nr_devs = 0; - if (strlen(_dev_name...
a49e9a0589d1828af787bacf0a1e18eca7facb88
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix null ptr deref when splitting compressed extents
Problem Details: Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index d9ce82e04e76..0dd7938101a5 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -2329,6 +2329,7 @@ void bch2_trans_reset(struct btree_trans *trans, unsigned flags) trans->iters_touched &= trans->iters_live; + trans->...
90d22a660a4ed5e1500602f15edcb91ab38a1e7c
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix overflow in journal_replay_entry_early
Problem Details: If filesystem on disk was used by a version with a larger BCH_DATA_NR thas the currently running version, we don't want this to cause a buffer overrun. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/recovery.c b/fs/bcachefs/recovery.c index 9bd6348842e0..f32414171aab 100644 --- a/fs/bcachefs/recovery.c +++ b/fs/bcachefs/recovery.c @@ -725,7 +725,7 @@ static int journal_replay_entry_early(struct bch_fs *c, ca->usage_base->buckets_ec = le64_to_cpu(u->buckets_ec); ca->usage_bas...
59ba21d99fc7a19d32fc4c2cb21509b8876d8e01
Analyze and fix the following issue in the Linux kernel code: bcachefs: Clean up key merging
Problem Details: This patch simplifies the key merging code by getting rid of partial merges - it's simpler and saner if we just don't merge extents when they'd overflow k->size. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/bkey_methods.c b/fs/bcachefs/bkey_methods.c index cf2e054cca2f..ff9d770aabea 100644 --- a/fs/bcachefs/bkey_methods.c +++ b/fs/bcachefs/bkey_methods.c @@ -84,7 +84,7 @@ static void key_type_inline_data_to_text(struct printbuf *out, struct bch_fs *c, .val_to_text = key_type_inline_data_...
74cc1abdbf50fcdaedf4bcf9a800c575ec44e17a
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix a buffer overrun
Problem Details: In make_extent_indirect(), we were allocating too small of a buffer for the new indirect extent. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/reflink.c b/fs/bcachefs/reflink.c index a420729288d4..6aa37726341d 100644 --- a/fs/bcachefs/reflink.c +++ b/fs/bcachefs/reflink.c @@ -138,7 +138,7 @@ static int bch2_make_extent_indirect(struct btree_trans *trans, /* rewind iter to start of hole, if necessary: */ bch2_btree_iter_set...
224ec3e677ca82eb4216a0916ce7b04f401e90e7
Analyze and fix the following issue in the Linux kernel code: bcachefs: Don't mark superblocks past end of usable space
Problem Details: bcachefs-tools recently started putting a backup superblock at the end of the device. This causes a problem if the bucket size doesn't divide the device size - but we can fix it by just skipping marking that part. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/buckets.c b/fs/bcachefs/buckets.c index c9e299706c74..db8c3b7f5fa1 100644 --- a/fs/bcachefs/buckets.c +++ b/fs/bcachefs/buckets.c @@ -635,6 +635,12 @@ void bch2_mark_metadata_bucket(struct bch_fs *c, struct bch_dev *ca, BUG_ON(type != BCH_DATA_sb && type != BCH_DATA_journal);...
7138f220973307d4f130eec33e4cb3f571a0f413
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix a spurious debug mode assertion
Problem Details: When we switched to using bch2_btree_bset_insert_key() for extents it turned out it started leaving invalid keys around - of type deleted but nonzero size - but this is fine (if ugly) because they're never written out. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index 7246519b3250..17338410d1fe 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -846,7 +846,14 @@ static inline struct bkey_s_c __btree_iter_unpack(struct btree_iter *iter, ret = bkey_disassemble(l->b, k, u); - if (b...
ca47fa236278312e1931b303416a79863f80936b
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix unitialized use of a value
Problem Details: Signed-off-by: Brett Holman <bpholman5@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/replicas.c b/fs/bcachefs/replicas.c index 5a8b0a7b7197..64fdf53a630a 100644 --- a/fs/bcachefs/replicas.c +++ b/fs/bcachefs/replicas.c @@ -442,6 +442,8 @@ static int __bch2_mark_bkey_replicas(struct bch_fs *c, struct bkey_s_c k, unsigned i; int ret; + memset(&search, 0, sizeof(sear...
66a0a49750d77926a6d4b47d7ac1f4904094fb7e
Analyze and fix the following issue in the Linux kernel code: bcachefs: btree_iter->should_be_locked
Problem Details: Add a field to struct btree_iter for tracking whether it should be locked - this fixes spurious transaction restarts in bch2_trans_relock(). Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index 78eae2169347..7246519b3250 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -463,12 +463,20 @@ void bch2_trans_downgrade(struct btree_trans *trans) /* Btree transaction locking: */ +static inline bool btree_iter_s...
d7fc453bdb012d5bc021e693896989fd5973823f
Analyze and fix the following issue in the Linux kernel code: bcachefs: Journal space calculation fix
Problem Details: When devices have different bucket sizes, we may accumulate a journal write that doesn't fit on some of our devices - previously, we'd underflow when calculating space on that device and then everything would get weird. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/journal_reclaim.c b/fs/bcachefs/journal_reclaim.c index 812620d3de31..54d8e2f32a37 100644 --- a/fs/bcachefs/journal_reclaim.c +++ b/fs/bcachefs/journal_reclaim.c @@ -93,6 +93,10 @@ journal_dev_space_available(struct journal *j, struct bch_dev *ca, * until we write it out - thus, acco...
649d9a4dfc834230b55c4ae34b60067d1d54c4d1
Analyze and fix the following issue in the Linux kernel code: bcachefs: Don't fragment extents when making them indirect
Problem Details: This fixes a "disk usage increased without a reservation" bug, when reflinking compressed extents. Also, there's no good reason for reflink to be fragmenting extents anyways. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/reflink.c b/fs/bcachefs/reflink.c index e986b5284d37..a420729288d4 100644 --- a/fs/bcachefs/reflink.c +++ b/fs/bcachefs/reflink.c @@ -181,18 +181,19 @@ err: static struct bkey_s_c get_next_src(struct btree_iter *iter, struct bpos end) { - struct bkey_s_c k = bch2_btree_iter_peek(ite...
c0ebe3e48c75ab075eb1c67aef957109c67e1643
Analyze and fix the following issue in the Linux kernel code: bcachefs: Assorted endianness fixes
Problem Details: Found by sparse Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index 745f1ac4f538..4b590b2096a7 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -2268,6 +2268,7 @@ static void bch2_trans_alloc_iters(struct btree_trans *trans, struct bch_fs *c) void bch2_trans_init(struct btree_trans *t...
ee7570546e89ece9b56eaa22c94a6ec0941ec827
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix a deadlock
Problem Details: Waiting on a btree node write with btree locks held can deadlock, if the write errors: the write error path has to do do a btree update to drop the pointer to the replica that errored. The interior update path has to wait on in flight btree writes before freeing nodes on disk. Previously, this was don...
```diff diff --git a/fs/bcachefs/btree_io.c b/fs/bcachefs/btree_io.c index 0f2a730e04b5..4ffdc11f4d9a 100644 --- a/fs/bcachefs/btree_io.c +++ b/fs/bcachefs/btree_io.c @@ -1727,6 +1727,10 @@ void __bch2_btree_node_write(struct bch_fs *c, struct btree *b) return; if (old & (1 << BTREE_NODE_write_in_flight)) { + ...
bff796ae6539b50bb3fe595e8db7b72e3255a34d
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix pathalogical behaviour with inode sharding by cpu ID
Problem Details: If the transactior restarts on a different CPU, it could end up needing to read in a different btree node, which makes another transaction restart more likely... Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/fs-common.c b/fs/bcachefs/fs-common.c index 08c6af886df7..00a63fecb976 100644 --- a/fs/bcachefs/fs-common.c +++ b/fs/bcachefs/fs-common.c @@ -23,6 +23,7 @@ int bch2_create_trans(struct btree_trans *trans, u64 dir_inum, struct btree_iter *inode_iter = NULL; struct bch_hash_info hash ...
d797ca3d8ed3b493d6558426fb4b4980ff186c37
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix journal write error path
Problem Details: Journal write errors were racing with the submission path - potentially causing writes to other replicas to not get submitted. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/journal_io.c b/fs/bcachefs/journal_io.c index 66a0e44a21a6..e42ca2a5e201 100644 --- a/fs/bcachefs/journal_io.c +++ b/fs/bcachefs/journal_io.c @@ -1232,8 +1232,6 @@ static void journal_write_done(struct closure *cl) struct journal *j = container_of(cl, struct journal, io); struct bch...
9eba7c8d15ce236b8033ae1f50fc1168984a507b
Analyze and fix the following issue in the Linux kernel code: bcachefs: Reflink refcount fix
Problem Details: __bch2_trans_mark_reflink_p wasn't always correctly returning the number of sectors processed - the new logic is a bit more straightforward overall too. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/buckets.c b/fs/bcachefs/buckets.c index 6389ec7ba18b..b452ff003e6c 100644 --- a/fs/bcachefs/buckets.c +++ b/fs/bcachefs/buckets.c @@ -1735,6 +1735,7 @@ static int __bch2_trans_mark_reflink_p(struct btree_trans *trans, struct bkey_i *n; __le64 *refcount; int add = !(flags & BTREE_T...
b282a74faebc9475355179aff40b98b5dbe0ae01
Analyze and fix the following issue in the Linux kernel code: bcachefs: Add an option to control sharding new inode numbers
Problem Details: We're seeing a bug where inode creates end up spinning in bch2_inode_create - disabling sharding will simplify what we're testing. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/bcachefs_format.h b/fs/bcachefs/bcachefs_format.h index 98a87e4928ab..6cfb8959d579 100644 --- a/fs/bcachefs/bcachefs_format.h +++ b/fs/bcachefs/bcachefs_format.h @@ -1348,6 +1348,7 @@ LE64_BITMASK(BCH_SB_GC_RESERVE_BYTES, struct bch_sb, flags[2], 4, 64); LE64_BITMASK(BCH_SB_ERASURE_...
c4d4b2f01abd95af7c6dccf236e2760aef5a9b69
Analyze and fix the following issue in the Linux kernel code: bcachefs: Add a cond_resched call to the copygc main loop
Problem Details: We seem to have a bug where the copygc thread ends up spinning and making the system unusable - this will at least prevent it from locking up the machine, and it's a good thing to have anyways. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/movinggc.c b/fs/bcachefs/movinggc.c index acb4d943db79..e8f9d70af930 100644 --- a/fs/bcachefs/movinggc.c +++ b/fs/bcachefs/movinggc.c @@ -317,6 +317,8 @@ static int bch2_copygc_thread(void *arg) set_freezable(); while (!kthread_should_stop()) { + cond_resched(); + if (kthread_...
443d2760e51f3e17ddb47ddaf969ba49e6dbd06d
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix a null ptr deref
Problem Details: bch2_btree_iter_peek() won't always return a key - whoops. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/move.c b/fs/bcachefs/move.c index bce10eb4eb4c..8807b18ddc43 100644 --- a/fs/bcachefs/move.c +++ b/fs/bcachefs/move.c @@ -522,6 +522,11 @@ static int lookup_inode(struct btree_trans *trans, struct bpos pos, if (ret) goto err; + if (!k.k || bkey_cmp(k.k->p, pos)) { + ret = -ENOEN...
9dd89a05fd946869c23e12fcfb9b9643b337fd56
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix an issue with inconsistent btree writes after unclean shutdown
Problem Details: After unclean shutdown, btree writes may have completed on one device and not others - and this inconsistency could lead us to writing new bsets with a gap in our btree node in one of our replicas. Fortunately, this is only an issue with bsets that are newer than the most recent journal flush, and we ...
```diff diff --git a/fs/bcachefs/btree_io.c b/fs/bcachefs/btree_io.c index 4d06e765a777..18d12c012cc6 100644 --- a/fs/bcachefs/btree_io.c +++ b/fs/bcachefs/btree_io.c @@ -824,6 +824,7 @@ int bch2_btree_node_read_done(struct bch_fs *c, struct bch_dev *ca, bool updated_range = b->key.k.type == KEY_TYPE_btree_ptr_v2 && ...
1ce0cf5fe9300f28e834e6fa001cc5a114cd0493
Analyze and fix the following issue in the Linux kernel code: bcachefs: Add a debug mode that always reads from every btree replica
Problem Details: There's a new module parameter, verify_all_btree_replicas, that enables reading from every btree replica when reading in btree nodes and comparing them against each other. We've been seeing some strange btree corruption - this will hopefully aid in tracking it down and catching it more often. Signed-o...
```diff diff --git a/fs/bcachefs/bcachefs.h b/fs/bcachefs/bcachefs.h index c5cafbd6d87a..3de62571fb9f 100644 --- a/fs/bcachefs/bcachefs.h +++ b/fs/bcachefs/bcachefs.h @@ -264,7 +264,10 @@ do { \ BCH_DEBUG_PARAM(verify_btree_ondisk, \ "Reread btree nodes at various points to verify the " \ "mergesort ...
304b7e08c72ee20f315142047ee4e133102ab911
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix an uninitialized var
Problem Details: this fixes a valgrind complaint Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/btree_update_interior.c b/fs/bcachefs/btree_update_interior.c index ea522b4583fd..ea1b09b36059 100644 --- a/fs/bcachefs/btree_update_interior.c +++ b/fs/bcachefs/btree_update_interior.c @@ -286,6 +286,7 @@ static struct btree *bch2_btree_node_alloc(struct btree_update *as, unsigned lev ...
a6336910b1c30703fe0d5078ef1c656ea1d39096
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix for buffered writes getting -ENOSPC
Problem Details: Buffered writes may have to increase their disk reservation at btree update time, due to compression and erasure coding being unpredictable: O_DIRECT writes should be checking for -ENOSPC, but buffered writes have already been accepted and should not. Signed-off-by: Kent Overstreet <kent.overstreet@gm...
```diff diff --git a/fs/bcachefs/btree_update_leaf.c b/fs/bcachefs/btree_update_leaf.c index cc844ca81bcc..3c4bf13d4ef9 100644 --- a/fs/bcachefs/btree_update_leaf.c +++ b/fs/bcachefs/btree_update_leaf.c @@ -690,6 +690,7 @@ int bch2_trans_commit_error(struct btree_trans *trans, } break; case BTREE_INSERT_ENOSPC:...
16ac8c9523a2744545bb773b41433a5007deeacb
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix inode backpointers in RENAME_OVERWRITE
Problem Details: 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>
```diff diff --git a/fs/bcachefs/dirent.c b/fs/bcachefs/dirent.c index ec4666143f23..3bf6379cefe6 100644 --- a/fs/bcachefs/dirent.c +++ b/fs/bcachefs/dirent.c @@ -210,6 +210,8 @@ int bch2_dirent_rename(struct btree_trans *trans, if (mode != BCH_RENAME) *dst_inum = le64_to_cpu(bkey_s_c_to_dirent(old_dst).v->d_inu...
c21d5377791d94fca0d990eee82111572412640c
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix for bch2_bkey_pack_pos() not initializing len/version fields
Problem Details: This bug led to push_whiteout() generating whiteouts that failed bch2_bkey_invalid() due to nonzero length fields - oops. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/bkey.c b/fs/bcachefs/bkey.c index a0379f980f7e..5de88a93f33f 100644 --- a/fs/bcachefs/bkey.c +++ b/fs/bcachefs/bkey.c @@ -446,8 +446,15 @@ enum bkey_pack_pos_ret bch2_bkey_pack_pos_lossy(struct bkey_packed *out, struct bpos orig = in; #endif bool exact = true; + unsigned i; - *w ...
82355e2882339067e1d6deaec68e629f63259c0d
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix a memcpy call
Problem Details: Not supposed to pass a null ptr to memcpy (even if the size is 0). Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/fsck.c b/fs/bcachefs/fsck.c index fcdcf42f85a4..a40459d2b0f0 100644 --- a/fs/bcachefs/fsck.c +++ b/fs/bcachefs/fsck.c @@ -1161,7 +1161,8 @@ static int add_nlink(struct nlink_table *t, u64 inum, u32 snapshot) return -ENOMEM; } - memcpy(d, t->d, t->size * sizeof(t->d[0])); + if...
bbfcb4519d61cdd83d1f9741e4f8525c0ffa8a8a
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix bch2_extent_can_insert() call
Problem Details: It was being skipped when hole punching, leading to problems when splitting compressed extents. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/btree_update_leaf.c b/fs/bcachefs/btree_update_leaf.c index 2e7b9210564d..fbe6a17ffd8a 100644 --- a/fs/bcachefs/btree_update_leaf.c +++ b/fs/bcachefs/btree_update_leaf.c @@ -806,13 +806,13 @@ static int extent_update_to_keys(struct btree_trans *trans, { int ret; - if (bkey_deleted(...