}
append_escaped(i, hoid.oid.name.end(), &full_name);
full_name.append("_");
- append_escaped(hoid.key.begin(), hoid.key.end(), &full_name);
+ append_escaped(hoid.get_key().begin(), hoid.get_key().end(), &full_name);
full_name.append("_");
char snap_with_hash[PATH_MAX];
}
bool LFNIndex::lfn_parse_object_name(const string &long_name, hobject_t *out) {
+ string name;
+ string key;
+ uint32_t hash;
+ snapid_t snap;
+
if (index_version == HASH_INDEX_TAG)
return lfn_parse_object_name_keyless(long_name, out);
if (current == long_name.end()) {
return false;
} else if (*current == 'd') {
- out->oid.name.append("DIR_");
+ name.append("DIR_");
++current;
} else if (*current == '.') {
- out->oid.name.append(".");
+ name.append(".");
++current;
} else {
--current;
for ( ; end != long_name.end() && *end != '_'; ++end) ;
if (end == long_name.end())
return false;
- if (!append_unescaped(current, end, &(out->oid.name)))
+ if (!append_unescaped(current, end, &name))
return false;
current = ++end;
for ( ; end != long_name.end() && *end != '_'; ++end) ;
if (end == long_name.end())
return false;
- if (!append_unescaped(current, end, &(out->key)))
+ if (!append_unescaped(current, end, &key))
return false;
current = ++end;
for ( ; end != long_name.end() && *end != '_'; ++end) ;
if (end == long_name.end())
return false;
- string snap(current, end);
+ string snap_str(current, end);
current = ++end;
for ( ; end != long_name.end() && *end != '_'; ++end) ;
if (end != long_name.end())
return false;
- string hash(current, end);
+ string hash_str(current, end);
- if (snap == "head")
- out->snap = CEPH_NOSNAP;
- else if (snap == "snapdir")
- out->snap = CEPH_SNAPDIR;
+ if (snap_str == "head")
+ snap = CEPH_NOSNAP;
+ else if (snap_str == "snapdir")
+ snap = CEPH_SNAPDIR;
else
- out->snap = strtoull(snap.c_str(), NULL, 16);
- sscanf(hash.c_str(), "%X", &out->hash);
+ snap = strtoull(snap_str.c_str(), NULL, 16);
+ sscanf(hash_str.c_str(), "%X", &hash);
+
+ (*out) = hobject_t(name, key, snap, hash);
return true;
}
// load clone info
bufferlist bl;
ObjectContext *obc = 0;
- int r = find_object_context(hobject_t(coid.oid, coid.key, sn, coid.hash),
+ int r = find_object_context(hobject_t(coid.oid, coid.get_key(), sn, coid.hash),
OLOC_BLANK, &obc, false, NULL);
if (r == -ENOENT || coid.snap != obc->obs.oi.soid.snap) {
if (obc) put_object_context(obc);
// get snap set context
if (!obc->ssc)
- obc->ssc = get_snapset_context(coid.oid, coid.key, coid.hash, false);
+ obc->ssc = get_snapset_context(coid.oid, coid.get_key(), coid.hash, false);
SnapSetContext *ssc = obc->ssc;
assert(ssc);
SnapSet& snapset = ssc->snapset;
// save head snapset
dout(10) << coid << " new snapset " << snapset << dendl;
- hobject_t snapoid(coid.oid, coid.key, snapset.head_exists ? CEPH_NOSNAP:CEPH_SNAPDIR, coid.hash);
+ hobject_t snapoid(coid.oid, coid.get_key(), snapset.head_exists ? CEPH_NOSNAP:CEPH_SNAPDIR, coid.hash);
ctx->snapset_obc = get_object_context(snapoid, coi.oloc, false);
assert(ctx->snapset_obc->registered);
if (snapset.clones.empty() && !snapset.head_exists) {
ObjectContext *src_obc = 0;
if (ceph_osd_op_type_multi(op.op)) {
- src_obc = ctx->src_obc[hobject_t(osd_op.soid, soid.key, soid.hash)];
+ src_obc = ctx->src_obc[hobject_t(osd_op.soid, soid.get_key(), soid.hash)];
assert(src_obc);
}
result = -EINVAL;
break;
}
- t.clone_range(coll, hobject_t(osd_op.soid, obs.oi.soid.key,
+ t.clone_range(coll, hobject_t(osd_op.soid, obs.oi.soid.get_key(),
obs.oi.soid.hash),
obs.oi.soid, op.clonerange.src_offset,
op.clonerange.length, op.clonerange.offset);
/* a different problem, like degraded pool
* with not-yet-restored object. We shouldn't have been able
* to get here; recovery should have completed first! */
- hobject_t rollback_target(soid.oid, soid.key, cloneid, soid.hash);
+ hobject_t rollback_target(soid.oid, soid.get_key(), cloneid, soid.hash);
assert(is_missing_object(rollback_target));
dout(20) << "_rollback_to attempted to roll back to a missing object "
<< rollback_target << " (requested snapid: ) " << snapid << dendl;
ctx->op_t.setattr(coll, soid, SS_ATTR, bss);
if (!head_existed) {
// if we logically recreated the head, remove old _snapdir object
- hobject_t snapoid(soid.oid, soid.key, CEPH_SNAPDIR, soid.hash);
+ hobject_t snapoid(soid.oid, soid.get_key(), CEPH_SNAPDIR, soid.hash);
ctx->snapset_obc = get_object_context(snapoid, ctx->new_obs.oi.oloc, false);
if (ctx->snapset_obc && ctx->snapset_obc->obs.exists) {
}
} else if (ctx->new_snapset.clones.size()) {
// save snapset on _snap
- hobject_t snapoid(soid.oid, soid.key, CEPH_SNAPDIR, soid.hash);
+ hobject_t snapoid(soid.oid, soid.get_key(), CEPH_SNAPDIR, soid.hash);
dout(10) << " final snapset " << ctx->new_snapset
<< " in " << snapoid << dendl;
ctx->at_version.version++;
SnapSetContext *ssc = NULL;
if (can_create)
- ssc = get_snapset_context(soid.oid, soid.key, soid.hash, true);
+ ssc = get_snapset_context(soid.oid, soid.get_key(), soid.hash, true);
obc = new ObjectContext(oi, true, ssc);
}
register_object_context(obc);
if (can_create && !obc->ssc)
- obc->ssc = get_snapset_context(soid.oid, soid.key, soid.hash, true);
+ obc->ssc = get_snapset_context(soid.oid, soid.get_key(), soid.hash, true);
if (r >= 0) {
obc->obs.oi.decode(bv);
snapid_t *psnapid)
{
// want the head?
- hobject_t head(oid.oid, oid.key, CEPH_NOSNAP, oid.hash);
+ hobject_t head(oid.oid, oid.get_key(), CEPH_NOSNAP, oid.hash);
if (oid.snap == CEPH_NOSNAP) {
ObjectContext *obc = get_object_context(head, oloc, can_create);
if (!obc)
*pobc = obc;
if (can_create && !obc->ssc)
- obc->ssc = get_snapset_context(oid.oid, oid.key, oid.hash, true);
+ obc->ssc = get_snapset_context(oid.oid, oid.get_key(), oid.hash, true);
return 0;
}
// we want a snap
- SnapSetContext *ssc = get_snapset_context(oid.oid, oid.key, oid.hash, can_create);
+ SnapSetContext *ssc = get_snapset_context(oid.oid, oid.get_key(), oid.hash, can_create);
if (!ssc)
return -ENOENT;
put_snapset_context(ssc);
return -ENOENT;
}
- hobject_t soid(oid.oid, oid.key, ssc->snapset.clones[k], oid.hash);
+ hobject_t soid(oid.oid, oid.get_key(), ssc->snapset.clones[k], oid.hash);
put_snapset_context(ssc); // we're done with ssc
ssc = 0;
}
// check snapset
- SnapSetContext *ssc = get_snapset_context(soid.oid, soid.key, soid.hash, false);
+ SnapSetContext *ssc = get_snapset_context(soid.oid, soid.get_key(), soid.hash, false);
dout(10) << " snapset " << ssc->snapset << dendl;
calc_clone_subsets(ssc->snapset, soid, missing,
data_subset, clone_subsets);
return push_start(snapdir, peer);
}
- SnapSetContext *ssc = get_snapset_context(soid.oid, soid.key, soid.hash, false);
+ SnapSetContext *ssc = get_snapset_context(soid.oid, soid.get_key(), soid.hash, false);
dout(15) << "push_to_replica snapset is " << ssc->snapset << dendl;
calc_clone_subsets(ssc->snapset, soid, peer_missing[peer],
data_subset, clone_subsets);
} else if (soid.snap == CEPH_NOSNAP) {
// pushing head or unversioned object.
// base this on partially on replica's clones?
- SnapSetContext *ssc = get_snapset_context(soid.oid, soid.key, soid.hash, false);
+ SnapSetContext *ssc = get_snapset_context(soid.oid, soid.get_key(), soid.hash, false);
dout(15) << "push_to_replica snapset is " << ssc->snapset << dendl;
calc_head_subsets(ssc->snapset, soid, peer_missing[peer], data_subset, clone_subsets);
put_snapset_context(ssc);
if (soid.snap && soid.snap < CEPH_NOSNAP) {
// clone. make sure we have enough data.
- SnapSetContext *ssc = get_snapset_context(soid.oid, soid.key, soid.hash, false);
+ SnapSetContext *ssc = get_snapset_context(soid.oid, soid.get_key(), soid.hash, false);
assert(ssc);
clone_subsets.clear(); // forget what pusher said; recalculate cloning.