From: Igor Fedotov Date: Tue, 2 Aug 2016 12:26:45 +0000 (+0300) Subject: osd/osd_types,mon/OSDMonitor: add compression related settings for pools. X-Git-Tag: v11.1.0~539^2~7 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3f60c1cfd47bd9366b9ac824b2d6d71dbe3a80a4;p=ceph.git osd/osd_types,mon/OSDMonitor: add compression related settings for pools. Signed-off-by: Igor Fedotov --- diff --git a/src/mon/MonCommands.h b/src/mon/MonCommands.h index 36958de297f0..1f9c91bf5ea7 100644 --- a/src/mon/MonCommands.h +++ b/src/mon/MonCommands.h @@ -719,11 +719,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|hashpspool|nodelete|nopgchange|nosizechange|write_fadvise_dontneed|noscrub|nodeep-scrub|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_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", \ + "name=var,type=CephChoices,strings=size|min_size|crash_replay_interval|pg_num|pgp_num|crush_ruleset|hashpspool|nodelete|nopgchange|nosizechange|write_fadvise_dontneed|noscrub|nodeep-scrub|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_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", \ "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|write_fadvise_dontneed|noscrub|nodeep-scrub|hit_set_type|hit_set_period|hit_set_count|hit_set_fpp|use_gmt_hitset|debug_fake_ec_pool|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|auid|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 " \ + "name=var,type=CephChoices,strings=size|min_size|crash_replay_interval|pg_num|pgp_num|crush_ruleset|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|debug_fake_ec_pool|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|auid|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 " \ "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 4fba1f5679c5..34a3e310c416 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -55,6 +55,8 @@ #include "common/errno.h" #include "erasure-code/ErasureCodePlugin.h" +#include "compressor/Compressor.h" +#include "common/Checksummer.h" #include "include/compat.h" #include "include/assert.h" @@ -3138,7 +3140,10 @@ namespace { 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}; + 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 }; std::set subtract_second_from_first(const std::set& first, @@ -3637,6 +3642,14 @@ bool OSDMonitor::preprocess_command(MonOpRequestRef op) {"recovery_priority", RECOVERY_PRIORITY}, {"recovery_op_priority", RECOVERY_OP_PRIORITY}, {"scrub_priority", SCRUB_PRIORITY}, + {"compression_mode", COMPRESSION_MODE}, + {"compression_algorithm", COMPRESSION_ALGORITHM}, + {"compression_required_ratio", COMPRESSION_REQUIRED_RATIO}, + {"compression_max_blob_size", COMPRESSION_MAX_BLOB_SIZE}, + {"compression_min_blob_size", COMPRESSION_MIN_BLOB_SIZE}, + {"csum_type", CSUM_TYPE}, + {"csum_max_block", CSUM_MAX_BLOCK}, + {"csum_min_block", CSUM_MIN_BLOCK}, }; typedef std::set choices_set_t; @@ -3825,12 +3838,27 @@ bool OSDMonitor::preprocess_command(MonOpRequestRef op) case RECOVERY_PRIORITY: case RECOVERY_OP_PRIORITY: case SCRUB_PRIORITY: + case COMPRESSION_MODE: + case COMPRESSION_ALGORITHM: + case COMPRESSION_REQUIRED_RATIO: + case COMPRESSION_MAX_BLOB_SIZE: + case COMPRESSION_MIN_BLOB_SIZE: + case CSUM_TYPE: + case CSUM_MAX_BLOCK: + case CSUM_MIN_BLOCK: for (i = ALL_CHOICES.begin(); i != ALL_CHOICES.end(); ++i) { if (i->second == *it) break; } assert(i != ALL_CHOICES.end()); - p->opts.dump(i->first, f.get()); + if(*it == CSUM_TYPE) { + int val; + p->opts.get(pool_opts_t::CSUM_TYPE, &val); + f->dump_string(i->first.c_str(), Checksummer::get_csum_type_string(val)); + } + else { + p->opts.dump(i->first, f.get()); + } break; } f->close_section(); @@ -3959,6 +3987,14 @@ bool OSDMonitor::preprocess_command(MonOpRequestRef op) case RECOVERY_PRIORITY: case RECOVERY_OP_PRIORITY: case SCRUB_PRIORITY: + case COMPRESSION_MODE: + case COMPRESSION_ALGORITHM: + case COMPRESSION_REQUIRED_RATIO: + case COMPRESSION_MAX_BLOB_SIZE: + case COMPRESSION_MIN_BLOB_SIZE: + case CSUM_TYPE: + case CSUM_MAX_BLOCK: + case CSUM_MIN_BLOCK: for (i = ALL_CHOICES.begin(); i != ALL_CHOICES.end(); ++i) { if (i->second == *it) break; @@ -3967,7 +4003,13 @@ bool OSDMonitor::preprocess_command(MonOpRequestRef op) { pool_opts_t::key_t key = pool_opts_t::get_opt_desc(i->first).key; if (p->opts.is_set(key)) { - ss << i->first << ": " << p->opts.get(key) << "\n"; + if(key == pool_opts_t::CSUM_TYPE) { + int val; + p->opts.get(key, &val); + ss << i->first << ": " << Checksummer::get_csum_type_string(val) << "\n"; + } else { + ss << i->first << ": " << p->opts.get(key) << "\n"; + } } } break; @@ -5423,6 +5465,46 @@ int OSDMonitor::prepare_command_pool_set(map &cmdmap, return -EINVAL; } } else if (pool_opts_t::is_opt_name(var)) { + if (var == "compression_mode") { + auto cmode = Compressor::get_comp_mode_type(val); + if (!cmode) { + ss << "unrecognized compression mode '" << val << "'"; + return EINVAL; + } + } else if (var == "compression_algorithm") { + auto alg = Compressor::get_comp_alg_type(val); + if (!alg) { + ss << "unrecognized compression_algorithm '" << val << "'"; + return EINVAL; + } + } else if (var == "compression_required_ratio") { + if (floaterr.length()) { + ss << "error parsing float value '" << val << "': " << floaterr; + return -EINVAL; + } + if (f < 0 || f>1) { + ss << "compression_required_ratio is out of range (0-1): '" << val << "'"; + return EINVAL; + } + } else if (var == "csum_type") { + auto t = val != "unset" ? Checksummer::get_csum_string_type(val) : 0; + if (t < 0 ) { + ss << "unrecognized csum_type '" << val << "'"; + return EINVAL; + } + //preserve csum_type numeric value + n = t; + interr.clear(); + } else if (var == "compression_max_blob_size" || + var == "compression_min_blob_size" || + var == "csum_max_block" || + var == "csum_min_block") { + if (interr.length()) { + ss << "error parsing int value '" << val << "': " << interr; + return -EINVAL; + } + } + pool_opts_t::opt_desc_t desc = pool_opts_t::get_opt_desc(var); switch (desc.type) { case pool_opts_t::STR: diff --git a/src/osd/osd_types.cc b/src/osd/osd_types.cc index e8054957a49d..bf0969d31f82 100644 --- a/src/osd/osd_types.cc +++ b/src/osd/osd_types.cc @@ -961,7 +961,23 @@ static opt_mapping_t opt_mapping = boost::assign::map_list_of ("recovery_op_priority", pool_opts_t::opt_desc_t( pool_opts_t::RECOVERY_OP_PRIORITY, pool_opts_t::INT)) ("scrub_priority", pool_opts_t::opt_desc_t( - pool_opts_t::SCRUB_PRIORITY, pool_opts_t::INT)); + pool_opts_t::SCRUB_PRIORITY, pool_opts_t::INT)) + ("compression_mode", pool_opts_t::opt_desc_t( + pool_opts_t::COMPRESSION_MODE, pool_opts_t::STR)) + ("compression_algorithm", pool_opts_t::opt_desc_t( + pool_opts_t::COMPRESSION_ALGORITHM, pool_opts_t::STR)) + ("compression_required_ratio", pool_opts_t::opt_desc_t( + pool_opts_t::COMPRESSION_REQUIRED_RATIO, pool_opts_t::DOUBLE)) + ("compression_max_blob_size", pool_opts_t::opt_desc_t( + pool_opts_t::COMPRESSION_MAX_BLOB_SIZE, pool_opts_t::INT)) + ("compression_min_blob_size", pool_opts_t::opt_desc_t( + pool_opts_t::COMPRESSION_MIN_BLOB_SIZE, pool_opts_t::INT)) + ("csum_type", pool_opts_t::opt_desc_t( + pool_opts_t::CSUM_TYPE, pool_opts_t::INT)) + ("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)); bool pool_opts_t::is_opt_name(const std::string& name) { return opt_mapping.find(name) != opt_mapping.end(); @@ -5407,4 +5423,4 @@ ostream& operator<<(ostream& out, const store_statfs_t &s) << std::dec << ")"; return out; -} \ No newline at end of file +} diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h index eec36f67c2ba..8fd2225dbe47 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -43,6 +43,7 @@ #include "OpRequest.h" #include "include/cmp.h" #include "librados/ListObjectImpl.h" +#include "compressor/Compressor.h" #include #define CEPH_OSD_ONDISK_MAGIC "ceph osd volume v026" @@ -976,7 +977,15 @@ public: DEEP_SCRUB_INTERVAL, RECOVERY_PRIORITY, RECOVERY_OP_PRIORITY, - SCRUB_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, }; enum type_t {