From: myoungwon oh Date: Thu, 23 Aug 2018 02:20:53 +0000 (+0900) Subject: mon: add a command to set fingerprint algorithm X-Git-Tag: v14.0.1~340^2~7 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ad7096afce13e280985db0b8a323ee63ffb7ea41;p=ceph.git mon: add a command to set fingerprint algorithm Signed-off-by: Myoungwon Oh --- diff --git a/src/mon/MonCommands.h b/src/mon/MonCommands.h index f91ddbd8bae6..d63b222555cf 100644 --- a/src/mon/MonCommands.h +++ b/src/mon/MonCommands.h @@ -954,11 +954,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|pg_num|pgp_num|crush_rule|hashpspool|nodelete|nopgchange|nosizechange|write_fadvise_dontneed|noscrub|nodeep-scrub|hit_set_type|hit_set_period|hit_set_count|hit_set_fpp|use_gmt_hitset|target_max_objects|target_max_bytes|cache_target_dirty_ratio|cache_target_dirty_high_ratio|cache_target_full_ratio|cache_min_flush_age|cache_min_evict_age|erasure_code_profile|min_read_recency_for_promote|all|min_write_recency_for_promote|fast_read|hit_set_grade_decay_rate|hit_set_search_last_n|scrub_min_interval|scrub_max_interval|deep_scrub_interval|recovery_priority|recovery_op_priority|scrub_priority|compression_mode|compression_algorithm|compression_required_ratio|compression_max_blob_size|compression_min_blob_size|csum_type|csum_min_block|csum_max_block|allow_ec_overwrites", \ + "name=var,type=CephChoices,strings=size|min_size|pg_num|pgp_num|crush_rule|hashpspool|nodelete|nopgchange|nosizechange|write_fadvise_dontneed|noscrub|nodeep-scrub|hit_set_type|hit_set_period|hit_set_count|hit_set_fpp|use_gmt_hitset|target_max_objects|target_max_bytes|cache_target_dirty_ratio|cache_target_dirty_high_ratio|cache_target_full_ratio|cache_min_flush_age|cache_min_evict_age|erasure_code_profile|min_read_recency_for_promote|all|min_write_recency_for_promote|fast_read|hit_set_grade_decay_rate|hit_set_search_last_n|scrub_min_interval|scrub_max_interval|deep_scrub_interval|recovery_priority|recovery_op_priority|scrub_priority|compression_mode|compression_algorithm|compression_required_ratio|compression_max_blob_size|compression_min_blob_size|csum_type|csum_min_block|csum_max_block|allow_ec_overwrites|fingerprint_algorithm", \ "get pool parameter ", "osd", "r", "cli,rest") COMMAND("osd pool set " \ "name=pool,type=CephPoolname " \ - "name=var,type=CephChoices,strings=size|min_size|pg_num|pgp_num|crush_rule|hashpspool|nodelete|nopgchange|nosizechange|write_fadvise_dontneed|noscrub|nodeep-scrub|hit_set_type|hit_set_period|hit_set_count|hit_set_fpp|use_gmt_hitset|target_max_bytes|target_max_objects|cache_target_dirty_ratio|cache_target_dirty_high_ratio|cache_target_full_ratio|cache_min_flush_age|cache_min_evict_age|min_read_recency_for_promote|min_write_recency_for_promote|fast_read|hit_set_grade_decay_rate|hit_set_search_last_n|scrub_min_interval|scrub_max_interval|deep_scrub_interval|recovery_priority|recovery_op_priority|scrub_priority|compression_mode|compression_algorithm|compression_required_ratio|compression_max_blob_size|compression_min_blob_size|csum_type|csum_min_block|csum_max_block|allow_ec_overwrites " \ + "name=var,type=CephChoices,strings=size|min_size|pg_num|pgp_num|crush_rule|hashpspool|nodelete|nopgchange|nosizechange|write_fadvise_dontneed|noscrub|nodeep-scrub|hit_set_type|hit_set_period|hit_set_count|hit_set_fpp|use_gmt_hitset|target_max_bytes|target_max_objects|cache_target_dirty_ratio|cache_target_dirty_high_ratio|cache_target_full_ratio|cache_min_flush_age|cache_min_evict_age|min_read_recency_for_promote|min_write_recency_for_promote|fast_read|hit_set_grade_decay_rate|hit_set_search_last_n|scrub_min_interval|scrub_max_interval|deep_scrub_interval|recovery_priority|recovery_op_priority|scrub_priority|compression_mode|compression_algorithm|compression_required_ratio|compression_max_blob_size|compression_min_blob_size|csum_type|csum_min_block|csum_max_block|allow_ec_overwrites|fingerprint_algorithm " \ "name=val,type=CephString " \ "name=force,type=CephChoices,strings=--yes-i-really-mean-it,req=false", \ "set pool parameter to ", "osd", "rw", "cli,rest") diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 072456a6aa13..0c6bb43430c9 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -4353,7 +4353,7 @@ namespace { RECOVERY_PRIORITY, RECOVERY_OP_PRIORITY, SCRUB_PRIORITY, COMPRESSION_MODE, COMPRESSION_ALGORITHM, COMPRESSION_REQUIRED_RATIO, COMPRESSION_MAX_BLOB_SIZE, COMPRESSION_MIN_BLOB_SIZE, - CSUM_TYPE, CSUM_MAX_BLOCK, CSUM_MIN_BLOCK }; + CSUM_TYPE, CSUM_MAX_BLOCK, CSUM_MIN_BLOCK, FINGERPRINT_ALGORITHM }; std::set subtract_second_from_first(const std::set& first, @@ -4942,6 +4942,7 @@ bool OSDMonitor::preprocess_command(MonOpRequestRef op) {"csum_type", CSUM_TYPE}, {"csum_max_block", CSUM_MAX_BLOCK}, {"csum_min_block", CSUM_MIN_BLOCK}, + {"fingerprint_algorithm", FINGERPRINT_ALGORITHM}, }; typedef std::set choices_set_t; @@ -5148,6 +5149,7 @@ bool OSDMonitor::preprocess_command(MonOpRequestRef op) case CSUM_TYPE: case CSUM_MAX_BLOCK: case CSUM_MIN_BLOCK: + case FINGERPRINT_ALGORITHM: pool_opts_t::key_t key = pool_opts_t::get_opt_desc(i->first).key; if (p->opts.is_set(key)) { if(*it == CSUM_TYPE) { @@ -5296,6 +5298,7 @@ bool OSDMonitor::preprocess_command(MonOpRequestRef op) case CSUM_TYPE: case CSUM_MAX_BLOCK: case CSUM_MIN_BLOCK: + case FINGERPRINT_ALGORITHM: for (i = ALL_CHOICES.begin(); i != ALL_CHOICES.end(); ++i) { if (i->second == *it) break; @@ -7062,6 +7065,14 @@ int OSDMonitor::prepare_command_pool_set(const cmdmap_t& cmdmap, ss << "error parsing int value '" << val << "': " << interr; return -EINVAL; } + } else if (var == "fingerprint_algorithm") { + if (!unset) { + auto alg = pg_pool_t::get_fingerprint_from_str(val); + if (!alg) { + ss << "unrecognized fingerprint_algorithm '" << val << "'"; + return -EINVAL; + } + } } pool_opts_t::opt_desc_t desc = pool_opts_t::get_opt_desc(var); diff --git a/src/osd/osd_types.cc b/src/osd/osd_types.cc index 6668fa2f1efd..1228137baa3a 100644 --- a/src/osd/osd_types.cc +++ b/src/osd/osd_types.cc @@ -1032,7 +1032,9 @@ static opt_mapping_t opt_mapping = boost::assign::map_list_of ("csum_max_block", pool_opts_t::opt_desc_t( pool_opts_t::CSUM_MAX_BLOCK, pool_opts_t::INT)) ("csum_min_block", pool_opts_t::opt_desc_t( - pool_opts_t::CSUM_MIN_BLOCK, pool_opts_t::INT)); + pool_opts_t::CSUM_MIN_BLOCK, pool_opts_t::INT)) + ("fingerprint_algorithm", pool_opts_t::opt_desc_t( + pool_opts_t::FINGERPRINT_ALGORITHM, pool_opts_t::STR)); bool pool_opts_t::is_opt_name(const std::string& name) { return opt_mapping.count(name); @@ -1958,6 +1960,8 @@ ostream& operator<<(ostream& out, const pg_pool_t& p) out << it->first; } } + if (p.get_fingerprint_type() != pg_pool_t::TYPE_FINGERPRINT_NONE) { + out << " fingerprint_algorighm " << p.get_fingerprint_name(); return out; } diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h index 02133ab1fb51..5e11a0f2a187 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -1076,6 +1076,7 @@ public: CSUM_TYPE, CSUM_MAX_BLOCK, CSUM_MIN_BLOCK, + FINGERPRINT_ALGORITHM, }; enum type_t { @@ -1415,6 +1416,37 @@ public: pool_opts_t opts; ///< options + typedef enum { + TYPE_FINGERPRINT_NONE = 0, + TYPE_FINGERPRINT_SHA1 = 1, + } fingerprint_t; + static fingerprint_t get_fingerprint_from_str(const string& s) { + if (s == "none") + return TYPE_FINGERPRINT_NONE; + if (s == "sha1") + return TYPE_FINGERPRINT_SHA1; + return (fingerprint_t)-1; + } + const fingerprint_t get_fingerprint_type() const { + string fp_str; + opts.get(pool_opts_t::FINGERPRINT_ALGORITHM, &fp_str); + return get_fingerprint_from_str(fp_str); + } + const char *get_fingerprint_name() const { + string fp_str; + fingerprint_t fp_t; + opts.get(pool_opts_t::FINGERPRINT_ALGORITHM, &fp_str); + fp_t = get_fingerprint_from_str(fp_str); + return get_fingerprint_name(fp_t); + } + static const char *get_fingerprint_name(fingerprint_t m) { + switch (m) { + case TYPE_FINGERPRINT_NONE: return "none"; + case TYPE_FINGERPRINT_SHA1: return "sha1"; + default: return "unknown"; + } + } + /// application -> key/value metadata map> application_metadata;