* [PATCH 1/7] bcachefs: io_read: remove from async obj list in rbio_done()
@ 2025-07-16 16:01 Kent Overstreet
2025-07-16 16:01 ` [PATCH 2/7] bcachefs: async_objs: update iter pos after obj printed Kent Overstreet
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: Kent Overstreet @ 2025-07-16 16:01 UTC (permalink / raw)
To: linux-bcachefs; +Cc: Kent Overstreet
Previously, only split rbios allocated in io_read.c would be removed
from the async obj list.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
---
fs/bcachefs/io_read.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/fs/bcachefs/io_read.c b/fs/bcachefs/io_read.c
index cd184b219a65..e0874ad9a6cf 100644
--- a/fs/bcachefs/io_read.c
+++ b/fs/bcachefs/io_read.c
@@ -166,6 +166,7 @@ static noinline void promote_free(struct bch_read_bio *rbio)
BUG_ON(ret);
async_object_list_del(c, promote, op->list_idx);
+ async_object_list_del(c, rbio, rbio->list_idx);
bch2_data_update_exit(&op->write);
@@ -456,6 +457,10 @@ static void bch2_rbio_done(struct bch_read_bio *rbio)
if (rbio->start_time)
bch2_time_stats_update(&rbio->c->times[BCH_TIME_data_read],
rbio->start_time);
+#ifdef CONFIG_BCACHEFS_ASYNC_OBJECT_LISTS
+ if (rbio->list_idx)
+ async_object_list_del(rbio->c, rbio, rbio->list_idx);
+#endif
bio_endio(&rbio->bio);
}
--
2.50.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/7] bcachefs: async_objs: update iter pos after obj printed
2025-07-16 16:01 [PATCH 1/7] bcachefs: io_read: remove from async obj list in rbio_done() Kent Overstreet
@ 2025-07-16 16:01 ` Kent Overstreet
2025-07-16 16:01 ` [PATCH 3/7] bcachefs: Fix triggering of discard by the journal path Kent Overstreet
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Kent Overstreet @ 2025-07-16 16:01 UTC (permalink / raw)
To: linux-bcachefs; +Cc: Kent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
---
fs/bcachefs/async_objs.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/fs/bcachefs/async_objs.c b/fs/bcachefs/async_objs.c
index a7cd1f0f0964..e368c765eb46 100644
--- a/fs/bcachefs/async_objs.c
+++ b/fs/bcachefs/async_objs.c
@@ -80,12 +80,11 @@ static ssize_t bch2_async_obj_list_read(struct file *file, char __user *buf,
break;
list->obj_to_text(&i->buf, obj);
+ i->iter = iter.pos;
}
if (i->buf.allocation_failure)
ret = -ENOMEM;
- else
- i->iter = iter.pos;
if (!ret)
ret = bch2_debugfs_flush_buf(i);
--
2.50.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/7] bcachefs: Fix triggering of discard by the journal path
2025-07-16 16:01 [PATCH 1/7] bcachefs: io_read: remove from async obj list in rbio_done() Kent Overstreet
2025-07-16 16:01 ` [PATCH 2/7] bcachefs: async_objs: update iter pos after obj printed Kent Overstreet
@ 2025-07-16 16:01 ` Kent Overstreet
2025-07-16 16:01 ` [PATCH 4/7] bcachefs: Tweak threshold for allocator triggering discards Kent Overstreet
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Kent Overstreet @ 2025-07-16 16:01 UTC (permalink / raw)
To: linux-bcachefs; +Cc: Kent Overstreet
It becomes possible to do discards after a journal flush, which
naturally the journal code is reponsible for.
A prior refactoring seems to have broken this - which went unnoticed
because the foreground allocator path can also trigger discards.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
---
fs/bcachefs/journal_io.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/fs/bcachefs/journal_io.c b/fs/bcachefs/journal_io.c
index dd3f3434c1b0..9e028dbcc3d0 100644
--- a/fs/bcachefs/journal_io.c
+++ b/fs/bcachefs/journal_io.c
@@ -1767,6 +1767,7 @@ static CLOSURE_CALLBACK(journal_write_done)
closure_wake_up(&c->freelist_wait);
bch2_reset_alloc_cursors(c);
+ do_discards = true;
}
j->seq_ondisk = seq;
--
2.50.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 4/7] bcachefs: Tweak threshold for allocator triggering discards
2025-07-16 16:01 [PATCH 1/7] bcachefs: io_read: remove from async obj list in rbio_done() Kent Overstreet
2025-07-16 16:01 ` [PATCH 2/7] bcachefs: async_objs: update iter pos after obj printed Kent Overstreet
2025-07-16 16:01 ` [PATCH 3/7] bcachefs: Fix triggering of discard by the journal path Kent Overstreet
@ 2025-07-16 16:01 ` Kent Overstreet
2025-07-16 16:01 ` [PATCH 5/7] bcachefs: Don't build aux search tree when still repairing node Kent Overstreet
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Kent Overstreet @ 2025-07-16 16:01 UTC (permalink / raw)
To: linux-bcachefs; +Cc: Kent Overstreet
The allocator path has a "if we're really low on free buckets, check if
we should issue discards" - tweak this to also trigger discards if more
than 1/128th of the device is in need_discard state.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
---
fs/bcachefs/alloc_foreground.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/bcachefs/alloc_foreground.c b/fs/bcachefs/alloc_foreground.c
index b375ad610acd..b58525ec7b4d 100644
--- a/fs/bcachefs/alloc_foreground.c
+++ b/fs/bcachefs/alloc_foreground.c
@@ -511,7 +511,8 @@ static struct open_bucket *bch2_bucket_alloc_trans(struct btree_trans *trans,
bch2_dev_usage_read_fast(ca, &req->usage);
avail = dev_buckets_free(ca, req->usage, req->watermark);
- if (req->usage.buckets[BCH_DATA_need_discard] > avail)
+ if (req->usage.buckets[BCH_DATA_need_discard] >
+ min(avail, ca->mi.nbuckets >> 7))
bch2_dev_do_discards(ca);
if (req->usage.buckets[BCH_DATA_need_gc_gens] > avail)
--
2.50.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 5/7] bcachefs: Don't build aux search tree when still repairing node
2025-07-16 16:01 [PATCH 1/7] bcachefs: io_read: remove from async obj list in rbio_done() Kent Overstreet
` (2 preceding siblings ...)
2025-07-16 16:01 ` [PATCH 4/7] bcachefs: Tweak threshold for allocator triggering discards Kent Overstreet
@ 2025-07-16 16:01 ` Kent Overstreet
2025-07-16 16:01 ` [PATCH 6/7] bcachefs: Fix reference to invalid bucket in copygc Kent Overstreet
2025-07-16 16:01 ` [PATCH 7/7] bcachefs: Fix build when CONFIG_UNICODE=n Kent Overstreet
5 siblings, 0 replies; 7+ messages in thread
From: Kent Overstreet @ 2025-07-16 16:01 UTC (permalink / raw)
To: linux-bcachefs; +Cc: Kent Overstreet, syzbot+c5e7a66b3b23ae65d44f
bch2_btree_node_drop_keys_outside_node() will (re)build aux search
trees, because it's also called by topology repair.
bch2_btree_node_read_done() was calling it before validating individual
keys; invalid ones have to be dropped.
If we call drop_keys_outside_node() first, then
bch2_bset_build_aux_tree() doesn't run because the node already has an
aux search tree - which was invalidated by the repair.
Reported-by: syzbot+c5e7a66b3b23ae65d44f@syzkaller.appspotmail.com
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
---
fs/bcachefs/btree_io.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/fs/bcachefs/btree_io.c b/fs/bcachefs/btree_io.c
index a4cc72986e36..590cd29f3e86 100644
--- a/fs/bcachefs/btree_io.c
+++ b/fs/bcachefs/btree_io.c
@@ -1295,9 +1295,6 @@ int bch2_btree_node_read_done(struct bch_fs *c, struct bch_dev *ca,
btree_bounce_free(c, btree_buf_bytes(b), used_mempool, sorted);
- if (updated_range)
- bch2_btree_node_drop_keys_outside_node(b);
-
i = &b->data->keys;
for (k = i->start; k != vstruct_last(i);) {
struct bkey tmp;
@@ -1335,6 +1332,9 @@ int bch2_btree_node_read_done(struct bch_fs *c, struct bch_dev *ca,
btree_node_reset_sib_u64s(b);
+ if (updated_range)
+ bch2_btree_node_drop_keys_outside_node(b);
+
/*
* XXX:
*
--
2.50.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 6/7] bcachefs: Fix reference to invalid bucket in copygc
2025-07-16 16:01 [PATCH 1/7] bcachefs: io_read: remove from async obj list in rbio_done() Kent Overstreet
` (3 preceding siblings ...)
2025-07-16 16:01 ` [PATCH 5/7] bcachefs: Don't build aux search tree when still repairing node Kent Overstreet
@ 2025-07-16 16:01 ` Kent Overstreet
2025-07-16 16:01 ` [PATCH 7/7] bcachefs: Fix build when CONFIG_UNICODE=n Kent Overstreet
5 siblings, 0 replies; 7+ messages in thread
From: Kent Overstreet @ 2025-07-16 16:01 UTC (permalink / raw)
To: linux-bcachefs; +Cc: Kent Overstreet, syzbot+3168625f36f4a539237e
Use bch2_dev_bucket_tryget() instead of bch2_dev_tryget() before
checking the bucket bitmap.
Reported-by: syzbot+3168625f36f4a539237e@syzkaller.appspotmail.com
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
---
fs/bcachefs/movinggc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/bcachefs/movinggc.c b/fs/bcachefs/movinggc.c
index 27e68d470ad0..5e6de91a8763 100644
--- a/fs/bcachefs/movinggc.c
+++ b/fs/bcachefs/movinggc.c
@@ -71,7 +71,7 @@ static int bch2_bucket_is_movable(struct btree_trans *trans,
if (ret)
return ret;
- struct bch_dev *ca = bch2_dev_tryget(c, k.k->p.inode);
+ struct bch_dev *ca = bch2_dev_bucket_tryget(c, k.k->p);
if (!ca)
goto out;
--
2.50.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 7/7] bcachefs: Fix build when CONFIG_UNICODE=n
2025-07-16 16:01 [PATCH 1/7] bcachefs: io_read: remove from async obj list in rbio_done() Kent Overstreet
` (4 preceding siblings ...)
2025-07-16 16:01 ` [PATCH 6/7] bcachefs: Fix reference to invalid bucket in copygc Kent Overstreet
@ 2025-07-16 16:01 ` Kent Overstreet
5 siblings, 0 replies; 7+ messages in thread
From: Kent Overstreet @ 2025-07-16 16:01 UTC (permalink / raw)
To: linux-bcachefs; +Cc: Kent Overstreet
94426e4201fb, which added the killswitch for casefolding, accidentally
removed some of the ifdefs we need to avoid build errors.
It appears we need better build testing for different configurations, it
took two weeks for the robots to catch this one.
Fixes: 94426e4201fb ("bcachefs: opts.casefold_disabled")
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
---
fs/bcachefs/dirent.c | 4 ++++
fs/bcachefs/dirent.h | 9 +++++++++
2 files changed, 13 insertions(+)
diff --git a/fs/bcachefs/dirent.c b/fs/bcachefs/dirent.c
index a18d0f78704d..28875c5c86ad 100644
--- a/fs/bcachefs/dirent.c
+++ b/fs/bcachefs/dirent.c
@@ -13,6 +13,7 @@
#include <linux/dcache.h>
+#ifdef CONFIG_UNICODE
int bch2_casefold(struct btree_trans *trans, const struct bch_hash_info *info,
const struct qstr *str, struct qstr *out_cf)
{
@@ -33,6 +34,7 @@ int bch2_casefold(struct btree_trans *trans, const struct bch_hash_info *info,
*out_cf = (struct qstr) QSTR_INIT(buf, ret);
return 0;
}
+#endif
static unsigned bch2_dirent_name_bytes(struct bkey_s_c_dirent d)
{
@@ -254,6 +256,7 @@ int bch2_dirent_init_name(struct bch_fs *c,
if (!bch2_fs_casefold_enabled(c))
return -EOPNOTSUPP;
+#ifdef CONFIG_UNICODE
memcpy(&dirent->v.d_cf_name_block.d_names[0], name->name, name->len);
char *cf_out = &dirent->v.d_cf_name_block.d_names[name->len];
@@ -279,6 +282,7 @@ int bch2_dirent_init_name(struct bch_fs *c,
dirent->v.d_cf_name_block.d_cf_name_len = cpu_to_le16(cf_len);
EBUG_ON(bch2_dirent_get_casefold_name(dirent_i_to_s_c(dirent)).len != cf_len);
+#endif
}
unsigned u64s = dirent_val_u64s(name->len, cf_len);
diff --git a/fs/bcachefs/dirent.h b/fs/bcachefs/dirent.h
index 1e17199cc5c7..2e9cbf8123c4 100644
--- a/fs/bcachefs/dirent.h
+++ b/fs/bcachefs/dirent.h
@@ -23,6 +23,7 @@ struct bch_fs;
struct bch_hash_info;
struct bch_inode_info;
+#ifdef CONFIG_UNICODE
int bch2_casefold(struct btree_trans *, const struct bch_hash_info *,
const struct qstr *, struct qstr *);
@@ -37,6 +38,14 @@ static inline int bch2_maybe_casefold(struct btree_trans *trans,
return bch2_casefold(trans, info, str, out_cf);
}
}
+#else
+static inline int bch2_maybe_casefold(struct btree_trans *trans,
+ const struct bch_hash_info *info,
+ const struct qstr *str, struct qstr *out_cf)
+{
+ return -EOPNOTSUPP;
+}
+#endif
struct qstr bch2_dirent_get_name(struct bkey_s_c_dirent);
--
2.50.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-07-16 16:01 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-16 16:01 [PATCH 1/7] bcachefs: io_read: remove from async obj list in rbio_done() Kent Overstreet
2025-07-16 16:01 ` [PATCH 2/7] bcachefs: async_objs: update iter pos after obj printed Kent Overstreet
2025-07-16 16:01 ` [PATCH 3/7] bcachefs: Fix triggering of discard by the journal path Kent Overstreet
2025-07-16 16:01 ` [PATCH 4/7] bcachefs: Tweak threshold for allocator triggering discards Kent Overstreet
2025-07-16 16:01 ` [PATCH 5/7] bcachefs: Don't build aux search tree when still repairing node Kent Overstreet
2025-07-16 16:01 ` [PATCH 6/7] bcachefs: Fix reference to invalid bucket in copygc Kent Overstreet
2025-07-16 16:01 ` [PATCH 7/7] bcachefs: Fix build when CONFIG_UNICODE=n Kent Overstreet
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).