using std::string;
-const string SnapMapper::MAPPING_PREFIX = "MAP_";
+const string SnapMapper::LEGACY_MAPPING_PREFIX = "MAP_";
+const string SnapMapper::MAPPING_PREFIX = "SNA_";
const string SnapMapper::OBJECT_PREFIX = "OBJ_";
/*
+ hobject_t::to_str() ("%llx.%8x.%lx.name...." % pool, hash, snap)
-> SnapMapping::Mapping { snap, hoid }
+ "SNA_"
+ + ("%lld" % poolid)
+ + "_"
+ + ("%016x" % snapid)
+ + "_"
+ + (".%x" % shard_id)
+ + "_"
+ + hobject_t::to_str() ("%llx.%8x.%lx.name...." % pool, hash, snap)
+ -> SnapMapping::Mapping { snap, hoid }
+
"OBJ_" +
+ (".%x" % shard_id)
+ hobject_t::to_str()
};
WRITE_CLASS_ENCODER(Mapping)
-string SnapMapper::get_prefix(snapid_t snap)
+string SnapMapper::get_legacy_prefix(snapid_t snap)
+{
+ char buf[100];
+ int len = snprintf(
+ buf, sizeof(buf),
+ "%.*X_",
+ (int)(sizeof(snap)*2), static_cast<unsigned>(snap));
+ return LEGACY_MAPPING_PREFIX + string(buf, len);
+}
+
+string SnapMapper::get_prefix(int64_t pool, snapid_t snap)
{
char buf[100];
int len = snprintf(
buf, sizeof(buf),
- "%.*X_", (int)(sizeof(snap)*2),
- static_cast<unsigned>(snap));
+ "%lld_%.*X_",
+ (long long)pool,
+ (int)(sizeof(snap)*2), static_cast<unsigned>(snap));
return MAPPING_PREFIX + string(buf, len);
}
string SnapMapper::to_raw_key(
const pair<snapid_t, hobject_t> &in)
{
- return get_prefix(in.first) + shard_prefix + in.second.to_str();
+ return get_prefix(pool, in.first) + shard_prefix + in.second.to_str();
}
pair<string, bufferlist> SnapMapper::to_raw(
for (set<string>::iterator i = prefixes.begin();
i != prefixes.end() && out->size() < max && r == 0;
++i) {
- string prefix(get_prefix(snap) + *i);
+ string prefix(get_prefix(pool, snap) + *i);
string pos = prefix;
while (out->size() < max) {
pair<string, bufferlist> next;
*
* We accomplish this using two sets of keys:
* 1) OBJECT_PREFIX + obj.str() -> encoding of object_snaps
- * 2) MAPPING_PREFIX + snapid_t + obj.str() -> encoding of pair<snapid_t, obj>
+ * 2) MAPPING_PREFIX + poolid + snapid_t + obj.str() -> encoding of pair<snapid_t, obj>
*
* The on disk strings and encodings are implemented in to_raw, to_raw_key,
* from_raw, to_object_key.
private:
MapCacher::MapCacher<std::string, bufferlist> backend;
+ static const std::string LEGACY_MAPPING_PREFIX;
static const std::string MAPPING_PREFIX;
static const std::string OBJECT_PREFIX;
- static std::string get_prefix(snapid_t snap);
+ static std::string get_legacy_prefix(snapid_t snap);
+ static std::string get_prefix(int64_t pool, snapid_t snap);
std::string to_raw_key(
const std::pair<snapid_t, hobject_t> &to_map);