Fsync after stabilizing
This commit is contained in:
@@ -173,6 +173,7 @@ class blockstore_impl_t: public blockstore_i
|
|||||||
|
|
||||||
// Sync
|
// Sync
|
||||||
int continue_sync(blockstore_op_t *op);
|
int continue_sync(blockstore_op_t *op);
|
||||||
|
int do_sync(blockstore_op_t *op, int base_state);
|
||||||
|
|
||||||
// Stabilize
|
// Stabilize
|
||||||
int dequeue_stable(blockstore_op_t *op);
|
int dequeue_stable(blockstore_op_t *op);
|
||||||
|
|||||||
@@ -66,28 +66,20 @@ resume_1:
|
|||||||
priv->op_state = 1;
|
priv->op_state = 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
resume_2:
|
|
||||||
if (!dsk.disable_meta_fsync)
|
|
||||||
{
|
|
||||||
BS_SUBMIT_GET_SQE(sqe, data);
|
|
||||||
io_uring_prep_fsync(sqe, dsk.meta_fd, IORING_FSYNC_DATASYNC);
|
|
||||||
data->iov = { 0 };
|
|
||||||
data->callback = [this, op](ring_data_t *data) { handle_write_event(data, op); };
|
|
||||||
priv->pending_ops++;
|
|
||||||
}
|
|
||||||
resume_3:
|
|
||||||
if (priv->pending_ops > 0)
|
|
||||||
{
|
|
||||||
priv->op_state = 3;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
resume_4:
|
|
||||||
// Mark writes as completed to allow compaction
|
// Mark writes as completed to allow compaction
|
||||||
// FIXME: Also mark as fsynced
|
|
||||||
for (uint64_t lsn = priv->lsn; lsn <= priv->to_lsn; lsn++)
|
for (uint64_t lsn = priv->lsn; lsn <= priv->to_lsn; lsn++)
|
||||||
{
|
{
|
||||||
heap->mark_lsn_completed(lsn);
|
heap->mark_lsn_completed(lsn);
|
||||||
}
|
}
|
||||||
|
// Fsync, just because our semantics imply that commit (stabilize) is immediately fsynced
|
||||||
|
resume_2:
|
||||||
|
resume_3:
|
||||||
|
resume_4:
|
||||||
|
int res = do_sync(op, 2);
|
||||||
|
if (res != 2)
|
||||||
|
{
|
||||||
|
return res;
|
||||||
|
}
|
||||||
// Done. Don't touch op->retval - if anything resulted in ENOENT, return it as is
|
// Done. Don't touch op->retval - if anything resulted in ENOENT, return it as is
|
||||||
FINISH_OP(op);
|
FINISH_OP(op);
|
||||||
return 2;
|
return 2;
|
||||||
|
|||||||
@@ -6,7 +6,21 @@
|
|||||||
|
|
||||||
int blockstore_impl_t::continue_sync(blockstore_op_t *op)
|
int blockstore_impl_t::continue_sync(blockstore_op_t *op)
|
||||||
{
|
{
|
||||||
int op_state = PRIV(op)->op_state;
|
if (!PRIV(op)->op_state)
|
||||||
|
{
|
||||||
|
op->retval = 0;
|
||||||
|
}
|
||||||
|
int res = do_sync(op, 0);
|
||||||
|
if (res == 2)
|
||||||
|
{
|
||||||
|
FINISH_OP(op);
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
int blockstore_impl_t::do_sync(blockstore_op_t *op, int base_state)
|
||||||
|
{
|
||||||
|
int op_state = PRIV(op)->op_state - base_state;
|
||||||
if (op_state == 1) goto resume_1;
|
if (op_state == 1) goto resume_1;
|
||||||
if (op_state == 2) goto resume_2;
|
if (op_state == 2) goto resume_2;
|
||||||
assert(!op_state);
|
assert(!op_state);
|
||||||
@@ -19,8 +33,6 @@ int blockstore_impl_t::continue_sync(blockstore_op_t *op)
|
|||||||
{
|
{
|
||||||
// We can return immediately because sync is only dequeued after all previous writes
|
// We can return immediately because sync is only dequeued after all previous writes
|
||||||
unsynced_big_write_count = unsynced_small_write_count = 0;
|
unsynced_big_write_count = unsynced_small_write_count = 0;
|
||||||
op->retval = 0;
|
|
||||||
FINISH_OP(op);
|
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
PRIV(op)->lsn = heap->get_completed_lsn();
|
PRIV(op)->lsn = heap->get_completed_lsn();
|
||||||
@@ -48,12 +60,10 @@ int blockstore_impl_t::continue_sync(blockstore_op_t *op)
|
|||||||
resume_1:
|
resume_1:
|
||||||
if (PRIV(op)->pending_ops > 0)
|
if (PRIV(op)->pending_ops > 0)
|
||||||
{
|
{
|
||||||
PRIV(op)->op_state = 1;
|
PRIV(op)->op_state = base_state+1;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
resume_2:
|
resume_2:
|
||||||
heap->mark_lsn_fsynced(PRIV(op)->lsn);
|
heap->mark_lsn_fsynced(PRIV(op)->lsn);
|
||||||
op->retval = 0;
|
|
||||||
FINISH_OP(op);
|
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user