]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: change coll_t::is_pg() and is_temp() to take a pointer; drop snap
authorSage Weil <sage@redhat.com>
Tue, 6 Jan 2015 19:20:24 +0000 (11:20 -0800)
committerSage Weil <sage@redhat.com>
Fri, 19 Jun 2015 00:02:48 +0000 (17:02 -0700)
The snap arg isn't used anymore.  The spg_t should be a pointer (not ref)
since it is an output argument.

Signed-off-by: Sage Weil <sage@redhat.com>
src/os/FileStore.cc
src/os/HashIndex.cc
src/os/LFNIndex.cc
src/osd/OSD.cc
src/osd/PG.cc
src/osd/osd_types.cc
src/osd/osd_types.h
src/tools/ceph_objectstore_tool.cc

index 70b8525daceaa398a0fc89c02b1ff2585dde3d2f..c921d47b9a4a9667f8386198f708f6b4bd52732d 100644 (file)
@@ -4725,11 +4725,10 @@ int FileStore::collection_list_partial(coll_t c, ghobject_t start,
   shard_id_t shard;
   {
     spg_t pgid;
-    snapid_t snap;
-    if (c.is_temp(pgid)) {
+    if (c.is_temp(&pgid)) {
       pool = -2 - pgid.pool();
       shard = pgid.shard;
-    } else if (c.is_pg(pgid, snap)) {
+    } else if (c.is_pg(&pgid)) {
       pool = pgid.pool();
       shard = pgid.shard;
     } else if (c.is_meta()) {
index 4324d38b51e9590f29cf9848c214486035dea306..96a0a5af35d98cb178dd55a47e8ff39cc5d62584 100644 (file)
@@ -382,7 +382,7 @@ int HashIndex::pre_split_folder(uint32_t pg_num, uint64_t expected_num_objs)
     return 0;
 
   spg_t spgid;
-  if (!c.is_pg_prefix(spgid))
+  if (!c.is_pg_prefix(&spgid))
     return -EINVAL;
   const ps_t ps = spgid.pgid.ps();
 
index 5d6bd7b9d8d7cfd1ed138006205fa53cff2ab855..0711c2d08b2ed9b86b1868c2c1ccff3968595202 100644 (file)
@@ -1025,7 +1025,7 @@ bool LFNIndex::lfn_parse_object_name_keyless(const string &long_name, ghobject_t
   bool r = parse_object(long_name.c_str(), *out);
   int64_t pool = -1;
   spg_t pg;
-  if (coll().is_pg_prefix(pg))
+  if (coll().is_pg_prefix(&pg))
     pool = (int64_t)pg.pgid.pool();
   out->hobj.pool = pool;
   if (!r) return r;
@@ -1118,7 +1118,7 @@ bool LFNIndex::lfn_parse_object_name_poolless(const string &long_name,
 
   int64_t pool = -1;
   spg_t pg;
-  if (coll().is_pg_prefix(pg))
+  if (coll().is_pg_prefix(&pg))
     pool = (int64_t)pg.pgid.pool();
   (*out) = ghobject_t(hobject_t(name, key, snap, hash, pool, ""));
   return true;
index c00c48352b625a06cb963ad5ff09316495591503..70769407d2a2ca9a17da255eddf877db5f962da2 100644 (file)
@@ -2767,26 +2767,17 @@ void OSD::load_pgs()
        it != ls.end();
        ++it) {
     spg_t pgid;
-    snapid_t snap;
-
-    if (it->is_temp(pgid) ||
+    if (it->is_temp(&pgid) ||
        it->is_removal(&pgid) ||
-       (it->is_pg(pgid, snap) &&
-        PG::_has_removal_flag(store, pgid))) {
+       (it->is_pg(&pgid) && PG::_has_removal_flag(store, pgid))) {
       dout(10) << "load_pgs " << *it << " clearing temp" << dendl;
       recursive_remove_collection(store, pgid, *it);
       continue;
     }
 
-    if (it->is_pg(pgid, snap)) {
-      if (snap != CEPH_NOSNAP) {
-       dout(10) << "load_pgs skipping snapped dir " << *it
-                << " (pg " << pgid << " snap " << snap << ")" << dendl;
-       pgs[pgid].insert(snap);
-      } else {
-       pgs[pgid];
-       head_pgs.insert(pgid);
-      }
+    if (it->is_pg(&pgid)) {
+      pgs[pgid];
+      head_pgs.insert(pgid);
       continue;
     }
 
index 7f12808654d11ea7aef5e95afb0ade5f884c6d07..767f607ec322d56e3332ef494e0431afcb8709e8 100644 (file)
@@ -2738,10 +2738,7 @@ epoch_t PG::peek_map_epoch(ObjectStore *store,
   assert(bl);
   {
     // validate collection name
-    spg_t pgid_temp;
-    snapid_t snap;
-    bool ok = coll.is_pg(pgid_temp, snap);
-    assert(ok);
+    assert(coll.is_pg());
   }
 
   // try for v8
index 74f64f83bd3d66d1e17da32826793b6b97ab90b3..f6037691a195c770e67a2f62bd76798cfdda18d8 100644 (file)
@@ -556,10 +556,10 @@ bool coll_t::is_temp() const
   return false;
 }
 
-bool coll_t::is_temp(spg_tpgid) const
+bool coll_t::is_temp(spg_t *pgid) const
 {
   const char *cstr(str.c_str());
-  if (!pgid.parse(cstr))
+  if (!pgid->parse(cstr))
     return false;
   const char *tmp_start = strchr(cstr, '_');
   if (!tmp_start)
@@ -569,31 +569,25 @@ bool coll_t::is_temp(spg_t& pgid) const
   return false;
 }
 
-bool coll_t::is_pg(spg_t& pgid, snapid_t& snap) const
+bool coll_t::is_pg(spg_t *pgid) const
 {
   const char *cstr(str.c_str());
 
-  if (!pgid.parse(cstr))
+  if (!pgid->parse(cstr))
     return false;
   const char *snap_start = strchr(cstr, '_');
   if (!snap_start)
     return false;
-  if (strncmp(snap_start, "_head", 5) == 0) {
-    snap = CEPH_NOSNAP;
-  } else {
-    errno = 0;
-    snap = strtoull(snap_start+1, 0, 16);
-    if (errno)
-      return false;
-  }
+  if (strncmp(snap_start, "_head", 5) != 0)
+    return false;
   return true;
 }
 
-bool coll_t::is_pg_prefix(spg_tpgid) const
+bool coll_t::is_pg_prefix(spg_t *pgid) const
 {
   const char *cstr(str.c_str());
 
-  if (!pgid.parse(cstr))
+  if (!pgid->parse(cstr))
     return false;
   const char *snap_start = strchr(cstr, '_');
   if (!snap_start)
index 42565bac92f9c8315b6534320aacae4f58fa6398..0d0145fe52fdfec468bd3e7ddd2aec95a64bae0b 100644 (file)
@@ -523,9 +523,13 @@ public:
   bool is_meta() const {
     return str == string("meta");
   }
-  bool is_pg_prefix(spg_t& pgid) const;
-  bool is_pg(spg_t& pgid, snapid_t& snap) const;
-  bool is_temp(spg_t& pgid) const;
+  bool is_pg_prefix(spg_t *pgid) const;
+  bool is_pg(spg_t *pgid) const;
+  bool is_pg() const {
+    spg_t pgid;
+    return is_pg(&pgid);
+  }
+  bool is_temp(spg_t *pgid) const;
   bool is_temp() const;
   bool is_removal(spg_t *pgid) const;
   void encode(bufferlist& bl) const;
@@ -541,10 +545,8 @@ public:
   // which we presume is a pg collection.
   coll_t get_temp() {
     spg_t pgid;
-    snapid_t snap;
-    bool foo = is_pg(pgid, snap);
-    assert(foo);
-    assert(snap == CEPH_NOSNAP);
+    bool valid = is_pg(&pgid);
+    assert(valid);
     return coll_t(str.substr(0, str.length() - 4) + "TEMP");
   }
 
index 4c831b81485a5ccff13e1e964c2d6b1363b32d77..c363089dcb3ac8eced1985ba8af010fb0cfd0fe7 100644 (file)
@@ -142,10 +142,7 @@ int action_on_all_objects_in_pg(ObjectStore *store, string pgidstr, action_on_ob
        i != candidates.end();
        ++i) {
     spg_t cand_pgid;
-    snapid_t snap;
-    if (!i->is_pg(cand_pgid, snap))
-      continue;
-    if (snap != CEPH_NOSNAP)
+    if (!i->is_pg(&cand_pgid))
       continue;
 
     // If an exact match or treat no shard as any shard
@@ -192,9 +189,7 @@ int _action_on_all_objects(ObjectStore *store, action_on_object_t &action, bool
   for (vector<coll_t>::iterator i = candidates.begin();
        i != candidates.end();
        ++i) {
-    spg_t pgid;
-    snapid_t snap;
-    if (i->is_pg(pgid, snap)) {
+    if (i->is_pg()) {
       colls_to_check.push_back(*i);
     }
   }
@@ -400,7 +395,7 @@ void dump_log(Formatter *formatter, ostream &out, pg_log_t &log,
 void remove_coll(ObjectStore *store, const coll_t &coll)
 {
   spg_t pg;
-  coll.is_pg_prefix(pg);
+  coll.is_pg_prefix(&pg);
   OSDriver driver(
     store,
     coll_t(),
@@ -459,11 +454,10 @@ int finish_remove_pgs(ObjectStore *store)
        it != ls.end();
        ++it) {
     spg_t pgid;
-    snapid_t snap;
 
-    if (it->is_temp(pgid) ||
+    if (it->is_temp(&pgid) ||
        it->is_removal(&pgid) ||
-       (it->is_pg(pgid, snap) && PG::_has_removal_flag(store, pgid))) {
+       (it->is_pg(&pgid) && PG::_has_removal_flag(store, pgid))) {
       cout << "finish_remove_pgs " << *it << " removing " << pgid << std::endl;
       OSD::recursive_remove_collection(store, pgid, *it);
       continue;
@@ -880,7 +874,7 @@ int ObjectStoreTool::get_object(ObjectStore *store, coll_t coll,
     coll_t(),
     OSD::make_snapmapper_oid());
   spg_t pg;
-  coll.is_pg_prefix(pg);
+  coll.is_pg_prefix(&pg);
   SnapMapper mapper(&driver, 0, 0, 0, pg.shard);
 
   assert(g_ceph_context);
@@ -891,8 +885,7 @@ int ObjectStoreTool::get_object(ObjectStore *store, coll_t coll,
     pg_t pgid = curmap.raw_pg_to_pg(raw_pgid);
   
     spg_t coll_pgid;
-    snapid_t coll_snap;
-    if (coll.is_pg(coll_pgid, coll_snap) == false) {
+    if (coll.is_pg(&coll_pgid) == false) {
       cerr << "INTERNAL ERROR: Bad collection during import" << std::endl;
       return -EFAULT;
     }
@@ -1388,7 +1381,7 @@ int do_list(ObjectStore *store, string pgidstr, string object, Formatter *format
 int do_remove_object(ObjectStore *store, coll_t coll, ghobject_t &ghobj)
 {
   spg_t pg;
-  coll.is_pg_prefix(pg);
+  coll.is_pg_prefix(&pg);
   OSDriver driver(
     store,
     coll_t(),
@@ -2367,26 +2360,19 @@ int main(int argc, char **argv)
 
   // Find pg
   for (it = ls.begin(); it != ls.end(); ++it) {
-    snapid_t snap;
     spg_t tmppgid;
 
-    if (!it->is_pg(tmppgid, snap)) {
+    if (!it->is_pg(&tmppgid)) {
       continue;
     }
 
-    if (it->is_temp(tmppgid)) {
+    if (it->is_temp(&tmppgid)) {
       continue;
     }
 
     if (op != "list-pgs" && tmppgid != pgid) {
       continue;
     }
-    if (snap != CEPH_NOSNAP) {
-      if (debug)
-        cerr << "skipping snapped dir " << *it
-              << " (pg " << pgid << " snap " << snap << ")" << std::endl;
-      continue;
-    }
 
     if (op != "list-pgs") {
       //Found!