]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: humanize ImageWatcher and Journal states in debug log
authorMykola Golub <mgolub@mirantis.com>
Tue, 15 Sep 2015 08:58:03 +0000 (11:58 +0300)
committerMykola Golub <mgolub@mirantis.com>
Fri, 4 Dec 2015 11:15:02 +0000 (13:15 +0200)
Signed-off-by: Mykola Golub <mgolub@mirantis.com>
src/librbd/ImageWatcher.cc
src/librbd/ImageWatcher.h
src/librbd/Journal.cc
src/librbd/Journal.h

index 6284ef9be312b1be43bc8ff5ac8e5f3f68fad603..f06856e22014f0eb06450bedb8461c3b5c6ff21b 100644 (file)
@@ -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<uint32_t>(state) << ")";
+    break;
+  }
+  return os;
+}
index 7395567ef716c388be2c65e65835995cca49d03f..829324a5abde4e075d46c5c756571deb123fce14 100644 (file)
@@ -332,4 +332,7 @@ private:
 
 } // namespace librbd
 
+std::ostream &operator<<(std::ostream &os,
+                        const librbd::ImageWatcher::LockUpdateState &state);
+
 #endif // CEPH_LIBRBD_IMAGE_WATCHER_H
index f38bb86af3f07dcf9a4feea6831f4118bf14a923..e60f2a11bf1334ea157e5fd519f7c87e07460f66 100644 (file)
@@ -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<uint32_t>(state) << ")";
+    break;
+  }
+  return os;
+}
+
 } // namespace librbd
index d694cf41810063393e0eeae0bb29c8fe3e94ed96..eb01e4c1ccc6c5b3490b3c6911dbe6758f864427 100644 (file)
@@ -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