From: Sage Weil Date: Sun, 10 Feb 2013 05:34:02 +0000 (-0800) Subject: os: use coll_t:is_pg_prefix() check instead of is_pg() X-Git-Tag: v0.58~96^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7edf8acfc1ed03e9d5add6a5f47a766663818b78;p=ceph.git os: use coll_t:is_pg_prefix() check instead of is_pg() 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 --- diff --git a/src/os/DBObjectMap.cc b/src/os/DBObjectMap.cc index 10b7b705a4b2..f884266ff751 100644 --- a/src/os/DBObjectMap.cc +++ b/src/os/DBObjectMap.cc @@ -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; diff --git a/src/os/LFNIndex.cc b/src/os/LFNIndex.cc index 5e505638d15a..1aae19b3a15e 100644 --- a/src/os/LFNIndex.cc +++ b/src/os/LFNIndex.cc @@ -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; diff --git a/src/osd/osd_types.cc b/src/osd/osd_types.cc index 786d0e876b4c..3e2990e8b68c 100644 --- a/src/osd/osd_types.cc +++ b/src/osd/osd_types.cc @@ -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_")) diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h index e06805740575..4d8789755a89 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -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;