]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os: use coll_t:is_pg_prefix() check instead of is_pg()
authorSage Weil <sage@inktank.com>
Sun, 10 Feb 2013 05:34:02 +0000 (21:34 -0800)
committerSamuel Just <sam.just@inktank.com>
Tue, 12 Feb 2013 18:15:03 +0000 (10:15 -0800)
The objectstore code was trying to parse out a pgid from the collection
name and using the is_pg() helper, which incorrectly tolerates a _TEMP
suffix and returns a bad value for the snapid.  The objectstore doesn't
actually care about that value, so this is harmless, but sloppy.

Introduce a simpler is_pg_prefix() helper and use that instead.

Signed-off-by: Sage Weil <sage@inktank.com>
src/os/DBObjectMap.cc
src/os/LFNIndex.cc
src/osd/osd_types.cc
src/osd/osd_types.h

index 10b7b705a4b24f1b0ac5dda4f90a54dade98a965..f884266ff7512121b9195d18728d1d2e76cdf760 100644 (file)
@@ -242,8 +242,7 @@ bool DBObjectMap::parse_hobject_key_v0(const string &in, coll_t *c,
   *c = coll_t(coll);
   int64_t pool = -1;
   pg_t pg;
-  snapid_t pg_snap;
-  if (c->is_pg(pg, pg_snap))
+  if (c->is_pg_prefix(pg))
     pool = (int64_t)pg.pool();
   (*hoid) = hobject_t(name, key, snap, hash, pool);
   return true;
index 5e505638d15a9edf6152f25ae4a50e8a8a6aa87c..1aae19b3a15e8204d6381f59f21b0d4e06375266 100644 (file)
@@ -893,8 +893,7 @@ bool LFNIndex::lfn_parse_object_name_keyless(const string &long_name, hobject_t
   bool r = parse_object(long_name.c_str(), *out);
   int64_t pool = -1;
   pg_t pg;
-  snapid_t snap;
-  if (coll().is_pg(pg, snap))
+  if (coll().is_pg_prefix(pg))
     pool = (int64_t)pg.pool();
   out->pool = pool;
   if (!r) return r;
@@ -985,8 +984,7 @@ bool LFNIndex::lfn_parse_object_name_poolless(const string &long_name,
 
   int64_t pool = -1;
   pg_t pg;
-  snapid_t pg_snap;
-  if (coll().is_pg(pg, pg_snap))
+  if (coll().is_pg_prefix(pg))
     pool = (int64_t)pg.pool();
   (*out) = hobject_t(name, key, snap, hash, pool);
   return true;
index 786d0e876b4c34d242f0d1441428d260b726cc7e..3e2990e8b68c136b2125eab01b934845a31d78e2 100644 (file)
@@ -301,6 +301,18 @@ bool coll_t::is_pg(pg_t& pgid, snapid_t& snap) const
   return true;
 }
 
+bool coll_t::is_pg_prefix(pg_t& pgid) const
+{
+  const char *cstr(str.c_str());
+
+  if (!pgid.parse(cstr))
+    return false;
+  const char *snap_start = strchr(cstr, '_');
+  if (!snap_start)
+    return false;
+  return true;
+}
+
 bool coll_t::is_removal(uint64_t *seq, pg_t *pgid) const
 {
   if (str.substr(0, 11) != string("FORREMOVAL_"))
index e06805740575473c422306a3c23f9920c5460367..4d8789755a89f986963d3943587d5f5d57b65f01 100644 (file)
@@ -355,6 +355,7 @@ public:
     return str < rhs.str;
   }
 
+  bool is_pg_prefix(pg_t& pgid) const;
   bool is_pg(pg_t& pgid, snapid_t& snap) const;
   bool is_temp(pg_t& pgid) const;
   bool is_removal(uint64_t *seq, pg_t *pgid) const;