Skip to content

Commit

Permalink
Merge pull request ceph#12669 from hjwsm1989/unfound-objects
Browse files Browse the repository at this point in the history
osd/PG: fix possible overflow on unfound objects

Reviewed-by: xie xingguo <[email protected]>
  • Loading branch information
liewegas committed May 2, 2017
2 parents 5610444 + 9bad74f commit 94a8730
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
11 changes: 6 additions & 5 deletions src/osd/PG.cc
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,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, ctx->handle);
if (found_missing && num_unfound_before != missing_loc.num_unfound())
Expand Down Expand Up @@ -604,11 +604,12 @@ bool PG::MissingLoc::add_source_info(
void PG::discover_all_missing(map<int, map<spg_t,pg_query_t> > &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<pg_shard_t>::const_iterator m = might_have_unfound.begin();
Expand Down Expand Up @@ -5422,7 +5423,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;
}
Expand Down Expand Up @@ -6995,7 +6996,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) {
Expand Down
2 changes: 1 addition & 1 deletion src/osd/PG.h
Original file line number Diff line number Diff line change
Expand Up @@ -1060,7 +1060,7 @@ class PG : public DoutPrefixProvider {
bool have_unfound() const {
return missing_loc.have_unfound();
}
int get_num_unfound() const {
uint64_t get_num_unfound() const {
return missing_loc.num_unfound();
}

Expand Down
8 changes: 4 additions & 4 deletions src/osd/PrimaryLogPG.cc
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,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
Expand Down Expand Up @@ -10030,7 +10030,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)) {
Expand Down Expand Up @@ -10600,8 +10600,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;
Expand Down

0 comments on commit 94a8730

Please sign in to comment.