]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: new Transaction::iterator interface
authorDong Yuan <yuandong1222@gmail.com>
Mon, 1 Dec 2014 10:58:56 +0000 (10:58 +0000)
committerSage Weil <sage@redhat.com>
Tue, 6 Jan 2015 21:29:06 +0000 (13:29 -0800)
This patch add new Transaction::iterator interface according to new
encode/decode layout. The new iterator give the whole Op struct in a
single decode_op method.

All ObjectStore Impl (FileStore/MemStore/KeyValueStore) is also changed
to use the new interface.

Change-Id: I1900a6ec302890df2c4357b071e4966c26d7f037
Signed-off-by: Dong Yuan <yuandong1222@gmail.com>
src/os/FileStore.cc
src/os/KeyValueStore.cc
src/os/MemStore.cc
src/os/ObjectStore.h
src/os/Transaction.cc
src/test/objectstore/ObjectStoreTransactionBenchmark.cc

index 7503796b284b78036021aeb4836f87880585c1c5..d44ea82be964ade5b167580c5ab3140a72394ee5 100644 (file)
@@ -2267,197 +2267,193 @@ unsigned FileStore::_do_transaction(
     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();
@@ -2478,88 +2474,88 @@ unsigned FileStore::_do_transaction(
 
     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;
@@ -2572,95 +2568,93 @@ unsigned FileStore::_do_transaction(
 
     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,
@@ -2670,24 +2664,24 @@ unsigned FileStore::_do_transaction(
       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
@@ -2696,15 +2690,15 @@ unsigned FileStore::_do_transaction(
         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;
        }
@@ -2721,9 +2715,9 @@ unsigned FileStore::_do_transaction(
       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)
index e9a889c921aa3f26e4d361ebccf985139b68aef3..95d5f57ff3a78a4cdf6164df23ac86c0b7f1cf2f 100644 (file)
@@ -1194,28 +1194,28 @@ unsigned KeyValueStore::_do_transaction(Transaction& transaction,
     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);
@@ -1224,46 +1224,42 @@ unsigned KeyValueStore::_do_transaction(Transaction& transaction,
 
     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;
@@ -1277,8 +1273,8 @@ unsigned KeyValueStore::_do_transaction(Transaction& transaction,
 
     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);
@@ -1289,26 +1285,26 @@ unsigned KeyValueStore::_do_transaction(Transaction& transaction,
 
     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);
       }
@@ -1316,11 +1312,11 @@ unsigned KeyValueStore::_do_transaction(Transaction& transaction,
 
     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);
       }
@@ -1328,12 +1324,12 @@ unsigned KeyValueStore::_do_transaction(Transaction& transaction,
 
     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);
       }
@@ -1341,15 +1337,15 @@ unsigned KeyValueStore::_do_transaction(Transaction& transaction,
 
     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();
@@ -1368,24 +1364,24 @@ unsigned KeyValueStore::_do_transaction(Transaction& transaction,
 
     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;
@@ -1393,27 +1389,27 @@ unsigned KeyValueStore::_do_transaction(Transaction& transaction,
     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);
@@ -1422,8 +1418,8 @@ unsigned KeyValueStore::_do_transaction(Transaction& transaction,
 
     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;
@@ -1436,23 +1432,23 @@ unsigned KeyValueStore::_do_transaction(Transaction& transaction,
 
     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);
@@ -1460,8 +1456,8 @@ unsigned KeyValueStore::_do_transaction(Transaction& transaction,
       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);
@@ -1469,18 +1465,18 @@ unsigned KeyValueStore::_do_transaction(Transaction& transaction,
       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);
@@ -1488,45 +1484,46 @@ unsigned KeyValueStore::_do_transaction(Transaction& transaction,
       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;
@@ -1550,7 +1547,7 @@ unsigned KeyValueStore::_do_transaction(Transaction& transaction,
         }
 
         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);
index 360e59fc29e9c28541f5b51669e644a0933aafd9..5c75226e06cc919bec210803dbbdab3a3748ea40 100644 (file)
@@ -648,77 +648,73 @@ void MemStore::_do_transaction(Transaction& t)
   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);
@@ -727,74 +723,74 @@ void MemStore::_do_transaction(Transaction& t)
       
     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();
@@ -813,24 +809,24 @@ void MemStore::_do_transaction(Transaction& t)
 
     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;
@@ -841,81 +837,81 @@ void MemStore::_do_transaction(Transaction& t)
 
     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;
@@ -924,35 +920,33 @@ void MemStore::_do_transaction(Transaction& 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);
       }
       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)
@@ -961,9 +955,9 @@ void MemStore::_do_transaction(Transaction& t)
       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)
@@ -976,7 +970,7 @@ void MemStore::_do_transaction(Transaction& t)
          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";
index c875c182333d2f7d62dc59d1ae92561d5596a166..c7347acc74e02f63261cdec5e8a0e8d686071c3f 100644 (file)
@@ -399,8 +399,8 @@ public:
       __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 {
@@ -614,75 +614,152 @@ public:
      * 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() {
@@ -1316,8 +1393,8 @@ public:
         _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++;
     }
@@ -1349,13 +1426,13 @@ public:
     // 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);
@@ -1363,7 +1440,7 @@ public:
 
     Transaction(bufferlist &nbl) :
       osr(NULL),
-      use_tbl(true),
+      use_tbl(false),
       coll_id(0),
       object_id(0) {
       bufferlist::iterator dp = nbl.begin();
index c193c46cae41734d8b186e3d1daabb9c985c19db..083c29e359e5a8821da85fbaf491dfe101907361 100644 (file)
@@ -11,18 +11,18 @@ void ObjectStore::Transaction::dump(ceph::Formatter *f)
   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;
@@ -31,10 +31,10 @@ void ObjectStore::Transaction::dump(ceph::Formatter *f)
       
     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");
@@ -48,10 +48,10 @@ void ObjectStore::Transaction::dump(ceph::Formatter *f)
       
     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;
@@ -62,23 +62,16 @@ void ObjectStore::Transaction::dump(ceph::Formatter *f)
       
     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;
@@ -88,8 +81,8 @@ void ObjectStore::Transaction::dump(ceph::Formatter *f)
       
     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;
@@ -98,9 +91,9 @@ void ObjectStore::Transaction::dump(ceph::Formatter *f)
       
     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");
@@ -113,8 +106,8 @@ void ObjectStore::Transaction::dump(ceph::Formatter *f)
       
     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");
@@ -131,9 +124,9 @@ void ObjectStore::Transaction::dump(ceph::Formatter *f)
 
     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;
@@ -143,8 +136,8 @@ void ObjectStore::Transaction::dump(ceph::Formatter *f)
 
     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;
@@ -153,9 +146,9 @@ void ObjectStore::Transaction::dump(ceph::Formatter *f)
       
     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;
@@ -165,11 +158,11 @@ void ObjectStore::Transaction::dump(ceph::Formatter *f)
 
     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;
@@ -181,12 +174,12 @@ void ObjectStore::Transaction::dump(ceph::Formatter *f)
 
     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;
@@ -199,7 +192,7 @@ void ObjectStore::Transaction::dump(ceph::Formatter *f)
 
     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;
       }
@@ -207,8 +200,8 @@ void ObjectStore::Transaction::dump(ceph::Formatter *f)
 
     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);
@@ -228,7 +221,7 @@ void ObjectStore::Transaction::dump(ceph::Formatter *f)
 
     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;
       }
