]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: explicit shard_id_t() and NO_SHARD
authorLoic Dachary <loic@dachary.org>
Wed, 28 May 2014 13:43:32 +0000 (15:43 +0200)
committerLoic Dachary <loic@dachary.org>
Thu, 29 May 2014 21:20:53 +0000 (23:20 +0200)
Whenever an integer needs to be converted in a shard_id_t,
replace the implicit conversion with an explicit call to the
constructor.

Replace all ghobject_t::NO_SHARD and ghobject_t::no_shard() with
shard_id_t::NO_SHARD

Signed-off-by: Loic Dachary <loic@dachary.org>
36 files changed:
src/common/hobject.cc
src/common/hobject.h
src/messages/MBackfillReserve.h
src/messages/MOSDPGBackfill.h
src/messages/MOSDPGLog.h
src/messages/MOSDPGPull.h
src/messages/MOSDPGPush.h
src/messages/MOSDPGPushReply.h
src/messages/MOSDPGQuery.h
src/messages/MOSDPGRemove.h
src/messages/MOSDPGScan.h
src/messages/MOSDPGTrim.h
src/messages/MOSDRepScrub.h
src/messages/MOSDSubOp.h
src/messages/MOSDSubOpReply.h
src/messages/MRecoveryReserve.h
src/os/DBObjectMap.cc
src/os/FileStore.cc
src/os/GenericObjectMap.cc
src/os/LFNIndex.cc
src/os/ObjectStore.h
src/osd/ECBackend.cc
src/osd/ECMsgTypes.cc
src/osd/OSD.cc
src/osd/OSDMap.h
src/osd/PG.cc
src/osd/PG.h
src/osd/ReplicatedBackend.cc
src/osd/SnapMapper.h
src/osd/osd_types.cc
src/osd/osd_types.h
src/test/ObjectMap/test_object_map.cc
src/test/os/TestLFNIndex.cc
src/test/osd/TestPGLog.cc
src/test/test_snap_mapper.cc
src/tools/ceph_filestore_dump.cc

index ecc8cfde4d715170a6df6c3a06657bf6a343729a..ed439fb06247a57b5d2f5a09788bf85704e18618 100644 (file)
@@ -230,7 +230,7 @@ void ghobject_t::decode(bufferlist::iterator& bl)
     ::decode(shard_id, bl);
   } else {
     generation = ghobject_t::NO_GEN;
-    shard_id = ghobject_t::NO_SHARD;
+    shard_id = shard_id_t::NO_SHARD;
   }
   DECODE_FINISH(bl);
 }
@@ -252,29 +252,29 @@ void ghobject_t::generate_test_instances(list<ghobject_t*>& o)
   o.push_back(new ghobject_t(hobject_t(object_t("oname"), string(), 1, 234, -1, "")));
 
   o.push_back(new ghobject_t(hobject_t(object_t("oname2"), string("okey"), CEPH_NOSNAP,
-       67, 0, "n1"), 1, 0));
+        67, 0, "n1"), 1, shard_id_t(0)));
   o.push_back(new ghobject_t(hobject_t(object_t("oname2"), string("okey"), CEPH_NOSNAP,
-       67, 0, "n1"), 1, 1));
+        67, 0, "n1"), 1, shard_id_t(1)));
   o.push_back(new ghobject_t(hobject_t(object_t("oname2"), string("okey"), CEPH_NOSNAP,
-       67, 0, "n1"), 1, 2));
+        67, 0, "n1"), 1, shard_id_t(2)));
   o.push_back(new ghobject_t(hobject_t(object_t("oname3"), string("oname3"),
-       CEPH_SNAPDIR, 910, 1, "n2"), 1, 0));
+        CEPH_SNAPDIR, 910, 1, "n2"), 1, shard_id_t(0)));
   o.push_back(new ghobject_t(hobject_t(object_t("oname3"), string("oname3"),
-       CEPH_SNAPDIR, 910, 1, "n2"), 2, 0));
+        CEPH_SNAPDIR, 910, 1, "n2"), 2, shard_id_t(0)));
   o.push_back(new ghobject_t(hobject_t(object_t("oname3"), string("oname3"),
-       CEPH_SNAPDIR, 910, 1, "n2"), 3, 0));
+        CEPH_SNAPDIR, 910, 1, "n2"), 3, shard_id_t(0)));
   o.push_back(new ghobject_t(hobject_t(object_t("oname3"), string("oname3"),
-       CEPH_SNAPDIR, 910, 1, "n2"), 3, 1));
+        CEPH_SNAPDIR, 910, 1, "n2"), 3, shard_id_t(1)));
   o.push_back(new ghobject_t(hobject_t(object_t("oname3"), string("oname3"),
-       CEPH_SNAPDIR, 910, 1, "n2"), 3, 2));
+        CEPH_SNAPDIR, 910, 1, "n2"), 3, shard_id_t(2)));
 }
 
 ostream& operator<<(ostream& out, const ghobject_t& o)
 {
   out << o.hobj;
   if (o.generation != ghobject_t::NO_GEN ||
-      o.shard_id != ghobject_t::NO_SHARD) {
-    assert(o.shard_id != ghobject_t::NO_SHARD);
+      o.shard_id != shard_id_t::NO_SHARD) {
+    assert(o.shard_id != shard_id_t::NO_SHARD);
     out << "/" << o.generation << "/" << (unsigned)(o.shard_id);
   }
   return out;
index f911e6e08f32a8b94471e49fc2225dee741f5628..831228007f2552950bf681b7ed85c5562be72dca 100644 (file)
@@ -269,7 +269,7 @@ public:
   }
 
   bool is_degenerate() const {
-    return generation == NO_GEN && shard_id == NO_SHARD;
+    return generation == NO_GEN && shard_id == shard_id_t::NO_SHARD;
   }
 
   bool is_no_gen() const {
@@ -277,7 +277,7 @@ public:
   }
 
   bool is_no_shard() const {
-    return shard_id == NO_SHARD;
+    return shard_id == shard_id_t::NO_SHARD;
   }
 
   // maximum sorted value.
