bcachefs: Btree write buffer
authorKent Overstreet <kent.overstreet@linux.dev>
Wed, 4 Jan 2023 05:00:50 +0000 (00:00 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:50 +0000 (17:09 -0400)
commit920e69bc3db88d3825c69190cafd43f0a1918d3b
tree6ff5cce6d8cbf0e014eeb1369e92512b60a21595
parentf2b542ba42a8b35d9dc43f5eab9791fea76bfd3a
bcachefs: Btree write buffer

This adds a new method of doing btree updates - a straight write buffer,
implemented as a flat fixed size array.

This is only useful when we don't need to read from the btree in order
to do the update, and when reading is infrequent - perfect for the LRU
btree.

This will make LRU btree updates fast enough that we'll be able to use
it for persistently indexing buckets by fragmentation, which will be a
massive boost to copygc performance.

Changes:
 - A new btree_insert_type enum, for btree_insert_entries. Specifies
   btree, btree key cache, or btree write buffer.

 - bch2_trans_update_buffered(): updates via the btree write buffer
   don't need a btree path, so we need a new update path.

 - Transaction commit path changes:
   The update to the btree write buffer both mutates global, and can
   fail if there isn't currently room. Therefore we do all write buffer
   updates in the transaction all at once, and also if it fails we have
   to revert filesystem usage counter changes.

   If there isn't room we flush the write buffer in the transaction
   commit error path and retry.

 - A new persistent option, for specifying the number of entries in the
   write buffer.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
16 files changed:
fs/bcachefs/Makefile
fs/bcachefs/bcachefs.h
fs/bcachefs/bcachefs_format.h
fs/bcachefs/btree_iter.c
fs/bcachefs/btree_types.h
fs/bcachefs/btree_update.h
fs/bcachefs/btree_update_leaf.c
fs/bcachefs/btree_write_buffer.c [new file with mode: 0644]
fs/bcachefs/btree_write_buffer.h [new file with mode: 0644]
fs/bcachefs/btree_write_buffer_types.h [new file with mode: 0644]
fs/bcachefs/buckets.c
fs/bcachefs/buckets.h
fs/bcachefs/errcode.h
fs/bcachefs/opts.h
fs/bcachefs/super.c
fs/bcachefs/trace.h