Move enqueue_write to _write.cpp

blocking-uring-test
Vitaliy Filippov 2019-11-10 13:27:59 +03:00
parent e5caffb6ac
commit 64185f7a1f
3 changed files with 39 additions and 33 deletions

View File

@ -256,39 +256,7 @@ int blockstore::enqueue_op(blockstore_operation *op)
submit_queue.push_back(op);
if ((op->flags & OP_TYPE_MASK) == OP_WRITE)
{
// Assign version number
auto dirty_it = dirty_db.upper_bound((obj_ver_id){
.oid = op->oid,
.version = UINT64_MAX,
});
dirty_it--;
if (dirty_it != dirty_db.end() && dirty_it->first.oid == op->oid)
{
op->version = dirty_it->first.version + 1;
}
else
{
auto clean_it = object_db.find(op->oid);
if (clean_it != object_db.end())
{
op->version = clean_it->second.version + 1;
}
else
{
op->version = 1;
}
}
// Immediately add the operation into dirty_db, so subsequent reads could see it
dirty_db.emplace((obj_ver_id){
.oid = op->oid,
.version = op->version,
}, (dirty_entry){
.state = ST_IN_FLIGHT,
.flags = 0,
.location = 0,
.offset = op->offset,
.size = op->len,
});
enqueue_write(op);
}
return 0;
}

View File

@ -277,6 +277,7 @@ class blockstore
void handle_read_event(ring_data_t *data, blockstore_operation *op);
// Write
void enqueue_write(blockstore_operation *op);
int dequeue_write(blockstore_operation *op);
void handle_write_event(ring_data_t *data, blockstore_operation *op);

View File

@ -1,5 +1,42 @@
#include "blockstore.h"
void blockstore::enqueue_write(blockstore_operation *op)
{
// Assign version number
auto dirty_it = dirty_db.upper_bound((obj_ver_id){
.oid = op->oid,
.version = UINT64_MAX,
});
dirty_it--;
if (dirty_it != dirty_db.end() && dirty_it->first.oid == op->oid)
{
op->version = dirty_it->first.version + 1;
}
else
{
auto clean_it = object_db.find(op->oid);
if (clean_it != object_db.end())
{
op->version = clean_it->second.version + 1;
}
else
{
op->version = 1;
}
}
// Immediately add the operation into dirty_db, so subsequent reads could see it
dirty_db.emplace((obj_ver_id){
.oid = op->oid,
.version = op->version,
}, (dirty_entry){
.state = ST_IN_FLIGHT,
.flags = 0,
.location = 0,
.offset = op->offset,
.size = op->len,
});
}
// First step of the write algorithm: dequeue operation and submit initial write(s)
int blockstore::dequeue_write(blockstore_operation *op)
{