From 6488d0044ae577f8cfaa2e07dc43f67405e80796 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Sat, 23 May 2020 15:01:47 +0300 Subject: [PATCH] Ignore EPOLL_CTL_DEL ENOENT, fix detection of the rollback version --- Makefile | 2 +- osd.cpp | 7 +++++-- osd.h | 2 +- osd_flush.cpp | 15 +++++++++++---- osd_peering_pg.cpp | 2 +- 5 files changed, 19 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 39c63be3..2db81d70 100644 --- a/Makefile +++ b/Makefile @@ -44,7 +44,7 @@ osd_peering.o: osd_peering.cpp osd.h osd_ops.h osd_peering_pg.h ringloop.h g++ $(CXXFLAGS) -c -o $@ $< osd_cluster.o: osd_cluster.cpp osd.h osd_ops.h ringloop.h g++ $(CXXFLAGS) -c -o $@ $< -http_client.o: http_client.cpp http_client.h osd.h osd_ops.h +http_client.o: http_client.cpp http_client.h g++ $(CXXFLAGS) -c -o $@ $< etcd_state_client.o: etcd_state_client.cpp etcd_state_client.h http_client.h pg_states.h g++ $(CXXFLAGS) -c -o $@ $< diff --git a/osd.cpp b/osd.cpp index a3e8d6e9..2367357a 100644 --- a/osd.cpp +++ b/osd.cpp @@ -250,7 +250,10 @@ void osd_t::set_fd_handler(int fd, std::function handler) } else { - epoll_ctl(epoll_fd, EPOLL_CTL_DEL, fd, NULL); + if (epoll_ctl(epoll_fd, EPOLL_CTL_DEL, fd, NULL) < 0 && errno != ENOENT) + { + throw std::runtime_error(std::string("epoll_ctl: ") + strerror(errno)); + } epoll_handlers.erase(fd); } } @@ -416,7 +419,7 @@ void osd_t::stop_client(int peer_fd) } } clients.erase(it); - if (epoll_ctl(epoll_fd, EPOLL_CTL_DEL, peer_fd, NULL) < 0) + if (epoll_ctl(epoll_fd, EPOLL_CTL_DEL, peer_fd, NULL) < 0 && errno != ENOENT) { throw std::runtime_error(std::string("epoll_ctl: ") + strerror(errno)); } diff --git a/osd.h b/osd.h index 09a3e905..45e02e8f 100644 --- a/osd.h +++ b/osd.h @@ -324,7 +324,7 @@ class osd_t // flushing, recovery and backfill void submit_pg_flush_ops(pg_num_t pg_num); - void handle_flush_op(pg_num_t pg_num, pg_flush_batch_t *fb, osd_num_t peer_osd, int retval); + void handle_flush_op(bool rollback, pg_num_t pg_num, pg_flush_batch_t *fb, osd_num_t peer_osd, int retval); void submit_flush_op(pg_num_t pg_num, pg_flush_batch_t *fb, bool rollback, osd_num_t peer_osd, int count, obj_ver_id *data); bool pick_next_recovery(osd_recovery_op_t &op); void submit_recovery_op(osd_recovery_op_t *op); diff --git a/osd_flush.cpp b/osd_flush.cpp index 62f19a52..2aa5df96 100644 --- a/osd_flush.cpp +++ b/osd_flush.cpp @@ -58,7 +58,7 @@ void osd_t::submit_pg_flush_ops(pg_num_t pg_num) } } -void osd_t::handle_flush_op(pg_num_t pg_num, pg_flush_batch_t *fb, osd_num_t peer_osd, int retval) +void osd_t::handle_flush_op(bool rollback, pg_num_t pg_num, pg_flush_batch_t *fb, osd_num_t peer_osd, int retval) { if (pgs.find(pg_num) == pgs.end() || pgs[pg_num].flush_batch != fb) { @@ -68,7 +68,14 @@ void osd_t::handle_flush_op(pg_num_t pg_num, pg_flush_batch_t *fb, osd_num_t pee if (retval != 0) { if (peer_osd == this->osd_num) - throw std::runtime_error(std::string("Error while doing local flush operation: ") + strerror(-retval)); + { + throw std::runtime_error( + std::string(rollback + ? "Error while doing local rollback operation: " + : "Error while doing local stabilize operation: " + ) + strerror(-retval) + ); + } else { printf("Error while doing flush on OSD %lu: %s\n", osd_num, strerror(-retval)); @@ -158,7 +165,7 @@ void osd_t::submit_flush_op(pg_num_t pg_num, pg_flush_batch_t *fb, bool rollback .callback = [this, op, pg_num, fb](blockstore_op_t *bs_op) { add_bs_subop_stats(op); - handle_flush_op(pg_num, fb, this->osd_num, bs_op->retval); + handle_flush_op(bs_op->opcode == BS_OP_ROLLBACK, pg_num, fb, this->osd_num, bs_op->retval); delete op; }, .len = (uint32_t)count, @@ -186,7 +193,7 @@ void osd_t::submit_flush_op(pg_num_t pg_num, pg_flush_batch_t *fb, bool rollback }; op->callback = [this, pg_num, fb](osd_op_t *op) { - handle_flush_op(pg_num, fb, clients[op->peer_fd].osd_num, op->reply.hdr.retval); + handle_flush_op(op->req.hdr.opcode == OSD_OP_SECONDARY_ROLLBACK, pg_num, fb, clients[op->peer_fd].osd_num, op->reply.hdr.retval); delete op; }; outbox_push(clients[peer_fd], op); diff --git a/osd_peering_pg.cpp b/osd_peering_pg.cpp index e67be66d..56f544a1 100644 --- a/osd_peering_pg.cpp +++ b/osd_peering_pg.cpp @@ -172,7 +172,7 @@ void pg_obj_state_check_t::finish_object() { pcs.stable_ver = list[i].version; } - if (list[i].version <= target_ver) + if (list[i].version <= target_ver && !pcs.max_target) { pcs.max_target = list[i].version; }