@@ -236,9 +229,9 @@ void ObjectStore::Transaction::dump(ceph::Formatter *f)
 
     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;
@@ -248,8 +241,8 @@ void ObjectStore::Transaction::dump(ceph::Formatter *f)
 
     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;
@@ -258,9 +251,9 @@ void ObjectStore::Transaction::dump(ceph::Formatter *f)
 
     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;
@@ -269,11 +262,10 @@ void ObjectStore::Transaction::dump(ceph::Formatter *f)
        }
       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");
@@ -285,8 +277,8 @@ void ObjectStore::Transaction::dump(ceph::Formatter *f)
 
     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);
@@ -299,18 +291,14 @@ void ObjectStore::Transaction::dump(ceph::Formatter *f)
 
     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;
@@ -319,8 +307,8 @@ void ObjectStore::Transaction::dump(ceph::Formatter *f)
 
     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");
@@ -337,8 +325,8 @@ void ObjectStore::Transaction::dump(ceph::Formatter *f)
 
     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");
@@ -349,8 +337,8 @@ void ObjectStore::Transaction::dump(ceph::Formatter *f)
 
     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");
@@ -362,10 +350,10 @@ void ObjectStore::Transaction::dump(ceph::Formatter *f)
 
     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;
@@ -376,10 +364,10 @@ void ObjectStore::Transaction::dump(ceph::Formatter *f)
 
     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;
@@ -390,11 +378,11 @@ void ObjectStore::Transaction::dump(ceph::Formatter *f)
 
     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;
@@ -405,10 +393,10 @@ void ObjectStore::Transaction::dump(ceph::Formatter *f)
 
     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;
@@ -419,10 +407,10 @@ void ObjectStore::Transaction::dump(ceph::Formatter *f)
 
     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;
@@ -433,7 +421,7 @@ void ObjectStore::Transaction::dump(ceph::Formatter *f)
 
     default:
       f->dump_string("op_name", "unknown");
-      f->dump_unsigned("op_code", op);
+      f->dump_unsigned("op_code", op->op);
       stop_looping = true;
       break;
     }
index 67074a4cf25c3d63b211a095b09f4c3df89c7b3d..c39f0a40693314a2d5d3025f8f1d2b36306235ad 100644 (file)
@@ -87,25 +87,25 @@ class Transaction {
     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;
@@ -114,16 +114,16 @@ class Transaction {
         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);
         }