]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os: Add optional flags to generic ObjectStore creation (SKIP_JOURNAL_REPLAY
authorDavid Zafman <david.zafman@inktank.com>
Wed, 14 May 2014 22:41:15 +0000 (15:41 -0700)
committerDavid Zafman <dzafman@redhat.com>
Thu, 28 Aug 2014 23:21:27 +0000 (16:21 -0700)
and SKIP_MOUNT_OMAP)

Only FileStore cares about these flags, so passed on during create()

Signed-off-by: David Zafman <david.zafman@inktank.com>
src/os/FileStore.cc
src/os/FileStore.h
src/os/JournalingObjectStore.cc
src/os/JournalingObjectStore.h
src/os/ObjectStore.cc
src/os/ObjectStore.h
src/test/objectstore/test_idempotent_sequence.cc

index 805b57990675eacfd16a0e0149d2103d6c662854..4e7c1a32f2413a6a2dfc77cf2be2a98875ee1081 100644 (file)
@@ -492,10 +492,11 @@ int FileStore::lfn_unlink(coll_t cid, const ghobject_t& o,
   return index->unlink(o);
 }
 
-FileStore::FileStore(const std::string &base, const std::string &jdev, const char *name, bool do_update) :
+FileStore::FileStore(const std::string &base, const std::string &jdev, osflagbits_t flags, const char *name, bool do_update) :
   JournalingObjectStore(base),
   internal_name(name),
   basedir(base), journalpath(jdev),
+  generic_flags(flags),
   blk_size(0),
   fsid_fd(-1), op_fd(-1),
   basedir_fd(-1), current_fd(-1),
@@ -1196,7 +1197,7 @@ int FileStore::write_op_seq(int fd, uint64_t seq)
   return ret;
 }
 
-int FileStore::mount() 
+int FileStore::mount()
 {
   int ret;
   char buf[PATH_MAX];
@@ -1424,7 +1425,7 @@ int FileStore::mount()
     ::unlink(nosnapfn);
   }
 