index d30e285cc5dcb34bfc9c27397dadb20373b380a3..8cf184e72a8d95f85db4b3e00245953b4028f567 100644 (file)
@@ -75,7 +75,7 @@ public:
     if (header.version >= 3)
       ::decode(pgid.shard, p);
     else
-      pgid.shard = ghobject_t::no_shard();
+      pgid.shard = shard_id_t::NO_SHARD;
 
   }
 
index e9ec661cbb5d873668a2b25587982231821decae..d4b65e82c298087242cc6d2e3e63c46598cbbe8f 100644 (file)
@@ -67,7 +67,7 @@ public:
     if (header.version >= 3)
       ::decode(pgid.shard, p);
     else
-      pgid.shard = ghobject_t::no_shard();
+      pgid.shard = shard_id_t::NO_SHARD;
   }
 
   virtual void encode_payload(uint64_t features) {
index 44cd98962b87001cbb9a739eb79d174511a63f39..741b14170a107b49926195b777be8a60cee9fa2f 100644 (file)
@@ -92,8 +92,8 @@ public:
       ::decode(to, p);
       ::decode(from, p);
     } else {
-      to = ghobject_t::NO_SHARD;
-      from = ghobject_t::NO_SHARD;
+      to = shard_id_t::NO_SHARD;
+      from = shard_id_t::NO_SHARD;
     }
   }
 };
index 91072320fe677994127510fbbe9703f5747e0699..51ea56a67672f188b3fe1bfd5ea8d54cf6474976 100644 (file)
@@ -58,8 +58,8 @@ public:
       ::decode(pgid.shard, p);
       ::decode(from, p);
     } else {
-      pgid.shard = ghobject_t::NO_SHARD;
-      from = pg_shard_t(get_source().num(), ghobject_t::NO_SHARD);
+      pgid.shard = shard_id_t::NO_SHARD;
+      from = pg_shard_t(get_source().num(), shard_id_t::NO_SHARD);
     }
   }
 
index 46a8f1becd44afc3a1fc6154b55bce6aa0d0326e..83bb184999aa13ce265bf40bf66e6848f6cc0e69 100644 (file)
@@ -58,8 +58,8 @@ public:
       ::decode(pgid.shard, p);
       ::decode(from, p);
     } else {
-      pgid.shard = ghobject_t::NO_SHARD;
-      from = pg_shard_t(get_source().num(), ghobject_t::NO_SHARD);
+      pgid.shard = shard_id_t::NO_SHARD;
+      from = pg_shard_t(get_source().num(), shard_id_t::NO_SHARD);
     }
   }
 
index 1875235dbb7d480249fbfc46996b8d240cf5d00e..793709e1650d1df3e0cb1bf148c9b46d09f52cf2 100644 (file)
@@ -58,8 +58,8 @@ public:
       ::decode(pgid.shard, p);
       ::decode(from, p);
     } else {
-      pgid.shard = ghobject_t::NO_SHARD;
-      from = pg_shard_t(get_source().num(), ghobject_t::NO_SHARD);
+      pgid.shard = shard_id_t::NO_SHARD;
+      from = pg_shard_t(get_source().num(), shard_id_t::NO_SHARD);
     }
   }
 
index c2c6f695d39ab4b6fdf710ecf5dfabe8f7e2e2ce..81a55c24f13b2c0f154c147ad8510783dbe19427 100644 (file)
@@ -78,7 +78,7 @@ public:
     ::decode(epoch, p);
     vector<pair<pg_t, pg_query_t> > _pg_list;
     ::decode(_pg_list, p);
-    vector<shard_id_t> _shard_list(_pg_list.size(), ghobject_t::no_shard());
+    vector<shard_id_t> _shard_list(_pg_list.size(), shard_id_t::NO_SHARD);
     if (header.version >= 3) {
       _shard_list.clear();
       ::decode(_shard_list, p);
index b55b5d28182decff44141487a763447eb595fa13..ca021fd7edecc7cb9ad516c3538473e91acce3e5 100644 (file)
@@ -65,7 +65,7 @@ public:
     vector<pg_t> _pg_list;
     ::decode(_pg_list, p);
 
-    vector<shard_id_t> _shard_list(_pg_list.size(), ghobject_t::no_shard());
+    vector<shard_id_t> _shard_list(_pg_list.size(), shard_id_t::NO_SHARD);
     if (header.version >= 2) {
       _shard_list.clear();
       ::decode(_shard_list, p);
index 2c0c1ad7abc8a4b30f2152d0f78357edec401218..f5fe18e523b710d28741fa404901c211044d9417 100644 (file)
@@ -63,8 +63,8 @@ public:
     } else {
       from = pg_shard_t(
        get_source().num(),
-       ghobject_t::NO_SHARD);
-      pgid.shard = ghobject_t::NO_SHARD;
+       shard_id_t::NO_SHARD);
+      pgid.shard = shard_id_t::NO_SHARD;
     }
   }
 
index 12a0e7c824037bf448d98a4f33ec72b753054fe3..29c7444fedf9643be6d528d87783f72c108f6df7 100644 (file)
@@ -56,7 +56,7 @@ public:
     if (header.version >= 2)
       ::decode(pgid.shard, p);
     else
-      pgid.shard = ghobject_t::no_shard();
+      pgid.shard = shard_id_t::NO_SHARD;
   }
 };
 
