osd/HitSet: take Params as const ref to avoid confusion about ownership

Signed-off-by: Sage Weil <sage@inktank.com>
This commit is contained in:
Sage Weil 2013-12-04 14:41:40 -08:00
parent 68c44cbbdc
commit a72094d504
3 changed files with 15 additions and 9 deletions

View File

@ -16,19 +16,23 @@
// -- HitSet --
HitSet::HitSet(HitSet::Params *params)
HitSet::HitSet(const HitSet::Params& params)
{
switch (params->get_type()) {
switch (params.get_type()) {
case TYPE_BLOOM:
impl.reset(new BloomHitSet(static_cast<BloomHitSet::Params*>(params->impl.get())));
{
BloomHitSet::Params *p =
static_cast<BloomHitSet::Params*>(params.impl.get());
impl.reset(new BloomHitSet(p));
}
break;
case TYPE_EXPLICIT_HASH:
impl.reset(new ExplicitHashHitSet(static_cast<ExplicitHashHitSet::Params*>(params->impl.get())));
impl.reset(new ExplicitHashHitSet(static_cast<ExplicitHashHitSet::Params*>(params.impl.get())));
break;
case TYPE_EXPLICIT_OBJECT:
impl.reset(new ExplicitObjectHitSet(static_cast<ExplicitObjectHitSet::Params*>(params->impl.get())));
impl.reset(new ExplicitObjectHitSet(static_cast<ExplicitObjectHitSet::Params*>(params.impl.get())));
break;
case TYPE_NONE:

View File

@ -115,7 +115,7 @@ public:
HitSet() : impl(NULL), sealed(false) {}
HitSet(Impl *i) : impl(i), sealed(false) {}
HitSet(HitSet::Params *params);
HitSet(const HitSet::Params& params);
HitSet(const HitSet& o) {
sealed = o.sealed;
@ -349,7 +349,8 @@ public:
uint64_t target_size; ///< number of unique insertions we expect to this HitSet
uint64_t seed; ///< seed to use when initializing the bloom filter
Params() : false_positive(0), target_size(0), seed(0) {}
Params()
: false_positive(0), target_size(0), seed(0) {}
Params(double fpp, uint64_t t, uint64_t s)
: false_positive(fpp), target_size(t), seed(s) {}
Params(const Params &o)

View File

@ -8503,11 +8503,12 @@ void ReplicatedPG::hit_set_create()
{
utime_t now = ceph_clock_now(NULL);
// make a copy of the params to modify
HitSet::Params *params = new HitSet::Params(pool.info.hit_set_params);
HitSet::Params params(pool.info.hit_set_params);
if (pool.info.hit_set_params.get_type() == HitSet::TYPE_BLOOM) {
BloomHitSet::Params *p =
static_cast<BloomHitSet::Params*>(params->impl.get());
static_cast<BloomHitSet::Params*>(params.impl.get());
dout(20) << __func__ << " " << params << " " << p << dendl;
// convert false positive rate so it holds up across the full period
p->false_positive = p->false_positive / pool.info.hit_set_count;