id
stringlengths
40
40
instruction
stringlengths
68
308
input
stringlengths
17
33.4k
output
stringlengths
100
30k
2cd0563461b68b895bd683e89ad70f3975e98e85
Analyze and fix the following issue in the Linux kernel code: bcachefs: made changes to support clang, fixed a couple bugs
Problem Details: fs/bcachefs/bset.c edited prefetch macro to add clang support fs/bcachefs/btree_iter.c bugfix: initialize iter->real_pos in bch2_btree_iter_init for later use fs/bcachefs/io.c bugfix: eliminated undefined behavior (negative bitshift) fs/bcachefs/buckets.c bu...
```diff diff --git a/fs/bcachefs/bset.c b/fs/bcachefs/bset.c index 8c038da3c108..e569d9a9b906 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) { -#ifdef CONFIG_X...
6ebe32b94c77f80aca235e476bad321ecc355035
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix locking in __bch2_set_nr_journal_buckets()
Problem Details: We weren't holding mark_lock correctly - it's needed for the new_fs path. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/journal.c b/fs/bcachefs/journal.c index a7cc0b167072..7cbea06f57fd 100644 --- a/fs/bcachefs/journal.c +++ b/fs/bcachefs/journal.c @@ -804,8 +804,11 @@ static int __bch2_set_nr_journal_buckets(struct bch_dev *ca, unsigned nr, long b; if (new_fs) { + if (c) + percpu_down_read...
d125615a4e22194dff9cecd12ec5a608f8c0f920
Analyze and fix the following issue in the Linux kernel code: bcachefs: properly initialize used values
Problem Details: - Ensure the second key value in bch_hash_info is initialized to zero if the info type is of type BCH_STR_HASH_SIPHASH. - Initialize the possibly returned value in bch2_inode_create. Assuming bch2_btree_iter_peek returns bkey_s_c_null, the uninitialized value of ret could be returned to the ...
```diff diff --git a/fs/bcachefs/buckets.c b/fs/bcachefs/buckets.c index 8806e8306e4e..dad1c7d27bab 100644 --- a/fs/bcachefs/buckets.c +++ b/fs/bcachefs/buckets.c @@ -1646,8 +1646,8 @@ static int bch2_trans_mark_stripe(struct btree_trans *trans, struct bkey_s_c old, struct bkey_s_c new, unsigned flags) {...
faf1a5f41772984d492f9805ded9a34dcdce724d
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix out of bounds read in fs usage ioctl
Problem Details: Fix a possible read out of bounds if bch2_ioctl_fs_usage is called when replica_entries_bytes is set to a value that is smaller than the size of bch_replicas_usage. Signed-off-by: Dan Robertson <dan@dlrobertson.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/chardev.c b/fs/bcachefs/chardev.c index b0cbbb70161d..99f112072ae5 100644 --- a/fs/bcachefs/chardev.c +++ b/fs/bcachefs/chardev.c @@ -414,7 +414,8 @@ static long bch2_ioctl_fs_usage(struct bch_fs *c, struct bch_replicas_entry *src_e = cpu_replicas_entry(&c->replicas, i); - if ...
2b25de552f8a8d9cae5b54c83137c67e03ee1957
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix null deref in bch2_ioctl_read_super
Problem Details: Do not attempt to cleanup the returned value of bch2_device_lookup if the returned value was an error pointer. We currently check to see if the returned value is null and run the cleanup otherwise. As a result, we attempt to run the cleanup on a error pointer. Signed-off-by: Dan Robertson <dan@dlrober...
```diff diff --git a/fs/bcachefs/chardev.c b/fs/bcachefs/chardev.c index 34085e32a159..b0cbbb70161d 100644 --- a/fs/bcachefs/chardev.c +++ b/fs/bcachefs/chardev.c @@ -523,7 +523,7 @@ static long bch2_ioctl_read_super(struct bch_fs *c, ret = copy_to_user((void __user *)(unsigned long)arg.sb, sb, vstruct_bytes(s...
ec4ab9d2fc08132113dc5d45ac68af2158377122
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix possible null deref on mount
Problem Details: Ensure that the block device pointer in a superblock handle is not null before dereferencing it in bch2_dev_to_fs. The block device pointer may be null when mounting a new bcachefs filesystem given another mounted bcachefs filesystem exists that has at least one device that is offline. Signed-off-by: ...
```diff diff --git a/fs/bcachefs/super.c b/fs/bcachefs/super.c index 9065e264c567..71493b5ff695 100644 --- a/fs/bcachefs/super.c +++ b/fs/bcachefs/super.c @@ -117,7 +117,7 @@ struct bch_fs *bch2_dev_to_fs(dev_t dev) list_for_each_entry(c, &bch_fs_list, list) for_each_member_device_rcu(ca, c, i, NULL) - if (ca-...
baf056b87da88b0c9812d53f8b12072652d1c07b
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix error in parsing of mount options
Problem Details: When parsing the mount options duplicate the given options. This is required as the options are parsed twice and strsep is used in parsing. The options will be modified into a possibly invalid options set for the second round of parsing if the options are not duplicated before parsing. Signed-off-by: ...
```diff diff --git a/fs/bcachefs/opts.c b/fs/bcachefs/opts.c index 0cfbb56a57c1..64bf5a382d63 100644 --- a/fs/bcachefs/opts.c +++ b/fs/bcachefs/opts.c @@ -315,11 +315,20 @@ int bch2_opts_check_may_set(struct bch_fs *c) int bch2_parse_mount_opts(struct bch_fs *c, struct bch_opts *opts, char *options) { + char *c...
ffcf9ec78c133fb85ff13d8119ff404e11820834
Analyze and fix the following issue in the Linux kernel code: bcachefs: avoid out-of-bounds in split_devs
Problem Details: Calling mount with an empty source string causes an out-of-bounds error in split_devs. Check the length of the source string to avoid this. Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/fs.c b/fs/bcachefs/fs.c index b00f35201132..5eef67358cfb 100644 --- a/fs/bcachefs/fs.c +++ b/fs/bcachefs/fs.c @@ -32,6 +32,7 @@ #include <linux/random.h> #include <linux/seq_file.h> #include <linux/statfs.h> +#include <linux/string.h> #include <linux/xattr.h> static struct kmem_c...
360746bf6f7cae871a683e1718bedba6a29f10dc
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix bch2_btree_iter_peek_with_updates()
Problem Details: By not re-fetching the next update we were going into an infinite loop. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.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 525afe3509ec..8c343d5cec0c 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -1618,16 +1618,17 @@ static struct bkey_i *btree_trans_peek_updates(struct btree_trans *trans, static inline struct bkey_s_c __btree_iter_pee...
933532b8b25cd7b739f30d66a0e9fcc9e03d57ec
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix reflink trigger
Problem Details: The trigger for reflink pointers wasn't always incrementing/decrementing the refcounts correctly - this patch fixes that logic. Signed-off-by: Kent Overstreet <kent.overstreet@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 a83d5de87d39..8806e8306e4e 100644 --- a/fs/bcachefs/buckets.c +++ b/fs/bcachefs/buckets.c @@ -1710,9 +1710,28 @@ static __le64 *bkey_refcount(struct bkey_i *k) } } +static bool reflink_p_frag_references(struct bkey_s_c_reflink_p p, + ...
3a402c8dabf11142d78d0f6174b50db6ba846c4e
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix some refcounting bugs
Problem Details: We really need debug mode assertions that ca->ref and ca->io_ref are used correctly. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/alloc_background.c b/fs/bcachefs/alloc_background.c index 996b1afd1380..791066b6b39b 100644 --- a/fs/bcachefs/alloc_background.c +++ b/fs/bcachefs/alloc_background.c @@ -371,7 +371,7 @@ int bch2_alloc_write(struct bch_fs *c, unsigned flags) ret = bch2_alloc_write_key(&trans, iter,...
5bc38f44fa8e938044bb3b69c8881f3682fe97f6
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix oob write in __bch2_btree_node_write
Problem Details: Fix a possible out of bounds write in __bch2_btree_node_write when the data buffer padding is cleared up to the block size. The out of bounds write is possible if the data buffers size is not a multiple of the block size. Signed-off-by: Dan Robertson <dan@dlrobertson.com> Signed-off-by: Kent Overstree...
```diff diff --git a/fs/bcachefs/btree_io.c b/fs/bcachefs/btree_io.c index 389524ce1fb6..dbaa05ac764c 100644 --- a/fs/bcachefs/btree_io.c +++ b/fs/bcachefs/btree_io.c @@ -1500,6 +1500,9 @@ void __bch2_btree_node_write(struct bch_fs *c, struct btree *b) /* bch2_varint_decode may read up to 7 bytes past the end of the ...
1784d43a88ecf0da66514f4b7f0f52b4182ef81c
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix usage of last_seq + encryption
Problem Details: jset->last_seq is in the region that's encrypted - on journal write completion, we were using it and getting garbage. This patch shadows it to fix. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/journal.c b/fs/bcachefs/journal.c index a70540853586..a7cc0b167072 100644 --- a/fs/bcachefs/journal.c +++ b/fs/bcachefs/journal.c @@ -189,7 +189,8 @@ static bool __journal_entry_close(struct journal *j) * Hence, we want update/set last_seq on the current journal entry right * befo...
595c1e9bab7fd5512250d0e297e50a549af59b1f
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix time handling
Problem Details: There were some overflows in the time conversion functions - fix this by converting tv_sec and tv_nsec separately. Also, set sb->time_min and sb->time_max. Fixes xfstest generic/258. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/bcachefs.h b/fs/bcachefs/bcachefs.h index 323705f352de..c47e69931b8a 100644 --- a/fs/bcachefs/bcachefs.h +++ b/fs/bcachefs/bcachefs.h @@ -605,11 +605,13 @@ struct bch_fs { u64 time_base_lo; u32 time_base_hi; - u32 time_precision; + unsigned time_units_per_sec; + unsigned n...
050197b1c1df1cfee84523bf2183c8674e06d10f
Analyze and fix the following issue in the Linux kernel code: bcachefs: Ensure that fpunch updates inode timestamps
Problem Details: Fixes xfstests generic/059 Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> 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 a7cd85647354..fbf171a4c191 100644 --- a/fs/bcachefs/fs-io.c +++ b/fs/bcachefs/fs-io.c @@ -2407,6 +2407,15 @@ err: /* fallocate: */ +static int inode_update_times_fn(struct bch_inode_info *inode, + struct bch_inode_unpacked *bi, void *p) +{ + ...
d4b4422345fcb4e284260bd52166e189c137e846
Analyze and fix the following issue in the Linux kernel code: bcachefs: Change copygc wait amount to be min of per device waits
Problem Details: We're seeing a filesystem get stuck when all devices but one have no more reclaimable buckets - because the copygc wait amount is curretly filesystem wide. This patch should fix that, possibly at the expensive of running too much when only one or a few devices is full and the rebalance thread needs to...
```diff diff --git a/fs/bcachefs/movinggc.c b/fs/bcachefs/movinggc.c index f9146ccd70ef..acb4d943db79 100644 --- a/fs/bcachefs/movinggc.c +++ b/fs/bcachefs/movinggc.c @@ -293,17 +293,19 @@ unsigned long bch2_copygc_wait_amount(struct bch_fs *c) { struct bch_dev *ca; unsigned dev_idx; - u64 fragmented_allowed = 0, ...
3dea728ce64bdd3c8c5e98cb7b8a148d52c8f0d4
Analyze and fix the following issue in the Linux kernel code: bcachefs: New tracepoint for bch2_trans_get_iter()
Problem Details: Trying to debug an issue where after traverse_all() we shouldn't have to traverse any iterators... yet we are Signed-off-by: Kent Overstreet <kent.overstreet@gmail.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 757e5650f33c..525afe3509ec 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -2020,6 +2020,13 @@ struct btree_iter *__bch2_trans_get_iter(struct btree_trans *trans, unsigned flags) { struct btree_iter *iter, *...
d36cdb045aa7029f8495d18760da6c944ab95cb3
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix __bch2_trans_get_iter()
Problem Details: We need to also set iter->uptodate to indicate it needs to be traversed. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.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 11f7b47e3e7f..757e5650f33c 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -2085,15 +2085,16 @@ struct btree_iter *__bch2_trans_get_iter(struct btree_trans *trans, btree_iter_get_locks(iter, true, false); } - w...
ceda1b9a179ffd8ece3f7d15d5b1379eb2552215
Analyze and fix the following issue in the Linux kernel code: bcachefs: Evict btree nodes we're deleting
Problem Details: There was a bug that led to duplicate btree node pointers being inserted at the wrong level. The new topology repair code can fix that, except that the btree cache code gets confused when we read in a btree node from the pointer that was at the wrong level. This patch evicts nodes that we're deleting t...
```diff diff --git a/fs/bcachefs/btree_cache.c b/fs/bcachefs/btree_cache.c index a42e0922f5e9..85c19e4e5216 100644 --- a/fs/bcachefs/btree_cache.c +++ b/fs/bcachefs/btree_cache.c @@ -948,6 +948,36 @@ void bch2_btree_node_prefetch(struct bch_fs *c, struct btree_iter *iter, bch2_btree_node_fill(c, iter, k, btree_id, le...
e3b4b48c17a0f749f2786e756714a56316a519b3
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix a null ptr deref
Problem Details: Fix a few memory safety issues, found by asan in userspace. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/fsck.c b/fs/bcachefs/fsck.c index 1ce038846476..b867576b3ffd 100644 --- a/fs/bcachefs/fsck.c +++ b/fs/bcachefs/fsck.c @@ -290,21 +290,24 @@ static int hash_redo_key(struct btree_trans *trans, struct bch_hash_info *hash_info, struct btree_iter *k_iter, struct bkey_s_c k) { - s...
4932e07ea04bcc7f1649052183d1ebbab30c711c
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix key cache assertion
Problem Details: Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/bcachefs.h b/fs/bcachefs/bcachefs.h index dc7b78b7e2a2..64a9094ec748 100644 --- a/fs/bcachefs/bcachefs.h +++ b/fs/bcachefs/bcachefs.h @@ -489,6 +489,7 @@ enum { BCH_FS_FSCK_DONE, BCH_FS_STARTED, BCH_FS_RW, + BCH_FS_WAS_RW, /* shutdown: */ BCH_FS_STOPPING, diff --git a/fs/bca...
8058b532ac3bb5a0cec80056fde8a4669de2b551
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix bch2_verify_keylist_sorted
Problem Details: Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/keylist.c b/fs/bcachefs/keylist.c index 864dfaa67b7a..cda77835b9ea 100644 --- a/fs/bcachefs/keylist.c +++ b/fs/bcachefs/keylist.c @@ -62,6 +62,6 @@ void bch2_verify_keylist_sorted(struct keylist *l) for_each_keylist_key(l, k) BUG_ON(bkey_next(k) != l->top && - bkey_cmp(k-...
bc2e5d5c6636f6a5794e4ed306fb008b02e6f419
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix an out of bounds read
Problem Details: bch2_varint_decode() can read up to 7 bytes past the end of the buffer, which means we need to allocate slightly larger key cache buffers. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/btree_key_cache.c b/fs/bcachefs/btree_key_cache.c index 0716c3314a36..019d4d164553 100644 --- a/fs/bcachefs/btree_key_cache.c +++ b/fs/bcachefs/btree_key_cache.c @@ -219,8 +219,14 @@ static int btree_key_cache_fill(struct btree_trans *trans, goto err; } - if (k.k->u64s > ck->u64s...
537c32f5212396751bf39b10d71af60af32dc257
Analyze and fix the following issue in the Linux kernel code: bcachefs: Don't BUG_ON() btree topology error
Problem Details: This replaces an assertion in the btree merge path with a bch2_inconsistent_error() - fsck will fix it. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/btree_cache.c b/fs/bcachefs/btree_cache.c index cc703c2602cf..5a5eb99baefa 100644 --- a/fs/bcachefs/btree_cache.c +++ b/fs/bcachefs/btree_cache.c @@ -686,6 +686,41 @@ static int lock_node_check_fn(struct six_lock *lock, void *p) return b->hash_val == btree_ptr_hash_val(k) ? 0 : -1; }...
1c8441bea5366ec1e4f077ab675b49a603d7cad8
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix repair leading to replicas not marked
Problem Details: bch2_check_fix_ptrs() was being called after checking if the replicas set was marked - but repair could change which replicas set needed to be marked. Oops. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/btree_gc.c b/fs/bcachefs/btree_gc.c index a7ffd566d431..6983a1197905 100644 --- a/fs/bcachefs/btree_gc.c +++ b/fs/bcachefs/btree_gc.c @@ -330,6 +330,10 @@ static int bch2_gc_mark_key(struct bch_fs *c, enum btree_id btree_id, BUG_ON(bch2_journal_seq_verify && k->k->version.l...
eb365fbc333519651bed300eb866f26dbc1efd05
Analyze and fix the following issue in the Linux kernel code: bcachefs: Don't BUG() in update_replicas
Problem Details: Apparently, we have a bug where in mark and sweep while accounting for a key, a replicas entry isn't found. Change the code to print out the key we couldn't mark and halt instead of a BUG_ON(). Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@l...
```diff diff --git a/fs/bcachefs/buckets.c b/fs/bcachefs/buckets.c index b51f311ad60e..e6e984587b5d 100644 --- a/fs/bcachefs/buckets.c +++ b/fs/bcachefs/buckets.c @@ -399,20 +399,22 @@ static void bch2_dev_usage_update(struct bch_fs *c, struct bch_dev *ca, bch2_wake_allocator(ca); } -static inline void update_rep...
f09517fc5136ad2ea67b6f332ed2445f053ccfe6
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix a deadlock on journal reclaim
Problem Details: Flushing the btree key cache needs to use allocation reserves - journal reclaim depends on flushing the btree key cache for making forward progress, and the allocator and copygc depend on journal reclaim making forward progress. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by:...
```diff diff --git a/fs/bcachefs/btree_key_cache.c b/fs/bcachefs/btree_key_cache.c index ac844f47b8dd..0716c3314a36 100644 --- a/fs/bcachefs/btree_key_cache.c +++ b/fs/bcachefs/btree_key_cache.c @@ -386,12 +386,18 @@ retry: goto evict; } + /* + * Since journal reclaim depends on us making progress here, and the...
6adaac0b95dd39da290f6006822fbf7560d2d1b5
Analyze and fix the following issue in the Linux kernel code: bcachefs: Update bch2_btree_verify()
Problem Details: bch2_btree_verify() verifies that the btree node on disk matches what we have in memory. This patch changes it to verify every replica, and also fixes it for interior btree nodes - there's a mem_ptr field which is used as a scratch space and needs to be zeroed out for comparing with what's on disk. Si...
```diff diff --git a/fs/bcachefs/bcachefs.h b/fs/bcachefs/bcachefs.h index 55e40b3acb90..dc7b78b7e2a2 100644 --- a/fs/bcachefs/bcachefs.h +++ b/fs/bcachefs/bcachefs.h @@ -259,7 +259,11 @@ do { \ BCH_DEBUG_PARAM(btree_gc_rewrite_disabled, \ "Disables rewriting of btree nodes during mark and sweep")\ BCH...
7b7278bbaf2a5d2e6955d763a8a30a3ba190dc10
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix two btree iterator leaks
Problem Details: Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/ec.c b/fs/bcachefs/ec.c index 370f9e6916f3..7d681a7254c4 100644 --- a/fs/bcachefs/ec.c +++ b/fs/bcachefs/ec.c @@ -1621,6 +1621,7 @@ int bch2_stripes_write(struct bch_fs *c, unsigned flags) if (ret) break; } + bch2_trans_iter_put(&trans, iter); bch2_trans_exit(&trans); dif...
4d47b21c4dac0d27ad02add2c68be0afaa63ef98
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix a use after free
Problem Details: Turns out, we weren't waiting on in flight btree writes when freeing existing btree nodes. This lead to stray btree writes overwriting newly allocated buckets, but only started showing itself with some of the recent allocator work and another patch to move submitting of btree writes to worqueues. Sign...
```diff diff --git a/fs/bcachefs/btree_update_interior.c b/fs/bcachefs/btree_update_interior.c index b3137525f9c1..dabd1a3e3aa3 100644 --- a/fs/bcachefs/btree_update_interior.c +++ b/fs/bcachefs/btree_update_interior.c @@ -887,6 +887,14 @@ void bch2_btree_interior_update_will_free_node(struct btree_update *as, btree_...
8ce600d44720a86c069fafefc92167ed85cc72c7
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix for btree_gc repairing interior btree ptrs
Problem Details: Using the normal transaction commit path to insert and journal updates to interior nodes hadn't been done before this repair code was written, not surprising that there was a bug. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/btree_update_leaf.c b/fs/bcachefs/btree_update_leaf.c index 6e26531eb671..96b53effded7 100644 --- a/fs/bcachefs/btree_update_leaf.c +++ b/fs/bcachefs/btree_update_leaf.c @@ -307,8 +307,7 @@ btree_key_can_insert_cached(struct btree_trans *trans, } static inline void do_btree_insert_o...
27cc532ef2d7c3bc4687547f59fe5d4a82affab7
Analyze and fix the following issue in the Linux kernel code: bcachefs: Check that keys are in the correct btrees
Problem Details: We've started seeing bug reports of pointers to btree nodes being detected in leaf nodes. This should catch that before it's happened, and it's something we should've been checking anyways. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux...
```diff diff --git a/fs/bcachefs/bkey_methods.c b/fs/bcachefs/bkey_methods.c index 6fe95b802e13..cf2e054cca2f 100644 --- a/fs/bcachefs/bkey_methods.c +++ b/fs/bcachefs/bkey_methods.c @@ -98,12 +98,51 @@ const char *bch2_bkey_val_invalid(struct bch_fs *c, struct bkey_s_c k) return bch2_bkey_ops[k.k->type].key_invalid(...
f02810a1a4cdcf643f6149396769e0fb38a94a78
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix an unused var warning in userspace
Problem Details: Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/fsck.c b/fs/bcachefs/fsck.c index 4a48ef5d1bfb..cfe606342032 100644 --- a/fs/bcachefs/fsck.c +++ b/fs/bcachefs/fsck.c @@ -159,13 +159,10 @@ static int reattach_inode(struct btree_trans *trans, struct bch_inode_unpacked *lostfound, u64 inum) { - struct bch_fs *c = trans->c; ...
f24fab9cbad1838fc4356e9e8b861a19cf055c3f
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix some small memory leaks
Problem Details: Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/fsck.c b/fs/bcachefs/fsck.c index e6036d36e0f9..4a48ef5d1bfb 100644 --- a/fs/bcachefs/fsck.c +++ b/fs/bcachefs/fsck.c @@ -1124,6 +1124,8 @@ static int check_directory_structure(struct bch_fs *c, BUG_ON(ret == -EINTR); + kfree(path.entries); + return bch2_trans_exit(&trans) ?: re...
5e6a668b19614c44819c4b0f7691da92df973384
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix transaction restarts due to upgrading of cloned iterators
Problem Details: This fixes a regression from 52d86202fd bcachefs: Improve bch2_btree_iter_traverse_all() We want to avoid mucking with other iterators in the btree transaction in operations that are only supposed to be touching individual iterators - that patch was a cleanup to move lock ordering handling to bch2_b...
```diff diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index f82976aab7d9..11f7b47e3e7f 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -387,11 +387,44 @@ bool bch2_btree_iter_relock(struct btree_iter *iter, bool trace) bool __bch2_btree_iter_upgrade(struct btree_iter *iter, ...
96f399d0eed9a63e706c045407675622f32f5a5d
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix journal reclaim loop
Problem Details: When dirty key cache keys were separated from other journal pins, we broke the loop conditional in __bch2_journal_reclaim() - it's supposed to keep looping as long as there's work to do. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.de...
```diff diff --git a/fs/bcachefs/journal_reclaim.c b/fs/bcachefs/journal_reclaim.c index 0d7fe1f99dbf..e2086c76d104 100644 --- a/fs/bcachefs/journal_reclaim.c +++ b/fs/bcachefs/journal_reclaim.c @@ -599,7 +599,7 @@ static int __bch2_journal_reclaim(struct journal *j, bool direct) struct bch_fs *c = container_of(j, st...
3e07a7300f0684f7c77485e65a1ae97c7ab2514f
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix an RCU splat
Problem Details: Writepoints are never deallocated so the rcu_read_lock() isn't really needed, but we are doing lockless list traversal. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/alloc_foreground.c b/fs/bcachefs/alloc_foreground.c index 4834ac798b9e..56b114888e49 100644 --- a/fs/bcachefs/alloc_foreground.c +++ b/fs/bcachefs/alloc_foreground.c @@ -683,11 +683,14 @@ static struct write_point *__writepoint_find(struct hlist_head *head, { struct write_point *wp; ...
d62ab355d7475a0da3267c8376ef436ba92f72c1
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix bch2_trans_mark_dev_sb()
Problem Details: Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/alloc_background.c b/fs/bcachefs/alloc_background.c index a8a59140efbe..c115c76b2197 100644 --- a/fs/bcachefs/alloc_background.c +++ b/fs/bcachefs/alloc_background.c @@ -254,9 +254,9 @@ void bch2_alloc_to_text(struct printbuf *out, struct bch_fs *c, { struct bkey_alloc_unpacked u = b...
558509aa0198b9c062ff7b91bf8feb74513e0965
Analyze and fix the following issue in the Linux kernel code: bcachefs: Don't downgrade iterators in bch2_trans_get_iter()
Problem Details: This fixes a livelock with btree node splits. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.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 c7a0ffc2cad5..dabf0e18c1ff 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -2038,13 +2038,18 @@ struct btree_iter *__bch2_trans_get_iter(struct btree_trans *trans, iter->snapshot = pos.snapshot; - locks_want = m...
2527dd91580b1eb5ff1f8df1b47817ac60395830
Analyze and fix the following issue in the Linux kernel code: bcachefs: Improve bch2_btree_iter_traverse_all()
Problem Details: By changing it to upgrade iterators to intent locks to avoid lock restarts we can simplify __bch2_btree_node_lock() quite a bit - this fixes a probable bug where it could potentially drop a lock on an unrelated error but still succeed instead of causing a transaction restart. Signed-off-by: Kent Overs...
```diff diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index 7d8b7d765cf7..c7a0ffc2cad5 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -268,13 +268,8 @@ bool __bch2_btree_node_lock(struct btree *b, struct bpos pos, */ if (type == SIX_LOCK_intent && linked->nodes_...
0ef107859bc868f783cbbbf055a907c702896661
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix journal_reclaim_wait_done()
Problem Details: Can't run arbitrary code inside a wait_event() conditional, due to task state being weird... Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/btree_update_leaf.c b/fs/bcachefs/btree_update_leaf.c index 9a747b420180..21a26987f975 100644 --- a/fs/bcachefs/btree_update_leaf.c +++ b/fs/bcachefs/btree_update_leaf.c @@ -629,25 +629,11 @@ static inline int do_bch2_trans_commit(struct btree_trans *trans, static int journal_reclaim...
1b9374adecea64244b0c67aa27e032feae1f1bca
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix bch2_gc_done() error messages
Problem Details: Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/btree_gc.c b/fs/bcachefs/btree_gc.c index b61d27de5cd7..068cfbb2c489 100644 --- a/fs/bcachefs/btree_gc.c +++ b/fs/bcachefs/btree_gc.c @@ -828,7 +828,7 @@ static int bch2_gc_done(struct bch_fs *c, if (dst->b[b].mark._f != src->b[b].mark._f) { \ if (verify) \ fsck_err(c, "...
e949fbbba0dce7cd80f7c2e932c289d3717c9759
Analyze and fix the following issue in the Linux kernel code: bcachefs: Ensure bucket gen gc completes
Problem Details: We don't want it to block, if it can't allocate it should just continue instead of possibly deadlocking. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/btree_gc.c b/fs/bcachefs/btree_gc.c index 9f47db77c66b..c14794cf1be8 100644 --- a/fs/bcachefs/btree_gc.c +++ b/fs/bcachefs/btree_gc.c @@ -1181,7 +1181,7 @@ static int bch2_gc_btree_gens(struct bch_fs *c, enum btree_id btree_id) struct btree_iter *iter; struct bkey_s_c k; struct bk...
319c1305071c3ac813c3ea9eed15d1a0d26f983a
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix heap overrun in bch2_fs_usage_read() XXX squash
Problem Details: oops Signed-off-by: Kent Overstreet <kent.overstreet@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 7093737a02f3..4791f4896d6b 100644 --- a/fs/bcachefs/buckets.c +++ b/fs/bcachefs/buckets.c @@ -224,7 +224,7 @@ u64 bch2_fs_usage_read_one(struct bch_fs *c, u64 *v) struct bch_fs_usage_online *bch2_fs_usage_read(struct bch_fs *c) { struct bch_fs...
d3ff7fec9c604e2cac3d0126f6764c5c0392a271
Analyze and fix the following issue in the Linux kernel code: bcachefs: Improved check_directory_structure()
Problem Details: Now that we have inode backpointers, we can simplify checking directory structure: instead of doing a DFS from the filesystem root and then checking if we found everything, we can iterate over every inode and see if we can go up until we get to the root. This patch also has a number of fixes and simpl...
```diff diff --git a/fs/bcachefs/btree_update.h b/fs/bcachefs/btree_update.h index 4ce12ae29a55..0c7caa7e91a0 100644 --- a/fs/bcachefs/btree_update.h +++ b/fs/bcachefs/btree_update.h @@ -103,13 +103,12 @@ static inline int bch2_trans_commit(struct btree_trans *trans, return __bch2_trans_commit(trans); } -#define _...
176cf4bf59014d03be6cef33cabb677d2117dbb2
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix fsck to not use bch2_link_trans()
Problem Details: bch2_link_trans() uses the btree key cache for inode updates, and fsck isn't supposed to - also, it's not really what we want for reattaching unreachable inodes anyways. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/fsck.c b/fs/bcachefs/fsck.c index 6bc3f2f09e36..d7d26fb40432 100644 --- a/fs/bcachefs/fsck.c +++ b/fs/bcachefs/fsck.c @@ -128,22 +128,63 @@ static int remove_dirent(struct btree_trans *trans, __remove_dirent(trans, dirent)); } -static int reattach_inode(struct bch_fs *c, -...
b69ac13cb39176634f1dd924dfabe2e282615d41
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix bch2_trans_relock()
Problem Details: The patch that changed bch2_trans_relock() to not look at iter->uptodate also tried to add an optimization by only having it relock btree_iter_key() iterators (iterators that are live or have been marked as keep). But, this wasn't thought through - this pops internal iterator assertions because on tran...
```diff diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index ae2e907adc73..033a079fb3f3 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -472,8 +472,7 @@ bool bch2_trans_relock(struct btree_trans *trans) struct btree_iter *iter; trans_for_each_iter(trans, iter) - if (btre...
d7f35163e61d962132539e38be89330834a8455b
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix BTREE_ITER_NOT_EXTENTS
Problem Details: bch2_btree_iter_peek() wasn't properly checking for BTREE_ITER_IS_EXTENTS when updating iter->pos. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/btree_gc.c b/fs/bcachefs/btree_gc.c index f810ad410cd1..bf40efcaa192 100644 --- a/fs/bcachefs/btree_gc.c +++ b/fs/bcachefs/btree_gc.c @@ -1243,7 +1243,7 @@ int bch2_gc_gens(struct bch_fs *c) } for (i = 0; i < BTREE_ID_NR; i++) - if (btree_node_type_needs_gc(i)) { + if ((1 << i) ...
0e96452eef51f32417d2abdb1806474083da5979
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix bch2_gc_btree_gens()
Problem Details: Since we're using a NOT_EXTENTS iterator, we shouldn't be setting the iter pos to the start of the extent. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/btree_gc.c b/fs/bcachefs/btree_gc.c index 2f93c9cc757d..f810ad410cd1 100644 --- a/fs/bcachefs/btree_gc.c +++ b/fs/bcachefs/btree_gc.c @@ -1197,8 +1197,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...
2177147b39098e6f08b3d8d45bbcf7dedd7ebdad
Analyze and fix the following issue in the Linux kernel code: bcachefs: Improve bset compaction
Problem Details: The previous patch that fixed btree nodes being written too aggressively now meant that we weren't sorting btree node bsets optimally - this patch fixes that. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/btree_cache.c b/fs/bcachefs/btree_cache.c index 2ec668c3427e..8ed8610796fb 100644 --- a/fs/bcachefs/btree_cache.c +++ b/fs/bcachefs/btree_cache.c @@ -215,7 +215,7 @@ static int __btree_node_reclaim(struct bch_fs *c, struct btree *b, bool flush) if (bch2_verify_btree_ondisk) bch2_...
f72b1fd710870547f566d7d02563833eda43e67d
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix a startup race
Problem Details: Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/btree_key_cache.c b/fs/bcachefs/btree_key_cache.c index 74d982c3402a..0af46335bd00 100644 --- a/fs/bcachefs/btree_key_cache.c +++ b/fs/bcachefs/btree_key_cache.c @@ -692,17 +692,16 @@ int bch2_fs_btree_key_cache_init(struct btree_key_cache *bc) struct bch_fs *c = container_of(bc, stru...
ecc1420944c73205225ed6fe4c1781c09759dd10
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix an uninitialized variable
Problem Details: Fortunately it was just used in an error message Signed-off-by: Kent Overstreet <kent.overstreet@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 47a1b8b12eb9..7093737a02f3 100644 --- a/fs/bcachefs/buckets.c +++ b/fs/bcachefs/buckets.c @@ -852,7 +852,7 @@ static int mark_stripe_bucket(struct bch_fs *c, struct bkey_s_c k, if (g->stripe && g->stripe != k.k->p.offset) { bch2_fs_inconsiste...
9c2e624290f24c69c835bc82b1abe349810e338f
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix livelock calling bch2_mark_bkey_replicas()
Problem Details: The bug was that we were trying to find a replicas entry that wasn't sorted - but, we can also simplify the code by not using bch2_mark_bkey_replicas and instead ensuring the list of replicas entries exists directly. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overst...
```diff diff --git a/fs/bcachefs/btree_update_leaf.c b/fs/bcachefs/btree_update_leaf.c index ee1c26f2901f..54e3850df009 100644 --- a/fs/bcachefs/btree_update_leaf.c +++ b/fs/bcachefs/btree_update_leaf.c @@ -707,11 +707,9 @@ int bch2_trans_commit_error(struct btree_trans *trans, case BTREE_INSERT_NEED_MARK_REPLICAS: ...
6167f7c8ff5ce564423fe8b416b5f95d1712859b
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix journal deadlock
Problem Details: After we get a journal reservation, we need to use it - if we erorr out of a transaction commit, we'll be eating into space in the journal and if our transaction needs to make forward progress in order to reclaim space in the journal, we'll deadlock. Signed-off-by: Kent Overstreet <kent.overstreet@gma...
```diff diff --git a/fs/bcachefs/btree_update_leaf.c b/fs/bcachefs/btree_update_leaf.c index 592f9516d4e7..d3d86aa0ee95 100644 --- a/fs/bcachefs/btree_update_leaf.c +++ b/fs/bcachefs/btree_update_leaf.c @@ -426,6 +426,14 @@ bch2_trans_commit_write_locked(struct btree_trans *trans, fs_usage = bch2_fs_usage_scratch_ge...
b753d4b338df70df1ee75db21a216385bb88b90b
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix this_cpu_ptr() usage
Problem Details: Signed-off-by: Kent Overstreet <kent.overstreet@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 88deb48a3a37..4c2485afe43c 100644 --- a/fs/bcachefs/buckets.c +++ b/fs/bcachefs/buckets.c @@ -1392,7 +1392,7 @@ static int bch2_fs_usage_apply(struct bch_fs *c, struct disk_reservation *disk_res, unsigned journal_seq) { - st...
2d587674bad9cf83db0cc43185eb7e2d913cf41f
Analyze and fix the following issue in the Linux kernel code: bcachefs: Increase commality between BTREE_ITER_NODES and BTREE_ITER_KEYS
Problem Details: Eventually BTREE_ITER_NODES should be going away. This patch is to fix a transaction iterator overflow in the btree node merge path because BTREE_ITER_NODES iterators couldn't be reused. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.de...
```diff diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index 50712c99d2bd..74094f5e67d2 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -432,25 +432,24 @@ bool __bch2_btree_iter_upgrade(struct btree_iter *iter, } void __bch2_btree_iter_downgrade(struct btree_iter *iter, - ...
2fa81d0b5bfdcd9c90725474ab9443f13152dfd8
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix BTREE_FOREGROUND_MERGE_HYSTERESIS
Problem Details: We were multiplying instead of dividing - oops. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/btree_cache.h b/fs/bcachefs/btree_cache.h index aa8fe4a1b04b..4791c3b64452 100644 --- a/fs/bcachefs/btree_cache.h +++ b/fs/bcachefs/btree_cache.h @@ -89,7 +89,7 @@ static inline unsigned btree_blocks(struct bch_fs *c) #define BTREE_FOREGROUND_MERGE_THRESHOLD(c) (btree_max_u64s(c) * 1 /...
1259cc31b23221feae5e49cc02eaf7cfb7df9f54
Analyze and fix the following issue in the Linux kernel code: bcachefs: Change where merging of interior btree nodes is trigger from
Problem Details: Previously, we were doing btree node merging from bch2_btree_insert_node() - but this is called from the split path, when we're in the middle of creating new nodes and deleting new nodes and the iterators are in a weird state. Also, this means we're starting a new btree_update while in the middle of a...
```diff diff --git a/fs/bcachefs/btree_update_interior.c b/fs/bcachefs/btree_update_interior.c index b8e37de19d06..fddb0c3e7167 100644 --- a/fs/bcachefs/btree_update_interior.c +++ b/fs/bcachefs/btree_update_interior.c @@ -1505,14 +1505,6 @@ void bch2_btree_insert_node(struct btree_update *as, struct btree *b, bch2_b...
5f65d74d791d9bc07de05d4fa4ed5bb075e07873
Analyze and fix the following issue in the Linux kernel code: bcachefs: Add repair code for out of order keys in a btree node.
Problem Details: This just drops the offending key - in the bug report where this was seen, it was clearly a single bit memory error, and fsck will fix the missing key. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/btree_io.c b/fs/bcachefs/btree_io.c index bc09f9377425..fc94782afb60 100644 --- a/fs/bcachefs/btree_io.c +++ b/fs/bcachefs/btree_io.c @@ -578,6 +578,10 @@ static int validate_bset(struct bch_fs *c, struct bch_dev *ca, mutex_unlock(&c->sb_lock); } + btree_err_on(BSET_SEPARATE_WHIT...
f793fd85dc598616ff903750b2a6d63425c23b2f
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix for bch2_trans_commit() unlocking when it's not supposed to
Problem Details: When we pass BTREE_INSERT_NOUNLOCK bch2_trans_commit isn't supposed to unlock after a successful commit, but it was calling bch2_trans_cond_resched() - oops. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.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 cf41ece0d66e..fb7614367e1c 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -2155,7 +2155,8 @@ void bch2_trans_reset(struct btree_trans *trans, unsigned flags) (void *) &trans->fs_usage_deltas->memset_start);...
3bf57160c23d507a46c1a7a4a453405d21ac0d7c
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix packed bkey format calculation for new btree roots
Problem Details: Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/btree_gc.c b/fs/bcachefs/btree_gc.c index 36ed6df39768..9e2f93c2adc2 100644 --- a/fs/bcachefs/btree_gc.c +++ b/fs/bcachefs/btree_gc.c @@ -1311,6 +1311,9 @@ static void bch2_coalesce_nodes(struct bch_fs *c, struct btree_iter *iter, /* Find a format that all keys in @old_nodes can pack ...
c7e04e22e000d3d9c2c0ed00cd444b3b8a26cf1a
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix building of aux search trees
Problem Details: We weren't packing the min/max keys, which was a major oversight and completely disabled generating bkey_floats for adjacent nodes. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/bset.c b/fs/bcachefs/bset.c index 59f613560b65..34fd2307a320 100644 --- a/fs/bcachefs/bset.c +++ b/fs/bcachefs/bset.c @@ -674,16 +674,20 @@ static void make_bfloat(struct btree *b, struct bset_tree *t, if (is_power_of_2(j) && !min_key->u64s) { - k = (void *) min_key; - bkey_...
2da5d000b91e0407dedc3baa35cf7c36a0392ff2
Analyze and fix the following issue in the Linux kernel code: bcachefs: Generate better bkey formats when splitting nodes
Problem Details: On btree node split, we weren't ensuring the min_key of the new larger node packs in the new format for this node. This triggers some painful slowpaths in the bset.c aux search tree code - this patch fixes that by calculating a new format for the new node with the new min_key. Signed-off-by: Kent Over...
```diff diff --git a/fs/bcachefs/btree_update_interior.c b/fs/bcachefs/btree_update_interior.c index c5e0516ff1fb..3cd431eb3fe7 100644 --- a/fs/bcachefs/btree_update_interior.c +++ b/fs/bcachefs/btree_update_interior.c @@ -1095,10 +1095,11 @@ static struct btree *__btree_split_node(struct btree_update *as, struct...
5c1ec980f9984983c90dd08754ad2c28fec1acf1
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix iterator picking
Problem Details: comparison was wrong Signed-off-by: Kent Overstreet <kent.overstreet@gmail.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 6e860d47da4f..97d806011bfd 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -2058,7 +2058,7 @@ struct btree_iter *__bch2_trans_get_iter(struct btree_trans *trans, continue; if (best && - bkey_cmp(bpos_dif...
50dc0f692a0dbe3e6a95d3f8e5c7e718bc9f021d
Analyze and fix the following issue in the Linux kernel code: bcachefs: Require all btree iterators to be freed
Problem Details: 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>
```diff diff --git a/fs/bcachefs/acl.c b/fs/bcachefs/acl.c index 3879815bcede..afb9562be2b2 100644 --- a/fs/bcachefs/acl.c +++ b/fs/bcachefs/acl.c @@ -241,12 +241,12 @@ retry: } xattr = bkey_s_c_to_xattr(bch2_btree_iter_peek_slot(iter)); - acl = bch2_acl_from_disk(xattr_val(xattr.v), le16_to_cpu(xattr.v->x_...
dbb93db9721e8d94e3d1a3c2217fc6265aace811
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix btree iterator leak in extent_handle_overwrites()
Problem Details: Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/btree_update_leaf.c b/fs/bcachefs/btree_update_leaf.c index bf2a2b0695b6..f8b493706c94 100644 --- a/fs/bcachefs/btree_update_leaf.c +++ b/fs/bcachefs/btree_update_leaf.c @@ -754,7 +754,7 @@ static int extent_handle_overwrites(struct btree_trans *trans, enum btree_id btree_id, ...
57447b7acccac0b7d75846ecfdfcd5a3421de3d0
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> 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 35480ba43621..70828d8876f9 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -1992,7 +1992,7 @@ static void btree_trans_iter_alloc_fail(struct btree_trans *trans) char buf[100]; trans_for_each_iter(trans, iter) - ...
5ff75ccbbc3f262158e5bf02c639539a4da93a43
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix read retry path for indirect extents
Problem Details: In the read path, for retry of indirect extents to work we need to differentiate between the location in the btree the read was for, vs. the location where we found the data. This patch adds that plumbing to bch_read_bio. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent O...
```diff diff --git a/fs/bcachefs/fs-io.c b/fs/bcachefs/fs-io.c index 4ccc9318a924..8584b90a3df9 100644 --- a/fs/bcachefs/fs-io.c +++ b/fs/bcachefs/fs-io.c @@ -788,6 +788,7 @@ retry: while (1) { struct bkey_s_c k; unsigned bytes, sectors, offset_into_extent; + enum btree_id data_btree = BTREE_ID_extents; b...
53b3e3c0e2f14f661cd61bbc9b82dc9383f783b9
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix locking in bch2_btree_iter_traverse_cached()
Problem Details: bch2_btree_iter_traverse() is supposed to ensure we have the correct type of lock - it was downgrading if necessary, but if we entered with a read lock it wasn't upgrading to an intent lock, oops. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstree...
```diff diff --git a/fs/bcachefs/btree_key_cache.c b/fs/bcachefs/btree_key_cache.c index 6dc13fa3d1f4..76f19f86c8ad 100644 --- a/fs/bcachefs/btree_key_cache.c +++ b/fs/bcachefs/btree_key_cache.c @@ -298,7 +298,14 @@ fill: set_bit(BKEY_CACHED_ACCESSED, &ck->flags); iter->uptodate = BTREE_ITER_NEED_PEEK; - bch2_bt...
7d6f07edc28c3c34bad7e6a92921e3fbf8c8dd4e
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix compat code for superblock
Problem Details: The bkey compat code wasn't being run for btree roots in the superblock clean section - this patch fixes it to use the journal entry validate code. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/bcachefs_format.h b/fs/bcachefs/bcachefs_format.h index 17cc6131de0c..5d0e340c4dcb 100644 --- a/fs/bcachefs/bcachefs_format.h +++ b/fs/bcachefs/bcachefs_format.h @@ -1314,6 +1314,7 @@ LE64_BITMASK(BCH_SB_PRJQUOTA, struct bch_sb, flags[0], 59, 60); LE64_BITMASK(BCH_SB_HAS_ERRORS, stru...
61a19ce4255abd1133d4e7cd64a6cfa40d1f37fa
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix bpos_diff()
Problem Details: Previously, bpos_diff() did not handle borrows correctly. Minor thing considering how it was used, but worth fixing. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/bkey.h b/fs/bcachefs/bkey.h index 25cb5e985109..77d9d871adfb 100644 --- a/fs/bcachefs/bkey.h +++ b/fs/bcachefs/bkey.h @@ -183,6 +183,37 @@ static inline struct bpos bpos_max(struct bpos l, struct bpos r) return bkey_cmp(l, r) > 0 ? l : r; } +#define sbb(a, b, borrow) \ +do { ...
c043a3303c11cdf53ee98db67cee11931b626e22
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix bch2_btree_cache_scan()
Problem Details: It was counting nodes on the freed list that it skips - because we want to leave a few so that btree splits don't touch the allocator - as nodes that it touched, meaning that if it was called with <= 3 nodes to reclaim, and those nodes were on the freed list, it would never do any work. Signed-off-by:...
```diff diff --git a/fs/bcachefs/btree_cache.c b/fs/bcachefs/btree_cache.c index 2152813554b4..97b4f87a377f 100644 --- a/fs/bcachefs/btree_cache.c +++ b/fs/bcachefs/btree_cache.c @@ -281,13 +281,19 @@ static unsigned long bch2_btree_cache_scan(struct shrinker *shrink, i = 0; list_for_each_entry_safe(b, t, &bc->fr...
2ee47eec44f0613d6c51d88f8c820a5e8ed624a3
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix for copygc getting stuck waiting for reserve to be filled
Problem Details: This fixes a regression from the patch bcachefs: Fix copygc dying on startup In general only the allocator thread itself should be updating ca->allocator_state, the thread waking up the allocator setting it is an ugly hack only needed to avoid racing with the copygc threads when we're first starting...
```diff diff --git a/fs/bcachefs/alloc_background.h b/fs/bcachefs/alloc_background.h index 73e1c27c96e3..ad15a80602c0 100644 --- a/fs/bcachefs/alloc_background.h +++ b/fs/bcachefs/alloc_background.h @@ -100,10 +100,8 @@ static inline void bch2_wake_allocator(struct bch_dev *ca) rcu_read_lock(); p = rcu_dereferenc...
cb66fc5fe4cc806d60d8884cb82b67c357b49640
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix copygc threshold
Problem Details: Awhile back the meaning of is_available_bucket() and thus also bch_dev_usage->buckets_unavailable changed to include buckets that are owned by the allocator - this was so that the stat could be persisted like other allocation information, and wouldn't have to be regenerated by walking each bucket at mo...
```diff diff --git a/fs/bcachefs/alloc_background.c b/fs/bcachefs/alloc_background.c index f2117084f2fe..f603fd347d58 100644 --- a/fs/bcachefs/alloc_background.c +++ b/fs/bcachefs/alloc_background.c @@ -46,7 +46,7 @@ static void pd_controllers_update(struct work_struct *work) struct bch_dev_usage stats = bch2_dev_us...
d065472c3a7966b5104cce6901f329250f629758
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix a use-after-free in bch2_gc_mark_key()
Problem Details: bch2_check_fix_ptrs() can update/reallocate k Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/btree_gc.c b/fs/bcachefs/btree_gc.c index 12f77ff4de62..f7a5bd9eca0b 100644 --- a/fs/bcachefs/btree_gc.c +++ b/fs/bcachefs/btree_gc.c @@ -281,10 +281,10 @@ fsck_err: static int bch2_gc_mark_key(struct bch_fs *c, enum btree_id btree_id, unsigned level, bool is_root, - st...
98f2197de49b8eb038909e709c79c13178022dda
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix bch2_write_super to obey very_degraded option
Problem Details: Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> 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 ce370cf2a72f..776c026ac838 100644 --- a/fs/bcachefs/super-io.c +++ b/fs/bcachefs/super-io.c @@ -699,8 +699,12 @@ int bch2_write_super(struct bch_fs *c) const char *err; struct bch_devs_mask sb_written; bool wrote, can_mount_without_written...
1b05778707d04cb367a7ca8dbeff571b6117a191
Analyze and fix the following issue in the Linux kernel code: bcachefs: Add a cond_seched() to the allocator thread
Problem Details: This is just a band-aid fix for now. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/alloc_background.c b/fs/bcachefs/alloc_background.c index b9b97cbda177..f2117084f2fe 100644 --- a/fs/bcachefs/alloc_background.c +++ b/fs/bcachefs/alloc_background.c @@ -1127,6 +1127,7 @@ static int bch2_allocator_thread(void *arg) pr_debug("free_inc now empty"); do { + cond_r...
33a391a2551beca12926c77b16404f6aab2e8f58
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix some (spurious) warnings about uninitialized vars
Problem Details: These are only complained about when building in userspace, for some reason. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/btree_gc.c b/fs/bcachefs/btree_gc.c index 259a36f41629..7c03c50e0fa5 100644 --- a/fs/bcachefs/btree_gc.c +++ b/fs/bcachefs/btree_gc.c @@ -166,7 +166,7 @@ static int bch2_check_fix_ptrs(struct bch_fs *c, enum btree_id btree_id, { struct bkey_ptrs_c ptrs = bch2_bkey_ptrs_c(*k); const...
220d206232ba682002b06feb68969e462867f8f5
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix an allocator startup race
Problem Details: Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/super.c b/fs/bcachefs/super.c index 224c21c3f9f7..19399447f379 100644 --- a/fs/bcachefs/super.c +++ b/fs/bcachefs/super.c @@ -1177,6 +1177,8 @@ static int bch2_dev_alloc(struct bch_fs *c, unsigned dev_idx) if (!ca) goto err; + ca->fs = c; + if (ca->mi.state == BCH_MEMBER_STATE_...
e01dacf76c0c6a5fc6963b7857773b3d58740acb
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix bkey format generation for 32 bit fields
Problem Details: Having a packed format that can represent a field larger than the unpacked type breaks bkey_packed_successor() assertions - we need to fix this to start using the snapshot filed. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/bcachefs_format.h b/fs/bcachefs/bcachefs_format.h index e2df0f7182b4..0a615fe6c1c1 100644 --- a/fs/bcachefs/bcachefs_format.h +++ b/fs/bcachefs/bcachefs_format.h @@ -1371,9 +1371,10 @@ enum bch_sb_feature { }; enum bch_sb_compat { - BCH_COMPAT_FEAT_ALLOC_INFO = 0, - BCH_COMPAT_FEAT_...
8567415457b25b467933e47ff78dca55a55f7206
Analyze and fix the following issue in the Linux kernel code: bcachefs: Dump journal state when we get stuck
Problem Details: We had a bug reported where the journal is failing to allocate a journal write - this should help figure out what's going on. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/journal_io.c b/fs/bcachefs/journal_io.c index 40d452cedffd..fdd5a837902c 100644 --- a/fs/bcachefs/journal_io.c +++ b/fs/bcachefs/journal_io.c @@ -1383,6 +1383,7 @@ void bch2_journal_write(struct closure *cl) struct jset_entry *start, *end; struct jset *jset; struct bio *bio; + cha...
514852c2b58f06f1643b10264b6bc9089071b05c
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix a 64 bit divide on 32 bit
Problem Details: Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/journal_io.c b/fs/bcachefs/journal_io.c index df5b375c367f..40d452cedffd 100644 --- a/fs/bcachefs/journal_io.c +++ b/fs/bcachefs/journal_io.c @@ -836,13 +836,15 @@ static void bch2_journal_ptrs_to_text(struct printbuf *out, struct bch_fs *c, for (i = 0; i < j->nr_ptrs; i++) { str...
fe38b720862204595f7b56b8db98ea5074c83f82
Analyze and fix the following issue in the Linux kernel code: bcachefs: Don't use inode btree key cache in fsck code
Problem Details: We had a cache coherency bug with the btree key cache in the fsck code - this fixes fsck to be consistent about not using it. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/fsck.c b/fs/bcachefs/fsck.c index b2d9d55b1951..66c9dad2ef3e 100644 --- a/fs/bcachefs/fsck.c +++ b/fs/bcachefs/fsck.c @@ -58,7 +58,7 @@ static int __remove_dirent(struct btree_trans *trans, buf[name.len] = '\0'; name.name = buf; - ret = bch2_inode_find_by_inum_trans(trans, dir_inu...
bcdb4b9732208fb8d3c634661a1b581437dcdd12
Analyze and fix the following issue in the Linux kernel code: bcachefs: Don't call into journal reclaim when we're not supposed to
Problem Details: This was causing a deadlock when btree_update_nodes_writtes() invokes journal reclaim because of the btree cache being too dirty. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/btree_update_leaf.c b/fs/bcachefs/btree_update_leaf.c index d99a78f8950d..70cf18bcbcdd 100644 --- a/fs/bcachefs/btree_update_leaf.c +++ b/fs/bcachefs/btree_update_leaf.c @@ -284,7 +284,8 @@ btree_key_can_insert_cached(struct btree_trans *trans, BUG_ON(iter->level); if (!test_bit(B...
18a7b97239b6f0bae3fa1475cb276a273e07597a
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix for bch2_btree_node_get_noiter() returning -ENOMEM
Problem Details: bch2_btree_node_get_noiter() isn't used from the btree iterator code, which retries with the btree node cache cannibalize lock held on -ENOMEM, so we should do it ourself if necessary. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/btree_cache.c b/fs/bcachefs/btree_cache.c index 443d669e6a30..2152813554b4 100644 --- a/fs/bcachefs/btree_cache.c +++ b/fs/bcachefs/btree_cache.c @@ -844,7 +844,7 @@ retry: b = btree_cache_find(bc, k); if (unlikely(!b)) { if (nofill) - return NULL; + goto out; b = bch2_b...
0ef837a0cc87d49d9f7d29bdef5a57f07ecc84d3
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix unnecessary read amplificaiton when allocating ec stripes
Problem Details: When allocating an erasure coding stripe, bcachefs will always reuse any partial stripes before reserving a new stripe. This causes unnecessary read amplification when preparing a stripe for writing. This patch changes bcachefs to always reserve new stripes first, only relying on stripe reuse when copy...
```diff diff --git a/fs/bcachefs/ec.c b/fs/bcachefs/ec.c index a32d399e5b6f..a70b859363f0 100644 --- a/fs/bcachefs/ec.c +++ b/fs/bcachefs/ec.c @@ -1389,6 +1389,72 @@ static s64 get_existing_stripe(struct bch_fs *c, return ret; } +static int __bch2_ec_stripe_head_reuse(struct bch_fs *c, + struct ec_stripe_h...
2bb748a69596e883cf9ea28321d43f8c6a225cef
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fsck fixes
Problem Details: Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/fsck.c b/fs/bcachefs/fsck.c index c3e6137ffd75..b2d9d55b1951 100644 --- a/fs/bcachefs/fsck.c +++ b/fs/bcachefs/fsck.c @@ -1072,6 +1072,11 @@ static void inc_link(struct bch_fs *c, nlink_table *links, if (inum < range_start || inum >= *range_end) return; + if (inum - range_start >...
9d4032617605144717892f0763b617568bd15ac3
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix a shift greater than type size
Problem Details: Found by UBSAN Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/inode.c b/fs/bcachefs/inode.c index b11aecf2cfab..3462e248c954 100644 --- a/fs/bcachefs/inode.c +++ b/fs/bcachefs/inode.c @@ -479,7 +479,7 @@ int bch2_inode_create(struct btree_trans *trans, u64 min, max, start, *hint; int ret; - unsigned cpu = raw_smp_processor_id(); + u64 cpu = ...
3d4955952f05d5d0583bbb1fe4ce56c022f97847
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix bch2_btree_iter_peek_prev()
Problem Details: This makes bch2_btree_iter_peek_prev() and bch2_btree_iter_prev() consistent with peek() and next(), w.r.t. iter->pos. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.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 294c591b5047..4012a2c0f008 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -1519,13 +1519,27 @@ void bch2_btree_iter_set_pos(struct btree_iter *iter, struct bpos new_pos) static inline bool bch2_btree_iter_advance_...
eaf798317aa8fe3c8417ae1414c0b0bc58748881
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix for hash_redo_key() in fsck
Problem Details: It's possible we're calling hash_redo_key() because of a duplicate key - easiest fix for that is to just not use BCH_HASH_SET_MUST_CREATE. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/fsck.c b/fs/bcachefs/fsck.c index df0f00f10bd7..c3e6137ffd75 100644 --- a/fs/bcachefs/fsck.c +++ b/fs/bcachefs/fsck.c @@ -193,7 +193,7 @@ static int hash_redo_key(const struct bch_hash_desc desc, bch2_trans_update(trans, k_iter, &delete, 0); return bch2_hash_set(trans, desc, &h->i...
4b8f89afd44592d50f7309750e7835fc777dfb08
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fixes/improvements for journal entry reservations
Problem Details: This fixes some arithmetic bugs in "bcachefs: Journal updates to dev usage" - additionally, it cleans things up by switching everything that goes in every journal entry to the journal_entry_res mechanism. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.o...
```diff diff --git a/fs/bcachefs/bcachefs.h b/fs/bcachefs/bcachefs.h index 0c24a5312e49..cec5c3ddce34 100644 --- a/fs/bcachefs/bcachefs.h +++ b/fs/bcachefs/bcachefs.h @@ -582,8 +582,9 @@ struct bch_fs { struct bch_replicas_cpu replicas_gc; struct mutex replicas_gc_lock; + struct journal_entry_res btree_root_jour...
26452d1dcd4b134ecc7aeaae74f78de1c525caf3
Analyze and fix the following issue in the Linux kernel code: bcachefs: Add missing call to bch2_replicas_entry_sort()
Problem Details: This fixes a bug introduced by "bcachefs: Improve diagnostics when journal entries are missing" - devices in a replicas entry are supposed to be sorted. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/journal_io.c b/fs/bcachefs/journal_io.c index 60cefb4ace45..7e726db77881 100644 --- a/fs/bcachefs/journal_io.c +++ b/fs/bcachefs/journal_io.c @@ -937,6 +937,8 @@ int bch2_journal_read(struct bch_fs *c, struct list_head *list, for (ptr = 0; ptr < i->nr_ptrs; ptr++) replicas.e.devs...
5b593ee172bd536a2c9fd717de7e4a16d682ef23
Analyze and fix the following issue in the Linux kernel code: bcachefs: Add support for doing btree updates prior to journal replay
Problem Details: Some errors may need to be fixed in order for GC to successfully run - walk and mark all metadata. But we can't start the allocators and do normal btree updates until after GC has completed, and allocation information is known to be consistent, so we need a different method of doing btree updates. For...
```diff diff --git a/fs/bcachefs/bcachefs.h b/fs/bcachefs/bcachefs.h index 799569d1778a..d5fc5eed73ae 100644 --- a/fs/bcachefs/bcachefs.h +++ b/fs/bcachefs/bcachefs.h @@ -539,11 +539,13 @@ struct journal_keys { struct journal_key { enum btree_id btree_id:8; unsigned level:8; + bool allocated; struct bkey_i...
e4c3f386b62d8f7e917b26089c7dea374f7c1fb6
Analyze and fix the following issue in the Linux kernel code: bcachefs: Improve diagnostics when journal entries are missing
Problem Details: There's an outstanding bug with journal entries being missing in journal replay. This patch adds code to print out where the journal entries were physically located that were around the entry(ies) being missing, which should make debugging easier. Signed-off-by: Kent Overstreet <kent.overstreet@gmail....
```diff diff --git a/fs/bcachefs/journal.c b/fs/bcachefs/journal.c index d4c5c6306928..ba37c78c01db 100644 --- a/fs/bcachefs/journal.c +++ b/fs/bcachefs/journal.c @@ -1010,13 +1010,19 @@ int bch2_fs_journal_start(struct journal *j, u64 cur_seq, } list_for_each_entry(i, journal_entries, list) { + unsigned ptr; + ...
522c25f068bd5df5e1bc623e855262afd90e4a05
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix BCH_REPLICAS_MAX check
Problem Details: Ideally, this limit will be going away in the future. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> 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 e1b4e6f02ee3..61b947313c88 100644 --- a/fs/bcachefs/super-io.c +++ b/fs/bcachefs/super-io.c @@ -283,19 +283,19 @@ const char *bch2_sb_validate(struct bch_sb_handle *disk_sb) return "Bad number of member devices"; if (!BCH_SB_META_REPLICAS...
0093a50f2759f6e58fe44bafb80146fd2ef4d6a2
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix build in userspace
Problem Details: The userspace bch_err() macro doesn't use the filesystem argument. Could also be fixed with a better macro. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/ec.c b/fs/bcachefs/ec.c index f280ca20d457..78bea3e5fa9a 100644 --- a/fs/bcachefs/ec.c +++ b/fs/bcachefs/ec.c @@ -744,7 +744,6 @@ err: static int ec_stripe_bkey_update(struct btree_trans *trans, struct bkey_i_stripe *new) { - struct bch_fs *c = trans->c; struct btree_iter *ite...
4529ae09cea2c040180e991ea648588220611497
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix an assertion
Problem Details: If we're invalidating a bucket that has cached data in it, data_type won't be 0 - oops. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/alloc_background.c b/fs/bcachefs/alloc_background.c index 206134fec320..68fa6caf022d 100644 --- a/fs/bcachefs/alloc_background.c +++ b/fs/bcachefs/alloc_background.c @@ -887,7 +887,7 @@ static int bch2_invalidate_one_bucket2(struct btree_trans *trans, g = bucket(ca, b); m = READ_ONC...
b7cf4bd7fe689534f77455b7d60f5033b9a3bd28
Analyze and fix the following issue in the Linux kernel code: bcachefs: Ensure __bch2_trans_commit() always calls bch2_trans_reset()
Problem Details: This was leading to a very strange bug in bch2_bucket_io_time_reset(), where we'd retry without clearing out the list of updates. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/btree_update_leaf.c b/fs/bcachefs/btree_update_leaf.c index ffd8e0b14257..f64e7d37bbbf 100644 --- a/fs/bcachefs/btree_update_leaf.c +++ b/fs/bcachefs/btree_update_leaf.c @@ -836,7 +836,7 @@ int __bch2_trans_commit(struct btree_trans *trans) int ret = 0; if (!trans->nr_updates) - ...
fdbb88ac019462efcdcf83927e004e74088831f4
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix a faulty assertion
Problem Details: If journal replay hasn't finished, the journal can't be empty - oops. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/journal.c b/fs/bcachefs/journal.c index 6f84a5dd06bc..ecc3629bcd4c 100644 --- a/fs/bcachefs/journal.c +++ b/fs/bcachefs/journal.c @@ -953,6 +953,7 @@ void bch2_fs_journal_stop(struct journal *j) journal_quiesce(j); BUG_ON(!bch2_journal_error(j) && + test_bit(JOURNAL_REPLAY_...
b4725cc1a45fa859e6ff0966f5fa988d6402e5c8
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix loopback in dio mode
Problem Details: We had a deadlock on page_lock, because buffered reads signal completion by unlocking the page, but the dio read path normally dirties the pages it's reading to with set_page_dirty_lock. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.de...
```diff diff --git a/fs/bcachefs/fs-io.c b/fs/bcachefs/fs-io.c index 5dd985e20c7f..79f1f0f37e18 100644 --- a/fs/bcachefs/fs-io.c +++ b/fs/bcachefs/fs-io.c @@ -93,6 +93,7 @@ struct dio_read { struct closure cl; struct kiocb *req; long ret; + bool should_dirty; struct bch_read_bio rbio; }; @@ -1599,...