From: Loic Dachary Date: Wed, 28 May 2014 13:43:32 +0000 (+0200) Subject: osd: explicit shard_id_t() and NO_SHARD X-Git-Tag: v0.83~136^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=dedd8e265d38b41bbabaaf452017730e5030bea2;p=ceph.git osd: explicit shard_id_t() and NO_SHARD 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 --- diff --git a/src/common/hobject.cc b/src/common/hobject.cc index ecc8cfde4d71..ed439fb06247 100644 --- a/src/common/hobject.cc +++ b/src/common/hobject.cc @@ -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& 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; diff --git a/src/common/hobject.h b/src/common/hobject.h index f911e6e08f32..831228007f25 100644 --- a/src/common/hobject.h +++ b/src/common/hobject.h @@ -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. diff --git a/src/messages/MBackfillReserve.h b/src/messages/MBackfillReserve.h index d30e285cc5dc..8cf184e72a8d 100644 --- a/src/messages/MBackfillReserve.h +++ b/src/messages/MBackfillReserve.h @@ -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; } diff --git a/src/messages/MOSDPGBackfill.h b/src/messages/MOSDPGBackfill.h index e9ec661cbb5d..d4b65e82c298 100644 --- a/src/messages/MOSDPGBackfill.h +++ b/src/messages/MOSDPGBackfill.h @@ -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) { diff --git a/src/messages/MOSDPGLog.h b/src/messages/MOSDPGLog.h index 44cd98962b87..741b14170a10 100644 --- a/src/messages/MOSDPGLog.h +++ b/src/messages/MOSDPGLog.h @@ -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; } } }; diff --git a/src/messages/MOSDPGPull.h b/src/messages/MOSDPGPull.h index 91072320fe67..51ea56a67672 100644 --- a/src/messages/MOSDPGPull.h +++ b/src/messages/MOSDPGPull.h @@ -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); } } diff --git a/src/messages/MOSDPGPush.h b/src/messages/MOSDPGPush.h index 46a8f1becd44..83bb184999aa 100644 --- a/src/messages/MOSDPGPush.h +++ b/src/messages/MOSDPGPush.h @@ -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); } } diff --git a/src/messages/MOSDPGPushReply.h b/src/messages/MOSDPGPushReply.h index 1875235dbb7d..793709e1650d 100644 --- a/src/messages/MOSDPGPushReply.h +++ b/src/messages/MOSDPGPushReply.h @@ -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); } } diff --git a/src/messages/MOSDPGQuery.h b/src/messages/MOSDPGQuery.h index c2c6f695d39a..81a55c24f13b 100644 --- a/src/messages/MOSDPGQuery.h +++ b/src/messages/MOSDPGQuery.h @@ -78,7 +78,7 @@ public: ::decode(epoch, p); vector > _pg_list; ::decode(_pg_list, p); - vector _shard_list(_pg_list.size(), ghobject_t::no_shard()); + vector _shard_list(_pg_list.size(), shard_id_t::NO_SHARD); if (header.version >= 3) { _shard_list.clear(); ::decode(_shard_list, p); diff --git a/src/messages/MOSDPGRemove.h b/src/messages/MOSDPGRemove.h index b55b5d28182d..ca021fd7edec 100644 --- a/src/messages/MOSDPGRemove.h +++ b/src/messages/MOSDPGRemove.h @@ -65,7 +65,7 @@ public: vector _pg_list; ::decode(_pg_list, p); - vector _shard_list(_pg_list.size(), ghobject_t::no_shard()); + vector _shard_list(_pg_list.size(), shard_id_t::NO_SHARD); if (header.version >= 2) { _shard_list.clear(); ::decode(_shard_list, p); diff --git a/src/messages/MOSDPGScan.h b/src/messages/MOSDPGScan.h index 2c0c1ad7abc8..f5fe18e523b7 100644 --- a/src/messages/MOSDPGScan.h +++ b/src/messages/MOSDPGScan.h @@ -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; } } diff --git a/src/messages/MOSDPGTrim.h b/src/messages/MOSDPGTrim.h index 12a0e7c82403..29c7444fedf9 100644 --- a/src/messages/MOSDPGTrim.h +++ b/src/messages/MOSDPGTrim.h @@ -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; } }; diff --git a/src/messages/MOSDRepScrub.h b/src/messages/MOSDRepScrub.h index 3f67021ef14c..52a03b849109 100644 --- a/src/messages/MOSDRepScrub.h +++ b/src/messages/MOSDRepScrub.h @@ -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; } } }; diff --git a/src/messages/MOSDSubOp.h b/src/messages/MOSDSubOp.h index 6a381861d613..dafc9f074fe1 100644 --- a/src/messages/MOSDSubOp.h +++ b/src/messages/MOSDSubOp.h @@ -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); diff --git a/src/messages/MOSDSubOpReply.h b/src/messages/MOSDSubOpReply.h index 270629f91f3d..7b441ae31f48 100644 --- a/src/messages/MOSDSubOpReply.h +++ b/src/messages/MOSDSubOpReply.h @@ -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) { diff --git a/src/messages/MRecoveryReserve.h b/src/messages/MRecoveryReserve.h index 2a88bfdeb9f3..29f1732aaca3 100644 --- a/src/messages/MRecoveryReserve.h +++ b/src/messages/MRecoveryReserve.h @@ -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) { diff --git a/src/os/DBObjectMap.cc b/src/os/DBObjectMap.cc index 5d2a2e616242..7f26c0e08716 100644 --- a/src/os/DBObjectMap.cc +++ b/src/os/DBObjectMap.cc @@ -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); } diff --git a/src/os/FileStore.cc b/src/os/FileStore.cc index 092ad22cd849..466a4dea1f47 100644 --- a/src/os/FileStore.cc +++ b/src/os/FileStore.cc @@ -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; diff --git a/src/os/GenericObjectMap.cc b/src/os/GenericObjectMap.cc index 4d41c50ae3a5..0d6c029d0b9f 100644 --- a/src/os/GenericObjectMap.cc +++ b/src/os/GenericObjectMap.cc @@ -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; diff --git a/src/os/LFNIndex.cc b/src/os/LFNIndex.cc index a460e5cdb305..ef3945808bf9 100644 --- a/src/os/LFNIndex.cc +++ b/src/os/LFNIndex.cc @@ -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; diff --git a/src/os/ObjectStore.h b/src/os/ObjectStore.h index 078e40f54798..080737bd3bf4 100644 --- a/src/os/ObjectStore.h +++ b/src/os/ObjectStore.h @@ -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 && diff --git a/src/osd/ECBackend.cc b/src/osd/ECBackend.cc index 5ca66cb4553e..754137b2ef64 100644 --- a/src/osd/ECBackend.cc +++ b/src/osd/ECBackend.cc @@ -1346,8 +1346,8 @@ int ECBackend::get_min_avail_to_read_shards( for (set::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; } diff --git a/src/osd/ECMsgTypes.cc b/src/osd/ECMsgTypes.cc index 4e4c8e3d9423..10c492d24731 100644 --- a/src/osd/ECMsgTypes.cc +++ b/src/osd/ECMsgTypes.cc @@ -210,14 +210,14 @@ void ECSubRead::generate_test_instances(list& 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& 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& 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; diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 1e20a7804594..e13c1e1dc22e 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -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)); } } diff --git a/src/osd/OSDMap.h b/src/osd/OSDMap.h index f1b0d6d3a47a..e5ffc0e1c733 100644 --- a/src/osd/OSDMap.h +++ b/src/osd/OSDMap.h @@ -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; } } diff --git a/src/osd/PG.cc b/src/osd/PG.cc index 579c9153fdee..42f9aea26fe2 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -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::iterator j = all_info_by_shard[i].begin(); - j != all_info_by_shard[i].end(); + for (set::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::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::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::const_iterator a = interval.acting.begin(); std::vector::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::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)) diff --git a/src/osd/PG.h b/src/osd/PG.h index 8294d08d84ef..9b03f661fffb 100644 --- a/src/osd/PG.h +++ b/src/osd/PG.h @@ -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; } } diff --git a/src/osd/ReplicatedBackend.cc b/src/osd/ReplicatedBackend.cc index 0763c7f740a5..468ca418e416 100644 --- a/src/osd/ReplicatedBackend.cc +++ b/src/osd/ReplicatedBackend.cc @@ -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, diff --git a/src/osd/SnapMapper.h b/src/osd/SnapMapper.h index d597a6b6cfd1..deb6868b30d0 100644 --- a/src/osd/SnapMapper.h +++ b/src/osd/SnapMapper.h @@ -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); diff --git a/src/osd/osd_types.cc b/src/osd/osd_types.cc index 4d48325cdea4..319d2acc9e92 100644 --- a/src/osd/osd_types.cc +++ b/src/osd/osd_types.cc @@ -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& o) list 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& 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 ¬ify) @@ -2122,8 +2122,8 @@ ostream &operator<<(ostream &lhs, const pg_notify_t ¬ify) 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& o) o.push_back(new pg_query_t()); list 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)); } diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h index 8a94ca60afb6..ead8fec6b58a 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -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, diff --git a/src/test/ObjectMap/test_object_map.cc b/src/test/ObjectMap/test_object_map.cc index 22c029fd3782..6ab3f82eb82c 100644 --- a/src/test/ObjectMap/test_object_map.cc +++ b/src/test/ObjectMap/test_object_map.cc @@ -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 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"); diff --git a/src/test/os/TestLFNIndex.cc b/src/test/os/TestLFNIndex.cc index c5853fbd7fdc..47ccf640aefa 100644 --- a/src/test/os/TestLFNIndex.cc +++ b/src/test/os/TestLFNIndex.cc @@ -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"); diff --git a/src/test/osd/TestPGLog.cc b/src/test/osd/TestPGLog.cc index c2063b8911c2..0d51ed9c2fb3 100644 --- a/src/test/osd/TestPGLog.cc +++ b/src/test/osd/TestPGLog.cc @@ -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); diff --git a/src/test/test_snap_mapper.cc b/src/test/test_snap_mapper.cc index 04db762b1a90..7f0fae39a00c 100644 --- a/src/test/test_snap_mapper.cc +++ b/src/test/test_snap_mapper.cc @@ -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") {} diff --git a/src/tools/ceph_filestore_dump.cc b/src/tools/ceph_filestore_dump.cc index 4eada7fbf2c7..7ea6395b5d8f 100644 --- a/src/tools/ceph_filestore_dump.cc +++ b/src/tools/ceph_filestore_dump.cc @@ -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); }