index 3f67021ef14c128d87566b5cce184757246bfbcd..52a03b8491097b0da6d89dbd6fa781c39aaa23c3 100644 (file)
@@ -112,7 +112,7 @@ public:
     if (header.version >= 5) {
       ::decode(pgid.shard, p);
     } else {
-      pgid.shard = ghobject_t::no_shard();
+      pgid.shard = shard_id_t::NO_SHARD;
     }
   }
 };
index 6a381861d613ee2dc2e0d521aa866743c29e7565..dafc9f074fe113ff722775ce1f3e35d9e3fa0019 100644 (file)
@@ -169,8 +169,8 @@ public:
     } else {
       from = pg_shard_t(
        get_source().num(),
-       ghobject_t::NO_SHARD);
-      pgid.shard = ghobject_t::NO_SHARD;
+       shard_id_t::NO_SHARD);
+      pgid.shard = shard_id_t::NO_SHARD;
     }
     if (header.version >= 10) {
       ::decode(updated_hit_set_history, p);
index 270629f91f3d1daf0af5ff6c509fd0659d1fc0f4..7b441ae31f48fa8597d6c2ba8825b5bd090521ed 100644 (file)
@@ -81,8 +81,8 @@ public:
     } else {
       from = pg_shard_t(
        get_source().num(),
-       ghobject_t::NO_SHARD);
-      pgid.shard = ghobject_t::NO_SHARD;
+       shard_id_t::NO_SHARD);
+      pgid.shard = shard_id_t::NO_SHARD;
     }
   }
   virtual void encode_payload(uint64_t features) {
index 2a88bfdeb9f3bdd6ba4c317c274ae7b64aba67fe..29f1732aaca37c6ebd06838d757ed169ad054a42 100644 (file)
@@ -69,7 +69,7 @@ public:
     if (header.version >= 2)
       ::decode(pgid.shard, p);
     else
-      pgid.shard = ghobject_t::no_shard();
+      pgid.shard = shard_id_t::NO_SHARD;
   }
 
   void encode_payload(uint64_t features) {
index 5d2a2e616242c0f67224febae08b87b06c9d9927..7f26c0e08716e367818ea8184ed4fd81924f635b 100644 (file)
@@ -157,7 +157,7 @@ string DBObjectMap::ghobject_key(const ghobject_t &oid)
   snprintf(t, end - t, ".%.*X", (int)(sizeof(oid.hobj.hash)*2), oid.hobj.hash);
 
   if (oid.generation != ghobject_t::NO_GEN ||
-      oid.shard_id != ghobject_t::NO_SHARD) {
+      oid.shard_id != shard_id_t::NO_SHARD) {
     t += snprintf(t, end - t, ".%llx", (long long unsigned)oid.generation);
     t += snprintf(t, end - t, ".%x", (int)oid.shard_id);
   }
index 092ad22cd849da94edfc474480fd71859f1b579b..466a4dea1f47bc7698a39e25d7a030a4a24d0bb5 100644 (file)
@@ -219,7 +219,7 @@ int FileStore::lfn_open(coll_t cid,
                        Index *index) 
 {
   assert(get_allow_sharded_objects() ||
-        ( oid.shard_id == ghobject_t::NO_SHARD &&
+        ( oid.shard_id == shard_id_t::NO_SHARD &&
           oid.generation == ghobject_t::NO_GEN ));
   assert(outfd);
   int flags = O_RDWR;
index 4d41c50ae3a59026679a9d8498bea7432cd127a3..0d6c029d0b9f1763339c81b20e19a452fcc5b7a5 100644 (file)
@@ -145,7 +145,7 @@ string GenericObjectMap::header_key(const coll_t &cid, const ghobject_t &oid)
   full_name += string(buf);
 
   if (oid.generation != ghobject_t::NO_GEN) {
-    assert(oid.shard_id != ghobject_t::NO_SHARD);
+    assert(oid.shard_id != shard_id_t::NO_SHARD);
     full_name.append(GHOBJECT_KEY_SEP_S);
 
     t = buf;
@@ -175,7 +175,7 @@ bool GenericObjectMap::parse_header_key(const string &long_name,
   snapid_t snap;
   uint64_t pool;
   gen_t generation = ghobject_t::NO_GEN;
-  shard_t shard_id = ghobject_t::NO_SHARD;
+  shard_id_t shard_id = shard_id_t::NO_SHARD;
 
   string::const_iterator current = long_name.begin();
   string::const_iterator end;
index a460e5cdb3058157b1ff0c2e730b8a16886245c0..ef3945808bf9bd2895ad72e6a888cdde21024427 100644 (file)
@@ -662,7 +662,7 @@ string LFNIndex::lfn_generate_object_name(const ghobject_t &oid)
   full_name += string(buf);
 
   if (oid.generation != ghobject_t::NO_GEN ||
-      oid.shard_id != ghobject_t::NO_SHARD) {
+      oid.shard_id != shard_id_t::NO_SHARD) {
     full_name.append("_");
 
     t = buf;
index 078e40f547983171a8010b8e32aa392007df2b6f..080737bd3bf4c28eafcf4553d029e85857611d77 100644 (file)
@@ -554,7 +554,7 @@ public:
          oid.hobj.snap = soid.snap;
          oid.hobj.oid = soid.oid;
          oid.generation = ghobject_t::NO_GEN;
-         oid.shard_id = ghobject_t::NO_SHARD;
+         oid.shard_id = shard_id_t::NO_SHARD;
        } else {
          ::decode(oid, p);
          if (use_pool_override && pool_override != -1 &&
index 5ca66cb4553e83edd75c88da3b7574084a4e4a35..754137b2ef64f7ab14191dca81c11990d1b45715 100644 (file)
@@ -1346,8 +1346,8 @@ int ECBackend::get_min_avail_to_read_shards(
   for (set<int>::iterator i = need.begin();
        i != need.end();
        ++i) {
-    assert(shards.count(*i));
-    to_read->insert(shards[*i]);
+    assert(shards.count(shard_id_t(*i)));
+    to_read->insert(shards[shard_id_t(*i)]);
   }
   return 0;
 }
index 4e4c8e3d94237207cff7c3d83aefaaf49ff2a5ff..10c492d24731342ad2dcf8fabf3bee2705d6f2e8 100644 (file)
@@ -210,14 +210,14 @@ void ECSubRead::generate_test_instances(list<ECSubRead*>& o)
   hobject_t hoid1(sobject_t("asdf", 1));
   hobject_t hoid2(sobject_t("asdf2", CEPH_NOSNAP));
   o.push_back(new ECSubRead());
-  o.back()->from = pg_shard_t(2, 255);
+  o.back()->from = pg_shard_t(2, shard_id_t(255));
   o.back()->tid = 1;
   o.back()->to_read[hoid1].push_back(make_pair(100, 200));
   o.back()->to_read[hoid1].push_back(make_pair(400, 600));
   o.back()->to_read[hoid2].push_back(make_pair(400, 600));
   o.back()->attrs_to_read.insert(hoid1);
   o.push_back(new ECSubRead());
-  o.back()->from = pg_shard_t(2, 255);
+  o.back()->from = pg_shard_t(2, shard_id_t(255));
   o.back()->tid = 300;
   o.back()->to_read[hoid1].push_back(make_pair(300, 200));
   o.back()->to_read[hoid2].push_back(make_pair(400, 600));
@@ -324,7 +324,7 @@ void ECSubReadReply::generate_test_instances(list<ECSubReadReply*>& o)
   bufferlist bl2;
   bl2.append_zero(200);
   o.push_back(new ECSubReadReply());
-  o.back()->from = pg_shard_t(2, 255);
+  o.back()->from = pg_shard_t(2, shard_id_t(255));
   o.back()->tid = 1;
   o.back()->buffers_read[hoid1].push_back(make_pair(20, bl));
   o.back()->buffers_read[hoid1].push_back(make_pair(2000, bl2));
@@ -332,7 +332,7 @@ void ECSubReadReply::generate_test_instances(list<ECSubReadReply*>& o)
   o.back()->attrs_read[hoid1]["foo"] = bl;
   o.back()->attrs_read[hoid1]["_"] = bl2;
   o.push_back(new ECSubReadReply());
-  o.back()->from = pg_shard_t(2, 255);
+  o.back()->from = pg_shard_t(2, shard_id_t(255));
   o.back()->tid = 300;
   o.back()->buffers_read[hoid2].push_back(make_pair(0, bl2));
   o.back()->attrs_read[hoid2]["foo"] = bl;
index 1e20a7804594c143d77ecab277383872357ee734..e13c1e1dc22ea7ce8e6dd4e4de0704820192b215 100644 (file)
@@ -2568,7 +2568,7 @@ void OSD::calc_priors_during(
          pset.insert(
            pg_shard_t(
              acting[i],
-             osdmap->pg_is_ec(pgid.pgid) ? i : ghobject_t::NO_SHARD));
+             osdmap->pg_is_ec(pgid.pgid) ? shard_id_t(i) : shard_id_t::NO_SHARD));
        }
        up++;
       }
@@ -2579,7 +2579,7 @@ void OSD::calc_priors_during(
          pset.insert(
            pg_shard_t(
              acting[i],
-             osdmap->pg_is_ec(pgid.pgid) ? i : ghobject_t::NO_SHARD));
+             osdmap->pg_is_ec(pgid.pgid) ? shard_id_t(i) : shard_id_t::NO_SHARD));
     }
   }
   dout(10) << "calc_priors_during " << pgid
@@ -3424,7 +3424,7 @@ void TestOpsSocketHook::test_ops(OSDService *service, ObjectStore *store,
       ss << "Must not call on ec pool";
       return;
     }
-    spg_t pgid = spg_t(curmap->raw_pg_to_pg(rawpg), ghobject_t::no_shard());
+    spg_t pgid = spg_t(curmap->raw_pg_to_pg(rawpg), shard_id_t::NO_SHARD);
 
     hobject_t obj(object_t(objname), string(""), CEPH_NOSNAP, rawpg.ps(), pool, nspace);
     ObjectStore::Transaction t;
@@ -6791,7 +6791,7 @@ bool OSD::compat_must_dispatch_immediately(PG *pg)
       tmpacting.insert(
        pg_shard_t(
          pg->acting[i],
-         pg->pool.info.ec_pool() ? i : ghobject_t::NO_SHARD));
+         pg->pool.info.ec_pool() ? shard_id_t(i) : shard_id_t::NO_SHARD));
     }
   }
 
