]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-osd: add --check-wants-journal, --check-allows-journal
authorSage Weil <sage@redhat.com>
Tue, 31 Mar 2015 20:49:35 +0000 (13:49 -0700)
committerSage Weil <sage@redhat.com>
Tue, 31 Mar 2015 20:49:35 +0000 (13:49 -0700)
Completes OSD side of #9580

Signed-off-by: Sage Weil <sage@redhat.com>
src/ceph_osd.cc
src/os/FileStore.h
src/os/KeyValueStore.h
src/os/MemStore.h
src/os/ObjectStore.h

index a589ee7356d1f78d5f4fd257f43eaf7bdb75d97f..d893aebd052a04bde13fe1c98e79e5f39c6aaa38 100644 (file)
@@ -70,6 +70,12 @@ void usage()
        << "                    run any pending upgrade operations\n"
        << "  --flush-journal   flush all data out of journal\n"
        << "  --mkjournal       initialize a new journal\n"
+       << "  --check-wants-journal\n"
+       << "                    check whether a journal is desired\n"
+       << "  --check-allows-journal\n"
+       << "                    check whether a journal is allowed\n"
+       << "  --check-needs-journal\n"
+       << "                    check whether a journal is required\n"
        << "  --debug_osd N     set debug level (e.g. 10)"
        << std::endl;
   generic_server_usage();
@@ -108,6 +114,9 @@ int main(int argc, const char **argv)
   // osd specific args
   bool mkfs = false;
   bool mkjournal = false;
+  bool check_wants_journal = false;
+  bool check_allows_journal = false;
+  bool check_needs_journal = false;
   bool mkkey = false;
   bool flushjournal = false;
   bool dump_journal = false;
@@ -115,7 +124,6 @@ int main(int argc, const char **argv)
   bool get_journal_fsid = false;
   bool get_osd_fsid = false;
   bool get_cluster_fsid = false;
-  bool check_need_journal = false;
   std::string dump_pg_log;
 
   std::string val;
@@ -129,6 +137,12 @@ int main(int argc, const char **argv)
       mkfs = true;
     } else if (ceph_argparse_flag(args, i, "--mkjournal", (char*)NULL)) {
       mkjournal = true;
+    } else if (ceph_argparse_flag(args, i, "--check-allows-journal", (char*)NULL)) {
+      check_allows_journal = true;
+    } else if (ceph_argparse_flag(args, i, "--check-wants-journal", (char*)NULL)) {
+      check_wants_journal = true;
+    } else if (ceph_argparse_flag(args, i, "--check-needs-journal", (char*)NULL)) {
+      check_needs_journal = true;
     } else if (ceph_argparse_flag(args, i, "--mkkey", (char*)NULL)) {
       mkkey = true;
     } else if (ceph_argparse_flag(args, i, "--flush-journal", (char*)NULL)) {
@@ -145,8 +159,6 @@ int main(int argc, const char **argv)
       get_osd_fsid = true;
     } else if (ceph_argparse_flag(args, i, "--get-journal-fsid", "--get-journal-uuid", (char*)NULL)) {
       get_journal_fsid = true;
-    } else if (ceph_argparse_flag(args, i, "--check-needs-journal", (char*)NULL)) {
-      check_need_journal = true;
     } else {
       ++i;
     }
@@ -268,6 +280,33 @@ int main(int argc, const char **argv)
         << " for object store " << g_conf->osd_data << dendl;
     exit(0);
   }
+  if (check_wants_journal) {
+    if (store->wants_journal()) {
+      cout << "yes" << std::endl;
+      exit(0);
+    } else {
+      cout << "no" << std::endl;
+      exit(1);
+    }
+  }
+  if (check_allows_journal) {
+    if (store->allows_journal()) {
+      cout << "yes" << std::endl;
+      exit(0);
+    } else {
+      cout << "no" << std::endl;
+      exit(1);
+    }
+  }
+  if (check_needs_journal) {
+    if (store->needs_journal()) {
+      cout << "yes" << std::endl;
+      exit(0);
+    } else {
+      cout << "no" << std::endl;
+      exit(1);
+    }
+  }
   if (flushjournal) {
     common_init_finish(g_ceph_context);
     int err = store->mount();
@@ -326,14 +365,6 @@ int main(int argc, const char **argv)
     exit(r);
   }
 
