Skip to content

Commit

Permalink
rgw: make the rgw-object-expirer's options more human readable.
Browse files Browse the repository at this point in the history
Fixes: ceph#4096
Signed-off-by: Radoslaw Zarzynski <rzarzynski@mirantis.com>
  • Loading branch information
rzarzynski authored and Piotr Dałek committed Sep 30, 2015
1 parent a738612 commit ccd651a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/common/config_opts.h
Expand Up @@ -1095,7 +1095,7 @@ OPTION(rgw_multipart_part_upload_limit, OPT_INT, 10000) // parts limit in multip
OPTION(rgw_olh_pending_timeout_sec, OPT_INT, 3600) // time until we retire a pending olh change

OPTION(rgw_objexp_gc_interval, OPT_U32, 60 * 10) // maximum time between round of expired objects garbage collecting
OPTION(rgw_objexp_time_step_exp, OPT_U32, 12) // exponent value (2 is the base) for rounding the timestamps
OPTION(rgw_objexp_time_step, OPT_U32, 4096) // number of seconds for rounding the timestamps
OPTION(rgw_objexp_hints_num_shards, OPT_U32, 127) // maximum number of parts in which the hint index is stored in

OPTION(mutex_perf_counter, OPT_BOOL, false) // enable/disable mutex perf counter
Expand Down
17 changes: 8 additions & 9 deletions src/rgw/rgw_rados.cc
Expand Up @@ -2339,7 +2339,7 @@ int RGWRados::time_log_trim(const string& oid, const utime_t& start_time, const

string RGWRados::objexp_hint_get_shardname(const utime_t &ts)
{
const time_t roundedts = ts.sec() >> cct->_conf->rgw_objexp_time_step_exp;
const time_t roundedts = ts.sec() / cct->_conf->rgw_objexp_time_step;
const unsigned int shnum = roundedts % cct->_conf->rgw_objexp_hints_num_shards;

char buf[32];
Expand Down Expand Up @@ -2387,20 +2387,19 @@ void RGWRados::objexp_get_shard(const utime_t& start_time,
marker = start_time;
}

const uint32_t time_step_exp = cct->_conf->rgw_objexp_time_step_exp;
const uint32_t num_shards = cct->_conf->rgw_objexp_hints_num_shards;
const time_t time_step = 1 << time_step_exp;
const time_t time_step = cct->_conf->rgw_objexp_time_step;

const time_t sts = start_time.sec() >> time_step_exp;
const time_t ets = end_time.sec() >> time_step_exp;
const time_t mts = marker.sec() >> time_step_exp;
const time_t sts = start_time.sec() / time_step;
const time_t ets = end_time.sec() / time_step;
const time_t mts = marker.sec() / time_step;

const uint32_t periods = (ets - sts) / time_step;
const uint32_t iters = min(periods, num_shards);
const uint32_t periods = ets - sts;
const uint32_t iters = min(periods, num_shards - 1);

shard = objexp_hint_get_shardname(marker);

if (mts % num_shards < (sts + iters) % num_shards) {
if (mts - sts < iters) {
truncated = true;
marker += utime_t(time_step, 0);
} else {
Expand Down

0 comments on commit ccd651a

Please sign in to comment.