bcachefs: Run btree updates after write out of write_point
authorKent Overstreet <kent.overstreet@linux.dev>
Mon, 31 Oct 2022 20:13:05 +0000 (16:13 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:29 +0000 (17:09 -0400)
commitb17d3cec14b487924df709dbeffb900f124a2607
treee3a5ce061e8e294d8d0570a7916996cebefb9d8d
parent5f417394033a0d8bfb31d02b3becf7381dc13867
bcachefs: Run btree updates after write out of write_point

In the write path, after the write to the block device(s) complete we
have to punt to process context to do the btree update.

Instead of using the work item embedded in op->cl, this patch switches
to a per write-point work item. This helps with two different issues:

 - lock contention: btree updates to the same writepoint will (usually)
   be updating the same alloc keys
 - context switch overhead: when we're bottlenecked on btree updates,
   having a thread (running out of a work item) checking the write point
   for completed ops is cheaper than queueing up a new work item and
   waking up a kworker.

In an arbitrary benchmark, 4k random writes with fio running inside a
VM, this patch resulted in a 10% improvement in total iops.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/alloc_foreground.c
fs/bcachefs/alloc_foreground.h
fs/bcachefs/alloc_types.h
fs/bcachefs/btree_update_interior.c
fs/bcachefs/io.c
fs/bcachefs/io.h
fs/bcachefs/io_types.h
fs/bcachefs/super.c
fs/bcachefs/sysfs.c
fs/bcachefs/util.c
fs/bcachefs/util.h