summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSage Weil <sage@inktank.com>2013-02-09 21:34:02 -0800
committerSamuel Just <sam.just@inktank.com>2013-02-12 10:15:03 -0800
commit7edf8acfc1ed03e9d5add6a5f47a766663818b78 (patch)
treee6e971c10eac80122d843034105ecd7a6b543111
parentea98fbb97c8e7d2e327cfa58753977b69b446321 (diff)
downloadceph-7edf8acfc1ed03e9d5add6a5f47a766663818b78.tar.gz
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 <sage@inktank.com>
-rw-r--r--src/os/DBObjectMap.cc3
-rw-r--r--src/os/LFNIndex.cc6
-rw-r--r--src/osd/osd_types.cc12
-rw-r--r--src/osd/osd_types.h1
4 files changed, 16 insertions, 6 deletions
diff --git a/src/os/DBObjectMap.cc b/src/os/DBObjectMap.cc
index 10b7b705a4b..f884266ff75 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 5e505638d15..1aae19b3a15 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 786d0e876b4..3e2990e8b68 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 e0680574057..4d8789755a8 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;