X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fceph%2Fsrc%2Frbd_replay%2Fios.cc;fp=src%2Fceph%2Fsrc%2Frbd_replay%2Fios.cc;h=0000000000000000000000000000000000000000;hb=7da45d65be36d36b880cc55c5036e96c24b53f00;hp=db8470e9cf424100b8997d14ce0568a48d26bc8e;hpb=691462d09d0987b47e112d6ee8740375df3c51b2;p=stor4nfv.git diff --git a/src/ceph/src/rbd_replay/ios.cc b/src/ceph/src/rbd_replay/ios.cc deleted file mode 100644 index db8470e..0000000 --- a/src/ceph/src/rbd_replay/ios.cc +++ /dev/null @@ -1,208 +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) 2014 Adam Crume - * - * 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. - * - */ - -// This code assumes that IO IDs and timestamps are related monotonically. -// In other words, (a.id < b.id) == (a.timestamp < b.timestamp) for all IOs a and b. - -#include "ios.hpp" -#include "rbd_replay/ActionTypes.h" - -using namespace std; -using namespace rbd_replay; - -namespace { - -bool compare_dependencies_by_start_time(const action::Dependency &lhs, - const action::Dependency &rhs) { - return lhs.time_delta < rhs.time_delta; -} - -action::Dependencies convert_dependencies(uint64_t start_time, - const io_set_t &deps) { - action::Dependencies action_deps; - action_deps.reserve(deps.size()); - for (io_set_t::const_iterator it = deps.begin(); it != deps.end(); ++it) { - boost::shared_ptr io = *it; - uint64_t time_delta = 0; - if (start_time >= io->start_time()) { - time_delta = start_time - io->start_time(); - } - action_deps.push_back(action::Dependency(io->ionum(), time_delta)); - } - std::sort(action_deps.begin(), action_deps.end(), - compare_dependencies_by_start_time); - return action_deps; -} - -} // anonymous namespace - -void IO::write_debug_base(ostream& out, string type) const { - out << m_ionum << ": " << m_start_time / 1000000.0 << ": " << type << ", thread = " << m_thread_id << ", deps = {"; - bool first = true; - for (io_set_t::iterator itr = m_dependencies.begin(), end = m_dependencies.end(); itr != end; ++itr) { - if (first) { - first = false; - } else { - out << ", "; - } - out << (*itr)->m_ionum << ": " << m_start_time - (*itr)->m_start_time; - } - out << "}"; -} - - -ostream& operator<<(ostream &out, const IO::ptr &io) { - io->write_debug(out); - return out; -} - -void StartThreadIO::encode(bufferlist &bl) const { - action::Action action((action::StartThreadAction( - ionum(), thread_id(), convert_dependencies(start_time(), dependencies())))); - ::encode(action, bl); -} - -void StartThreadIO::write_debug(std::ostream& out) const { - write_debug_base(out, "start thread"); -} - -void StopThreadIO::encode(bufferlist &bl) const { - action::Action action((action::StopThreadAction( - ionum(), thread_id(), convert_dependencies(start_time(), dependencies())))); - ::encode(action, bl); -} - -void StopThreadIO::write_debug(std::ostream& out) const { - write_debug_base(out, "stop thread"); -} - -void ReadIO::encode(bufferlist &bl) const { - action::Action action((action::ReadAction( - ionum(), thread_id(), convert_dependencies(start_time(), dependencies()), - m_imagectx, m_offset, m_length))); - ::encode(action, bl); -} - -void ReadIO::write_debug(std::ostream& out) const { - write_debug_base(out, "read"); - out << ", imagectx=" << m_imagectx << ", offset=" << m_offset << ", length=" << m_length << "]"; -} - -void WriteIO::encode(bufferlist &bl) const { - action::Action action((action::WriteAction( - ionum(), thread_id(), convert_dependencies(start_time(), dependencies()), - m_imagectx, m_offset, m_length))); - ::encode(action, bl); -} - -void WriteIO::write_debug(std::ostream& out) const { - write_debug_base(out, "write"); - out << ", imagectx=" << m_imagectx << ", offset=" << m_offset << ", length=" << m_length << "]"; -} - -void DiscardIO::encode(bufferlist &bl) const { - action::Action action((action::DiscardAction( - ionum(), thread_id(), convert_dependencies(start_time(), dependencies()), - m_imagectx, m_offset, m_length))); - ::encode(action, bl); -} - -void DiscardIO::write_debug(std::ostream& out) const { - write_debug_base(out, "discard"); - out << ", imagectx=" << m_imagectx << ", offset=" << m_offset << ", length=" << m_length << "]"; -} - -void AioReadIO::encode(bufferlist &bl) const { - action::Action action((action::AioReadAction( - ionum(), thread_id(), convert_dependencies(start_time(), dependencies()), - m_imagectx, m_offset, m_length))); - ::encode(action, bl); -} - -void AioReadIO::write_debug(std::ostream& out) const { - write_debug_base(out, "aio read"); - out << ", imagectx=" << m_imagectx << ", offset=" << m_offset << ", length=" << m_length << "]"; -} - -void AioWriteIO::encode(bufferlist &bl) const { - action::Action action((action::AioWriteAction( - ionum(), thread_id(), convert_dependencies(start_time(), dependencies()), - m_imagectx, m_offset, m_length))); - ::encode(action, bl); -} - -void AioWriteIO::write_debug(std::ostream& out) const { - write_debug_base(out, "aio write"); - out << ", imagectx=" << m_imagectx << ", offset=" << m_offset << ", length=" << m_length << "]"; -} - -void AioDiscardIO::encode(bufferlist &bl) const { - action::Action action((action::AioDiscardAction( - ionum(), thread_id(), convert_dependencies(start_time(), dependencies()), - m_imagectx, m_offset, m_length))); - ::encode(action, bl); -} - -void AioDiscardIO::write_debug(std::ostream& out) const { - write_debug_base(out, "aio discard"); - out << ", imagectx=" << m_imagectx << ", offset=" << m_offset << ", length=" << m_length << "]"; -} - -void OpenImageIO::encode(bufferlist &bl) const { - 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); -} - -void OpenImageIO::write_debug(std::ostream& out) const { - write_debug_base(out, "open image"); - out << ", imagectx=" << m_imagectx << ", name='" << m_name << "', snap_name='" << m_snap_name << "', readonly=" << m_readonly; -} - -void CloseImageIO::encode(bufferlist &bl) const { - action::Action action((action::CloseImageAction( - ionum(), thread_id(), convert_dependencies(start_time(), dependencies()), - m_imagectx))); - ::encode(action, bl); -} - -void CloseImageIO::write_debug(std::ostream& out) const { - write_debug_base(out, "close image"); - out << ", imagectx=" << m_imagectx; -} - -void AioOpenImageIO::encode(bufferlist &bl) const { - 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); -} - -void AioOpenImageIO::write_debug(std::ostream& out) const { - write_debug_base(out, "aio open image"); - out << ", imagectx=" << m_imagectx << ", name='" << m_name << "', snap_name='" << m_snap_name << "', readonly=" << m_readonly; -} - -void AioCloseImageIO::encode(bufferlist &bl) const { - action::Action action((action::AioCloseImageAction( - ionum(), thread_id(), convert_dependencies(start_time(), dependencies()), - m_imagectx))); - ::encode(action, bl); -} - -void AioCloseImageIO::write_debug(std::ostream& out) const { - write_debug_base(out, "aio close image"); - out << ", imagectx=" << m_imagectx; -}