From 5fe1c6f9482b82e21c0c7a9d01828a455eb0c5d1 Mon Sep 17 00:00:00 2001 From: "Adam C. Emerson" Date: Tue, 26 Dec 2017 14:45:48 -0500 Subject: [PATCH] rbd_replay: Use unqualified encode/decode This is a portion of Part 1 of the namespace project: using ADL properly in encode and decode so we can use namespaces easily in Ceph. Signed-off-by: Adam C. Emerson --- src/rbd_replay/ActionTypes.cc | 90 ++++++++++++++++++++--------------- src/rbd_replay/ActionTypes.h | 7 +-- src/rbd_replay/ios.cc | 36 +++++++++----- 3 files changed, 78 insertions(+), 55 deletions(-) diff --git a/src/rbd_replay/ActionTypes.cc b/src/rbd_replay/ActionTypes.cc index 6b0d584caab..167bf852233 100644 --- a/src/rbd_replay/ActionTypes.cc +++ b/src/rbd_replay/ActionTypes.cc @@ -23,9 +23,10 @@ bool byte_swap_required(__u8 version) { } void decode_big_endian_string(std::string &str, bufferlist::iterator &it) { + using ceph::decode; #if defined(CEPH_LITTLE_ENDIAN) uint32_t length; - ::decode(length, it); + decode(length, it); length = swab(length); str.clear(); it.copy(length, str); @@ -41,7 +42,8 @@ public: template inline void operator()(const Action &action) const { - ::encode(static_cast(Action::ACTION_TYPE), m_bl); + using ceph::encode; + encode(static_cast(Action::ACTION_TYPE), m_bl); action.encode(m_bl); } private: @@ -80,8 +82,9 @@ private: } // anonymous namespace void Dependency::encode(bufferlist &bl) const { - ::encode(id, bl); - ::encode(time_delta, bl); + using ceph::encode; + encode(id, bl); + encode(time_delta, bl); } void Dependency::decode(bufferlist::iterator &it) { @@ -89,8 +92,9 @@ void Dependency::decode(bufferlist::iterator &it) { } void Dependency::decode(__u8 version, bufferlist::iterator &it) { - ::decode(id, it); - ::decode(time_delta, it); + using ceph::decode; + decode(id, it); + decode(time_delta, it); if (byte_swap_required(version)) { id = swab(id); time_delta = swab(time_delta); @@ -108,20 +112,22 @@ void Dependency::generate_test_instances(std::list &o) { } void ActionBase::encode(bufferlist &bl) const { - ::encode(id, bl); - ::encode(thread_id, bl); - ::encode(dependencies, bl); + using ceph::encode; + encode(id, bl); + encode(thread_id, bl); + encode(dependencies, bl); } void ActionBase::decode(__u8 version, bufferlist::iterator &it) { - ::decode(id, it); - ::decode(thread_id, it); + using ceph::decode; + decode(id, it); + decode(thread_id, it); if (version == 0) { uint32_t num_successors; - ::decode(num_successors, it); + decode(num_successors, it); uint32_t num_completion_successors; - ::decode(num_completion_successors, it); + decode(num_completion_successors, it); } if (byte_swap_required(version)) { @@ -129,14 +135,14 @@ void ActionBase::decode(__u8 version, bufferlist::iterator &it) { thread_id = swab(thread_id); uint32_t dep_count; - ::decode(dep_count, it); + decode(dep_count, it); dep_count = swab(dep_count); dependencies.resize(dep_count); for (uint32_t i = 0; i < dep_count; ++i) { dependencies[i].decode(0, it); } } else { - ::decode(dependencies, it); + decode(dependencies, it); } } @@ -153,13 +159,15 @@ void ActionBase::dump(Formatter *f) const { } void ImageActionBase::encode(bufferlist &bl) const { + using ceph::encode; ActionBase::encode(bl); - ::encode(imagectx_id, bl); + encode(imagectx_id, bl); } void ImageActionBase::decode(__u8 version, bufferlist::iterator &it) { + using ceph::decode; ActionBase::decode(version, it); - ::decode(imagectx_id, it); + decode(imagectx_id, it); if (byte_swap_required(version)) { imagectx_id = swab(imagectx_id); } @@ -171,15 +179,17 @@ void ImageActionBase::dump(Formatter *f) const { } void IoActionBase::encode(bufferlist &bl) const { + using ceph::encode; ImageActionBase::encode(bl); - ::encode(offset, bl); - ::encode(length, bl); + encode(offset, bl); + encode(length, bl); } void IoActionBase::decode(__u8 version, bufferlist::iterator &it) { + using ceph::decode; ImageActionBase::decode(version, it); - ::decode(offset, it); - ::decode(length, it); + decode(offset, it); + decode(length, it); if (byte_swap_required(version)) { offset = swab(offset); length = swab(length); @@ -193,22 +203,24 @@ void IoActionBase::dump(Formatter *f) const { } void OpenImageAction::encode(bufferlist &bl) const { + using ceph::encode; ImageActionBase::encode(bl); - ::encode(name, bl); - ::encode(snap_name, bl); - ::encode(read_only, bl); + encode(name, bl); + encode(snap_name, bl); + encode(read_only, bl); } void OpenImageAction::decode(__u8 version, bufferlist::iterator &it) { + using ceph::decode; ImageActionBase::decode(version, it); if (byte_swap_required(version)) { decode_big_endian_string(name, it); decode_big_endian_string(snap_name, it); } else { - ::decode(name, it); - ::decode(snap_name, it); + decode(name, it); + decode(snap_name, it); } - ::decode(read_only, it); + decode(read_only, it); } void OpenImageAction::dump(Formatter *f) const { @@ -219,22 +231,24 @@ void OpenImageAction::dump(Formatter *f) const { } void AioOpenImageAction::encode(bufferlist &bl) const { + using ceph::encode; ImageActionBase::encode(bl); - ::encode(name, bl); - ::encode(snap_name, bl); - ::encode(read_only, bl); + encode(name, bl); + encode(snap_name, bl); + encode(read_only, bl); } void AioOpenImageAction::decode(__u8 version, bufferlist::iterator &it) { + using ceph::decode; ImageActionBase::decode(version, it); if (byte_swap_required(version)) { decode_big_endian_string(name, it); decode_big_endian_string(snap_name, it); } else { - ::decode(name, it); - ::decode(snap_name, it); + decode(name, it); + decode(snap_name, it); } - ::decode(read_only, it); + decode(read_only, it); } void AioOpenImageAction::dump(Formatter *f) const { @@ -271,8 +285,9 @@ void ActionEntry::decode_unversioned(bufferlist::iterator &it) { } void ActionEntry::decode(__u8 version, bufferlist::iterator &it) { + using ceph::decode; uint8_t action_type; - ::decode(action_type, it); + decode(action_type, it); // select the correct action variant based upon the action_type switch (action_type) { @@ -364,11 +379,8 @@ void ActionEntry::generate_test_instances(std::list &o) { o.push_back(new ActionEntry(AioCloseImageAction(1, 123456789, dependencies, 3))); } -} // namespace action -} // namespace rbd_replay - std::ostream &operator<<(std::ostream &out, - const rbd_replay::action::ActionType &type) { + const ActionType &type) { using namespace rbd_replay::action; switch (type) { @@ -415,3 +427,5 @@ std::ostream &operator<<(std::ostream &out, return out; } +} // namespace action +} // namespace rbd_replay diff --git a/src/rbd_replay/ActionTypes.h b/src/rbd_replay/ActionTypes.h index b6dc43351e1..c7c86e751ea 100644 --- a/src/rbd_replay/ActionTypes.h +++ b/src/rbd_replay/ActionTypes.h @@ -330,13 +330,10 @@ private: WRITE_CLASS_ENCODER(ActionEntry); -} // namespace action -} // namespace rbd_replay - std::ostream &operator<<(std::ostream &out, const rbd_replay::action::ActionType &type); -using rbd_replay::action::decode; -using rbd_replay::action::encode; +} // namespace action +} // namespace rbd_replay #endif // CEPH_RBD_REPLAY_ACTION_TYPES_H diff --git a/src/rbd_replay/ios.cc b/src/rbd_replay/ios.cc index db8470e9cf4..845b6990234 100644 --- a/src/rbd_replay/ios.cc +++ b/src/rbd_replay/ios.cc @@ -68,9 +68,10 @@ ostream& operator<<(ostream &out, const IO::ptr &io) { } void StartThreadIO::encode(bufferlist &bl) const { + using ceph::encode; action::Action action((action::StartThreadAction( ionum(), thread_id(), convert_dependencies(start_time(), dependencies())))); - ::encode(action, bl); + encode(action, bl); } void StartThreadIO::write_debug(std::ostream& out) const { @@ -78,9 +79,10 @@ void StartThreadIO::write_debug(std::ostream& out) const { } void StopThreadIO::encode(bufferlist &bl) const { + using ceph::encode; action::Action action((action::StopThreadAction( ionum(), thread_id(), convert_dependencies(start_time(), dependencies())))); - ::encode(action, bl); + encode(action, bl); } void StopThreadIO::write_debug(std::ostream& out) const { @@ -88,10 +90,11 @@ void StopThreadIO::write_debug(std::ostream& out) const { } void ReadIO::encode(bufferlist &bl) const { + using ceph::encode; action::Action action((action::ReadAction( ionum(), thread_id(), convert_dependencies(start_time(), dependencies()), m_imagectx, m_offset, m_length))); - ::encode(action, bl); + encode(action, bl); } void ReadIO::write_debug(std::ostream& out) const { @@ -100,10 +103,11 @@ void ReadIO::write_debug(std::ostream& out) const { } void WriteIO::encode(bufferlist &bl) const { + using ceph::encode; action::Action action((action::WriteAction( ionum(), thread_id(), convert_dependencies(start_time(), dependencies()), m_imagectx, m_offset, m_length))); - ::encode(action, bl); + encode(action, bl); } void WriteIO::write_debug(std::ostream& out) const { @@ -112,10 +116,11 @@ void WriteIO::write_debug(std::ostream& out) const { } void DiscardIO::encode(bufferlist &bl) const { + using ceph::encode; action::Action action((action::DiscardAction( ionum(), thread_id(), convert_dependencies(start_time(), dependencies()), m_imagectx, m_offset, m_length))); - ::encode(action, bl); + encode(action, bl); } void DiscardIO::write_debug(std::ostream& out) const { @@ -124,10 +129,11 @@ void DiscardIO::write_debug(std::ostream& out) const { } void AioReadIO::encode(bufferlist &bl) const { + using ceph::encode; action::Action action((action::AioReadAction( ionum(), thread_id(), convert_dependencies(start_time(), dependencies()), m_imagectx, m_offset, m_length))); - ::encode(action, bl); + encode(action, bl); } void AioReadIO::write_debug(std::ostream& out) const { @@ -136,10 +142,11 @@ void AioReadIO::write_debug(std::ostream& out) const { } void AioWriteIO::encode(bufferlist &bl) const { + using ceph::encode; action::Action action((action::AioWriteAction( ionum(), thread_id(), convert_dependencies(start_time(), dependencies()), m_imagectx, m_offset, m_length))); - ::encode(action, bl); + encode(action, bl); } void AioWriteIO::write_debug(std::ostream& out) const { @@ -148,10 +155,11 @@ void AioWriteIO::write_debug(std::ostream& out) const { } void AioDiscardIO::encode(bufferlist &bl) const { + using ceph::encode; action::Action action((action::AioDiscardAction( ionum(), thread_id(), convert_dependencies(start_time(), dependencies()), m_imagectx, m_offset, m_length))); - ::encode(action, bl); + encode(action, bl); } void AioDiscardIO::write_debug(std::ostream& out) const { @@ -160,10 +168,11 @@ void AioDiscardIO::write_debug(std::ostream& out) const { } void OpenImageIO::encode(bufferlist &bl) const { + using ceph::encode; action::Action action((action::OpenImageAction( ionum(), thread_id(), convert_dependencies(start_time(), dependencies()), m_imagectx, m_name, m_snap_name, m_readonly))); - ::encode(action, bl); + encode(action, bl); } void OpenImageIO::write_debug(std::ostream& out) const { @@ -172,10 +181,11 @@ void OpenImageIO::write_debug(std::ostream& out) const { } void CloseImageIO::encode(bufferlist &bl) const { + using ceph::encode; action::Action action((action::CloseImageAction( ionum(), thread_id(), convert_dependencies(start_time(), dependencies()), m_imagectx))); - ::encode(action, bl); + encode(action, bl); } void CloseImageIO::write_debug(std::ostream& out) const { @@ -184,10 +194,11 @@ void CloseImageIO::write_debug(std::ostream& out) const { } void AioOpenImageIO::encode(bufferlist &bl) const { + using ceph::encode; action::Action action((action::AioOpenImageAction( ionum(), thread_id(), convert_dependencies(start_time(), dependencies()), m_imagectx, m_name, m_snap_name, m_readonly))); - ::encode(action, bl); + encode(action, bl); } void AioOpenImageIO::write_debug(std::ostream& out) const { @@ -196,10 +207,11 @@ void AioOpenImageIO::write_debug(std::ostream& out) const { } void AioCloseImageIO::encode(bufferlist &bl) const { + using ceph::encode; action::Action action((action::AioCloseImageAction( ionum(), thread_id(), convert_dependencies(start_time(), dependencies()), m_imagectx))); - ::encode(action, bl); + encode(action, bl); } void AioCloseImageIO::write_debug(std::ostream& out) const {