]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
tools/ceph-dencoder: move ceph-dencoder to tools/ceph-dencoder
authorKefu Chai <kchai@redhat.com>
Fri, 27 Jul 2018 15:36:02 +0000 (23:36 +0800)
committerKefu Chai <kchai@redhat.com>
Fri, 27 Jul 2018 17:57:17 +0000 (01:57 +0800)
Signed-off-by: Kefu Chai <kchai@redhat.com>
src/test/encoding/test_ceph_time.h [deleted file]
src/test/encoding/test_sstring.h [deleted file]
src/test/encoding/types.h [deleted file]
src/tools/CMakeLists.txt
src/tools/ceph-dencoder/CMakeLists.txt [new file with mode: 0644]
src/tools/ceph-dencoder/ceph_dencoder.cc [new file with mode: 0644]
src/tools/ceph-dencoder/ceph_time.h [new file with mode: 0644]
src/tools/ceph-dencoder/sstring.h [new file with mode: 0644]
src/tools/ceph-dencoder/types.h [new file with mode: 0644]
src/tools/ceph_dencoder.cc [deleted file]

diff --git a/src/test/encoding/test_ceph_time.h b/src/test/encoding/test_ceph_time.h
deleted file mode 100644 (file)
index c27cb57..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-#ifndef TEST_CEPH_TIME_H
-#define TEST_CEPH_TIME_H
-
-#include <list>
-
-#include "include/encoding.h"
-#include "common/ceph_time.h"
-#include "common/Formatter.h"
-
-// wrapper for ceph::real_time that implements the dencoder interface
-template <typename Clock>
-class time_point_wrapper {
-  using time_point = typename Clock::time_point;
-  time_point t;
- public:
-  time_point_wrapper() = default;
-  explicit time_point_wrapper(const time_point& t) : t(t) {}
-
-  void encode(bufferlist& bl) const {
-    using ceph::encode;
-    encode(t, bl);
-  }
-  void decode(bufferlist::const_iterator &p) {
-    using ceph::decode;
-    decode(t, p);
-  }
-  void dump(Formatter* f) {
-    auto epoch_time = Clock::to_time_t(t);
-    f->dump_string("time", std::ctime(&epoch_time));
-  }
-  static void generate_test_instances(std::list<time_point_wrapper*>& ls) {
-    constexpr time_t t{455500800}; // Ghostbusters release date
-    ls.push_back(new time_point_wrapper(Clock::from_time_t(t)));
-  }
-};
-
-using real_time_wrapper = time_point_wrapper<ceph::real_clock>;
-WRITE_CLASS_ENCODER(real_time_wrapper)
-
-using coarse_real_time_wrapper = time_point_wrapper<ceph::coarse_real_clock>;
-WRITE_CLASS_ENCODER(coarse_real_time_wrapper)
-
-// wrapper for ceph::timespan that implements the dencoder interface
-class timespan_wrapper {
-  ceph::timespan d;
- public:
-  timespan_wrapper() = default;
-  explicit timespan_wrapper(const ceph::timespan& d) : d(d) {}
-
-  void encode(bufferlist& bl) const {
-    using ceph::encode;
-    encode(d, bl);
-  }
-  void decode(bufferlist::const_iterator &p) {
-    using ceph::decode;
-    decode(d, p);
-  }
-  void dump(Formatter* f) {
-    f->dump_int("timespan", d.count());
-  }
-  static void generate_test_instances(std::list<timespan_wrapper*>& ls) {
-    constexpr std::chrono::seconds d{7377}; // marathon world record (2:02:57)
-    ls.push_back(new timespan_wrapper(d));
-  }
-};
-WRITE_CLASS_ENCODER(timespan_wrapper)
-
-#endif
diff --git a/src/test/encoding/test_sstring.h b/src/test/encoding/test_sstring.h
deleted file mode 100644 (file)
index c2493c1..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-#ifndef TEST_SSTRING_H
-#define TEST_SSTRING_H
-
-#include "common/sstring.hh"
-
-// wrapper for sstring that implements the dencoder interface
-class sstring_wrapper {
-  using sstring16 = basic_sstring<char, uint32_t, 16>;
-  sstring16 s1;
-  using sstring24 = basic_sstring<unsigned char, uint16_t, 24>;
-  sstring24 s2;
- public:
-  sstring_wrapper() = default;
-  sstring_wrapper(sstring16&& s1, sstring24&& s2)
-    : s1(std::move(s1)), s2(std::move(s2))
-  {}
-
-  DENC(sstring_wrapper, w, p) {
-    DENC_START(1, 1, p);
-    denc(w.s1, p);
-    denc(w.s2, p);
-    DENC_FINISH(p);
-  }
-  void dump(Formatter* f) {
-    f->dump_string("s1", s1.c_str());
-    f->dump_string("s2", reinterpret_cast<const char*>(s2.c_str()));
-  }
-  static void generate_test_instances(std::list<sstring_wrapper*>& ls) {
-    ls.push_back(new sstring_wrapper());
-    // initialize sstrings that fit in internal storage
-    constexpr auto cstr6 = "abcdef";
-    ls.push_back(new sstring_wrapper(sstring16{cstr6}, sstring24{cstr6}));
-    // initialize sstrings that overflow into external storage
-    constexpr auto cstr26 = "abcdefghijklmnopqrstuvwxyz";
-    ls.push_back(new sstring_wrapper(sstring16{cstr26}, sstring24{cstr26}));
-  }
-};
-WRITE_CLASS_DENC(sstring_wrapper)
-
-#endif
diff --git a/src/test/encoding/types.h b/src/test/encoding/types.h
deleted file mode 100644 (file)
index 01c0e5d..0000000
+++ /dev/null
@@ -1,871 +0,0 @@
-#include "test_ceph_time.h"
-TYPE(real_time_wrapper)
-TYPE(coarse_real_time_wrapper)
-TYPE(timespan_wrapper)
-
-#include "test_sstring.h"
-TYPE(sstring_wrapper)
-
-#include "include/CompatSet.h"
-TYPE(CompatSet)
-
-#include "include/filepath.h"
-TYPE(filepath)
-
-#include "include/fs_types.h"
-TYPE_FEATUREFUL(file_layout_t)
-
-#include "include/util.h"
-TYPE(ceph_data_stats)
-
-#include "common/bit_vector.hpp"
-TYPE(BitVector<2>)
-
-#include "common/bloom_filter.hpp"
-TYPE(bloom_filter)
-TYPE(compressible_bloom_filter)
-
-#include "common/DecayCounter.h"
-TYPE(DecayCounter)
-
-#include "common/histogram.h"
-TYPE(pow2_hist_t)
-
-#include "common/hobject.h"
-TYPE(hobject_t)
-TYPE(ghobject_t)
-
-#include "common/LogEntry.h"
-TYPE_FEATUREFUL(LogEntry)
-TYPE_FEATUREFUL(LogSummary)
-
-#include "common/SloppyCRCMap.h"
-TYPE(SloppyCRCMap)
-
-#include "common/snap_types.h"
-TYPE(SnapContext)
-TYPE(SnapRealmInfo)
-
-#include "msg/msg_types.h"
-TYPE(entity_name_t)
-TYPE_FEATUREFUL(entity_addr_t)
-TYPE_FEATUREFUL(entity_addrvec_t)
-TYPE_FEATUREFUL(entity_inst_t)
-
-#include "crush/CrushWrapper.h"
-TYPE_FEATUREFUL_NOCOPY(CrushWrapper)
-
-#include "osd/OSDMap.h"
-TYPE(osd_info_t)
-TYPE(osd_xinfo_t)
-TYPE_FEATUREFUL_NOCOPY(OSDMap)
-TYPE_FEATUREFUL_STRAYDATA(OSDMap::Incremental)
-
-#include "osd/osd_types.h"
-TYPE(osd_reqid_t)
-TYPE(object_locator_t)
-TYPE(request_redirect_t)
-TYPE(pg_t)
-TYPE(coll_t)
-TYPE_FEATUREFUL(objectstore_perf_stat_t)
-TYPE_FEATUREFUL(osd_stat_t)
-TYPE(OSDSuperblock)
-TYPE_FEATUREFUL(pool_snap_info_t)
-TYPE_FEATUREFUL(pg_pool_t)
-TYPE(object_stat_sum_t)
-TYPE(object_stat_collection_t)
-TYPE(pg_stat_t)
-TYPE_FEATUREFUL(pool_stat_t)
-TYPE(pg_hit_set_info_t)
-TYPE(pg_hit_set_history_t)
-TYPE(pg_history_t)
-TYPE(pg_info_t)
-TYPE(PastIntervals)
-TYPE_FEATUREFUL(pg_query_t)
-TYPE(ObjectModDesc)
-TYPE(pg_log_entry_t)
-TYPE(pg_log_dup_t)
-TYPE(pg_log_t)
-TYPE_FEATUREFUL(pg_missing_item)
-TYPE(pg_missing_t)
-TYPE(pg_nls_response_t)
-TYPE(pg_ls_response_t)
-TYPE(object_copy_cursor_t)
-TYPE_FEATUREFUL(object_copy_data_t)
-TYPE(pg_create_t)
-TYPE(OSDSuperblock)
-TYPE(SnapSet)
-TYPE_FEATUREFUL(watch_info_t)
-TYPE(object_manifest_t)
-TYPE_FEATUREFUL(object_info_t)
-TYPE(SnapSet)
-TYPE_FEATUREFUL(ObjectRecoveryInfo)
-TYPE(ObjectRecoveryProgress)
-TYPE(PushReplyOp)
-TYPE_FEATUREFUL(PullOp)
-TYPE_FEATUREFUL(PushOp)
-TYPE(ScrubMap::object)
-TYPE(ScrubMap)
-TYPE_FEATUREFUL(obj_list_watch_response_t)
-TYPE(clone_info)
-TYPE(obj_list_snap_response_t)
-
-#include "osd/ECUtil.h"
-// TYPE(stripe_info_t) non-standard encoding/decoding functions
-TYPE(ECUtil::HashInfo)
-
-#include "osd/ECMsgTypes.h"
-TYPE_NOCOPY(ECSubWrite)
-TYPE(ECSubWriteReply)
-TYPE_FEATUREFUL(ECSubRead)
-TYPE(ECSubReadReply)
-
-#include "osd/HitSet.h"
-TYPE_NONDETERMINISTIC(ExplicitHashHitSet)
-TYPE_NONDETERMINISTIC(ExplicitObjectHitSet)
-TYPE(BloomHitSet)
-TYPE_NONDETERMINISTIC(HitSet)   // because some subclasses are
-TYPE(HitSet::Params)
-
-#include "os/ObjectStore.h"
-TYPE(ObjectStore::Transaction)
-
-#include "os/filestore/SequencerPosition.h"
-TYPE(SequencerPosition)
-
-#ifdef WITH_BLUESTORE
-#include "os/bluestore/bluestore_types.h"
-TYPE(bluestore_bdev_label_t)
-TYPE(bluestore_cnode_t)
-TYPE(bluestore_compression_header_t)
-TYPE(bluestore_extent_ref_map_t)
-TYPE(bluestore_pextent_t)
-TYPE(bluestore_blob_use_tracker_t)
-// TODO: bluestore_blob_t repurposes the "feature" param of encode() for its
-// struct_v. at a higher level, BlueStore::ExtentMap encodes the extends using
-// a different interface than the normal ones. see
-// BlueStore::ExtentMap::encode_some(). maybe we can test it using another
-// approach.
-// TYPE_FEATUREFUL(bluestore_blob_t)
-// TYPE(bluestore_shared_blob_t) there is no encode here
-TYPE(bluestore_onode_t)
-TYPE(bluestore_deferred_op_t)
-TYPE(bluestore_deferred_transaction_t)
-// TYPE(bluestore_compression_header_t) there is no encode here
-
-#include "os/bluestore/bluefs_types.h"
-TYPE(bluefs_extent_t)
-TYPE(bluefs_fnode_t)
-TYPE(bluefs_super_t)
-TYPE(bluefs_transaction_t)
-#endif
-
-#include "mon/AuthMonitor.h"
-TYPE_FEATUREFUL(AuthMonitor::Incremental)
-
-#include "mon/PGMap.h"
-TYPE_FEATUREFUL_NONDETERMINISTIC(PGMapDigest)
-TYPE_FEATUREFUL_NONDETERMINISTIC(PGMap)
-
-#include "mon/MonitorDBStore.h"
-TYPE(MonitorDBStore::Transaction)
-TYPE(MonitorDBStore::Op)
-
-#include "mon/MonMap.h"
-TYPE_FEATUREFUL(MonMap)
-
-#include "mon/MonCap.h"
-TYPE(MonCap)
-
-#include "mon/MgrMap.h"
-TYPE_FEATUREFUL(MgrMap)
-
-#include "mon/mon_types.h"
-TYPE(LevelDBStoreStats)
-TYPE(ScrubResult)
-
-#include "mon/CreatingPGs.h"
-TYPE(creating_pgs_t)
-
-#include "mgr/ServiceMap.h"
-TYPE_FEATUREFUL(ServiceMap)
-TYPE_FEATUREFUL(ServiceMap::Service)
-TYPE_FEATUREFUL(ServiceMap::Daemon)
-
-#include "os/filestore/DBObjectMap.h"
-TYPE(DBObjectMap::_Header)
-TYPE(DBObjectMap::State)
-
-#include "os/filestore/FileStore.h"
-TYPE(FSSuperblock)
-
-#include "os/kstore/kstore_types.h"
-TYPE(kstore_cnode_t)
-TYPE(kstore_onode_t)
-
-#include "mds/JournalPointer.h"
-TYPE(JournalPointer)
-
-#include "osdc/Journaler.h"
-TYPE(Journaler::Header)
-
-#include "mds/snap.h"
-TYPE(SnapInfo)
-TYPE(snaplink_t)
-TYPE(sr_t)
-
-#include "mds/mdstypes.h"
-TYPE(frag_info_t)
-TYPE(nest_info_t)
-TYPE(quota_info_t)
-TYPE(client_writeable_range_t)
-TYPE_FEATUREFUL(inode_t<std::allocator>)
-TYPE_FEATUREFUL(old_inode_t<std::allocator>)
-TYPE(fnode_t)
-TYPE(old_rstat_t)
-TYPE_FEATUREFUL(session_info_t)
-TYPE(string_snap_t)
-TYPE(MDSCacheObjectInfo)
-TYPE(mds_table_pending_t)
-TYPE(cap_reconnect_t)
-TYPE(inode_load_vec_t)
-TYPE(dirfrag_load_vec_t)
-TYPE(mds_load_t)
-TYPE(MDSCacheObjectInfo)
-TYPE(inode_backtrace_t)
-TYPE(inode_backpointer_t)
-
-#include "mds/CInode.h"
-TYPE_FEATUREFUL(InodeStore)
-TYPE_FEATUREFUL(InodeStoreBare)
-
-#include "mds/MDSMap.h"
-TYPE_FEATUREFUL(MDSMap)
-TYPE_FEATUREFUL(MDSMap::mds_info_t)
-
-#include "mds/FSMap.h"
-//TYPE_FEATUREFUL(Filesystem)
-TYPE_FEATUREFUL(FSMap)
-
-#include "mds/Capability.h"
-TYPE_NOCOPY(Capability)
-
-#include "mds/inode_backtrace.h"
-TYPE(inode_backpointer_t)
-TYPE(inode_backtrace_t)
-
-#include "mds/InoTable.h"
-TYPE(InoTable)
-
-#include "mds/SnapServer.h"
-TYPE_STRAYDATA(SnapServer)
-
-#include "mds/events/ECommitted.h"
-TYPE_FEATUREFUL(ECommitted)
-
-#include "mds/events/EExport.h"
-TYPE_FEATUREFUL(EExport)
-
-#include "mds/events/EFragment.h"
-TYPE_FEATUREFUL(EFragment)
-
-#include "mds/events/EImportFinish.h"
-TYPE_FEATUREFUL(EImportFinish)
-
-#include "mds/events/EImportStart.h"
-TYPE_FEATUREFUL(EImportStart)
-
-#include "mds/events/EMetaBlob.h"
-TYPE_FEATUREFUL_NOCOPY(EMetaBlob::fullbit)
-TYPE(EMetaBlob::remotebit)
-TYPE(EMetaBlob::nullbit)
-TYPE_FEATUREFUL(EMetaBlob::dirlump)
-TYPE_FEATUREFUL(EMetaBlob)
-
-#include "mds/events/EOpen.h"
-TYPE_FEATUREFUL(EOpen)
-
-#include "mds/events/EResetJournal.h"
-TYPE_FEATUREFUL(EResetJournal)
-
-#include "mds/events/ESession.h"
-TYPE_FEATUREFUL(ESession)
-
-#include "mds/events/ESessions.h"
-TYPE_FEATUREFUL(ESessions)
-
-#include "mds/events/ESlaveUpdate.h"
-TYPE(link_rollback)
-TYPE(rmdir_rollback)
-TYPE(rename_rollback::drec)
-TYPE(rename_rollback)
-TYPE_FEATUREFUL(ESlaveUpdate)
-
-#include "mds/events/ESubtreeMap.h"
-TYPE_FEATUREFUL(ESubtreeMap)
-
-#include "mds/events/ETableClient.h"
-TYPE_FEATUREFUL(ETableClient)
-
-#include "mds/events/ETableServer.h"
-TYPE_FEATUREFUL(ETableServer)
-
-#include "mds/events/EUpdate.h"
-TYPE_FEATUREFUL(EUpdate)
-
-#ifdef WITH_RBD
-#include "librbd/journal/Types.h"
-TYPE(librbd::journal::EventEntry)
-TYPE(librbd::journal::ClientData)
-TYPE(librbd::journal::TagData)
-#include "librbd/mirroring_watcher/Types.h"
-TYPE(librbd::mirroring_watcher::NotifyMessage)
-#include "librbd/trash_watcher/Types.h"
-TYPE(librbd::mirroring_watcher::NotifyMessage)
-#include "librbd/WatchNotifyTypes.h"
-TYPE(librbd::watch_notify::NotifyMessage)
-TYPE(librbd::watch_notify::ResponseMessage)
-
-#include "rbd_replay/ActionTypes.h"
-TYPE(rbd_replay::action::Dependency)
-TYPE(rbd_replay::action::ActionEntry)
-
-#include "tools/rbd_mirror/image_map/Types.h"
-TYPE(rbd::mirror::image_map::PolicyData)
-#endif
-
-#ifdef WITH_RADOSGW
-
-#include "rgw/rgw_rados.h"
-TYPE(RGWOLHInfo)
-TYPE(RGWObjManifestPart)
-TYPE(RGWObjManifest)
-TYPE(RGWZoneParams)
-TYPE(RGWZone)
-TYPE(RGWZoneGroup)
-
-#include "rgw/rgw_acl.h"
-TYPE(ACLPermission)
-TYPE(ACLGranteeType)
-TYPE(ACLGrant)
-TYPE(RGWAccessControlList)
-TYPE(ACLOwner)
-TYPE(RGWAccessControlPolicy)
-
-#include "rgw/rgw_cache.h"
-TYPE(ObjectMetaInfo)
-TYPE(ObjectCacheInfo)
-TYPE(RGWCacheNotifyInfo)
-
-#include "rgw/rgw_lc.h"
-TYPE(RGWLifecycleConfiguration)
-
-#include "cls/rgw/cls_rgw_types.h"
-TYPE(rgw_bucket_pending_info)
-TYPE(rgw_bucket_dir_entry_meta)
-TYPE(rgw_bucket_entry_ver)
-TYPE(rgw_bucket_dir_entry)
-TYPE(rgw_bucket_category_stats)
-TYPE(rgw_bucket_dir_header)
-TYPE(rgw_bucket_dir)
-TYPE(rgw_bucket_entry_ver)
-TYPE(cls_rgw_obj_key)
-TYPE(rgw_bucket_olh_log_entry)
-TYPE(rgw_usage_log_entry)
-
-#include "cls/rgw/cls_rgw_ops.h"
-TYPE(rgw_cls_obj_prepare_op)
-TYPE(rgw_cls_obj_complete_op)
-TYPE(rgw_cls_list_op)
-TYPE(rgw_cls_list_ret)
-TYPE(cls_rgw_gc_defer_entry_op)
-TYPE(cls_rgw_gc_list_op)
-TYPE(cls_rgw_gc_list_ret)
-TYPE(cls_rgw_gc_obj_info)
-TYPE(cls_rgw_gc_remove_op)
-TYPE(cls_rgw_gc_set_entry_op)
-TYPE(cls_rgw_obj)
-TYPE(cls_rgw_obj_chain)
-TYPE(rgw_cls_tag_timeout_op)
-TYPE(cls_rgw_bi_log_list_op)
-TYPE(cls_rgw_bi_log_trim_op)
-TYPE(cls_rgw_bi_log_list_ret)
-TYPE(rgw_cls_link_olh_op)
-TYPE(rgw_cls_unlink_instance_op)
-TYPE(rgw_cls_read_olh_log_op)
-TYPE(rgw_cls_read_olh_log_ret)
-TYPE(rgw_cls_trim_olh_log_op)
-TYPE(rgw_cls_bucket_clear_olh_op)
-TYPE(rgw_cls_check_index_ret)
-TYPE(cls_rgw_reshard_add_op)
-TYPE(cls_rgw_reshard_list_op)
-TYPE(cls_rgw_reshard_list_ret)
-TYPE(cls_rgw_reshard_get_op)
-TYPE(cls_rgw_reshard_get_ret)
-TYPE(cls_rgw_reshard_remove_op)
-TYPE(cls_rgw_set_bucket_resharding_op)
-TYPE(cls_rgw_clear_bucket_resharding_op)
-TYPE(cls_rgw_lc_obj_head)
-
-#include "cls/rgw/cls_rgw_client.h"
-TYPE(rgw_bi_log_entry)
-TYPE(cls_rgw_reshard_entry)
-TYPE(cls_rgw_bucket_instance_entry)
-
-#include "cls/user/cls_user_types.h"
-TYPE(cls_user_bucket)
-TYPE(cls_user_bucket_entry)
-TYPE(cls_user_stats)
-TYPE(cls_user_header)
-
-#include "cls/user/cls_user_ops.h"
-TYPE(cls_user_set_buckets_op)
-TYPE(cls_user_remove_bucket_op)
-TYPE(cls_user_list_buckets_op)
-TYPE(cls_user_list_buckets_ret)
-TYPE(cls_user_get_header_op)
-TYPE(cls_user_get_header_ret)
-TYPE(cls_user_complete_stats_sync_op)
-
-#include "cls/journal/cls_journal_types.h"
-TYPE(cls::journal::ObjectPosition)
-TYPE(cls::journal::ObjectSetPosition)
-TYPE(cls::journal::Client)
-TYPE(cls::journal::Tag)
-
-#include "rgw/rgw_common.h"
-TYPE(RGWAccessKey)
-TYPE(RGWSubUser)
-TYPE(RGWUserInfo)
-TYPE(rgw_bucket)
-TYPE(RGWBucketInfo)
-TYPE(RGWBucketEnt)
-TYPE(RGWUploadPartInfo)
-TYPE(rgw_obj)
-
-#include "rgw/rgw_log.h"
-TYPE(rgw_log_entry)
-
-#include "rgw/rgw_meta_sync_status.h"
-TYPE(rgw_meta_sync_info)
-TYPE(rgw_meta_sync_marker)
-TYPE(rgw_meta_sync_status)
-
-#include "rgw/rgw_data_sync.h"
-TYPE(rgw_data_sync_info)
-TYPE(rgw_data_sync_marker)
-TYPE(rgw_data_sync_status)
-
-#endif
-
-#ifdef WITH_RBD
-#include "cls/rbd/cls_rbd.h"
-TYPE(cls_rbd_parent)
-TYPE(cls_rbd_snap)
-
-#include "cls/rbd/cls_rbd_types.h"
-TYPE(cls::rbd::ChildImageSpec)
-TYPE(cls::rbd::MirrorPeer)
-TYPE(cls::rbd::MirrorImage)
-TYPE(cls::rbd::MirrorImageMap)
-TYPE(cls::rbd::MirrorImageStatus)
-TYPE(cls::rbd::GroupImageSpec)
-TYPE(cls::rbd::GroupImageStatus)
-TYPE(cls::rbd::GroupSnapshot)
-TYPE(cls::rbd::GroupSpec)
-TYPE(cls::rbd::ImageSnapshotSpec)
-TYPE(cls::rbd::SnapshotInfo)
-TYPE(cls::rbd::SnapshotNamespace)
-#endif
-
-#include "cls/lock/cls_lock_types.h"
-TYPE(rados::cls::lock::locker_id_t)
-TYPE_FEATUREFUL(rados::cls::lock::locker_info_t)
-TYPE_FEATUREFUL(rados::cls::lock::lock_info_t)
-
-#include "cls/lock/cls_lock_ops.h"
-TYPE(cls_lock_lock_op)
-TYPE(cls_lock_unlock_op)
-TYPE(cls_lock_break_op)
-TYPE(cls_lock_get_info_op)
-TYPE_FEATUREFUL(cls_lock_get_info_reply)
-TYPE(cls_lock_list_locks_reply)
-TYPE(cls_lock_assert_op)
-TYPE(cls_lock_set_cookie_op)
-
-#include "cls/refcount/cls_refcount_ops.h"
-TYPE(cls_refcount_get_op)
-TYPE(cls_refcount_put_op)
-TYPE(cls_refcount_set_op)
-TYPE(cls_refcount_read_op)
-TYPE(cls_refcount_read_ret)
-
-#include "journal/Entry.h"
-TYPE(journal::Entry)
-
-// --- messages ---
-#include "messages/MAuth.h"
-MESSAGE(MAuth)
-
-#include "messages/MAuthReply.h"
-MESSAGE(MAuthReply)
-
-#include "messages/MCacheExpire.h"
-MESSAGE(MCacheExpire)
-
-#include "messages/MClientCapRelease.h"
-MESSAGE(MClientCapRelease)
-
-#include "messages/MClientCaps.h"
-MESSAGE(MClientCaps)
-
-#include "messages/MClientLease.h"
-MESSAGE(MClientLease)
-
-#include "messages/MClientReconnect.h"
-MESSAGE(MClientReconnect)
-
-#include "messages/MClientReply.h"
-MESSAGE(MClientReply)
-
-#include "messages/MClientRequest.h"
-MESSAGE(MClientRequest)
-
-#include "messages/MClientRequestForward.h"
-MESSAGE(MClientRequestForward)
-
-#include "messages/MClientQuota.h"
-MESSAGE(MClientQuota)
-
-#include "messages/MClientSession.h"
-MESSAGE(MClientSession)
-
-#include "messages/MClientSnap.h"
-MESSAGE(MClientSnap)
-
-#include "messages/MCommand.h"
-MESSAGE(MCommand)
-
-#include "messages/MCommandReply.h"
-MESSAGE(MCommandReply)
-
-#include "messages/MConfig.h"
-MESSAGE(MConfig)
-
-#include "messages/MDataPing.h"
-MESSAGE(MDataPing)
-
-#include "messages/MDentryLink.h"
-MESSAGE(MDentryLink)
-
-#include "messages/MDentryUnlink.h"
-MESSAGE(MDentryUnlink)
-
-#include "messages/MDirUpdate.h"
-MESSAGE(MDirUpdate)
-
-#include "messages/MDiscover.h"
-MESSAGE(MDiscover)
-
-#include "messages/MDiscoverReply.h"
-MESSAGE(MDiscoverReply)
-
-#include "messages/MExportCaps.h"
-MESSAGE(MExportCaps)
-
-#include "messages/MExportCapsAck.h"
-MESSAGE(MExportCapsAck)
-
-#include "messages/MExportDir.h"
-MESSAGE(MExportDir)
-
-#include "messages/MExportDirAck.h"
-MESSAGE(MExportDirAck)
-
-#include "messages/MExportDirCancel.h"
-MESSAGE(MExportDirCancel)
-
-#include "messages/MExportDirDiscover.h"
-MESSAGE(MExportDirDiscover)
-
-#include "messages/MExportDirDiscoverAck.h"
-MESSAGE(MExportDirDiscoverAck)
-
-#include "messages/MExportDirFinish.h"
-MESSAGE(MExportDirFinish)
-
-#include "messages/MExportDirNotify.h"
-MESSAGE(MExportDirNotify)
-
-#include "messages/MExportDirNotifyAck.h"
-MESSAGE(MExportDirNotifyAck)
-
-#include "messages/MExportDirPrep.h"
-MESSAGE(MExportDirPrep)
-
-#include "messages/MExportDirPrepAck.h"
-MESSAGE(MExportDirPrepAck)
-
-#include "messages/MForward.h"
-MESSAGE(MForward)
-
-#include "messages/MFSMap.h"
-MESSAGE(MFSMap)
-
-#include "messages/MFSMapUser.h"
-MESSAGE(MFSMapUser)
-
-#include "messages/MGatherCaps.h"
-MESSAGE(MGatherCaps)
-
-#include "messages/MGenericMessage.h"
-MESSAGE(MGenericMessage)
-
-#include "messages/MGetConfig.h"
-MESSAGE(MGetConfig)
-
-#include "messages/MGetPoolStats.h"
-MESSAGE(MGetPoolStats)
-
-#include "messages/MGetPoolStatsReply.h"
-MESSAGE(MGetPoolStatsReply)
-
-#include "messages/MHeartbeat.h"
-MESSAGE(MHeartbeat)
-
-#include "messages/MInodeFileCaps.h"
-MESSAGE(MInodeFileCaps)
-
-#include "messages/MLock.h"
-MESSAGE(MLock)
-
-#include "messages/MLog.h"
-MESSAGE(MLog)
-
-#include "messages/MLogAck.h"
-MESSAGE(MLogAck)
-
-#include "messages/MMDSOpenIno.h"
-MESSAGE(MMDSOpenIno)
-
-#include "messages/MMDSOpenInoReply.h"
-MESSAGE(MMDSOpenInoReply)
-
-#include "messages/MMDSBeacon.h"
-MESSAGE(MMDSBeacon)
-
-#include "messages/MMDSCacheRejoin.h"
-MESSAGE(MMDSCacheRejoin)
-
-#include "messages/MMDSFindIno.h"
-MESSAGE(MMDSFindIno)
-
-#include "messages/MMDSFindInoReply.h"
-MESSAGE(MMDSFindInoReply)
-
-#include "messages/MMDSFragmentNotify.h"
-MESSAGE(MMDSFragmentNotify)
-
-#include "messages/MMDSLoadTargets.h"
-MESSAGE(MMDSLoadTargets)
-
-#include "messages/MMDSMap.h"
-MESSAGE(MMDSMap)
-
-#include "messages/MMgrReport.h"
-MESSAGE(MMgrReport)
-
-#include "messages/MMDSResolve.h"
-MESSAGE(MMDSResolve)
-
-#include "messages/MMDSResolveAck.h"
-MESSAGE(MMDSResolveAck)
-
-#include "messages/MMDSSlaveRequest.h"
-MESSAGE(MMDSSlaveRequest)
-
-#include "messages/MMDSSnapUpdate.h"
-MESSAGE(MMDSSnapUpdate)
-
-#include "messages/MMDSTableRequest.h"
-MESSAGE(MMDSTableRequest)
-
-#include "messages/MMgrClose.h"
-MESSAGE(MMgrClose)
-
-#include "messages/MMgrConfigure.h"
-MESSAGE(MMgrConfigure)
-
-#include "messages/MMgrDigest.h"
-MESSAGE(MMgrDigest)
-
-#include "messages/MMgrMap.h"
-MESSAGE(MMgrMap)
-
-#include "messages/MMgrOpen.h"
-MESSAGE(MMgrOpen)
-
-#include "messages/MMonCommand.h"
-MESSAGE(MMonCommand)
-
-#include "messages/MMonCommandAck.h"
-MESSAGE(MMonCommandAck)
-
-#include "messages/MMonElection.h"
-MESSAGE(MMonElection)
-
-#include "messages/MMonGetMap.h"
-MESSAGE(MMonGetMap)
-
-#include "messages/MMonGetVersion.h"
-MESSAGE(MMonGetVersion)
-
-#include "messages/MMonGetVersionReply.h"
-MESSAGE(MMonGetVersionReply)
-
-#include "messages/MMonGlobalID.h"
-MESSAGE(MMonGlobalID)
-
-#include "messages/MMonJoin.h"
-MESSAGE(MMonJoin)
-
-#include "messages/MMonMap.h"
-MESSAGE(MMonMap)
-
-#include "messages/MMonMetadata.h"
-MESSAGE(MMonMetadata)
-
-#include "messages/MMonPaxos.h"
-MESSAGE(MMonPaxos)
-
-#include "messages/MMonProbe.h"
-MESSAGE(MMonProbe)
-
-#include "messages/MMonScrub.h"
-MESSAGE(MMonScrub)
-
-#include "messages/MMonSync.h"
-MESSAGE(MMonSync)
-
-#include "messages/MMonSubscribe.h"
-MESSAGE(MMonSubscribe)
-
-#include "messages/MMonSubscribeAck.h"
-MESSAGE(MMonSubscribeAck)
-
-#include "messages/MNop.h"
-MESSAGE(MNop)
-
-#include "messages/MOSDAlive.h"
-MESSAGE(MOSDAlive)
-
-#include "messages/MOSDBoot.h"
-MESSAGE(MOSDBoot)
-
-#include "messages/MOSDFailure.h"
-MESSAGE(MOSDFailure)
-
-#include "messages/MOSDMap.h"
-MESSAGE(MOSDMap)
-
-#include "messages/MOSDOp.h"
-MESSAGE(MOSDOp)
-
-#include "messages/MOSDOpReply.h"
-MESSAGE(MOSDOpReply)
-
-#include "messages/MOSDPGBackfill.h"
-MESSAGE(MOSDPGBackfill)
-
-#include "messages/MOSDPGCreate.h"
-MESSAGE(MOSDPGCreate)
-
-#include "messages/MOSDPGCreate2.h"
-MESSAGE(MOSDPGCreate2)
-
-#include "messages/MOSDPGInfo.h"
-MESSAGE(MOSDPGInfo)
-
-#include "messages/MOSDPGLog.h"
-MESSAGE(MOSDPGLog)
-
-#include "messages/MOSDPGNotify.h"
-MESSAGE(MOSDPGNotify)
-
-#include "messages/MOSDPGQuery.h"
-MESSAGE(MOSDPGQuery)
-
-#include "messages/MOSDPGRemove.h"
-MESSAGE(MOSDPGRemove)
-
-#include "messages/MOSDPGRecoveryDelete.h"
-MESSAGE(MOSDPGRecoveryDelete)
-
-#include "messages/MOSDPGRecoveryDeleteReply.h"
-MESSAGE(MOSDPGRecoveryDeleteReply)
-
-#include "messages/MOSDPGScan.h"
-MESSAGE(MOSDPGScan)
-
-#include "messages/MOSDPGTemp.h"
-MESSAGE(MOSDPGTemp)
-
-#include "messages/MOSDPGTrim.h"
-MESSAGE(MOSDPGTrim)
-
-#include "messages/MOSDPing.h"
-MESSAGE(MOSDPing)
-
-#include "messages/MOSDRepScrub.h"
-MESSAGE(MOSDRepScrub)
-
-#include "messages/MOSDScrub.h"
-MESSAGE(MOSDScrub)
-
-#include "messages/MOSDScrub2.h"
-MESSAGE(MOSDScrub2)
-
-#include "messages/MOSDForceRecovery.h"
-MESSAGE(MOSDForceRecovery)
-
-#include "messages/MPGStats.h"
-MESSAGE(MPGStats)
-
-#include "messages/MPGStatsAck.h"
-MESSAGE(MPGStatsAck)
-
-#include "messages/MPing.h"
-MESSAGE(MPing)
-
-#include "messages/MPoolOp.h"
-MESSAGE(MPoolOp)
-
-#include "messages/MPoolOpReply.h"
-MESSAGE(MPoolOpReply)
-
-#include "messages/MRemoveSnaps.h"
-MESSAGE(MRemoveSnaps)
-
-#include "messages/MRoute.h"
-MESSAGE(MRoute)
-
-#include "messages/MServiceMap.h"
-MESSAGE(MServiceMap)
-
-#include "messages/MStatfs.h"
-MESSAGE(MStatfs)
-
-#include "messages/MStatfsReply.h"
-MESSAGE(MStatfsReply)
-
-#include "messages/MTimeCheck.h"
-MESSAGE(MTimeCheck)
-
-#include "messages/MTimeCheck2.h"
-MESSAGE(MTimeCheck2)
-
-#include "messages/MWatchNotify.h"
-MESSAGE(MWatchNotify)
-
-#include "messages/PaxosServiceMessage.h"
-MESSAGE(PaxosServiceMessage)
index ef7e302e208b694d624ccede7b75737b03d68907..3789e3c274a6de6cf778636ec0f51799b549a8d6 100644 (file)
@@ -107,60 +107,4 @@ if(WITH_RBD)
   endif()
 endif(WITH_RBD)
 
