id
stringlengths
40
40
instruction
stringlengths
68
308
input
stringlengths
17
33.4k
output
stringlengths
100
30k
c6cf49a95ac7aea3450cacb66b7de1d46671deeb
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix blocking with locks held
Problem Details: This is a major oopsy - we should always be unlocking before calling closure_sync(), else we'll cause a deadlock. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/btree_update_interior.c b/fs/bcachefs/btree_update_interior.c index 7a682c1751b3..797efa738dc4 100644 --- a/fs/bcachefs/btree_update_interior.c +++ b/fs/bcachefs/btree_update_interior.c @@ -1117,10 +1117,10 @@ bch2_btree_update_start(struct btree_trans *trans, struct btree_path *path, ...
01ed3359b2705d7b862ad0644dabc616774f8779
Analyze and fix the following issue in the Linux kernel code: bcachefs: btree_update_nodes_written() needs BTREE_INSERT_USE_RESERVE
Problem Details: This fixes an obvious deadlock - whoops. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/btree_update_interior.c b/fs/bcachefs/btree_update_interior.c index 0d87b1c88ed4..7a682c1751b3 100644 --- a/fs/bcachefs/btree_update_interior.c +++ b/fs/bcachefs/btree_update_interior.c @@ -625,6 +625,7 @@ static void btree_update_nodes_written(struct btree_update *as) ret = commit_do...
d602657cd185784bf4b227ecd1a88ed90735eae5
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix error handling in bch2_btree_update_start()
Problem Details: We were checking for -EAGAIN, but we're not returned that when we didn't pass a closure to wait with - oops. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/btree_update_interior.c b/fs/bcachefs/btree_update_interior.c index 7028597358d5..0d87b1c88ed4 100644 --- a/fs/bcachefs/btree_update_interior.c +++ b/fs/bcachefs/btree_update_interior.c @@ -1110,8 +1110,8 @@ bch2_btree_update_start(struct btree_trans *trans, struct btree_path *path, ...
8b31e4fc7d9e27fd5dc56bb063acf9e4ea575973
Analyze and fix the following issue in the Linux kernel code: bcachefs: Kill normalize_read_intent_locks()
Problem Details: Before we had the deadlock cycle detector, we didn't want to be holding read locks when taking intent locks, because blocking on an intent lock while holding a read lock was a lock ordering violation that could cause a deadlock. With the cycle detector this is no longer an issue, so this code can be d...
```diff diff --git a/fs/bcachefs/btree_update_leaf.c b/fs/bcachefs/btree_update_leaf.c index 7b21971fa13d..ad46c887185b 100644 --- a/fs/bcachefs/btree_update_leaf.c +++ b/fs/bcachefs/btree_update_leaf.c @@ -740,62 +740,6 @@ bch2_trans_commit_write_locked(struct btree_trans *trans, return ret; } -static inline void...
2ec254c098da677295c2487ae36e75a26d557222
Analyze and fix the following issue in the Linux kernel code: bcachefs: Ensure bch2_btree_node_lock_write_nofail() never fails
Problem Details: In order for bch2_btree_node_lock_write_nofail() to never produce a deadlock, we must ensure we're never holding read locks when using it. Fortunately, it's only used from code paths where any read locks may be safely dropped. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/btree_locking.c b/fs/bcachefs/btree_locking.c index 11f83a936dc7..6793d7dd18d7 100644 --- a/fs/bcachefs/btree_locking.c +++ b/fs/bcachefs/btree_locking.c @@ -320,6 +320,40 @@ int __bch2_btree_node_lock_write(struct btree_trans *trans, struct btree_path *p return ret; } +void bch2_b...
0d7009d7ca99ad9261a7cffcecd515108377a6ac
Analyze and fix the following issue in the Linux kernel code: bcachefs: Delete old deadlock avoidance code
Problem Details: This deletes our old lock ordering based deadlock avoidance code. 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 a0e9e14e3fa5..aeb058c800cd 100644 --- a/fs/bcachefs/btree_cache.c +++ b/fs/bcachefs/btree_cache.c @@ -151,8 +151,6 @@ void bch2_btree_node_hash_remove(struct btree_cache *bc, struct btree *b) /* Cause future lookups for this node to fa...
96d994b37cfcf468bf1d71527ae95ad93a311e38
Analyze and fix the following issue in the Linux kernel code: bcachefs: Print deadlock cycle in debugfs
Problem Details: In the event that we're not finished debugging the cycle detector, this adds a new file to debugfs that shows what the cycle detector finds, if anything. By comparing this with btree_transactions, which shows held locks for every btree_transaction, we'll be able to determine if it's the cycle detector ...
```diff diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index 5773b00e69ac..ece80d7914b2 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -2992,7 +2992,6 @@ bch2_btree_path_node_to_text(struct printbuf *out, c.n[0], c.n[1], c.n[2], pid); } -#ifdef CONFIG_BCACHEFS_DEBUG_T...
33bd5d068603f9e81e0b73dbe50e9b88b2e56d0d
Analyze and fix the following issue in the Linux kernel code: bcachefs: Deadlock cycle detector
Problem Details: We've outgrown our own deadlock avoidance strategy. The btree iterator API provides an interface where the user doesn't need to concern themselves with lock ordering - different btree iterators can be traversed in any order. Without special care, this will lead to deadlocks. Our previous strategy was...
```diff diff --git a/fs/bcachefs/bcachefs_format.h b/fs/bcachefs/bcachefs_format.h index 0e80fe2568f2..5471b797be93 100644 --- a/fs/bcachefs/bcachefs_format.h +++ b/fs/bcachefs/bcachefs_format.h @@ -1400,7 +1400,8 @@ struct bch_sb_field_disk_groups { x(trans_restart_key_cache_upgrade, 70) \ x(trans_traverse_all, ...
62448afee714354a26db8a0f3c644f58628f0792
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix bch2_btree_node_upgrade()
Problem Details: Previously, if we were trying to upgrade from a read to an intent lock but we held an additional read lock via another btree_path, bch2_btree_node_upgrade() would always fail, in six_lock_tryupgrade(). This patch factors out the code that __bch2_btree_node_lock_write() uses to temporarily drop extra r...
```diff diff --git a/fs/bcachefs/btree_locking.c b/fs/bcachefs/btree_locking.c index 08dbc799bb35..5b6d8184ea45 100644 --- a/fs/bcachefs/btree_locking.c +++ b/fs/bcachefs/btree_locking.c @@ -230,6 +230,7 @@ bool bch2_btree_node_upgrade(struct btree_trans *trans, struct btree_path *path, unsigned level) { st...
845cffed0d343ecea9f6ff3883cac9a6872d9920
Analyze and fix the following issue in the Linux kernel code: bcachefs: Add a debug assert
Problem Details: Chasing down a strange locking bug. 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 1650ba87ef03..df9949cef907 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -1110,6 +1110,9 @@ static int btree_path_traverse_one(struct btree_trans *trans, path->level = btree_path_up_until_good_node(trans, path, ...
e4b7254c754b676a6f4d607fd92cd71d221ff130
Analyze and fix the following issue in the Linux kernel code: six locks: Fix a lost wakeup
Problem Details: There was a lost wakeup between a read unlock in percpu mode and a write lock. The unlock path unlocks, then executes a barrier, then checks for waiters; correspondingly, the lock side should set the wait bit and execute a barrier, then attempt to take the lock. Signed-off-by: Kent Overstreet <kent.ov...
```diff diff --git a/fs/bcachefs/six.c b/fs/bcachefs/six.c index 01ff210ff18c..abdc2414f58b 100644 --- a/fs/bcachefs/six.c +++ b/fs/bcachefs/six.c @@ -198,6 +198,14 @@ retry: atomic64_add(__SIX_VAL(write_locking, 1), &lock->state.counter); smp_mb__after_atomic(); + } else if (!(lock->state.waiters & ...
0bfb9f42b7b16aa11a7b5d283b0b7b98d11476b7
Analyze and fix the following issue in the Linux kernel code: six locks: six_lock_waiter()
Problem Details: This allows passing in the wait list entry - to be used for a deadlock cycle detector. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/six.c b/fs/bcachefs/six.c index d5e09fae1538..82e8d77c3082 100644 --- a/fs/bcachefs/six.c +++ b/fs/bcachefs/six.c @@ -439,10 +439,10 @@ static inline bool six_optimistic_spin(struct six_lock *lock, enum six_lock_type noinline static int __six_lock_type_slowpath(struct six_lock *lock...
ebc6f76a667f5fc599a5f76515f6881dfb82af2f
Analyze and fix the following issue in the Linux kernel code: six locks: Simplify wait lists
Problem Details: This switches to a single list of waiters, instead of separate lists for read and intent, and switches write locks to also use the wait lists instead of being handled differently. Also, removal from the wait list is now done by the process waiting on the lock, not the process doing the wakeup. This is...
```diff diff --git a/fs/bcachefs/six.c b/fs/bcachefs/six.c index 0ab72f59d23b..d5e09fae1538 100644 --- a/fs/bcachefs/six.c +++ b/fs/bcachefs/six.c @@ -89,50 +89,38 @@ static inline unsigned pcpu_read_count(struct six_lock *lock) return read_count; } -struct six_lock_waiter { - struct list_head list; - struct task_...
e4215d0fec777e6516306f5f1b69a45a4205dce0
Analyze and fix the following issue in the Linux kernel code: bcachefs: All held locks must be in a btree path
Problem Details: With the new deadlock cycle detector, it's critical that all held locks be marked in a btree_path, because that's what the cycle detector traverses - any locks that aren't correctly marked will cause deadlocks. This changes the btree_path to allocate some btree_paths for the new nodes, since until the...
```diff diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index b1c81278ad75..e65c300ffe40 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -619,61 +619,6 @@ static inline bool btree_path_advance_to_pos(struct btree_path *path, return true; } -/* - * Verify that iterator for p...
5a82c7c7d1925f6f060a427f38ea17b53c6945f1
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix sb_field_counters formatting
Problem Details: We have counters with longer names now, so adjust the tabstop - also, make sure there's always a space printed between the name and the number. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/counters.c b/fs/bcachefs/counters.c index 745f856e6d3e..edd1b2537f48 100644 --- a/fs/bcachefs/counters.c +++ b/fs/bcachefs/counters.c @@ -36,7 +36,7 @@ void bch2_sb_counters_to_text(struct printbuf *out, struct bch_sb *sb, for (i = 0; i < nr; i++) { if (i < BCH_COUNTER_NR) - pr...
1ffb876fb0f31632b761ee721f633e0d7491ca7b
Analyze and fix the following issue in the Linux kernel code: bcachefs: Kill journal_keys->journal_seq_base
Problem Details: This removes an optimization that didn't actually save us any memory, due to alignment, but did make the code more complicated than it needed to be. We were also seeing a bug where journal_seq_base wasn't getting correctly initailized, so hopefully it'll fix that too. Signed-off-by: Kent Overstreet <k...
```diff diff --git a/fs/bcachefs/bcachefs.h b/fs/bcachefs/bcachefs.h index c1d96222f4c3..74da688d994b 100644 --- a/fs/bcachefs/bcachefs.h +++ b/fs/bcachefs/bcachefs.h @@ -555,13 +555,13 @@ struct journal_seq_blacklist_table { struct journal_keys { struct journal_key { + u64 journal_seq; + u32 journal_offset; ...
e87b0e4a7120eeca1850666351b75bf8ceb9d5c9
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix redundant transaction restart
Problem Details: Little bit of tidying up, this makes the counters a little bit clearer as to what's happening. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/btree_locking.c b/fs/bcachefs/btree_locking.c index bfe9780aea3a..08dbc799bb35 100644 --- a/fs/bcachefs/btree_locking.c +++ b/fs/bcachefs/btree_locking.c @@ -413,14 +413,13 @@ int bch2_trans_relock(struct btree_trans *trans) struct btree_path *path; if (unlikely(trans->restarted))...
38474c264252475196a5e3c555b2625a5bc36a00
Analyze and fix the following issue in the Linux kernel code: bcachefs: Avoid using btree_node_lock_nopath()
Problem Details: With the upcoming cycle detector, we have to be careful about using btree_node_lock_nopath - in particular, using it to take write locks can cause deadlocks. All held locks need to be tracked in a btree_path, so that the cycle detector knows about them - unless we know that we cannot cause deadlocks f...
```diff diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index 9c39027513b0..b1c81278ad75 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -716,13 +716,13 @@ void bch2_trans_node_add(struct btree_trans *trans, struct btree *b) struct btree_path *path; trans_for_each_path(tra...
3d21d48e898a2eadc9055c44e0fd51e6087c9e9f
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix usage of six lock's percpu mode, key cache version
Problem Details: Similar to "bcachefs: Fix usage of six lock's percpu mode", six locks have a percpu mode, but we can't switch between percpu and non percpu modes while a lock is in use: threads attempting to take a read lock may race, and we'll end up with the read count permanently off. Fixing this the "correct" way...
```diff diff --git a/fs/bcachefs/btree_key_cache.c b/fs/bcachefs/btree_key_cache.c index b3d383ff3d5b..89e540c5a244 100644 --- a/fs/bcachefs/btree_key_cache.c +++ b/fs/bcachefs/btree_key_cache.c @@ -13,6 +13,11 @@ #include <linux/sched/mm.h> +static inline bool btree_uses_pcpu_readers(enum btree_id id) +{ + return...
6b81f194f345d15dd15601ee7b604a0640445895
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix six_lock_readers_add()
Problem Details: Have to be careful with bit fields - when subtracting, this was overflowing into the write_locking bit. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/btree_locking.c b/fs/bcachefs/btree_locking.c index 24d0ea903380..158cb7ac64f2 100644 --- a/fs/bcachefs/btree_locking.c +++ b/fs/bcachefs/btree_locking.c @@ -10,10 +10,12 @@ struct lock_class_key bch2_btree_node_lock_key; static inline void six_lock_readers_add(struct six_lock *lock,...
ca7d8fcabf29fae627babb72bda9b51763f9a145
Analyze and fix the following issue in the Linux kernel code: bcachefs: New locking functions
Problem Details: In the future, with the new deadlock cycle detector, we won't be using bare six_lock_* anymore: lock wait entries will all be embedded in btree_trans, and we will need a btree_trans context whenever locking a btree node. This patch plumbs a btree_trans to the few places that need it, and adds two new ...
```diff diff --git a/fs/bcachefs/btree_cache.c b/fs/bcachefs/btree_cache.c index e09fbf36ebc2..a0e9e14e3fa5 100644 --- a/fs/bcachefs/btree_cache.c +++ b/fs/bcachefs/btree_cache.c @@ -959,12 +959,13 @@ lock_node: return b; } -struct btree *bch2_btree_node_get_noiter(struct bch_fs *c, +struct btree *bch2_btree_node_...
546180874ade7225676bc0cd5ea4e2388e2374bc
Analyze and fix the following issue in the Linux kernel code: bcachefs: Mark write locks before taking lock
Problem Details: six locks are unfair: while a thread is blocked trying to take a write lock, new read locks will fail. The new deadlock cycle detector makes use of our existing lock tracing, so we need to tell it we're holding a write lock before we take the lock for it to work correctly. Signed-off-by: Kent Overstre...
```diff diff --git a/fs/bcachefs/btree_locking.h b/fs/bcachefs/btree_locking.h index 1e4c81d8084b..ab3161c1b1f4 100644 --- a/fs/bcachefs/btree_locking.h +++ b/fs/bcachefs/btree_locking.h @@ -271,10 +271,15 @@ static inline void bch2_btree_node_lock_write(struct btree_trans *trans, EBUG_ON(path->l[b->c.level].lock_seq...
c919f53f3bcba3598fc6ce1ee5c5aed75d0834b7
Analyze and fix the following issue in the Linux kernel code: bcachefs: Don't leak lock pcpu counts memory
Problem Details: This fixes a small memory leak. 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 127cb6edaff5..7349c70f8445 100644 --- a/fs/bcachefs/btree_key_cache.c +++ b/fs/bcachefs/btree_key_cache.c @@ -238,8 +238,6 @@ btree_key_cache_create(struct bch_fs *c, } else { if (btree_id == BTREE_ID_subvolumes) six_lock_...
d97e6aaed60a9c2c727cce2979ca311fe232163f
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix bch2_btree_update_start() to return -BCH_ERR_journal_reclaim_would_deadlock
Problem Details: On failure to get a journal pre-reservation because we're called from journal reclaim we're not supposed to return a transaction restart error - this fixes a livelock. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/btree_update_interior.c b/fs/bcachefs/btree_update_interior.c index fc768195be54..dd9405c631f5 100644 --- a/fs/bcachefs/btree_update_interior.c +++ b/fs/bcachefs/btree_update_interior.c @@ -1049,6 +1049,11 @@ bch2_btree_update_start(struct btree_trans *trans, struct btree_path *path, ...
c240c3a94427346f27a7ff48f02cbe03f2c2ebd6
Analyze and fix the following issue in the Linux kernel code: bcachefs: Print lock counts in debugs btree_transactions
Problem Details: Improve our debugfs output, to help in debugging deadlocks: this shows, for every btree node we print, the current number of readers/intent locks/write locks held. 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 ce9437916cf2..99422e29c704 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -3024,9 +3024,21 @@ bch2_btree_path_node_to_text(struct printbuf *out, struct btree_bkey_cached_common *b, bool cached) { +...
02afcb8c26b14ae317754d8c79339f41b3dfeaae
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix adding a device with a label
Problem Details: Device labels are represented as pointers in the member info section: we need to get and then set the label for it to be kept correctly. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/disk_groups.c b/fs/bcachefs/disk_groups.c index 33d2702e6849..5f405d38b3de 100644 --- a/fs/bcachefs/disk_groups.c +++ b/fs/bcachefs/disk_groups.c @@ -384,32 +384,34 @@ inval: prt_printf(out, "invalid label %u", v); } -int bch2_dev_group_set(struct bch_fs *c, struct bch_dev *ca, con...
12043cf1511420ecf38f4925a0089c1ae1aa058b
Analyze and fix the following issue in the Linux kernel code: bcachefs: fsck: Another transaction restart handling fix
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/data_update.c b/fs/bcachefs/data_update.c index c0d6a48d3c72..f9eb147fe229 100644 --- a/fs/bcachefs/data_update.c +++ b/fs/bcachefs/data_update.c @@ -248,6 +248,8 @@ next: } continue; nomatch: + trace_data_update_fail(&old.k->p); + if (m->ctxt) { BUG_ON(k.k->p.offset <= i...
42590b53fef427f96fc50da4974923564e9033cd
Analyze and fix the following issue in the Linux kernel code: bcachefs: bch2_btree_delete_range_trans() now returns -BCH_ERR_transaction_restart_nested
Problem Details: The new convention is that functions that handle transaction restarts within an existing transaction context should return -BCH_ERR_transaction_restart_nested when they did so, since they invalidated the outer transaction context. This also means bch2_btree_delete_range_trans() is changed to only call...
```diff diff --git a/fs/bcachefs/btree_update_leaf.c b/fs/bcachefs/btree_update_leaf.c index 6bf34853f261..11c3767896aa 100644 --- a/fs/bcachefs/btree_update_leaf.c +++ b/fs/bcachefs/btree_update_leaf.c @@ -1713,15 +1713,16 @@ int bch2_btree_delete_range_trans(struct btree_trans *trans, enum btree_id id, unsigne...
efd0d03816dd0d5127217220f85f1f0e621974d1
Analyze and fix the following issue in the Linux kernel code: bcachefs: Minor transaction restart handling fix
Problem Details: - fsck_inode_rm() wasn't returning BCH_ERR_transaction_restart_nested - change bch2_trans_verify_not_restarted() to call panic() - we don't want these errors to be missed 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 88b2ed1d508a..95bc71dd87af 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -3289,10 +3289,10 @@ u32 bch2_trans_begin(struct btree_trans *trans) void bch2_trans_verify_not_restarted(struct btree_trans *trans, u32 re...
23dfb3a2f7757593249b745f2a17b56b756d2874
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix bch2_btree_iter_peek_slot() error path
Problem Details: iter->k needs to be consistent with iter->pos - required for bch2_btree_iter_(rewind|advance) to work correctly. 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 0c6e215f46c8..88b2ed1d508a 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -2844,8 +2844,10 @@ struct bkey_s_c bch2_btree_iter_peek_slot(struct btree_iter *iter) iter->flags & BTREE_ITER_INTENT); ret = bch2_...
bbf4288401519a7554201caf9b945c79f29753b3
Analyze and fix the following issue in the Linux kernel code: bcachefs: Always rebuild aux search trees when node boundaries change
Problem Details: Topology repair may change btree node min/max keys: when it does so, we need to always rebuild eytzinger search trees because nodes directly depend on those values. This fixes a bug found by the 'kill_btree_node' test, where we'd pop an assertion in bch2_bset_search_linear(). Signed-off-by: Kent Over...
```diff diff --git a/fs/bcachefs/btree_io.c b/fs/bcachefs/btree_io.c index 6e39c1641b90..bd74bd31dd1f 100644 --- a/fs/bcachefs/btree_io.c +++ b/fs/bcachefs/btree_io.c @@ -611,7 +611,6 @@ void bch2_btree_node_drop_keys_outside_node(struct btree *b) (u64 *) vstruct_end(i) - (u64 *) k); i->u64s = cpu_to_le16(l...
15bc0948e73d9a858a6b69fc4eb34d176436044c
Analyze and fix the following issue in the Linux kernel code: bcachefs: Add an overflow check in set_bkey_val_u64s()
Problem Details: For now this is just a BUG_ON() - we may want to change this to return an error in the future. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/bkey.h b/fs/bcachefs/bkey.h index 6a637a408a9f..8e9405f89537 100644 --- a/fs/bcachefs/bkey.h +++ b/fs/bcachefs/bkey.h @@ -50,12 +50,15 @@ static inline size_t bkey_val_bytes(const struct bkey *k) static inline void set_bkey_val_u64s(struct bkey *k, unsigned val_u64s) { - k->u64s = B...
c59d66b51b11064f17d87d5b9695e0216b8ade99
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix bch2_fs_check_snapshots()
Problem Details: We were iterating starting at BCACHEFS_ROOT_INO, but snapshots start at POS_MIN - meaning this code was never getting run. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Reported-by: Olexa Bilaniuk <obilaniu@gmail.com>
```diff diff --git a/fs/bcachefs/subvolume.c b/fs/bcachefs/subvolume.c index 24244bc3d2fb..fb3f8e4074c7 100644 --- a/fs/bcachefs/subvolume.c +++ b/fs/bcachefs/subvolume.c @@ -278,8 +278,8 @@ int bch2_fs_check_snapshots(struct bch_fs *c) bch2_trans_init(&trans, c, 0, 0); - ret = for_each_btree_key_commit(&trans, i...
45b033fa1afd35a8eab0af003ffac9413548f476
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix assertion in bch2_btree_key_cache_drop()
Problem Details: Turns out this assertion was something we could legitimately hit - add a comment describing what's going on, and handle it. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/btree_key_cache.c b/fs/bcachefs/btree_key_cache.c index f0055f17381d..0e87c19effeb 100644 --- a/fs/bcachefs/btree_key_cache.c +++ b/fs/bcachefs/btree_key_cache.c @@ -639,11 +639,22 @@ bool bch2_btree_insert_key_cached(struct btree_trans *trans, void bch2_btree_key_cache_drop(struct btr...
5c0bb66ae341c71e5f62c193ea4d7b0cf278a914
Analyze and fix the following issue in the Linux kernel code: bcachefs: Track the maximum btree_paths ever allocated by each transaction
Problem Details: We need a way to check if the machinery for handling btree_paths with in a transaction is behaving reasonably, as it often has not been - we've had bugs with transaction path overflows caused by duplicate paths and plenty of other things. This patch tracks, per transaction fn, the most btree paths eve...
```diff diff --git a/fs/bcachefs/bcachefs.h b/fs/bcachefs/bcachefs.h index 9fe96516c114..f8b7434534eb 100644 --- a/fs/bcachefs/bcachefs.h +++ b/fs/bcachefs/bcachefs.h @@ -531,6 +531,9 @@ struct btree_debug { struct btree_transaction_stats { struct bch2_time_stats lock_hold_times; + struct mutex lock; + unsigned ...
11c1a62f3b872d2345c97e72700ed4d1b2511888
Analyze and fix the following issue in the Linux kernel code: bcachefs: Switch bch2_btree_delete_range() to bch2_trans_run()
Problem Details: This fixes an assertion about unexpected transaction restarts - bch2_delete_range_trans() handles transaction restarts. 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 1371b7c6ff8b..6bf34853f261 100644 --- a/fs/bcachefs/btree_update_leaf.c +++ b/fs/bcachefs/btree_update_leaf.c @@ -1785,9 +1785,8 @@ int bch2_btree_delete_range(struct bch_fs *c, enum btree_id id, unsigned update_flags, ...
7c812ab786c4a689989aabf9e865164eb4f8004d
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix btree_path->uptodate inconsistency
Problem Details: This fixes an assertion in bch2_btree_path_peek_slot(). 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 2d824f6a6fab..1371b7c6ff8b 100644 --- a/fs/bcachefs/btree_update_leaf.c +++ b/fs/bcachefs/btree_update_leaf.c @@ -726,8 +726,10 @@ bch2_trans_commit_write_locked(struct btree_trans *trans, btree_insert_key_leaf(trans, i); ...
a300261ad19d69e080278ec4950d39caef3ffbf1
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix duplicate paths left by bch2_path_put()
Problem Details: bch2_path_put() is supposed to drop paths that aren't needed on transaction restart, or to hold locks that we're supposed to keep until transaction commit: but it was failing to free paths in some cases that it should have, leading to transaction path overflows with lots of duplicate paths. Signed-off...
```diff diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index bd6e35fcbdbd..837cdcc5c77c 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -424,13 +424,17 @@ int bch2_btree_path_relock_intent(struct btree_trans *trans, return 0; } -noinline __flatten -static int __bch2_btree_...
fd211bc71c9b4093ed39d4fc93294f9ff423febc
Analyze and fix the following issue in the Linux kernel code: bcachefs: Don't set should_be_locked on paths that aren't locked
Problem Details: It doesn't make any sense to set should_be_locked on btree_paths that aren't locked, and is often a bug - this patch adds assertions and fixes some of those 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 74978a50023f..1d5d7b639241 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -2103,7 +2103,7 @@ bch2_btree_iter_traverse(struct btree_iter *iter) if (ret) return ret; - iter->path->should_be_locked = true; + btre...
31301dd46975b2423fd38fc64bc58728d89dbcac
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix missing error handling in bch2_subvolume_delete()
Problem Details: This fixes an assertion when the transaction has been unexpectedly restarted. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/subvolume.c b/fs/bcachefs/subvolume.c index b5b0f5e39f97..24244bc3d2fb 100644 --- a/fs/bcachefs/subvolume.c +++ b/fs/bcachefs/subvolume.c @@ -877,6 +877,8 @@ int bch2_subvolume_delete(struct btree_trans *trans, u32 subvolid) goto err; ret = bch2_snapshot_node_set_deleted(trans, s...
17047fbced563cf5abe5aa546f6a92af48900b69
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix incorrectly freeing btree_path in alloc path
Problem Details: Clearing path->preserve means the path will be dropping in bch2_trans_begin() - but on transaction restart, we're likely to need that path again. This fixes a livelock in the allocation path. 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 9a3287da9a12..5ca92b6bb397 100644 --- a/fs/bcachefs/btree_iter.h +++ b/fs/bcachefs/btree_iter.h @@ -335,7 +335,8 @@ void bch2_trans_copy_iter(struct btree_iter *, struct btree_iter *); static inline void set_btree_iter_dontneed(struct btr...
86b74451931790eafa018021fe900faea3230189
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix bch2_btree_trans_to_text()
Problem Details: bch2_btree_trans_to_text() is used to print btree_transactions owned by other threads; thus, it needs to be particularly careful. This fixes a null ptr deref caused by racing with the owning thread changing path->l[].b. 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 01ca27ee6314..171894d9347d 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -3417,19 +3417,19 @@ void bch2_trans_exit(struct btree_trans *trans) static void __maybe_unused bch2_btree_path_node_to_text(struct printb...
4a7f7e9e4de665d94e1a7610bf5506265df414d3
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix not punting to worqueue when promoting
Problem Details: Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/io.c b/fs/bcachefs/io.c index dfa708c0a7fc..0348e2ab6422 100644 --- a/fs/bcachefs/io.c +++ b/fs/bcachefs/io.c @@ -2027,6 +2027,7 @@ static void bch2_read_endio(struct bio *bio) } if (rbio->narrow_crcs || + rbio->promote || crc_is_compressed(rbio->pick.crc) || bch2_...
0763c552e7ef024ce6dbc9cbc828b8715dff251c
Analyze and fix the following issue in the Linux kernel code: bcachefs: fsck: Fix nested transaction handling
Problem Details: This uses the new trans->restart count to make sure we always correctly return -BCH_ERR_transaction_restart_nested when we restart a nested transaction - eliminating some other hacks and preparing for new assertions. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/fsck.c b/fs/bcachefs/fsck.c index ea264421fe8f..bb8cab7cb405 100644 --- a/fs/bcachefs/fsck.c +++ b/fs/bcachefs/fsck.c @@ -650,6 +650,7 @@ static int __walk_inode(struct btree_trans *trans, struct bch_fs *c = trans->c; struct btree_iter iter; struct bkey_s_c k; + u32 restart_count ...
7903e3d2d7e5266dde40c9db746fafb078f84f4f
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix check_i_sectors()
Problem Details: bch2_count_inode_sectors() uses for_each_btree_key() internally, which handles lock restarts - the lockrestart_do() in check_i_sectors() is redundant, and buggy here since the count that bch2_count_inode_sectors() returns was interpreted as an error by lockrestart_do(). Signed-off-by: Kent Overstreet ...
```diff diff --git a/fs/bcachefs/fsck.c b/fs/bcachefs/fsck.c index 306983811c1b..ea264421fe8f 100644 --- a/fs/bcachefs/fsck.c +++ b/fs/bcachefs/fsck.c @@ -1122,8 +1122,7 @@ static int check_i_sectors(struct btree_trans *trans, struct inode_walker *w) if (i->inode.bi_sectors == i->count) continue; - count2 = l...
d7228ecc483e1e104179a24a7e1e4568ae9235cb
Analyze and fix the following issue in the Linux kernel code: bcachefs: Convert debugfs code to for_each_btree_key2()
Problem Details: This fixes a bug where we were leaking a transaction restart error to userspace. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/debug.c b/fs/bcachefs/debug.c index 45f5229f20eb..b9b6cad8cd40 100644 --- a/fs/bcachefs/debug.c +++ b/fs/bcachefs/debug.c @@ -188,6 +188,7 @@ struct dump_iter { struct bch_fs *c; enum btree_id id; struct bpos from; + struct bpos prev_node; u64 iter; struct printbuf bu...
a0cb8d784f309d22323974e47b103bf01d0b62c0
Analyze and fix the following issue in the Linux kernel code: bcachefs: Inject transaction restarts in debug mode
Problem Details: In CONFIG_BCACHEFS_DEBUG mode, we'll now randomly issue transaction restarts - with a decaying probability based on the number of restarts we've already had, to ensure that transactions eventually make forward progress. This should help shake out some bugs. Signed-off-by: Kent Overstreet <kent.overstr...
```diff diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index db247c96298f..777e41a12246 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -17,6 +17,7 @@ #include "subvolume.h" #include "trace.h" +#include <linux/random.h> #include <linux/prefetch.h> static inline void btr...
90cecb921cfe95858a32995019f11c20b6339607
Analyze and fix the following issue in the Linux kernel code: bcachefs: Prevent a btree iter overflow in alloc path
Problem Details: In bch2_bucket_alloc_trans(), we're iterating over buckets - but not directly with an iterator, since we're iterating over the freespace btree. This means that we need to clear iter->path->preserve, otherwise we'll end up retaining a btree_path for every alloc key we touched - which is not what we wan...
```diff diff --git a/fs/bcachefs/alloc_foreground.c b/fs/bcachefs/alloc_foreground.c index 39e3bb5205ca..a9f893361c73 100644 --- a/fs/bcachefs/alloc_foreground.c +++ b/fs/bcachefs/alloc_foreground.c @@ -351,6 +351,7 @@ static struct open_bucket *try_alloc_bucket(struct btree_trans *trans, struct bc if (!ob) iter.p...
b962552eabd59f0026dcc21c14775b9d78336baf
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix should_invalidate_buckets()
Problem Details: Like bch2_copygc_wait_amount, should_invalidate_buckets() needs to try to ensure that there are always more buckets free than the largest reserve. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/alloc_background.h b/fs/bcachefs/alloc_background.h index ff366e61ace5..488db3211ce4 100644 --- a/fs/bcachefs/alloc_background.h +++ b/fs/bcachefs/alloc_background.h @@ -134,11 +134,13 @@ void bch2_do_discards(struct bch_fs *); static inline u64 should_invalidate_buckets(struct bch_dev...
0d06b4eca687b3a6a07b62fd4ca83d635103c77f
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix repair for extent past end of inode
Problem Details: When we find an extent past an inode's i_size, we need to do the deletion in the inode's snapshot (which will emit a whiteout if necessary); and we also need to note that we now have an a key at that position and snapshot, so that we don't go into an infinite loop. Also, switch to walking inodes in re...
```diff diff --git a/fs/bcachefs/fsck.c b/fs/bcachefs/fsck.c index b401c0913bdc..5cec55edb483 100644 --- a/fs/bcachefs/fsck.c +++ b/fs/bcachefs/fsck.c @@ -489,6 +489,28 @@ static inline void snapshots_seen_init(struct snapshots_seen *s) memset(s, 0, sizeof(*s)); } +static int snapshots_seen_add(struct bch_fs *c, s...
4ab35c34d5ab258fdd7325315fe5d94699e51eb4
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix subvol/snapshot deleting in recovery
Problem Details: fsck doesn't want to run while we're cleaning up deleted snapshots - if that work needs to be done, we want it to have finished before fsck runs, otherwise fsck will get confused when it finds multiple keys in the same snapshot ID equivalence class (i.e. the mechanism that snapshot deletion uses for cl...
```diff diff --git a/fs/bcachefs/bcachefs.h b/fs/bcachefs/bcachefs.h index c07ea9af561d..7020eee5de21 100644 --- a/fs/bcachefs/bcachefs.h +++ b/fs/bcachefs/bcachefs.h @@ -514,6 +514,8 @@ enum { BCH_FS_INITIAL_GC_UNFIXED, /* kill when we enumerate fsck errors */ BCH_FS_NEED_ANOTHER_GC, + BCH_FS_HAVE_DELETED_SNAPSH...
416cc426c0d79c65d85de52d3548a32de06ab3e8
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix snapshot deletion
Problem Details: Snapshots being deleted won't in general have a corresponding subvolume: this fixes a spurious fsck error where we'd complain about a snapshot pointing to a missing subvolume - but the subvolume had been deleted, and the snapshot was pending deletion as well. Signed-off-by: Kent Overstreet <kent.overs...
```diff diff --git a/fs/bcachefs/subvolume.c b/fs/bcachefs/subvolume.c index d74dc9843028..083eb4324583 100644 --- a/fs/bcachefs/subvolume.c +++ b/fs/bcachefs/subvolume.c @@ -17,7 +17,7 @@ void bch2_snapshot_to_text(struct printbuf *out, struct bch_fs *c, { struct bkey_s_c_snapshot s = bkey_s_c_to_snapshot(k); - p...
7c0732b88dfb87b5f32dcf5fdd7984d2acb992b9
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix move path when move_stats == NULL
Problem Details: This isn't done very often, but it is legitimate Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/move.c b/fs/bcachefs/move.c index eae93c65e1c7..8b44d95c32ce 100644 --- a/fs/bcachefs/move.c +++ b/fs/bcachefs/move.c @@ -140,13 +140,15 @@ void bch2_moving_ctxt_exit(struct moving_context *ctxt) { move_ctxt_wait_event(ctxt, NULL, list_empty(&ctxt->reads)); closure_sync(&ctxt->cl);...
47ab0c5f6a1e6ac1e9387181585fb39393fec4ea
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix bch2_check_alloc_key()
Problem Details: bch2_check_alloc_key() was failing to check buckets that didn't have alloc keys yet (because they'd never been used) - they still need to be added to the freespace btree. 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 9ede98a3dc64..f4457d62d75e 100644 --- a/fs/bcachefs/alloc_background.c +++ b/fs/bcachefs/alloc_background.c @@ -618,7 +618,9 @@ static int bch2_check_alloc_key(struct btree_trans *trans, struct printbuf buf = PRINTBUF; int re...
7a47d0993be95bf68e2e04653f40d311e3c25bed
Analyze and fix the following issue in the Linux kernel code: bcachefs: Always descend to leaf nodes it btree_gc
Problem Details: If a btree node is unreadable, it's the topology repair that fixes that and it's kicked off by btree_gc, so btree_gc needs to touch every node and very that they can be read. 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 2de5d97a9d2c..0447f5a51b5e 100644 --- a/fs/bcachefs/btree_gc.c +++ b/fs/bcachefs/btree_gc.c @@ -851,10 +851,7 @@ static int bch2_gc_btree(struct btree_trans *trans, enum btree_id btree_id, struct bch_fs *c = trans->c; struct btree_iter iter;...
58aaa0836be3be279f17db9ba07f3a58da033a9f
Analyze and fix the following issue in the Linux kernel code: bcachefs: fix __dev_available().
Problem Details: __dev_available() now calculates available buckets correctly. Previously it would almost always return 0 when we have cached data. Signed-off-by: Daniel Hill <daniel@gluo.nz> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/buckets.h b/fs/bcachefs/buckets.h index 080bcb20a5b0..b4cf10a47c52 100644 --- a/fs/bcachefs/buckets.h +++ b/fs/bcachefs/buckets.h @@ -159,12 +159,12 @@ static inline u64 __dev_buckets_available(struct bch_dev *ca, enum alloc_reserve reserve) { return max_t(s64, 0, - usa...
2817d453819a10654ac72e5f4937d4653dea1648
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix assertion in topology repair
Problem Details: If we were at the end of the node, when breaking out of the loop we'd pop the assertion on line 446 when cur wasn't NULL. 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 123644ffe93c..2de5d97a9d2c 100644 --- a/fs/bcachefs/btree_gc.c +++ b/fs/bcachefs/btree_gc.c @@ -395,6 +395,7 @@ again: bch2_btree_node_evict(c, cur_k.k); ret = bch2_journal_key_delete(c, b->c.btree_id, b->c.level, cur_k.k->k...
5a3c24714c8bd5e0d01d1547c0848147f2f79f69
Analyze and fix the following issue in the Linux kernel code: bcachefs: Make verbose option settable at runtime
Problem Details: -o verbose is very useful, and we're starting to use it more for runtime debug statements - making it possible to enable at runtime is a no brainer. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/opts.h b/fs/bcachefs/opts.h index 43b4488b8c6f..30cf9a2d9dc1 100644 --- a/fs/bcachefs/opts.h +++ b/fs/bcachefs/opts.h @@ -269,7 +269,7 @@ enum opt_type { BCH2_NO_SB_OPT, true, \ NULL, "Enable discard/TRIM support") \ x(verbose, u8, \ - OPT_FS|OPT_MOUNT, \ + ...
1c6ff39445553f84f9a46c2c60a4768c7f4ef226
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix refcount leak in bch2_do_invalidates()
Problem Details: If we fail to queue the work item because it's already in process, we need to drop the ref we just took. 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 3084081966b6..933334fed960 100644 --- a/fs/bcachefs/alloc_background.c +++ b/fs/bcachefs/alloc_background.c @@ -1192,8 +1192,9 @@ static void bch2_do_invalidates_work(struct work_struct *work) void bch2_do_invalidates(struct b...
2ed6248ab3a58dbbe5819cbd0e60e4e3a5b72c47
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix assertion in bch2_dev_list_add_dev()
Problem Details: We were only allowing 4 devices in a dev_list, not 16. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/super.h b/fs/bcachefs/super.h index 359fa1e7fc18..d66de6f589ac 100644 --- a/fs/bcachefs/super.h +++ b/fs/bcachefs/super.h @@ -89,7 +89,7 @@ static inline void bch2_dev_list_add_dev(struct bch_devs_list *devs, unsigned dev) { BUG_ON(bch2_dev_list_has_dev(*devs, dev)); - BUG_ON(...
c9bd67321e9b9bae0a9ba151a3906086878159b6
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix btree node read retries
Problem Details: b->written wasn't being reset to 0 in the btree node read retry path, causing decrypting & validation of previously read bsets to not be re-run - ouch. 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 598c30b7ab8b..b7441677dc33 100644 --- a/fs/bcachefs/btree_io.c +++ b/fs/bcachefs/btree_io.c @@ -879,6 +879,8 @@ int bch2_btree_node_read_done(struct bch_fs *c, struct bch_dev *ca, int ret, retry_read = 0, write = READ; b->version_ondisk = ...
a5d18f9ec0e2cfce1e0dc50f07d614ba21edaae9
Analyze and fix the following issue in the Linux kernel code: bcachefs: Improved human readable integer parsing
Problem Details: Printbufs recently switched to using string_get_size() for printing integers in human readable units. This updates __bch2_strtoh() to parse numbers printed by string_get_size() - we now have to handle floating point numbers, and new unit suffixes. Signed-off-by: Kent Overstreet <kent.overstreet@gmail....
```diff diff --git a/fs/bcachefs/util.c b/fs/bcachefs/util.c index dac7dfd0b806..a2e42ae77371 100644 --- a/fs/bcachefs/util.c +++ b/fs/bcachefs/util.c @@ -27,16 +27,19 @@ static const char si_units[] = "?kMGTPEZY"; -static int __bch2_strtoh(const char *cp, u64 *res, - u64 t_max, bool t_signed) +/* string_get_si...
df8c2ccb9309f342724f3104fd9d68d7e4ce65da
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix freespace initialization
Problem Details: bch2_dev_freespace_init() was using __bch2_trans_do() incorrectly, and calling bch2_bucket_do_index() with a stale alloc key. 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 bffbddbdacea..982cd185b1af 100644 --- a/fs/bcachefs/alloc_background.c +++ b/fs/bcachefs/alloc_background.c @@ -1190,12 +1190,26 @@ void bch2_do_invalidates(struct bch_fs *c) queue_work(system_long_wq, &c->invalidate_work); }...
652018d66190412669a898c2dc3e75073eac8679
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix btree node read error path
Problem Details: We were forgetting to clear the read_in_flight flag - oops. This also fixes it to not call bch2_fatal_error() before topology repair has had a chance to do its thing. 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 a1043492dbd9..9d4d6a65e70c 100644 --- a/fs/bcachefs/btree_io.c +++ b/fs/bcachefs/btree_io.c @@ -1483,23 +1483,32 @@ void bch2_btree_node_read(struct bch_fs *c, struct btree *b, struct btree_read_bio *rb; struct bch_dev *ca; struct bio *bio...
576179021c90bea808ac12c491bd9b239ca80c2e
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix btree_and_journal_iter
Problem Details: We had a bug where btree_and_journal_iter would return the same key twice - after deleting it (perhaps because it was present in both the btree and the journal?) This reworks btree_and_journal_iter to track the current position, much like btree_paths, which makes the logic considerably simpler and mor...
```diff diff --git a/fs/bcachefs/recovery.c b/fs/bcachefs/recovery.c index 5fe7595d36be..d755da42d6c5 100644 --- a/fs/bcachefs/recovery.c +++ b/fs/bcachefs/recovery.c @@ -159,21 +159,17 @@ static void journal_iters_fix(struct bch_fs *c) { struct journal_keys *keys = &c->journal_keys; /* The key we just inserted is...
f2aa02657561b0e6d96089eb8ee44e4154f4acad
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix for cmd_list_journal
Problem Details: cmd_list_journal wasn't correctly listing the most recent journal entries as blacklisted - because in the recovery path when just reading the journal, we were failing to add those to the blacklist table. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/recovery.c b/fs/bcachefs/recovery.c index edb04f65a148..5fe7595d36be 100644 --- a/fs/bcachefs/recovery.c +++ b/fs/bcachefs/recovery.c @@ -1175,9 +1175,6 @@ use_clean: blacklist_seq = journal_seq = le64_to_cpu(clean->journal_seq) + 1; } - if (c->opts.read_journal_only) - goto out...
636d4eef1eefe447deef134bdf8e34c979ff009e
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix memory corruption in encryption path
Problem Details: When do_encrypt() was passed a vmalloc address and the buffer spanned more than a single page, we were encrypting/decrypting completely different pages than the ones intended. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/checksum.c b/fs/bcachefs/checksum.c index 317efd047a46..e9a444f75b93 100644 --- a/fs/bcachefs/checksum.c +++ b/fs/bcachefs/checksum.c @@ -114,15 +114,41 @@ static inline int do_encrypt(struct crypto_sync_skcipher *tfm, struct nonce nonce, void *buf, size_t len) { - ...
9b688da35072910ec205697d2f51226cd3fd9f90
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix error checking in bch2_fs_alloc()
Problem Details: One of the init calls had a ; instead of a ?:, and errors after that got dropped - oops. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/super.c b/fs/bcachefs/super.c index 159d47d129a2..8d02a8158520 100644 --- a/fs/bcachefs/super.c +++ b/fs/bcachefs/super.c @@ -780,7 +780,7 @@ static struct bch_fs *bch2_fs_alloc(struct bch_sb *sb, struct bch_opts opts) bch2_fs_btree_key_cache_init(&c->btree_key_cache) ?: bch...
30525f68633740e071c0960c11c4380f1f6851af
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix journal_keys_search() overhead
Problem Details: Previously, on every btree_iter_peek() operation we were searching the journal keys, doing a full binary search - which was slow. This patch fixes that by saving our position in the journal keys, so that we only do a full binary search when moving our position backwards or a large jump forwards. Sign...
```diff diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index b840035dca55..3ce0571651b5 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -2242,13 +2242,30 @@ static inline struct bkey_i *btree_trans_peek_updates(struct btree_iter *iter) : NULL; } +struct bkey_i *bch2_btree...
c346def9af1d3890ee604905fb08d689e8383855
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix encryption path on arm
Problem Details: flush_dcache_page() is not a noop on arm, but we were using virt_to_page() instead of vmalloc_to_page() for an address on the kernel stack - vmalloc memory, leading to an oops in flush_dcache_page(). Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/checksum.c b/fs/bcachefs/checksum.c index 50157b4013a5..317efd047a46 100644 --- a/fs/bcachefs/checksum.c +++ b/fs/bcachefs/checksum.c @@ -116,7 +116,12 @@ static inline int do_encrypt(struct crypto_sync_skcipher *tfm, { struct scatterlist sg; - sg_init_one(&sg, buf, len); + sg_init...
e320b42dfeb5797a618edbba5186060b3907ba89
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix extent merging
Problem Details: When merging extents, we have to check that we won't overflow size fields in any CRC entries - but the check for this was wrong, because in the loop it was in we weren't keeping a pointer to the (packed, encoded) CRC field. Fix this by moving it to its own loop. Signed-off-by: Kent Overstreet <kent.o...
```diff diff --git a/fs/bcachefs/extents.c b/fs/bcachefs/extents.c index c56925d94bfe..d8f429ffe57c 100644 --- a/fs/bcachefs/extents.c +++ b/fs/bcachefs/extents.c @@ -307,8 +307,20 @@ bool bch2_extent_merge(struct bch_fs *c, struct bkey_s l, struct bkey_s_c r) lp.crc.uncompressed_size + rp.crc.uncompres...
099989c1b230e0f36ee7146d1df948822c999f6a
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix journal_iters_fix()
Problem Details: journal_iters_fix() was incorrectly rewinding iterators past keys they had already returned, leading to those keys being double counted in the bch2_gc() path - oops. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/recovery.c b/fs/bcachefs/recovery.c index 5831ab53a982..f54859b49416 100644 --- a/fs/bcachefs/recovery.c +++ b/fs/bcachefs/recovery.c @@ -147,7 +147,7 @@ static void journal_iters_fix(struct bch_fs *c) /* * If an iterator points one after the key we just inserted, - * and the ke...
fd4cecd2583e784ff28b851de2ff5046201c57d7
Analyze and fix the following issue in the Linux kernel code: bcachefs: Lock ordering fix
Problem Details: Can't take btree node locks while holding btree_reserve_cache_lock - it would be nice if we could check this with lockdep. 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 27ab1cde2217..9696eb2b91e7 100644 --- a/fs/bcachefs/btree_update_interior.c +++ b/fs/bcachefs/btree_update_interior.c @@ -383,16 +383,13 @@ static void bch2_btree_reserve_put(struct btree_update *as) struct bch_fs *c ...
d8f31407c842331a13c48404bc030f49d60f25aa
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix hash_check_key()
Problem Details: hash_check_key() was incorrectly handling transaction restarts - switch it to for_each_btree_key_norestart(). Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/fsck.c b/fs/bcachefs/fsck.c index d507b9fdd32e..f1abec95a740 100644 --- a/fs/bcachefs/fsck.c +++ b/fs/bcachefs/fsck.c @@ -740,8 +740,9 @@ static int hash_check_key(struct btree_trans *trans, if (hash_k.k->p.offset < hash) goto bad_hash; - for_each_btree_key(trans, iter, desc.btre...
7419646b254a599d7881e7815fc5e61b18c94b7e
Analyze and fix the following issue in the Linux kernel code: bcachefs: btree_update_interior.c prep for backpointers
Problem Details: Previously, btree_update_interior.c passed keys to bch2_trans_mark_* that hadn't been fully initialized - they didn't have the key field filled out, just the value. With backpointers, we need to make sure keys are fully initialized before marking them - because the backpointer points back to the origi...
```diff diff --git a/fs/bcachefs/btree_update_interior.c b/fs/bcachefs/btree_update_interior.c index 29de7afa9616..7a092d852930 100644 --- a/fs/bcachefs/btree_update_interior.c +++ b/fs/bcachefs/btree_update_interior.c @@ -509,18 +509,6 @@ static void btree_update_add_key(struct btree_update *as, bch2_keylist_push(ke...
c609947b5eae4bee096fde660a53a719ee65e191
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix for getting stuck in journal replay
Problem Details: In journal replay, we weren't immediately dropping journal pins when we start doing updates that ewern't from journal replay - leading to journal reclaim getting stuck. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/recovery.c b/fs/bcachefs/recovery.c index 16ba5d24a86d..dc11eae1bcaa 100644 --- a/fs/bcachefs/recovery.c +++ b/fs/bcachefs/recovery.c @@ -556,7 +556,8 @@ static int journal_keys_sort(struct bch_fs *c) static void replay_now_at(struct journal *j, u64 seq) { BUG_ON(seq < j->replay_jou...
e296b1f9cadfc4ee7ebe5933fb98497263ce9999
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix inode_backpointer_exists()
Problem Details: If the dirent an inode points to doesn't exist, we shouldn't be returning an error - just 0/false. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/fsck.c b/fs/bcachefs/fsck.c index 6a89b0694e50..ccbf3ac4b1d6 100644 --- a/fs/bcachefs/fsck.c +++ b/fs/bcachefs/fsck.c @@ -1092,7 +1092,7 @@ static int inode_backpointer_exists(struct btree_trans *trans, SPOS(inode->bi_dir, inode->bi_dir_offset, snapshot)); ret = bkey_err(d.s_c); ...
5650bb46be89a1254609d47e4c87d1e9cf9121fb
Analyze and fix the following issue in the Linux kernel code: bcachefs: Introduce bch2_journal_keys_peek_(upto|slot)()
Problem Details: When many journal replay keys have been overwritten, bch2_journal_keys_peek() was taking excessively long to scan before it found a key to return. Fix this by introducing bch2_journal_keys_peek_upto() which takes a parameter for the end of the range we want, so that we can terminate the search much so...
```diff diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index 1c0560ecd120..80ea97e21cf3 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -2225,10 +2225,10 @@ static noinline struct bkey_s_c btree_trans_peek_slot_journal(struct btree_trans *trans, struct btree_iter *...
9b93596c33f6c23de96c05dce82b9aead271a286
Analyze and fix the following issue in the Linux kernel code: bcachefs: Improve error message when alloc key doesn't match lru entry
Problem Details: Error messages should always print out the full key when available - this gives us a starting point when looking through the journal to debug what went wrong. 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 17b147d15320..1e6283b55e3b 100644 --- a/fs/bcachefs/alloc_background.c +++ b/fs/bcachefs/alloc_background.c @@ -1082,6 +1082,7 @@ static int invalidate_one_bucket(struct btree_trans *trans, struct bch_dev *ca) struct bkey_s_c k...
ec7ccbde6baa50760c2679a5c54b2fccfd5ca64e
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix CPU usage in journal read path
Problem Details: In journal_entry_add(), we were repeatedly scanning the journal entries radix tree to scan for old entries that can be freed, with O(n^2) behaviour. This patch tweaks things to remember the previous last_seq, so we don't have to scan for entries to free from the start. Signed-off-by: Kent Overstreet <...
```diff diff --git a/fs/bcachefs/journal_io.c b/fs/bcachefs/journal_io.c index 64341da75963..9e43914ebd6a 100644 --- a/fs/bcachefs/journal_io.c +++ b/fs/bcachefs/journal_io.c @@ -16,17 +16,17 @@ #include "replicas.h" #include "trace.h" -static inline u32 journal_entry_radix_idx(struct bch_fs *c, - struct jset...
6e811bbbc2ea3b20854c45fa29811640881bb534
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix a null ptr deref
Problem Details: We start doing allocations before the GC thread is created, which means we need to check for that to avoid a null ptr deref. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/btree_gc.h b/fs/bcachefs/btree_gc.h index 8de54005e4ea..95d803b5743d 100644 --- a/fs/bcachefs/btree_gc.h +++ b/fs/bcachefs/btree_gc.h @@ -105,7 +105,8 @@ static inline bool gc_visited(struct bch_fs *c, struct gc_pos pos) static inline void bch2_do_gc_gens(struct bch_fs *c) { atomic_...
a9c0a4cbf1ceb9842fee5d7084817509a5e962aa
Analyze and fix the following issue in the Linux kernel code: bcachefs: Minor device removal fixes
Problem Details: - We weren't clearing the LRU btree - bch2_alloc_read() runs before bch2_check_alloc_key() deletes alloc keys for devices/buckets that don't exists, so it needs to check for that - bch2_check_lrus() needs to check that buckets exists - improve some error messages Signed-off-by: Kent Overstree...
```diff diff --git a/fs/bcachefs/alloc_background.c b/fs/bcachefs/alloc_background.c index 6110d4ce4e5f..108b98c9fe45 100644 --- a/fs/bcachefs/alloc_background.c +++ b/fs/bcachefs/alloc_background.c @@ -446,6 +446,13 @@ int bch2_alloc_read(struct bch_fs *c) for_each_btree_key(&trans, iter, BTREE_ID_alloc, POS_MIN, ...
502f973dba660ed04f295e5ba129f2d369cc1aa6
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix a few warnings on 32 bit
Problem Details: These showed up when building for mips. 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 a84a8e088953..969507c42c55 100644 --- a/fs/bcachefs/bcachefs_format.h +++ b/fs/bcachefs/bcachefs_format.h @@ -851,10 +851,9 @@ struct bch_dirent { #define DT_SUBVOL 16 #define BCH_DT_MAX 17 -#define BCH_NAME_MAX (U8_MAX * sizeo...
ce6201c456571d919e722eec3c17f868f0575b05
Analyze and fix the following issue in the Linux kernel code: bcachefs: Use a genradix for reading journal entries
Problem Details: Previously, the journal read path used a linked list for storing the journal entries we read from disk. But there's been a bug that's been causing journal_flush_delay to incorrectly be set to 0, leading to far more journal entries than is normal being written out, which then means filesystems are no lo...
```diff diff --git a/fs/bcachefs/bcachefs.h b/fs/bcachefs/bcachefs.h index f2bb23162b4a..43e921b91d85 100644 --- a/fs/bcachefs/bcachefs.h +++ b/fs/bcachefs/bcachefs.h @@ -894,7 +894,8 @@ mempool_t bio_bounce_pages; mempool_t btree_bounce_pool; struct journal journal; - struct list_head journal_entries; + GENRA...
48620e5177ae7cd91722f5c504c5138160b90df4
Analyze and fix the following issue in the Linux kernel code: bcachefs: Topology repair fixes
Problem Details: - We were failing to start topology repair, because we hadn't set the superblock flag indicating it needed to run - set_node_min() forget to update the btree node's key - bch2_gc_alloc_reset() didn't reset data type, leading to inserting an invalid key that was empty but had nonzero data type ...
```diff diff --git a/fs/bcachefs/btree_gc.c b/fs/bcachefs/btree_gc.c index 747667ce131d..14b772cd8fe5 100644 --- a/fs/bcachefs/btree_gc.c +++ b/fs/bcachefs/btree_gc.c @@ -214,7 +214,7 @@ static int set_node_min(struct bch_fs *c, struct btree *b, struct bpos new_min) } bch2_btree_node_drop_keys_outside_node(b); - ...
1d8a268940045b73f43f86e6332bdfdfe64d0fa0
Analyze and fix the following issue in the Linux kernel code: bcachefs: Improve btree_bad_header()
Problem Details: In the future printbufs will be mempool-ified, so we shouldn't be using more than one at a time if we don't have to. This also fixes an extra trailing newline. 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 0e3db9ee65d2..6557fcb24b21 100644 --- a/fs/bcachefs/btree_cache.c +++ b/fs/bcachefs/btree_cache.c @@ -767,31 +767,29 @@ static int lock_node_check_fn(struct six_lock *lock, void *p) static noinline void btree_bad_header(struct bch_fs *c...
c6b6d416126da015e4b6b6a66b4c6fd3eda40f1f
Analyze and fix the following issue in the Linux kernel code: bcachefs: gc mark fn fixes, cleanups
Problem Details: mark_stripe_bucket() was busted; it was using @new unitialized. Also, clean up all the gc mark functions, and convert them to the same style. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/buckets.c b/fs/bcachefs/buckets.c index dcb2ea3de4b8..5b78e8f983a1 100644 --- a/fs/bcachefs/buckets.c +++ b/fs/bcachefs/buckets.c @@ -624,13 +624,13 @@ int bch2_mark_alloc(struct btree_trans *trans, return 0; } -void bch2_mark_metadata_bucket(struct bch_fs *c, struct bch_dev *ca, -...
c32fc674d4ca13f3b889693a2b59365d93a77144
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix pr_buf() calls
Problem Details: In a few places we were passing a variable to pr_buf() for the format string - oops. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/opts.c b/fs/bcachefs/opts.c index 77fbb7d2194e..385451ef865e 100644 --- a/fs/bcachefs/opts.c +++ b/fs/bcachefs/opts.c @@ -324,7 +324,7 @@ void bch2_opt_to_text(struct printbuf *out, if (flags & OPT_SHOW_FULL_LIST) bch2_string_opt_to_text(out, opt->choices, v); else - pr_buf(...
70a9953c424ccba616a3b74368780de13a80dabd
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix bch2_journal_pin_set()
Problem Details: When bch2_journal_pin_set() is updating an existing pin, we shouldn't call bch2_journal_reclaim_fast() after dropping the old pin and before dropping the new pin - that could reclaim the entry we're trying to pin. 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 b30730ce58c5..f55fc0b11977 100644 --- a/fs/bcachefs/journal_reclaim.c +++ b/fs/bcachefs/journal_reclaim.c @@ -346,13 +346,13 @@ void bch2_journal_pin_put(struct journal *j, u64 seq) } } -static inline void __journal_pin_drop(s...
d864842581e70d2280f2a51ceb2ad6e7cefeed94
Analyze and fix the following issue in the Linux kernel code: bcachefs: btree_path_make_mut() clears should_be_locked
Problem Details: This fixes a bug where __bch2_btree_node_update_key() wasn't clearing should_be_locked, leading to bch2_btree_path_traverse() always failing - all callers of btree_path_make_mut() want should_be_locked cleared, so do it there. 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 bfba10b1c127..3a4ed2f70cc2 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -1662,9 +1662,8 @@ static struct btree_path *btree_path_clone(struct btree_trans *trans, struct btr return new; } -struct btree_path * __...
81cdc8f3070561786a906c66d697666e6a3319b9
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix error path in bch2_snapshot_set_equiv()
Problem Details: We weren't properly catching errors from snapshot_live() - oops. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/subvolume.c b/fs/bcachefs/subvolume.c index 2c5f7e7793a7..20c6b21e54d3 100644 --- a/fs/bcachefs/subvolume.c +++ b/fs/bcachefs/subvolume.c @@ -139,7 +139,7 @@ static int bch2_snapshots_set_equiv(struct btree_trans *trans) for_each_btree_key(trans, iter, BTREE_ID_snapshots, POS_M...
7fda0f08fa86731f057367ca36054d29d0c0344c
Analyze and fix the following issue in the Linux kernel code: bcachefs: Work around a journal self-deadlock
Problem Details: bch2_journal_space_available -> bch2_journal_halt() self deadlocks on journal lock; work around this by dropping/retaking journal lock before we call bch2_fatal_error(). 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 56b0c018ac26..b30730ce58c5 100644 --- a/fs/bcachefs/journal_reclaim.c +++ b/fs/bcachefs/journal_reclaim.c @@ -216,7 +216,14 @@ void bch2_journal_space_available(struct journal *j) bch_err(c, "journal stuck\n%s", buf.buf); pri...
30690c441a6b481aadb0284d1b9bf487f8d28bfc
Analyze and fix the following issue in the Linux kernel code: bcachefs: Heap code fix
Problem Details: When deleting an entry from a heap that was at entry h->used - 1, we'd end up calling heap_sift() on an entry outside the heap - the entry we just removed - which would end up re-adding it to the heap and deleting something we didn't want to delete. Oops... Signed-off-by: Kent Overstreet <kent.overstr...
```diff diff --git a/fs/bcachefs/util.h b/fs/bcachefs/util.h index f2df4d7fbec9..fd776fb281b7 100644 --- a/fs/bcachefs/util.h +++ b/fs/bcachefs/util.h @@ -210,9 +210,11 @@ do { \ \ BUG_ON(_i >= (h)->used); \ (h)->used--; \ - heap_swap(h, _i, (h)->used, set_backpointer); \ - heap_sift_u...
fd1e9c69959ec2dd0946f3d2285548c87f9d6ea3
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix an unitialized var warning in userspace
Problem Details: Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/io.c b/fs/bcachefs/io.c index c9204cab055d..2cc56979fcb3 100644 --- a/fs/bcachefs/io.c +++ b/fs/bcachefs/io.c @@ -1141,7 +1141,7 @@ static void __bch2_write(struct closure *cl) struct bch_write_op *op = container_of(cl, struct bch_write_op, cl); struct bch_fs *c = op->c; struct wr...
b8559f1a212a7035b430b83e0a01e94a872adc23
Analyze and fix the following issue in the Linux kernel code: bcachefs: Reset journal flush delay to default value if zeroed
Problem Details: We've been seeing a very strange bug where journal flush & reclaim delay end up getting inexplicably zeroed, in the superblock. We're now validating all the options in bch2_validate_super(), and 0 is no longer a valid value for those options, but we need to be careful not to prevent people's filesystem...
```diff diff --git a/fs/bcachefs/super-io.c b/fs/bcachefs/super-io.c index 224653f129f8..6d54319a95e6 100644 --- a/fs/bcachefs/super-io.c +++ b/fs/bcachefs/super-io.c @@ -253,7 +253,8 @@ static int validate_sb_layout(struct bch_sb_layout *layout, struct printbuf *out return 0; } -static int bch2_sb_validate(struct...
b0be2fcfb425022025203c27ed75a20db8c6feda
Analyze and fix the following issue in the Linux kernel code: bcachefs: Change journal_io.c assertion to error message
Problem Details: Something funny is going on with the new code for restoring the journal write point, and it's hard to reproduce. We do want to debug this because resuming writing to the journal in the wrong spot could be something serious. For now, replace the assertion with an error message and revert to old behavio...
```diff diff --git a/fs/bcachefs/journal_io.c b/fs/bcachefs/journal_io.c index ba43e5771c7c..b2c3ee336c1f 100644 --- a/fs/bcachefs/journal_io.c +++ b/fs/bcachefs/journal_io.c @@ -964,8 +964,16 @@ static void bch2_journal_read_device(struct closure *cl) } mutex_unlock(&jlist->lock); - BUG_ON(ja->bucket_seq[ja->cur...
7a6f4411aeaae888a7b2880f0c046f9efb0d83cc
Analyze and fix the following issue in the Linux kernel code: bcachefs: Make minimum journal_flush_delay nonzero
Problem Details: We're seeing a very strange bug where journal_flush_delay sometimes gets set to 0 in the superblock. Together with the preceding patch, this should help us track it down. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/opts.h b/fs/bcachefs/opts.h index 69ca75429943..b45740ec3c67 100644 --- a/fs/bcachefs/opts.h +++ b/fs/bcachefs/opts.h @@ -275,7 +275,7 @@ enum opt_type { NULL, "Extra debugging information during mount/recovery")\ x(journal_flush_delay, u32, \ OPT_FS|OPT_MOUNT|OPT_RUNTIME...
3a306f3c2c303febffefea4caf09b2326107507a
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix large key cache keys
Problem Details: Previously, we'd go into an infinite loop when attempting to cache a bkey in the key cache larger than 128 u64s - since we were only using a u8 for the size field, it'd get rounded up to 256 then truncated to 0. Oops. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/btree_types.h b/fs/bcachefs/btree_types.h index 51eb686331bf..a8b08955cedc 100644 --- a/fs/bcachefs/btree_types.h +++ b/fs/bcachefs/btree_types.h @@ -323,7 +323,7 @@ struct bkey_cached { struct btree_bkey_cached_common c; unsigned long flags; - u8 u64s; + u16 u64s; bool v...
5d93a842c1eb292e2cde9f5025628269d7d386e0
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix BTREE_TRIGGER_WANTS_OLD_AND_NEW
Problem Details: BTREE_TRIGGER_WANTS_OLD_AND_NEW didn't work correctly when the old and new key were both alloc keys, but different versions - it required old and new key type to be identical, and this bug is a problem for the new allocator rewrite. This patch fixes it by checking if the old and new key have the same ...
```diff diff --git a/fs/bcachefs/btree_update_leaf.c b/fs/bcachefs/btree_update_leaf.c index a789a7cf4c74..cb0cab71b99b 100644 --- a/fs/bcachefs/btree_update_leaf.c +++ b/fs/bcachefs/btree_update_leaf.c @@ -442,7 +442,8 @@ static int run_one_mem_trigger(struct btree_trans *trans, if (!btree_node_type_needs_gc(i->btre...
880e2275f9f1461c87cd113a8da291861cc01400
Analyze and fix the following issue in the Linux kernel code: bcachefs: Move trigger fns to bkey_ops
Problem Details: This replaces the switch statements in bch2_mark_key(), bch2_trans_mark_key() with new bkey methods - prep work for the next patch, which fixes BTREE_TRIGGER_WANTS_OLD_AND_NEW. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
```diff diff --git a/fs/bcachefs/alloc_background.h b/fs/bcachefs/alloc_background.h index 98c7866e20b5..3eaa6d204286 100644 --- a/fs/bcachefs/alloc_background.h +++ b/fs/bcachefs/alloc_background.h @@ -65,16 +65,19 @@ void bch2_alloc_to_text(struct printbuf *, struct bch_fs *, struct bkey_s_c); #define bch2_bkey_ops_...