id
stringlengths
40
40
instruction
stringlengths
68
308
input
stringlengths
17
33.4k
output
stringlengths
100
30k
ef470b4817e6592fdb22b566380d289d7c42a17d
Analyze and fix the following issue in the Linux kernel code: bcachefs: Clean up bch2_extent_can_insert
Problem Details: It was using an internal btree node iterator interface, when bch2_btree_iter_peek_slot() sufficed. We were hitting a null ptr deref that looked like it was from the iterator not being uptodate - this will also fix that. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Ove...
```diff diff --git a/fs/bcachefs/extent_update.c b/fs/bcachefs/extent_update.c index 1faca4bc1825..5c43678e94a3 100644 --- a/fs/bcachefs/extent_update.c +++ b/fs/bcachefs/extent_update.c @@ -192,18 +192,13 @@ bch2_extent_can_insert(struct btree_trans *trans, struct btree_iter *iter, struct bkey_i *i...
a5cd80ea99e544b67acde573fc2a2dd68659fd40
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix an assertion pop
Problem Details: There was a race: btree node writes drop their reference on journal pins before clearing the btree_node_write_in_flight flag. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/btree_io.c b/fs/bcachefs/btree_io.c index c4d53ea2e920..cd2b300043b6 100644 --- a/fs/bcachefs/btree_io.c +++ b/fs/bcachefs/btree_io.c @@ -1829,23 +1829,6 @@ void bch2_btree_flush_all_writes(struct bch_fs *c) __bch2_btree_flush_all(c, BTREE_NODE_write_in_flight); } -void bch2_btree_...
f9ef45ad434ba85363aab6d74fa48499f7ea6499
Analyze and fix the following issue in the Linux kernel code: bcachefs: Verify transaction updates are sorted
Problem Details: A user reported a bug that implies they might not be correctly sorted, this should help track that down. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/btree_update_leaf.c b/fs/bcachefs/btree_update_leaf.c index a25cc3b7db39..ffd8e0b14257 100644 --- a/fs/bcachefs/btree_update_leaf.c +++ b/fs/bcachefs/btree_update_leaf.c @@ -981,10 +981,22 @@ int bch2_trans_update(struct btree_trans *trans, struct btree_iter *iter, .trigger_flags = f...
a39c74be8059be72fcf6c7cc2f827c38076a25db
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix gc updating stripes info
Problem Details: The primary stripes radix tree can be sparse, which was causing an assertion to pop because the one use for gc isn't. Fix this by changing the algorithm to copy between the two radix trees. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux...
```diff diff --git a/fs/bcachefs/btree_gc.c b/fs/bcachefs/btree_gc.c index 790beac71e9b..f2310f7f89c5 100644 --- a/fs/bcachefs/btree_gc.c +++ b/fs/bcachefs/btree_gc.c @@ -580,7 +580,7 @@ static int bch2_gc_done(struct bch_fs *c, if (verify) \ fsck_err(c, "stripe %zu has wrong "_msg \ ": got %u, should...
2ef220cba297ef381a980572154fd17aa2a7e3de
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix double counting of stripe block counts by GC
Problem Details: Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/buckets.c b/fs/bcachefs/buckets.c index 11907abd9b4c..95368c9f70c3 100644 --- a/fs/bcachefs/buckets.c +++ b/fs/bcachefs/buckets.c @@ -1273,9 +1273,15 @@ static int bch2_mark_stripe(struct bch_fs *c, m->blocks_nonempty = 0; for (i = 0; i < new_s->nr_blocks; i++) { - m->block_se...
cd9f3dfe58709c7b0793a706d0dd0292a66237d5
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix integer overflow in bch2_disk_reservation_get()
Problem Details: The sectors argument shouldn't have been a u32 - it can be up to U32_MAX (i.e. fallocate creating persistent reservations), and if replication is enabled we'll overflow when we calculate the real number of sectors to reserve. Oops. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-...
```diff diff --git a/fs/bcachefs/buckets.c b/fs/bcachefs/buckets.c index 1bbd1ee080ec..11907abd9b4c 100644 --- a/fs/bcachefs/buckets.c +++ b/fs/bcachefs/buckets.c @@ -2109,7 +2109,7 @@ int bch2_trans_mark_update(struct btree_trans *trans, #define SECTORS_CACHE 1024 int bch2_disk_reservation_add(struct bch_fs *c, st...
ed9d58a2b1ddbc38816571638ee114b7efb9f279
Analyze and fix the following issue in the Linux kernel code: bcachefs: Run jset_validate in write path as well
Problem Details: This is because we had a bug where we were writing out journal entries with garbage last_seq, and not catching it. Also, completely ignore jset->last_seq when JSET_NO_FLUSH is true, because of aforementioned bug, but change the write path to set last_seq to 0 when JSET_NO_FLUSH is true. Minor other c...
```diff diff --git a/fs/bcachefs/btree_io.c b/fs/bcachefs/btree_io.c index 831f387557aa..c4d53ea2e920 100644 --- a/fs/bcachefs/btree_io.c +++ b/fs/bcachefs/btree_io.c @@ -1624,7 +1624,7 @@ void __bch2_btree_node_write(struct bch_fs *c, struct btree *b, validate_before_checksum = true; /* validate_bset will be mo...
ac958006294ab462848bc69b9b5ddb1a8b99e748
Analyze and fix the following issue in the Linux kernel code: bcachefs: Factor out bch2_ec_stripes_heap_start()
Problem Details: This fixes a bug where mark and sweep gc incorrectly was clearing out the stripes heap and causing assertions to fire later - simpler to just create the stripes heap after gc has finished. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux....
```diff diff --git a/fs/bcachefs/btree_gc.c b/fs/bcachefs/btree_gc.c index 4a1d800d257e..790beac71e9b 100644 --- a/fs/bcachefs/btree_gc.c +++ b/fs/bcachefs/btree_gc.c @@ -607,8 +607,6 @@ static int bch2_gc_done(struct bch_fs *c, struct genradix_iter src_iter = genradix_iter_init(&c->stripes[1], 0); struct stripe ...
2a3731e34de9365038b25d76bb6e11cf5c40ac36
Analyze and fix the following issue in the Linux kernel code: bcachefs: Erasure coding fixes & refactoring
Problem Details: - Originally bch_extent_stripe_ptr didn't contain the block index, instead we'd have to search through the stripe pointers to figure out which pointer matched. When the block field was added to bch_extent_stripe_ptr, not all of the code was updated to use it. This patch fixes that, and we a...
```diff diff --git a/fs/bcachefs/buckets.c b/fs/bcachefs/buckets.c index 31a2d3dbfe8f..1bbd1ee080ec 100644 --- a/fs/bcachefs/buckets.c +++ b/fs/bcachefs/buckets.c @@ -1656,7 +1656,7 @@ out: } static int bch2_trans_mark_stripe_ptr(struct btree_trans *trans, - struct bch_extent_stripe_ptr p, + struct extent_ptr_d...
032ac32c516403cd0d5ebf30e233746271a7ddcc
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix .splice_write
Problem Details: 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 d48aa5b31e7b..5dd985e20c7f 100644 --- a/fs/bcachefs/fs-io.c +++ b/fs/bcachefs/fs-io.c @@ -1918,8 +1918,7 @@ loop: i_size_write(&inode->v, req->ki_pos); spin_unlock(&inode->v.i_lock); - bio_for_each_segment_all(bv, bio, iter) - put_page(bv-...
53ef2c5cc991a9c5aecc7b85754695df5cc5de45
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix bch2_replicas_gc2
Problem Details: This fixes a regression introduced by "bcachefs: Refactor filesystem usage accounting". We have to include all the replicas entries that have any of the entries for different journal entries nonzero, we can't skip them if they sum to zero. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Sig...
```diff diff --git a/fs/bcachefs/replicas.c b/fs/bcachefs/replicas.c index 57c2e66edad1..a0840e1c9f88 100644 --- a/fs/bcachefs/replicas.c +++ b/fs/bcachefs/replicas.c @@ -607,7 +607,11 @@ retry: cpu_replicas_entry(&c->replicas, i); if (e->data_type == BCH_DATA_journal || - bch2_fs_usage_read_one(c, &c->us...
4291a3317f3724283023f35802c47083a05b938d
Analyze and fix the following issue in the Linux kernel code: bcachefs: bch2_alloc_write() should be writing for all devices
Problem Details: Alloc info isn't stored on a particular device, it makes no sense to only be writing it out for rw members - this was causing fsck to not fix alloc info errors, oops. Also, make sure we write out alloc info in other repair paths. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-b...
```diff diff --git a/fs/bcachefs/alloc_background.c b/fs/bcachefs/alloc_background.c index 9920e902d383..d93c7809d821 100644 --- a/fs/bcachefs/alloc_background.c +++ b/fs/bcachefs/alloc_background.c @@ -366,7 +366,7 @@ int bch2_alloc_write(struct bch_fs *c, unsigned flags) unsigned i; int ret = 0; - for_each_rw_m...
dcf64dfbbc3c3c46af5508afed9f46e906fcd748
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix btree node split after merge operations
Problem Details: A btree node merge operation deletes a key in the parent node; if when inserting into the parent node we split the parent node, we can end up with a whiteout in the parent node that we don't want. The existing code drops them before doing the split, because they can screw up picking the pivot, but we ...
```diff diff --git a/fs/bcachefs/btree_update_interior.c b/fs/bcachefs/btree_update_interior.c index c25ce358f931..3b19c1c7b450 100644 --- a/fs/bcachefs/btree_update_interior.c +++ b/fs/bcachefs/btree_update_interior.c @@ -1227,6 +1227,9 @@ static void btree_split_insert_keys(struct btree_update *as, struct btree *b, ...
fd54c40e00dc54cf1cd1724e4184502a56b9848f
Analyze and fix the following issue in the Linux kernel code: bcachefs: Work around a zstd bug
Problem Details: The zstd compression code seems to have a bug where it will write just past the end of the destination buffer - probably only when the compressed output isn't going to fit in the destination buffer, which will never happen if you're always allocating a bigger buffer than the source buffer which would e...
```diff diff --git a/fs/bcachefs/compress.c b/fs/bcachefs/compress.c index 27bbc265d550..78757dcede36 100644 --- a/fs/bcachefs/compress.c +++ b/fs/bcachefs/compress.c @@ -336,8 +336,19 @@ static int attempt_compress(struct bch_fs *c, ZSTD_CCtx *ctx = zstd_init_cctx(workspace, zstd_cctx_workspace_bound(&c->zstd_p...
c859430b1728d59ca6e4d7e9356db82979e2fd5b
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix journal_buf_realloc()
Problem Details: It used to be safe to reallocate a buf that the write path owns without holding the journal lock, but now this can trigger an assertion in journal_seq_to_buf(). Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/journal_io.c b/fs/bcachefs/journal_io.c index 25010aa42af6..cba420565248 100644 --- a/fs/bcachefs/journal_io.c +++ b/fs/bcachefs/journal_io.c @@ -1051,9 +1051,13 @@ static void journal_buf_realloc(struct journal *j, struct journal_buf *buf) return; memcpy(new_buf, buf->data, buf-...
f0e70018d14ef94a5f680c977591ccb6cf29e9ca
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix iterator overflow in move path
Problem Details: The move path was calling bch2_bucket_io_time_reset() for cached pointers (which it shouldn't have been), and then not calling bch2_trans_reset() when it got -EINTR (indicating transaction restart). Oops. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.o...
```diff diff --git a/fs/bcachefs/io.c b/fs/bcachefs/io.c index a67bd18f6b8c..ee2ba1b8aff9 100644 --- a/fs/bcachefs/io.c +++ b/fs/bcachefs/io.c @@ -2202,7 +2202,11 @@ get_bio: bch2_increment_clock(c, bio_sectors(&rbio->bio), READ); - if (pick.ptr.cached) + /* + * If it's being moved internally, we don't want to f...
07bd4c285b79e068d2e6986a4cc60703434f1eed
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix btree lock being incorrectly dropped
Problem Details: __btree_trans_get_iter() was using bch2_btree_iter_upgrade, but it shouldn't have been because on failure bch2_btree_iter_upgrade may drop locks in other iterators, expecting the transaction to be restarted. But __btree_trans_get_iter can't return an error to indicate that we need to restart thet trans...
```diff diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index c0333ee94463..15963a657c72 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -2124,9 +2124,12 @@ static struct btree_iter *__btree_trans_get_iter(struct btree_trans *trans, iter->flags &= ~BTREE_ITER_USER_FLAGS; ite...
e323edd6d39094ce021dbb20e513b03ae6ebecbe
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix for spinning in journal reclaim on startup
Problem Details: We normally avoid having too many dirty keys in the btree key cache, to ensure that we can always shrink our caches to reclaim memory if needed. But this check was causing us to go into an infinite loop on startup, in the btree insert path before journal reclaim was started. Signed-off-by: Kent Overs...
```diff diff --git a/fs/bcachefs/btree_key_cache.h b/fs/bcachefs/btree_key_cache.h index dad3e344dcf9..2f8b5521718a 100644 --- a/fs/bcachefs/btree_key_cache.h +++ b/fs/bcachefs/btree_key_cache.h @@ -16,7 +16,8 @@ static inline bool bch2_btree_key_cache_must_wait(struct bch_fs *c) size_t nr_keys = READ_ONCE(c->btree_k...
d483dd17e2bfd6858498d39eb92abd232d7b8e97
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix race between journal_seq_copy() and journal_seq_drop()
Problem Details: In bch2_btree_interior_update_will_free_node, we copy the journal pins from outstanding writes on the btree node we're about to free. But, this can race with the writes completing, and dropping their journal pins. To guard against this, just use READ_ONCE() in bch2_journal_pin_copy(). Signed-off-by: ...
```diff diff --git a/fs/bcachefs/journal_reclaim.c b/fs/bcachefs/journal_reclaim.c index e8fd11abe4c3..1141b7d3a060 100644 --- a/fs/bcachefs/journal_reclaim.c +++ b/fs/bcachefs/journal_reclaim.c @@ -384,12 +384,22 @@ void bch2_journal_pin_set(struct journal *j, u64 seq, struct journal_entry_pin_list *pin_list; sp...
537c49d6afadb4be54be03c9a8cb1f1ade07b104
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix btree node merge -> split operations
Problem Details: If a btree node merger is followed by a split or compact of the parent node, we could end up with the parent btree node iterator pointing to the whiteout inserted by the btree node merge operation - the fix is to ensure that interior btree node iterators always point to the first non whiteout. Signed-...
```diff diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index 239d7c5deddc..c0333ee94463 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -902,6 +902,13 @@ static inline void __btree_iter_init(struct btree_iter *iter, bch2_btree_node_iter_init(&l->iter, l->b, &pos); + /* + ...
5b9bf43c81e6c0fd9d4f16351d53f26e7e6d19b5
Analyze and fix the following issue in the Linux kernel code: bcachefs: Always check if we need disk res in extent update path
Problem Details: With erasure coding, we now have processes in the background that compact data, causing it to take up less space on disk than when it was written, or potentially when it was read. This means that we can't trust the page cache when it says "we have data on disk taking up x amount of space here" - there...
```diff diff --git a/fs/bcachefs/io.c b/fs/bcachefs/io.c index 9603381bb7ce..2b381fc96009 100644 --- a/fs/bcachefs/io.c +++ b/fs/bcachefs/io.c @@ -195,34 +195,33 @@ void bch2_bio_alloc_pages_pool(struct bch_fs *c, struct bio *bio, static int sum_sector_overwrites(struct btree_trans *trans, struct btree_iter *ext...
719fe7fb555ad9a53bb847bfae1cad7170cb2591
Analyze and fix the following issue in the Linux kernel code: bcachefs: Update transactional triggers interface to pass old & new keys
Problem Details: This is needed to fix a bug where we're overflowing iterators within a btree transaction, because we're updating the stripes btree (to update block counts) and the stripes btree trigger is unnecessarily updating the alloc btree - it doesn't need to update the alloc btree when the pointers within a stri...
```diff diff --git a/fs/bcachefs/btree_update_interior.c b/fs/bcachefs/btree_update_interior.c index 594bcd797516..3ae920a223f9 100644 --- a/fs/bcachefs/btree_update_interior.c +++ b/fs/bcachefs/btree_update_interior.c @@ -519,14 +519,18 @@ static int btree_update_nodes_written_trans(struct btree_trans *trans, trans-...
cc578a36f9953c32a8ba866ee1878fcbb99a9746
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix __btree_iter_next() when all iters are in use_next() when all iters are in use
Problem Details: Also, print out more information on btree transaction iterator overflow. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index ea1735445202..239d7c5deddc 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -2017,9 +2017,10 @@ static void btree_trans_iter_alloc_fail(struct btree_trans *trans) { struct btree_iter *iter; + struct btree_insert_e...
d5b98fe2d764170e7a30eda8b94780aa6a0af129
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix rand_delete() test
Problem Details: When we didn't find a key to delete we were getting a null ptr deref. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/tests.c b/fs/bcachefs/tests.c index 2acecbca212e..6d0f8e233e8b 100644 --- a/fs/bcachefs/tests.c +++ b/fs/bcachefs/tests.c @@ -563,15 +563,14 @@ static int __do_delete(struct btree_trans *trans, struct bpos pos) iter = bch2_trans_get_iter(trans, BTREE_ID_XATTRS, pos, BTREE_IT...
a2bfc8412ad8da289b933810232cf95f7739340a
Analyze and fix the following issue in the Linux kernel code: bcachefs: Try to print full btree error message
Problem Details: Metadata corruption bugs are hard to debug if we can't see exactly what went wrong - try to allocate a bigger buffer so we can print out everything we have. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/btree_io.c b/fs/bcachefs/btree_io.c index b2ffdff48637..c100f930bb8f 100644 --- a/fs/bcachefs/btree_io.c +++ b/fs/bcachefs/btree_io.c @@ -635,21 +635,26 @@ enum btree_validate_ret { ({ \ __label__ out; \ char _buf[300]; \ + char *buf2 = _buf; \ struct pri...
f51e84fe24d8d170bfbba626e76ee08b1ab7b283
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix btree key cache dirty checks
Problem Details: Had a type that meant we were triggering journal reclaim _much_ more aggressively than needed. Also, fix a potential integer overflow. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/btree_key_cache.h b/fs/bcachefs/btree_key_cache.h index d7d31a0662c3..dad3e344dcf9 100644 --- a/fs/bcachefs/btree_key_cache.h +++ b/fs/bcachefs/btree_key_cache.h @@ -4,8 +4,8 @@ static inline size_t bch2_nr_btree_keys_need_flush(struct bch_fs *c) { size_t nr_dirty = READ_ONCE(c->btr...
7bfbbd88024d70947761e482c856522b43a98d87
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix spurious alloc errors on forced shutdown
Problem Details: Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/btree_update_interior.c b/fs/bcachefs/btree_update_interior.c index ac91006f3c69..aed54d5b5251 100644 --- a/fs/bcachefs/btree_update_interior.c +++ b/fs/bcachefs/btree_update_interior.c @@ -544,6 +544,17 @@ static void btree_update_nodes_written(struct btree_update *as) unsigned i; ...
b206df6e15ca85d0bb777a5548834c8685e99bc8
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix some spurious gcc warnings
Problem Details: These only come up when building in userspace, for some reason. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/btree_key_cache.c b/fs/bcachefs/btree_key_cache.c index 83156bc45e7b..7416e7a49893 100644 --- a/fs/bcachefs/btree_key_cache.c +++ b/fs/bcachefs/btree_key_cache.c @@ -317,7 +317,7 @@ static int btree_key_cache_flush_pos(struct btree_trans *trans, struct bch_fs *c = trans->c; struct j...
c5bb1690346167888d3b2834b4b11d9cfa682583
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix journal_flush_seq()
Problem Details: The error check was inverted - leading fsyncs to get stuck and hang, oops. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/journal.c b/fs/bcachefs/journal.c index 759a04346cde..0cd868c8248b 100644 --- a/fs/bcachefs/journal.c +++ b/fs/bcachefs/journal.c @@ -552,16 +552,13 @@ int bch2_journal_flush_seq_async(struct journal *j, u64 seq, struct journal_buf *buf; int ret = 0; - if (seq <= j->err_seq) - re...
34c1cd6a59bf1a72bb1b672df35f9d819c81bfde
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix for fsck spuriously finding duplicate extents
Problem Details: Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/fsck.c b/fs/bcachefs/fsck.c index 09ce6c29b88c..7449819d8eac 100644 --- a/fs/bcachefs/fsck.c +++ b/fs/bcachefs/fsck.c @@ -485,7 +485,11 @@ static int check_extents(struct bch_fs *c) BTREE_ITER_INTENT); retry: for_each_btree_key_continue(iter, 0, k, ret) { - if (bkey_cmp(prev...
d0022290b81c15db3c81936cdb254663598ef35f
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix error in filesystem initialization
Problem Details: The rhashtable code doesn't like when we destroy an rhashtable that was never initialized Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/btree_key_cache.c b/fs/bcachefs/btree_key_cache.c index d1f226e66158..ae3d5880f84e 100644 --- a/fs/bcachefs/btree_key_cache.c +++ b/fs/bcachefs/btree_key_cache.c @@ -608,7 +608,8 @@ void bch2_fs_btree_key_cache_exit(struct btree_key_cache *bc) } mutex_unlock(&bc->lock); - rhashtab...
5731cf01567da4f354bbff4a040b53f3f86328ad
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix journal reclaim spinning in recovery
Problem Details: We can't run journal reclaim until we've finished replaying updates to interior btree nodes - the check for this was in the wrong place though, leading to journal reclaim spinning before it was allowed to proceed. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstree...
```diff diff --git a/fs/bcachefs/journal_reclaim.c b/fs/bcachefs/journal_reclaim.c index 9f0d2e6aa4e3..c20f6de34730 100644 --- a/fs/bcachefs/journal_reclaim.c +++ b/fs/bcachefs/journal_reclaim.c @@ -609,6 +609,10 @@ static int bch2_journal_reclaim_thread(void *arg) struct journal *j = arg; unsigned long next; + s...
89931472c20bee93c6bcb0df7b057edda6473381
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix for __readahead_batch getting partial batch
Problem Details: We were incorrectly ignoring the return value of __readahead_batch, leading to a null ptr deref in __bch2_page_state_create(). Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/fs-io.c b/fs/bcachefs/fs-io.c index 1afdd775ffb3..9c3b11f414b5 100644 --- a/fs/bcachefs/fs-io.c +++ b/fs/bcachefs/fs-io.c @@ -667,7 +667,7 @@ static int readpages_iter_init(struct readpages_iter *iter, if (!iter->pages) return -ENOMEM; - __readahead_batch(ractl, iter->pages, nr_p...
f3020550777af9a66737334db94d96f8c3253e96
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix an rcu splat
Problem Details: bch2_bucket_alloc() requires rcu_read_lock() to be held. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/journal.c b/fs/bcachefs/journal.c index 2c6aa36cc025..27fcb378790b 100644 --- a/fs/bcachefs/journal.c +++ b/fs/bcachefs/journal.c @@ -682,16 +682,19 @@ static int __bch2_set_nr_journal_buckets(struct bch_dev *ca, unsigned nr, if (nr <= ja->nr) return 0; - ret = -ENOMEM; new_buc...
d5425a3b220a8b94ae2dd3c74af001a6b1216651
Analyze and fix the following issue in the Linux kernel code: bcachefs: Throttle updates when btree key cache is too dirty
Problem Details: This is needed to ensure we don't deadlock because journal reclaim and thus memory reclaim isn't making forward progress. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/btree_key_cache.h b/fs/bcachefs/btree_key_cache.h index 7723a2178430..d7d31a0662c3 100644 --- a/fs/bcachefs/btree_key_cache.h +++ b/fs/bcachefs/btree_key_cache.h @@ -5,11 +5,20 @@ static inline size_t bch2_nr_btree_keys_need_flush(struct bch_fs *c) { size_t nr_dirty = READ_ONCE(c->bt...
4e92cbb64287fcacc05f9a4fc1f9f390d5f58574
Analyze and fix the following issue in the Linux kernel code: bcachefs: More debug code improvements
Problem Details: Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/btree_update_interior.c b/fs/bcachefs/btree_update_interior.c index 96fa2b5a1d1e..3f6ab09d100d 100644 --- a/fs/bcachefs/btree_update_interior.c +++ b/fs/bcachefs/btree_update_interior.c @@ -49,12 +49,27 @@ static void btree_node_interior_verify(struct bch_fs *c, struct btree *b) bre...
ed0e24c0992dffe494bdd0ea6ddf3b816c438524
Analyze and fix the following issue in the Linux kernel code: bcachefs: Be more precise with journal error reporting
Problem Details: We were incorrectly detecting a journal deadlock - the journal filling up - when only the journal pin fifo had filled up; if the journal pin fifo is full that just means we need to wait on reclaim. This plumbs through better error reporting so we can better discriminate in the journal_res_get path wha...
```diff diff --git a/fs/bcachefs/journal.c b/fs/bcachefs/journal.c index b2a5e9db404e..bb4353e673e7 100644 --- a/fs/bcachefs/journal.c +++ b/fs/bcachefs/journal.c @@ -234,7 +234,7 @@ static int journal_entry_open(struct journal *j) BUG_ON(journal_entry_is_open(j)); if (j->blocked) - return -EAGAIN; + return cur...
1c74cec10cc8dbc595c6de83e2344a44d278dc11
Analyze and fix the following issue in the Linux kernel code: bcachefs: Add more debug checks
Problem Details: tracking down a bug where we see a btree node pointer in the wrong node Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/btree_io.c b/fs/bcachefs/btree_io.c index 302ee3851b0d..af3b39b70957 100644 --- a/fs/bcachefs/btree_io.c +++ b/fs/bcachefs/btree_io.c @@ -1442,8 +1442,10 @@ static int validate_bset_for_write(struct bch_fs *c, struct btree *b, ret = validate_bset(c, b, i, sectors, WRITE, false) ?: ...
e8bd002b23813f162d83a5c5c3b28832ba88f78e
Analyze and fix the following issue in the Linux kernel code: bcachefs: Dump journal state when the journal deadlocks
Problem Details: Currently tracking down one of these bugs. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/journal.c b/fs/bcachefs/journal.c index e7b60876d09a..32555ccffc0e 100644 --- a/fs/bcachefs/journal.c +++ b/fs/bcachefs/journal.c @@ -414,8 +414,17 @@ unlock: goto retry; if (ret == -ENOSPC) { - WARN_ONCE(!can_discard && (flags & JOURNAL_RES_GET_RESERVED), - "JOURNAL_RES_GET...
4d54337cdbf3baf8115bf8c1ed61bf44b3932a6d
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix journal entry repair code
Problem Details: When we detect bad keys in the journal that have to be dropped, the flow control was wrong - we ended up not checking the next key in that entry. Oops. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/journal_io.c b/fs/bcachefs/journal_io.c index a6fb4fb207a2..354d57a3cd59 100644 --- a/fs/bcachefs/journal_io.c +++ b/fs/bcachefs/journal_io.c @@ -160,6 +160,8 @@ static void journal_entry_null_range(void *start, void *end) #define journal_entry_err_on(cond, c, msg, ...) \ ((cond) ...
6d758368f1265ca9d0b7a077caf1ca9e9859c8c8
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix a btree transaction iter overflow
Problem Details: extent_replay_key dates from before putting iterators was required - fixed. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/recovery.c b/fs/bcachefs/recovery.c index 1745cfac6b26..6750063663b5 100644 --- a/fs/bcachefs/recovery.c +++ b/fs/bcachefs/recovery.c @@ -456,6 +456,7 @@ retry: __bch2_btree_iter_set_pos(split_iter, split->k.p, false); bch2_trans_update(&trans, split_iter, split, BTREE_TRIG...
101d471367a4b3a9158c53d3ca0093b0bed60338
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix a 64 bit divide
Problem Details: this fixes builds on 32 bit. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/buckets.c b/fs/bcachefs/buckets.c index 0dc01386d1cd..65d9b8126609 100644 --- a/fs/bcachefs/buckets.c +++ b/fs/bcachefs/buckets.c @@ -321,7 +321,7 @@ static u64 reserve_factor(u64 r) static u64 avail_factor(u64 r) { - return (r << RESERVE_FACTOR) / ((1 << RESERVE_FACTOR) + 1); + ret...
35ef6df5ca67347c606e418eb3ef71870ea97ba7
Analyze and fix the following issue in the Linux kernel code: bcachefs: Improve journal entry validate code
Problem Details: Previously, the journal entry read code was changed so that if we got a journal entry that failed validation, we'd try to use it, preferring to use a good version from another device if available. But this left a bug where if an earlier validation check (say, checksum) failed, the later checks (for la...
```diff diff --git a/fs/bcachefs/journal_io.c b/fs/bcachefs/journal_io.c index 80c833f1390b..e976aa83d527 100644 --- a/fs/bcachefs/journal_io.c +++ b/fs/bcachefs/journal_io.c @@ -431,46 +431,45 @@ static int jset_validate(struct bch_fs *c, "%s sector %llu seq %llu: unknown journal entry version %u", ca->name, s...
eb8e6e9ccbb4ba37c04a7cff032975b4df7d63c7
Analyze and fix the following issue in the Linux kernel code: bcachefs: Deadlock prevention for ei_pagecache_lock
Problem Details: In the dio write path, when get_user_pages() invokes the fault handler we have a recursive locking situation - we have to handle the lock ordering ourselves or we have a deadlock: this patch addresses that by checking for locking ordering violations and doing the unlock/relock dance if necessary. Sign...
```diff diff --git a/fs/bcachefs/fs-io.c b/fs/bcachefs/fs-io.c index 658d19c04b99..1afdd775ffb3 100644 --- a/fs/bcachefs/fs-io.c +++ b/fs/bcachefs/fs-io.c @@ -44,6 +44,22 @@ static inline bool bio_full(struct bio *bio, unsigned len) return false; } +static inline struct address_space *faults_disabled_mapping(void)...
e648448ca562af0cb11729ce6fad0f860fa42cb4
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix missing memalloc_nofs_restore()
Problem Details: Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/btree_cache.c b/fs/bcachefs/btree_cache.c index d130447e3477..9d8c73ec57d3 100644 --- a/fs/bcachefs/btree_cache.c +++ b/fs/bcachefs/btree_cache.c @@ -329,9 +329,9 @@ restart: clear_btree_node_accessed(b); } - memalloc_nofs_restore(flags); mutex_unlock(&bc->lock); out: + memal...
f526d26d711a376aa3dd8dd56f55928d5a28d9b1
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix btree key cache shutdown
Problem Details: On emergency shutdown, we might still have dirty keys in the btree key cache that need to be cleaned up properly. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/btree_key_cache.c b/fs/bcachefs/btree_key_cache.c index 4c61324f59d4..8b5e690a4d83 100644 --- a/fs/bcachefs/btree_key_cache.c +++ b/fs/bcachefs/btree_key_cache.c @@ -490,6 +490,9 @@ void bch2_fs_btree_key_cache_exit(struct btree_key_cache *bc) list_splice(&bc->dirty, &bc->clean); ...
01819cfe37e864a0e7d6f208c2e5b4635c66f974
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix btree iterator leak
Problem Details: this fixes an occasonial btree transaction iterators overflow. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/inode.c b/fs/bcachefs/inode.c index c64197d8fc84..8e52d475b397 100644 --- a/fs/bcachefs/inode.c +++ b/fs/bcachefs/inode.c @@ -537,7 +537,9 @@ found_slot: inode_u->bi_inum = k.k->p.offset; inode_u->bi_generation = bkey_generation(k); - return bch2_inode_write(trans, iter, inode_u);...
b3d1e6cab2dfcdfef5fc35659a8f33a75ae5904e
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix build warning when CONFIG_BCACHEFS_DEBUG=n
Problem Details: this function is only used by debug code, but we'd like to always build it so we know that it does build. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index bbb125fb9d43..f1d6553890f4 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -2408,9 +2408,10 @@ int bch2_trans_exit(struct btree_trans *trans) return trans->error ? -EIO : 0; } -static void bch2_btree_iter_node_to...
7e7ae6ca57d210dcedc4268323c9471d97194111
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix spurious transaction restarts
Problem Details: The checks for lock ordering violations weren't quite right. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index f62658f1b1dd..bbb125fb9d43 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -238,14 +238,32 @@ bool __bch2_btree_node_lock(struct btree *b, struct bpos pos, } } + if (linked->btree_id != iter->btree_id) { + ...
b735d73a00d5d9f5652a299146d518b7eea47b7b
Analyze and fix the following issue in the Linux kernel code: bcachefs: Build fixes for 32bit x86
Problem Details: PAGE_SIZE and size_t are not unsigned longs on 32 bit, annoying... also switch to atomic64_cmpxchg instead of cmpxchg() for journal_seq_copy, as atomic64_cmpxchg has a fallback that uses spinlocks for when it's not supported. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: K...
```diff diff --git a/fs/bcachefs/ec.c b/fs/bcachefs/ec.c index e5033b392432..42331f0e54e7 100644 --- a/fs/bcachefs/ec.c +++ b/fs/bcachefs/ec.c @@ -1586,7 +1586,7 @@ void bch2_stripes_heap_to_text(struct printbuf *out, struct bch_fs *c) size_t i; spin_lock(&c->ec_stripes_heap_lock); - for (i = 0; i < min(h->used, ...
d108efc2541590a0a086f27b1b703e59a84fafb2
Analyze and fix the following issue in the Linux kernel code: bcachefs: add const annotations to bset.c
Problem Details: perhaps a bit silly, but some debug assertions we want to add need const propagated a bit more. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/bset.c b/fs/bcachefs/bset.c index f483bcbe801e..fc8a7cc2f4bd 100644 --- a/fs/bcachefs/bset.c +++ b/fs/bcachefs/bset.c @@ -357,10 +357,10 @@ static struct bkey_float *bkey_float(const struct btree *b, return ro_aux_tree_base(b, t)->f + idx; } -static void bset_aux_tree_verify(struct...
29364f34530d30ca0f34dfe5d1ea73c8f1e77ff3
Analyze and fix the following issue in the Linux kernel code: bcachefs: Drop sysfs interface to debug parameters
Problem Details: It's not used much anymore, the module paramter interface is better. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/alloc_background.h b/fs/bcachefs/alloc_background.h index 66ce54724e93..8e3abb89dfb7 100644 --- a/fs/bcachefs/alloc_background.h +++ b/fs/bcachefs/alloc_background.h @@ -74,7 +74,7 @@ static inline void bch2_wake_allocator(struct bch_dev *ca) static inline void verify_not_on_freelist(s...
dcf141b9e13d261629806aa37e0fa7769d38b789
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix spurious transaction restarts
Problem Details: The check for whether locking a btree node would deadlock was wrong - we have to check that interior nodes are locked before descendents, but this check was wrong when consider cached vs. non cached iterators. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <k...
```diff diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index a76e13000d11..d310b2389e38 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -244,6 +244,7 @@ bool __bch2_btree_node_lock(struct btree *b, struct bpos pos, * we're about to lock, it must have the ancestors locked to...
a301dc38efa178e900a59ce7f03c1e81123c0919
Analyze and fix the following issue in the Linux kernel code: bcachefs: Improve tracing for transaction restarts
Problem Details: We have a bug where we can get stuck with a process spinning in transaction restarts - need more information. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/btree_cache.c b/fs/bcachefs/btree_cache.c index c503d76bab3b..02a2f558cf4d 100644 --- a/fs/bcachefs/btree_cache.c +++ b/fs/bcachefs/btree_cache.c @@ -706,7 +706,8 @@ static int lock_node_check_fn(struct six_lock *lock, void *p) */ struct btree *bch2_btree_node_get(struct bch_fs *c, s...
527087c741dc1199fbf4a635a80bf4839a9a8288
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix stack corruption
Problem Details: A bkey_on_stack_realloc() call was in the wrong place, and broken for indirect extents Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/fs.c b/fs/bcachefs/fs.c index 5119266a8493..2ed80ef41d1a 100644 --- a/fs/bcachefs/fs.c +++ b/fs/bcachefs/fs.c @@ -921,9 +921,7 @@ retry: bkey_start_offset(k.k); sectors = k.k->size - offset_into_extent; - bkey_on_stack_realloc(&cur, c, k.k->u64s); - bkey_on_stack_realloc(&p...
e7b854b1f76d34eeea6baa3a1b5eaa1f85ae6340
Analyze and fix the following issue in the Linux kernel code: bcachefs: fiemap fixes
Problem Details: - fiemap didn't know about inline extents, fixed - advancing to the next extent after we'd chased a pointer to the reflink btree was wrong, fixed Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/fs.c b/fs/bcachefs/fs.c index a61d5f8aecd6..5119266a8493 100644 --- a/fs/bcachefs/fs.c +++ b/fs/bcachefs/fs.c @@ -831,7 +831,7 @@ static int bch2_fill_extent(struct bch_fs *c, struct fiemap_extent_info *info, struct bkey_s_c k, unsigned flags) { - if (bkey_extent_is_dat...
645d72aa366e51259296cfc02e37c802d7b78493
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix btree updates when mixing cached and non cached iterators
Problem Details: There was a bug where bch2_trans_update() would incorrectly delete a pending update where the new update did not actually overwrite the existing update, because we were incorrectly using BTREE_ITER_TYPE when sorting pending btree updates. This affects the pending patch to use cached iterators for inod...
```diff diff --git a/fs/bcachefs/btree_cache.c b/fs/bcachefs/btree_cache.c index 90d884b18b70..c503d76bab3b 100644 --- a/fs/bcachefs/btree_cache.c +++ b/fs/bcachefs/btree_cache.c @@ -949,7 +949,7 @@ struct btree *bch2_btree_node_get_sibling(struct bch_fs *c, * holding other locks that would cause us to deadlock: ...
8be901d5d4a266e6838cdb6781084a02d2b37ace
Analyze and fix the following issue in the Linux kernel code: bcachefs: Always write a journal entry when stopping journal
Problem Details: This is to fix a (harmless) bug where the read clock hand in the superblock doesn't match the journal. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/journal.c b/fs/bcachefs/journal.c index d1e4a8162ddd..1f7f3b96bd87 100644 --- a/fs/bcachefs/journal.c +++ b/fs/bcachefs/journal.c @@ -979,9 +979,11 @@ void bch2_fs_journal_stop(struct journal *j) wait_event(j->wait, journal_entry_close(j)); - /* do we need to write another journal...
33114c2d897405ec338df979d1bf1d3319f92938
Analyze and fix the following issue in the Linux kernel code: bcachefs: Drop alloc keys from journal when -o reconstruct_alloc
Problem Details: This fixes a bug where we'd pop an assertion due to replaying a key for an interior btree node when that node no longer exists. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/recovery.c b/fs/bcachefs/recovery.c index d70fa968db50..32fed6b81a52 100644 --- a/fs/bcachefs/recovery.c +++ b/fs/bcachefs/recovery.c @@ -25,6 +25,18 @@ #define QSTR(n) { { { .len = strlen(n) } }, .name = n } +/* for -o reconstruct_alloc: */ +static void drop_alloc_keys(struct jour...
13dcd4abcd8d4e177f4f75ea3f5c8838a8a8c3c3
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix rare use after free in read path
Problem Details: If the bkey_on_stack_reassemble() call in __bch2_read_indirect_extent() reallocates the buffer, k in bch2_read - which we pointed at the bkey_on_stack buffer - will now point to a stale buffer. Whoops. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.over...
```diff diff --git a/fs/bcachefs/fs-io.c b/fs/bcachefs/fs-io.c index 0290f7410a5c..edc3d73d26ba 100644 --- a/fs/bcachefs/fs-io.c +++ b/fs/bcachefs/fs-io.c @@ -782,18 +782,19 @@ retry: if (ret) break; - bkey_on_stack_reassemble(&sk, c, k); - k = bkey_i_to_s_c(sk.k); - offset_into_extent = iter->pos.offset ...
a10e677a1555e070f1a7b3c1dc3e3189d462ab9e
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix for passing target= opts as mount opts
Problem Details: Some options can't be parsed until the filesystem initialized; previously, passing these options to mount or remount would cause mount to fail. This changes the mount path so that we parse the options passed in twice, and just ignore any options that can't be parsed the first time. Signed-off-by: Ken...
```diff diff --git a/fs/bcachefs/fs.c b/fs/bcachefs/fs.c index a488dcebc11a..b214d58e94e9 100644 --- a/fs/bcachefs/fs.c +++ b/fs/bcachefs/fs.c @@ -1343,7 +1343,7 @@ static int bch2_remount(struct super_block *sb, int *flags, char *data) opt_set(opts, read_only, (*flags & SB_RDONLY) != 0); - ret = bch2_parse_mount...
5b088c1dd005ec0fbddfa3664d3095caef6ae52e
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix bch2_mark_stripe()
Problem Details: There's no reason not to always recalculate these fields Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/buckets.c b/fs/bcachefs/buckets.c index 7558e2bffbdd..aacc20f71729 100644 --- a/fs/bcachefs/buckets.c +++ b/fs/bcachefs/buckets.c @@ -1264,6 +1264,13 @@ static int bch2_mark_stripe(struct bch_fs *c, m->algorithm = new_s->algorithm; m->nr_blocks = new_s->nr_blocks; m->nr_redunda...
39283c712e6df927c7c49e8b738ca110551bb399
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix for bad stripe pointers
Problem Details: The allocator usually doesn't increment bucket gens right away on buckets that it's about to hand out (for reasons that need to be documented), instead deferring that to whatever extent update first references that bucket. But stripe pointers reference buckets without changing bucket sector counts, me...
```diff diff --git a/fs/bcachefs/alloc_background.c b/fs/bcachefs/alloc_background.c index b0448d2f1916..8f0c1f378b77 100644 --- a/fs/bcachefs/alloc_background.c +++ b/fs/bcachefs/alloc_background.c @@ -497,8 +497,6 @@ static void bch2_bucket_clock_init(struct bch_fs *c, int rw) * commands to the newly free buckets, ...
289980195ffaa949ecd4216337a70a8e23cf8e86
Analyze and fix the following issue in the Linux kernel code: bcachefs: Start/stop io clock hands in read/write paths
Problem Details: This fixes a bug where the clock hands in the journal and superblock didn't match, because we were still incrementing the read clock hand while read-only. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/alloc_background.c b/fs/bcachefs/alloc_background.c index 459da00457ef..b0448d2f1916 100644 --- a/fs/bcachefs/alloc_background.c +++ b/fs/bcachefs/alloc_background.c @@ -1267,18 +1267,6 @@ void bch2_recalc_capacity(struct bch_fs *c) c->bucket_size_max = bucket_size_max; - if (c->c...
8d6b6222bf168e7a0613c0baf3da30f2c7338488
Analyze and fix the following issue in the Linux kernel code: bcachefs: Improvements to writing alloc info
Problem Details: Now that we've got transactional alloc info updates (and have for awhile), we don't need to write it out on shutdown, and we don't need to write it out on startup except when GC found errors - this is a big improvement to mount/unmount performance. This patch also fixes a few bugs where we weren't wri...
```diff diff --git a/fs/bcachefs/alloc_background.c b/fs/bcachefs/alloc_background.c index 9fa7184188c2..459da00457ef 100644 --- a/fs/bcachefs/alloc_background.c +++ b/fs/bcachefs/alloc_background.c @@ -271,12 +271,6 @@ int bch2_alloc_read(struct bch_fs *c, struct journal_keys *journal_keys) return 0; } -enum allo...
aa8889c07abecd7db7b2c0beb61db921fbafe04f
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix assertion popping in transaction commit path
Problem Details: We can't be holding read locks on btree nodes when we go to take write locks: this would deadlock if another thread is holding an intent lock on the node we have a read lock on, and it tries to commit and upgrade to a write lock. But instead of triggering an assertion, if this happens we can just upgr...
```diff diff --git a/fs/bcachefs/btree_update_leaf.c b/fs/bcachefs/btree_update_leaf.c index 4a0e248f6f82..a4a5e084aad3 100644 --- a/fs/bcachefs/btree_update_leaf.c +++ b/fs/bcachefs/btree_update_leaf.c @@ -503,6 +503,10 @@ static inline int do_bch2_trans_commit(struct btree_trans *trans, /* * Can't be holding a...
9f20ed157d521c7a1af0fe01e80d9e0ee880f9f7
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix copygc dying on startup
Problem Details: The copygc threads errors out and makes the filesystem go RO if it ever tries to run and discovers it has no reserve allocated - which is a problem if it races with the allocator thread and its reserve hasn't been filled yet. The allocator thread doesn't start filling the copygc reserve until after BC...
```diff diff --git a/fs/bcachefs/alloc_background.h b/fs/bcachefs/alloc_background.h index f6b9f27f0713..4f462696b747 100644 --- a/fs/bcachefs/alloc_background.h +++ b/fs/bcachefs/alloc_background.h @@ -61,8 +61,10 @@ static inline void bch2_wake_allocator(struct bch_dev *ca) rcu_read_lock(); p = rcu_dereference(...
6ea873d1727af15ae429882737e8848492b63595
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix copygc of compressed data
Problem Details: The check for when we need to get a disk reservation was wrong. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/move.c b/fs/bcachefs/move.c index 9967dd422e4d..8aa13b41d20d 100644 --- a/fs/bcachefs/move.c +++ b/fs/bcachefs/move.c @@ -296,14 +296,14 @@ int bch2_migrate_write_init(struct bch_fs *c, struct migrate_write *m, unsigned compressed_sectors = 0; bkey_for_each_ptr_decode(k.k, ptrs,...
97c0e19502549c0501581f9efff45022a10be2aa
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix another lockdep splat
Problem Details: vfree() can allocate memory, so we need to call memalloc_nofs_save(). Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/btree_cache.c b/fs/bcachefs/btree_cache.c index 5d1a7f138a54..90d884b18b70 100644 --- a/fs/bcachefs/btree_cache.c +++ b/fs/bcachefs/btree_cache.c @@ -253,7 +253,7 @@ static unsigned long bch2_btree_cache_scan(struct shrinker *shrink, unsigned long can_free; unsigned long touched = 0...
505b7a4c2844d8ee0004ab905874513776bc14da
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix errors early in the fs init process
Problem Details: At some point bch2_fs_alloc() was changed to always call bch2_fs_free() in the error path, which means we need c->cl to always be initialized. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/super.c b/fs/bcachefs/super.c index d0d46023163c..988c678de9fc 100644 --- a/fs/bcachefs/super.c +++ b/fs/bcachefs/super.c @@ -654,6 +654,14 @@ static struct bch_fs *bch2_fs_alloc(struct bch_sb *sb, struct bch_opts opts) __module_get(THIS_MODULE); + closure_init(&c->cl, NULL); + + ...
c47c50f8564a5bacff1afaa2adc8f46ef49935b4
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix gc of stale ptr gens
Problem Details: Awhile back, gcing of stale pointers was split out from full mark-and-sweep gc - but, the bit to actually drop those stale pointers wasn't implemnted. Whoops. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/btree_gc.c b/fs/bcachefs/btree_gc.c index 4b20817402f6..2774f10054a9 100644 --- a/fs/bcachefs/btree_gc.c +++ b/fs/bcachefs/btree_gc.c @@ -8,6 +8,7 @@ #include "alloc_background.h" #include "alloc_foreground.h" #include "bkey_methods.h" +#include "bkey_on_stack.h" #include "btree_loc...
9ee38f62da22625d9cd8919d9bbe1e4f0e36b9c3
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix off-by-one error in ptr gen check
Problem Details: Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/buckets.c b/fs/bcachefs/buckets.c index 7aba1907f91d..a34a9fe5a21c 100644 --- a/fs/bcachefs/buckets.c +++ b/fs/bcachefs/buckets.c @@ -950,7 +950,7 @@ static int __mark_pointer(struct bch_fs *c, struct bkey_s_c k, return -EIO; } - if (gen_cmp(bucket_gen, p.ptr.gen) >= 96U) { + if ...
5d0b7f906a7e047768f86539b10df602fcbd44b8
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix a lockdep splat
Problem Details: We can't allocate memory with GFP_FS while holding the btree cache lock, and vfree() can allocate memory. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/btree_cache.c b/fs/bcachefs/btree_cache.c index 829bff37df8d..5d1a7f138a54 100644 --- a/fs/bcachefs/btree_cache.c +++ b/fs/bcachefs/btree_cache.c @@ -349,11 +349,13 @@ void bch2_fs_btree_cache_exit(struct bch_fs *c) { struct btree_cache *bc = &c->btree_cache; struct btree *b; - uns...
9ba2eb25f017800c3d00eac2bbc3c99451c3bae2
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix __bch2_truncate_page()
Problem Details: __bch2_truncate_page() will mark some of the blocks in a page as unallocated. But, if the page is mmapped (and writable), every block in the page needs to be marked dirty, else those blocks won't be written by __bch2_writepage(). The solution is to change those userspace mappings to RO, so that we for...
```diff diff --git a/fs/bcachefs/fs-io.c b/fs/bcachefs/fs-io.c index c0995723ddd2..0290f7410a5c 100644 --- a/fs/bcachefs/fs-io.c +++ b/fs/bcachefs/fs-io.c @@ -27,6 +27,7 @@ #include <linux/migrate.h> #include <linux/mmu_context.h> #include <linux/pagevec.h> +#include <linux/rmap.h> #include <linux/sched/signal.h> ...
61ce38b862c17acccd0df0004d69710d8b438e99
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix journal_seq_copy()
Problem Details: We also need to update the journal's bloom filter of inode numbers that each journal write has upudates for - in case the inode gets evicted before it gets fsynced. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/fs.c b/fs/bcachefs/fs.c index 3239c4717cc6..a488dcebc11a 100644 --- a/fs/bcachefs/fs.c +++ b/fs/bcachefs/fs.c @@ -40,7 +40,8 @@ static void bch2_vfs_inode_init(struct bch_fs *, struct bch_inode_info *, struct bch_inode_unpacked *); -static void journal_seq_copy(struct bch_in...
d5e4dcc29cce41b4bb51bf83c54940018d57e598
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix unmount path
Problem Details: There was a long standing race in the mount/unmount code - the VFS intends for mount/unmount synchronizatino to be handled by the list of superblocks, but we were still holding devices open after tearing down our superblock in the unmount path. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev...
```diff diff --git a/fs/bcachefs/bcachefs.h b/fs/bcachefs/bcachefs.h index baa8801c5412..f60d530313dc 100644 --- a/fs/bcachefs/bcachefs.h +++ b/fs/bcachefs/bcachefs.h @@ -491,7 +491,6 @@ enum { BCH_FS_ERRORS_FIXED, /* misc: */ - BCH_FS_BDEV_MOUNTED, BCH_FS_FIXED_GENS, BCH_FS_ALLOC_WRITTEN, BCH_FS_REBUILD_RE...
7af0cec3076886d16114f4ca9794dfba3674794e
Analyze and fix the following issue in the Linux kernel code: bcachefs: Some project id fixes
Problem Details: Inode options that are accessible via the xattr interface are stored with a +1 bias, so that a value of 0 means unset. We weren't handling this consistently. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/fs-ioctl.c b/fs/bcachefs/fs-ioctl.c index acc0a230ff0c..f6773783b958 100644 --- a/fs/bcachefs/fs-ioctl.c +++ b/fs/bcachefs/fs-ioctl.c @@ -138,6 +138,10 @@ static int bch2_ioc_fssetxattr(struct bch_fs *c, if (fa.fsx_projid >= U32_MAX) return -EINVAL; + /* + * inode fields accessi...
2d8c0da1a7c2601b21d3fb63b8cb4f3610cac196
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix a couple null ptr derefs when no disk groups exist
Problem Details: Normally successfully parsing a target means disk groups should exist, but we don't want a BUG() or null ptr deref if we end up with an invalid target. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/disk_groups.c b/fs/bcachefs/disk_groups.c index 1c30065833c2..c47fa0a0f450 100644 --- a/fs/bcachefs/disk_groups.c +++ b/fs/bcachefs/disk_groups.c @@ -183,7 +183,7 @@ const struct bch_devs_mask *bch2_target_to_mask(struct bch_fs *c, unsigned targe case TARGET_GROUP: { struct bch_dis...
01566db2fb1fca313d75b8b849ee95bb9ec5bcd7
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix disk groups not being updated when set via sysfs
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/disk_groups.c b/fs/bcachefs/disk_groups.c index ee10308131e9..1c30065833c2 100644 --- a/fs/bcachefs/disk_groups.c +++ b/fs/bcachefs/disk_groups.c @@ -387,6 +387,7 @@ int bch2_dev_group_set(struct bch_fs *c, struct bch_dev *ca, const char *name) { struct bch_member *mi; int v = -1; ...
9f115ce9e9b57f0e55a37b657feac5663590b85e
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix a bug with the journal_seq_blacklist mechanism
Problem Details: Previously, we would start doing btree updates before writing the first journal entry; if this was after an unclean shutdown, this could cause those btree updates to not be blacklisted. Also, move some code to headers for userspace debug tools. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.co...
```diff diff --git a/fs/bcachefs/btree_io.c b/fs/bcachefs/btree_io.c index d3ea43dd9fe6..996fc0c34b3c 100644 --- a/fs/bcachefs/btree_io.c +++ b/fs/bcachefs/btree_io.c @@ -597,34 +597,6 @@ void bch2_btree_init_next(struct bch_fs *c, struct btree *b, bch2_btree_iter_reinit_node(iter, b); } -static struct nonce btre...
00c24f53b563dafb2de8c5f642d24ac775b4479c
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix bch2_new_stripes_to_text()
Problem Details: painful looking typo, fortunately difficult to hit. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/ec.c b/fs/bcachefs/ec.c index 61bc34225bf1..2120f0a9b424 100644 --- a/fs/bcachefs/ec.c +++ b/fs/bcachefs/ec.c @@ -1594,7 +1594,7 @@ void bch2_new_stripes_to_text(struct printbuf *out, struct bch_fs *c) mutex_unlock(&c->ec_stripe_head_lock); mutex_lock(&c->ec_stripe_new_lock); - li...
79e72a90936e9d19caf0ced4113e8d7659ebb2af
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix maximum btree node size
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/opts.h b/fs/bcachefs/opts.h index 2f93238891b0..6aaabb24d3ed 100644 --- a/fs/bcachefs/opts.h +++ b/fs/bcachefs/opts.h @@ -83,7 +83,7 @@ enum opt_type { "size", NULL) \ x(btree_node_size, u16, \ OPT_FORMAT, \ - OPT_SECTORS(1, 128), \ + OPT_SECTORS(1, 512...
f8058242205d59b8969990188f5590c054f90b5b
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix bch2_btree_node_insert_fits()
Problem Details: It should be checking for the recently added flag btree_node_needs_rewrite. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/btree_update_interior.h b/fs/bcachefs/btree_update_interior.h index 4a5b9dcfbdd0..812bafdc2d04 100644 --- a/fs/bcachefs/btree_update_interior.h +++ b/fs/bcachefs/btree_update_interior.h @@ -311,7 +311,7 @@ static inline void push_whiteout(struct bch_fs *c, struct btree *b, static inlin...
33e339619f7fda8c428daa5cb8fde7d68dad2edb
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix a race with BCH_WRITE_SKIP_CLOSURE_PUT
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/io.c b/fs/bcachefs/io.c index 7e57ca2e1071..d9e35329f707 100644 --- a/fs/bcachefs/io.c +++ b/fs/bcachefs/io.c @@ -1110,6 +1110,16 @@ again: goto flush_io; } + /* + * It's possible for the allocator to fail, put us on the + * freelist waitlist, and then succeed in one of va...
74ed7e560b794369adf87e0d310453bc78f4b273
Analyze and fix the following issue in the Linux kernel code: bcachefs: Don't let copygc buckets be stolen by other threads
Problem Details: And assorted other copygc fixes. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/alloc_background.c b/fs/bcachefs/alloc_background.c index 54455f77ad2a..ba7620999a8d 100644 --- a/fs/bcachefs/alloc_background.c +++ b/fs/bcachefs/alloc_background.c @@ -518,7 +518,9 @@ static int wait_buckets_available(struct bch_fs *c, struct bch_dev *ca) ca->inc_gen_really_nee...
4fe7efa17713e3d0eecbd106adff3d1b039cc554
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix an error path
Problem Details: We were missing a 'goto retry' and continuing on with an error pointer. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/btree_update_interior.c b/fs/bcachefs/btree_update_interior.c index 81386b26f369..5317f29c2776 100644 --- a/fs/bcachefs/btree_update_interior.c +++ b/fs/bcachefs/btree_update_interior.c @@ -1869,7 +1869,7 @@ int bch2_btree_node_update_key(struct bch_fs *c, struct btree_iter *iter, ...
a2b5313a39dfb0c027ef3f9d79efa531e1c0a736
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix a faulty assertion
Problem Details: Now that updates to interior nodes are journalled, we shouldn't be checking topology of interior nodes until we've finished replaying updates to that node. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/btree_update_interior.c b/fs/bcachefs/btree_update_interior.c index 05d20a6f5efd..81386b26f369 100644 --- a/fs/bcachefs/btree_update_interior.c +++ b/fs/bcachefs/btree_update_interior.c @@ -26,7 +26,7 @@ /* * Verify that child nodes correctly span parent node's range: */ -static vo...
e8306e3b4ca2d6cb325136afe5631247466ad176
Analyze and fix the following issue in the Linux kernel code: bcachefs: Wrap write path in memalloc_nofs_save()
Problem Details: This fixes a lockdep splat where we're allocating memory with vmalloc in the compression bounce path, which doesn't always obey GFP_NOFS. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/compress.c b/fs/bcachefs/compress.c index 920460a182b4..595d76aa3956 100644 --- a/fs/bcachefs/compress.c +++ b/fs/bcachefs/compress.c @@ -7,7 +7,6 @@ #include "super-io.h" #include <linux/lz4.h> -#include <linux/sched/mm.h> #include <linux/zlib.h> #include <linux/zstd.h> @@ -64,...
f621e1521c3ff5ea295a97d7d71cdbe84f496467
Analyze and fix the following issue in the Linux kernel code: bcachefs: Add an option for rebuilding the replicas section
Problem Details: There is a bug where we cnan end up clearing the data_has field in the superblock members section, which causes us to skip reading the journal and thus journal replay fails. This option tells the recovery path to not trust those fields. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed...
```diff diff --git a/fs/bcachefs/opts.h b/fs/bcachefs/opts.h index bc274918e18c..2f93238891b0 100644 --- a/fs/bcachefs/opts.h +++ b/fs/bcachefs/opts.h @@ -260,6 +260,11 @@ enum opt_type { OPT_BOOL(), \ NO_SB_OPT, false, \ NULL, "Don't replay the journal") \ + x(rebuild_replicas, u8, \ + ...
1d2ff0a63049f03bddcc98b195213bbd37e3ab53
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix extent_ptr_durability() calculation for erasure coded data
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/extents.c b/fs/bcachefs/extents.c index 5c1329360d9b..0fae8d76365e 100644 --- a/fs/bcachefs/extents.c +++ b/fs/bcachefs/extents.c @@ -723,7 +723,7 @@ static unsigned bch2_extent_ptr_durability(struct bch_fs *c, if (WARN_ON(!s)) goto out; - durability = max_t(unsigned, durabili...
912bdf17a849990f7241e294e48629987553b94c
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix short buffered writes
Problem Details: In the buffered write path, we have to check for short writes that write to the full page, where the page wasn't UpToDate; when this happens, the page is partly garbage, so we have to zero it out and revert that part of the write. This check was wrong - we reverted total from copied, but didn't revert...
```diff diff --git a/fs/bcachefs/fs-io.c b/fs/bcachefs/fs-io.c index d379581c2517..c0995723ddd2 100644 --- a/fs/bcachefs/fs-io.c +++ b/fs/bcachefs/fs-io.c @@ -1454,23 +1454,23 @@ retry_reservation: if (!pg_copied) break; + if (!PageUptodate(page) && + pg_copied != PAGE_SIZE && + pos + copied + pg_co...
fff899b1d90089a3c77a20dbe48bd44a00161a6b
Analyze and fix the following issue in the Linux kernel code: bcachefs: Mark btree nodes as needing rewrite when not all replicas are RW
Problem Details: This fixes a bug where recovery fails when one of the devices is read only. Also - consolidate the "must rewrite this node to insert it" behind a new btree node flag. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/btree_io.c b/fs/bcachefs/btree_io.c index cb9abca07059..d5240598e7d3 100644 --- a/fs/bcachefs/btree_io.c +++ b/fs/bcachefs/btree_io.c @@ -917,6 +917,7 @@ int bch2_btree_node_read_done(struct bch_fs *c, struct btree *b, bool have_retry struct sort_iter *iter; struct btree_node *sorte...
52fbb7c859788bb10dc0f1527eedf80fd11ec9ec
Analyze and fix the following issue in the Linux kernel code: bcachefs: Don't cap ios in dio write path at 2 MB
Problem Details: It appears this was erronious, a different bug was responsible Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/fs-io.c b/fs/bcachefs/fs-io.c index f893bef34217..d379581c2517 100644 --- a/fs/bcachefs/fs-io.c +++ b/fs/bcachefs/fs-io.c @@ -1797,22 +1797,12 @@ static long bch2_dio_write_loop(struct dio_write *dio) goto loop; while (1) { - size_t extra = dio->iter.count - - min(BIO_MAX_VECS...
042a1f268e82678ea202390b8a69457aafacd4a0
Analyze and fix the following issue in the Linux kernel code: bcachefs: Refactor dio write code to reinit bch_write_op
Problem Details: This fixes a bug where the BCH_WRITE_SKIP_CLOSURE_PUT was set incorrectly, causing the completion to be delivered multiple times. oops. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/fs-io.c b/fs/bcachefs/fs-io.c index 98fe1ec7867d..f893bef34217 100644 --- a/fs/bcachefs/fs-io.c +++ b/fs/bcachefs/fs-io.c @@ -63,6 +63,7 @@ struct dio_write { sync:1, free_iov:1; struct quota_res quota_res; + u64 written; struct iov_iter iter; struct iovec in...
64f2a8803ec8d3702a4b5225726f9c1dc685f43a
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix bch2_extent_can_insert() not being called
Problem Details: It's supposed to check whether we're splitting a compressed extent and if so get a bigger disk reservation - hence this fixes a "disk usage increased by x without a reservaiton" bug. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/btree_types.h b/fs/bcachefs/btree_types.h index f741bb79d49b..40cb4758a065 100644 --- a/fs/bcachefs/btree_types.h +++ b/fs/bcachefs/btree_types.h @@ -568,6 +568,16 @@ static inline bool btree_node_is_extents(struct btree *b) return btree_node_type_is_extents(btree_node_type(b)); } ...
c61b7e21ecfff2096cdb84d86bd18f1ceab7de72
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix a null ptr deref in bch2_btree_iter_traverse_one()
Problem Details: We use sentinal values that aren't NULL to indicate there's a btree node at a higher level; occasionally, this may result in btree_iter_up_until_good_node() stopping at one of those sentinal values. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstr...
```diff diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index 2bd02e804b76..7501556c0988 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -1235,7 +1235,7 @@ static int btree_iter_traverse_one(struct btree_iter *iter) * * XXX correctly using BTREE_ITER_UPTODATE should make t...
b9c3d13978120344d8b999d1c8bc4e3096d5a18f
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix a deadlock in the RO path
Problem Details: Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/btree_gc.c b/fs/bcachefs/btree_gc.c index 3775b65a89a6..cdd4bc334530 100644 --- a/fs/bcachefs/btree_gc.c +++ b/fs/bcachefs/btree_gc.c @@ -932,7 +932,12 @@ int bch2_gc_gens(struct bch_fs *c) unsigned i; int ret; - down_read(&c->state_lock); + /* + * Ideally we would be using state...
47a5649a0a934b3186f34d90ddfe31bb4bcf4fac
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix incorrect gfp check
Problem Details: Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/btree_cache.c b/fs/bcachefs/btree_cache.c index 9423cff1539f..dedb2790445d 100644 --- a/fs/bcachefs/btree_cache.c +++ b/fs/bcachefs/btree_cache.c @@ -310,7 +310,7 @@ restart: if (freed >= nr) goto out; - if (sc->gfp_mask & __GFP_IO) + if (sc->gfp_mask & __GFP_FS) mut...
d211b408abbcec99531bc262a8e9973c86a6d856
Analyze and fix the following issue in the Linux kernel code: bcachefs: Fix lock ordering with new btree cache code
Problem Details: The code that checks lock ordering was recently changed to go off of the pos of the btree node, rather than the iterator, but the btree cache code didn't update to handle iterators that point to cached bkeys. Oops Also, update various debug code. Signed-off-by: Kent Overstreet <kent.overstreet@gmail....
```diff diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index 592663a00182..2bd02e804b76 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -185,6 +185,14 @@ static inline bool btree_iter_get_locks(struct btree_iter *iter, return iter->uptodate < BTREE_ITER_NEED_RELOCK; } +sta...
7fffc85baf1fa176560a546a0625efc549969ce4
Analyze and fix the following issue in the Linux kernel code: bcachefs: Add an internal option for reading entire journal
Problem Details: To be used the debug tool that dumps the contents of the journal. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
```diff diff --git a/fs/bcachefs/journal.c b/fs/bcachefs/journal.c index 767cb6f809e7..cbfaec5143d8 100644 --- a/fs/bcachefs/journal.c +++ b/fs/bcachefs/journal.c @@ -986,9 +986,8 @@ int bch2_fs_journal_start(struct journal *j, u64 cur_seq, u64 last_seq = cur_seq, nr, seq; if (!list_empty(journal_entries)) - las...