-  {
+  if (!(generic_flags & SKIP_MOUNT_OMAP)) {
     KeyValueDB * omap_store = KeyValueDB::create(g_ceph_context,
                                                 superblock.omap_backend,
                                                 omap_dir);
@@ -1528,24 +1529,26 @@ int FileStore::mount()
   wbthrottle.start();
   sync_thread.create();
 
-  ret = journal_replay(initial_op_seq);
-  if (ret < 0) {
-    derr << "mount failed to open journal " << journalpath << ": " << cpp_strerror(ret) << dendl;
-    if (ret == -ENOTTY) {
-      derr << "maybe journal is not pointing to a block device and its size "
-          << "wasn't configured?" << dendl;
-    }
+  if (!(generic_flags & SKIP_JOURNAL_REPLAY)) {
+    ret = journal_replay(initial_op_seq);
+    if (ret < 0) {
+      derr << "mount failed to open journal " << journalpath << ": " << cpp_strerror(ret) << dendl;
+      if (ret == -ENOTTY) {
+        derr << "maybe journal is not pointing to a block device and its size "
+            << "wasn't configured?" << dendl;
+      }
 
-    // stop sync thread
-    lock.Lock();
-    stop = true;
-    sync_cond.Signal();
-    lock.Unlock();
-    sync_thread.join();
+      // stop sync thread
+      lock.Lock();
+      stop = true;
+      sync_cond.Signal();
+      lock.Unlock();
+      sync_thread.join();
 
-    wbthrottle.stop();
+      wbthrottle.stop();
 
-    goto close_current_fd;
+      goto close_current_fd;
+    }
   }
 
   {
@@ -1597,6 +1600,8 @@ int FileStore::umount()
   op_tp.stop();
 
   journal_stop();
+  if (!(generic_flags & SKIP_JOURNAL_REPLAY))
+    journal_write_close();
 
   op_finisher.stop();
   ondisk_finisher.stop();
index f18b238393bf71de9363cff9aafc981d3d72afbf..f6ed7bb4b713009799c0277de58810c42f8bb2d2 100644 (file)
@@ -119,6 +119,7 @@ public:
 private:
   string internal_name;         ///< internal name, used to name the perfcounter instance
   string basedir, journalpath;
+  osflagbits_t generic_flags;
   std::string current_fn;
   std::string current_op_seq_fn;
   std::string omap_dir;
@@ -399,7 +400,9 @@ public:
                 bool force_clear_omap=false);
 
 public:
-  FileStore(const std::string &base, const std::string &jdev, const char *internal_name = "filestore", bool update_to=false);
+  FileStore(const std::string &base, const std::string &jdev,
+    osflagbits_t flags = 0,
+    const char *internal_name = "filestore", bool update_to=false);
   ~FileStore();
 
   int _detect_fs();
index 490a014c5d182a3604d47627b6ce3b21004a2728..518d54edf6621ee2ef274499f664f3c865dbff7b 100644 (file)
@@ -21,6 +21,11 @@ void JournalingObjectStore::journal_stop()
 {
   dout(10) << "journal_stop" << dendl;
   finisher.stop();
+}
+
+// A journal_replay() makes journal writeable, this closes that out.
+void JournalingObjectStore::journal_write_close()
+{
   if (journal) {
     journal->close();
     delete journal;
index fb7f0eca6d78bb85d3d4c69b1bb7b28d68f59665..6a09c6133de90eb9d8b6dc11b930cac21d3e993e 100644 (file)
@@ -111,6 +111,7 @@ protected:
 protected:
   void journal_start();
   void journal_stop();
+  void journal_write_close();
   int journal_replay(uint64_t fs_op_seq);
 
   void _op_journal_transactions(list<ObjectStore::Transaction*>& tls, uint64_t op,
index 5a7d2175d3af05fa5605b2064d87b7e4a654c268..f9f6e1142478f029119d667db7e309a44f919fed 100644 (file)
 ObjectStore *ObjectStore::create(CephContext *cct,
                                 const string& type,
                                 const string& data,
-                                const string& journal)
+                                const string& journal,
+                                osflagbits_t flags)
 {
   if (type == "filestore") {
-    return new FileStore(data, journal);
+    return new FileStore(data, journal, flags);
   }
   if (type == "memstore") {
     return new MemStore(cct, data);
index b2d3f2ccb38600e5a9d455f84143c5c326481170..20f925bc66beff317155f91b5263f108a3c95ccf 100644 (file)
@@ -80,6 +80,11 @@ static inline void encode(const map<string,bufferptr> *attrset, bufferlist &bl)
   ::encode(*attrset, bl);
 }
 
+// Flag bits
+typedef uint32_t osflagbits_t;
+const int SKIP_JOURNAL_REPLAY = 1 << 0;
+const int SKIP_MOUNT_OMAP = 1 << 1;
+
 class ObjectStore {
 protected:
   string path;
@@ -93,11 +98,13 @@ public:
    * @param type type of store. This is a string from the configuration file.
    * @param data path (or other descriptor) for data
    * @param journal path (or other descriptor) for journal (optional)
+   * @param flags which filestores should check if applicable
    */
   static ObjectStore *create(CephContext *cct,
                             const string& type,
                             const string& data,
-                            const string& journal);
+                            const string& journal,
+                            osflagbits_t flag = 0);
 
   Logger *logger;
 
index 3ef2c79987d8134fc981b1cc0b2c79aecfa7527f..df502f8bfa13b86dad2cd004920d54206227c6b0 100644 (file)
@@ -79,8 +79,8 @@ std::string status_file;
 int run_diff(std::string& a_path, std::string& a_journal,
              std::string& b_path, std::string& b_journal)
 {
-  FileStore *a = new FileStore(a_path, a_journal, "a");
-  FileStore *b = new FileStore(b_path, b_journal, "b");
+  FileStore *a = new FileStore(a_path, a_journal, 0, "a");
+  FileStore *b = new FileStore(b_path, b_journal, 0, "b");
 
   int ret = 0;
   {