Skip to content

Commit 161f73c

Browse files
author
Kent Overstreet
committed
bcachefs: Split out btree_write_submit_wq
Split the workqueues for btree read completions and btree write submissions; we don't want concurrency control on btree read completions, but we do want concurrency control on write submissions, else blocking in submit_bio() will cause a ton of kworkers to be allocated. Signed-off-by: Kent Overstreet <[email protected]>
1 parent 83a7eef commit 161f73c

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

fs/bcachefs/bcachefs.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,8 @@ struct bch_fs {
790790

791791
/* BTREE CACHE */
792792
struct bio_set btree_bio;
793-
struct workqueue_struct *io_complete_wq;
793+
struct workqueue_struct *btree_read_complete_wq;
794+
struct workqueue_struct *btree_write_submit_wq;
794795

795796
struct btree_root btree_roots_known[BTREE_ID_NR];
796797
DARRAY(struct btree_root) btree_roots_extra;

fs/bcachefs/btree_io.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1389,7 +1389,7 @@ static void btree_node_read_endio(struct bio *bio)
13891389
bch2_latency_acct(ca, rb->start_time, READ);
13901390
}
13911391

1392-
queue_work(c->io_complete_wq, &rb->work);
1392+
queue_work(c->btree_read_complete_wq, &rb->work);
13931393
}
13941394

13951395
struct btree_node_read_all {
@@ -1656,7 +1656,7 @@ static int btree_node_read_all_replicas(struct bch_fs *c, struct btree *b, bool
16561656
btree_node_read_all_replicas_done(&ra->cl.work);
16571657
} else {
16581658
continue_at(&ra->cl, btree_node_read_all_replicas_done,
1659-
c->io_complete_wq);
1659+
c->btree_read_complete_wq);
16601660
}
16611661

16621662
return 0;
@@ -1737,7 +1737,7 @@ void bch2_btree_node_read(struct btree_trans *trans, struct btree *b,
17371737
if (sync)
17381738
btree_node_read_work(&rb->work);
17391739
else
1740-
queue_work(c->io_complete_wq, &rb->work);
1740+
queue_work(c->btree_read_complete_wq, &rb->work);
17411741
}
17421742
}
17431743

@@ -2229,7 +2229,7 @@ void __bch2_btree_node_write(struct bch_fs *c, struct btree *b, unsigned flags)
22292229
atomic64_add(bytes_to_write, &c->btree_write_stats[type].bytes);
22302230

22312231
INIT_WORK(&wbio->work, btree_write_submit);
2232-
queue_work(c->io_complete_wq, &wbio->work);
2232+
queue_work(c->btree_write_submit_wq, &wbio->work);
22332233
return;
22342234
err:
22352235
set_btree_node_noevict(b);

fs/bcachefs/super.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -582,8 +582,10 @@ static void __bch2_fs_free(struct bch_fs *c)
582582

583583
if (c->write_ref_wq)
584584
destroy_workqueue(c->write_ref_wq);
585-
if (c->io_complete_wq)
586-
destroy_workqueue(c->io_complete_wq);
585+
if (c->btree_write_submit_wq)
586+
destroy_workqueue(c->btree_write_submit_wq);
587+
if (c->btree_read_complete_wq)
588+
destroy_workqueue(c->btree_read_complete_wq);
587589
if (c->copygc_wq)
588590
destroy_workqueue(c->copygc_wq);
589591
if (c->btree_io_complete_wq)
@@ -878,8 +880,10 @@ static struct bch_fs *bch2_fs_alloc(struct bch_sb *sb, struct bch_opts opts)
878880
WQ_HIGHPRI|WQ_FREEZABLE|WQ_MEM_RECLAIM, 1)) ||
879881
!(c->copygc_wq = alloc_workqueue("bcachefs_copygc",
880882
WQ_HIGHPRI|WQ_FREEZABLE|WQ_MEM_RECLAIM|WQ_CPU_INTENSIVE, 1)) ||
881-
!(c->io_complete_wq = alloc_workqueue("bcachefs_io",
883+
!(c->btree_read_complete_wq = alloc_workqueue("bcachefs_btree_read_complete",
882884
WQ_HIGHPRI|WQ_FREEZABLE|WQ_MEM_RECLAIM, 512)) ||
885+
!(c->btree_write_submit_wq = alloc_workqueue("bcachefs_btree_write_sumit",
886+
WQ_HIGHPRI|WQ_FREEZABLE|WQ_MEM_RECLAIM, 1)) ||
883887
!(c->write_ref_wq = alloc_workqueue("bcachefs_write_ref",
884888
WQ_FREEZABLE, 0)) ||
885889
#ifndef BCH_WRITE_REF_DEBUG

0 commit comments

Comments
 (0)