index f1b0d6d3a47abb26bf73e227038bd6a64695425f..e5ffc0e1c733e42b9ff1fd432159cd1608ae5811 100644 (file)
@@ -677,7 +677,7 @@ public:
     if (i->second.ec_pool()) {
       for (uint8_t i = 0; i < acting.size(); ++i) {
        if (acting[i] == primary) {
-         *out = spg_t(pgid, i);
+         *out = spg_t(pgid, shard_id_t(i));
          return true;
        }
       }
index 579c9153fdee5e449b6c360039798f5160c49fc9..42f9aea26fe210b2d0296ad849e496da534766f5 100644 (file)
@@ -956,30 +956,30 @@ void PG::calc_ec_acting(
   for (uint8_t i = 0; i < want.size(); ++i) {
     ss << "For position " << (unsigned)i << ": ";
     if (up.size() > (unsigned)i && up[i] != CRUSH_ITEM_NONE &&
-       !all_info.find(pg_shard_t(up[i], i))->second.is_incomplete() &&
-       all_info.find(pg_shard_t(up[i], i))->second.last_update >=
+       !all_info.find(pg_shard_t(up[i], shard_id_t(i)))->second.is_incomplete() &&
+       all_info.find(pg_shard_t(up[i], shard_id_t(i)))->second.last_update >=
        auth_log_shard->second.log_tail) {
-      ss << " selecting up[i]: " << pg_shard_t(up[i], i) << std::endl;
+      ss << " selecting up[i]: " << pg_shard_t(up[i], shard_id_t(i)) << std::endl;
       want[i] = up[i];
       ++usable;
       continue;
     }
     if (up.size() > (unsigned)i && up[i] != CRUSH_ITEM_NONE) {
-      ss << " backfilling up[i]: " << pg_shard_t(up[i], i)
+      ss << " backfilling up[i]: " << pg_shard_t(up[i], shard_id_t(i))
         << " and ";
-      backfill->insert(pg_shard_t(up[i], i));
+      backfill->insert(pg_shard_t(up[i], shard_id_t(i)));
     }
 
     if (acting.size() > (unsigned)i && acting[i] != CRUSH_ITEM_NONE &&
-       !all_info.find(pg_shard_t(acting[i], i))->second.is_incomplete() &&
-       all_info.find(pg_shard_t(acting[i], i))->second.last_update >=
+       !all_info.find(pg_shard_t(acting[i], shard_id_t(i)))->second.is_incomplete() &&
+       all_info.find(pg_shard_t(acting[i], shard_id_t(i)))->second.last_update >=
        auth_log_shard->second.log_tail) {
-      ss << " selecting acting[i]: " << pg_shard_t(acting[i], i) << std::endl;
+      ss << " selecting acting[i]: " << pg_shard_t(acting[i], shard_id_t(i)) << std::endl;
       want[i] = acting[i];
       ++usable;
     } else {
-      for (set<pg_shard_t>::iterator j = all_info_by_shard[i].begin();
-          j != all_info_by_shard[i].end();
+      for (set<pg_shard_t>::iterator j = all_info_by_shard[shard_id_t(i)].begin();
+          j != all_info_by_shard[shard_id_t(i)].end();
           ++j) {
        assert(j->shard == i);
        if (!all_info.find(*j)->second.is_incomplete() &&
@@ -999,9 +999,9 @@ void PG::calc_ec_acting(
   bool found_primary = false;
   for (uint8_t i = 0; i < want.size(); ++i) {
     if (want[i] != CRUSH_ITEM_NONE) {
-      acting_backfill->insert(pg_shard_t(want[i], i));
+      acting_backfill->insert(pg_shard_t(want[i], shard_id_t(i)));
       if (!found_primary) {
-       *want_primary = pg_shard_t(want[i], i);
+       *want_primary = pg_shard_t(want[i], shard_id_t(i));
        found_primary = true;
       }
     }
@@ -1063,7 +1063,7 @@ void PG::calc_replicated_acting(
   for (vector<int>::const_iterator i = up.begin();
        i != up.end();
        ++i) {
-    pg_shard_t up_cand = pg_shard_t(*i, ghobject_t::no_shard());
+    pg_shard_t up_cand = pg_shard_t(*i, shard_id_t::NO_SHARD);
     if (up_cand == primary->first)
       continue;
     const pg_info_t &cur_info = all_info.find(up_cand)->second;
@@ -1099,7 +1099,7 @@ void PG::calc_replicated_acting(
   for (vector<int>::const_iterator i = acting.begin();
        i != acting.end();
        ++i) {
-    pg_shard_t acting_cand(*i, ghobject_t::no_shard());
+    pg_shard_t acting_cand(*i, shard_id_t::NO_SHARD);
     if (usable >= size)
       break;
 
@@ -1285,7 +1285,7 @@ bool PG::choose_acting(pg_shard_t &auth_log_shard_id)
       have.insert(
        pg_shard_t(
          want[i],
-         pool.info.ec_pool() ? i : ghobject_t::NO_SHARD));
+         pool.info.ec_pool() ? shard_id_t(i) : shard_id_t::NO_SHARD));
   }
   if (!(*recoverable_predicate)(have)) {
     want_acting.clear();
@@ -1370,7 +1370,7 @@ void PG::build_might_have_unfound()
     std::vector<int>::const_iterator a = interval.acting.begin();
     std::vector<int>::const_iterator a_end = interval.acting.end();
     for (; a != a_end; ++a, ++i) {
-      pg_shard_t shard(*a, pool.info.ec_pool() ? i : ghobject_t::NO_SHARD);
+      pg_shard_t shard(*a, pool.info.ec_pool() ? shard_id_t(i) : shard_id_t::NO_SHARD);
       if (*a != CRUSH_ITEM_NONE && shard != pg_whoami)
        might_have_unfound.insert(shard);
     }
@@ -6570,7 +6570,7 @@ boost::statechart::result PG::RecoveryState::GetInfo::react(const MNotifyRec& in
            int o = interval.acting[i];
            if (o == CRUSH_ITEM_NONE)
              continue;
-           pg_shard_t so(o, pg->pool.info.ec_pool() ? i : ghobject_t::NO_SHARD);
+           pg_shard_t so(o, pg->pool.info.ec_pool() ? shard_id_t(i) : shard_id_t::NO_SHARD);
            if (!osdmap->exists(o) || osdmap->get_info(o).lost_at > interval.first)
              continue;  // dne or lost
            if (osdmap->is_up(o)) {
@@ -7133,13 +7133,13 @@ PG::PriorSet::PriorSet(bool ec_pool,
   // sending them any new info/logs/whatever.
   for (unsigned i=0; i<acting.size(); i++) {
     if (acting[i] != CRUSH_ITEM_NONE)
-      probe.insert(pg_shard_t(acting[i], ec_pool ? i : ghobject_t::NO_SHARD));
+      probe.insert(pg_shard_t(acting[i], ec_pool ? shard_id_t(i) : shard_id_t::NO_SHARD));
   }
   // It may be possible to exlude the up nodes, but let's keep them in
   // there for now.
   for (unsigned i=0; i<up.size(); i++) {
     if (up[i] != CRUSH_ITEM_NONE)
-      probe.insert(pg_shard_t(up[i], ec_pool ? i : ghobject_t::NO_SHARD));
+      probe.insert(pg_shard_t(up[i], ec_pool ? shard_id_t(i) : shard_id_t::NO_SHARD));
   }
 
   for (map<epoch_t,pg_interval_t>::const_reverse_iterator p = past_intervals.rbegin();
@@ -7168,7 +7168,7 @@ PG::PriorSet::PriorSet(bool ec_pool,
       int o = interval.acting[i];
       if (o == CRUSH_ITEM_NONE)
        continue;
-      pg_shard_t so(o, ec_pool ? i : ghobject_t::NO_SHARD);
+      pg_shard_t so(o, ec_pool ? shard_id_t(i) : shard_id_t::NO_SHARD);
 
       const osd_info_t *pinfo = 0;
       if (osdmap.exists(o))
index 8294d08d84efc0fa7bbd89475c79dd619a133530..9b03f661fffb31325c694e799f06e161cf06e285 100644 (file)
@@ -1894,25 +1894,25 @@ public:
        actingset.insert(
          pg_shard_t(
            acting[i],
-           pool.info.ec_pool() ? i : ghobject_t::NO_SHARD));
+           pool.info.ec_pool() ? shard_id_t(i) : shard_id_t::NO_SHARD));
     }
     up = newup;
     if (!pool.info.ec_pool()) {
-      up_primary = pg_shard_t(new_up_primary, ghobject_t::no_shard());
-      primary = pg_shard_t(new_acting_primary, ghobject_t::no_shard());
+      up_primary = pg_shard_t(new_up_primary, shard_id_t::NO_SHARD);
+      primary = pg_shard_t(new_acting_primary, shard_id_t::NO_SHARD);
       return;
     }
     up_primary = pg_shard_t();
     primary = pg_shard_t();
     for (uint8_t i = 0; i < up.size(); ++i) {
       if (up[i] == new_up_primary) {
-       up_primary = pg_shard_t(up[i], i);
+       up_primary = pg_shard_t(up[i], shard_id_t(i));
        break;
       }
     }
     for (uint8_t i = 0; i < acting.size(); ++i) {
       if (acting[i] == new_acting_primary) {
-       primary = pg_shard_t(acting[i], i);
+       primary = pg_shard_t(acting[i], shard_id_t(i));
        break;
       }
     }
index 0763c7f740a59e2eba525274a30ddf1e2e915ae4..468ca418e41673bb0dbbf2b32058d0663a926a7c 100644 (file)
@@ -329,7 +329,7 @@ public:
     version_t former_version) {
     t->collection_move_rename(
       coll, hoid, coll,
-      ghobject_t(hoid, former_version, ghobject_t::NO_SHARD));
+      ghobject_t(hoid, former_version, shard_id_t::NO_SHARD));
   }
   void setattrs(
     const hobject_t &hoid,
index d597a6b6cfd15c877a3073d52dcaeec7de193473..deb6868b30d034db0471bc751e524e05641400fe 100644 (file)
@@ -151,7 +151,7 @@ private:
 
 public:
   static string make_shard_prefix(shard_id_t shard) {
-    if (shard == ghobject_t::NO_SHARD)
+    if (shard == shard_id_t::NO_SHARD)
       return string();
     char buf[20];
     int r = snprintf(buf, sizeof(buf), ".%x", (int)shard);
index 4d48325cdea4ca6559910ee82a362e9ceeea6397..319d2acc9e92cc1252a7b1b438931f79df041a7d 100644 (file)
@@ -86,7 +86,7 @@ ostream &operator<<(ostream &lhs, const pg_shard_t &rhs)
 {
   if (rhs.is_undefined())
     return lhs << "?";
-  if (rhs.shard == ghobject_t::NO_SHARD)
+  if (rhs.shard == shard_id_t::NO_SHARD)
     return lhs << rhs.osd;
   return lhs << rhs.osd << '(' << (unsigned)(rhs.shard) << ')';
 }
@@ -354,7 +354,7 @@ bool pg_t::parse(const char *s)
 bool spg_t::parse(const char *s)
 {
   pgid.set_preferred(-1);
-  shard = ghobject_t::NO_SHARD;
+  shard = shard_id_t::NO_SHARD;
   uint64_t ppool;
   uint32_t pseed;
   int32_t pref;
@@ -379,7 +379,7 @@ bool spg_t::parse(const char *s)
   if (p) {
     r = sscanf(p, "s%d", &pshard);
     if (r == 1) {
-      shard = pshard;
+      shard = shard_id_t(pshard);
     } else {
       return false;
     }
@@ -2013,7 +2013,7 @@ void pg_info_t::decode(bufferlist::iterator &bl)
   if (struct_v >= 30)
     ::decode(pgid.shard, bl);
   else
-    pgid.shard = ghobject_t::no_shard();
+    pgid.shard = shard_id_t::NO_SHARD;
   DECODE_FINISH(bl);
 }
 
@@ -2052,7 +2052,7 @@ void pg_info_t::generate_test_instances(list<pg_info_t*>& o)
   list<pg_history_t*> h;
   pg_history_t::generate_test_instances(h);
   o.back()->history = *h.back();
-  o.back()->pgid = spg_t(pg_t(1, 2, -1), ghobject_t::no_shard());
+  o.back()->pgid = spg_t(pg_t(1, 2, -1), shard_id_t::NO_SHARD);
   o.back()->last_update = eversion_t(3, 4);
   o.back()->last_complete = eversion_t(5, 6);
   o.back()->last_user_version = 2;
@@ -2092,8 +2092,8 @@ void pg_notify_t::decode(bufferlist::iterator &bl)
     ::decode(to, bl);
     ::decode(from, bl);
   } else {
-    to = ghobject_t::NO_SHARD;
-    from = ghobject_t::NO_SHARD;
+    to = shard_id_t::NO_SHARD;
+    from = shard_id_t::NO_SHARD;
   }
   DECODE_FINISH(bl);
 }
@@ -2113,8 +2113,8 @@ void pg_notify_t::dump(Formatter *f) const
 
 void pg_notify_t::generate_test_instances(list<pg_notify_t*>& o)
 {
-  o.push_back(new pg_notify_t(3, ghobject_t::NO_SHARD, 1 ,1 , pg_info_t()));
-  o.push_back(new pg_notify_t(0, 0, 3, 10, pg_info_t()));
+  o.push_back(new pg_notify_t(shard_id_t(3), shard_id_t::NO_SHARD, 1, 1, pg_info_t()));
+  o.push_back(new pg_notify_t(shard_id_t(0), shard_id_t(0), 3, 10, pg_info_t()));
 }
 
 ostream &operator<<(ostream &lhs, const pg_notify_t &notify)
@@ -2122,8 +2122,8 @@ ostream &operator<<(ostream &lhs, const pg_notify_t &notify)
   lhs << "(query_epoch:" << notify.query_epoch
       << ", epoch_sent:" << notify.epoch_sent
       << ", info:" << notify.info;
-  if (notify.from != ghobject_t::NO_SHARD ||
-      notify.to != ghobject_t::NO_SHARD)
+  if (notify.from != shard_id_t::NO_SHARD ||
+      notify.to != shard_id_t::NO_SHARD)
     lhs << " " << (unsigned)notify.from
        << "->" << (unsigned)notify.to;
   return lhs << ")";
@@ -2358,8 +2358,8 @@ void pg_query_t::decode(bufferlist::iterator &bl) {
       ::decode(to, bl);
       ::decode(from, bl);
     } else {
-      to = ghobject_t::NO_SHARD;
-      from = ghobject_t::NO_SHARD;
+      to = shard_id_t::NO_SHARD;
+      from = shard_id_t::NO_SHARD;
     }
     DECODE_FINISH(bl);
   } catch (...) {
@@ -2386,12 +2386,12 @@ void pg_query_t::generate_test_instances(list<pg_query_t*>& o)
   o.push_back(new pg_query_t());
   list<pg_history_t*> h;
   pg_history_t::generate_test_instances(h);
-  o.push_back(new pg_query_t(pg_query_t::INFO, 1, 2, *h.back(), 4));
-  o.push_back(new pg_query_t(pg_query_t::MISSING, 2, 3, *h.back(), 4));
-  o.push_back(new pg_query_t(pg_query_t::LOG, 0, 0,
+  o.push_back(new pg_query_t(pg_query_t::INFO, shard_id_t(1), shard_id_t(2), *h.back(), 4));
+  o.push_back(new pg_query_t(pg_query_t::MISSING, shard_id_t(2), shard_id_t(3), *h.back(), 4));
+  o.push_back(new pg_query_t(pg_query_t::LOG, shard_id_t(0), shard_id_t(0),
                             eversion_t(4, 5), *h.back(), 4));
   o.push_back(new pg_query_t(pg_query_t::FULLLOG,
-                            ghobject_t::NO_SHARD, ghobject_t::NO_SHARD,
+                            shard_id_t::NO_SHARD, shard_id_t::NO_SHARD,
                             *h.back(), 5));
 }
 
index 8a94ca60afb6ad2dc954bcde0814dfb7d639bbe9..ead8fec6b58a41466403c36381883564c148d8f6 100644 (file)
@@ -67,11 +67,11 @@ string ceph_osd_flag_string(unsigned flags);
 struct pg_shard_t {
   int osd;
   shard_id_t shard;
-  pg_shard_t() : osd(-1), shard(ghobject_t::NO_SHARD) {}
-  explicit pg_shard_t(int osd) : osd(osd), shard(ghobject_t::NO_SHARD) {}
+  pg_shard_t() : osd(-1), shard(shard_id_t::NO_SHARD) {}
+  explicit pg_shard_t(int osd) : osd(osd), shard(shard_id_t::NO_SHARD) {}
   pg_shard_t(int osd, shard_id_t shard) : osd(osd), shard(shard) {}
   static pg_shard_t undefined_shard() {
-    return pg_shard_t(-1, ghobject_t::NO_SHARD);
+    return pg_shard_t(-1, shard_id_t::NO_SHARD);
   }
   bool is_undefined() const {
     return osd == -1;
@@ -393,9 +393,9 @@ CEPH_HASH_NAMESPACE_END
 struct spg_t {
   pg_t pgid;
   shard_id_t shard;
-  spg_t() : shard(ghobject_t::NO_SHARD) {}
+  spg_t() : shard(shard_id_t::NO_SHARD) {}
   spg_t(pg_t pgid, shard_id_t shard) : pgid(pgid), shard(shard) {}
-  explicit spg_t(pg_t pgid) : pgid(pgid), shard(ghobject_t::NO_SHARD) {}
+  explicit spg_t(pg_t pgid) : pgid(pgid), shard(shard_id_t::NO_SHARD) {}
   unsigned get_split_bits(unsigned pg_num) const {
     return pgid.get_split_bits(pg_num);
   }
@@ -427,7 +427,7 @@ struct spg_t {
     return is_split;
   }
   bool is_no_shard() const {
-    return shard == ghobject_t::NO_SHARD;
+    return shard == shard_id_t::NO_SHARD;
   }
   void encode(bufferlist &bl) const {
     ENCODE_START(1, 1, bl);
@@ -1659,8 +1659,8 @@ struct pg_notify_t {
   shard_id_t to;
   shard_id_t from;
   pg_notify_t() :
-    query_epoch(0), epoch_sent(0), to(ghobject_t::no_shard()),
-    from(ghobject_t::no_shard()) {}
+    query_epoch(0), epoch_sent(0), to(shard_id_t::NO_SHARD),
+    from(shard_id_t::NO_SHARD) {}
   pg_notify_t(
     shard_id_t to,
     shard_id_t from,
@@ -1779,8 +1779,8 @@ struct pg_query_t {
   shard_id_t to;
   shard_id_t from;
 
-  pg_query_t() : type(-1), epoch_sent(0), to(ghobject_t::NO_SHARD),
-                from(ghobject_t::NO_SHARD) {}
+  pg_query_t() : type(-1), epoch_sent(0), to(shard_id_t::NO_SHARD),
+                from(shard_id_t::NO_SHARD) {}
   pg_query_t(
     int t,
     shard_id_t to,
index 22c029fd37823c5e14bb933f520835df18f217d7..6ab3f82eb82cf81f79e6780d33ea95d298ea9e16 100644 (file)
@@ -559,7 +559,7 @@ int main(int argc, char **argv) {
 }
 
 TEST_F(ObjectMapTest, CreateOneObject) {
-  ghobject_t hoid(hobject_t(sobject_t("foo", CEPH_NOSNAP)), 100, 0);
+  ghobject_t hoid(hobject_t(sobject_t("foo", CEPH_NOSNAP)), 100, shard_id_t(0));
   map<string, bufferlist> to_set;
   string key("test");
   string val("test_val");
@@ -614,8 +614,8 @@ TEST_F(ObjectMapTest, CreateOneObject) {
 }
 
 TEST_F(ObjectMapTest, CloneOneObject) {
-  ghobject_t hoid(hobject_t(sobject_t("foo", CEPH_NOSNAP)), 200, 0);
-  ghobject_t hoid2(hobject_t(sobject_t("foo2", CEPH_NOSNAP)), 201, 1);
+  ghobject_t hoid(hobject_t(sobject_t("foo", CEPH_NOSNAP)), 200, shard_id_t(0));
+  ghobject_t hoid2(hobject_t(sobject_t("foo2", CEPH_NOSNAP)), 201, shard_id_t(1));
 
   tester.set_key(hoid, "foo", "bar");
   tester.set_key(hoid, "foo2", "bar2");
index c5853fbd7fdc473d6146c235290f9cdc2172841a..47ccf640aefae41040ce3fef9fd61770255d5002 100644 (file)
@@ -142,7 +142,7 @@ TEST_F(TestHOBJECT_WITH_POOL, generate_and_parse_name) {
   uint64_t hash = 0xABABABAB;
   uint64_t pool = 0xCDCDCDCD;
   int64_t gen = 0xefefefefef;
-  int8_t shard_id = 0xb;
+  shard_id_t shard_id(0xb);
 
   {
     std::string name(".XA/B_\\C.D");
index c2063b8911c26efce45e545baca3d82666dafe07..0d51ed9c2fb3328484d6093043ea930cdd5a3b1d 100644 (file)
@@ -213,7 +213,7 @@ public:
     bool dirty_info = false;
     bool dirty_big_info = false;
     merge_log(
-      t, oinfo, olog, pg_shard_t(1, 0), info,
+      t, oinfo, olog, pg_shard_t(1, shard_id_t(0)), info,
       &h, dirty_info, dirty_big_info);
 
     ASSERT_EQ(info.last_update, oinfo.last_update);
@@ -233,7 +233,7 @@ public:
     pg_info_t oinfo = tcase.get_divinfo();
 
     proc_replica_log(
-      t, oinfo, olog, omissing, pg_shard_t(1, 0));
+       t, oinfo, olog, omissing, pg_shard_t(1, shard_id_t(0)));
 
     if (!tcase.base.empty()) {
       ASSERT_EQ(tcase.base.rbegin()->version, oinfo.last_update);
index 04db762b1a9003d65b22cf39c7d2450dfde7103e..7f0fae39a00cbe4d66e041c5728be71b8ab4ce70 100644 (file)
@@ -453,7 +453,7 @@ public:
     uint32_t mask,
     uint32_t bits)
     : driver(driver),
-      mapper(new SnapMapper(driver, mask, bits, 0, 1)),
+      mapper(new SnapMapper(driver, mask, bits, 0, shard_id_t(1))),
              mask(mask), bits(bits),
       lock("lock") {}
 
index 4eada7fbf2c70d56f7e7cf3b562702d2b66e5e5c..7ea6395b5d8f99309e223e8ae84a04b93cec283d 100644 (file)
@@ -184,7 +184,7 @@ struct pg_begin {
     if (struct_v > 2) {
       ::decode(pgid.shard, bl);
     } else {
-      pgid.shard = ghobject_t::NO_SHARD;
+      pgid.shard = shard_id_t::NO_SHARD;
     }
     DECODE_FINISH(bl);
   }
@@ -213,7 +213,7 @@ struct object_begin {
       ::decode(hoid.shard_id, bl);
     } else {
       hoid.generation = ghobject_t::NO_GEN;
-      hoid.shard_id = ghobject_t::NO_SHARD;
+      hoid.shard_id = shard_id_t::NO_SHARD;
     }
     DECODE_FINISH(bl);
   }