OP_SETALLOCHINT = 39, // cid, oid, object_size, write_size
OP_COLL_HINT = 40, // cid, type, bl
+
+ OP_TRY_RENAME = 41, // oldcid, oldoid, newoid
};
// Transaction hint type
}
data.ops++;
}
+ void try_rename(coll_t cid, const ghobject_t& oldoid,
+ const ghobject_t& oid) {
+ if (use_tbl) {
+ __u32 op = OP_TRY_RENAME;
+ ::encode(op, tbl);
+ ::encode(cid, tbl);
+ ::encode(oldoid, tbl);
+ ::encode(oid, tbl);
+ } else {
+ Op* _op = _get_next_op();
+ _op->op = OP_TRY_RENAME;
+ _op->cid = _get_coll_id(cid);
+ _op->oid = _get_object_id(oldoid);
+ _op->dest_oid = _get_object_id(oid);
+ }
+ data.ops++;
+ }
// NOTE: Collection attr operations are all DEPRECATED. new
// backends need not implement these at all.
}
break;
+ case Transaction::OP_TRY_RENAME:
+ {
+ coll_t cid;
+ ghobject_t oldoid;
+ ghobject_t newoid;
+
+ ::decode(cid, p);
+ ::decode(oldoid, p);
+ ::decode(newoid, p);
+
+ try_rename(cid, oldoid, newoid);
+ }
+ break;
+
case Transaction::OP_COLL_SETATTR:
{
coll_t cid;
}
break;
+ case Transaction::OP_TRY_RENAME:
+ {
+ const ghobject_t& noid = i.get_oid(op->dest_oid);
+ OnodeRef no = c->get_onode(noid, true);
+ r = _rename(txc, c, o, no, noid);
+ if (r == -ENOENT)
+ r = 0;
+ o.reset();
+ }
+ break;
+
case Transaction::OP_OMAP_CLEAR:
{
r = _omap_clear(txc, c, o);
}
break;
+ case Transaction::OP_TRY_RENAME:
+ {
+ coll_t oldcid = i.get_cid(op->cid);
+ coll_t newcid = oldcid;
+ ghobject_t oldoid = i.get_oid(op->oid);
+ ghobject_t newoid = i.get_oid(op->dest_oid);
+ _kludge_temp_object_collection(oldcid, oldoid);
+ _kludge_temp_object_collection(newcid, newoid);
+ tracepoint(objectstore, coll_try_rename_enter);
+ r = _collection_move_rename(oldcid, oldoid, newcid, newoid, spos, true);
+ tracepoint(objectstore, coll_try_rename_exit, r);
+ }
+ break;
+
case Transaction::OP_COLL_SETATTR:
{
coll_t cid = i.get_cid(op->cid);
int FileStore::_collection_move_rename(const coll_t& oldcid, const ghobject_t& oldoid,
coll_t c, const ghobject_t& o,
- const SequencerPosition& spos)
+ const SequencerPosition& spos,
+ bool allow_enoent)
{
dout(15) << __func__ << " " << c << "/" << o << " from " << oldcid << "/" << oldoid << dendl;
int r = 0;
if (r < 0) {
// the source collection/object does not exist. If we are replaying, we
// should be safe, so just return 0 and move on.
- assert(replaying);
- dout(10) << __func__ << " " << c << "/" << o << " from "
- << oldcid << "/" << oldoid << " (dne, continue replay) " << dendl;
+ if (replaying) {
+ dout(10) << __func__ << " " << c << "/" << o << " from "
+ << oldcid << "/" << oldoid << " (dne, continue replay) " << dendl;
+ } else if (allow_enoent) {
+ dout(10) << __func__ << " " << c << "/" << o << " from "
+ << oldcid << "/" << oldoid << " (dne, ignoring enoent)"
+ << dendl;
+ } else {
+ assert(0 == "ERROR: source must exist");
+ }
return 0;
}
if (dstcmp > 0) { // if dstcmp == 0 the guard already says "in-progress"
const SequencerPosition& spos);
int _collection_move_rename(const coll_t& oldcid, const ghobject_t& oldoid,
coll_t c, const ghobject_t& o,
- const SequencerPosition& spos);
+ const SequencerPosition& spos,
+ bool ignore_enoent = false);
int _set_alloc_hint(const coll_t& cid, const ghobject_t& oid,
uint64_t expected_object_size,
}
break;
+ case Transaction::OP_TRY_RENAME:
+ {
+ const ghobject_t& noid = i.get_oid(op->dest_oid);
+ OnodeRef no = c->get_onode(noid, true);
+ r = _rename(txc, c, o, no, noid);
+ if (r == -ENOENT)
+ r = 0;
+ o.reset();
+ }
+ break;
+
case Transaction::OP_OMAP_CLEAR:
{
r = _omap_clear(txc, c, o);
coll_t newcid = i.get_cid(op->dest_cid);
ghobject_t newoid = i.get_oid(op->dest_oid);
r = _collection_move_rename(oldcid, oldoid, newcid, newoid);
+ if (r == -ENOENT)
+ r = 0;
+ }
+ break;
+
+ case Transaction::OP_TRY_RENAME:
+ {
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oldoid = i.get_oid(op->oid);
+ ghobject_t newoid = i.get_oid(op->dest_oid);
+ r = _collection_move_rename(cid, oldoid, cid, newoid);
+ if (r == -ENOENT)
+ r = 0;
}
break;
)
)
+TRACEPOINT_EVENT(objectstore, coll_try_rename_enter,
+ TP_ARGS(),
+ TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(objectstore, coll_try_rename_exit,
+ TP_ARGS(
+ int, retval),
+ TP_FIELDS(
+ ctf_integer(int, retval, retval)
+ )
+)
+
TRACEPOINT_EVENT(objectstore, coll_remove_enter,
TP_ARGS(
const char *, osr_name),