From: Mykola Golub Date: Tue, 15 Sep 2015 08:58:03 +0000 (+0300) Subject: librbd: humanize ImageWatcher and Journal states in debug log X-Git-Tag: v10.0.2~100^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7311185ace7f3a1067cd2ebd34c9a5dd64c3d54a;p=ceph.git librbd: humanize ImageWatcher and Journal states in debug log Signed-off-by: Mykola Golub --- diff --git a/src/librbd/ImageWatcher.cc b/src/librbd/ImageWatcher.cc index 6284ef9be312..f06856e22014 100644 --- a/src/librbd/ImageWatcher.cc +++ b/src/librbd/ImageWatcher.cc @@ -1321,3 +1321,27 @@ void ImageWatcher::C_ResponseMessage::finish(int r) { } // namespace librbd +std::ostream &operator<<(std::ostream &os, + const librbd::ImageWatcher::LockUpdateState &state) { + switch (state) { + case librbd::ImageWatcher::LOCK_UPDATE_STATE_NOT_SUPPORTED: + os << "NotSupported"; + break; + case librbd::ImageWatcher::LOCK_UPDATE_STATE_LOCKED: + os << "Locked"; + break; + case librbd::ImageWatcher::LOCK_UPDATE_STATE_RELEASING: + os << "Releasing"; + break; + case librbd::ImageWatcher::LOCK_UPDATE_STATE_UNLOCKED: + os << "Unlocked"; + break; + case librbd::ImageWatcher::LOCK_UPDATE_STATE_NOTIFICATION: + os << "Notification"; + break; + default: + os << "Unknown (" << static_cast(state) << ")"; + break; + } + return os; +} diff --git a/src/librbd/ImageWatcher.h b/src/librbd/ImageWatcher.h index 7395567ef716..829324a5abde 100644 --- a/src/librbd/ImageWatcher.h +++ b/src/librbd/ImageWatcher.h @@ -332,4 +332,7 @@ private: } // namespace librbd +std::ostream &operator<<(std::ostream &os, + const librbd::ImageWatcher::LockUpdateState &state); + #endif // CEPH_LIBRBD_IMAGE_WATCHER_H diff --git a/src/librbd/Journal.cc b/src/librbd/Journal.cc index f38bb86af3f0..e60f2a11bf13 100644 --- a/src/librbd/Journal.cc +++ b/src/librbd/Journal.cc @@ -757,4 +757,28 @@ void Journal::handle_wait_for_ready(Context *on_ready) { } } +std::ostream &operator<<(std::ostream &os, const Journal::State &state) { + switch (state) { + case Journal::STATE_UNINITIALIZED: + os << "Uninitialized"; + break; + case Journal::STATE_INITIALIZING: + os << "Initializing"; + break; + case Journal::STATE_REPLAYING: + os << "Replaying"; + break; + case Journal::STATE_RECORDING: + os << "Recording"; + break; + case Journal::STATE_STOPPING_RECORDING: + os << "StoppingRecording"; + break; + default: + os << "Unknown (" << static_cast(state) << ")"; + break; + } + return os; +} + } // namespace librbd diff --git a/src/librbd/Journal.h b/src/librbd/Journal.h index d694cf418100..eb01e4c1ccc6 100644 --- a/src/librbd/Journal.h +++ b/src/librbd/Journal.h @@ -223,6 +223,8 @@ private: void wait_for_state_transition(); void schedule_wait_for_ready(Context *on_ready); void handle_wait_for_ready(Context *on_ready); + + friend std::ostream &operator<<(std::ostream &os, const State &state); }; } // namespace librbd