id
stringlengths
40
40
instruction
stringlengths
68
308
input
stringlengths
17
33.4k
output
stringlengths
100
30k
a64adedb8663ded044e535159b2e723a04396845
Analyze and fix the following issue in the Linux kernel code: bcachefs: ec: Ensure new stripe is closed in error path
Problem Details: This fixes a use-after-free bug. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/ec.c b/fs/bcachefs/ec.c index 88f319992c37..cb291b2a4dd8 100644 --- a/fs/bcachefs/ec.c +++ b/fs/bcachefs/ec.c @@ -1107,8 +1107,6 @@ static void ec_stripe_create(struct ec_stripe_new *s) bch2_err_str(ret)); goto err; } - - bch2_stripe_close(c, s); err: bch2_disk_reservation_p...
94bc95c468344d6a329dd87ab4461532584a7b71
Analyze and fix the following issue in the Linux kernel code: bcachefs: ec: zero_out_rest_of_ec_bucket()
Problem Details: Occasionally, we won't write to an entire bucket. This fixes the EC code to handle this case, zeroing out the rest of the bucket as needed. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/ec.c b/fs/bcachefs/ec.c index 473f1c09e106..88f319992c37 100644 --- a/fs/bcachefs/ec.c +++ b/fs/bcachefs/ec.c @@ -1003,6 +1003,35 @@ err: return ret; } +static void zero_out_rest_of_ec_bucket(struct bch_fs *c, + struct ec_stripe_new *s, + unsigned block, + ...
747ded6ddfe88eb9644ee0512c061e46fe2fb09d
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix for shared paths in write buffer flush
Problem Details: It's possible for bch2_write_buffer_flush_one() to end up with a shared path, if called from a context that already has a btree iterator pointing to a key being flushed. We have to be careful when that happens, since we can't clone a path that holds write locks. Signed-off-by: Kent Overstreet <kent.ov...
```diff diff --git a/fs/bcachefs/btree_write_buffer.c b/fs/bcachefs/btree_write_buffer.c index 6285532e7790..026c249a3f44 100644 --- a/fs/bcachefs/btree_write_buffer.c +++ b/fs/bcachefs/btree_write_buffer.c @@ -64,6 +64,15 @@ static int bch2_btree_write_buffer_flush_one(struct btree_trans *trans, bch2_btree_insert_...
70ded998c5abef9907b8d42a5118dddd3de67160
Analyze and fix the following issue in the Linux kernel code: bcachefs: get_stripe_key_trans()
Problem Details: Another nested btree_trans fix Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/ec.c b/fs/bcachefs/ec.c index 123ca0b0b43f..b711f33f0e03 100644 --- a/fs/bcachefs/ec.c +++ b/fs/bcachefs/ec.c @@ -442,15 +442,14 @@ static void ec_block_io(struct bch_fs *c, struct ec_stripe_buf *buf, percpu_ref_put(&ca->io_ref); } -static int get_stripe_key(struct bch_fs *c, u64 i...
e3877382fb9d0a8ae43c7e012742622bbd6e6d17
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix erasure coding shutdown path
Problem Details: It's possible when shutting down to for a stripe head to have a new stripe that doesn't yet have any blocks allocated - we just need to free it. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/ec.c b/fs/bcachefs/ec.c index 4b054f7c4d4e..123ca0b0b43f 100644 --- a/fs/bcachefs/ec.c +++ b/fs/bcachefs/ec.c @@ -1764,6 +1764,7 @@ void bch2_new_stripes_to_text(struct printbuf *out, struct bch_fs *c) void bch2_fs_ec_exit(struct bch_fs *c) { struct ec_stripe_head *h; + unsigned i; ...
64784ade4fd75cdd47d7ddfbfcbed3506fe10523
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix buffer overrun in ec_stripe_update_extent()
Problem Details: Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/ec.c b/fs/bcachefs/ec.c index 924494868102..4b054f7c4d4e 100644 --- a/fs/bcachefs/ec.c +++ b/fs/bcachefs/ec.c @@ -865,25 +865,6 @@ err: return ret; } -static void extent_stripe_ptr_add(struct bkey_s_extent e, - struct ec_stripe_buf *s, - struct bch_extent_ptr *ptr, - ...
930256d4fbe7b8dee8f1a1658630655d8c6043f8
Analyze and fix the following issue in the Linux kernel code: bcachefs: __bch2_btree_insert uses BTREE_INSERT_CACHED
Problem Details: Cached btrees should be doing cached updates by default: this fixes a bug in the migrate tool. 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 544b90b15260..0bf4116442f4 100644 --- a/fs/bcachefs/btree_update_leaf.c +++ b/fs/bcachefs/btree_update_leaf.c @@ -1749,6 +1749,7 @@ int __bch2_btree_insert(struct btree_trans *trans, enum btree_id id, int ret; bch2_trans_...
7546c78df1963c60b2b6b80265daa26462b87ec5
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix ec repair code check
Problem Details: 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 959f4081b42f..8ae838acd853 100644 --- a/fs/bcachefs/btree_gc.c +++ b/fs/bcachefs/btree_gc.c @@ -661,7 +661,7 @@ static int bch2_check_fix_ptrs(struct btree_trans *trans, enum btree_id btree_id bch2_bkey_val_to_text(&buf, c, *k), buf.buf))...
5e2d8be8bd7985aa590dcccec14fb38fb529b3f0
Analyze and fix the following issue in the Linux kernel code: bcachefs: Split trans->last_begin_ip and trans->last_restarted_ip
Problem Details: These are two different things - this improves our debug assert messages. 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 5ab22c4c2b2e..63213205a043 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -976,6 +976,7 @@ static int bch2_btree_path_traverse_all(struct btree_trans *trans) trans->in_traverse_all = true; retry_all: trans->rest...
73d86dfd888541fd85f7e4d03c898f2ad8486196
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix erasure coding locking
Problem Details: This adds a new helper, bch2_trans_mutex_lock(), for locking a mutex - dropping and retaking btree locks as needed. 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 2eab63b90664..0b0fe4fea6cc 100644 --- a/fs/bcachefs/alloc_foreground.c +++ b/fs/bcachefs/alloc_foreground.c @@ -1073,7 +1073,7 @@ static bool try_decrease_writepoints(struct bch_fs *c, return true; } -static void bch2_trans_...
6623c0fcdffe22db466ec38c5f9f4b3a44c33003
Analyze and fix the following issue in the Linux kernel code: bcachefs: Add an assertion for using multiple btree_trans
Problem Details: A thread should never be using more than one btree_trans - doing so is an invitation for deadlocks. 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 4ac1364acc8b..5ab22c4c2b2e 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -2955,6 +2955,15 @@ void __bch2_trans_init(struct btree_trans *trans, struct bch_fs *c, unsigned fn_ mutex_lock(&c->btree_trans_lock); ...
2c7dd446d91681e90396c82e20c703b93f8daa2f
Analyze and fix the following issue in the Linux kernel code: bcachefs: Erasure coding now uses bch2_bucket_alloc_trans
Problem Details: This code predates plumbing btree_trans through the bucket allocation path: switching to it fixes a deadlock due to using multiple btree_trans at the same time, which we never want to do. 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 9e1c236d57b8..2eab63b90664 100644 --- a/fs/bcachefs/alloc_foreground.c +++ b/fs/bcachefs/alloc_foreground.c @@ -713,7 +713,7 @@ static void add_new_bucket(struct bch_fs *c, ob_push(c, ptrs, ob); } -static int bch2_bucket_all...
f2c6e4b3621778103805fe4d5f384db3fcd96159
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix integer overflow warnings on 32 bit
Problem Details: Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/util.c b/fs/bcachefs/util.c index 12f4107662fc..e0c93da2523f 100644 --- a/fs/bcachefs/util.c +++ b/fs/bcachefs/util.c @@ -428,8 +428,8 @@ static const struct time_unit { { "us", NSEC_PER_USEC }, { "ms", NSEC_PER_MSEC }, { "s", NSEC_PER_SEC }, - { "m", NSEC_PER_SEC *...
f2a53270c7d6bceae5441ed180516d3b76799680
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix insert_snapshot_whiteouts()
Problem Details: - We were failing to set the key type on the whiteouts it was creating, oops. - Also, we need to create whiteouts when generating front splits, not just back splits. 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 09a5fff339fe..c3adc7b32e19 100644 --- a/fs/bcachefs/data_update.c +++ b/fs/bcachefs/data_update.c @@ -21,9 +21,10 @@ static int insert_snapshot_whiteouts(struct btree_trans *trans, struct bpos new_pos) { struct bch_fs *c = tra...
19d6521964ed0439a7a03776d8cf0451afb63c1d
Analyze and fix the following issue in the Linux kernel code: bcachefs: bch2_mark_snapshot() now called like other triggers
Problem Details: This fixes a bug where bch2_mark_snapshot() wasn't called for existing snapshot nodes being updated when child nodes were added. This led to the data update path thinking the key being updated was for a snapshot that didn't have children, causing it to fail to insert whiteouts when splitting existing ...
```diff diff --git a/fs/bcachefs/subvolume.c b/fs/bcachefs/subvolume.c index 1805c8542d65..ba281104eb30 100644 --- a/fs/bcachefs/subvolume.c +++ b/fs/bcachefs/subvolume.c @@ -512,8 +512,7 @@ int bch2_snapshot_node_create(struct btree_trans *trans, u32 parent, n->v.pad = 0; SET_BCH_SNAPSHOT_SUBVOL(&n->v, true); ...
2ffe3ad62dafac036c523204c6e2e2f39b23cb6f
Analyze and fix the following issue in the Linux kernel code: bcachefs: Snapshot whiteout fix
Problem Details: When fully overwriting an existing extent, we may need to generate a whiteout - not just if the extent being overwritten was in an older snapshot, but also if it was overwriting an extent in an older snapshot. 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 0fc98b43a073..544b90b15260 100644 --- a/fs/bcachefs/btree_update_leaf.c +++ b/fs/bcachefs/btree_update_leaf.c @@ -1307,6 +1307,39 @@ static noinline int extent_back_merge(struct btree_trans *trans, return 0; } +/* + * When...
564fbd9dd6329abde8aca143da26ffbada13ff7d
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix a 64 bit divide
Problem Details: This fixes a build failure on 32 bit Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/backpointers.c b/fs/bcachefs/backpointers.c index c269fc73a41d..e001f4191671 100644 --- a/fs/bcachefs/backpointers.c +++ b/fs/bcachefs/backpointers.c @@ -738,7 +738,7 @@ static size_t btree_nodes_fit_in_ram(struct bch_fs *c) si_meminfo(&i); mem_bytes = i.totalram * i.mem_unit; - r...
70f0b0fd7e9b85a14fdb8b3f229572b7439d8915
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix verify_update_old_key()
Problem Details: This fixes a very-rare race in our assertion, with needs_whiteout being modified in the btree key. 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 cefe62d28cc0..3773439d031a 100644 --- a/fs/bcachefs/btree_update_leaf.c +++ b/fs/bcachefs/btree_update_leaf.c @@ -56,9 +56,10 @@ static void verify_update_old_key(struct btree_trans *trans, struct btree_insert k = bkey_i_to...
429dd4270fab3c88a8bfcb5b2b8c6d60ec6a1f2a
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix verify_bucket_evacuated()
Problem Details: This fixes an incorrectly handled transaction restart. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/move.c b/fs/bcachefs/move.c index c2226353c775..67f861eb597a 100644 --- a/fs/bcachefs/move.c +++ b/fs/bcachefs/move.c @@ -583,7 +583,7 @@ int bch2_move_data(struct bch_fs *c, return ret; } -static int verify_bucket_evacuated(struct btree_trans *trans, struct bpos bucket, int gen) +...
4bd4035e64c2a90b9c939135e95be0106205b370
Analyze and fix the following issue in the Linux kernel code: bcachefs: Handle sb buffer resizing in __copy_super()
Problem Details: This fixes a rare buffer overrun when one field is growing and another field is shrinking - and is a nice simplification as well. 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 ff27ae1839a8..e311b1b4595a 100644 --- a/fs/bcachefs/super-io.c +++ b/fs/bcachefs/super-io.c @@ -435,7 +435,7 @@ static void bch2_sb_update(struct bch_fs *c) ca->mi = bch2_mi_to_cpu(mi->members + i); } -static void __copy_super(struct bch_s...
806c8a6aa83410cf78dc13fc63bb5df6352670f2
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix failure to read btree roots
Problem Details: If failed to read a btree root - or if we're not using a btree root, because of the reconstruct_alloc option - make sure we update the corresponding info for the key/level for the root on disk. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/recovery.c b/fs/bcachefs/recovery.c index 8a78377bf9c5..178f06424460 100644 --- a/fs/bcachefs/recovery.c +++ b/fs/bcachefs/recovery.c @@ -974,9 +974,15 @@ static int read_btree_roots(struct bch_fs *c) } } - for (i = 0; i < BTREE_ID_NR; i++) - if (!c->btree_roots[i].b) + for (i =...
3277081522d8620f7410b173881d4b0267ce58f9
Analyze and fix the following issue in the Linux kernel code: bcachefs: Don't run triggers when repairing in __bch2_mark_reflink_p()
Problem Details: Triggers current trip-up on the faulty reflink we're trying to repair, Disabling them lets us fix broken reflink and continue. Signed-off-by: Daniel Hill <daniel@gluo.nz> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/buckets.c b/fs/bcachefs/buckets.c index 32750a65d37a..2e1751eeaef4 100644 --- a/fs/bcachefs/buckets.c +++ b/fs/bcachefs/buckets.c @@ -1225,7 +1225,7 @@ not_found: new->k.p.offset += *idx - start; bch2_key_resize(&new->k, next_idx - *idx); ret = __bch2_btree_insert(trans, BTREE_...
0093b9e9704cc932363c66b2b072b762771ffe1f
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix promote path leak
Problem Details: Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/io.c b/fs/bcachefs/io.c index 93d300812b4b..1436863fe418 100644 --- a/fs/bcachefs/io.c +++ b/fs/bcachefs/io.c @@ -1924,6 +1924,8 @@ static void promote_free(struct bch_fs *c, struct promote_op *op) { int ret; + bch2_data_update_exit(&op->write); + ret = rhashtable_remove_fast(&c-...
46eea9cb9ec14684d1b6e90c17db1ac896f26a5b
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix move_ctxt_wait_event()
Problem Details: We shouldn't be evaluating cond again if it already returned true. This fixes a bug when this helper is used for taking nocow locks. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/move.h b/fs/bcachefs/move.h index a2822d4a4afb..34b9cadef6b5 100644 --- a/fs/bcachefs/move.h +++ b/fs/bcachefs/move.h @@ -28,14 +28,18 @@ struct moving_context { wait_queue_head_t wait; }; -#define move_ctxt_wait_event(_ctxt, _trans, _cond) \ -do { \ - bch2_moving_ctxt_do_p...
7ffb6a7ec6712eb1ba84a80137c2f712e67c4171
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix deadlock on nocow locks in data move path
Problem Details: The recent nocow locking rework introduced a deadlock in the data move path: the new nocow locking scheme uses a hash table with a fixed size array for chaining, meaning on hash collision we may have to wait for other locks to be released before we can lock a bucket. And since the data move path needs...
```diff diff --git a/fs/bcachefs/data_update.c b/fs/bcachefs/data_update.c index eb248968de48..91bc95b8ecb9 100644 --- a/fs/bcachefs/data_update.c +++ b/fs/bcachefs/data_update.c @@ -397,13 +397,16 @@ void bch2_update_unwritten_extent(struct btree_trans *trans, } } -int bch2_data_update_init(struct bch_fs *c, stru...
15949c549993a2383ebacf6c563b85722278fba3
Analyze and fix the following issue in the Linux kernel code: bcachefs: Don't stop copygc while removing devices
Problem Details: With the new backpointer based copygc we don't need an explicit copygc reserve, we're always evacuating buckets one at a time - so this is no longer needed, and in fact removing it fixes a deadlock in bch2_dev_allocator_remove(). Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/super.c b/fs/bcachefs/super.c index c5efaa7d38a8..2fb7e6300ea5 100644 --- a/fs/bcachefs/super.c +++ b/fs/bcachefs/super.c @@ -1345,19 +1345,11 @@ static bool bch2_fs_may_start(struct bch_fs *c) static void __bch2_dev_read_only(struct bch_fs *c, struct bch_dev *ca) { - /* - * Device...
dea5647e16d15ee7c47dbe11b1f68ec221dc51be
Analyze and fix the following issue in the Linux kernel code: bcachefs: Erasure coding now uses backpointers
Problem Details: This is only a start to updating erasure coding for backpointers - it's still not working yet. The subsequent patch will delete our old in memory backpointers for copygc, and this fixes a spurious EPERM bug/error message. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/ec.c b/fs/bcachefs/ec.c index af6a23021381..68f5314b51e6 100644 --- a/fs/bcachefs/ec.c +++ b/fs/bcachefs/ec.c @@ -4,10 +4,12 @@ #include "bcachefs.h" #include "alloc_foreground.h" +#include "backpointers.h" #include "bkey_buf.h" #include "bset.h" #include "btree_gc.h" #include "...
5f5c74661713327309f124e247de61db6729bc3d
Analyze and fix the following issue in the Linux kernel code: bcachefs: Start copygc when first going read-write
Problem Details: In the distant past, it wasn't possible to start copygc until after journal replay had finished. Now, the btree iterator code overlays keys from the journal, so there's no reason not to start it earlier - and it solves a rare deadlock. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/recovery.c b/fs/bcachefs/recovery.c index 80736be21b9f..ebdf9f754e08 100644 --- a/fs/bcachefs/recovery.c +++ b/fs/bcachefs/recovery.c @@ -1267,6 +1267,20 @@ use_clean: goto err; bch_verbose(c, "done checking need_discard and freespace btrees"); + if (c->sb.version < bcachefs_m...
d94189ad568f6cbd80d372cf7aa6e4898b6c5c17
Analyze and fix the following issue in the Linux kernel code: bcachefs: Debug mode for c->writes references
Problem Details: This adds a debug mode where we split up the c->writes refcount into distinct refcounts for every codepath that takes a reference, and adds sysfs code to print the value of each ref. This will make it easier to debug shutdown hangs due to refcount leaks. Signed-off-by: Kent Overstreet <kent.overstree...
```diff diff --git a/fs/bcachefs/alloc_background.c b/fs/bcachefs/alloc_background.c index 388a44858097..1db0b6253661 100644 --- a/fs/bcachefs/alloc_background.c +++ b/fs/bcachefs/alloc_background.c @@ -1113,7 +1113,7 @@ static void bch2_do_discards_work(struct work_struct *work) if (need_journal_commit * 2 > seen) ...
06ab86d596170b9f3b88ce3f8e9fea7e9c1ea0c2
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix btree_node_write_blocked() not being cleared
Problem Details: The btree_node_write_blocked bit was a later addition to this code, it only mirrors the state of the b->write_blocked list (empty or nonempty) - unfortunately, when it was added it wasn't correctly kept in sync - 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 566838317845..4e9c963dbd23 100644 --- a/fs/bcachefs/btree_update_interior.c +++ b/fs/bcachefs/btree_update_interior.c @@ -161,6 +161,7 @@ static void __btree_node_free(struct bch_fs *c, struct btree *b) { trace_and_c...
992fa4e62020d257197efa4ec567499d52e9c381
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix btree_path_alloc()
Problem Details: We need to call bch2_trans_update_max_paths() before marking the new path as allocated, since we're not initializing it yet. 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 e5c82aa9bfeb..3d138ae19469 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -1507,6 +1507,14 @@ static inline struct btree_path *btree_path_alloc(struct btree_trans *trans, btree_path_overflow(trans); idx = __ff...
d7afe651ffa29fca79725a3cf5580a3fd2421fed
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix memleak in replicas_table_update()
Problem Details: Signed-off-by: Brett Holman <bholman.devel@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/replicas.c b/fs/bcachefs/replicas.c index 482bedf4be8b..3bff21959d98 100644 --- a/fs/bcachefs/replicas.c +++ b/fs/bcachefs/replicas.c @@ -299,13 +299,6 @@ static int replicas_table_update(struct bch_fs *c, memset(new_usage, 0, sizeof(new_usage)); - for (i = 0; i < ARRAY_SIZE(new_u...
5b3008bc6182e56fdd5ba36fdf324430d0792e0c
Analyze and fix the following issue in the Linux kernel code: bcachefs: Don't call bch2_journal_pin_drop() under key cache lock
Problem Details: This fixes a (harmless) lockdep splat, due to a lock order violation in the key cache exit path. 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 743ebeba12b1..867f063f22d1 100644 --- a/fs/bcachefs/btree_key_cache.c +++ b/fs/bcachefs/btree_key_cache.c @@ -947,6 +947,7 @@ void bch2_fs_btree_key_cache_exit(struct btree_key_cache *bc) struct bucket_table *tbl; struct bkey_c...
464b415539cc543addb45b85e76c44da145b114c
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix bch2_trans_reset_updates()
Problem Details: This should have been resetting trans->fs_usage_deltas as well. 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 3774ee8577a9..1a71e8af52d0 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -2792,14 +2792,6 @@ u32 bch2_trans_begin(struct btree_trans *trans) trans->restart_count++; trans->mem_top = 0; - if (trans->fs_usage_...
419fc65f8cfbadb29b2024457bf914787af8db91
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix hash_check_key()
Problem Details: On hash collision when we have to check for duplicates or incorrect hash value, we weren't specifying a snapshot ID to iterate with. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/fsck.c b/fs/bcachefs/fsck.c index 0124aa0b14c5..e0d7ab67ca35 100644 --- a/fs/bcachefs/fsck.c +++ b/fs/bcachefs/fsck.c @@ -821,7 +821,7 @@ static int hash_check_key(struct btree_trans *trans, goto bad_hash; for_each_btree_key_norestart(trans, iter, desc.btree_id, - POS(has...
3e57db65cdd93bee55d1ecf53ff4ab895e05c40e
Analyze and fix the following issue in the Linux kernel code: bcachefs: Use trylock in bch2_prt_backtrace()
Problem Details: Easy workaround for a lockdep splat - and since bch2_prt_backtrace() is only used in debug code this is fine. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/util.c b/fs/bcachefs/util.c index 31934f7a6436..e6672b67ae32 100644 --- a/fs/bcachefs/util.c +++ b/fs/bcachefs/util.c @@ -270,11 +270,9 @@ int bch2_prt_backtrace(struct printbuf *out, struct task_struct *task) { unsigned long entries[32]; unsigned i, nr_entries; - int ret; - ret ...
f52dd1ae20ac8094eb881f816e7274d3f7910a84
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix bch_alloc_to_text()
Problem Details: We weren't guarding against the alloc key having an invalid data type. 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 d75738134f94..388a44858097 100644 --- a/fs/bcachefs/alloc_background.c +++ b/fs/bcachefs/alloc_background.c @@ -351,7 +351,10 @@ void bch2_alloc_to_text(struct printbuf *out, struct bch_fs *c, struct bkey_s_c printbuf_indent_ad...
db36c1477d1753f4d5bebaed074ca4e4477df3ea
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix bch2_bucket_alloc_early()
Problem Details: We were incorrectly retrying after a transaction restart. 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 3219c37d9262..471ae15caa75 100644 --- a/fs/bcachefs/alloc_foreground.c +++ b/fs/bcachefs/alloc_foreground.c @@ -421,12 +421,15 @@ again: ca->alloc_cursor = alloc_cursor; + if (!ob && ret) + ob = ERR_PTR(ret); + if (!ob &...
d7dd3fb84f05a0d221be3979929706a4828fb252
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix rereplicate when we already have a cached pointer
Problem Details: When we need to add more replicas to an extent, it might be the case that we already have a replica on every device, but some of them are cached. This patch fixes a bug where we'd spin on that extent because the write path fails to find a device we can allocate from: we allow allocating from devices t...
```diff diff --git a/fs/bcachefs/data_update.c b/fs/bcachefs/data_update.c index b4480852e935..acb634b3480b 100644 --- a/fs/bcachefs/data_update.c +++ b/fs/bcachefs/data_update.c @@ -183,7 +183,17 @@ int bch2_data_update_index_update(struct bch_write_op *op) /* Add new ptrs: */ extent_for_each_ptr_decode(extent...
7c909f654bae57083a0965f105e52ac8737a0785
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix repair path in bch2_mark_reflink_p()
Problem Details: Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/buckets.c b/fs/bcachefs/buckets.c index 4fd396cb1dad..6c9dcfd54be6 100644 --- a/fs/bcachefs/buckets.c +++ b/fs/bcachefs/buckets.c @@ -1213,17 +1213,23 @@ not_found: " missing range %llu-%llu", (bch2_bkey_val_to_text(&buf, c, p.s_c), buf.buf), *idx, next_idx)) { ...
834dc29d521d34718602bfb8d93d370093a5d430
Analyze and fix the following issue in the Linux kernel code: bcachefs: debug: Fix some locking bugs
Problem Details: This fixes a few error paths in debug code that lead to locks failing to be dropped. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/debug.c b/fs/bcachefs/debug.c index ab210296223b..fcefd55a5322 100644 --- a/fs/bcachefs/debug.c +++ b/fs/bcachefs/debug.c @@ -520,7 +520,7 @@ static ssize_t bch2_btree_transactions_read(struct file *file, char __user *buf, ret = flush_buf(i); if (ret) - return ret; + break; ...
e9a1da97377f89f09e6b0b484554fe7a0e2dbe3e
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix compat path for old inode formats
Problem Details: Old inode formats don't have all the fields of the current inode format: when unpacking inodes in the current format we can thus skip zeroing out the destination buffer, but that doesn't work on for the old formats. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/inode.c b/fs/bcachefs/inode.c index 141cf21e2951..6e7ba2e6fe33 100644 --- a/fs/bcachefs/inode.c +++ b/fs/bcachefs/inode.c @@ -213,6 +213,8 @@ static int bch2_inode_unpack_v2(struct bch_inode_unpacked *unpacked, int bch2_inode_unpack(struct bkey_s_c k, struct bch_inode_unpacked...
ee2c6ea7760eceee3051ef2f2046d16dc5ab06ec
Analyze and fix the following issue in the Linux kernel code: bcachefs: btree_iter->ip_allocated
Problem Details: In debug mode, we now track where btree iterators and paths are initialized/allocated - helpful in tracking down btree path overflows. 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 0a0d3aa05395..5034f8ebfb04 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -24,6 +24,15 @@ static inline void btree_path_list_remove(struct btree_trans *, struct btree_pat static inline void btree_path_list_add(struc...
c82ed3047b8875b07b19e6e287c48f27a37b756f
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix bch2_btree_path_traverse_all()
Problem Details: We need to take a ref on a path while we're traversing it: this fixes a bug with paths getting reused while being traversed, in the key cache fill code. 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 398db0faa816..31733c239746 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -999,7 +999,10 @@ retry_all: * the same position: */ if (path->uptodate) { + __btree_path_get(path, false); ret = btree_path_...
149651dc6c1250b3b51c38391b3677261ac94075
Analyze and fix the following issue in the Linux kernel code: bcachefs: fix fsck error
Problem Details: 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 9dedac2c7885..81f513c7a1a0 100644 --- a/fs/bcachefs/btree_io.c +++ b/fs/bcachefs/btree_io.c @@ -557,7 +557,7 @@ enum btree_validate_ret { \ if (type == BTREE_ERR_FIXABLE && \ write == READ && \ - !test_bit(BCH_FS_IN...
2cc9c0db89f7b6e3c3218ddaa7964055af8d95af
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix some memcpy() warnings
Problem Details: With CONFIG_FORTIFY_SOURCE, the compiler attempts to warn about mempcys that extend past struct field boundaries. This results in some spurious warnings where we use embedded variable length structs, this patch switches to unsafe_mecpy() to fix the warnings. Signed-off-by: Kent Overstreet <kent.overst...
```diff diff --git a/fs/bcachefs/buckets.c b/fs/bcachefs/buckets.c index 49cb2589f47c..137a9aef6987 100644 --- a/fs/bcachefs/buckets.c +++ b/fs/bcachefs/buckets.c @@ -156,7 +156,8 @@ retry: do { seq = read_seqcount_begin(&c->usage_lock); - memcpy(&ret->u, c->usage_base, u64s * sizeof(u64)); + unsafe_memcpy(&re...
a2b9a5b272f2bbfc3988f4b5c8e92d9951885bcb
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix bch2_journal_flush_device_pins()
Problem Details: It's now legal for the pin fifo to be empty, which means this code needs to be updated in order to not hit an assert. 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 b683a13dbf87..e8b7ed8e1333 100644 --- a/fs/bcachefs/journal_reclaim.c +++ b/fs/bcachefs/journal_reclaim.c @@ -831,10 +831,12 @@ int bch2_journal_flush_device_pins(struct journal *j, int dev_idx) seq = 0; spin_lock(&j->lock); ...
e242b92af5ef74cdf40b237c9e904034c081b144
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix for long running btree transactions & key cache
Problem Details: While a btree transaction is running, we hold a SRCU read lock on the btree key cache that prevents btree key cache keys from being freed - this is so that relock() operations won't access freed memory. The downside of this is that long running btree transactions prevent memory from being freed from t...
```diff diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index c6ccf3add733..669d2b0b384a 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -2756,6 +2756,20 @@ void *__bch2_trans_kmalloc(struct btree_trans *trans, size_t size) return p; } +static noinline void bch2_trans_reset...
1ba8a796b427d312aa68c2e04e00b42ec742883e
Analyze and fix the following issue in the Linux kernel code: bcachefs: Recover from blacklisted journal entries
Problem Details: If it so happens that we crash while dirty, meaning we don't have the superblock clean section, and we erroneously mark a journal entry we wrote as blacklisted, we won't be able to recover. This patch fixes this by adding a fallback: if we've got no superblock clean section, and no non-ignored journal...
```diff diff --git a/fs/bcachefs/journal_io.c b/fs/bcachefs/journal_io.c index 854a0685db09..a54c06064647 100644 --- a/fs/bcachefs/journal_io.c +++ b/fs/bcachefs/journal_io.c @@ -1123,9 +1123,6 @@ int bch2_journal_read(struct bch_fs *c, u64 *blacklist_seq, u64 *start_seq) /* * Find most recent flush entry, and ign...
14d7d61fac9c151a270c6ef6f969993eae9f1bbf
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix btree_gc when multiple passes required
Problem Details: We weren't resetting filesystem & device usage when restarting gc, which was spotted when free bucket counters overflowed - whoops. 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 2defa811f48f..d4a0e0a716c5 100644 --- a/fs/bcachefs/btree_gc.c +++ b/fs/bcachefs/btree_gc.c @@ -1282,8 +1282,7 @@ fsck_err: return ret; } -static int bch2_gc_start(struct bch_fs *c, - bool metadata_only) +static int bch2_gc_start(struct ...
1ae40fd816ca6f52b46a8d74f799f8a85ecb92ad
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix error path in bch2_trans_commit_write_locked()
Problem Details: Previously, we were journalling extra_journal_entries (which is used for new btree roots, and irreversably mutates system state) before calling bch2_trans_fs_usage_apply(), which can fail - whoops. 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 bdd703289ecb..f986f1774b51 100644 --- a/fs/bcachefs/btree_update_leaf.c +++ b/fs/bcachefs/btree_update_leaf.c @@ -660,21 +660,13 @@ bch2_trans_commit_write_locked(struct btree_trans *trans, trans->journal_res.seq = c->journa...
4f948723eda1ca44e470c31fcab4a453ed53aa13
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix bch2_journal_keys_peek_upto()
Problem Details: bch2_journal_keys_peek_upto() was comparing against btree_id & level incorrectly - fix this by using __journal_key_cmp(). Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/recovery.c b/fs/bcachefs/recovery.c index aff813e3e360..15a676196e2f 100644 --- a/fs/bcachefs/recovery.c +++ b/fs/bcachefs/recovery.c @@ -128,12 +128,12 @@ search: if (!*idx) *idx = __bch2_journal_key_search(keys, btree_id, level, pos); - while (*idx < keys->nr && - (k = i...
5c792e1b64cb5b87129f7226d610fd63465039bd
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix a btree iter assertion pop
Problem Details: This fixes a (harmless) broken invariant in __bch2_btree_path_set_pos(): iterators to interior nodes should point to the first non whiteout. 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 ecb6f27e4917..ff796a74fd2f 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -1202,7 +1202,7 @@ __bch2_btree_path_set_pos(struct btree_trans *trans, struct btree_path *path, struct bpos new_pos, bool intent,...
b9004e8576b1c2803ee7d7b3f28fbcc779f05ffb
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix a "no journal entries found" bug
Problem Details: On startup, we need to ensure the first journal entry written is a flush write: after a clean shutdown we generally don't read the journal, which means we might be overwriting whatever was there previously, and there must always be at least one flush entry in the journal or recovery will fail. Found b...
```diff diff --git a/fs/bcachefs/journal_io.c b/fs/bcachefs/journal_io.c index cd48ba11e771..a5c9524aa6e7 100644 --- a/fs/bcachefs/journal_io.c +++ b/fs/bcachefs/journal_io.c @@ -1661,20 +1661,42 @@ void bch2_journal_write(struct closure *cl) j->write_start_time = local_clock(); spin_lock(&j->lock); - if (bch2_jo...
6f90e6b28180cb567b0abdb753ccac4c7d840cb2
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix a livelock in key cache fill path
Problem Details: We weren't setting path->uptodate before calling bch2_btree_key_cache_fill() - which causes __bch2_btree_path_upgrade() to fail. 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 c118d1b8241f..4833cb4c7cf5 100644 --- a/fs/bcachefs/btree_key_cache.c +++ b/fs/bcachefs/btree_key_cache.c @@ -487,6 +487,8 @@ retry: path->l[0].lock_seq = ck->c.lock.state.seq; path->l[0].b = (void *) ck; fill: + path->uptoda...
52bf51b91f5d19ab0555b901023def61d60f1a97
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix __btree_trans_peek_key_cache()
Problem Details: We were returning a pointer to a variable on the stack - oops. 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 8a18b55cab26..c95dbeaaceab 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -1851,6 +1851,7 @@ struct bkey_s_c __btree_trans_peek_key_cache(struct btree_iter *iter, struct bpo struct btree_trans *trans = iter->trans;...
e2fcf7f6306f12c50ad2ec655fdb8d1918c23bdd
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix BCH_IOCTL_DISK_SET_STATE
Problem Details: - Ensure we print an error message if necessary. Ideally we'd return the precise error code to userspace and leave printing the error message to the userspace tool, but we haven't decided to make our private error codes ABI-stable yet. - Return standard error code to userspace Signed-off-b...
```diff diff --git a/fs/bcachefs/chardev.c b/fs/bcachefs/chardev.c index 7b448b9551b6..28854a6c31b9 100644 --- a/fs/bcachefs/chardev.c +++ b/fs/bcachefs/chardev.c @@ -284,6 +284,8 @@ static long bch2_ioctl_disk_set_state(struct bch_fs *c, return PTR_ERR(ca); ret = bch2_dev_set_state(c, ca, arg.new_state, arg.fla...
447e92274af6c7e8dcdc7921a6af238afcc87a0a
Analyze and fix the following issue in the Linux kernel code: bcachefs: Don't set accessed bit on btree node fill
Problem Details: Btree nodes shouldn't have their accessed bit set when entering the btree cache by being read in from disk - this fixes linear scans thrashing the cache. 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 91ddbc7b8489..90be4c7325f7 100644 --- a/fs/bcachefs/btree_cache.c +++ b/fs/bcachefs/btree_cache.c @@ -707,6 +707,12 @@ static noinline struct btree *bch2_btree_node_fill(struct bch_fs *c, if (IS_ERR(b)) return b; + /* + * Btree nod...
b6804b6103263417994602482e9186fb3697a3e6
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix an include
Problem Details: Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/ec_types.h b/fs/bcachefs/ec_types.h index edd93da663c1..2bf26d254b2c 100644 --- a/fs/bcachefs/ec_types.h +++ b/fs/bcachefs/ec_types.h @@ -2,7 +2,7 @@ #ifndef _BCACHEFS_EC_TYPES_H #define _BCACHEFS_EC_TYPES_H -#include <linux/llist.h> +#include "bcachefs_format.h" struct bch_repli...
c9ee99ad8c52a9d7f93e2e9f786a172a849622fd
Analyze and fix the following issue in the Linux kernel code: bcachefs: Move some asserts behind CONFIG_BCACHEFS_DEBUG
Problem Details: Convert some non-critical asserts in long-stable code to debug asserts. 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 e4ea77d7c1d8..331479f34a0c 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -1490,7 +1490,7 @@ struct btree_path *bch2_path_get(struct btree_trans *trans, bool intent = flags & BTREE_ITER_INTENT; int i; - BUG_ON(...
96c2e01083f19c75421002bebb819a668839184e
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix a transaction path overflow
Problem Details: It turns out we need bch2_extent_trim_atomi() even when we're deleting extents one at a time because it's possible for one reflink_p to reference arbitrarily many reflink_v extents. This doesn't normally happen, but the data move path can fragment existing extents in the background. Signed-off-by: Ken...
```diff diff --git a/fs/bcachefs/inode.c b/fs/bcachefs/inode.c index 4161cd850eb8..f026e2f70dcd 100644 --- a/fs/bcachefs/inode.c +++ b/fs/bcachefs/inode.c @@ -599,7 +599,6 @@ static int bch2_inode_delete_keys(struct btree_trans *trans, * iterator: */ bch2_trans_iter_init(trans, &iter, id, POS(inum.inum, 0), - ...
42af0ad569edbfcd252e9abf0badd97b895c34be
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix a race with b->write_type
Problem Details: b->write_type needs to be set atomically with setting the btree_node_need_write flag, so move it into b->flags. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/bcachefs.h b/fs/bcachefs/bcachefs.h index c8ab0e2029df..e61dc1e6da06 100644 --- a/fs/bcachefs/bcachefs.h +++ b/fs/bcachefs/bcachefs.h @@ -627,23 +627,6 @@ typedef struct { #define BCACHEFS_ROOT_SUBVOL_INUM \ ((subvol_inum) { BCACHEFS_ROOT_SUBVOL, BCACHEFS_ROOT_INO }) -#define B...
3bce13837395f1af2fd585ef6dd4b54d80c2d1fb
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix for_each_btree_key2()
Problem Details: Previously, when we exited from the loop body with a break statement _ret wouldn't have been assigned to yet, and we could spuriously return a transaction restart error. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/btree_iter.h b/fs/bcachefs/btree_iter.h index 635cf97f5692..1c60122c5ea5 100644 --- a/fs/bcachefs/btree_iter.h +++ b/fs/bcachefs/btree_iter.h @@ -490,11 +490,11 @@ __bch2_btree_iter_peek_and_restart(struct btree_trans *trans, \ while (1) { \ u32 _restart_count = bch...
0f35e0860a73a35e8c3aa1afebc45e75eb2fbae6
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix return code from btree_path_traverse_one()
Problem Details: trans->restarted is a positive error code, not the usual negative 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 fc057ba11190..e4ea77d7c1d8 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -1079,7 +1079,7 @@ static int btree_path_traverse_one(struct btree_trans *trans, unsigned long trace_ip) { unsigned depth_want = pa...
061f7999a6322c639dd6616dc6d3785957de2bc3
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix a use after free
Problem Details: This fixes a regression from percpu freedlists in the btree key cache code: in a rare error path, we were immediately freeing a bkey_cached that had been used before and should've waited for an SRCU barrier. 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 179669dbd688..1ac91221cc95 100644 --- a/fs/bcachefs/btree_key_cache.c +++ b/fs/bcachefs/btree_key_cache.c @@ -190,7 +190,8 @@ static void bkey_cached_free_fast(struct btree_key_cache *bc, } static struct bkey_cached * -bkey_cac...
961cbdef3c270266e17aa831cf22eb14b900af65
Analyze and fix the following issue in the Linux kernel code: bcachefs: Delete atomic_inc_bug()
Problem Details: These were wrappers around atomic operations that verified that the counter wasn't negative, but they're dead code - delete. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/util.h b/fs/bcachefs/util.h index 4243a22c766c..67b0d3de24cc 100644 --- a/fs/bcachefs/util.h +++ b/fs/bcachefs/util.h @@ -23,33 +23,9 @@ struct closure; #ifdef CONFIG_BCACHEFS_DEBUG - #define EBUG_ON(cond) BUG_ON(cond) -#define atomic_dec_bug(v) BUG_ON(atomic_dec_return(v) < 0) -#...
b2d1d56b1d34bcfb6da77eb74a2fbcdea92514f9
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fixes for building in userspace
Problem Details: - Marking a non-static function as inline doesn't actually work and is now causing problems - drop that - Introduce BCACHEFS_LOG_PREFIX for when we want to prefix log messages with bcachefs (filesystem name) - Userspace doesn't have real percpu variables (maybe we can get this fixed someda...
```diff diff --git a/fs/bcachefs/bcachefs.h b/fs/bcachefs/bcachefs.h index c0416258985b..90a1bd1f9d63 100644 --- a/fs/bcachefs/bcachefs.h +++ b/fs/bcachefs/bcachefs.h @@ -226,6 +226,10 @@ do { \ dynamic_fault("bcachefs:meta:write:" name) #ifdef __KERNEL__ +#define BCACHEFS_LOG_PREFIX +#endif + +#ifdef BCA...
80fe580c8db02059d833d2ded6143e90641184ab
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix a spurious warning
Problem Details: Fixes fstests generic/648 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 49b0fb6522e7..9e9ada8f007a 100644 --- a/fs/bcachefs/fs-io.c +++ b/fs/bcachefs/fs-io.c @@ -1428,7 +1428,8 @@ do_io: /* Check for writing past i_size: */ WARN_ON_ONCE((bio_end_sector(&w->io->op.wbio.bio) << 9) > - round_up(i_size, block_b...
353448f3ea42e5deec298d6d2c577ade7028b7fd
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix buffered write path for generic/275
Problem Details: Per fstests generic/275, on -ENOSPC we're supposed write until the filesystem is full - i.e. do a partial write instead of failing the full write. This is a partial fix for the buffered write path: we'll still fail on a page boundary. 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 b1d53290f6ba..49b0fb6522e7 100644 --- a/fs/bcachefs/fs-io.c +++ b/fs/bcachefs/fs-io.c @@ -1656,10 +1656,21 @@ static int __bch2_buffered_write(struct bch_inode_info *inode, goto out; } + /* + * XXX: per POSIX and fstests generic/275, on -...
c167f9e54100179a009051ad6eac1dfb0bcd21f6
Analyze and fix the following issue in the Linux kernel code: bcachefs: Journal keys overlay fixes
Problem Details: - In the btree iterator code that overlays keys from the journal, we were incorrectly specifying level=0 instead of the btree_path's current level in a few places - When we didn't do journal replay, we shouldn't free the journal keys: this fixes cmd_list and cmd_dump, which run in norecovery ...
```diff diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index 611f7b0ca014..5af295317cee 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -1834,7 +1834,7 @@ struct bkey_s_c btree_trans_peek_journal(struct btree_trans *trans, { struct bkey_i *next_journal = bch2_btree_journa...
1f69368c5cfce6770d101aaeff46ef22d22de07c
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix an out-of-bounds shift
Problem Details: roundup_pow_of_two() is undefined for 0 - oops. 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 15bf079e17ab..611f7b0ca014 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -2879,7 +2879,7 @@ void __bch2_trans_init(struct btree_trans *trans, struct bch_fs *c, unsigned fn_ bch2_trans_alloc_paths(trans, c); s ...
3e3e02e6bce627ed9e3a5d9fd3118e6569dc2548
Analyze and fix the following issue in the Linux kernel code: bcachefs: Assorted checkpatch fixes
Problem Details: checkpatch.pl gives lots of warnings that we don't want - suggested ignore list: ASSIGN_IN_IF UNSPECIFIED_INT - bcachefs coding style prefers single token type names NEW_TYPEDEFS - typedefs are occasionally good FUNCTION_ARGUMENTS - we prefer to look at functions in .c files (hopefully with ...
```diff diff --git a/fs/bcachefs/acl.c b/fs/bcachefs/acl.c index 7edebeed779e..2bf58aa89f71 100644 --- a/fs/bcachefs/acl.c +++ b/fs/bcachefs/acl.c @@ -173,7 +173,7 @@ bch2_acl_to_xattr(struct btree_trans *trans, bkey_xattr_init(&xattr->k_i); xattr->k.u64s = u64s; xattr->v.x_type = acl_to_xattr_type(type); - xat...
2d485df3da368193dafc78be933669d427b7ddf7
Analyze and fix the following issue in the Linux kernel code: bcachefs: fix bch2_write_extent() crc corruption.
Problem Details: crc.compression_type & nouce gets reset to inside bch2_rechecksum_bio(), we set it back to the previous values calculated. This fixes incompressible extents being marked as uncompressed. Signed-off-by: Daniel Hill <daniel@gluo.nz> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/io.c b/fs/bcachefs/io.c index 648e4a0a21a9..616407fa08ae 100644 --- a/fs/bcachefs/io.c +++ b/fs/bcachefs/io.c @@ -1074,8 +1074,7 @@ static int bch2_write_extent(struct bch_write_op *op, struct write_point *wp, saved_iter = dst->bi_iter; do { - struct bch_extent_crc_unpacked crc =...
55b8550d304a1c0884e98d0bb7126d490a96128f
Analyze and fix the following issue in the Linux kernel code: bcachefs: fix security warning in pr_name_and_units
Problem Details: Signed-off-by: Daniel Hill <daniel@gluo.nz> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/util.c b/fs/bcachefs/util.c index ee85bb27e231..a58239fb2a6d 100644 --- a/fs/bcachefs/util.c +++ b/fs/bcachefs/util.c @@ -436,7 +436,7 @@ static void bch2_pr_time_units_aligned(struct printbuf *out, u64 ns) static inline void pr_name_and_units(struct printbuf *out, const char *name, ...
b0c5b15cc8969f79b410a825efe9894cdec85738
Analyze and fix the following issue in the Linux kernel code: bcachefs: Optimize __bkey_unpack_key_format_checked()
Problem Details: Delete some code when CONFIG_BCACHEFS_DEBUG=n Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/bset.h b/fs/bcachefs/bset.h index 9708b9ffa4df..e458d1acdef4 100644 --- a/fs/bcachefs/bset.h +++ b/fs/bcachefs/bset.h @@ -212,20 +212,19 @@ __bkey_unpack_key_format_checked(const struct btree *b, struct bkey *dst, const struct bkey_packed *src) { -#ifdef HAVE_BCAC...
b2f83e769f607409753888c95a9b46dc927dc856
Analyze and fix the following issue in the Linux kernel code: bcachefs: Btree key cache shrinker fix
Problem Details: The shrinker assumes freed key cache items are ordered by age, so that it doesn't have to scan the full list to find items that are old enough (according to the srcu code) to be freed. But percpu freelists broke this ordering; this patch fixes this by ensuring we insert items into the proper position....
```diff diff --git a/fs/bcachefs/btree_key_cache.c b/fs/bcachefs/btree_key_cache.c index 419317bc6bec..9a5729309b8f 100644 --- a/fs/bcachefs/btree_key_cache.c +++ b/fs/bcachefs/btree_key_cache.c @@ -103,16 +103,34 @@ static void bkey_cached_free(struct btree_key_cache *bc, six_unlock_intent(&ck->c.lock); } +#ifdef...
be75bb7a0e0565c0c409842048567e8d07f28675
Analyze and fix the following issue in the Linux kernel code: bcachefs: __bio_compress() fix up.
Problem Details: A single block can't be compressed, so it's incompressible. This stops rebalance repeatably marking extents as uncompressed. Signed-off-by: Daniel Hill <daniel@gluo.nz> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/compress.c b/fs/bcachefs/compress.c index f692f35a6a98..2b7080b67eca 100644 --- a/fs/bcachefs/compress.c +++ b/fs/bcachefs/compress.c @@ -377,7 +377,7 @@ static unsigned __bio_compress(struct bch_fs *c, /* If it's only one block, don't bother trying to compress: */ if (src->bi_ite...
bd954215cad1dbe4304736e6968d8a0c10d1e048
Analyze and fix the following issue in the Linux kernel code: bcachefs: Quota fixes
Problem Details: - We now correctly allow soft limits to be exceeded, instead of always returning -EDQUOT - Disk quota grate times/warnings can now be set, not just the systemwide defaults 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 9a0751a140e4..274dc78916f8 100644 --- a/fs/bcachefs/fs-io.c +++ b/fs/bcachefs/fs-io.c @@ -605,7 +605,7 @@ static void bch2_page_reservation_put(struct bch_fs *c, static int bch2_page_reservation_get(struct bch_fs *c, struct bch_inode_info *inode,...
dccedaaa5262cfbf537b740d83aabf52e94c3143
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix btree node prefetchig
Problem Details: We were forgetting to count down the number of nodes to prefetch, firing off _way_ more than intended - whoops. 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 0bb156e6152a..c87129a11640 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -764,7 +764,7 @@ static int btree_path_prefetch(struct btree_trans *trans, struct btree_path *pat bch2_bkey_buf_init(&tmp); - while (nr ...
92095781e0f607e735971c1a6462ca6dad8826d2
Analyze and fix the following issue in the Linux kernel code: bcachefs: Mean and variance
Problem Details: This module provides a fast 64bit implementation of basic statistics functions, including mean, variance and standard deviation in both weighted and unweighted variants, the unweighted variant has a 32bit limitation per sample to prevent overflow when squaring. Signed-off-by: Daniel Hill <daniel@gluo....
```diff diff --git a/fs/bcachefs/Kconfig b/fs/bcachefs/Kconfig index 76953e05b240..f8e208826997 100644 --- a/fs/bcachefs/Kconfig +++ b/fs/bcachefs/Kconfig @@ -71,3 +71,12 @@ config BCACHEFS_NO_LATENCY_ACCT depends on BCACHEFS_FS help This disables device latency tracking and time stats, only for performance testi...
07bfcc0b4c92a569b7f613a3202f45c89f983b4f
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix for not dropping privs in fallocate
Problem Details: When modifying a file, we may be required to drop the suid/sgid bits - we were missing a file_modified() call to do this. 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 cca764cdb4f4..9a0751a140e4 100644 --- a/fs/bcachefs/fs-io.c +++ b/fs/bcachefs/fs-io.c @@ -3113,6 +3113,10 @@ long bch2_fallocate_dispatch(struct file *file, int mode, inode_dio_wait(&inode->v); bch2_pagecache_block_get(&inode->ei_pagecache_lock); ...
3a4d3656e5620df8323448c7d33f4b1401ff14ec
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix bch2_write_begin()
Problem Details: An error case was jumping to the wrong label, creating an infinite loop - oops. This fixes fstests generic/648. 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 f5517c31f120..cca764cdb4f4 100644 --- a/fs/bcachefs/fs-io.c +++ b/fs/bcachefs/fs-io.c @@ -1517,7 +1517,7 @@ out: if (!bch2_page_state_create(page, __GFP_NOFAIL)->uptodate) { ret = bch2_page_state_set(c, inode_inum(inode), &page, 1); if (ret) -...
40405557b92dfe9cd581f914a5fa5f2c0e82d797
Analyze and fix the following issue in the Linux kernel code: fixup bcachefs: Deadlock cycle detector
Problem Details: 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 76a532f98c72..5e9424fbc3be 100644 --- a/fs/bcachefs/btree_locking.c +++ b/fs/bcachefs/btree_locking.c @@ -226,6 +226,10 @@ static int lock_graph_descend(struct lock_graph *g, struct btree_trans *trans, while (g->nr) lock_graph...
80df5b8cacceb25962621ccf4cf555413bdfbdbb
Analyze and fix the following issue in the Linux kernel code: fixup bcachefs: Deadlock cycle detector
Problem Details: 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 922cfc7f5450..76a532f98c72 100644 --- a/fs/bcachefs/btree_locking.c +++ b/fs/bcachefs/btree_locking.c @@ -99,6 +99,12 @@ static void lock_graph_up(struct lock_graph *g) closure_put(&g->g[--g->nr].trans->ref); } +static noinline vo...
896f1b316f8e8f51f83095ab4b0e319471d93803
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix lock_graph_remove_non_waiters()
Problem Details: We were removing 1 more entry than we were supposed to - oops. Also some other simplifications and cleanups, and bring back the abort preference code in a better fashion. 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 4940b3069a76..922cfc7f5450 100644 --- a/fs/bcachefs/btree_locking.c +++ b/fs/bcachefs/btree_locking.c @@ -94,6 +94,37 @@ static noinline void print_chain(struct printbuf *out, struct lock_graph *g) prt_newline(out); } +static void...
f866870f5dbe9c9fb745f5a24bb30b6477ec619a
Analyze and fix the following issue in the Linux kernel code: bcachefs: Initialize sb_quota with default 1 week timer
Problem Details: For compliance with other quota implementations, we should be initializing quota information with a default 1 week timelimit: this fixes fstests generic/235. Also, this adds to_text() functions for some quota structs - useful debugging aids. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/quota.c b/fs/bcachefs/quota.c index c12d715fb758..ad7130a14691 100644 --- a/fs/bcachefs/quota.c +++ b/fs/bcachefs/quota.c @@ -95,6 +95,113 @@ void bch2_quota_to_text(struct printbuf *out, struct bch_fs *c, #include <linux/fs.h> #include <linux/quota.h> +static void qc_info_to_text(s...
f42238b5cde2f1624b2be5f64c813e6127a8012a
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix a rare path in bch2_btree_path_peek_slot()
Problem Details: In the drop_alloc tests, we may end up calling bch2_btree_iter_peek_slot() on an interior level that doesn't exist. Previously, this would hit the path->uptodate assertion in bch2_btree_path_peek_slot(); this path first checks a NULL btree node, which is how we know we're at the end of the btree. Sign...
```diff diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index 283764225d13..0bb156e6152a 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -1544,14 +1544,17 @@ struct btree_path *bch2_path_get(struct btree_trans *trans, inline struct bkey_s_c bch2_btree_path_peek_slot(struct btre...
7dcbdbd85cc3af14c0b9b5b80eb87cca8a322285
Analyze and fix the following issue in the Linux kernel code: bcachefs: bch2_path_put_nokeep()
Problem Details: The btree iterator code may allocate extra btree paths, temporarily, that do not refer to keys being returned: we don't need to wait until transaction restart to drop these, when they're not referenced they should be deleted right away. This fixes a transaction path overflow bug. Signed-off-by: Kent ...
```diff diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index baf8ed40280c..283764225d13 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -1299,6 +1299,18 @@ void bch2_path_put(struct btree_trans *trans, struct btree_path *path, bool inte __bch2_path_free(trans, path); } +st...
5b3243cb528f96e5d90d65f56f96ad179c666ff5
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix cached data accounting
Problem Details: Negating without casting to a signed integer means the value wasn't getting sign extended properly - oops. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/buckets.c b/fs/bcachefs/buckets.c index 4b041707cd54..5cb4a00166f9 100644 --- a/fs/bcachefs/buckets.c +++ b/fs/bcachefs/buckets.c @@ -578,7 +578,7 @@ int bch2_mark_alloc(struct btree_trans *trans, if ((flags & BTREE_TRIGGER_BUCKET_INVALIDATE) && old_a.cached_sectors) { ret = ...
1f0f731ffef13bde3b2cd5a439c886d94d2bb3cc
Analyze and fix the following issue in the Linux kernel code: bcachefs: Btree splits now only take the locks they need
Problem Details: Previously, bch2_btree_update_start() would always take all intent locks, all the way up to the root. We've finally got data from users where this became a scalability issue - so, this patch fixes bch2_btree_update_start() to only take the locks we need. Signed-off-by: Kent Overstreet <kent.overstree...
```diff diff --git a/fs/bcachefs/btree_update_interior.c b/fs/bcachefs/btree_update_interior.c index 7619890d9df1..84a1cd0a0a4f 100644 --- a/fs/bcachefs/btree_update_interior.c +++ b/fs/bcachefs/btree_update_interior.c @@ -1070,23 +1070,23 @@ bch2_btree_update_start(struct btree_trans *trans, struct btree_path *path, ...
1148a97f1fb9b80ef5355021f0c2dfc7b8f003a2
Analyze and fix the following issue in the Linux kernel code: bcachefs: Print cycle on unrecoverable deadlock
Problem Details: Some lock operations can't fail; a cycle of nofail locks is impossible to recover from. So we want to get rid of these nofail locking operations, but as this is tricky it'll be done incrementally. If such a cycle happens, this patch prints out which codepaths are involved so we know what to work on ne...
```diff diff --git a/fs/bcachefs/btree_locking.c b/fs/bcachefs/btree_locking.c index ad6e364980f3..3973e8d7e6da 100644 --- a/fs/bcachefs/btree_locking.c +++ b/fs/bcachefs/btree_locking.c @@ -138,7 +138,29 @@ static noinline int break_cycle(struct lock_graph *g) return abort_lock(g, i); } - BUG(); + { + struct b...
160dff6dad43d9428b1250f927721a9a8756cfd9
Analyze and fix the following issue in the Linux kernel code: bcachefs: Ratelimit ec error message
Problem Details: We should fix this, but for now this makes this more usable. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/ec.c b/fs/bcachefs/ec.c index aa8301146382..2dcca5c7fcec 100644 --- a/fs/bcachefs/ec.c +++ b/fs/bcachefs/ec.c @@ -1386,10 +1386,8 @@ static int __bch2_ec_stripe_head_reuse(struct bch_fs *c, int ret; idx = get_existing_stripe(c, h); - if (idx < 0) { - bch_err(c, "failed to find an...
6c22eb7085d3ee055a178ed0a4e8d0e5d18800f3
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix "multiple types of data in same bucket" with ec
Problem Details: Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/buckets.c b/fs/bcachefs/buckets.c index f01b8171cb92..4b041707cd54 100644 --- a/fs/bcachefs/buckets.c +++ b/fs/bcachefs/buckets.c @@ -687,6 +687,10 @@ static int check_bucket_ref(struct bch_fs *c, if (bucket_data_type == BCH_DATA_cached) bucket_data_type = BCH_DATA_user; + if ((b...
8aaee94d463f781fbd5377b7d96234342de9c6eb
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix a deadlock in btree_update_nodes_written()
Problem Details: btree_node_lock_nopath() is something we'd like to get rid of, it's always prone to deadlocks if we accidentally are holding other locks, because it doesn't mark the lock it's taking in a path: we'll want to get rid of it in the future, but for now this patch works it by calling bch2_trans_unlock(). S...
```diff diff --git a/fs/bcachefs/btree_update_interior.c b/fs/bcachefs/btree_update_interior.c index fd44492150b0..247555dffa3f 100644 --- a/fs/bcachefs/btree_update_interior.c +++ b/fs/bcachefs/btree_update_interior.c @@ -650,6 +650,17 @@ err: * we're in journal error state: */ + /* + * Ensure transaction...
40a44873a5ca9843532344d12583e6a3a78ea848
Analyze and fix the following issue in the Linux kernel code: bcachefs: Improve btree_deadlock debugfs output
Problem Details: This changes bch2_check_for_deadlock() to print the longest chains it finds - when we have a deadlock because the cycle detector isn't finding something, this will let us see what it's missing. 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 19062cea8774..b79543ae5eeb 100644 --- a/fs/bcachefs/btree_locking.c +++ b/fs/bcachefs/btree_locking.c @@ -71,11 +71,6 @@ struct lock_graph { unsigned nr; }; -static void lock_graph_pop(struct lock_graph *g) -{ - closure_put(&g->...
685e0f0c477dfc2b2147a20137a349f25b0a1f62
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix a trans path overflow in bch2_btree_delete_range_trans()
Problem Details: bch2_btree_delete_range_trans() was using btree_trans_too_many_iters() to avoid path overflow, but this was buggy here (and also btree_trans_too_many_iters() is suspect in general). btree_trans_too_many_iters() only returns true when we're close to the maximum number of paths - within 8 - but extent i...
```diff diff --git a/fs/bcachefs/btree_update_leaf.c b/fs/bcachefs/btree_update_leaf.c index 31b60864b6da..98030f22ee05 100644 --- a/fs/bcachefs/btree_update_leaf.c +++ b/fs/bcachefs/btree_update_leaf.c @@ -1651,15 +1651,18 @@ int bch2_btree_delete_range_trans(struct btree_trans *trans, enum btree_id id, int ret = 0;...
29cea6f4834b36f6a51832e08218e03b60002a9a
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix bch2_btree_path_up_until_good_node()
Problem Details: There was a rare bug when path->locks_want was nonzero, but not BTREE_MAX_DEPTH, where we'd return on a valid node that wasn't locked - oops. 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 67a1e0d70ed9..7ea297249850 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -1030,7 +1030,7 @@ static inline unsigned btree_path_up_until_good_node(struct btree_trans *trans, int check_pos) { unsigned i,...
3f3bc66ef0601e425a3c2901b34a825d4166da63
Analyze and fix the following issue in the Linux kernel code: bcachefs: Optimize btree_path_alloc()
Problem Details: - move slowpath code to a separate function, btree_path_overflow() - no need to use hweight64 - copy nr_max_paths from btree_transaction_stats to btree_trans, avoiding a data dependency in the fast path 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 30e7f07e3fa8..366be8015b97 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -1408,7 +1408,8 @@ static void bch2_trans_update_max_paths(struct btree_trans *trans) if (!buf.allocation_failure) { mutex_lock(&s->lock)...
f3b8403ee70e5dcce5a16d3517b411bd8839319b
Analyze and fix the following issue in the Linux kernel code: bcachefs: Run bch2_fs_counters_init() earlier
Problem Details: We need counters to be initialized before initializing shrinkers - the shrinker callbacks will update those counters. This fixes a segfault in userspace. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/super.c b/fs/bcachefs/super.c index 8dc87c103216..29e2b76322d7 100644 --- a/fs/bcachefs/super.c +++ b/fs/bcachefs/super.c @@ -781,7 +781,8 @@ static struct bch_fs *bch2_fs_alloc(struct bch_sb *sb, struct bch_opts opts) goto err; } - ret = bch2_io_clock_init(&c->io_clock[READ]) ?:...
dbb9936b0dc905657db6e5289be18e425f1b60d3
Analyze and fix the following issue in the Linux kernel code: bcachefs: Improve bch2_fsck_err()
Problem Details: - factor out fsck_err_get() - if the "bcachefs (%s):" prefix has already been applied, don't duplicate it - convert to printbufs instead of static char arrays - tidy up control flow a bit - use bch2_print_string_as_lines(), to avoid messages getting truncated Signed-off-by: Kent Overstreet <ken...
```diff diff --git a/fs/bcachefs/bcachefs.h b/fs/bcachefs/bcachefs.h index 74da688d994b..08fd899d8837 100644 --- a/fs/bcachefs/bcachefs.h +++ b/fs/bcachefs/bcachefs.h @@ -226,9 +226,11 @@ do { \ dynamic_fault("bcachefs:meta:write:" name) #ifdef __KERNEL__ -#define bch2_fmt(_c, fmt) "bcachefs (%s): " fmt ...