Add a test with fsync

This commit is contained in:
Vitaliy Filippov
2025-12-02 01:52:12 +03:00
parent 7f4c541a6f
commit 57d2f30303
10 changed files with 358 additions and 136 deletions
+8 -7
View File
@@ -123,9 +123,9 @@ int blockstore_impl_t::dequeue_write(blockstore_op_t *op)
);
#endif
heap->use_data(op->oid.inode, PRIV(op)->location);
if (!dsk.disable_data_fsync)
if (!dsk.disable_data_fsync && dsk.disable_meta_fsync)
{
// Do big_write as an INTENT to avoid fsync
// Do big_write as an INTENT to avoid data fsync
bool ok = make_big_write(op, 0, 0, &modified_block);
assert(ok);
obj = heap->read_entry(op->oid, &modified_block);
@@ -160,8 +160,7 @@ int blockstore_impl_t::dequeue_write(blockstore_op_t *op)
}
// Only one INTENT_WRITE is allowed at a time, but in fact,
// parallel writes to the same object are forbidden anyway
else if (op->opcode == BS_OP_WRITE_STABLE &&
op->len > 0 && op->len <= dsk.atomic_write_size &&
else if (op->len > 0 && op->len <= dsk.atomic_write_size &&
// Intent-writes are disabled if "absolutely correct during compaction" checksum validation algorithm is enabled
// We could also do RMW here when padded_csum_update is enabled, but it's unclear if we need it
(!padded_csum_update || dsk.csum_block_size <= dsk.bitmap_granularity ||
@@ -171,8 +170,10 @@ int blockstore_impl_t::dequeue_write(blockstore_op_t *op)
obj->get_writes()->can_be_collapsed(heap))) &&
// One intent-write is allowed even with fsyncs because BIG_WRITE is always counted as fsynced
dsk.disable_meta_fsync &&
(obj->get_writes()->flags == (BS_HEAP_BIG_WRITE|BS_HEAP_STABLE) ||
obj->get_writes()->flags == (BS_HEAP_INTENT_WRITE|BS_HEAP_STABLE) && dsk.disable_data_fsync))
(op->opcode == BS_OP_WRITE_STABLE &&
(obj->get_writes()->flags == (BS_HEAP_BIG_WRITE|BS_HEAP_STABLE) ||
obj->get_writes()->flags == (BS_HEAP_INTENT_WRITE|BS_HEAP_STABLE) && dsk.disable_data_fsync) ||
op->opcode == BS_OP_WRITE && obj->get_writes()->flags == BS_HEAP_BIG_WRITE))
{
// Direct intent-write
BS_SUBMIT_CHECK_SQES(1);
@@ -191,7 +192,7 @@ process_intent:
wr->offset = op->offset;
wr->len = op->len;
wr->location = 0;
wr->flags = BS_HEAP_INTENT_WRITE | BS_HEAP_STABLE;
wr->flags = BS_HEAP_INTENT_WRITE | (op->opcode == BS_OP_WRITE_STABLE ? BS_HEAP_STABLE : 0);
if (op->bitmap)
memcpy(wr->get_ext_bitmap(heap), op->bitmap, dsk.clean_entry_bitmap_size);
heap->calc_checksums(wr, (uint8_t*)op->buf, true);