From patchwork Thu May 21 13:34:07 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Wang X-Patchwork-Id: 6455331 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id BF3AEC0432 for ; Thu, 21 May 2015 13:36:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CA4982027D for ; Thu, 21 May 2015 13:36:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AF7922044C for ; Thu, 21 May 2015 13:36:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756167AbbEUNf5 (ORCPT ); Thu, 21 May 2015 09:35:57 -0400 Received: from m59-178.qiye.163.com ([123.58.178.59]:58912 "EHLO m59-178.qiye.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755072AbbEUNf4 (ORCPT ); Thu, 21 May 2015 09:35:56 -0400 Received: from localhost.localdomain (unknown [113.240.220.93]) by m59-178.qiye.163.com (HMail) with ESMTPA id E6F731481A42; Thu, 21 May 2015 21:35:41 +0800 (CST) From: Li Wang To: Sage Weil Cc: ceph-devel@vger.kernel.org, MingXin Liu Subject: [PATCH 2/5] Mon: expose commands for temperature related setting Date: Thu, 21 May 2015 21:34:07 +0800 Message-Id: <6826e84a012cff2bd1a2a8741a8bfddc002da8dd.1432214851.git.liwang@ubuntukylin.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: References: In-Reply-To: References: X-HM-Spam-Status: e1koWUFPN1dZCBgUCR5ZQUpOVUNJQkJCQkJJSExLTUtOTldZCQ4XHghZQV koKz0kKDQ9Lz06MjckMjUkMz46Pz4pQUtVS0A2IyQiPigkMjUkMz46Pz4pQUtVS0ArLykkNTQkMj UkMz46Pz4pQUlVS0A*IjU6NjI4JDIrJDU0JDI1JDM#Oj8#KUFLVUtANi43LzIkKTgrLyQ*Mj09Pi k#NS8kMjUkMz46Pz4pQUlVS0AyKyQvND86IiQ4NS8kSyRKS0tBS1VLQDIrJEokMzQuKSQ4NS8kSy RKS0tBS1VLQDIrJEokNjI1Li8#JDg1LyRLJEpLQUtVS0AyKyRISyQ2MjUuLz4kODUvJEskTktBS1 VLQDIrJE4kNjI1Li8#JDg1LyRLJEpLQUtVS0AoLjkxPjgvJC80PzoiJDg1LyRLJEpLS0FLVUtAKC 45MT44LyROJDYyNS4vPiQ4NS8kSyRKS0FLVUtAKC45MT44LyRKJDM0LikkODUvJEskSktLQUtVS0 A1NC8kPTo2NC4oJD80NjoyNSQoKz0kPToyN0FKS1VLQD01JDM0LyQzNzEkS0xLTktPQUtVS0AoLj kkPkFKVU5OQD01JCguOSQ#NSw0KT8oJDM3MSRKS0tJS0pBS1VJQ1kG X-HM-Sender-Digest: e1kSHx4VD1lBWUc6Py46FBw6PDo8OAFCEC8ONDlLHCxPCSJVSlVKT0hJ SUpOSE9ISk1OVTMWGhIXVRcSDBoVHDsOGQ4VDw4QAhcSFVUYFBZFWVdZDB4ZWUEdGhcIHldZCAFZ QUpKSklPN1dZEgtZQVlKSkhVSU9LVUlJS1VCSFkG X-HM-Tid: 0a4d76afcbc1649fe6f731481a42 Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: MingXin Liu Signed-off-by: MingXin Liu Reviewed-by: Li Wang --- src/mon/MonCommands.h | 8 +++-- src/mon/OSDMonitor.cc | 87 ++++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 88 insertions(+), 7 deletions(-) diff --git a/src/mon/MonCommands.h b/src/mon/MonCommands.h index 8a36807..b26834d 100644 --- a/src/mon/MonCommands.h +++ b/src/mon/MonCommands.h @@ -639,11 +639,11 @@ COMMAND("osd pool rename " \ "rename to ", "osd", "rw", "cli,rest") COMMAND("osd pool get " \ "name=pool,type=CephPoolname " \ - "name=var,type=CephChoices,strings=size|min_size|crash_replay_interval|pg_num|pgp_num|crush_ruleset|hit_set_type|hit_set_period|hit_set_count|hit_set_fpp|auid|target_max_objects|target_max_bytes|cache_target_dirty_ratio|cache_target_full_ratio|cache_min_flush_age|cache_min_evict_age|erasure_code_profile|min_read_recency_for_promote|write_fadvise_dontneed|all", \ + "name=var,type=CephChoices,strings=size|min_size|crash_replay_interval|pg_num|pgp_num|crush_ruleset|hit_set_type|hit_set_period|hit_set_count|hit_set_fpp|auid|target_max_objects|target_max_bytes|cache_target_dirty_ratio|cache_target_full_ratio|cache_min_flush_age|cache_min_evict_age|erasure_code_profile|min_read_recency_for_promote|write_fadvise_dontneed|hit_set_grade_decay_rate|all", \ "get pool parameter ", "osd", "r", "cli,rest") COMMAND("osd pool set " \ "name=pool,type=CephPoolname " \ - "name=var,type=CephChoices,strings=size|min_size|crash_replay_interval|pg_num|pgp_num|crush_ruleset|hashpspool|nodelete|nopgchange|nosizechange|hit_set_type|hit_set_period|hit_set_count|hit_set_fpp|debug_fake_ec_pool|target_max_bytes|target_max_objects|cache_target_dirty_ratio|cache_target_full_ratio|cache_min_flush_age|cache_min_evict_age|auid|min_read_recency_for_promote|write_fadvise_dontneed " \ + "name=var,type=CephChoices,strings=size|min_size|crash_replay_interval|pg_num|pgp_num|crush_ruleset|hashpspool|nodelete|nopgchange|nosizechange|hit_set_type|hit_set_period|hit_set_count|hit_set_fpp|debug_fake_ec_pool|target_max_bytes|target_max_objects|cache_target_dirty_ratio|cache_target_full_ratio|cache_min_flush_age|cache_min_evict_age|auid|min_read_recency_for_promote|write_fadvise_dontneed|hit_set_grade_decay_rate " \ "name=val,type=CephString " \ "name=force,type=CephChoices,strings=--yes-i-really-mean-it,req=false", \ "set pool parameter to ", "osd", "rw", "cli,rest") @@ -695,6 +695,10 @@ COMMAND("osd tier cache-mode " \ "name=pool,type=CephPoolname " \ "name=mode,type=CephChoices,strings=none|writeback|forward|readonly|readforward|readproxy", \ "specify the caching mode for cache tier ", "osd", "rw", "cli,rest") +COMMAND("osd tier cache-measure " \ + "name=pool,type=CephPoolname " \ + "name=measure,type=CephChoices,strings=atime|temperature", \ + "specify the caching measure to judge hot objects for cache tier ", "osd", "rw", "cli,rest") COMMAND("osd tier set-overlay " \ "name=pool,type=CephPoolname " \ "name=overlaypool,type=CephPoolname", \ diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 10597d0..0374778 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -2803,7 +2803,7 @@ namespace { CACHE_TARGET_DIRTY_RATIO, CACHE_TARGET_FULL_RATIO, CACHE_MIN_FLUSH_AGE, CACHE_MIN_EVICT_AGE, ERASURE_CODE_PROFILE, MIN_READ_RECENCY_FOR_PROMOTE, - WRITE_FADVISE_DONTNEED}; + WRITE_FADVISE_DONTNEED, HIT_SET_GRADE_DECAY_RATE}; std::set subtract_second_from_first(const std::set& first, @@ -3251,7 +3251,8 @@ bool OSDMonitor::preprocess_command(MMonCommand *m) ("cache_min_evict_age", CACHE_MIN_EVICT_AGE) ("erasure_code_profile", ERASURE_CODE_PROFILE) ("min_read_recency_for_promote", MIN_READ_RECENCY_FOR_PROMOTE) - ("write_fadvise_dontneed", WRITE_FADVISE_DONTNEED); + ("write_fadvise_dontneed", WRITE_FADVISE_DONTNEED) + ("hit_set_grade_decay_rate", HIT_SET_GRADE_DECAY_RATE); typedef std::set choices_set_t; @@ -3259,7 +3260,7 @@ bool OSDMonitor::preprocess_command(MMonCommand *m) (HIT_SET_TYPE)(HIT_SET_PERIOD)(HIT_SET_COUNT)(HIT_SET_FPP) (TARGET_MAX_OBJECTS)(TARGET_MAX_BYTES)(CACHE_TARGET_FULL_RATIO) (CACHE_TARGET_DIRTY_RATIO)(CACHE_MIN_FLUSH_AGE)(CACHE_MIN_EVICT_AGE) - (MIN_READ_RECENCY_FOR_PROMOTE); + (MIN_READ_RECENCY_FOR_PROMOTE)(HIT_SET_GRADE_DECAY_RATE); const choices_set_t ONLY_ERASURE_CHOICES = boost::assign::list_of (ERASURE_CODE_PROFILE); @@ -3389,6 +3390,10 @@ bool OSDMonitor::preprocess_command(MMonCommand *m) f->dump_int("min_read_recency_for_promote", p->min_read_recency_for_promote); break; + case HIT_SET_GRADE_DECAY_RATE: + f->dump_int("hit_set_priority_decacy_rate", + p->hit_set_grade_decay_rate); + break; case WRITE_FADVISE_DONTNEED: f->dump_string("write_fadvise_dontneed", p->has_flag(pg_pool_t::FLAG_WRITE_FADVISE_DONTNEED) ? @@ -3476,6 +3481,10 @@ bool OSDMonitor::preprocess_command(MMonCommand *m) ss << "min_read_recency_for_promote: " << p->min_read_recency_for_promote << "\n"; break; + case HIT_SET_GRADE_DECAY_RATE: + ss << "hit_set_grade_decay_rate: " << + p->hit_set_grade_decay_rate << "\n"; + break; case WRITE_FADVISE_DONTNEED: ss << "write_fadvise_dontneed: " << (p->has_flag(pg_pool_t::FLAG_WRITE_FADVISE_DONTNEED) ? @@ -4466,7 +4475,8 @@ int OSDMonitor::prepare_command_pool_set(map &cmdmap, var == "hit_set_count" || var == "hit_set_fpp" || var == "target_max_objects" || var == "target_max_bytes" || var == "cache_target_full_ratio" || var == "cache_target_dirty_ratio" || - var == "cache_min_flush_age" || var == "cache_min_evict_age")) { + var == "cache_min_flush_age" || var == "cache_min_evict_age" || + var == "hit_set_grade_decay_rate")) { ss << "pool '" << poolstr << "' is not a tier pool: variable not applicable"; return -EACCES; } @@ -4652,12 +4662,12 @@ int OSDMonitor::prepare_command_pool_set(map &cmdmap, } p.hit_set_period = n; } else if (var == "hit_set_count") { - if (interr.length()) { ss << "error parsing integer value '" << val << "': " << interr; return -EINVAL; } p.hit_set_count = n; + p.set_grade(p.hit_set_grade_decay_rate, n); } else if (var == "hit_set_fpp") { if (floaterr.length()) { ss << "error parsing floating point value '" << val << "': " << floaterr; @@ -4723,6 +4733,17 @@ int OSDMonitor::prepare_command_pool_set(map &cmdmap, return -EINVAL; } p.min_read_recency_for_promote = n; + } else if (var == "hit_set_grade_decay_rate") { + if (interr.length()) { + ss << "error parsing integer value '" << val << "': " << interr; + return -EINVAL; + } + if (n > 100 || n < 0) { + ss << "value out of range,valid range is 0 - 100"; + return -EINVAL; + } + p.hit_set_grade_decay_rate = n; + p.set_grade(n, p.hit_set_count); } else if (var == "write_fadvise_dontneed") { if (val == "true" || (interr.empty() && n == 1)) { p.flags |= pg_pool_t::FLAG_WRITE_FADVISE_DONTNEED; @@ -6744,6 +6765,62 @@ done: wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, ss.str(), get_last_committed() + 1)); return true; + } else if (prefix == "osd tier cache-measure") { + err = check_cluster_features(CEPH_FEATURE_OSD_CACHEPOOL, ss); + if (err == -EAGAIN) + goto wait; + if (err) + goto reply; + string poolstr; + cmd_getval(g_ceph_context, cmdmap, "pool", poolstr); + int64_t pool_id = osdmap.lookup_pg_pool_name(poolstr); + if (pool_id < 0) { + ss << "unrecognized pool '" << poolstr << "'"; + err = -ENOENT; + goto reply; + } + const pg_pool_t *p = osdmap.get_pg_pool(pool_id); + assert(p); + if (!p->is_tier()) { + ss << "pool '" << poolstr << "' is not a tier"; + err = -EINVAL; + goto reply; + } + string measurestr; + cmd_getval(g_ceph_context, cmdmap, "measure", measurestr); + pg_pool_t::cache_measure_t measure = pg_pool_t::get_cache_measure_from_str(measurestr); + if (measure < 0) { + ss << "'" << measurestr << "' is not a valid cache measure"; + err = -EINVAL; + goto reply; + } + if (p->grade_table.empty()) { + ss << "grade_table is empty,set hit_set and hit_set_decay_rate first"; + err = -EINVAL; + goto reply; + } + if (p->hit_set_params.get_type() == HitSet::TYPE_NONE) { + ss << "hit_set_type cannot be none"; + err = -EINVAL; + goto reply; + } + + //pool already had this cache-measure set and there are no pending changes + if (p->cache_measure == measure && + (pending_inc.new_pools.count(pool_id) == 0 || + pending_inc.new_pools[pool_id].cache_measure == p->cache_measure)) { + ss << "set cache-measure for pool '" << poolstr << "'" + << " to " << pg_pool_t::get_cache_measure_name(measure); + err = 0; + goto reply; + } + pg_pool_t *np = pending_inc.get_new_pool(pool_id, p); + np->cache_measure = measure; + ss << "set cache-measure for pool '" << poolstr + << "' to " << pg_pool_t::get_cache_measure_name(measure); + wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, ss.str(), + get_last_committed() + 1)); + return true; } else if (prefix == "osd tier add-cache") { err = check_cluster_features(CEPH_FEATURE_OSD_CACHEPOOL, ss); if (err == -EAGAIN)