Allow to read specific versions

blocking-uring-test
Vitaliy Filippov 2019-11-10 13:26:56 +03:00
parent 2d0334f9b9
commit e5caffb6ac
3 changed files with 8 additions and 11 deletions

View File

@ -66,8 +66,7 @@ void blockstore::handle_event(ring_data_t *data)
else
{
struct blockstore_operation* op = (struct blockstore_operation*)data->op;
if ((op->flags & OP_TYPE_MASK) == OP_READ_DIRTY ||
(op->flags & OP_TYPE_MASK) == OP_READ)
if ((op->flags & OP_TYPE_MASK) == OP_READ)
{
handle_read_event(data, op);
}
@ -145,8 +144,7 @@ void blockstore::loop()
unsigned ring_space = io_uring_sq_space_left(ringloop->ring);
unsigned prev_sqe_pos = ringloop->ring->sq.sqe_tail;
int dequeue_op = 0;
if ((op->flags & OP_TYPE_MASK) == OP_READ_DIRTY ||
(op->flags & OP_TYPE_MASK) == OP_READ)
if ((op->flags & OP_TYPE_MASK) == OP_READ)
{
dequeue_op = dequeue_read(op);
}

View File

@ -171,11 +171,10 @@ public:
// In fact, adding a write operation must immediately result in dirty_db being populated
#define OP_READ 1
#define OP_READ_DIRTY 2
#define OP_WRITE 3
#define OP_SYNC 4
#define OP_STABLE 5
#define OP_DELETE 6
#define OP_WRITE 2
#define OP_SYNC 3
#define OP_STABLE 4
#define OP_DELETE 5
#define OP_TYPE_MASK 0x7
// Suspend operation until there are more free SQEs
@ -192,6 +191,7 @@ struct blockstore_operation
std::function<void (blockstore_operation*)> callback;
uint32_t flags;
object_id oid;
// For reads: version=0 -> last stable, version=UINT64_MAX -> last unstable, version=X -> specific version
uint64_t version;
uint32_t offset;
uint32_t len;

View File

@ -71,7 +71,6 @@ int blockstore::fulfill_read(blockstore_operation *read_op, uint32_t item_start,
int blockstore::dequeue_read(blockstore_operation *read_op)
{
// FIXME: allow to read specific version
auto clean_it = object_db.find(read_op->oid);
auto dirty_it = dirty_db.upper_bound((obj_ver_id){
.oid = read_op->oid,
@ -94,7 +93,7 @@ int blockstore::dequeue_read(blockstore_operation *read_op)
while (dirty_it->first.oid == read_op->oid)
{
dirty_entry& dirty = dirty_it->second;
if ((read_op->flags & OP_TYPE_MASK) == OP_READ_DIRTY || IS_STABLE(dirty.state))
if (IS_STABLE(dirty.state) || read_op->version >= dirty_it->first.version)
{
if (!fulfill_read(read_op, dirty.offset, dirty.offset + dirty.size,
dirty.state, dirty_it->first.version, dirty.location))