From: huangjun Date: Mon, 26 Dec 2016 15:45:45 +0000 (+0800) Subject: osd/PG: fix possible overflow on unfound objects X-Git-Tag: v12.0.3~127^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F12669%2Fhead;p=ceph.git osd/PG: fix possible overflow on unfound objects Signed-off-by: huangjun --- diff --git a/src/osd/PG.cc b/src/osd/PG.cc index 9b49fe84dcb..9661594fb1c 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -470,7 +470,7 @@ bool PG::search_for_missing( pg_shard_t from, RecoveryCtx *ctx) { - unsigned num_unfound_before = missing_loc.num_unfound(); + uint64_t num_unfound_before = missing_loc.num_unfound(); bool found_missing = missing_loc.add_source_info( from, oinfo, omissing, get_sort_bitwise(), ctx->handle); if (found_missing && num_unfound_before != missing_loc.num_unfound()) @@ -596,11 +596,12 @@ bool PG::MissingLoc::add_source_info( void PG::discover_all_missing(map > &query_map) { auto &missing = pg_log.get_missing(); - assert(have_unfound()); + uint64_t unfound = get_num_unfound(); + assert(unfound > 0); dout(10) << __func__ << " " << missing.num_missing() << " missing, " - << get_num_unfound() << " unfound" + << unfound << " unfound" << dendl; std::set::const_iterator m = might_have_unfound.begin(); @@ -5391,7 +5392,7 @@ ostream& operator<<(ostream& out, const PG& pg) if (pg.pg_log.get_missing().num_missing()) { out << " m=" << pg.pg_log.get_missing().num_missing(); if (pg.is_primary()) { - int unfound = pg.get_num_unfound(); + uint64_t unfound = pg.get_num_unfound(); if (unfound) out << " u=" << unfound; } @@ -6890,7 +6891,7 @@ boost::statechart::result PG::RecoveryState::Active::react(const ActMap&) if (pg->cct->_conf->osd_check_for_log_corruption) pg->check_log_for_corruption(pg->osd->store); - int unfound = pg->missing_loc.num_unfound(); + uint64_t unfound = pg->missing_loc.num_unfound(); if (unfound > 0 && pg->all_unfound_are_queried_or_lost(pg->get_osdmap())) { if (pg->cct->_conf->osd_auto_mark_unfound_lost) { diff --git a/src/osd/PG.h b/src/osd/PG.h index 883af9158d1..4e30023bdbf 100644 --- a/src/osd/PG.h +++ b/src/osd/PG.h @@ -1043,7 +1043,7 @@ public: bool have_unfound() const { return missing_loc.num_unfound() > 0; } - int get_num_unfound() const { + uint64_t get_num_unfound() const { return missing_loc.num_unfound(); } diff --git a/src/osd/PrimaryLogPG.cc b/src/osd/PrimaryLogPG.cc index 0f7c1b70035..4fc6fc3b991 100644 --- a/src/osd/PrimaryLogPG.cc +++ b/src/osd/PrimaryLogPG.cc @@ -937,7 +937,7 @@ int PrimaryLogPG::do_command( return -EROFS; } - int unfound = missing_loc.num_unfound(); + uint64_t unfound = missing_loc.num_unfound(); if (!unfound) { ss << "pg has no unfound objects"; return 0; // make command idempotent @@ -9931,7 +9931,7 @@ void PrimaryLogPG::mark_all_unfound_lost( ObcLockManager manager; eversion_t v = get_next_version(); v.epoch = get_osdmap()->get_epoch(); - unsigned num_unfound = missing_loc.num_unfound(); + uint64_t num_unfound = missing_loc.num_unfound(); while (m != mend) { const hobject_t &oid(m->first); if (!missing_loc.is_unfound(oid)) { @@ -10501,8 +10501,8 @@ bool PrimaryLogPG::start_recovery_ops( const pg_missing_t &missing = pg_log.get_missing(); - int num_missing = missing.num_missing(); - int num_unfound = get_num_unfound(); + unsigned int num_missing = missing.num_missing(); + uint64_t num_unfound = get_num_unfound(); if (num_missing == 0) { info.last_complete = info.last_update;