From: Zhiqiang Wang Date: Thu, 12 Mar 2015 05:54:51 +0000 (+0800) Subject: osd: refactor the skip promotion logic X-Git-Tag: v9.0.1~38^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d42c2c4517140619a0edb75c6ffb71a24372d4b0;p=ceph.git osd: refactor the skip promotion logic Moving the skip promotion detection logic into init_op_flags, avoid doing extra checking. Signed-off-by: Zhiqiang Wang --- diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 933d35daaf22..c5cc613b635c 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -8667,6 +8667,16 @@ int OSD::init_op_flags(OpRequestRef& op) break; } + case CEPH_OSD_OP_DELETE: + // if we get a delete with FAILOK we can skip promote. without + // FAILOK we still need to promote (or do something smarter) to + // determine whether to return ENOENT or 0. + if (iter == m->ops.begin() && + iter->op.flags == CEPH_OSD_OP_FLAG_FAILOK) { + op->set_skip_promote(); + } + break; + default: break; } diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index ab435301c15e..ac977a136e4a 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -1800,7 +1800,7 @@ bool ReplicatedPG::maybe_handle_cache(OpRequestRef op, osd->logger->inc(l_osd_op_cache_hit); return false; } - + MOSDOp *m = static_cast(op->get_req()); const object_locator_t& oloc = m->get_object_locator(); @@ -1809,6 +1809,10 @@ bool ReplicatedPG::maybe_handle_cache(OpRequestRef op, return true; } + if (op->need_skip_promote()) { + return false; + } + // older versions do not proxy the feature bits. bool can_proxy_read = get_osdmap()->get_up_osd_features() & CEPH_FEATURE_OSD_PROXY_FEATURES; @@ -1832,9 +1836,7 @@ bool ReplicatedPG::maybe_handle_cache(OpRequestRef op, waiting_for_cache_not_full.push_back(op); return true; } - if (can_skip_promote(op)) { - return false; - } + if (op->may_write() || write_ordered || !hit_set) { promote_object(obc, missing_oid, oloc, op); return true; @@ -1920,9 +1922,6 @@ bool ReplicatedPG::maybe_handle_cache(OpRequestRef op, waiting_for_cache_not_full.push_back(op); return true; } - if (can_skip_promote(op)) { - return false; - } promote_object(obc, missing_oid, oloc, op); return true; } @@ -1940,9 +1939,6 @@ bool ReplicatedPG::maybe_handle_cache(OpRequestRef op, waiting_for_cache_not_full.push_back(op); return true; } - if (can_skip_promote(op)) { - return false; - } promote_object(obc, missing_oid, oloc, op); return true; } @@ -1957,20 +1953,6 @@ bool ReplicatedPG::maybe_handle_cache(OpRequestRef op, return false; } -bool ReplicatedPG::can_skip_promote(OpRequestRef op) -{ - MOSDOp *m = static_cast(op->get_req()); - if (m->ops.empty()) - return false; - // if we get a delete with FAILOK we can skip promote. without - // FAILOK we still need to promote (or do something smarter) to - // determine whether to return ENOENT or 0. - if (m->ops[0].op.op == CEPH_OSD_OP_DELETE && - (m->ops[0].op.flags & CEPH_OSD_OP_FLAG_FAILOK)) - return true; - return false; -} - void ReplicatedPG::do_cache_redirect(OpRequestRef op) { MOSDOp *m = static_cast(op->get_req()); diff --git a/src/osd/ReplicatedPG.h b/src/osd/ReplicatedPG.h index 5c8ad6bd3494..28afab1518ac 100644 --- a/src/osd/ReplicatedPG.h +++ b/src/osd/ReplicatedPG.h @@ -1156,11 +1156,6 @@ protected: const object_locator_t& oloc, ///< locator for obc|oid OpRequestRef op); ///< [optional] client op - /** - * Check if the op is such that we can skip promote (e.g., DELETE) - */ - bool can_skip_promote(OpRequestRef op); - int prepare_transaction(OpContext *ctx); list > in_progress_async_reads; void complete_read_ctx(int result, OpContext *ctx);