-  if (check_need_journal) {
-    if (store->need_journal())
-      cout << "yes" << std::endl;
-    else
-      cout << "no" << std::endl;
-    exit(0);
-  }
-
   string magic;
   uuid_d cluster_fsid, osd_fsid;
   int w;
index bdd6761cf77db8146cd4318ea01b8221ad9b0431..4f6a69f1af1f359509babb7b610bf0499903fb6d 100644 (file)
@@ -96,7 +96,6 @@ public:
     return target_version;
   }
 
-  bool need_journal() { return true; }
   int peek_journal_fsid(uuid_d *fsid);
 
   struct FSPerfTracker {
@@ -423,6 +422,15 @@ public:
   }
   int mkfs();
   int mkjournal();
+  bool wants_journal() {
+    return true;
+  }
+  bool allows_journal() {
+    return true;
+  }
+  bool needs_journal() {
+    return false;
+  }
 
   int write_version_stamp();
   int version_stamp_is_valid(uint32_t *version);
index ef3085fa0d95b094383ef73eb3e88ece41c4cffc..376a37097ce39d029424edff98e84b669eeb6d1e 100644 (file)
@@ -484,7 +484,6 @@ class KeyValueStore : public ObjectStore,
   uint32_t get_target_version() {
     return target_version;
   }
-  bool need_journal() { return false; };
   int peek_journal_fsid(uuid_d *id) {
     *id = fsid;
     return 0;
@@ -501,6 +500,15 @@ class KeyValueStore : public ObjectStore,
   }
   int mkfs();
   int mkjournal() {return 0;}
+  bool wants_journal() {
+    return false;
+  }
+  bool allows_journal() {
+    return false;
+  }
+  bool needs_journal() {
+    return false;
+  }
 
   /**
    ** set_allow_sharded_objects()
index 4459a6a267401e1397b754d8107a16e4c15c2c61..d6cb51a866483f0156db0596ba18ff172b4a6a20 100644 (file)
@@ -245,7 +245,6 @@ public:
       sharded(false) {}
   ~MemStore() { }
 
-  bool need_journal() { return false; };
   int peek_journal_fsid(uuid_d *fsid);
 
   bool test_mount_in_use() {
@@ -266,6 +265,15 @@ public:
   int mkjournal() {
     return 0;
   }
+  bool wants_journal() {
+    return false;
+  }
+  bool allows_journal() {
+    return false;
+  }
+  bool needs_journal() {
+    return false;
+  }
 
   bool sharded;
   void set_allow_sharded_objects() {
index dd703743dcd4f523aa1c5c5bf9a2423fa4d18798..5fbc869785ef8ccfc222f53264a30049063ea814 100644 (file)
@@ -1761,6 +1761,9 @@ public:
   virtual unsigned get_max_attr_name_length() = 0;
   virtual int mkfs() = 0;  // wipe
   virtual int mkjournal() = 0; // journal only
+  virtual bool needs_journal() = 0;  //< requires a journal
+  virtual bool wants_journal() = 0;  //< prefers a journal
+  virtual bool allows_journal() = 0; //< allows a journal
   virtual void set_allow_sharded_objects() = 0;
   virtual bool get_allow_sharded_objects() = 0;
 
@@ -1768,14 +1771,6 @@ public:
 
   virtual void collect_metadata(map<string,string> *pm) { }
 
-  /**
-   * check whether need journal device
-   *
-   * It's not constant for backend store. FileStore could have journaless mode
-   * and KeyValueStore could have journal device for special backend.
-   */
-  virtual bool need_journal() = 0;
-
   /**
    * check the journal uuid/fsid, without opening
    */