From 4a52a15564c185a2694d5ff7e7c0779e55c5f269 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Sun, 23 Feb 2020 19:03:06 +0300 Subject: [PATCH] Rename osd_op_t.op to req --- osd.cpp | 24 ++++++------ osd.h | 2 +- osd_client.cpp | 12 +++--- osd_exec_secondary.cpp | 84 +++++++++++++++++++++--------------------- osd_peering.cpp | 2 +- osd_primary.cpp | 28 +++++++------- osd_receive.cpp | 66 ++++++++++++++++----------------- osd_send.cpp | 4 +- 8 files changed, 111 insertions(+), 111 deletions(-) diff --git a/osd.cpp b/osd.cpp index c722e5a4a..799772de5 100644 --- a/osd.cpp +++ b/osd.cpp @@ -99,7 +99,7 @@ osd_op_t::~osd_op_t() // Note: reusing osd_op_t WILL currently lead to memory leaks // So we don't reuse it, but free it every time if (op_type == OSD_OP_IN && - op.hdr.opcode == OSD_OP_SHOW_CONFIG) + req.hdr.opcode == OSD_OP_SHOW_CONFIG) { std::string *str = (std::string*)buf; delete str; @@ -245,8 +245,8 @@ void osd_t::cancel_osd_ops(osd_client_t & cl) void osd_t::cancel_op(osd_op_t *op) { op->reply.hdr.magic = SECONDARY_OSD_REPLY_MAGIC; - op->reply.hdr.id = op->op.hdr.id; - op->reply.hdr.opcode = op->op.hdr.opcode; + op->reply.hdr.id = op->req.hdr.id; + op->reply.hdr.opcode = op->req.hdr.opcode; op->reply.hdr.retval = -EPIPE; op->callback(op); } @@ -304,30 +304,30 @@ void osd_t::exec_op(osd_op_t *cur_op) return; } inflight_ops++; - if (cur_op->op.hdr.magic != SECONDARY_OSD_OP_MAGIC || - cur_op->op.hdr.opcode < OSD_OP_MIN || cur_op->op.hdr.opcode > OSD_OP_MAX || - (cur_op->op.hdr.opcode == OSD_OP_SECONDARY_READ || cur_op->op.hdr.opcode == OSD_OP_SECONDARY_WRITE || - cur_op->op.hdr.opcode == OSD_OP_READ || cur_op->op.hdr.opcode == OSD_OP_WRITE) && - (cur_op->op.sec_rw.len > OSD_RW_MAX || cur_op->op.sec_rw.len % OSD_RW_ALIGN || cur_op->op.sec_rw.offset % OSD_RW_ALIGN)) + if (cur_op->req.hdr.magic != SECONDARY_OSD_OP_MAGIC || + cur_op->req.hdr.opcode < OSD_OP_MIN || cur_op->req.hdr.opcode > OSD_OP_MAX || + (cur_op->req.hdr.opcode == OSD_OP_SECONDARY_READ || cur_op->req.hdr.opcode == OSD_OP_SECONDARY_WRITE || + cur_op->req.hdr.opcode == OSD_OP_READ || cur_op->req.hdr.opcode == OSD_OP_WRITE) && + (cur_op->req.sec_rw.len > OSD_RW_MAX || cur_op->req.sec_rw.len % OSD_RW_ALIGN || cur_op->req.sec_rw.offset % OSD_RW_ALIGN)) { // Bad command cur_op->bs_op.retval = -EINVAL; secondary_op_callback(cur_op); return; } - if (cur_op->op.hdr.opcode == OSD_OP_TEST_SYNC_STAB_ALL) + if (cur_op->req.hdr.opcode == OSD_OP_TEST_SYNC_STAB_ALL) { exec_sync_stab_all(cur_op); } - else if (cur_op->op.hdr.opcode == OSD_OP_SHOW_CONFIG) + else if (cur_op->req.hdr.opcode == OSD_OP_SHOW_CONFIG) { exec_show_config(cur_op); } - else if (cur_op->op.hdr.opcode == OSD_OP_READ) + else if (cur_op->req.hdr.opcode == OSD_OP_READ) { exec_primary_read(cur_op); } - else if (cur_op->op.hdr.opcode == OSD_OP_WRITE) + else if (cur_op->req.hdr.opcode == OSD_OP_WRITE) { exec_primary_write(cur_op); } diff --git a/osd.h b/osd.h index 5c2f6c44f..2b772a6e1 100644 --- a/osd.h +++ b/osd.h @@ -98,7 +98,7 @@ struct osd_op_t { int op_type; int peer_fd; - osd_any_op_t op; + osd_any_op_t req; osd_any_reply_t reply; blockstore_op_t bs_op; void *buf = NULL; diff --git a/osd_client.cpp b/osd_client.cpp index 6ea07f17d..c53b13061 100644 --- a/osd_client.cpp +++ b/osd_client.cpp @@ -4,18 +4,18 @@ void slice() // Primary OSD still operates individual stripes, except they're twice the size of the blockstore's stripe. std::vector read_parts; int block = bs->get_block_size(); - uint64_t stripe1 = cur_op->op.rw.offset / block / 2; - uint64_t stripe2 = (cur_op->op.rw.offset + cur_op->op.rw.len + block*2 - 1) / block / 2 - 1; + uint64_t stripe1 = cur_op->req.rw.offset / block / 2; + uint64_t stripe2 = (cur_op->req.rw.offset + cur_op->req.rw.len + block*2 - 1) / block / 2 - 1; for (uint64_t s = stripe1; s <= stripe2; s++) { - uint64_t start = s == stripe1 ? cur_op->op.rw.offset - stripe1*block*2 : 0; - uint64_t end = s == stripe2 ? cur_op->op.rw.offset + cur_op->op.rw.len - stripe2*block*2 : block*2; + uint64_t start = s == stripe1 ? cur_op->req.rw.offset - stripe1*block*2 : 0; + uint64_t end = s == stripe2 ? cur_op->req.rw.offset + cur_op->req.rw.len - stripe2*block*2 : block*2; if (start < block) { read_parts.push_back({ .role = 1, .oid = { - .inode = cur_op->op.rw.inode, + .inode = cur_op->req.rw.inode, .stripe = (s << STRIPE_ROLE_BITS) | 1, }, .version = UINT64_MAX, @@ -28,7 +28,7 @@ void slice() read_parts.push_back({ .role = 2, .oid = { - .inode = cur_op->op.rw.inode, + .inode = cur_op->req.rw.inode, .stripe = (s << STRIPE_ROLE_BITS) | 2, }, .version = UINT64_MAX, diff --git a/osd_exec_secondary.cpp b/osd_exec_secondary.cpp index e4cf48ac2..f1e883a70 100644 --- a/osd_exec_secondary.cpp +++ b/osd_exec_secondary.cpp @@ -21,46 +21,46 @@ void osd_t::secondary_op_callback(osd_op_t *cur_op) void osd_t::exec_secondary(osd_op_t *cur_op) { cur_op->bs_op.callback = [this, cur_op](blockstore_op_t* bs_op) { secondary_op_callback(cur_op); }; - cur_op->bs_op.opcode = (cur_op->op.hdr.opcode == OSD_OP_SECONDARY_READ ? BS_OP_READ - : (cur_op->op.hdr.opcode == OSD_OP_SECONDARY_WRITE ? BS_OP_WRITE - : (cur_op->op.hdr.opcode == OSD_OP_SECONDARY_SYNC ? BS_OP_SYNC - : (cur_op->op.hdr.opcode == OSD_OP_SECONDARY_STABILIZE ? BS_OP_STABLE - : (cur_op->op.hdr.opcode == OSD_OP_SECONDARY_ROLLBACK ? BS_OP_ROLLBACK - : (cur_op->op.hdr.opcode == OSD_OP_SECONDARY_DELETE ? BS_OP_DELETE - : (cur_op->op.hdr.opcode == OSD_OP_SECONDARY_LIST ? BS_OP_LIST + cur_op->bs_op.opcode = (cur_op->req.hdr.opcode == OSD_OP_SECONDARY_READ ? BS_OP_READ + : (cur_op->req.hdr.opcode == OSD_OP_SECONDARY_WRITE ? BS_OP_WRITE + : (cur_op->req.hdr.opcode == OSD_OP_SECONDARY_SYNC ? BS_OP_SYNC + : (cur_op->req.hdr.opcode == OSD_OP_SECONDARY_STABILIZE ? BS_OP_STABLE + : (cur_op->req.hdr.opcode == OSD_OP_SECONDARY_ROLLBACK ? BS_OP_ROLLBACK + : (cur_op->req.hdr.opcode == OSD_OP_SECONDARY_DELETE ? BS_OP_DELETE + : (cur_op->req.hdr.opcode == OSD_OP_SECONDARY_LIST ? BS_OP_LIST : -1))))))); - if (cur_op->op.hdr.opcode == OSD_OP_SECONDARY_READ || - cur_op->op.hdr.opcode == OSD_OP_SECONDARY_WRITE) + if (cur_op->req.hdr.opcode == OSD_OP_SECONDARY_READ || + cur_op->req.hdr.opcode == OSD_OP_SECONDARY_WRITE) { - cur_op->bs_op.oid = cur_op->op.sec_rw.oid; - cur_op->bs_op.version = cur_op->op.sec_rw.version; - cur_op->bs_op.offset = cur_op->op.sec_rw.offset; - cur_op->bs_op.len = cur_op->op.sec_rw.len; + cur_op->bs_op.oid = cur_op->req.sec_rw.oid; + cur_op->bs_op.version = cur_op->req.sec_rw.version; + cur_op->bs_op.offset = cur_op->req.sec_rw.offset; + cur_op->bs_op.len = cur_op->req.sec_rw.len; cur_op->bs_op.buf = cur_op->buf; } - else if (cur_op->op.hdr.opcode == OSD_OP_SECONDARY_DELETE) + else if (cur_op->req.hdr.opcode == OSD_OP_SECONDARY_DELETE) { - cur_op->bs_op.oid = cur_op->op.sec_del.oid; - cur_op->bs_op.version = cur_op->op.sec_del.version; + cur_op->bs_op.oid = cur_op->req.sec_del.oid; + cur_op->bs_op.version = cur_op->req.sec_del.version; } - else if (cur_op->op.hdr.opcode == OSD_OP_SECONDARY_STABILIZE || - cur_op->op.hdr.opcode == OSD_OP_SECONDARY_ROLLBACK) + else if (cur_op->req.hdr.opcode == OSD_OP_SECONDARY_STABILIZE || + cur_op->req.hdr.opcode == OSD_OP_SECONDARY_ROLLBACK) { - cur_op->bs_op.len = cur_op->op.sec_stab.len/sizeof(obj_ver_id); + cur_op->bs_op.len = cur_op->req.sec_stab.len/sizeof(obj_ver_id); cur_op->bs_op.buf = cur_op->buf; } - else if (cur_op->op.hdr.opcode == OSD_OP_SECONDARY_LIST) + else if (cur_op->req.hdr.opcode == OSD_OP_SECONDARY_LIST) { - if (cur_op->op.sec_list.pg_count < cur_op->op.sec_list.list_pg) + if (cur_op->req.sec_list.pg_count < cur_op->req.sec_list.list_pg) { // requested pg number is greater than total pg count cur_op->bs_op.retval = -EINVAL; secondary_op_callback(cur_op); return; } - cur_op->bs_op.oid.stripe = cur_op->op.sec_list.parity_block_size; - cur_op->bs_op.len = cur_op->op.sec_list.pg_count; - cur_op->bs_op.offset = cur_op->op.sec_list.list_pg - 1; + cur_op->bs_op.oid.stripe = cur_op->req.sec_list.parity_block_size; + cur_op->bs_op.len = cur_op->req.sec_list.pg_count; + cur_op->bs_op.offset = cur_op->req.sec_list.list_pg - 1; } #ifdef OSD_STUB cur_op->bs_op.retval = cur_op->bs_op.len; @@ -92,15 +92,15 @@ void osd_t::exec_sync_stab_all(osd_op_t *cur_op) return; } cur_op->bs_op.opcode = BS_OP_SYNC; - cur_op->bs_op.callback = [this, cur_op](blockstore_op_t *op) + cur_op->bs_op.callback = [this, cur_op](blockstore_op_t *bs_op) { auto & unstable_writes = bs->get_unstable_writes(); - if (op->retval >= 0 && unstable_writes.size() > 0) + if (bs_op->retval >= 0 && unstable_writes.size() > 0) { - op->opcode = BS_OP_STABLE; - op->len = unstable_writes.size(); - obj_ver_id *vers = new obj_ver_id[op->len]; - op->buf = vers; + bs_op->opcode = BS_OP_STABLE; + bs_op->len = unstable_writes.size(); + obj_ver_id *vers = new obj_ver_id[bs_op->len]; + bs_op->buf = vers; int i = 0; for (auto it = unstable_writes.begin(); it != unstable_writes.end(); it++, i++) { @@ -110,13 +110,13 @@ void osd_t::exec_sync_stab_all(osd_op_t *cur_op) }; } unstable_writes.clear(); - op->callback = [this, cur_op](blockstore_op_t *op) + bs_op->callback = [this, cur_op](blockstore_op_t *bs_op) { secondary_op_callback(cur_op); - obj_ver_id *vers = (obj_ver_id*)op->buf; + obj_ver_id *vers = (obj_ver_id*)bs_op->buf; delete[] vers; }; - bs->enqueue_op(op); + bs->enqueue_op(bs_op); } else { @@ -134,9 +134,9 @@ void osd_t::exec_sync_stab_all(osd_op_t *cur_op) void osd_t::make_reply(osd_op_t *op) { op->reply.hdr.magic = SECONDARY_OSD_REPLY_MAGIC; - op->reply.hdr.id = op->op.hdr.id; - op->reply.hdr.opcode = op->op.hdr.opcode; - if (op->op.hdr.opcode == OSD_OP_SHOW_CONFIG) + op->reply.hdr.id = op->req.hdr.id; + op->reply.hdr.opcode = op->req.hdr.opcode; + if (op->req.hdr.opcode == OSD_OP_SHOW_CONFIG) { std::string *str = (std::string*)op->buf; op->reply.hdr.retval = str->size()+1; @@ -145,20 +145,20 @@ void osd_t::make_reply(osd_op_t *op) else { op->reply.hdr.retval = op->bs_op.retval; - if (op->op.hdr.opcode == OSD_OP_SECONDARY_LIST) + if (op->req.hdr.opcode == OSD_OP_SECONDARY_LIST) op->reply.sec_list.stable_count = op->bs_op.version; - else if (op->op.hdr.opcode == OSD_OP_SECONDARY_READ || - op->op.hdr.opcode == OSD_OP_SECONDARY_WRITE) + else if (op->req.hdr.opcode == OSD_OP_SECONDARY_READ || + op->req.hdr.opcode == OSD_OP_SECONDARY_WRITE) op->reply.sec_rw.version = op->bs_op.version; - else if (op->op.hdr.opcode == OSD_OP_SECONDARY_DELETE) + else if (op->req.hdr.opcode == OSD_OP_SECONDARY_DELETE) op->reply.sec_del.version = op->bs_op.version; } - if (op->op.hdr.opcode == OSD_OP_SECONDARY_READ && + if (op->req.hdr.opcode == OSD_OP_SECONDARY_READ && op->reply.hdr.retval > 0) { op->send_list.push_back(op->buf, op->reply.hdr.retval); } - else if (op->op.hdr.opcode == OSD_OP_SECONDARY_LIST && + else if (op->req.hdr.opcode == OSD_OP_SECONDARY_LIST && op->reply.hdr.retval > 0) { op->buf = op->bs_op.buf; // allocated by blockstore diff --git a/osd_peering.cpp b/osd_peering.cpp index b5e8c7803..579dfaf82 100644 --- a/osd_peering.cpp +++ b/osd_peering.cpp @@ -348,7 +348,7 @@ void osd_t::start_pg_peering(int pg_idx) osd_op_t *op = new osd_op_t(); op->op_type = OSD_OP_OUT; op->peer_fd = cl.peer_fd; - op->op = { + op->req = { .sec_list = { .header = { .magic = SECONDARY_OSD_OP_MAGIC, diff --git a/osd_primary.cpp b/osd_primary.cpp index 3471e8198..0a992bc66 100644 --- a/osd_primary.cpp +++ b/osd_primary.cpp @@ -28,8 +28,8 @@ void osd_t::finish_primary_op(osd_op_t *cur_op, int retval) { // FIXME add separate magics cur_op->reply.hdr.magic = SECONDARY_OSD_REPLY_MAGIC; - cur_op->reply.hdr.id = cur_op->op.hdr.id; - cur_op->reply.hdr.opcode = cur_op->op.hdr.opcode; + cur_op->reply.hdr.id = cur_op->req.hdr.id; + cur_op->reply.hdr.opcode = cur_op->req.hdr.opcode; cur_op->reply.hdr.retval = retval; outbox_push(this->clients[cur_op->peer_fd], cur_op); } @@ -41,7 +41,7 @@ bool osd_t::prepare_primary_rw(osd_op_t *cur_op) // But we must not use K in the process of calculating the PG number // So we calculate the PG number using a separate setting which should be per-inode (FIXME) // FIXME Real pg_num should equal the below expression + 1 - pg_num_t pg_num = (cur_op->op.rw.inode + cur_op->op.rw.offset / parity_block_size) % pg_count; + pg_num_t pg_num = (cur_op->req.rw.inode + cur_op->req.rw.offset / parity_block_size) % pg_count; // FIXME: Postpone operations in inactive PGs if (pg_num > pgs.size() || !(pgs[pg_num].state & PG_ACTIVE)) { @@ -50,14 +50,14 @@ bool osd_t::prepare_primary_rw(osd_op_t *cur_op) } uint64_t pg_parity_size = bs_block_size * pgs[pg_num].pg_minsize; object_id oid = { - .inode = cur_op->op.rw.inode, + .inode = cur_op->req.rw.inode, // oid.stripe = starting offset of the parity stripe, so it can be mapped back to the PG - .stripe = (cur_op->op.rw.offset / parity_block_size) * parity_block_size + - ((cur_op->op.rw.offset % parity_block_size) / pg_parity_size) * pg_parity_size + .stripe = (cur_op->req.rw.offset / parity_block_size) * parity_block_size + + ((cur_op->req.rw.offset % parity_block_size) / pg_parity_size) * pg_parity_size }; - if ((cur_op->op.rw.offset + cur_op->op.rw.len) > (oid.stripe + pg_parity_size) || - (cur_op->op.rw.offset % bs_disk_alignment) != 0 || - (cur_op->op.rw.len % bs_disk_alignment) != 0) + if ((cur_op->req.rw.offset + cur_op->req.rw.len) > (oid.stripe + pg_parity_size) || + (cur_op->req.rw.offset % bs_disk_alignment) != 0 || + (cur_op->req.rw.len % bs_disk_alignment) != 0) { finish_primary_op(cur_op, -EINVAL); return false; @@ -69,7 +69,7 @@ bool osd_t::prepare_primary_rw(osd_op_t *cur_op) op_data->oid = oid; op_data->stripes = ((osd_read_stripe_t*)(op_data+1)); cur_op->op_data = op_data; - split_stripes(pgs[pg_num].pg_minsize, bs_block_size, (uint32_t)(cur_op->op.rw.offset - oid.stripe), cur_op->op.rw.len, op_data->stripes); + split_stripes(pgs[pg_num].pg_minsize, bs_block_size, (uint32_t)(cur_op->req.rw.offset - oid.stripe), cur_op->req.rw.len, op_data->stripes); return true; } @@ -94,7 +94,7 @@ void osd_t::exec_primary_read(osd_op_t *cur_op) // Fast happy-path cur_op->buf = alloc_read_buffer(op_data->stripes, pg.pg_minsize, 0); submit_read_subops(pg.pg_minsize, pg.cur_set.data(), cur_op); - cur_op->send_list.push_back(cur_op->buf, cur_op->op.rw.len); + cur_op->send_list.push_back(cur_op->buf, cur_op->req.rw.len); } else { @@ -158,7 +158,7 @@ void osd_t::handle_primary_read_subop(osd_op_t *cur_op, int ok) } free(op_data); cur_op->op_data = NULL; - finish_primary_op(cur_op, cur_op->op.rw.len); + finish_primary_op(cur_op, cur_op->req.rw.len); } } @@ -223,7 +223,7 @@ void osd_t::submit_read_subops(int read_pg_size, const uint64_t* osd_set, osd_op { subops[subop].op_type = OSD_OP_OUT; subops[subop].peer_fd = this->osd_peer_fds.at(role_osd_num); - subops[subop].op.sec_rw = { + subops[subop].req.sec_rw = { .header = { .magic = SECONDARY_OSD_OP_MAGIC, .id = this->next_subop_id++, @@ -242,7 +242,7 @@ void osd_t::submit_read_subops(int read_pg_size, const uint64_t* osd_set, osd_op { // so it doesn't get freed. FIXME: do it better subop->buf = NULL; - handle_primary_read_subop(cur_op, subop->reply.hdr.retval == subop->op.sec_rw.len); + handle_primary_read_subop(cur_op, subop->reply.hdr.retval == subop->req.sec_rw.len); }; outbox_push(clients[subops[subop].peer_fd], &subops[subop]); } diff --git a/osd_receive.cpp b/osd_receive.cpp index 875aa443c..a54e31300 100644 --- a/osd_receive.cpp +++ b/osd_receive.cpp @@ -23,7 +23,7 @@ void osd_t::read_requests() cl.read_op->peer_fd = peer_fd; } cl.read_op->op_type = OSD_OP_IN; - cl.read_buf = &cl.read_op->op.buf; + cl.read_buf = &cl.read_op->req.buf; cl.read_remaining = OSD_PACKET_SIZE; cl.read_state = CL_READ_OP; } @@ -66,7 +66,7 @@ void osd_t::handle_read(ring_data_t *data, int peer_fd) cl.read_buf = NULL; if (cl.read_state == CL_READ_OP) { - if (cl.read_op->op.hdr.magic == SECONDARY_OSD_REPLY_MAGIC) + if (cl.read_op->req.hdr.magic == SECONDARY_OSD_REPLY_MAGIC) { handle_read_reply(&cl); } @@ -100,29 +100,29 @@ void osd_t::handle_read(ring_data_t *data, int peer_fd) void osd_t::handle_read_op(osd_client_t *cl) { osd_op_t *cur_op = cl->read_op; - if (cur_op->op.hdr.opcode == OSD_OP_SECONDARY_READ || - cur_op->op.hdr.opcode == OSD_OP_SECONDARY_WRITE || - cur_op->op.hdr.opcode == OSD_OP_SECONDARY_STABILIZE || - cur_op->op.hdr.opcode == OSD_OP_SECONDARY_ROLLBACK) + if (cur_op->req.hdr.opcode == OSD_OP_SECONDARY_READ || + cur_op->req.hdr.opcode == OSD_OP_SECONDARY_WRITE || + cur_op->req.hdr.opcode == OSD_OP_SECONDARY_STABILIZE || + cur_op->req.hdr.opcode == OSD_OP_SECONDARY_ROLLBACK) { // Allocate a buffer - cur_op->buf = memalign(512, cur_op->op.sec_rw.len); + cur_op->buf = memalign(512, cur_op->req.sec_rw.len); } - else if (cur_op->op.hdr.opcode == OSD_OP_READ || - cur_op->op.hdr.opcode == OSD_OP_WRITE) + else if (cur_op->req.hdr.opcode == OSD_OP_READ || + cur_op->req.hdr.opcode == OSD_OP_WRITE) { - cur_op->buf = memalign(512, cur_op->op.rw.len); + cur_op->buf = memalign(512, cur_op->req.rw.len); } - if (cur_op->op.hdr.opcode == OSD_OP_SECONDARY_WRITE || - cur_op->op.hdr.opcode == OSD_OP_SECONDARY_STABILIZE || - cur_op->op.hdr.opcode == OSD_OP_SECONDARY_ROLLBACK || - cur_op->op.hdr.opcode == OSD_OP_WRITE) + if (cur_op->req.hdr.opcode == OSD_OP_SECONDARY_WRITE || + cur_op->req.hdr.opcode == OSD_OP_SECONDARY_STABILIZE || + cur_op->req.hdr.opcode == OSD_OP_SECONDARY_ROLLBACK || + cur_op->req.hdr.opcode == OSD_OP_WRITE) { // Read data cl->read_buf = cur_op->buf; - cl->read_remaining = (cur_op->op.hdr.opcode == OSD_OP_SECONDARY_WRITE - ? cur_op->op.sec_rw.len - : cur_op->op.rw.len); + cl->read_remaining = (cur_op->req.hdr.opcode == OSD_OP_SECONDARY_WRITE + ? cur_op->req.sec_rw.len + : cur_op->req.rw.len); cl->read_state = CL_READ_DATA; } else @@ -137,38 +137,38 @@ void osd_t::handle_read_op(osd_client_t *cl) void osd_t::handle_read_reply(osd_client_t *cl) { osd_op_t *cur_op = cl->read_op; - auto req_it = cl->sent_ops.find(cur_op->op.hdr.id); + auto req_it = cl->sent_ops.find(cur_op->req.hdr.id); if (req_it == cl->sent_ops.end()) { // Command out of sync. Drop connection stop_client(cl->peer_fd); return; } - osd_op_t *request = req_it->second; - memcpy(request->reply.buf, cur_op->op.buf, OSD_PACKET_SIZE); - if (request->reply.hdr.opcode == OSD_OP_SECONDARY_READ && - request->reply.hdr.retval > 0) + osd_op_t *op = req_it->second; + memcpy(op->reply.buf, cur_op->req.buf, OSD_PACKET_SIZE); + if (op->reply.hdr.opcode == OSD_OP_SECONDARY_READ && + op->reply.hdr.retval > 0) { // Read data - // FIXME: request->buf must be allocated + // FIXME: op->buf must be allocated cl->read_state = CL_READ_REPLY_DATA; - cl->read_reply_id = request->op.hdr.id; - cl->read_buf = request->buf; - cl->read_remaining = request->reply.hdr.retval; + cl->read_reply_id = op->req.hdr.id; + cl->read_buf = op->buf; + cl->read_remaining = op->reply.hdr.retval; } - else if (request->reply.hdr.opcode == OSD_OP_SECONDARY_LIST && - request->reply.hdr.retval > 0) + else if (op->reply.hdr.opcode == OSD_OP_SECONDARY_LIST && + op->reply.hdr.retval > 0) { - request->buf = memalign(512, sizeof(obj_ver_id) * request->reply.hdr.retval); + op->buf = memalign(512, sizeof(obj_ver_id) * op->reply.hdr.retval); cl->read_state = CL_READ_REPLY_DATA; - cl->read_reply_id = request->op.hdr.id; - cl->read_buf = request->buf; - cl->read_remaining = sizeof(obj_ver_id) * request->reply.hdr.retval; + cl->read_reply_id = op->req.hdr.id; + cl->read_buf = op->buf; + cl->read_remaining = sizeof(obj_ver_id) * op->reply.hdr.retval; } else { cl->read_state = 0; cl->sent_ops.erase(req_it); - request->callback(request); + op->callback(op); } } diff --git a/osd_send.cpp b/osd_send.cpp index 8c78a3bf9..fa959b013 100644 --- a/osd_send.cpp +++ b/osd_send.cpp @@ -32,7 +32,7 @@ void osd_t::send_replies() cl.outbox.pop_front(); if (cl.write_op->op_type == OSD_OP_OUT) { - cl.write_buf = &cl.write_op->op.buf; + cl.write_buf = &cl.write_op->req.buf; cl.write_remaining = OSD_PACKET_SIZE; cl.write_state = CL_WRITE_REPLY; } @@ -95,7 +95,7 @@ void osd_t::handle_send(ring_data_t *data, int peer_fd) } else { - cl.sent_ops[cl.write_op->op.hdr.id] = cl.write_op; + cl.sent_ops[cl.write_op->req.hdr.id] = cl.write_op; } cl.write_op = NULL; cl.write_state = cl.outbox.size() > 0 ? CL_WRITE_READY : 0;