]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
journal: helper method to determine if journal exists
authorJason Dillaman <dillaman@redhat.com>
Mon, 30 Nov 2015 17:31:02 +0000 (12:31 -0500)
committerJason Dillaman <dillaman@redhat.com>
Mon, 30 Nov 2015 17:31:02 +0000 (12:31 -0500)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/journal/Journaler.cc
src/journal/Journaler.h

index 83862fc8221081550a0a2659d39d0f38ac65e6d0..3957f8f152b3c1f77a39fb959fcd8e642983ad54 100644 (file)
@@ -69,6 +69,16 @@ Journaler::~Journaler() {
   assert(m_recorder == NULL);
 }
 
+int Journaler::exists(bool *header_exists) const {
+  int r = m_header_ioctx.stat(m_header_oid, NULL, NULL);
+  if (r < 0 && r != -ENOENT) {
+    return r;
+  }
+
+  *header_exists = (r == 0);
+  return 0;
+}
+
 void Journaler::init(Context *on_init) {
   m_metadata->init(new C_InitJournaler(this, on_init));
 }
index d35821891402e829202c156a66cf46a9fa675aa3..1230e409b2df5f6ef296b343229044e4f7f51430 100644 (file)
@@ -30,6 +30,7 @@ public:
            const std::string &client_id, double commit_interval);
   ~Journaler();
 
+  int exists(bool *header_exists) const;
   int create(uint8_t order, uint8_t splay_width, int64_t pool_id);
   int remove();
 
@@ -66,7 +67,7 @@ private:
     }
   };
 
-  librados::IoCtx m_header_ioctx;
+  mutable librados::IoCtx m_header_ioctx;
   librados::IoCtx m_data_ioctx;
   CephContext *m_cct;
   std::string m_client_id;