]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/PG: fix possible overflow on unfound objects 12669/head
authorhuangjun <hjwsm1989@gmail.com>
Mon, 26 Dec 2016 15:45:45 +0000 (23:45 +0800)
committerhuangjun <hjwsm1989@gmail.com>
Wed, 28 Dec 2016 01:11:36 +0000 (09:11 +0800)
Signed-off-by: huangjun <hjwsm1989@gmail.com>
src/osd/PG.cc
src/osd/PG.h
src/osd/PrimaryLogPG.cc

index 9b49fe84dcba9347f48ecb69afe2c3d07b712986..9661594fb1c56a8d69afd6a007e000c9aa26fdbc 100644 (file)
@@ -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<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();
@@ -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) {
index 883af9158d1b351c8d1472e88f32a7e823b7a42e..4e30023bdbf290e09e5d793528d5da36d9d6c37c 100644 (file)
@@ -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();
   }
 
index 0f7c1b70035c025071b85a9dee72e9505f76ae4c..4fc6fc3b9918c7e3d0abebec46edc9dc86832c29 100644 (file)
@@ -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;