Move enqueue_write to _write.cpp
parent
e5caffb6ac
commit
64185f7a1f
|
@ -256,39 +256,7 @@ int blockstore::enqueue_op(blockstore_operation *op)
|
||||||
submit_queue.push_back(op);
|
submit_queue.push_back(op);
|
||||||
if ((op->flags & OP_TYPE_MASK) == OP_WRITE)
|
if ((op->flags & OP_TYPE_MASK) == OP_WRITE)
|
||||||
{
|
{
|
||||||
// Assign version number
|
enqueue_write(op);
|
||||||
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,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -277,6 +277,7 @@ class blockstore
|
||||||
void handle_read_event(ring_data_t *data, blockstore_operation *op);
|
void handle_read_event(ring_data_t *data, blockstore_operation *op);
|
||||||
|
|
||||||
// Write
|
// Write
|
||||||
|
void enqueue_write(blockstore_operation *op);
|
||||||
int dequeue_write(blockstore_operation *op);
|
int dequeue_write(blockstore_operation *op);
|
||||||
void handle_write_event(ring_data_t *data, blockstore_operation *op);
|
void handle_write_event(ring_data_t *data, blockstore_operation *op);
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,42 @@
|
||||||
#include "blockstore.h"
|
#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)
|
// First step of the write algorithm: dequeue operation and submit initial write(s)
|
||||||
int blockstore::dequeue_write(blockstore_operation *op)
|
int blockstore::dequeue_write(blockstore_operation *op)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue