BlueStore write path
In the book: Chapter 12
Lab
BlueStore write path
Choose the device, offset and length of a write and watch BlueStore split it and decide what goes through the WAL (deferred) and what is written directly.
1pieces
4 KiBbytes through the WAL
–bytes written directly
64 KiBprefer_deferred_size
| Piece | Range | Path | How | Read first | Allocated |
|---|---|---|---|---|---|
| big | 0 B + 4 KiB | big overwrite in existing blobs | deferred (WAL) | – | – |
- queue_transactions The OSD hands BlueStore a transaction; a TransContext is created in state PREPARE.
BlueStore::queue_transactions, _txc_create - split at min_alloc _do_write_data cuts the write into 1 piece(s) and sends each to _do_write_small or _do_write_big.
BlueStore::_do_write_data, _do_write_small, _do_write_big - deferred op The bytes to be written in place are put into a bluestore_deferred_op_t inside the same RocksDB transaction.
bluestore_deferred_op_t, BlueStore::_txc_add_transaction - KV commit with data _kv_sync_thread commits the metadata and the deferred data to RocksDB with a sync; the WAL write is the only synchronous disk write.
BlueStore::_kv_sync_thread, _txc_apply_kv - ack After the commit the write is durable; _txc_committed_kv completes the OSD's callbacks and the client can get its ack.
BlueStore::_txc_committed_kv, _txc_state_proc - deferred write Later, in batches (bluestore_deferred_batch_ops), the deferred bytes are written to their place on the block device.
BlueStore::_deferred_queue, _deferred_submit_unlock - cleanup When that write is on disk, _deferred_aio_finish removes the deferred record from RocksDB.
BlueStore::_deferred_aio_finish
new data: deferred ⇔ data_size < prefer_deferred_size (64 KiB) · small overwrite: always deferred · big overwrite: deferred ⇔ len ≤ 2 × prefer_deferred_size
Follows:
src/os/bluestore/BlueStore.cc :: _do_write, _do_write_datasplitting a write into head, middle and tailBlueStore.cc :: _do_write_small, _do_write_bigthe small and big write pathsBlueStore.cc :: _do_alloc_write (prefer_deferred_size)allocation and the deferred-or-direct decisionBlueStore.cc :: _txc_state_proc, _kv_sync_thread, _deferred_queuethe transaction's state machine, the KV commit and the deferred queuesrc/os/bluestore/BlueStore_components.h :: TransContext::state_tthe TransContext statessrc/common/options/global.yaml.in :: bluestore_min_alloc_size_hdd/ssd (4K), bluestore_prefer_deferred_size_hdd (64K) / _ssd (0)the default sizes used here