if (handle)
handle->reset_tp_timeout();
- int op = i.decode_op();
+ Transaction::Op *op = i.decode_op();
int r = 0;
_inject_failure();
- switch (op) {
+ switch (op->op) {
case Transaction::OP_NOP:
break;
case Transaction::OP_TOUCH:
{
- coll_t cid = i.decode_cid();
- ghobject_t oid = i.decode_oid();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
tracepoint(objectstore, touch_enter, osr_name);
- if (_check_replay_guard(cid, oid, spos) > 0)
- r = _touch(cid, oid);
+ if (_check_replay_guard(cid, oid, spos) > 0)
+ r = _touch(cid, oid);
tracepoint(objectstore, touch_exit, r);
}
break;
case Transaction::OP_WRITE:
{
- coll_t cid = i.decode_cid();
- ghobject_t oid = i.decode_oid();
- uint64_t off = i.decode_length();
- uint64_t len = i.decode_length();
- uint32_t fadvise_flags = i.get_fadvise_flags();
- bufferlist bl;
- i.decode_bl(bl);
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
+ uint64_t off = op->off;
+ uint64_t len = op->len;
+ uint32_t fadvise_flags = i.get_fadvise_flags();
+ bufferlist bl;
+ i.decode_bl(bl);
tracepoint(objectstore, write_enter, osr_name, off, len);
- if (_check_replay_guard(cid, oid, spos) > 0)
- r = _write(cid, oid, off, len, bl, fadvise_flags);
+ if (_check_replay_guard(cid, oid, spos) > 0)
+ r = _write(cid, oid, off, len, bl, fadvise_flags);
tracepoint(objectstore, write_exit, r);
}
break;
case Transaction::OP_ZERO:
{
- coll_t cid = i.decode_cid();
- ghobject_t oid = i.decode_oid();
- uint64_t off = i.decode_length();
- uint64_t len = i.decode_length();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
+ uint64_t off = op->off;
+ uint64_t len = op->len;
tracepoint(objectstore, zero_enter, osr_name, off, len);
- if (_check_replay_guard(cid, oid, spos) > 0)
- r = _zero(cid, oid, off, len);
+ if (_check_replay_guard(cid, oid, spos) > 0)
+ r = _zero(cid, oid, off, len);
tracepoint(objectstore, zero_exit, r);
}
break;
case Transaction::OP_TRIMCACHE:
{
- i.decode_cid();
- i.decode_oid();
- i.decode_length();
- i.decode_length();
// deprecated, no-op
}
break;
case Transaction::OP_TRUNCATE:
{
- coll_t cid = i.decode_cid();
- ghobject_t oid = i.decode_oid();
- uint64_t off = i.decode_length();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
+ uint64_t off = op->off;
tracepoint(objectstore, truncate_enter, osr_name, off);
- if (_check_replay_guard(cid, oid, spos) > 0)
- r = _truncate(cid, oid, off);
+ if (_check_replay_guard(cid, oid, spos) > 0)
+ r = _truncate(cid, oid, off);
tracepoint(objectstore, truncate_exit, r);
}
break;
case Transaction::OP_REMOVE:
{
- coll_t cid = i.decode_cid();
- ghobject_t oid = i.decode_oid();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
tracepoint(objectstore, remove_enter, osr_name);
- if (_check_replay_guard(cid, oid, spos) > 0)
- r = _remove(cid, oid, spos);
+ if (_check_replay_guard(cid, oid, spos) > 0)
+ r = _remove(cid, oid, spos);
tracepoint(objectstore, remove_exit, r);
}
break;
case Transaction::OP_SETATTR:
{
- coll_t cid = i.decode_cid();
- ghobject_t oid = i.decode_oid();
- string name = i.decode_attrname();
- bufferlist bl;
- i.decode_bl(bl);
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
+ string name = i.decode_string();
+ bufferlist bl;
+ i.decode_bl(bl);
tracepoint(objectstore, setattr_enter, osr_name);
- if (_check_replay_guard(cid, oid, spos) > 0) {
- map<string, bufferptr> to_set;
- to_set[name] = bufferptr(bl.c_str(), bl.length());
- r = _setattrs(cid, oid, to_set, spos);
- if (r == -ENOSPC)
- dout(0) << " ENOSPC on setxattr on " << cid << "/" << oid
- << " name " << name << " size " << bl.length() << dendl;
- }
+ if (_check_replay_guard(cid, oid, spos) > 0) {
+ map<string, bufferptr> to_set;
+ to_set[name] = bufferptr(bl.c_str(), bl.length());
+ r = _setattrs(cid, oid, to_set, spos);
+ if (r == -ENOSPC)
+ dout(0) << " ENOSPC on setxattr on " << cid << "/" << oid
+ << " name " << name << " size " << bl.length() << dendl;
+ }
tracepoint(objectstore, setattr_exit, r);
}
break;
case Transaction::OP_SETATTRS:
{
- coll_t cid = i.decode_cid();
- ghobject_t oid = i.decode_oid();
- map<string, bufferptr> aset;
- i.decode_attrset(aset);
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
+ map<string, bufferptr> aset;
+ i.decode_attrset(aset);
tracepoint(objectstore, setattrs_enter, osr_name);
- if (_check_replay_guard(cid, oid, spos) > 0)
- r = _setattrs(cid, oid, aset, spos);
+ if (_check_replay_guard(cid, oid, spos) > 0)
+ r = _setattrs(cid, oid, aset, spos);
tracepoint(objectstore, setattrs_exit, r);
- if (r == -ENOSPC)
- dout(0) << " ENOSPC on setxattrs on " << cid << "/" << oid << dendl;
+ if (r == -ENOSPC)
+ dout(0) << " ENOSPC on setxattrs on " << cid << "/" << oid << dendl;
}
break;
case Transaction::OP_RMATTR:
{
- coll_t cid = i.decode_cid();
- ghobject_t oid = i.decode_oid();
- string name = i.decode_attrname();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
+ string name = i.decode_string();
tracepoint(objectstore, rmattr_enter, osr_name);
- if (_check_replay_guard(cid, oid, spos) > 0)
- r = _rmattr(cid, oid, name.c_str(), spos);
+ if (_check_replay_guard(cid, oid, spos) > 0)
+ r = _rmattr(cid, oid, name.c_str(), spos);
tracepoint(objectstore, rmattr_exit, r);
}
break;
case Transaction::OP_RMATTRS:
{
- coll_t cid = i.decode_cid();
- ghobject_t oid = i.decode_oid();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
tracepoint(objectstore, rmattrs_enter, osr_name);
- if (_check_replay_guard(cid, oid, spos) > 0)
- r = _rmattrs(cid, oid, spos);
+ if (_check_replay_guard(cid, oid, spos) > 0)
+ r = _rmattrs(cid, oid, spos);
tracepoint(objectstore, rmattrs_exit, r);
}
break;
case Transaction::OP_CLONE:
{
- coll_t cid = i.decode_cid();
- ghobject_t oid = i.decode_oid();
- ghobject_t noid = i.decode_oid();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
+ ghobject_t noid = i.get_oid(op->dest_oid);
tracepoint(objectstore, clone_enter, osr_name);
- r = _clone(cid, oid, noid, spos);
+ r = _clone(cid, oid, noid, spos);
tracepoint(objectstore, clone_exit, r);
}
break;
case Transaction::OP_CLONERANGE:
{
- coll_t cid = i.decode_cid();
- ghobject_t oid = i.decode_oid();
- ghobject_t noid = i.decode_oid();
- uint64_t off = i.decode_length();
- uint64_t len = i.decode_length();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
+ ghobject_t noid = i.get_oid(op->dest_oid);
+ uint64_t off = op->off;
+ uint64_t len = op->len;
tracepoint(objectstore, clone_range_enter, osr_name, len);
- r = _clone_range(cid, oid, noid, off, len, off, spos);
+ r = _clone_range(cid, oid, noid, off, len, off, spos);
tracepoint(objectstore, clone_range_exit, r);
}
break;
case Transaction::OP_CLONERANGE2:
{
- coll_t cid = i.decode_cid();
- ghobject_t oid = i.decode_oid();
- ghobject_t noid = i.decode_oid();
- uint64_t srcoff = i.decode_length();
- uint64_t len = i.decode_length();
- uint64_t dstoff = i.decode_length();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
+ ghobject_t noid = i.get_oid(op->dest_oid);
+ uint64_t srcoff = op->off;
+ uint64_t len = op->len;
+ uint64_t dstoff = op->dest_off;
tracepoint(objectstore, clone_range2_enter, osr_name, len);
- r = _clone_range(cid, oid, noid, srcoff, len, dstoff, spos);
+ r = _clone_range(cid, oid, noid, srcoff, len, dstoff, spos);
tracepoint(objectstore, clone_range2_exit, r);
}
break;
case Transaction::OP_MKCOLL:
{
- coll_t cid = i.decode_cid();
+ coll_t cid = i.get_cid(op->cid);
tracepoint(objectstore, mkcoll_enter, osr_name);
- if (_check_replay_guard(cid, spos) > 0)
- r = _create_collection(cid, spos);
+ if (_check_replay_guard(cid, spos) > 0)
+ r = _create_collection(cid, spos);
tracepoint(objectstore, mkcoll_exit, r);
}
break;
case Transaction::OP_COLL_HINT:
{
- coll_t cid = i.decode_cid();
- uint32_t type = i.decode_u32();
+ coll_t cid = i.get_cid(op->cid);
+ uint32_t type = op->hint_type;
bufferlist hint;
i.decode_bl(hint);
bufferlist::iterator hiter = hint.begin();
case Transaction::OP_RMCOLL:
{
- coll_t cid = i.decode_cid();
+ coll_t cid = i.get_cid(op->cid);
tracepoint(objectstore, rmcoll_enter, osr_name);
- if (_check_replay_guard(cid, spos) > 0)
- r = _destroy_collection(cid);
+ if (_check_replay_guard(cid, spos) > 0)
+ r = _destroy_collection(cid);
tracepoint(objectstore, rmcoll_exit, r);
}
break;
case Transaction::OP_COLL_ADD:
{
- coll_t ncid = i.decode_cid();
- coll_t ocid = i.decode_cid();
- ghobject_t oid = i.decode_oid();
-
- // always followed by OP_COLL_REMOVE
- int op = i.decode_op();
- coll_t ocid2 = i.decode_cid();
- ghobject_t oid2 = i.decode_oid();
- assert(op == Transaction::OP_COLL_REMOVE);
- assert(ocid2 == ocid);
- assert(oid2 == oid);
+ coll_t ocid = i.get_cid(op->cid);
+ coll_t ncid = i.get_cid(op->dest_cid);
+ ghobject_t oid = i.get_oid(op->oid);
+
+ // always followed by OP_COLL_REMOVE
+ Transaction::Op *op2 = i.decode_op();
+ coll_t ocid2 = i.get_cid(op2->cid);
+ ghobject_t oid2 = i.get_oid(op2->oid);
+ assert(op2->op == Transaction::OP_COLL_REMOVE);
+ assert(ocid2 == ocid);
+ assert(oid2 == oid);
tracepoint(objectstore, coll_add_enter);
- r = _collection_add(ncid, ocid, oid, spos);
+ r = _collection_add(ncid, ocid, oid, spos);
tracepoint(objectstore, coll_add_exit, r);
- spos.op++;
- if (r < 0)
- break;
+ spos.op++;
+ if (r < 0)
+ break;
tracepoint(objectstore, coll_remove_enter, osr_name);
- if (_check_replay_guard(ocid, oid, spos) > 0)
- r = _remove(ocid, oid, spos);
+ if (_check_replay_guard(ocid, oid, spos) > 0)
+ r = _remove(ocid, oid, spos);
tracepoint(objectstore, coll_remove_exit, r);
- }
+ }
break;
case Transaction::OP_COLL_MOVE:
{
- // WARNING: this is deprecated and buggy; only here to replay old journals.
- coll_t ocid = i.decode_cid();
- coll_t ncid = i.decode_cid();
- ghobject_t oid = i.decode_oid();
+ // WARNING: this is deprecated and buggy; only here to replay old journals.
+ coll_t ocid = i.get_cid(op->cid);
+ coll_t ncid = i.get_cid(op->dest_cid);
+ ghobject_t oid = i.get_oid(op->oid);
tracepoint(objectstore, coll_move_enter);
- r = _collection_add(ocid, ncid, oid, spos);
- if (r == 0 &&
- (_check_replay_guard(ocid, oid, spos) > 0))
- r = _remove(ocid, oid, spos);
+ r = _collection_add(ocid, ncid, oid, spos);
+ if (r == 0 &&
+ (_check_replay_guard(ocid, oid, spos) > 0))
+ r = _remove(ocid, oid, spos);
tracepoint(objectstore, coll_move_exit, r);
}
break;
case Transaction::OP_COLL_MOVE_RENAME:
{
- coll_t oldcid = i.decode_cid();
- ghobject_t oldoid = i.decode_oid();
- coll_t newcid = i.decode_cid();
- ghobject_t newoid = i.decode_oid();
+ coll_t oldcid = i.get_cid(op->cid);
+ ghobject_t oldoid = i.get_oid(op->oid);
+ coll_t newcid = i.get_cid(op->dest_cid);
+ ghobject_t newoid = i.get_oid(op->dest_oid);
tracepoint(objectstore, coll_move_rename_enter);
- r = _collection_move_rename(oldcid, oldoid, newcid, newoid, spos);
+ r = _collection_move_rename(oldcid, oldoid, newcid, newoid, spos);
tracepoint(objectstore, coll_move_rename_exit, r);
}
break;
case Transaction::OP_COLL_SETATTR:
{
- coll_t cid = i.decode_cid();
- string name = i.decode_attrname();
- bufferlist bl;
- i.decode_bl(bl);
+ coll_t cid = i.get_cid(op->cid);
+ string name = i.decode_string();
+ bufferlist bl;
+ i.decode_bl(bl);
tracepoint(objectstore, coll_setattr_enter, osr_name);
- if (_check_replay_guard(cid, spos) > 0)
- r = _collection_setattr(cid, name.c_str(), bl.c_str(), bl.length());
+ if (_check_replay_guard(cid, spos) > 0)
+ r = _collection_setattr(cid, name.c_str(), bl.c_str(), bl.length());
tracepoint(objectstore, coll_setattr_exit, r);
}
break;
case Transaction::OP_COLL_RMATTR:
{
- coll_t cid = i.decode_cid();
- string name = i.decode_attrname();
+ coll_t cid = i.get_cid(op->cid);
+ string name = i.decode_string();
tracepoint(objectstore, coll_rmattr_enter, osr_name);
- if (_check_replay_guard(cid, spos) > 0)
- r = _collection_rmattr(cid, name.c_str());
+ if (_check_replay_guard(cid, spos) > 0)
+ r = _collection_rmattr(cid, name.c_str());
tracepoint(objectstore, coll_rmattr_exit, r);
}
break;
case Transaction::OP_COLL_RENAME:
{
- coll_t cid(i.decode_cid());
- coll_t ncid(i.decode_cid());
- r = -EOPNOTSUPP;
+ r = -EOPNOTSUPP;
}
break;
case Transaction::OP_OMAP_CLEAR:
{
- coll_t cid(i.decode_cid());
- ghobject_t oid = i.decode_oid();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
tracepoint(objectstore, omap_clear_enter, osr_name);
- r = _omap_clear(cid, oid, spos);
+ r = _omap_clear(cid, oid, spos);
tracepoint(objectstore, omap_clear_exit, r);
}
break;
case Transaction::OP_OMAP_SETKEYS:
{
- coll_t cid(i.decode_cid());
- ghobject_t oid = i.decode_oid();
- map<string, bufferlist> aset;
- i.decode_attrset(aset);
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
+ map<string, bufferlist> aset;
+ i.decode_attrset(aset);
tracepoint(objectstore, omap_setkeys_enter, osr_name);
- r = _omap_setkeys(cid, oid, aset, spos);
+ r = _omap_setkeys(cid, oid, aset, spos);
tracepoint(objectstore, omap_setkeys_exit, r);
}
break;
case Transaction::OP_OMAP_RMKEYS:
{
- coll_t cid(i.decode_cid());
- ghobject_t oid = i.decode_oid();
- set<string> keys;
- i.decode_keyset(keys);
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
+ set<string> keys;
+ i.decode_keyset(keys);
tracepoint(objectstore, omap_rmkeys_enter, osr_name);
- r = _omap_rmkeys(cid, oid, keys, spos);
+ r = _omap_rmkeys(cid, oid, keys, spos);
tracepoint(objectstore, omap_rmkeys_exit, r);
}
break;
case Transaction::OP_OMAP_RMKEYRANGE:
{
- coll_t cid(i.decode_cid());
- ghobject_t oid = i.decode_oid();
- string first, last;
- first = i.decode_key();
- last = i.decode_key();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
+ string first, last;
+ first = i.decode_string();
+ last = i.decode_string();
tracepoint(objectstore, omap_rmkeyrange_enter, osr_name);
- r = _omap_rmkeyrange(cid, oid, first, last, spos);
+ r = _omap_rmkeyrange(cid, oid, first, last, spos);
tracepoint(objectstore, omap_rmkeyrange_exit, r);
}
break;
case Transaction::OP_OMAP_SETHEADER:
{
- coll_t cid(i.decode_cid());
- ghobject_t oid = i.decode_oid();
- bufferlist bl;
- i.decode_bl(bl);
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
+ bufferlist bl;
+ i.decode_bl(bl);
tracepoint(objectstore, omap_setheader_enter, osr_name);
- r = _omap_setheader(cid, oid, bl, spos);
+ r = _omap_setheader(cid, oid, bl, spos);
tracepoint(objectstore, omap_setheader_exit, r);
}
break;
case Transaction::OP_SPLIT_COLLECTION:
{
- coll_t cid(i.decode_cid());
- uint32_t bits(i.decode_u32());
- uint32_t rem(i.decode_u32());
- coll_t dest(i.decode_cid());
+ coll_t cid = i.get_cid(op->cid);
+ uint32_t bits = op->split_bits;
+ uint32_t rem = op->split_rem;
+ coll_t dest = i.get_cid(op->dest_cid);
tracepoint(objectstore, split_coll_enter, osr_name);
- r = _split_collection_create(cid, bits, rem, dest, spos);
+ r = _split_collection_create(cid, bits, rem, dest, spos);
tracepoint(objectstore, split_coll_exit, r);
}
break;
case Transaction::OP_SPLIT_COLLECTION2:
{
- coll_t cid(i.decode_cid());
- uint32_t bits(i.decode_u32());
- uint32_t rem(i.decode_u32());
- coll_t dest(i.decode_cid());
+ coll_t cid = i.get_cid(op->cid);
+ uint32_t bits = op->split_bits;
+ uint32_t rem = op->split_rem;
+ coll_t dest = i.get_cid(op->dest_cid);
tracepoint(objectstore, split_coll2_enter, osr_name);
- r = _split_collection(cid, bits, rem, dest, spos);
+ r = _split_collection(cid, bits, rem, dest, spos);
tracepoint(objectstore, split_coll2_exit, r);
}
break;
case Transaction::OP_SETALLOCHINT:
{
- coll_t cid = i.decode_cid();
- ghobject_t oid = i.decode_oid();
- uint64_t expected_object_size = i.decode_length();
- uint64_t expected_write_size = i.decode_length();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
+ uint64_t expected_object_size = op->expected_object_size;
+ uint64_t expected_write_size = op->expected_write_size;
tracepoint(objectstore, setallochint_enter, osr_name);
if (_check_replay_guard(cid, oid, spos) > 0)
r = _set_alloc_hint(cid, oid, expected_object_size,
break;
default:
- derr << "bad op " << op << dendl;
+ derr << "bad op " << op->op << dendl;
assert(0);
}
if (r < 0) {
bool ok = false;
- if (r == -ENOENT && !(op == Transaction::OP_CLONERANGE ||
- op == Transaction::OP_CLONE ||
- op == Transaction::OP_CLONERANGE2 ||
- op == Transaction::OP_COLL_ADD))
+ if (r == -ENOENT && !(op->op == Transaction::OP_CLONERANGE ||
+ op->op == Transaction::OP_CLONE ||
+ op->op == Transaction::OP_CLONERANGE2 ||
+ op->op == Transaction::OP_COLL_ADD))
// -ENOENT is normally okay
// ...including on a replayed OP_RMCOLL with checkpoint mode
ok = true;
if (r == -ENODATA)
ok = true;
- if (op == Transaction::OP_SETALLOCHINT)
+ if (op->op == Transaction::OP_SETALLOCHINT)
// Either EOPNOTSUPP or EINVAL most probably. EINVAL in most
// cases means invalid hint size (e.g. too big, not a multiple
// of block size, etc) or, at least on xfs, an attempt to set
ok = true;
if (replaying && !backend->can_checkpoint()) {
- if (r == -EEXIST && op == Transaction::OP_MKCOLL) {
+ if (r == -EEXIST && op->op == Transaction::OP_MKCOLL) {
dout(10) << "tolerating EEXIST during journal replay since checkpoint is not enabled" << dendl;
ok = true;
}
- if (r == -EEXIST && op == Transaction::OP_COLL_ADD) {
+ if (r == -EEXIST && op->op == Transaction::OP_COLL_ADD) {
dout(10) << "tolerating EEXIST during journal replay since checkpoint is not enabled" << dendl;
ok = true;
}
- if (r == -EEXIST && op == Transaction::OP_COLL_MOVE) {
+ if (r == -EEXIST && op->op == Transaction::OP_COLL_MOVE) {
dout(10) << "tolerating EEXIST during journal replay since checkpoint is not enabled" << dendl;
ok = true;
}
if (!ok) {
const char *msg = "unexpected error code";
- if (r == -ENOENT && (op == Transaction::OP_CLONERANGE ||
- op == Transaction::OP_CLONE ||
- op == Transaction::OP_CLONERANGE2))
+ if (r == -ENOENT && (op->op == Transaction::OP_CLONERANGE ||
+ op->op == Transaction::OP_CLONE ||
+ op->op == Transaction::OP_CLONERANGE2))
msg = "ENOENT on clone suggests osd bug";
if (r == -ENOSPC)
if (handle)
handle->reset_tp_timeout();
- int op = i.decode_op();
+ Transaction::Op *op = i.decode_op();
int r = 0;
- switch (op) {
+ switch (op->op) {
case Transaction::OP_NOP:
break;
case Transaction::OP_TOUCH:
{
- coll_t cid = i.decode_cid();
- ghobject_t oid = i.decode_oid();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
r = _touch(cid, oid, t);
}
break;
case Transaction::OP_WRITE:
{
- coll_t cid = i.decode_cid();
- ghobject_t oid = i.decode_oid();
- uint64_t off = i.decode_length();
- uint64_t len = i.decode_length();
- uint32_t fadvise_flags = i.get_fadvise_flags();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
+ uint64_t off = op->off;
+ uint64_t len = op->len;
+ uint32_t fadvise_flags = i.get_fadvise_flags();
bufferlist bl;
i.decode_bl(bl);
r = _write(cid, oid, off, len, bl, t, fadvise_flags);
case Transaction::OP_ZERO:
{
- coll_t cid = i.decode_cid();
- ghobject_t oid = i.decode_oid();
- uint64_t off = i.decode_length();
- uint64_t len = i.decode_length();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
+ uint64_t off = op->off;
+ uint64_t len = op->len;
r = _zero(cid, oid, off, len, t);
}
break;
case Transaction::OP_TRIMCACHE:
{
- i.decode_cid();
- i.decode_oid();
- i.decode_length();
- i.decode_length();
// deprecated, no-op
}
break;
case Transaction::OP_TRUNCATE:
{
- coll_t cid = i.decode_cid();
- ghobject_t oid = i.decode_oid();
- uint64_t off = i.decode_length();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
+ uint64_t off = op->off;
r = _truncate(cid, oid, off, t);
}
break;
case Transaction::OP_REMOVE:
{
- coll_t cid = i.decode_cid();
- ghobject_t oid = i.decode_oid();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
r = _remove(cid, oid, t);
}
break;
case Transaction::OP_SETATTR:
{
- coll_t cid = i.decode_cid();
- ghobject_t oid = i.decode_oid();
- string name = i.decode_attrname();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
+ string name = i.decode_string();
bufferlist bl;
i.decode_bl(bl);
map<string, bufferptr> to_set;
case Transaction::OP_SETATTRS:
{
- coll_t cid = i.decode_cid();
- ghobject_t oid = i.decode_oid();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
map<string, bufferptr> aset;
i.decode_attrset(aset);
r = _setattrs(cid, oid, aset, t);
case Transaction::OP_RMATTR:
{
- coll_t cid = i.decode_cid();
- ghobject_t oid = i.decode_oid();
- string name = i.decode_attrname();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
+ string name = i.decode_string();
r = _rmattr(cid, oid, name.c_str(), t);
}
break;
case Transaction::OP_RMATTRS:
{
- coll_t cid = i.decode_cid();
- ghobject_t oid = i.decode_oid();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
r = _rmattrs(cid, oid, t);
}
break;
case Transaction::OP_CLONE:
{
- coll_t cid = i.decode_cid();
- ghobject_t oid = i.decode_oid();
- ghobject_t noid = i.decode_oid();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
+ ghobject_t noid = i.get_oid(op->dest_oid);
exist_clone = true;
r = _clone(cid, oid, noid, t);
}
case Transaction::OP_CLONERANGE:
{
- coll_t cid = i.decode_cid();
- ghobject_t oid = i.decode_oid();
- ghobject_t noid = i.decode_oid();
- uint64_t off = i.decode_length();
- uint64_t len = i.decode_length();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
+ ghobject_t noid = i.get_oid(op->dest_oid);
+ uint64_t off = op->off;
+ uint64_t len = op->len;
exist_clone = true;
r = _clone_range(cid, oid, noid, off, len, off, t);
}
case Transaction::OP_CLONERANGE2:
{
- coll_t cid = i.decode_cid();
- ghobject_t oid = i.decode_oid();
- ghobject_t noid = i.decode_oid();
- uint64_t srcoff = i.decode_length();
- uint64_t len = i.decode_length();
- uint64_t dstoff = i.decode_length();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
+ ghobject_t noid = i.get_oid(op->dest_oid);
+ uint64_t srcoff = op->off;
+ uint64_t len = op->len;
+ uint64_t dstoff = op->dest_off;
exist_clone = true;
r = _clone_range(cid, oid, noid, srcoff, len, dstoff, t);
}
case Transaction::OP_MKCOLL:
{
- coll_t cid = i.decode_cid();
+ coll_t cid = i.get_cid(op->cid);
r = _create_collection(cid, t);
}
break;
case Transaction::OP_COLL_HINT:
{
- coll_t cid = i.decode_cid();
- uint32_t type = i.decode_u32();
+ coll_t cid = i.get_cid(op->cid);
+ uint32_t type = op->hint_type;
bufferlist hint;
i.decode_bl(hint);
bufferlist::iterator hiter = hint.begin();
case Transaction::OP_RMCOLL:
{
- coll_t cid = i.decode_cid();
+ coll_t cid = i.get_cid(op->cid);
r = _destroy_collection(cid, t);
}
break;
case Transaction::OP_COLL_ADD:
{
- coll_t ncid = i.decode_cid();
- coll_t ocid = i.decode_cid();
- ghobject_t oid = i.decode_oid();
+ coll_t ocid = i.get_cid(op->cid);
+ coll_t ncid = i.get_cid(op->dest_cid);
+ ghobject_t oid = i.get_oid(op->oid);
r = _collection_add(ncid, ocid, oid, t);
}
break;
case Transaction::OP_COLL_REMOVE:
{
- coll_t cid = i.decode_cid();
- ghobject_t oid = i.decode_oid();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
r = _remove(cid, oid, t);
}
break;
case Transaction::OP_COLL_MOVE:
{
// WARNING: this is deprecated and buggy; only here to replay old journals.
- coll_t ocid = i.decode_cid();
- coll_t ncid = i.decode_cid();
- ghobject_t oid = i.decode_oid();
+ coll_t ocid = i.get_cid(op->cid);
+ coll_t ncid = i.get_cid(op->dest_cid);
+ ghobject_t oid = i.get_oid(op->oid);
r = _collection_move_rename(ocid, oid, ncid, oid, t);
}
break;
case Transaction::OP_COLL_MOVE_RENAME:
{
- coll_t oldcid = i.decode_cid();
- ghobject_t oldoid = i.decode_oid();
- coll_t newcid = i.decode_cid();
- ghobject_t newoid = i.decode_oid();
+ coll_t oldcid = i.get_cid(op->cid);
+ ghobject_t oldoid = i.get_oid(op->oid);
+ 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, t);
}
break;
case Transaction::OP_COLL_SETATTR:
{
- coll_t cid = i.decode_cid();
- string name = i.decode_attrname();
+ coll_t cid = i.get_cid(op->cid);
+ string name = i.decode_string();
bufferlist bl;
i.decode_bl(bl);
r = _collection_setattr(cid, name.c_str(), bl.c_str(), bl.length(), t);
case Transaction::OP_COLL_RMATTR:
{
- coll_t cid = i.decode_cid();
- string name = i.decode_attrname();
+ coll_t cid = i.get_cid(op->cid);
+ string name = i.decode_string();
r = _collection_rmattr(cid, name.c_str(), t);
}
break;
case Transaction::OP_COLL_RENAME:
{
- coll_t cid(i.decode_cid());
- coll_t ncid(i.decode_cid());
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
r = -EOPNOTSUPP;
}
break;
case Transaction::OP_OMAP_CLEAR:
{
- coll_t cid(i.decode_cid());
- ghobject_t oid = i.decode_oid();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
r = _omap_clear(cid, oid, t);
}
break;
case Transaction::OP_OMAP_SETKEYS:
{
- coll_t cid(i.decode_cid());
- ghobject_t oid = i.decode_oid();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
map<string, bufferlist> aset;
i.decode_attrset(aset);
r = _omap_setkeys(cid, oid, aset, t);
break;
case Transaction::OP_OMAP_RMKEYS:
{
- coll_t cid(i.decode_cid());
- ghobject_t oid = i.decode_oid();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
set<string> keys;
i.decode_keyset(keys);
r = _omap_rmkeys(cid, oid, keys, t);
break;
case Transaction::OP_OMAP_RMKEYRANGE:
{
- coll_t cid(i.decode_cid());
- ghobject_t oid = i.decode_oid();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
string first, last;
- first = i.decode_key();
- last = i.decode_key();
+ first = i.decode_string();
+ last = i.decode_string();
r = _omap_rmkeyrange(cid, oid, first, last, t);
}
break;
case Transaction::OP_OMAP_SETHEADER:
{
- coll_t cid(i.decode_cid());
- ghobject_t oid = i.decode_oid();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
bufferlist bl;
i.decode_bl(bl);
r = _omap_setheader(cid, oid, bl, t);
break;
case Transaction::OP_SPLIT_COLLECTION:
{
- coll_t cid(i.decode_cid());
- uint32_t bits(i.decode_u32());
- uint32_t rem(i.decode_u32());
- coll_t dest(i.decode_cid());
+ coll_t cid = i.get_cid(op->cid);
+ uint32_t bits = op->split_bits;
+ uint32_t rem = op->split_rem;
+ coll_t dest = i.get_cid(op->dest_cid);
r = _split_collection_create(cid, bits, rem, dest, t);
}
break;
case Transaction::OP_SPLIT_COLLECTION2:
{
- coll_t cid(i.decode_cid());
- uint32_t bits(i.decode_u32());
- uint32_t rem(i.decode_u32());
- coll_t dest(i.decode_cid());
+ coll_t cid = i.get_cid(op->cid);
+ uint32_t bits = op->split_bits;
+ uint32_t rem = op->split_rem;
+ coll_t dest = i.get_cid(op->dest_cid);
r = _split_collection(cid, bits, rem, dest, t);
}
break;
case Transaction::OP_SETALLOCHINT:
{
- coll_t cid(i.decode_cid());
- ghobject_t oid = i.decode_oid();
- uint64_t expected_object_size = i.decode_length();
- uint64_t expected_write_size = i.decode_length();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
+ uint64_t expected_object_size = op->expected_object_size;
+ uint64_t expected_write_size = op->expected_write_size;
r = _set_alloc_hint(cid, oid, expected_object_size,
expected_write_size, t);
}
break;
default:
- derr << "bad op " << op << dendl;
+ derr << "bad op " << op->op << dendl;
assert(0);
}
if (r < 0) {
bool ok = false;
- if (r == -ENOENT && !(op == Transaction::OP_CLONERANGE ||
- op == Transaction::OP_CLONE ||
- op == Transaction::OP_CLONERANGE2))
+ if (r == -ENOENT && !(op->op == Transaction::OP_CLONERANGE ||
+ op->op == Transaction::OP_CLONE ||
+ op->op == Transaction::OP_CLONERANGE2 ||
+ op->op == Transaction::OP_COLL_ADD))
// -ENOENT is normally okay
// ...including on a replayed OP_RMCOLL with checkpoint mode
ok = true;
}
dout(0) << " error " << cpp_strerror(r) << " not handled on operation "
- << op << " op " << op_num << ", counting from 0)" << dendl;
+ << op->op << " op " << op_num << ", counting from 0)" << dendl;
dout(0) << msg << dendl;
dout(0) << " transaction dump:\n";
JSONFormatter f(true);
int pos = 0;
while (i.have_op()) {
- int op = i.decode_op();
+ Transaction::Op *op = i.decode_op();
int r = 0;
- switch (op) {
+ switch (op->op) {
case Transaction::OP_NOP:
break;
case Transaction::OP_TOUCH:
{
- coll_t cid = i.decode_cid();
- ghobject_t oid = i.decode_oid();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
r = _touch(cid, oid);
}
break;
case Transaction::OP_WRITE:
{
- coll_t cid = i.decode_cid();
- ghobject_t oid = i.decode_oid();
- uint64_t off = i.decode_length();
- uint64_t len = i.decode_length();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
+ uint64_t off = op->off;
+ uint64_t len = op->len;
uint32_t fadvise_flags = i.get_fadvise_flags();
- bufferlist bl;
- i.decode_bl(bl);
+ bufferlist bl;
+ i.decode_bl(bl);
r = _write(cid, oid, off, len, bl, fadvise_flags);
}
break;
case Transaction::OP_ZERO:
{
- coll_t cid = i.decode_cid();
- ghobject_t oid = i.decode_oid();
- uint64_t off = i.decode_length();
- uint64_t len = i.decode_length();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
+ uint64_t off = op->off;
+ uint64_t len = op->len;
r = _zero(cid, oid, off, len);
}
break;
case Transaction::OP_TRIMCACHE:
{
- i.decode_cid();
- i.decode_oid();
- i.decode_length();
- i.decode_length();
- // deprecated, no-op
+ // deprecated, no-op
}
break;
case Transaction::OP_TRUNCATE:
{
- coll_t cid = i.decode_cid();
- ghobject_t oid = i.decode_oid();
- uint64_t off = i.decode_length();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
+ uint64_t off = op->off;
r = _truncate(cid, oid, off);
}
break;
case Transaction::OP_REMOVE:
{
- coll_t cid = i.decode_cid();
- ghobject_t oid = i.decode_oid();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
r = _remove(cid, oid);
}
break;
case Transaction::OP_SETATTR:
{
- coll_t cid = i.decode_cid();
- ghobject_t oid = i.decode_oid();
- string name = i.decode_attrname();
- bufferlist bl;
- i.decode_bl(bl);
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
+ string name = i.decode_string();
+ bufferlist bl;
+ i.decode_bl(bl);
map<string, bufferptr> to_set;
to_set[name] = bufferptr(bl.c_str(), bl.length());
r = _setattrs(cid, oid, to_set);
case Transaction::OP_SETATTRS:
{
- coll_t cid = i.decode_cid();
- ghobject_t oid = i.decode_oid();
- map<string, bufferptr> aset;
- i.decode_attrset(aset);
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
+ map<string, bufferptr> aset;
+ i.decode_attrset(aset);
r = _setattrs(cid, oid, aset);
}
break;
case Transaction::OP_RMATTR:
{
- coll_t cid = i.decode_cid();
- ghobject_t oid = i.decode_oid();
- string name = i.decode_attrname();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
+ string name = i.decode_string();
r = _rmattr(cid, oid, name.c_str());
}
break;
case Transaction::OP_RMATTRS:
{
- coll_t cid = i.decode_cid();
- ghobject_t oid = i.decode_oid();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
r = _rmattrs(cid, oid);
}
break;
case Transaction::OP_CLONE:
{
- coll_t cid = i.decode_cid();
- ghobject_t oid = i.decode_oid();
- ghobject_t noid = i.decode_oid();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
+ ghobject_t noid = i.get_oid(op->dest_oid);
r = _clone(cid, oid, noid);
}
break;
case Transaction::OP_CLONERANGE:
{
- coll_t cid = i.decode_cid();
- ghobject_t oid = i.decode_oid();
- ghobject_t noid = i.decode_oid();
- uint64_t off = i.decode_length();
- uint64_t len = i.decode_length();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
+ ghobject_t noid = i.get_oid(op->dest_oid);
+ uint64_t off = op->off;
+ uint64_t len = op->len;
r = _clone_range(cid, oid, noid, off, len, off);
}
break;
case Transaction::OP_CLONERANGE2:
{
- coll_t cid = i.decode_cid();
- ghobject_t oid = i.decode_oid();
- ghobject_t noid = i.decode_oid();
- uint64_t srcoff = i.decode_length();
- uint64_t len = i.decode_length();
- uint64_t dstoff = i.decode_length();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
+ ghobject_t noid = i.get_oid(op->dest_oid);
+ uint64_t srcoff = op->off;
+ uint64_t len = op->len;
+ uint64_t dstoff = op->dest_off;
r = _clone_range(cid, oid, noid, srcoff, len, dstoff);
}
break;
case Transaction::OP_MKCOLL:
{
- coll_t cid = i.decode_cid();
+ coll_t cid = i.get_cid(op->cid);
r = _create_collection(cid);
}
break;
case Transaction::OP_COLL_HINT:
{
- coll_t cid = i.decode_cid();
- uint32_t type = i.decode_u32();
+ coll_t cid = i.get_cid(op->cid);
+ uint32_t type = op->hint_type;
bufferlist hint;
i.decode_bl(hint);
bufferlist::iterator hiter = hint.begin();
case Transaction::OP_RMCOLL:
{
- coll_t cid = i.decode_cid();
+ coll_t cid = i.get_cid(op->cid);
r = _destroy_collection(cid);
}
break;
case Transaction::OP_COLL_ADD:
{
- coll_t ncid = i.decode_cid();
- coll_t ocid = i.decode_cid();
- ghobject_t oid = i.decode_oid();
+ coll_t ocid = i.get_cid(op->cid);
+ coll_t ncid = i.get_cid(op->dest_cid);
+ ghobject_t oid = i.get_oid(op->oid);
r = _collection_add(ncid, ocid, oid);
}
break;
case Transaction::OP_COLL_REMOVE:
{
- coll_t cid = i.decode_cid();
- ghobject_t oid = i.decode_oid();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
r = _remove(cid, oid);
}
break;
case Transaction::OP_COLL_MOVE_RENAME:
{
- coll_t oldcid = i.decode_cid();
- ghobject_t oldoid = i.decode_oid();
- coll_t newcid = i.decode_cid();
- ghobject_t newoid = i.decode_oid();
+ coll_t oldcid = i.get_cid(op->cid);
+ ghobject_t oldoid = i.get_oid(op->oid);
+ 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);
}
break;
case Transaction::OP_COLL_SETATTR:
{
- coll_t cid = i.decode_cid();
- string name = i.decode_attrname();
- bufferlist bl;
- i.decode_bl(bl);
+ coll_t cid = i.get_cid(op->cid);
+ string name = i.decode_string();
+ bufferlist bl;
+ i.decode_bl(bl);
assert(0 == "not implemented");
}
break;
case Transaction::OP_COLL_RMATTR:
{
- coll_t cid = i.decode_cid();
- string name = i.decode_attrname();
+ coll_t cid = i.get_cid(op->cid);
+ string name = i.decode_string();
assert(0 == "not implemented");
}
break;
case Transaction::OP_COLL_RENAME:
{
- coll_t cid(i.decode_cid());
- coll_t ncid(i.decode_cid());
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
r = -EOPNOTSUPP;
}
break;
case Transaction::OP_OMAP_CLEAR:
{
- coll_t cid(i.decode_cid());
- ghobject_t oid = i.decode_oid();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
r = _omap_clear(cid, oid);
}
break;
case Transaction::OP_OMAP_SETKEYS:
{
- coll_t cid(i.decode_cid());
- ghobject_t oid = i.decode_oid();
- map<string, bufferlist> aset;
- i.decode_attrset(aset);
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
+ map<string, bufferlist> aset;
+ i.decode_attrset(aset);
r = _omap_setkeys(cid, oid, aset);
}
break;
case Transaction::OP_OMAP_RMKEYS:
{
- coll_t cid(i.decode_cid());
- ghobject_t oid = i.decode_oid();
- set<string> keys;
- i.decode_keyset(keys);
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
+ set<string> keys;
+ i.decode_keyset(keys);
r = _omap_rmkeys(cid, oid, keys);
}
break;
case Transaction::OP_OMAP_RMKEYRANGE:
{
- coll_t cid(i.decode_cid());
- ghobject_t oid = i.decode_oid();
- string first, last;
- first = i.decode_key();
- last = i.decode_key();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
+ string first, last;
+ first = i.decode_string();
+ last = i.decode_string();
r = _omap_rmkeyrange(cid, oid, first, last);
}
break;
case Transaction::OP_OMAP_SETHEADER:
{
- coll_t cid(i.decode_cid());
- ghobject_t oid = i.decode_oid();
- bufferlist bl;
- i.decode_bl(bl);
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
+ bufferlist bl;
+ i.decode_bl(bl);
r = _omap_setheader(cid, oid, bl);
}
break;
break;
case Transaction::OP_SPLIT_COLLECTION2:
{
- coll_t cid(i.decode_cid());
- uint32_t bits(i.decode_u32());
- uint32_t rem(i.decode_u32());
- coll_t dest(i.decode_cid());
+ coll_t cid = i.get_cid(op->cid);
+ uint32_t bits = op->split_bits;
+ uint32_t rem = op->split_rem;
+ coll_t dest = i.get_cid(op->dest_cid);
r = _split_collection(cid, bits, rem, dest);
}
break;
case Transaction::OP_SETALLOCHINT:
{
- coll_t cid(i.decode_cid());
- ghobject_t oid = i.decode_oid();
- i.decode_length(); // uint64_t expected_object_size
- i.decode_length(); // uint64_t expected_write_size
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
}
break;
default:
- derr << "bad op " << op << dendl;
+ derr << "bad op " << op->op << dendl;
assert(0);
}
if (r < 0) {
bool ok = false;
- if (r == -ENOENT && !(op == Transaction::OP_CLONERANGE ||
- op == Transaction::OP_CLONE ||
- op == Transaction::OP_CLONERANGE2 ||
- op == Transaction::OP_COLL_ADD))
+ if (r == -ENOENT && !(op->op == Transaction::OP_CLONERANGE ||
+ op->op == Transaction::OP_CLONE ||
+ op->op == Transaction::OP_CLONERANGE2 ||
+ op->op == Transaction::OP_COLL_ADD))
// -ENOENT is usually okay
ok = true;
if (r == -ENODATA)
if (!ok) {
const char *msg = "unexpected error code";
- if (r == -ENOENT && (op == Transaction::OP_CLONERANGE ||
- op == Transaction::OP_CLONE ||
- op == Transaction::OP_CLONERANGE2))
+ if (r == -ENOENT && (op->op == Transaction::OP_CLONERANGE ||
+ op->op == Transaction::OP_CLONE ||
+ op->op == Transaction::OP_CLONERANGE2))
msg = "ENOENT on clone suggests osd bug";
if (r == -ENOSPC)
dump_all();
}
- dout(0) << " error " << cpp_strerror(r) << " not handled on operation " << op
+ dout(0) << " error " << cpp_strerror(r) << " not handled on operation " << op->op
<< " (op " << pos << ", counting from 0)" << dendl;
dout(0) << msg << dendl;
dout(0) << " transaction dump:\n";
__le32 hint_type; //OP_COLL_HINT
__le64 expected_object_size; //OP_SETALLOCHINT
__le64 expected_write_size; //OP_SETALLOCHINT
- __le32 bits; //OP_SPLIT_COLLECTION2
- __le32 rem; //OP_SPLIT_COLLECTION2
+ __le32 split_bits; //OP_SPLIT_COLLECTION2
+ __le32 split_rem; //OP_SPLIT_COLLECTION2
} __attribute__ ((packed)) ;
struct TransactionData {
* buffer decoding operation codes and parameters as we go.
*
*/
- class iterator {
- bufferlist::iterator p;
- uint32_t fadvise_flags;
+ class iterator_impl {
+ public:
+ virtual ~iterator_impl() { }
- iterator(Transaction *t)
- : p(t->tbl.begin()) {}
+ virtual bool have_op() = 0;
+ virtual Op* decode_op() = 0;
+ virtual string decode_string() = 0;
+ virtual void decode_bl(bufferlist& bl) = 0;
+ virtual void decode_attrset(map<string,bufferptr>& aset) = 0;
+ virtual void decode_attrset(map<string,bufferlist>& aset) = 0;
+ virtual void decode_keyset(set<string> &keys) = 0;
+
+ virtual ghobject_t get_oid(__le32 oid_id) = 0;
+ virtual coll_t get_cid(__le32 cid_id) = 0;
+ virtual uint32_t get_fadvise_flags() const = 0;
+
+ friend class Transaction;
+ };
+
+ class map_iterator : public iterator_impl {
+ Transaction *t;
+
+ uint64_t ops;
+ char* op_buffer_p;
+
+ bufferlist::iterator data_bl_p;
+
+ vector<coll_t> colls;
+ vector<ghobject_t> objects;
+
+ map_iterator(Transaction *t)
+ : t(t), data_bl_p(t->data_bl.begin()) {
+
+ ops = t->data.ops;
+ op_buffer_p = t->op_bl.get_contiguous(0, t->data.ops * sizeof(Op));
+
+ colls.resize(t->coll_index.size());
+ map<coll_t, __le32>::iterator coll_index_p;
+ for (coll_index_p = t->coll_index.begin();
+ coll_index_p != t->coll_index.end();
+ coll_index_p++) {
+ colls[coll_index_p->second] = coll_index_p->first;
+ }
+
+ objects.resize(t->object_index.size());
+ map<ghobject_t, __le32>::iterator object_index_p;
+ for (object_index_p = t->object_index.begin();
+ object_index_p != t->object_index.end();
+ object_index_p++) {
+ objects[object_index_p->second] = object_index_p->first;
+ }
+ }
friend class Transaction;
public:
- /// true if there are more operations left to be enumerated
+
bool have_op() {
- return !p.end();
+ return ops > 0;
}
+ Op* decode_op() {
+ assert(ops > 0);
+
+ Op* op = (Op*)op_buffer_p;
+ op_buffer_p += sizeof(Op);
+ ops--;
- /* Decode the specified type of object from the input
- * stream. There is no checking that the encoded data is of the
- * correct type.
- */
- int decode_op() {
- __u32 op;
- ::decode(op, p);
- return op;
+ return op;
+ }
+ string decode_string() {
+ string s;
+ ::decode(s, data_bl_p);
+ return s;
}
void decode_bl(bufferlist& bl) {
- ::decode(bl, p);
- }
- /// Get an oid, recognize various legacy forms and update them.
- ghobject_t decode_oid() {
- ghobject_t oid;
- ::decode(oid, p);
- return oid;
- }
- coll_t decode_cid() {
- coll_t c;
- ::decode(c, p);
- return c;
- }
- uint64_t decode_length() {
- uint64_t len;
- ::decode(len, p);
- return len;
- }
- string decode_attrname() {
- string s;
- ::decode(s, p);
- return s;
- }
- string decode_key() {
- string s;
- ::decode(s, p);
- return s;
+ ::decode(bl, data_bl_p);
}
void decode_attrset(map<string,bufferptr>& aset) {
- ::decode(aset, p);
+ ::decode(aset, data_bl_p);
}
void decode_attrset(map<string,bufferlist>& aset) {
- ::decode(aset, p);
+ ::decode(aset, data_bl_p);
}
- void decode_keyset(set<string> &keys) {
- ::decode(keys, p);
+ void decode_keyset(set<string> &keys){
+ ::decode(keys, data_bl_p);
+ }
+
+ ghobject_t get_oid(__le32 oid_id) {
+ return objects[oid_id];
+ }
+ coll_t get_cid(__le32 cid_id) {
+ return colls[cid_id];
}
- uint32_t decode_u32() {
- uint32_t bits;
- ::decode(bits, p);
- return bits;
+ uint32_t get_fadvise_flags() const {
+ return t->get_fadvise_flags();
}
+ };
- uint32_t get_fadvise_flags() { return fadvise_flags; }
+ class iterator {
+ shared_ptr<iterator_impl> impl;
+
+ public:
+ iterator(Transaction *t) {
+ iterator_impl* iterator = NULL;
+
+ if (t->use_tbl) {
+ assert("tbl is not supported" == 0);
+ iterator = new map_iterator(t);
+ } else {
+ iterator = new map_iterator(t);
+ }
+
+ impl = shared_ptr<iterator_impl>(iterator);
+ }
+
+ bool have_op() {
+ return impl->have_op();
+ }
+ Op* decode_op() {
+ return impl->decode_op();
+ }
+ void decode_bl(bufferlist& bl) {
+ impl->decode_bl(bl);
+ }
+ string decode_string() {
+ return impl->decode_string();
+ }
+ void decode_attrset(map<string,bufferptr>& aset) {
+ impl->decode_attrset(aset);
+ }
+ void decode_attrset(map<string,bufferlist>& aset) {
+ impl->decode_attrset(aset);
+ }
+ void decode_keyset(set<string> &keys) {
+ impl->decode_keyset(keys);
+ }
+
+ ghobject_t get_oid(__le32 oid_id) {
+ return impl->get_oid(oid_id);
+ }
+ coll_t get_cid(__le32 cid_id) {
+ return impl->get_cid(cid_id);
+ }
+ uint32_t get_fadvise_flags() const {
+ return impl->get_fadvise_flags();
+ }
};
iterator begin() {
_op->op = OP_SPLIT_COLLECTION2;
_op->cid = _get_coll_id(cid);
_op->dest_cid = _get_coll_id(destination);
- _op->bits = bits;
- _op->rem = rem;
+ _op->split_bits = bits;
+ _op->split_rem = rem;
}
data.ops++;
}
// etc.
Transaction() :
osr(NULL),
- use_tbl(true),
+ use_tbl(false),
coll_id(0),
object_id(0) {}
Transaction(bufferlist::iterator &dp) :
osr(NULL),
- use_tbl(true),
+ use_tbl(false),
coll_id(0),
object_id(0) {
decode(dp);
Transaction(bufferlist &nbl) :
osr(NULL),
- use_tbl(true),
+ use_tbl(false),
coll_id(0),
object_id(0) {
bufferlist::iterator dp = nbl.begin();
int op_num = 0;
bool stop_looping = false;
while (i.have_op() && !stop_looping) {
- int op = i.decode_op();
+ Transaction::Op *op = i.decode_op();
f->open_object_section("op");
f->dump_int("op_num", op_num);
- switch (op) {
+ switch (op->op) {
case Transaction::OP_NOP:
f->dump_string("op_name", "nop");
break;
case Transaction::OP_TOUCH:
{
- coll_t cid = i.decode_cid();
- ghobject_t oid = i.decode_oid();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
f->dump_string("op_name", "touch");
f->dump_stream("collection") << cid;
f->dump_stream("oid") << oid;
case Transaction::OP_WRITE:
{
- coll_t cid = i.decode_cid();
- ghobject_t oid = i.decode_oid();
- uint64_t off = i.decode_length();
- uint64_t len = i.decode_length();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
+ uint64_t off = op->off;
+ uint64_t len = op->len;
bufferlist bl;
i.decode_bl(bl);
f->dump_string("op_name", "write");
case Transaction::OP_ZERO:
{
- coll_t cid = i.decode_cid();
- ghobject_t oid = i.decode_oid();
- uint64_t off = i.decode_length();
- uint64_t len = i.decode_length();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
+ uint64_t off = op->off;
+ uint64_t len = op->len;
f->dump_string("op_name", "zero");
f->dump_stream("collection") << cid;
f->dump_stream("oid") << oid;
case Transaction::OP_TRIMCACHE:
{
- coll_t cid = i.decode_cid();
- ghobject_t oid = i.decode_oid();
- uint64_t off = i.decode_length();
- uint64_t len = i.decode_length();
+ // deprecated, no-op
f->dump_string("op_name", "trim_cache");
- f->dump_stream("collection") << cid;
- f->dump_stream("oid") << oid;
- f->dump_unsigned("offset", off);
- f->dump_unsigned("length", len);
}
break;
case Transaction::OP_TRUNCATE:
{
- coll_t cid = i.decode_cid();
- ghobject_t oid = i.decode_oid();
- uint64_t off = i.decode_length();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
+ uint64_t off = op->off;
f->dump_string("op_name", "truncate");
f->dump_stream("collection") << cid;
f->dump_stream("oid") << oid;
case Transaction::OP_REMOVE:
{
- coll_t cid = i.decode_cid();
- ghobject_t oid = i.decode_oid();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
f->dump_string("op_name", "remove");
f->dump_stream("collection") << cid;
f->dump_stream("oid") << oid;
case Transaction::OP_SETATTR:
{
- coll_t cid = i.decode_cid();
- ghobject_t oid = i.decode_oid();
- string name = i.decode_attrname();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
+ string name = i.decode_string();
bufferlist bl;
i.decode_bl(bl);
f->dump_string("op_name", "setattr");
case Transaction::OP_SETATTRS:
{
- coll_t cid = i.decode_cid();
- ghobject_t oid = i.decode_oid();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
map<string, bufferptr> aset;
i.decode_attrset(aset);
f->dump_string("op_name", "setattrs");
case Transaction::OP_RMATTR:
{
- coll_t cid = i.decode_cid();
- ghobject_t oid = i.decode_oid();
- string name = i.decode_attrname();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
+ string name = i.decode_string();
f->dump_string("op_name", "rmattr");
f->dump_stream("collection") << cid;
f->dump_stream("oid") << oid;
case Transaction::OP_RMATTRS:
{
- coll_t cid = i.decode_cid();
- ghobject_t oid = i.decode_oid();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
f->dump_string("op_name", "rmattrs");
f->dump_stream("collection") << cid;
f->dump_stream("oid") << oid;
case Transaction::OP_CLONE:
{
- coll_t cid = i.decode_cid();
- ghobject_t oid = i.decode_oid();
- ghobject_t noid = i.decode_oid();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
+ ghobject_t noid = i.get_oid(op->dest_oid);
f->dump_string("op_name", "clone");
f->dump_stream("collection") << cid;
f->dump_stream("src_oid") << oid;
case Transaction::OP_CLONERANGE:
{
- coll_t cid = i.decode_cid();
- ghobject_t oid = i.decode_oid();
- ghobject_t noid = i.decode_oid();
- uint64_t off = i.decode_length();
- uint64_t len = i.decode_length();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
+ ghobject_t noid = i.get_oid(op->dest_oid);
+ uint64_t off = op->off;
+ uint64_t len = op->len;
f->dump_string("op_name", "clonerange");
f->dump_stream("collection") << cid;
f->dump_stream("src_oid") << oid;
case Transaction::OP_CLONERANGE2:
{
- coll_t cid = i.decode_cid();
- ghobject_t oid = i.decode_oid();
- ghobject_t noid = i.decode_oid();
- uint64_t srcoff = i.decode_length();
- uint64_t len = i.decode_length();
- uint64_t dstoff = i.decode_length();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
+ ghobject_t noid = i.get_oid(op->dest_oid);
+ uint64_t srcoff = op->off;
+ uint64_t len = op->len;
+ uint64_t dstoff = op->dest_off;
f->dump_string("op_name", "clonerange2");
f->dump_stream("collection") << cid;
f->dump_stream("src_oid") << oid;
case Transaction::OP_MKCOLL:
{
- coll_t cid = i.decode_cid();
+ coll_t cid = i.get_cid(op->cid);
f->dump_string("op_name", "mkcoll");
f->dump_stream("collection") << cid;
}
case Transaction::OP_COLL_HINT:
{
- coll_t cid = i.decode_cid();
- uint32_t type = i.decode_u32();
+ coll_t cid = i.get_cid(op->cid);
+ uint32_t type = op->hint_type;
f->dump_string("op_name", "coll_hint");
f->dump_stream("collection") << cid;
f->dump_unsigned("type", type);
case Transaction::OP_RMCOLL:
{
- coll_t cid = i.decode_cid();
+ coll_t cid = i.get_cid(op->cid);
f->dump_string("op_name", "rmcoll");
f->dump_stream("collection") << cid;
}
case Transaction::OP_COLL_ADD:
{
- coll_t ncid = i.decode_cid();
- coll_t ocid = i.decode_cid();
- ghobject_t oid = i.decode_oid();
+ coll_t ocid = i.get_cid(op->cid);
+ coll_t ncid = i.get_cid(op->dest_cid);
+ ghobject_t oid = i.get_oid(op->oid);
f->dump_string("op_name", "collection_add");
f->dump_stream("src_collection") << ocid;
f->dump_stream("dst_collection") << ncid;
case Transaction::OP_COLL_REMOVE:
{
- coll_t cid = i.decode_cid();
- ghobject_t oid = i.decode_oid();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
f->dump_string("op_name", "collection_remove");
f->dump_stream("collection") << cid;
f->dump_stream("oid") << oid;
case Transaction::OP_COLL_MOVE:
{
- coll_t ocid = i.decode_cid();
- coll_t ncid = i.decode_cid();
- ghobject_t oid = i.decode_oid();
+ coll_t ocid = i.get_cid(op->cid);
+ coll_t ncid = i.get_cid(op->dest_cid);
+ ghobject_t oid = i.get_oid(op->oid);
f->open_object_section("collection_move");
f->dump_stream("src_collection") << ocid;
f->dump_stream("dst_collection") << ncid;
}
break;
-
case Transaction::OP_COLL_SETATTR:
{
- coll_t cid = i.decode_cid();
- string name = i.decode_attrname();
+ coll_t cid = i.get_cid(op->cid);
+ string name = i.decode_string();
bufferlist bl;
i.decode_bl(bl);
f->dump_string("op_name", "collection_setattr");
case Transaction::OP_COLL_RMATTR:
{
- coll_t cid = i.decode_cid();
- string name = i.decode_attrname();
+ coll_t cid = i.get_cid(op->cid);
+ string name = i.decode_string();
f->dump_string("op_name", "collection_rmattr");
f->dump_stream("collection") << cid;
f->dump_string("name", name);
case Transaction::OP_COLL_RENAME:
{
- coll_t cid(i.decode_cid());
- coll_t ncid(i.decode_cid());
f->dump_string("op_name", "collection_rename");
- f->dump_stream("src_collection") << cid;
- f->dump_stream("dst_collection") << ncid;
}
break;
case Transaction::OP_OMAP_CLEAR:
{
- coll_t cid(i.decode_cid());
- ghobject_t oid = i.decode_oid();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
f->dump_string("op_name", "omap_clear");
f->dump_stream("collection") << cid;
f->dump_stream("oid") << oid;
case Transaction::OP_OMAP_SETKEYS:
{
- coll_t cid(i.decode_cid());
- ghobject_t oid = i.decode_oid();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
map<string, bufferlist> aset;
i.decode_attrset(aset);
f->dump_string("op_name", "omap_setkeys");
case Transaction::OP_OMAP_RMKEYS:
{
- coll_t cid(i.decode_cid());
- ghobject_t oid = i.decode_oid();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
set<string> keys;
i.decode_keyset(keys);
f->dump_string("op_name", "omap_rmkeys");
case Transaction::OP_OMAP_SETHEADER:
{
- coll_t cid(i.decode_cid());
- ghobject_t oid = i.decode_oid();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
bufferlist bl;
i.decode_bl(bl);
f->dump_string("op_name", "omap_setheader");
case Transaction::OP_SPLIT_COLLECTION:
{
- coll_t cid(i.decode_cid());
- uint32_t bits(i.decode_u32());
- uint32_t rem(i.decode_u32());
- coll_t dest(i.decode_cid());
+ coll_t cid = i.get_cid(op->cid);
+ uint32_t bits = op->split_bits;
+ uint32_t rem = op->split_rem;
+ coll_t dest = i.get_cid(op->dest_cid);
f->dump_string("op_name", "op_split_collection_create");
f->dump_stream("collection") << cid;
f->dump_stream("bits") << bits;
case Transaction::OP_SPLIT_COLLECTION2:
{
- coll_t cid(i.decode_cid());
- uint32_t bits(i.decode_u32());
- uint32_t rem(i.decode_u32());
- coll_t dest(i.decode_cid());
+ coll_t cid = i.get_cid(op->cid);
+ uint32_t bits = op->split_bits;
+ uint32_t rem = op->split_rem;
+ coll_t dest = i.get_cid(op->dest_cid);
f->dump_string("op_name", "op_split_collection");
f->dump_stream("collection") << cid;
f->dump_stream("bits") << bits;
case Transaction::OP_OMAP_RMKEYRANGE:
{
- coll_t cid(i.decode_cid());
- ghobject_t oid = i.decode_oid();
- string first, last;
- first = i.decode_key();
- last = i.decode_key();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
+ string first, last;
+ first = i.decode_string();
+ last = i.decode_string();
f->dump_string("op_name", "op_omap_rmkeyrange");
f->dump_stream("collection") << cid;
f->dump_stream("oid") << oid;
case Transaction::OP_COLL_MOVE_RENAME:
{
- coll_t old_cid(i.decode_cid());
- ghobject_t old_oid = i.decode_oid();
- coll_t new_cid(i.decode_cid());
- ghobject_t new_oid = i.decode_oid();
+ coll_t old_cid = i.get_cid(op->cid);
+ ghobject_t old_oid = i.get_oid(op->oid);
+ coll_t new_cid = i.get_cid(op->dest_cid);
+ ghobject_t new_oid = i.get_oid(op->dest_oid);
f->dump_string("op_name", "op_coll_move_rename");
f->dump_stream("old_collection") << old_cid;
f->dump_stream("old_oid") << old_oid;
case Transaction::OP_SETALLOCHINT:
{
- coll_t cid = i.decode_cid();
- ghobject_t oid = i.decode_oid();
- uint64_t expected_object_size = i.decode_length();
- uint64_t expected_write_size = i.decode_length();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
+ uint64_t expected_object_size = op->expected_object_size;
+ uint64_t expected_write_size = op->expected_write_size;
f->dump_string("op_name", "op_setallochint");
f->dump_stream("collection") << cid;
f->dump_stream("oid") << oid;
default:
f->dump_string("op_name", "unknown");
- f->dump_unsigned("op_code", op);
+ f->dump_unsigned("op_code", op->op);
stop_looping = true;
break;
}
uint64_t start_time = Cycles::rdtsc();
ObjectStore::Transaction::iterator i = t.begin();
while (i.have_op()) {
- int op = i.decode_op();
+ ObjectStore::Transaction::Op *op = i.decode_op();
- switch (op) {
+ switch (op->op) {
case ObjectStore::Transaction::OP_WRITE:
{
- coll_t cid = i.decode_cid();
- ghobject_t oid = i.decode_oid();
- i.decode_length();
- i.decode_length();
- i.get_fadvise_flags();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
+ uint64_t off = op->off;
+ uint64_t len = op->len;
+ uint32_t fadvise_flags = i.get_fadvise_flags();
bufferlist bl;
i.decode_bl(bl);
}
break;
case ObjectStore::Transaction::OP_SETATTR:
{
- coll_t cid = i.decode_cid();
- ghobject_t oid = i.decode_oid();
- string name = i.decode_attrname();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
+ string name = i.decode_string();
bufferlist bl;
i.decode_bl(bl);
map<string, bufferptr> to_set;
break;
case ObjectStore::Transaction::OP_OMAP_SETKEYS:
{
- coll_t cid(i.decode_cid());
- ghobject_t oid = i.decode_oid();
- map<string, bufferlist> aset;
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
+ map<string, bufferptr> aset;
i.decode_attrset(aset);
}
break;
case ObjectStore::Transaction::OP_OMAP_RMKEYS:
{
- coll_t cid(i.decode_cid());
- ghobject_t oid = i.decode_oid();
+ coll_t cid = i.get_cid(op->cid);
+ ghobject_t oid = i.get_oid(op->oid);
set<string> keys;
i.decode_keyset(keys);
}