osd: add the support of per pool scrub priority

ceph osd pool get pool_name scrub_priority
ceph osd pool set pool_name scrub_priority x

Signed-off-by: Zhiqiang Wang <zhiqiang@xsky.com>
This commit is contained in:
Zhiqiang Wang 2016-02-25 06:06:12 -05:00
parent bea2e10a00
commit 3241011cf7
7 changed files with 22 additions and 7 deletions

View File

@ -676,11 +676,11 @@ COMMAND("osd pool rename " \
"rename <srcpool> to <destpool>", "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", \
"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", \
"get pool parameter <var>", "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 " \
"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=val,type=CephString " \
"name=force,type=CephChoices,strings=--yes-i-really-mean-it,req=false", \
"set pool parameter <var> to <val>", "osd", "rw", "cli,rest")

View File

@ -2923,7 +2923,7 @@ 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};
RECOVERY_PRIORITY, RECOVERY_OP_PRIORITY, SCRUB_PRIORITY};
std::set<osd_pool_get_choices>
subtract_second_from_first(const std::set<osd_pool_get_choices>& first,
@ -3404,7 +3404,8 @@ bool OSDMonitor::preprocess_command(MonOpRequestRef op)
("scrub_max_interval", SCRUB_MAX_INTERVAL)
("deep_scrub_interval", DEEP_SCRUB_INTERVAL)
("recovery_priority", RECOVERY_PRIORITY)
("recovery_op_priority", RECOVERY_OP_PRIORITY);
("recovery_op_priority", RECOVERY_OP_PRIORITY)
("scrub_priority", SCRUB_PRIORITY);
typedef std::set<osd_pool_get_choices> choices_set_t;
@ -3588,6 +3589,7 @@ bool OSDMonitor::preprocess_command(MonOpRequestRef op)
case DEEP_SCRUB_INTERVAL:
case RECOVERY_PRIORITY:
case RECOVERY_OP_PRIORITY:
case SCRUB_PRIORITY:
for (i = ALL_CHOICES.begin(); i != ALL_CHOICES.end(); ++i) {
if (i->second == *it)
break;
@ -3721,6 +3723,7 @@ bool OSDMonitor::preprocess_command(MonOpRequestRef op)
case DEEP_SCRUB_INTERVAL:
case RECOVERY_PRIORITY:
case RECOVERY_OP_PRIORITY:
case SCRUB_PRIORITY:
for (i = ALL_CHOICES.begin(); i != ALL_CHOICES.end(); ++i) {
if (i->second == *it)
break;

View File

@ -845,7 +845,7 @@ public:
PGQueueable(
PGScrub(pg->get_osdmap()->get_epoch()),
cct->_conf->osd_scrub_cost,
cct->_conf->osd_scrub_priority,
pg->get_scrub_priority(),
ceph_clock_now(cct),
entity_inst_t())));
}

View File

@ -2047,6 +2047,14 @@ bool PG::queue_scrub()
return true;
}
unsigned PG::get_scrub_priority()
{
// a higher value -> a higher priority
int pool_scrub_priority = 0;
pool.info.opts.get(pool_opts_t::SCRUB_PRIORITY, &pool_scrub_priority);
return pool_scrub_priority > 0 ? pool_scrub_priority : cct->_conf->osd_scrub_priority;
}
struct C_PG_FinishRecovery : public Context {
PGRef pg;
C_PG_FinishRecovery(PG *p) : pg(p) {}

View File

@ -2216,6 +2216,7 @@ public:
void queue_snap_trim();
bool requeue_scrub();
bool queue_scrub();
unsigned get_scrub_priority();
/// share pg info after a pg is active
void share_pg_info();

View File

@ -928,7 +928,9 @@ static opt_mapping_t opt_mapping = boost::assign::map_list_of
("recovery_priority", pool_opts_t::opt_desc_t(
pool_opts_t::RECOVERY_PRIORITY, pool_opts_t::INT))
("recovery_op_priority", pool_opts_t::opt_desc_t(
pool_opts_t::RECOVERY_OP_PRIORITY, pool_opts_t::INT));
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));
bool pool_opts_t::is_opt_name(const std::string& name) {
return opt_mapping.find(name) != opt_mapping.end();

View File

@ -926,7 +926,8 @@ public:
SCRUB_MAX_INTERVAL,
DEEP_SCRUB_INTERVAL,
RECOVERY_PRIORITY,
RECOVERY_OP_PRIORITY
RECOVERY_OP_PRIORITY,
SCRUB_PRIORITY
};
enum type_t {