From 749ab6e2c60ea51016b8745215b9eaf3537b52f3 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Sun, 15 Dec 2019 14:11:03 +0300 Subject: [PATCH] Rename blockstore_operation to blockstore_op_t --- blockstore.cpp | 8 +++---- blockstore.h | 49 ++++++++++++++++++++---------------------- blockstore_journal.cpp | 2 +- blockstore_journal.h | 2 +- blockstore_read.cpp | 8 +++---- blockstore_stable.cpp | 4 ++-- blockstore_sync.cpp | 10 ++++----- blockstore_write.cpp | 8 +++---- fio_engine.cpp | 10 ++++----- osd.cpp | 2 +- osd.h | 5 ++++- test_blockstore.cpp | 4 ++-- 12 files changed, 56 insertions(+), 56 deletions(-) diff --git a/blockstore.cpp b/blockstore.cpp index 0e760f0e..f08ea7dd 100644 --- a/blockstore.cpp +++ b/blockstore.cpp @@ -205,10 +205,10 @@ bool blockstore::is_safe_to_stop() if (!readonly && !stop_sync_submitted) { // We should sync the blockstore before unmounting - blockstore_operation *op = new blockstore_operation; + blockstore_op_t *op = new blockstore_op_t; op->flags = OP_SYNC; op->buf = NULL; - op->callback = [](blockstore_operation *op) + op->callback = [](blockstore_op_t *op) { delete op; }; @@ -220,7 +220,7 @@ bool blockstore::is_safe_to_stop() return true; } -void blockstore::check_wait(blockstore_operation *op) +void blockstore::check_wait(blockstore_op_t *op) { if (op->wait_for == WAIT_SQE) { @@ -276,7 +276,7 @@ void blockstore::check_wait(blockstore_operation *op) } } -void blockstore::enqueue_op(blockstore_operation *op) +void blockstore::enqueue_op(blockstore_op_t *op) { int type = op->flags & OP_TYPE_MASK; if (type < OP_READ || type > OP_DELETE || (type == OP_READ || type == OP_WRITE) && diff --git a/blockstore.h b/blockstore.h index 0adc19d0..d5d509ef 100644 --- a/blockstore.h +++ b/blockstore.h @@ -64,9 +64,6 @@ #define MAX_BLOCK_SIZE 128*1024*1024 #define DISK_ALIGNMENT 512 -#define STRIPE_NUM(oid) ((oid) >> 4) -#define STRIPE_REPLICA(oid) ((oid) & 0xf) - #define BS_SUBMIT_GET_SQE(sqe, data) \ BS_SUBMIT_GET_ONLY_SQE(sqe); \ struct ring_data_t *data = ((ring_data_t*)sqe->user_data) @@ -91,7 +88,7 @@ class blockstore; -class blockstore_operation; +class blockstore_op_t; // 16 bytes per object/stripe id // stripe includes replica number in 4 least significant bits @@ -207,12 +204,12 @@ struct fulfill_read_t uint64_t offset, len; }; -struct blockstore_operation +struct blockstore_op_t { // flags contain operation type and possibly other flags uint64_t flags; // finish callback - std::function callback; + std::function callback; // For reads, writes & deletes: oid is the requested object object_id oid; // For reads: version=0 -> last stable, version=UINT64_MAX -> last unstable, version=X -> specific version @@ -246,7 +243,7 @@ private: // Sync std::vector sync_big_writes, sync_small_writes; - std::list::iterator in_progress_ptr; + std::list::iterator in_progress_ptr; int sync_state, prev_sync_count; }; @@ -263,9 +260,9 @@ class blockstore // Another option is https://github.com/algorithm-ninja/cpp-btree spp::sparse_hash_map clean_db; std::map dirty_db; - std::list submit_queue; // FIXME: funny thing is that vector is better here + std::list submit_queue; // FIXME: funny thing is that vector is better here std::vector unsynced_big_writes, unsynced_small_writes; - std::list in_progress_syncs; // ...and probably here, too + std::list in_progress_syncs; // ...and probably here, too allocator *data_alloc = NULL; uint8_t *zero_object; @@ -313,32 +310,32 @@ class blockstore blockstore_init_meta* metadata_init_reader; blockstore_init_journal* journal_init_reader; - void check_wait(blockstore_operation *op); + void check_wait(blockstore_op_t *op); // Read - int dequeue_read(blockstore_operation *read_op); - int fulfill_read(blockstore_operation *read_op, uint64_t &fulfilled, uint32_t item_start, uint32_t item_end, + int dequeue_read(blockstore_op_t *read_op); + int fulfill_read(blockstore_op_t *read_op, uint64_t &fulfilled, uint32_t item_start, uint32_t item_end, uint32_t item_state, uint64_t item_version, uint64_t item_location); - int fulfill_read_push(blockstore_operation *op, void *buf, uint64_t offset, uint64_t len, + int fulfill_read_push(blockstore_op_t *op, void *buf, uint64_t offset, uint64_t len, uint32_t item_state, uint64_t item_version); - void handle_read_event(ring_data_t *data, blockstore_operation *op); + void handle_read_event(ring_data_t *data, blockstore_op_t *op); // Write - void enqueue_write(blockstore_operation *op); - int dequeue_write(blockstore_operation *op); - int dequeue_del(blockstore_operation *op); - void handle_write_event(ring_data_t *data, blockstore_operation *op); + void enqueue_write(blockstore_op_t *op); + int dequeue_write(blockstore_op_t *op); + int dequeue_del(blockstore_op_t *op); + void handle_write_event(ring_data_t *data, blockstore_op_t *op); // Sync - int dequeue_sync(blockstore_operation *op); - void handle_sync_event(ring_data_t *data, blockstore_operation *op); - int continue_sync(blockstore_operation *op); - void ack_one_sync(blockstore_operation *op); - int ack_sync(blockstore_operation *op); + int dequeue_sync(blockstore_op_t *op); + void handle_sync_event(ring_data_t *data, blockstore_op_t *op); + int continue_sync(blockstore_op_t *op); + void ack_one_sync(blockstore_op_t *op); + int ack_sync(blockstore_op_t *op); // Stabilize - int dequeue_stable(blockstore_operation *op); - void handle_stable_event(ring_data_t *data, blockstore_operation *op); + int dequeue_stable(blockstore_op_t *op); + void handle_stable_event(ring_data_t *data, blockstore_op_t *op); void stabilize_object(object_id oid, uint64_t max_ver); public: @@ -359,7 +356,7 @@ public: bool is_safe_to_stop(); // Submission - void enqueue_op(blockstore_operation *op); + void enqueue_op(blockstore_op_t *op); // Unstable writes are added here (map of object_id -> version) std::map unstable_writes; diff --git a/blockstore_journal.cpp b/blockstore_journal.cpp index 6d6f6654..9df489ec 100644 --- a/blockstore_journal.cpp +++ b/blockstore_journal.cpp @@ -11,7 +11,7 @@ blockstore_journal_check_t::blockstore_journal_check_t(blockstore *bs) } // Check if we can write entries of bytes and data bytes after them to the journal -int blockstore_journal_check_t::check_available(blockstore_operation *op, int required, int size, int data_after) +int blockstore_journal_check_t::check_available(blockstore_op_t *op, int required, int size, int data_after) { while (1) { diff --git a/blockstore_journal.h b/blockstore_journal.h index 7e2d82c4..2d7557cb 100644 --- a/blockstore_journal.h +++ b/blockstore_journal.h @@ -144,7 +144,7 @@ struct blockstore_journal_check_t bool right_dir; // writing to the end or the beginning of the ring buffer blockstore_journal_check_t(blockstore *bs); - int check_available(blockstore_operation *op, int required, int size, int data_after); + int check_available(blockstore_op_t *op, int required, int size, int data_after); }; journal_entry* prefill_single_journal_entry(journal_t & journal, uint16_t type, uint32_t size); diff --git a/blockstore_read.cpp b/blockstore_read.cpp index 0002f3b2..9d9df07c 100644 --- a/blockstore_read.cpp +++ b/blockstore_read.cpp @@ -1,6 +1,6 @@ #include "blockstore.h" -int blockstore::fulfill_read_push(blockstore_operation *op, void *buf, uint64_t offset, uint64_t len, +int blockstore::fulfill_read_push(blockstore_op_t *op, void *buf, uint64_t offset, uint64_t len, uint32_t item_state, uint64_t item_version) { if (IS_IN_FLIGHT(item_state)) @@ -34,7 +34,7 @@ int blockstore::fulfill_read_push(blockstore_operation *op, void *buf, uint64_t return 1; } -int blockstore::fulfill_read(blockstore_operation *read_op, uint64_t &fulfilled, uint32_t item_start, uint32_t item_end, +int blockstore::fulfill_read(blockstore_op_t *read_op, uint64_t &fulfilled, uint32_t item_start, uint32_t item_end, uint32_t item_state, uint64_t item_version, uint64_t item_location) { uint32_t cur_start = item_start; @@ -69,7 +69,7 @@ int blockstore::fulfill_read(blockstore_operation *read_op, uint64_t &fulfilled, return 1; } -int blockstore::dequeue_read(blockstore_operation *read_op) +int blockstore::dequeue_read(blockstore_op_t *read_op) { auto clean_it = clean_db.find(read_op->oid); auto dirty_it = dirty_db.upper_bound((obj_ver_id){ @@ -148,7 +148,7 @@ int blockstore::dequeue_read(blockstore_operation *read_op) return 1; } -void blockstore::handle_read_event(ring_data_t *data, blockstore_operation *op) +void blockstore::handle_read_event(ring_data_t *data, blockstore_op_t *op) { op->pending_ops--; if (data->res != data->iov.iov_len) diff --git a/blockstore_stable.cpp b/blockstore_stable.cpp index 7d53830f..6fa7186f 100644 --- a/blockstore_stable.cpp +++ b/blockstore_stable.cpp @@ -38,7 +38,7 @@ // 4) after a while it takes his synced object list and sends stabilize requests // to peers and to its own blockstore, thus freeing the old version -int blockstore::dequeue_stable(blockstore_operation *op) +int blockstore::dequeue_stable(blockstore_op_t *op) { obj_ver_id* v; int i, todo = 0; @@ -121,7 +121,7 @@ int blockstore::dequeue_stable(blockstore_operation *op) return 1; } -void blockstore::handle_stable_event(ring_data_t *data, blockstore_operation *op) +void blockstore::handle_stable_event(ring_data_t *data, blockstore_op_t *op) { if (data->res != data->iov.iov_len) { diff --git a/blockstore_sync.cpp b/blockstore_sync.cpp index 6dd52f68..9c68cccc 100644 --- a/blockstore_sync.cpp +++ b/blockstore_sync.cpp @@ -7,7 +7,7 @@ #define SYNC_JOURNAL_SYNC_SENT 5 #define SYNC_DONE 6 -int blockstore::dequeue_sync(blockstore_operation *op) +int blockstore::dequeue_sync(blockstore_op_t *op) { if (op->sync_state == 0) { @@ -33,7 +33,7 @@ int blockstore::dequeue_sync(blockstore_operation *op) return r; } -int blockstore::continue_sync(blockstore_operation *op) +int blockstore::continue_sync(blockstore_op_t *op) { auto cb = [this, op](ring_data_t *data) { handle_sync_event(data, op); }; if (op->sync_state == SYNC_HAS_SMALL) @@ -131,7 +131,7 @@ int blockstore::continue_sync(blockstore_operation *op) return 1; } -void blockstore::handle_sync_event(ring_data_t *data, blockstore_operation *op) +void blockstore::handle_sync_event(ring_data_t *data, blockstore_op_t *op) { if (data->res != data->iov.iov_len) { @@ -173,7 +173,7 @@ void blockstore::handle_sync_event(ring_data_t *data, blockstore_operation *op) } } -int blockstore::ack_sync(blockstore_operation *op) +int blockstore::ack_sync(blockstore_op_t *op) { if (op->sync_state == SYNC_DONE && op->prev_sync_count == 0) { @@ -199,7 +199,7 @@ int blockstore::ack_sync(blockstore_operation *op) return 0; } -void blockstore::ack_one_sync(blockstore_operation *op) +void blockstore::ack_one_sync(blockstore_op_t *op) { // Handle states for (auto it = op->sync_big_writes.begin(); it != op->sync_big_writes.end(); it++) diff --git a/blockstore_write.cpp b/blockstore_write.cpp index 7c5e09eb..4cda85b2 100644 --- a/blockstore_write.cpp +++ b/blockstore_write.cpp @@ -1,6 +1,6 @@ #include "blockstore.h" -void blockstore::enqueue_write(blockstore_operation *op) +void blockstore::enqueue_write(blockstore_op_t *op) { // Assign version number bool found = false, deleted = false, is_del = (op->flags & OP_TYPE_MASK) == OP_DELETE; @@ -60,7 +60,7 @@ void blockstore::enqueue_write(blockstore_operation *op) } // 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_op_t *op) { auto dirty_it = dirty_db.find((obj_ver_id){ .oid = op->oid, @@ -184,7 +184,7 @@ int blockstore::dequeue_write(blockstore_operation *op) return 1; } -void blockstore::handle_write_event(ring_data_t *data, blockstore_operation *op) +void blockstore::handle_write_event(ring_data_t *data, blockstore_op_t *op) { if (data->res != data->iov.iov_len) { @@ -236,7 +236,7 @@ void blockstore::handle_write_event(ring_data_t *data, blockstore_operation *op) } } -int blockstore::dequeue_del(blockstore_operation *op) +int blockstore::dequeue_del(blockstore_op_t *op) { auto dirty_it = dirty_db.find((obj_ver_id){ .oid = op->oid, diff --git a/fio_engine.cpp b/fio_engine.cpp index 68eea94a..a015a275 100644 --- a/fio_engine.cpp +++ b/fio_engine.cpp @@ -180,7 +180,7 @@ static enum fio_q_status bs_queue(struct thread_data *td, struct io_u *io) if (io->ddir == DDIR_WRITE || io->ddir == DDIR_READ) assert(io->xfer_buflen <= bsd->bs->get_block_size()); - blockstore_operation *op = new blockstore_operation; + blockstore_op_t *op = new blockstore_op_t; op->callback = NULL; switch (io->ddir) @@ -194,7 +194,7 @@ static enum fio_q_status bs_queue(struct thread_data *td, struct io_u *io) }; op->offset = io->offset % bsd->bs->get_block_size(); op->len = io->xfer_buflen; - op->callback = [io, n](blockstore_operation *op) + op->callback = [io, n](blockstore_op_t *op) { io->error = op->retval < 0 ? -op->retval : 0; bs_data *bsd = (bs_data*)io->engine_data; @@ -215,7 +215,7 @@ static enum fio_q_status bs_queue(struct thread_data *td, struct io_u *io) }; op->offset = io->offset % bsd->bs->get_block_size(); op->len = io->xfer_buflen; - op->callback = [io, n](blockstore_operation *op) + op->callback = [io, n](blockstore_op_t *op) { io->error = op->retval < 0 ? -op->retval : 0; bs_data *bsd = (bs_data*)io->engine_data; @@ -229,7 +229,7 @@ static enum fio_q_status bs_queue(struct thread_data *td, struct io_u *io) break; case DDIR_SYNC: op->flags = OP_SYNC; - op->callback = [io, n](blockstore_operation *op) + op->callback = [io, n](blockstore_op_t *op) { bs_data *bsd = (bs_data*)io->engine_data; if (op->retval >= 0 && bsd->bs->unstable_writes.size() > 0) @@ -247,7 +247,7 @@ static enum fio_q_status bs_queue(struct thread_data *td, struct io_u *io) }; } bsd->bs->unstable_writes.clear(); - op->callback = [io, n](blockstore_operation *op) + op->callback = [io, n](blockstore_op_t *op) { io->error = op->retval < 0 ? -op->retval : 0; bs_data *bsd = (bs_data*)io->engine_data; diff --git a/osd.cpp b/osd.cpp index 162844ec..02b03a72 100644 --- a/osd.cpp +++ b/osd.cpp @@ -309,7 +309,7 @@ void osd_t::handle_read(ring_data_t *data, int peer_fd) void osd_t::enqueue_op(osd_op_t *cur_op) { - cur_op->bs_op.callback = [this, cur_op](blockstore_operation* bs_op) + cur_op->bs_op.callback = [this, cur_op](blockstore_op_t* bs_op) { auto cl_it = clients.find(cur_op->peer_fd); if (cl_it != clients.end()) diff --git a/osd.h b/osd.h index 880be859..8fc43602 100644 --- a/osd.h +++ b/osd.h @@ -7,6 +7,9 @@ #include "ringloop.h" #include "osd_ops.h" +#define STRIPE_NUM(stripe) ((stripe) >> 4) +#define STRIPE_REPLICA(stripe) ((stripe) & 0xf) + struct osd_op_t { int peer_fd; @@ -20,7 +23,7 @@ struct osd_op_t osd_any_reply_t reply; uint8_t reply_buf[OSD_REPLY_PACKET_SIZE] = { 0 }; }; - blockstore_operation bs_op; + blockstore_op_t bs_op; void *buf = NULL; ~osd_op_t() diff --git a/test_blockstore.cpp b/test_blockstore.cpp index cb2687d3..a7ad8852 100644 --- a/test_blockstore.cpp +++ b/test_blockstore.cpp @@ -15,11 +15,11 @@ int main(int narg, char *args[]) printf("tick 1s\n"); }); - blockstore_operation op; + blockstore_op_t op; int main_state = 0; uint64_t version = 0; ring_consumer_t main_cons; - op.callback = [&](blockstore_operation *op) + op.callback = [&](blockstore_op_t *op) { printf("op completed %d\n", op->retval); if (main_state == 1)