-## dencoder
-set_source_files_properties(
-  ${CMAKE_SOURCE_DIR}/src/test/encoding/ceph_dencoder.cc
-  APPEND PROPERTY OBJECT_DEPENDS ${CMAKE_BINARY_DIR}/src/include/ceph_ver.h)
-
-if(HAS_VTA)
-  set_source_files_properties(test/encoding/ceph_dencoder.cc
-    PROPERTIES COMPILE_FLAGS -fno-var-tracking-assignments)
-endif()
-
-set(dencoder_srcs
-  ceph_dencoder.cc
-  $<TARGET_OBJECTS:common_texttable_obj>)
-if(WITH_RADOSGW)
-  list(APPEND dencoder_srcs
-    ${CMAKE_SOURCE_DIR}/src/rgw/rgw_dencoder.cc)
-endif()
-
-add_executable(ceph-dencoder ${dencoder_srcs})
-
-if(WITH_RADOSGW)
-  list(APPEND DENCODER_EXTRALIBS
-    rgw_a
-    cls_rgw_client)
-endif()
-
-if(WITH_RBD)
-  list(APPEND DENCODER_EXTRALIBS
-    cls_rbd_client
-    rbd_mirror_types
-    rbd_types
-    rbd_replay_types)
-  if(WITH_KRBD)
-    list(APPEND DENCODER_EXTRALIBS
-      krbd)
-  endif()
-endif()
-
-target_link_libraries(ceph-dencoder
-  global
-  os
-  osd
-  mds
-  mon
-  journal
-  ${DENCODER_EXTRALIBS}
-  cls_lock_client
-  cls_refcount_client
-  cls_log_client
-  cls_statelog_client
-  cls_version_client
-  cls_user_client
-  cls_journal_client
-  cls_timeindex_client
-  ${EXTRALIBS}
-  ${CMAKE_DL_LIBS})
-install(TARGETS ceph-dencoder DESTINATION bin)
+add_subdirectory(ceph-dencoder)
diff --git a/src/tools/ceph-dencoder/CMakeLists.txt b/src/tools/ceph-dencoder/CMakeLists.txt
new file mode 100644 (file)
index 0000000..be0f9d1
--- /dev/null
@@ -0,0 +1,57 @@
+## dencoder
+set_source_files_properties(
+  ceph_dencoder.cc
+  APPEND PROPERTY OBJECT_DEPENDS ${CMAKE_BINARY_DIR}/src/include/ceph_ver.h)
+
+if(HAS_VTA)
+  set_source_files_properties(ceph_dencoder.cc
+    PROPERTIES COMPILE_FLAGS -fno-var-tracking-assignments)
+endif()
+
+set(dencoder_srcs
+  ceph_dencoder.cc
+  $<TARGET_OBJECTS:common_texttable_obj>)
+if(WITH_RADOSGW)
+  list(APPEND dencoder_srcs
+    ${CMAKE_SOURCE_DIR}/src/rgw/rgw_dencoder.cc)
+endif()
+
+add_executable(ceph-dencoder ${dencoder_srcs})
+
+if(WITH_RADOSGW)
+  list(APPEND DENCODER_EXTRALIBS
+    rgw_a
+    cls_rgw_client)
+endif()
+
+if(WITH_RBD)
+  list(APPEND DENCODER_EXTRALIBS
+    cls_rbd_client
+    rbd_mirror_types
+    rbd_types
+    rbd_replay_types)
+  if(WITH_KRBD)
+    list(APPEND DENCODER_EXTRALIBS
+      krbd)
+  endif()
+endif()
+
+target_link_libraries(ceph-dencoder
+  global
+  os
+  osd
+  mds
+  mon
+  journal
+  ${DENCODER_EXTRALIBS}
+  cls_lock_client
+  cls_refcount_client
+  cls_log_client
+  cls_statelog_client
+  cls_version_client
+  cls_user_client
+  cls_journal_client
+  cls_timeindex_client
+  ${EXTRALIBS}
+  ${CMAKE_DL_LIBS})
+install(TARGETS ceph-dencoder DESTINATION bin)
diff --git a/src/tools/ceph-dencoder/ceph_dencoder.cc b/src/tools/ceph-dencoder/ceph_dencoder.cc
new file mode 100644 (file)
index 0000000..74f3ca3
--- /dev/null
@@ -0,0 +1,486 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright (C) 2015 Red Hat
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software
+ * Foundation.  See file COPYING.
+ *
+ */
+
+
+#include <errno.h>
+#include "include/types.h"
+#include "ceph_ver.h"
+#include "include/encoding.h"
+#include "include/ceph_features.h"
+#include "common/ceph_argparse.h"
+#include "common/Formatter.h"
+#include "common/errno.h"
+#include "msg/Message.h"
+#include "include/assert.h"
+
+#define TYPE(t)
+#define TYPE_STRAYDATA(t)
+#define TYPE_NONDETERMINISTIC(t)
+#define TYPE_FEATUREFUL(t)
+#define TYPE_FEATUREFUL_STRAYDATA(t)
+#define TYPE_FEATUREFUL_NONDETERMINISTIC(t)
+#define TYPE_FEATUREFUL_NOCOPY(t)
+#define TYPE_NOCOPY(t)
+#define MESSAGE(t)
+#include "include/types.h"
+#undef TYPE
+#undef TYPE_STRAYDATA
+#undef TYPE_NONDETERMINISTIC
+#undef TYPE_NOCOPY
+#undef TYPE_FEATUREFUL
+#undef TYPE_FEATUREFUL_STRAYDATA
+#undef TYPE_FEATUREFUL_NONDETERMINISTIC
+#undef TYPE_FEATUREFUL_NOCOPY
+#undef MESSAGE
+
+#define MB(m) ((m) * 1024 * 1024)
+
+void usage(ostream &out)
+{
+  out << "usage: ceph-dencoder [commands ...]" << std::endl;
+  out << "\n";
+  out << "  version             print version string (to stdout)\n";
+  out << "\n";
+  out << "  import <encfile>    read encoded data from encfile\n";
+  out << "  export <outfile>    write encoded data to outfile\n";
+  out << "\n";
+  out << "  set_features <num>  set feature bits used for encoding\n";
+  out << "  get_features        print feature bits (int) to stdout\n";
+  out << "\n";
+  out << "  list_types          list supported types\n";
+  out << "  type <classname>    select in-memory type\n";
+  out << "  skip <num>          skip <num> leading bytes before decoding\n";
+  out << "  decode              decode into in-memory object\n";
+  out << "  encode              encode in-memory object\n";
+  out << "  dump_json           dump in-memory object as json (to stdout)\n";
+  out << "  hexdump             print encoded data in hex\n";
+  out << "\n";
+  out << "  copy                copy object (via operator=)\n";
+  out << "  copy_ctor           copy object (via copy ctor)\n";
+  out << "\n";
+  out << "  count_tests         print number of generated test objects (to stdout)\n";
+  out << "  select_test <n>     select generated test object as in-memory object\n";
+  out << "  is_deterministic    exit w/ success if type encodes deterministically\n";
+}
+struct Dencoder {
+  virtual ~Dencoder() {}
+  virtual string decode(bufferlist bl, uint64_t seek) = 0;
+  virtual void encode(bufferlist& out, uint64_t features) = 0;
+  virtual void dump(ceph::Formatter *f) = 0;
+  virtual void copy() {
+    cerr << "copy operator= not supported" << std::endl;
+  }
+  virtual void copy_ctor() {
+    cerr << "copy ctor not supported" << std::endl;
+  }
+  virtual void generate() = 0;
+  virtual int num_generated() = 0;
+  virtual string select_generated(unsigned n) = 0;
+  virtual bool is_deterministic() = 0;
+  //virtual void print(ostream& out) = 0;
+};
+
+template<class T>
+class DencoderBase : public Dencoder {
+protected:
+  T* m_object;
+  list<T*> m_list;
+  bool stray_okay;
+  bool nondeterministic;
+
+public:
+  DencoderBase(bool stray_okay, bool nondeterministic)
+    : m_object(new T),
+      stray_okay(stray_okay),
+      nondeterministic(nondeterministic) {}
+  ~DencoderBase() override {
+    delete m_object;
+  }
+
+  string decode(bufferlist bl, uint64_t seek) override {
+    auto p = bl.cbegin();
+    p.seek(seek);
+    try {
+      using ceph::decode;
+      decode(*m_object, p);
+    }
+    catch (buffer::error& e) {
+      return e.what();
+    }
+    if (!stray_okay && !p.end()) {
+      ostringstream ss;
+      ss << "stray data at end of buffer, offset " << p.get_off();
+      return ss.str();
+    }
+    return string();
+  }
+
+  void encode(bufferlist& out, uint64_t features) override = 0;
+
+  void dump(ceph::Formatter *f) override {
+    m_object->dump(f);
+  }
+  void generate() override {
+    T::generate_test_instances(m_list);
+  }
+  int num_generated() override {
+    return m_list.size();
+  }
+  string select_generated(unsigned i) override {
+    // allow 0- or 1-based (by wrapping)
+    if (i == 0)
+      i = m_list.size();
+    if ((i == 0) || (i > m_list.size()))
+      return "invalid id for generated object";
+    m_object = *(std::next(m_list.begin(), i-1));
+    return string();
+  }
+
+  bool is_deterministic() override {
+    return !nondeterministic;
+  }
+};
+
+template<class T>
+class DencoderImplNoFeatureNoCopy : public DencoderBase<T> {
+public:
+  DencoderImplNoFeatureNoCopy(bool stray_ok, bool nondeterministic)
+    : DencoderBase<T>(stray_ok, nondeterministic) {}
+  void encode(bufferlist& out, uint64_t features) override {
+    out.clear();
+    using ceph::encode;
+    encode(*this->m_object, out);
+  }
+};
+
+template<class T>
+class DencoderImplNoFeature : public DencoderImplNoFeatureNoCopy<T> {
+public:
+  DencoderImplNoFeature(bool stray_ok, bool nondeterministic)
+    : DencoderImplNoFeatureNoCopy<T>(stray_ok, nondeterministic) {}
+  void copy() override {
+    T *n = new T;
+    *n = *this->m_object;
+    delete this->m_object;
+    this->m_object = n;
+  }
+  void copy_ctor() override {
+    T *n = new T(*this->m_object);
+    delete this->m_object;
+    this->m_object = n;
+  }
+};
+
+template<class T>
+class DencoderImplFeaturefulNoCopy : public DencoderBase<T> {
+public:
+  DencoderImplFeaturefulNoCopy(bool stray_ok, bool nondeterministic)
+    : DencoderBase<T>(stray_ok, nondeterministic) {}
+  void encode(bufferlist& out, uint64_t features) override {
+    out.clear();
+    using ceph::encode;
+    encode(*(this->m_object), out, features);
+  }
+};
+
+template<class T>
+class DencoderImplFeatureful : public DencoderImplFeaturefulNoCopy<T> {
+public:
+  DencoderImplFeatureful(bool stray_ok, bool nondeterministic)
+    : DencoderImplFeaturefulNoCopy<T>(stray_ok, nondeterministic) {}
+  void copy() override {
+    T *n = new T;
+    *n = *this->m_object;
+    delete this->m_object;
+    this->m_object = n;
+  }
+  void copy_ctor() override {
+    T *n = new T(*this->m_object);
+    delete this->m_object;
+    this->m_object = n;
+  }
+};
+
+template<class T>
+class MessageDencoderImpl : public Dencoder {
+  T *m_object;
+  list<T*> m_list;
+
+public:
+  MessageDencoderImpl() {
+    m_object = new T;
+  }
+  ~MessageDencoderImpl() override {
+    m_object->put();
+  }
+
+  string decode(bufferlist bl, uint64_t seek) override {
+    auto p = bl.cbegin();
+    p.seek(seek);
+    try {
+      Message *n = decode_message(g_ceph_context, 0, p);
+      if (!n)
+       throw std::runtime_error("failed to decode");
+      if (n->get_type() != m_object->get_type()) {
+       stringstream ss;
+       ss << "decoded type " << n->get_type() << " instead of expected " << m_object->get_type();
+       throw std::runtime_error(ss.str());
+      }
+      m_object->put();
+      m_object = static_cast<T *>(n);
+    }
+    catch (buffer::error& e) {
+      return e.what();
+    }
+    if (!p.end()) {
+      ostringstream ss;
+      ss << "stray data at end of buffer, offset " << p.get_off();
+      return ss.str();
+    }
+    return string();
+  }
+
+  void encode(bufferlist& out, uint64_t features) override {
+    out.clear();
+    encode_message(m_object, features, out);
+  }
+
+  void dump(ceph::Formatter *f) override {
+    m_object->dump(f);
+  }
+  void generate() override {
+    //T::generate_test_instances(m_list);
+  }
+  int num_generated() override {
+    return m_list.size();
+  }
+  string select_generated(unsigned i) override {
+    // allow 0- or 1-based (by wrapping)
+    if (i == 0)
+      i = m_list.size();
+    if ((i == 0) || (i > m_list.size()))
+      return "invalid id for generated object";
+    m_object->put();
+    m_object = *(std::next(m_list.begin(), i-1));
+    return string();
+  }
+  bool is_deterministic() override {
+    return true;
+  }
+
+  //void print(ostream& out) {
+  //out << m_object << std::endl;
+  //}
+};
+
+  
+
+int main(int argc, const char **argv)
+{
+  // dencoders
+  map<string,Dencoder*> dencoders;
+
+#define T_STR(x) #x
+#define T_STRINGIFY(x) T_STR(x)
+#define TYPE(t) dencoders[T_STRINGIFY(t)] = new DencoderImplNoFeature<t>(false, false);
+#define TYPE_STRAYDATA(t) dencoders[T_STRINGIFY(t)] = new DencoderImplNoFeature<t>(true, false);
+#define TYPE_NONDETERMINISTIC(t) dencoders[T_STRINGIFY(t)] = new DencoderImplNoFeature<t>(false, true);
+#define TYPE_FEATUREFUL(t) dencoders[T_STRINGIFY(t)] = new DencoderImplFeatureful<t>(false, false);
+#define TYPE_FEATUREFUL_STRAYDATA(t) dencoders[T_STRINGIFY(t)] = new DencoderImplFeatureful<t>(true, false);
+#define TYPE_FEATUREFUL_NONDETERMINISTIC(t) dencoders[T_STRINGIFY(t)] = new DencoderImplFeatureful<t>(false, true);
+#define TYPE_FEATUREFUL_NOCOPY(t) dencoders[T_STRINGIFY(t)] = new DencoderImplFeaturefulNoCopy<t>(false, false);
+#define TYPE_NOCOPY(t) dencoders[T_STRINGIFY(t)] = new DencoderImplNoFeatureNoCopy<t>(false, false);
+#define MESSAGE(t) dencoders[T_STRINGIFY(t)] = new MessageDencoderImpl<t>;
+#include "include/types.h"
+#undef TYPE
+#undef TYPE_STRAYDATA
+#undef TYPE_NONDETERMINISTIC
+#undef TYPE_NOCOPY
+#undef TYPE_FEATUREFUL
+#undef TYPE_FEATUREFUL_STRAYDATA
+#undef TYPE_FEATUREFUL_NONDETERMINISTIC
+#undef TYPE_FEATUREFUL_NOCOPY
+#undef T_STR
+#undef T_STRINGIFY
+
+  vector<const char*> args;
+  argv_to_vec(argc, argv, args);
+  env_to_vec(args);
+
+  Dencoder *den = NULL;
+  uint64_t features = CEPH_FEATURES_SUPPORTED_DEFAULT;
+  bufferlist encbl;
+  uint64_t skip = 0;
+
+  if (args.empty()) {
+    cerr << "-h for help" << std::endl;
+    exit(1);
+  }
+  for (std::vector<const char*>::iterator i = args.begin(); i != args.end(); ++i) {
+    string err;
+
+    if (*i == string("help") || *i == string("-h") || *i == string("--help")) {
+      usage(cout);
+      exit(0);
+    } else if (*i == string("version")) {
+      cout << CEPH_GIT_NICE_VER << std::endl;
+    } else if (*i == string("list_types")) {
+      for (map<string,Dencoder*>::iterator p = dencoders.begin();
+          p != dencoders.end();
+          ++p)
+       cout << p->first << std::endl;
+      exit(0);
+    } else if (*i == string("type")) {
+      ++i;
+      if (i == args.end()) {
+       cerr << "expecting type" << std::endl;
+       exit(1);
+      }
+      string cname = *i;
+      if (!dencoders.count(cname)) {
+       cerr << "class '" << cname << "' unknown" << std::endl;
+       exit(1);
+      }
+      den = dencoders[cname];
+      den->generate();
+    } else if (*i == string("skip")) {
+      ++i;
+      if (i == args.end()) {
+       cerr << "expecting byte count" << std::endl;
+       exit(1);
+      }
+      skip = atoi(*i);
+    } else if (*i == string("get_features")) {
+      cout << CEPH_FEATURES_SUPPORTED_DEFAULT << std::endl;
+      exit(0);
+    } else if (*i == string("set_features")) {
+      ++i;
+      if (i == args.end()) {
+       cerr << "expecting features" << std::endl;
+       exit(1);
+      }
+      features = atoll(*i);
+    } else if (*i == string("encode")) {
+      if (!den) {
+       cerr << "must first select type with 'type <name>'" << std::endl;
+       exit(1);
+      }
+      den->encode(encbl, features | CEPH_FEATURE_RESERVED); // hack for OSDMap
+    } else if (*i == string("decode")) {
+      if (!den) {
+       cerr << "must first select type with 'type <name>'" << std::endl;
+       exit(1);
+      }
+      err = den->decode(encbl, skip);
+    } else if (*i == string("copy_ctor")) {
+      if (!den) {
+       cerr << "must first select type with 'type <name>'" << std::endl;
+       exit(1);
+      }
+      den->copy_ctor();
+    } else if (*i == string("copy")) {
+      if (!den) {
+       cerr << "must first select type with 'type <name>'" << std::endl;
+       exit(1);
+      }
+      den->copy();
+    } else if (*i == string("dump_json")) {
+      if (!den) {
+       cerr << "must first select type with 'type <name>'" << std::endl;
+       exit(1);
+      }
+      JSONFormatter jf(true);
+      jf.open_object_section("object");
+      den->dump(&jf);
+      jf.close_section();
+      jf.flush(cout);
+      cout << std::endl;
+
+    } else if (*i == string("hexdump")) {
+      encbl.hexdump(cout);
+    } else if (*i == string("import")) {
+      ++i;
+      if (i == args.end()) {
+       cerr << "expecting filename" << std::endl;
+       exit(1);
+      }
+      int r;
+      if (*i == string("-")) {
+        *i = "stdin";
+       // Read up to 1mb if stdin specified
+       r = encbl.read_fd(STDIN_FILENO, MB(1));
+      } else {
+       r = encbl.read_file(*i, &err);
+      }
+      if (r < 0) {
+        cerr << "error reading " << *i << ": " << err << std::endl;
+        exit(1);
+      }
+
+    } else if (*i == string("export")) {
+      ++i;
+      if (i == args.end()) {
+       cerr << "expecting filename" << std::endl;
+       exit(1);
+      }
+      int fd = ::open(*i, O_WRONLY|O_CREAT|O_TRUNC, 0644);
+      if (fd < 0) {
+       cerr << "error opening " << *i << " for write: " << cpp_strerror(errno) << std::endl;
+       exit(1);
+      }
+      int r = encbl.write_fd(fd);
+      if (r < 0) {
+       cerr << "error writing " << *i << ": " << cpp_strerror(errno) << std::endl;
+       exit(1);
+      }
+      ::close(fd);
+
+    } else if (*i == string("count_tests")) {
+      if (!den) {
+       cerr << "must first select type with 'type <name>'" << std::endl;
+       exit(1);
+      }
+      cout << den->num_generated() << std::endl;
+    } else if (*i == string("select_test")) {
+      if (!den) {
+       cerr << "must first select type with 'type <name>'" << std::endl;
+       exit(1);
+      }
+      ++i;
+      if (i == args.end()) {
+       cerr << "expecting instance number" << std::endl;
+       exit(1);
+      }
+      int n = atoi(*i);
+      err = den->select_generated(n);
+    } else if (*i == string("is_deterministic")) {
+      if (!den) {
+       cerr << "must first select type with 'type <name>'" << std::endl;
+       exit(1);
+      }
+      if (den->is_deterministic())
+       exit(0);
+      else
+       exit(1);
+    } else {
+      cerr << "unknown option '" << *i << "'" << std::endl;
+      exit(1);
+    }      
+    if (err.length()) {
+      cerr << "error: " << err << std::endl;
+      exit(1);
+    }
+  }
+  return 0;
+}
diff --git a/src/tools/ceph-dencoder/ceph_time.h b/src/tools/ceph-dencoder/ceph_time.h
new file mode 100644 (file)
index 0000000..c27cb57
--- /dev/null
@@ -0,0 +1,68 @@
+#ifndef TEST_CEPH_TIME_H
+#define TEST_CEPH_TIME_H
+
+#include <list>
+
+#include "include/encoding.h"
+#include "common/ceph_time.h"
+#include "common/Formatter.h"
+
+// wrapper for ceph::real_time that implements the dencoder interface
+template <typename Clock>
+class time_point_wrapper {
+  using time_point = typename Clock::time_point;
+  time_point t;
+ public:
+  time_point_wrapper() = default;
+  explicit time_point_wrapper(const time_point& t) : t(t) {}
+
+  void encode(bufferlist& bl) const {
+    using ceph::encode;
+    encode(t, bl);
+  }
+  void decode(bufferlist::const_iterator &p) {
+    using ceph::decode;
+    decode(t, p);
+  }
+  void dump(Formatter* f) {
+    auto epoch_time = Clock::to_time_t(t);
+    f->dump_string("time", std::ctime(&epoch_time));
+  }
+  static void generate_test_instances(std::list<time_point_wrapper*>& ls) {
+    constexpr time_t t{455500800}; // Ghostbusters release date
+    ls.push_back(new time_point_wrapper(Clock::from_time_t(t)));
+  }
+};
+
+using real_time_wrapper = time_point_wrapper<ceph::real_clock>;
+WRITE_CLASS_ENCODER(real_time_wrapper)
+
+using coarse_real_time_wrapper = time_point_wrapper<ceph::coarse_real_clock>;
+WRITE_CLASS_ENCODER(coarse_real_time_wrapper)
+
+// wrapper for ceph::timespan that implements the dencoder interface
+class timespan_wrapper {
+  ceph::timespan d;
+ public:
+  timespan_wrapper() = default;
+  explicit timespan_wrapper(const ceph::timespan& d) : d(d) {}
+
+  void encode(bufferlist& bl) const {
+    using ceph::encode;
+    encode(d, bl);
+  }
+  void decode(bufferlist::const_iterator &p) {
+    using ceph::decode;
+    decode(d, p);
+  }
+  void dump(Formatter* f) {
+    f->dump_int("timespan", d.count());
+  }
+  static void generate_test_instances(std::list<timespan_wrapper*>& ls) {
+    constexpr std::chrono::seconds d{7377}; // marathon world record (2:02:57)
+    ls.push_back(new timespan_wrapper(d));
+  }
+};
+WRITE_CLASS_ENCODER(timespan_wrapper)
+
+#endif
diff --git a/src/tools/ceph-dencoder/sstring.h b/src/tools/ceph-dencoder/sstring.h
new file mode 100644 (file)
index 0000000..c2493c1
--- /dev/null
@@ -0,0 +1,40 @@
+#ifndef TEST_SSTRING_H
+#define TEST_SSTRING_H
+
+#include "common/sstring.hh"
+
+// wrapper for sstring that implements the dencoder interface
+class sstring_wrapper {
+  using sstring16 = basic_sstring<char, uint32_t, 16>;
+  sstring16 s1;
+  using sstring24 = basic_sstring<unsigned char, uint16_t, 24>;
+  sstring24 s2;
+ public:
+  sstring_wrapper() = default;
+  sstring_wrapper(sstring16&& s1, sstring24&& s2)
+    : s1(std::move(s1)), s2(std::move(s2))
+  {}
+
+  DENC(sstring_wrapper, w, p) {
+    DENC_START(1, 1, p);
+    denc(w.s1, p);
+    denc(w.s2, p);
+    DENC_FINISH(p);
+  }
+  void dump(Formatter* f) {
+    f->dump_string("s1", s1.c_str());
+    f->dump_string("s2", reinterpret_cast<const char*>(s2.c_str()));
+  }
+  static void generate_test_instances(std::list<sstring_wrapper*>& ls) {
+    ls.push_back(new sstring_wrapper());
+    // initialize sstrings that fit in internal storage
+    constexpr auto cstr6 = "abcdef";
+    ls.push_back(new sstring_wrapper(sstring16{cstr6}, sstring24{cstr6}));
+    // initialize sstrings that overflow into external storage
+    constexpr auto cstr26 = "abcdefghijklmnopqrstuvwxyz";
+    ls.push_back(new sstring_wrapper(sstring16{cstr26}, sstring24{cstr26}));
+  }
+};
+WRITE_CLASS_DENC(sstring_wrapper)
+
+#endif
diff --git a/src/tools/ceph-dencoder/types.h b/src/tools/ceph-dencoder/types.h
new file mode 100644 (file)
index 0000000..5bd6e70
--- /dev/null
@@ -0,0 +1,871 @@
+#include "ceph_time.h"
+TYPE(real_time_wrapper)
+TYPE(coarse_real_time_wrapper)
+TYPE(timespan_wrapper)
+
+#include "sstring.h"
+TYPE(sstring_wrapper)
+
+#include "include/CompatSet.h"
+TYPE(CompatSet)
+
+#include "include/filepath.h"
+TYPE(filepath)
+
+#include "include/fs_types.h"
+TYPE_FEATUREFUL(file_layout_t)
+
+#include "include/util.h"
+TYPE(ceph_data_stats)
+
+#include "common/bit_vector.hpp"
+TYPE(BitVector<2>)
+
+#include "common/bloom_filter.hpp"
+TYPE(bloom_filter)
+TYPE(compressible_bloom_filter)
+
+#include "common/DecayCounter.h"
+TYPE(DecayCounter)
+
+#include "common/histogram.h"
+TYPE(pow2_hist_t)
+
+#include "common/hobject.h"
+TYPE(hobject_t)
+TYPE(ghobject_t)
+
+#include "common/LogEntry.h"
+TYPE_FEATUREFUL(LogEntry)
+TYPE_FEATUREFUL(LogSummary)
+
+#include "common/SloppyCRCMap.h"
+TYPE(SloppyCRCMap)
+
+#include "common/snap_types.h"
+TYPE(SnapContext)
+TYPE(SnapRealmInfo)
+
+#include "msg/msg_types.h"
+TYPE(entity_name_t)
+TYPE_FEATUREFUL(entity_addr_t)
+TYPE_FEATUREFUL(entity_addrvec_t)
+TYPE_FEATUREFUL(entity_inst_t)
+
+#include "crush/CrushWrapper.h"
+TYPE_FEATUREFUL_NOCOPY(CrushWrapper)
+
+#include "osd/OSDMap.h"
+TYPE(osd_info_t)
+TYPE(osd_xinfo_t)
+TYPE_FEATUREFUL_NOCOPY(OSDMap)
+TYPE_FEATUREFUL_STRAYDATA(OSDMap::Incremental)
+
+#include "osd/osd_types.h"
+TYPE(osd_reqid_t)
+TYPE(object_locator_t)
+TYPE(request_redirect_t)
+TYPE(pg_t)
+TYPE(coll_t)
+TYPE_FEATUREFUL(objectstore_perf_stat_t)
+TYPE_FEATUREFUL(osd_stat_t)
+TYPE(OSDSuperblock)
+TYPE_FEATUREFUL(pool_snap_info_t)
+TYPE_FEATUREFUL(pg_pool_t)
+TYPE(object_stat_sum_t)
+TYPE(object_stat_collection_t)
+TYPE(pg_stat_t)
+TYPE_FEATUREFUL(pool_stat_t)
+TYPE(pg_hit_set_info_t)
+TYPE(pg_hit_set_history_t)
+TYPE(pg_history_t)
+TYPE(pg_info_t)
+TYPE(PastIntervals)
+TYPE_FEATUREFUL(pg_query_t)
+TYPE(ObjectModDesc)
+TYPE(pg_log_entry_t)
+TYPE(pg_log_dup_t)
+TYPE(pg_log_t)
+TYPE_FEATUREFUL(pg_missing_item)
+TYPE(pg_missing_t)
+TYPE(pg_nls_response_t)
+TYPE(pg_ls_response_t)
+TYPE(object_copy_cursor_t)
+TYPE_FEATUREFUL(object_copy_data_t)
+TYPE(pg_create_t)
+TYPE(OSDSuperblock)
+TYPE(SnapSet)
+TYPE_FEATUREFUL(watch_info_t)
+TYPE(object_manifest_t)
+TYPE_FEATUREFUL(object_info_t)
+TYPE(SnapSet)
+TYPE_FEATUREFUL(ObjectRecoveryInfo)
+TYPE(ObjectRecoveryProgress)
+TYPE(PushReplyOp)
+TYPE_FEATUREFUL(PullOp)
+TYPE_FEATUREFUL(PushOp)
+TYPE(ScrubMap::object)
+TYPE(ScrubMap)
+TYPE_FEATUREFUL(obj_list_watch_response_t)
+TYPE(clone_info)
+TYPE(obj_list_snap_response_t)
+
+#include "osd/ECUtil.h"
+// TYPE(stripe_info_t) non-standard encoding/decoding functions
+TYPE(ECUtil::HashInfo)
+
+#include "osd/ECMsgTypes.h"
+TYPE_NOCOPY(ECSubWrite)
+TYPE(ECSubWriteReply)
+TYPE_FEATUREFUL(ECSubRead)
+TYPE(ECSubReadReply)
+
+#include "osd/HitSet.h"
+TYPE_NONDETERMINISTIC(ExplicitHashHitSet)
+TYPE_NONDETERMINISTIC(ExplicitObjectHitSet)
+TYPE(BloomHitSet)
+TYPE_NONDETERMINISTIC(HitSet)   // because some subclasses are
+TYPE(HitSet::Params)
+
+#include "os/ObjectStore.h"
+TYPE(ObjectStore::Transaction)
+
+#include "os/filestore/SequencerPosition.h"
+TYPE(SequencerPosition)
+
+#ifdef WITH_BLUESTORE
+#include "os/bluestore/bluestore_types.h"
+TYPE(bluestore_bdev_label_t)
+TYPE(bluestore_cnode_t)
+TYPE(bluestore_compression_header_t)
+TYPE(bluestore_extent_ref_map_t)
+TYPE(bluestore_pextent_t)
+TYPE(bluestore_blob_use_tracker_t)
+// TODO: bluestore_blob_t repurposes the "feature" param of encode() for its
+// struct_v. at a higher level, BlueStore::ExtentMap encodes the extends using
+// a different interface than the normal ones. see
+// BlueStore::ExtentMap::encode_some(). maybe we can test it using another
+// approach.
+// TYPE_FEATUREFUL(bluestore_blob_t)
+// TYPE(bluestore_shared_blob_t) there is no encode here
+TYPE(bluestore_onode_t)
+TYPE(bluestore_deferred_op_t)
+TYPE(bluestore_deferred_transaction_t)
+// TYPE(bluestore_compression_header_t) there is no encode here
+
+#include "os/bluestore/bluefs_types.h"
+TYPE(bluefs_extent_t)
+TYPE(bluefs_fnode_t)
+TYPE(bluefs_super_t)
+TYPE(bluefs_transaction_t)
+#endif
+
+#include "mon/AuthMonitor.h"
+TYPE_FEATUREFUL(AuthMonitor::Incremental)
+
+#include "mon/PGMap.h"
+TYPE_FEATUREFUL_NONDETERMINISTIC(PGMapDigest)
+TYPE_FEATUREFUL_NONDETERMINISTIC(PGMap)
+
+#include "mon/MonitorDBStore.h"
+TYPE(MonitorDBStore::Transaction)
+TYPE(MonitorDBStore::Op)
+
+#include "mon/MonMap.h"
+TYPE_FEATUREFUL(MonMap)
+
+#include "mon/MonCap.h"
+TYPE(MonCap)
+
+#include "mon/MgrMap.h"
+TYPE_FEATUREFUL(MgrMap)
+
+#include "mon/mon_types.h"
+TYPE(LevelDBStoreStats)
+TYPE(ScrubResult)
+
+#include "mon/CreatingPGs.h"
+TYPE(creating_pgs_t)
+
+#include "mgr/ServiceMap.h"
+TYPE_FEATUREFUL(ServiceMap)
+TYPE_FEATUREFUL(ServiceMap::Service)
+TYPE_FEATUREFUL(ServiceMap::Daemon)
+
+#include "os/filestore/DBObjectMap.h"
+TYPE(DBObjectMap::_Header)
+TYPE(DBObjectMap::State)
+
+#include "os/filestore/FileStore.h"
+TYPE(FSSuperblock)
+
+#include "os/kstore/kstore_types.h"
+TYPE(kstore_cnode_t)
+TYPE(kstore_onode_t)
+
+#include "mds/JournalPointer.h"
+TYPE(JournalPointer)
+
+#include "osdc/Journaler.h"
+TYPE(Journaler::Header)
+
+#include "mds/snap.h"
+TYPE(SnapInfo)
+TYPE(snaplink_t)
+TYPE(sr_t)
+
+#include "mds/mdstypes.h"
+TYPE(frag_info_t)
+TYPE(nest_info_t)
+TYPE(quota_info_t)
+TYPE(client_writeable_range_t)
+TYPE_FEATUREFUL(inode_t<std::allocator>)
+TYPE_FEATUREFUL(old_inode_t<std::allocator>)
+TYPE(fnode_t)
+TYPE(old_rstat_t)
+TYPE_FEATUREFUL(session_info_t)
+TYPE(string_snap_t)
+TYPE(MDSCacheObjectInfo)
+TYPE(mds_table_pending_t)
+TYPE(cap_reconnect_t)
+TYPE(inode_load_vec_t)
+TYPE(dirfrag_load_vec_t)
+TYPE(mds_load_t)
+TYPE(MDSCacheObjectInfo)
+TYPE(inode_backtrace_t)
+TYPE(inode_backpointer_t)
+
+#include "mds/CInode.h"
+TYPE_FEATUREFUL(InodeStore)
+TYPE_FEATUREFUL(InodeStoreBare)
+
+#include "mds/MDSMap.h"
+TYPE_FEATUREFUL(MDSMap)
+TYPE_FEATUREFUL(MDSMap::mds_info_t)
+
+#include "mds/FSMap.h"
+//TYPE_FEATUREFUL(Filesystem)
+TYPE_FEATUREFUL(FSMap)
+
+#include "mds/Capability.h"
+TYPE_NOCOPY(Capability)
+
+#include "mds/inode_backtrace.h"
+TYPE(inode_backpointer_t)
+TYPE(inode_backtrace_t)
+
+#include "mds/InoTable.h"
+TYPE(InoTable)
+
+#include "mds/SnapServer.h"
+TYPE_STRAYDATA(SnapServer)
+
+#include "mds/events/ECommitted.h"
+TYPE_FEATUREFUL(ECommitted)
+
+#include "mds/events/EExport.h"
+TYPE_FEATUREFUL(EExport)
+
+#include "mds/events/EFragment.h"
+TYPE_FEATUREFUL(EFragment)
+
+#include "mds/events/EImportFinish.h"
+TYPE_FEATUREFUL(EImportFinish)
+
+#include "mds/events/EImportStart.h"
+TYPE_FEATUREFUL(EImportStart)
+
+#include "mds/events/EMetaBlob.h"
+TYPE_FEATUREFUL_NOCOPY(EMetaBlob::fullbit)
+TYPE(EMetaBlob::remotebit)
+TYPE(EMetaBlob::nullbit)
+TYPE_FEATUREFUL(EMetaBlob::dirlump)
+TYPE_FEATUREFUL(EMetaBlob)
+
+#include "mds/events/EOpen.h"
+TYPE_FEATUREFUL(EOpen)
+
+#include "mds/events/EResetJournal.h"
+TYPE_FEATUREFUL(EResetJournal)
+
+#include "mds/events/ESession.h"
+TYPE_FEATUREFUL(ESession)
+
+#include "mds/events/ESessions.h"
+TYPE_FEATUREFUL(ESessions)
+
+#include "mds/events/ESlaveUpdate.h"
+TYPE(link_rollback)
+TYPE(rmdir_rollback)
+TYPE(rename_rollback::drec)
+TYPE(rename_rollback)
+TYPE_FEATUREFUL(ESlaveUpdate)
+
+#include "mds/events/ESubtreeMap.h"
+TYPE_FEATUREFUL(ESubtreeMap)
+
+#include "mds/events/ETableClient.h"
+TYPE_FEATUREFUL(ETableClient)
+
+#include "mds/events/ETableServer.h"
+TYPE_FEATUREFUL(ETableServer)
+
+#include "mds/events/EUpdate.h"
+TYPE_FEATUREFUL(EUpdate)
+
+#ifdef WITH_RBD
+#include "librbd/journal/Types.h"
+TYPE(librbd::journal::EventEntry)
+TYPE(librbd::journal::ClientData)
+TYPE(librbd::journal::TagData)
+#include "librbd/mirroring_watcher/Types.h"
+TYPE(librbd::mirroring_watcher::NotifyMessage)
+#include "librbd/trash_watcher/Types.h"
+TYPE(librbd::mirroring_watcher::NotifyMessage)
+#include "librbd/WatchNotifyTypes.h"
+TYPE(librbd::watch_notify::NotifyMessage)
+TYPE(librbd::watch_notify::ResponseMessage)
+
+#include "rbd_replay/ActionTypes.h"
+TYPE(rbd_replay::action::Dependency)
+TYPE(rbd_replay::action::ActionEntry)
+
+#include "tools/rbd_mirror/image_map/Types.h"
+TYPE(rbd::mirror::image_map::PolicyData)
+#endif
+
+#ifdef WITH_RADOSGW
+
+#include "rgw/rgw_rados.h"
+TYPE(RGWOLHInfo)
+TYPE(RGWObjManifestPart)
+TYPE(RGWObjManifest)
+TYPE(RGWZoneParams)
+TYPE(RGWZone)
+TYPE(RGWZoneGroup)
+
+#include "rgw/rgw_acl.h"
+TYPE(ACLPermission)
+TYPE(ACLGranteeType)
+TYPE(ACLGrant)
+TYPE(RGWAccessControlList)
+TYPE(ACLOwner)
+TYPE(RGWAccessControlPolicy)
+
+#include "rgw/rgw_cache.h"
+TYPE(ObjectMetaInfo)
+TYPE(ObjectCacheInfo)
+TYPE(RGWCacheNotifyInfo)
+
+#include "rgw/rgw_lc.h"
+TYPE(RGWLifecycleConfiguration)
+
+#include "cls/rgw/cls_rgw_types.h"
+TYPE(rgw_bucket_pending_info)
+TYPE(rgw_bucket_dir_entry_meta)
+TYPE(rgw_bucket_entry_ver)
+TYPE(rgw_bucket_dir_entry)
+TYPE(rgw_bucket_category_stats)
+TYPE(rgw_bucket_dir_header)
+TYPE(rgw_bucket_dir)
+TYPE(rgw_bucket_entry_ver)
+TYPE(cls_rgw_obj_key)
+TYPE(rgw_bucket_olh_log_entry)
+TYPE(rgw_usage_log_entry)
+
+#include "cls/rgw/cls_rgw_ops.h"
+TYPE(rgw_cls_obj_prepare_op)
+TYPE(rgw_cls_obj_complete_op)
+TYPE(rgw_cls_list_op)
+TYPE(rgw_cls_list_ret)
+TYPE(cls_rgw_gc_defer_entry_op)
+TYPE(cls_rgw_gc_list_op)
+TYPE(cls_rgw_gc_list_ret)
+TYPE(cls_rgw_gc_obj_info)
+TYPE(cls_rgw_gc_remove_op)
+TYPE(cls_rgw_gc_set_entry_op)
+TYPE(cls_rgw_obj)
+TYPE(cls_rgw_obj_chain)
+TYPE(rgw_cls_tag_timeout_op)
+TYPE(cls_rgw_bi_log_list_op)
+TYPE(cls_rgw_bi_log_trim_op)
+TYPE(cls_rgw_bi_log_list_ret)
+TYPE(rgw_cls_link_olh_op)
+TYPE(rgw_cls_unlink_instance_op)
+TYPE(rgw_cls_read_olh_log_op)
+TYPE(rgw_cls_read_olh_log_ret)
+TYPE(rgw_cls_trim_olh_log_op)
+TYPE(rgw_cls_bucket_clear_olh_op)
+TYPE(rgw_cls_check_index_ret)
+TYPE(cls_rgw_reshard_add_op)
+TYPE(cls_rgw_reshard_list_op)
+TYPE(cls_rgw_reshard_list_ret)
+TYPE(cls_rgw_reshard_get_op)
+TYPE(cls_rgw_reshard_get_ret)
+TYPE(cls_rgw_reshard_remove_op)
+TYPE(cls_rgw_set_bucket_resharding_op)
+TYPE(cls_rgw_clear_bucket_resharding_op)
+TYPE(cls_rgw_lc_obj_head)
+
+#include "cls/rgw/cls_rgw_client.h"
+TYPE(rgw_bi_log_entry)
+TYPE(cls_rgw_reshard_entry)
+TYPE(cls_rgw_bucket_instance_entry)
+
+#include "cls/user/cls_user_types.h"
+TYPE(cls_user_bucket)
+TYPE(cls_user_bucket_entry)
+TYPE(cls_user_stats)
+TYPE(cls_user_header)
+
+#include "cls/user/cls_user_ops.h"
+TYPE(cls_user_set_buckets_op)
+TYPE(cls_user_remove_bucket_op)
+TYPE(cls_user_list_buckets_op)
+TYPE(cls_user_list_buckets_ret)
+TYPE(cls_user_get_header_op)
+TYPE(cls_user_get_header_ret)
+TYPE(cls_user_complete_stats_sync_op)
+
+#include "cls/journal/cls_journal_types.h"
+TYPE(cls::journal::ObjectPosition)
+TYPE(cls::journal::ObjectSetPosition)
+TYPE(cls::journal::Client)
+TYPE(cls::journal::Tag)
+
+#include "rgw/rgw_common.h"
+TYPE(RGWAccessKey)
+TYPE(RGWSubUser)
+TYPE(RGWUserInfo)
+TYPE(rgw_bucket)
+TYPE(RGWBucketInfo)
+TYPE(RGWBucketEnt)
+TYPE(RGWUploadPartInfo)
+TYPE(rgw_obj)
+
+#include "rgw/rgw_log.h"
+TYPE(rgw_log_entry)
+
+#include "rgw/rgw_meta_sync_status.h"
+TYPE(rgw_meta_sync_info)
+TYPE(rgw_meta_sync_marker)
+TYPE(rgw_meta_sync_status)
+
+#include "rgw/rgw_data_sync.h"
+TYPE(rgw_data_sync_info)
+TYPE(rgw_data_sync_marker)
+TYPE(rgw_data_sync_status)
+
+#endif
+
+#ifdef WITH_RBD
+#include "cls/rbd/cls_rbd.h"
+TYPE(cls_rbd_parent)
+TYPE(cls_rbd_snap)
+
+#include "cls/rbd/cls_rbd_types.h"
+TYPE(cls::rbd::ChildImageSpec)
+TYPE(cls::rbd::MirrorPeer)
+TYPE(cls::rbd::MirrorImage)
+TYPE(cls::rbd::MirrorImageMap)
+TYPE(cls::rbd::MirrorImageStatus)
+TYPE(cls::rbd::GroupImageSpec)
+TYPE(cls::rbd::GroupImageStatus)
+TYPE(cls::rbd::GroupSnapshot)
+TYPE(cls::rbd::GroupSpec)
+TYPE(cls::rbd::ImageSnapshotSpec)
+TYPE(cls::rbd::SnapshotInfo)
+TYPE(cls::rbd::SnapshotNamespace)
+#endif
+
+#include "cls/lock/cls_lock_types.h"
+TYPE(rados::cls::lock::locker_id_t)
+TYPE_FEATUREFUL(rados::cls::lock::locker_info_t)
+TYPE_FEATUREFUL(rados::cls::lock::lock_info_t)
+
+#include "cls/lock/cls_lock_ops.h"
+TYPE(cls_lock_lock_op)
+TYPE(cls_lock_unlock_op)
+TYPE(cls_lock_break_op)
+TYPE(cls_lock_get_info_op)
+TYPE_FEATUREFUL(cls_lock_get_info_reply)
+TYPE(cls_lock_list_locks_reply)
+TYPE(cls_lock_assert_op)
+TYPE(cls_lock_set_cookie_op)
+
+#include "cls/refcount/cls_refcount_ops.h"
+TYPE(cls_refcount_get_op)
+TYPE(cls_refcount_put_op)
+TYPE(cls_refcount_set_op)
+TYPE(cls_refcount_read_op)
+TYPE(cls_refcount_read_ret)
+
+#include "journal/Entry.h"
+TYPE(journal::Entry)
+
+// --- messages ---
+#include "messages/MAuth.h"
+MESSAGE(MAuth)
+
+#include "messages/MAuthReply.h"
+MESSAGE(MAuthReply)
+
+#include "messages/MCacheExpire.h"
+MESSAGE(MCacheExpire)
+
+#include "messages/MClientCapRelease.h"
+MESSAGE(MClientCapRelease)
+
+#include "messages/MClientCaps.h"
+MESSAGE(MClientCaps)
+
+#include "messages/MClientLease.h"
+MESSAGE(MClientLease)
+
+#include "messages/MClientReconnect.h"
+MESSAGE(MClientReconnect)
+
+#include "messages/MClientReply.h"
+MESSAGE(MClientReply)
+
+#include "messages/MClientRequest.h"
+MESSAGE(MClientRequest)
+
+#include "messages/MClientRequestForward.h"
+MESSAGE(MClientRequestForward)
+
+#include "messages/MClientQuota.h"
+MESSAGE(MClientQuota)
+
+#include "messages/MClientSession.h"
+MESSAGE(MClientSession)
+
+#include "messages/MClientSnap.h"
+MESSAGE(MClientSnap)
+
+#include "messages/MCommand.h"
+MESSAGE(MCommand)
+
+#include "messages/MCommandReply.h"
+MESSAGE(MCommandReply)
+
+#include "messages/MConfig.h"
+MESSAGE(MConfig)
+
+#include "messages/MDataPing.h"
+MESSAGE(MDataPing)
+
+#include "messages/MDentryLink.h"
+MESSAGE(MDentryLink)
+
+#include "messages/MDentryUnlink.h"
+MESSAGE(MDentryUnlink)
+
+#include "messages/MDirUpdate.h"
+MESSAGE(MDirUpdate)
+
+#include "messages/MDiscover.h"
+MESSAGE(MDiscover)
+
+#include "messages/MDiscoverReply.h"
+MESSAGE(MDiscoverReply)
+
+#include "messages/MExportCaps.h"
+MESSAGE(MExportCaps)
+
+#include "messages/MExportCapsAck.h"
+MESSAGE(MExportCapsAck)
+
+#include "messages/MExportDir.h"
+MESSAGE(MExportDir)
+
+#include "messages/MExportDirAck.h"
+MESSAGE(MExportDirAck)
+
+#include "messages/MExportDirCancel.h"
+MESSAGE(MExportDirCancel)
+
+#include "messages/MExportDirDiscover.h"
+MESSAGE(MExportDirDiscover)
+
+#include "messages/MExportDirDiscoverAck.h"
+MESSAGE(MExportDirDiscoverAck)
+
+#include "messages/MExportDirFinish.h"
+MESSAGE(MExportDirFinish)
+
+#include "messages/MExportDirNotify.h"
+MESSAGE(MExportDirNotify)
+
+#include "messages/MExportDirNotifyAck.h"
+MESSAGE(MExportDirNotifyAck)
+
+#include "messages/MExportDirPrep.h"
+MESSAGE(MExportDirPrep)
+
+#include "messages/MExportDirPrepAck.h"
+MESSAGE(MExportDirPrepAck)
+
+#include "messages/MForward.h"
+MESSAGE(MForward)
+
+#include "messages/MFSMap.h"
+MESSAGE(MFSMap)
+
+#include "messages/MFSMapUser.h"
+MESSAGE(MFSMapUser)
+
+#include "messages/MGatherCaps.h"
+MESSAGE(MGatherCaps)
+
+#include "messages/MGenericMessage.h"
+MESSAGE(MGenericMessage)
+
+#include "messages/MGetConfig.h"
+MESSAGE(MGetConfig)
+
+#include "messages/MGetPoolStats.h"
+MESSAGE(MGetPoolStats)
+
+#include "messages/MGetPoolStatsReply.h"
+MESSAGE(MGetPoolStatsReply)
+
+#include "messages/MHeartbeat.h"
+MESSAGE(MHeartbeat)
+
+#include "messages/MInodeFileCaps.h"
+MESSAGE(MInodeFileCaps)
+
+#include "messages/MLock.h"
+MESSAGE(MLock)
+
+#include "messages/MLog.h"
+MESSAGE(MLog)
+
+#include "messages/MLogAck.h"
+MESSAGE(MLogAck)
+
+#include "messages/MMDSOpenIno.h"
+MESSAGE(MMDSOpenIno)
+
+#include "messages/MMDSOpenInoReply.h"
+MESSAGE(MMDSOpenInoReply)
+
+#include "messages/MMDSBeacon.h"
+MESSAGE(MMDSBeacon)
+
+#include "messages/MMDSCacheRejoin.h"
+MESSAGE(MMDSCacheRejoin)
+
+#include "messages/MMDSFindIno.h"
+MESSAGE(MMDSFindIno)
+
+#include "messages/MMDSFindInoReply.h"
+MESSAGE(MMDSFindInoReply)
+
+#include "messages/MMDSFragmentNotify.h"
+MESSAGE(MMDSFragmentNotify)
+
+#include "messages/MMDSLoadTargets.h"
+MESSAGE(MMDSLoadTargets)
+
+#include "messages/MMDSMap.h"
+MESSAGE(MMDSMap)
+
+#include "messages/MMgrReport.h"
+MESSAGE(MMgrReport)
+
+#include "messages/MMDSResolve.h"
+MESSAGE(MMDSResolve)
+
+#include "messages/MMDSResolveAck.h"
+MESSAGE(MMDSResolveAck)
+
+#include "messages/MMDSSlaveRequest.h"
+MESSAGE(MMDSSlaveRequest)
+
+#include "messages/MMDSSnapUpdate.h"
+MESSAGE(MMDSSnapUpdate)
+
+#include "messages/MMDSTableRequest.h"
+MESSAGE(MMDSTableRequest)
+
+#include "messages/MMgrClose.h"
+MESSAGE(MMgrClose)
+
+#include "messages/MMgrConfigure.h"
+MESSAGE(MMgrConfigure)
+
+#include "messages/MMgrDigest.h"
+MESSAGE(MMgrDigest)
+
+#include "messages/MMgrMap.h"
+MESSAGE(MMgrMap)
+
+#include "messages/MMgrOpen.h"
+MESSAGE(MMgrOpen)
+
+#include "messages/MMonCommand.h"
+MESSAGE(MMonCommand)
+
+#include "messages/MMonCommandAck.h"
+MESSAGE(MMonCommandAck)
+
+#include "messages/MMonElection.h"
+MESSAGE(MMonElection)
+
+#include "messages/MMonGetMap.h"
+MESSAGE(MMonGetMap)
+
+#include "messages/MMonGetVersion.h"
+MESSAGE(MMonGetVersion)
+
+#include "messages/MMonGetVersionReply.h"
+MESSAGE(MMonGetVersionReply)
+
+#include "messages/MMonGlobalID.h"
+MESSAGE(MMonGlobalID)
+
+#include "messages/MMonJoin.h"
+MESSAGE(MMonJoin)
+
+#include "messages/MMonMap.h"
+MESSAGE(MMonMap)
+
+#include "messages/MMonMetadata.h"
+MESSAGE(MMonMetadata)
+
+#include "messages/MMonPaxos.h"
+MESSAGE(MMonPaxos)
+
+#include "messages/MMonProbe.h"
+MESSAGE(MMonProbe)
+
+#include "messages/MMonScrub.h"
+MESSAGE(MMonScrub)
+
+#include "messages/MMonSync.h"
+MESSAGE(MMonSync)
+
+#include "messages/MMonSubscribe.h"
+MESSAGE(MMonSubscribe)
+
+#include "messages/MMonSubscribeAck.h"
+MESSAGE(MMonSubscribeAck)
+
+#include "messages/MNop.h"
+MESSAGE(MNop)
+
+#include "messages/MOSDAlive.h"
+MESSAGE(MOSDAlive)
+
+#include "messages/MOSDBoot.h"
+MESSAGE(MOSDBoot)
+
+#include "messages/MOSDFailure.h"
+MESSAGE(MOSDFailure)
+
+#include "messages/MOSDMap.h"
+MESSAGE(MOSDMap)
+
+#include "messages/MOSDOp.h"
+MESSAGE(MOSDOp)
+
+#include "messages/MOSDOpReply.h"
+MESSAGE(MOSDOpReply)
+
+#include "messages/MOSDPGBackfill.h"
+MESSAGE(MOSDPGBackfill)
+
+#include "messages/MOSDPGCreate.h"
+MESSAGE(MOSDPGCreate)
+
+#include "messages/MOSDPGCreate2.h"
+MESSAGE(MOSDPGCreate2)
+
+#include "messages/MOSDPGInfo.h"
+MESSAGE(MOSDPGInfo)
+
+#include "messages/MOSDPGLog.h"
+MESSAGE(MOSDPGLog)
+
+#include "messages/MOSDPGNotify.h"
+MESSAGE(MOSDPGNotify)
+
+#include "messages/MOSDPGQuery.h"
+MESSAGE(MOSDPGQuery)
+
+#include "messages/MOSDPGRemove.h"
+MESSAGE(MOSDPGRemove)
+
+#include "messages/MOSDPGRecoveryDelete.h"
+MESSAGE(MOSDPGRecoveryDelete)
+
+#include "messages/MOSDPGRecoveryDeleteReply.h"
+MESSAGE(MOSDPGRecoveryDeleteReply)
+
+#include "messages/MOSDPGScan.h"
+MESSAGE(MOSDPGScan)
+
+#include "messages/MOSDPGTemp.h"
+MESSAGE(MOSDPGTemp)
+
+#include "messages/MOSDPGTrim.h"
+MESSAGE(MOSDPGTrim)
+
+#include "messages/MOSDPing.h"
+MESSAGE(MOSDPing)
+
+#include "messages/MOSDRepScrub.h"
+MESSAGE(MOSDRepScrub)
+
+#include "messages/MOSDScrub.h"
+MESSAGE(MOSDScrub)
+
+#include "messages/MOSDScrub2.h"
+MESSAGE(MOSDScrub2)
+
+#include "messages/MOSDForceRecovery.h"
+MESSAGE(MOSDForceRecovery)
+
+#include "messages/MPGStats.h"
+MESSAGE(MPGStats)
+
+#include "messages/MPGStatsAck.h"
+MESSAGE(MPGStatsAck)
+
+#include "messages/MPing.h"
+MESSAGE(MPing)
+
+#include "messages/MPoolOp.h"
+MESSAGE(MPoolOp)
+
+#include "messages/MPoolOpReply.h"
+MESSAGE(MPoolOpReply)
+
+#include "messages/MRemoveSnaps.h"
+MESSAGE(MRemoveSnaps)
+
+#include "messages/MRoute.h"
+MESSAGE(MRoute)
+
+#include "messages/MServiceMap.h"
+MESSAGE(MServiceMap)
+
+#include "messages/MStatfs.h"
+MESSAGE(MStatfs)
+
+#include "messages/MStatfsReply.h"
+MESSAGE(MStatfsReply)
+
+#include "messages/MTimeCheck.h"
+MESSAGE(MTimeCheck)
+
+#include "messages/MTimeCheck2.h"
+MESSAGE(MTimeCheck2)
+
+#include "messages/MWatchNotify.h"
+MESSAGE(MWatchNotify)
+
+#include "messages/PaxosServiceMessage.h"
+MESSAGE(PaxosServiceMessage)
diff --git a/src/tools/ceph_dencoder.cc b/src/tools/ceph_dencoder.cc
deleted file mode 100644 (file)
index 74f3ca3..0000000
+++ /dev/null
@@ -1,486 +0,0 @@
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
-// vim: ts=8 sw=2 smarttab
-/*
- * Ceph - scalable distributed file system
- *
- * Copyright (C) 2015 Red Hat
- *
- * This is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1, as published by the Free Software
- * Foundation.  See file COPYING.
- *
- */
-
-
-#include <errno.h>
-#include "include/types.h"
-#include "ceph_ver.h"
-#include "include/encoding.h"
-#include "include/ceph_features.h"
-#include "common/ceph_argparse.h"
-#include "common/Formatter.h"
-#include "common/errno.h"
-#include "msg/Message.h"
-#include "include/assert.h"
-
-#define TYPE(t)
-#define TYPE_STRAYDATA(t)
-#define TYPE_NONDETERMINISTIC(t)
-#define TYPE_FEATUREFUL(t)
-#define TYPE_FEATUREFUL_STRAYDATA(t)
-#define TYPE_FEATUREFUL_NONDETERMINISTIC(t)
-#define TYPE_FEATUREFUL_NOCOPY(t)
-#define TYPE_NOCOPY(t)
-#define MESSAGE(t)
-#include "include/types.h"
-#undef TYPE
-#undef TYPE_STRAYDATA
-#undef TYPE_NONDETERMINISTIC
-#undef TYPE_NOCOPY
-#undef TYPE_FEATUREFUL
-#undef TYPE_FEATUREFUL_STRAYDATA
-#undef TYPE_FEATUREFUL_NONDETERMINISTIC
-#undef TYPE_FEATUREFUL_NOCOPY
-#undef MESSAGE
-
-#define MB(m) ((m) * 1024 * 1024)
-
-void usage(ostream &out)
-{
-  out << "usage: ceph-dencoder [commands ...]" << std::endl;
-  out << "\n";
-  out << "  version             print version string (to stdout)\n";
-  out << "\n";
-  out << "  import <encfile>    read encoded data from encfile\n";
-  out << "  export <outfile>    write encoded data to outfile\n";
-  out << "\n";
-  out << "  set_features <num>  set feature bits used for encoding\n";
-  out << "  get_features        print feature bits (int) to stdout\n";
-  out << "\n";
-  out << "  list_types          list supported types\n";
-  out << "  type <classname>    select in-memory type\n";
-  out << "  skip <num>          skip <num> leading bytes before decoding\n";
-  out << "  decode              decode into in-memory object\n";
-  out << "  encode              encode in-memory object\n";
-  out << "  dump_json           dump in-memory object as json (to stdout)\n";
-  out << "  hexdump             print encoded data in hex\n";
-  out << "\n";
-  out << "  copy                copy object (via operator=)\n";
-  out << "  copy_ctor           copy object (via copy ctor)\n";
-  out << "\n";
-  out << "  count_tests         print number of generated test objects (to stdout)\n";
-  out << "  select_test <n>     select generated test object as in-memory object\n";
-  out << "  is_deterministic    exit w/ success if type encodes deterministically\n";
-}
-struct Dencoder {
-  virtual ~Dencoder() {}
-  virtual string decode(bufferlist bl, uint64_t seek) = 0;
-  virtual void encode(bufferlist& out, uint64_t features) = 0;
-  virtual void dump(ceph::Formatter *f) = 0;
-  virtual void copy() {
-    cerr << "copy operator= not supported" << std::endl;
-  }
-  virtual void copy_ctor() {
-    cerr << "copy ctor not supported" << std::endl;
-  }
-  virtual void generate() = 0;
-  virtual int num_generated() = 0;
-  virtual string select_generated(unsigned n) = 0;
-  virtual bool is_deterministic() = 0;
-  //virtual void print(ostream& out) = 0;
-};
-
-template<class T>
-class DencoderBase : public Dencoder {
-protected:
-  T* m_object;
-  list<T*> m_list;
-  bool stray_okay;
-  bool nondeterministic;
-
-public:
-  DencoderBase(bool stray_okay, bool nondeterministic)
-    : m_object(new T),
-      stray_okay(stray_okay),
-      nondeterministic(nondeterministic) {}
-  ~DencoderBase() override {
-    delete m_object;
-  }
-
-  string decode(bufferlist bl, uint64_t seek) override {
-    auto p = bl.cbegin();
-    p.seek(seek);
-    try {
-      using ceph::decode;
-      decode(*m_object, p);
-    }
-    catch (buffer::error& e) {
-      return e.what();
-    }
-    if (!stray_okay && !p.end()) {
-      ostringstream ss;
-      ss << "stray data at end of buffer, offset " << p.get_off();
-      return ss.str();
-    }
-    return string();
-  }
-
-  void encode(bufferlist& out, uint64_t features) override = 0;
-
-  void dump(ceph::Formatter *f) override {
-    m_object->dump(f);
-  }
-  void generate() override {
-    T::generate_test_instances(m_list);
-  }
-  int num_generated() override {
-    return m_list.size();
-  }
-  string select_generated(unsigned i) override {
-    // allow 0- or 1-based (by wrapping)
-    if (i == 0)
-      i = m_list.size();
-    if ((i == 0) || (i > m_list.size()))
-      return "invalid id for generated object";
-    m_object = *(std::next(m_list.begin(), i-1));
-    return string();
-  }
-
-  bool is_deterministic() override {
-    return !nondeterministic;
-  }
-};
-
-template<class T>
-class DencoderImplNoFeatureNoCopy : public DencoderBase<T> {
-public:
-  DencoderImplNoFeatureNoCopy(bool stray_ok, bool nondeterministic)
-    : DencoderBase<T>(stray_ok, nondeterministic) {}
-  void encode(bufferlist& out, uint64_t features) override {
-    out.clear();
-    using ceph::encode;
-    encode(*this->m_object, out);
-  }
-};
-
-template<class T>
-class DencoderImplNoFeature : public DencoderImplNoFeatureNoCopy<T> {
-public:
-  DencoderImplNoFeature(bool stray_ok, bool nondeterministic)
-    : DencoderImplNoFeatureNoCopy<T>(stray_ok, nondeterministic) {}
-  void copy() override {
-    T *n = new T;
-    *n = *this->m_object;
-    delete this->m_object;
-    this->m_object = n;
-  }
-  void copy_ctor() override {
-    T *n = new T(*this->m_object);
-    delete this->m_object;
-    this->m_object = n;
-  }
-};
-
-template<class T>
-class DencoderImplFeaturefulNoCopy : public DencoderBase<T> {
-public:
-  DencoderImplFeaturefulNoCopy(bool stray_ok, bool nondeterministic)
-    : DencoderBase<T>(stray_ok, nondeterministic) {}
-  void encode(bufferlist& out, uint64_t features) override {
-    out.clear();
-    using ceph::encode;
-    encode(*(this->m_object), out, features);
-  }
-};
-
-template<class T>
-class DencoderImplFeatureful : public DencoderImplFeaturefulNoCopy<T> {
-public:
-  DencoderImplFeatureful(bool stray_ok, bool nondeterministic)
-    : DencoderImplFeaturefulNoCopy<T>(stray_ok, nondeterministic) {}
-  void copy() override {
-    T *n = new T;
-    *n = *this->m_object;
-    delete this->m_object;
-    this->m_object = n;
-  }
-  void copy_ctor() override {
-    T *n = new T(*this->m_object);
-    delete this->m_object;
-    this->m_object = n;
-  }
-};
-
-template<class T>
-class MessageDencoderImpl : public Dencoder {
-  T *m_object;
-  list<T*> m_list;
-
-public:
-  MessageDencoderImpl() {
-    m_object = new T;
-  }
-  ~MessageDencoderImpl() override {
-    m_object->put();
-  }
-
-  string decode(bufferlist bl, uint64_t seek) override {
-    auto p = bl.cbegin();
-    p.seek(seek);
-    try {
-      Message *n = decode_message(g_ceph_context, 0, p);
-      if (!n)
-       throw std::runtime_error("failed to decode");
-      if (n->get_type() != m_object->get_type()) {
-       stringstream ss;
-       ss << "decoded type " << n->get_type() << " instead of expected " << m_object->get_type();
-       throw std::runtime_error(ss.str());
-      }
-      m_object->put();
-      m_object = static_cast<T *>(n);
-    }
-    catch (buffer::error& e) {
-      return e.what();
-    }
-    if (!p.end()) {
-      ostringstream ss;
-      ss << "stray data at end of buffer, offset " << p.get_off();
-      return ss.str();
-    }
-    return string();
-  }
-
-  void encode(bufferlist& out, uint64_t features) override {
-    out.clear();
-    encode_message(m_object, features, out);
-  }
-
-  void dump(ceph::Formatter *f) override {
-    m_object->dump(f);
-  }
-  void generate() override {
-    //T::generate_test_instances(m_list);
-  }
-  int num_generated() override {
-    return m_list.size();
-  }
-  string select_generated(unsigned i) override {
-    // allow 0- or 1-based (by wrapping)
-    if (i == 0)
-      i = m_list.size();
-    if ((i == 0) || (i > m_list.size()))
-      return "invalid id for generated object";
-    m_object->put();
-    m_object = *(std::next(m_list.begin(), i-1));
-    return string();
-  }
-  bool is_deterministic() override {
-    return true;
-  }
-
-  //void print(ostream& out) {
-  //out << m_object << std::endl;
-  //}
-};
-
-  
-
-int main(int argc, const char **argv)
-{
-  // dencoders
-  map<string,Dencoder*> dencoders;
-
-#define T_STR(x) #x
-#define T_STRINGIFY(x) T_STR(x)
-#define TYPE(t) dencoders[T_STRINGIFY(t)] = new DencoderImplNoFeature<t>(false, false);
-#define TYPE_STRAYDATA(t) dencoders[T_STRINGIFY(t)] = new DencoderImplNoFeature<t>(true, false);
-#define TYPE_NONDETERMINISTIC(t) dencoders[T_STRINGIFY(t)] = new DencoderImplNoFeature<t>(false, true);
-#define TYPE_FEATUREFUL(t) dencoders[T_STRINGIFY(t)] = new DencoderImplFeatureful<t>(false, false);
-#define TYPE_FEATUREFUL_STRAYDATA(t) dencoders[T_STRINGIFY(t)] = new DencoderImplFeatureful<t>(true, false);
-#define TYPE_FEATUREFUL_NONDETERMINISTIC(t) dencoders[T_STRINGIFY(t)] = new DencoderImplFeatureful<t>(false, true);
-#define TYPE_FEATUREFUL_NOCOPY(t) dencoders[T_STRINGIFY(t)] = new DencoderImplFeaturefulNoCopy<t>(false, false);
-#define TYPE_NOCOPY(t) dencoders[T_STRINGIFY(t)] = new DencoderImplNoFeatureNoCopy<t>(false, false);
-#define MESSAGE(t) dencoders[T_STRINGIFY(t)] = new MessageDencoderImpl<t>;
-#include "include/types.h"
-#undef TYPE
-#undef TYPE_STRAYDATA
-#undef TYPE_NONDETERMINISTIC
-#undef TYPE_NOCOPY
-#undef TYPE_FEATUREFUL
-#undef TYPE_FEATUREFUL_STRAYDATA
-#undef TYPE_FEATUREFUL_NONDETERMINISTIC
-#undef TYPE_FEATUREFUL_NOCOPY
-#undef T_STR
-#undef T_STRINGIFY
-
-  vector<const char*> args;
-  argv_to_vec(argc, argv, args);
-  env_to_vec(args);
-
-  Dencoder *den = NULL;
-  uint64_t features = CEPH_FEATURES_SUPPORTED_DEFAULT;
-  bufferlist encbl;
-  uint64_t skip = 0;
-
-  if (args.empty()) {
-    cerr << "-h for help" << std::endl;
-    exit(1);
-  }
-  for (std::vector<const char*>::iterator i = args.begin(); i != args.end(); ++i) {
-    string err;
-
-    if (*i == string("help") || *i == string("-h") || *i == string("--help")) {
-      usage(cout);
-      exit(0);
-    } else if (*i == string("version")) {
-      cout << CEPH_GIT_NICE_VER << std::endl;
-    } else if (*i == string("list_types")) {
-      for (map<string,Dencoder*>::iterator p = dencoders.begin();
-          p != dencoders.end();
-          ++p)
-       cout << p->first << std::endl;
-      exit(0);
-    } else if (*i == string("type")) {
-      ++i;
-      if (i == args.end()) {
-       cerr << "expecting type" << std::endl;
-       exit(1);
-      }
-      string cname = *i;
-      if (!dencoders.count(cname)) {
-       cerr << "class '" << cname << "' unknown" << std::endl;
-       exit(1);
-      }
-      den = dencoders[cname];
-      den->generate();
-    } else if (*i == string("skip")) {
-      ++i;
-      if (i == args.end()) {
-       cerr << "expecting byte count" << std::endl;
-       exit(1);
-      }
-      skip = atoi(*i);
-    } else if (*i == string("get_features")) {
-      cout << CEPH_FEATURES_SUPPORTED_DEFAULT << std::endl;
-      exit(0);
-    } else if (*i == string("set_features")) {
-      ++i;
-      if (i == args.end()) {
-       cerr << "expecting features" << std::endl;
-       exit(1);
-      }
-      features = atoll(*i);
-    } else if (*i == string("encode")) {
-      if (!den) {
-       cerr << "must first select type with 'type <name>'" << std::endl;
-       exit(1);
-      }
-      den->encode(encbl, features | CEPH_FEATURE_RESERVED); // hack for OSDMap
-    } else if (*i == string("decode")) {
-      if (!den) {
-       cerr << "must first select type with 'type <name>'" << std::endl;
-       exit(1);
-      }
-      err = den->decode(encbl, skip);
-    } else if (*i == string("copy_ctor")) {
-      if (!den) {
-       cerr << "must first select type with 'type <name>'" << std::endl;
-       exit(1);
-      }
-      den->copy_ctor();
-    } else if (*i == string("copy")) {
-      if (!den) {
-       cerr << "must first select type with 'type <name>'" << std::endl;
-       exit(1);
-      }
-      den->copy();
-    } else if (*i == string("dump_json")) {
-      if (!den) {
-       cerr << "must first select type with 'type <name>'" << std::endl;
-       exit(1);
-      }
-      JSONFormatter jf(true);
-      jf.open_object_section("object");
-      den->dump(&jf);
-      jf.close_section();
-      jf.flush(cout);
-      cout << std::endl;
-
-    } else if (*i == string("hexdump")) {
-      encbl.hexdump(cout);
-    } else if (*i == string("import")) {
-      ++i;
-      if (i == args.end()) {
-       cerr << "expecting filename" << std::endl;
-       exit(1);
-      }
-      int r;
-      if (*i == string("-")) {
-        *i = "stdin";
-       // Read up to 1mb if stdin specified
-       r = encbl.read_fd(STDIN_FILENO, MB(1));
-      } else {
-       r = encbl.read_file(*i, &err);
-      }
-      if (r < 0) {
-        cerr << "error reading " << *i << ": " << err << std::endl;
-        exit(1);
-      }
-
-    } else if (*i == string("export")) {
-      ++i;
-      if (i == args.end()) {
-       cerr << "expecting filename" << std::endl;
-       exit(1);
-      }
-      int fd = ::open(*i, O_WRONLY|O_CREAT|O_TRUNC, 0644);
-      if (fd < 0) {
-       cerr << "error opening " << *i << " for write: " << cpp_strerror(errno) << std::endl;
-       exit(1);
-      }
-      int r = encbl.write_fd(fd);
-      if (r < 0) {
-       cerr << "error writing " << *i << ": " << cpp_strerror(errno) << std::endl;
-       exit(1);
-      }
-      ::close(fd);
-
-    } else if (*i == string("count_tests")) {
-      if (!den) {
-       cerr << "must first select type with 'type <name>'" << std::endl;
-       exit(1);
-      }
-      cout << den->num_generated() << std::endl;
-    } else if (*i == string("select_test")) {
-      if (!den) {
-       cerr << "must first select type with 'type <name>'" << std::endl;
-       exit(1);
-      }
-      ++i;
-      if (i == args.end()) {
-       cerr << "expecting instance number" << std::endl;
-       exit(1);
-      }
-      int n = atoi(*i);
-      err = den->select_generated(n);
-    } else if (*i == string("is_deterministic")) {
-      if (!den) {
-       cerr << "must first select type with 'type <name>'" << std::endl;
-       exit(1);
-      }
-      if (den->is_deterministic())
-       exit(0);
-      else
-       exit(1);
-    } else {
-      cerr << "unknown option '" << *i << "'" << std::endl;
-      exit(1);
-    }      
-    if (err.length()) {
-      cerr << "error: " << err << std::endl;
-      exit(1);
-    }
-  }
-  return 0;
-}