]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: allow reinitialization of osd journal
authorSage Weil <sage@newdream.net>
Wed, 18 Nov 2009 18:49:38 +0000 (10:49 -0800)
committerSage Weil <sage@newdream.net>
Wed, 18 Nov 2009 18:58:09 +0000 (10:58 -0800)
(without hosing osd data)

src/cosd.cc
src/os/FileStore.cc
src/os/FileStore.h
src/os/ObjectStore.h
src/osd/OSD.cc
src/osd/OSD.h

index 4336a676474d9442a4ac75eb363589135a8cdc7e..aa34cf3f4a9eab689ac8bb09b584759419630ecf 100644 (file)
@@ -37,7 +37,7 @@ using namespace std;
 
 void usage() 
 {
-  cerr << "usage: cosd -i osdid [--osd-data=path] [--osd-journal=path] [--mkfs]" << std::endl;
+  cerr << "usage: cosd -i osdid [--osd-data=path] [--osd-journal=path] [--mkfs] [--mkjournal]" << std::endl;
   cerr << "   --debug_osd N   set debug level (e.g. 10)" << std::endl;
   generic_server_usage();
 }
@@ -54,10 +54,13 @@ int main(int argc, const char **argv)
   if (g_conf.clock_tare) g_clock.tare();
 
   // osd specific args
-  bool mkfs = 0;
+  bool mkfs = false;
+  bool mkjournal = false;
   FOR_EACH_ARG(args) {
     if (CONF_ARG_EQ("mkfs", '\0')) {
-      mkfs = 1; 
+      mkfs = true;
+    } else if (CONF_ARG_EQ("mkjournal", '\0')) {
+      mkjournal = true;
     } else {
       cerr << "unrecognized arg " << args[i] << std::endl;
       ARGS_USAGE();
@@ -151,7 +154,7 @@ int main(int argc, const char **argv)
   rank.start();
 
   // start osd
-  OSD *osd = new OSD(whoami, m, hbm, &mc, g_conf.osd_data, g_conf.osd_journal);
+  OSD *osd = new OSD(whoami, m, hbm, &mc, g_conf.osd_data, g_conf.osd_journal, mkjournal);
   if (osd->init() < 0) {
     cout << "error initializing osd" << std::endl;
     return 1;
index 464f454e5a18a736cc3fd7c72b14cae6af9fa853..91fa7dcbe3dca9cdb12bb392d98b8f7cc6b7d84c 100644 (file)
@@ -328,18 +328,9 @@ int FileStore::mkfs()
   dout(10) << "mkfs fsid is " << fsid << dendl;
 
   // journal?
-  open_journal();
-  if (journal) {
-    if (journal->create() < 0) {
-      dout(0) << "mkfs error creating journal on " << fn << dendl;
-    } else {
-      dout(0) << "mkfs created journal on " << fn << dendl;
-    }
-    delete journal;
-    journal = 0;
-  } else {
-    dout(10) << "mkfs no journal at " << fn << dendl;
-  }
+  int err = mkjournal();
+  if (err)
+    return err;
 
   if (g_conf.filestore_dev) {
     char cmd[PATH_MAX];
@@ -349,10 +340,31 @@ int FileStore::mkfs()
   }
 
   dout(1) << "mkfs done in " << basedir << dendl;
-
   return 0;
 }
 
+int FileStore::mkjournal()
+{
+  int err;
+
+  open_journal();
+  if (journal) {
+    err = journal->create();
+    if (err < 0) {
+      dout(0) << "mkjournal error creating journal on " << journalpath << dendl;
+    } else {
+      dout(0) << "mkjournal created journal on " << journalpath << dendl;
+    }
+    delete journal;
+    journal = 0;
+  } else {
+    err = -ENOENT;
+    dout(10) << "mkjournal no journal at " << journalpath << dendl;
+  }
+  return err;
+}
+
+
 Mutex sig_lock("FileStore.cc sig_lock");
 Cond sig_cond;
 bool sig_installed = false;
index f7dfc99846e808ccb9131456c859d81ab895afe5..53a82b411ed04c0050445d7a121be57e2f697198 100644 (file)
@@ -109,6 +109,7 @@ class FileStore : public JournalingObjectStore {
   int mount();
   int umount();
   int mkfs();
+  int mkjournal();
 
   int statfs(struct statfs *buf);
 
index adbd025553fb1af1ef7dbb932b411b9cb2ab5e5e..26bd74e70f1a87bf2ae7eb3f1a28bb21991da5db 100644 (file)
@@ -429,6 +429,7 @@ public:
   virtual int mount() = 0;
   virtual int umount() = 0;
   virtual int mkfs() = 0;  // wipe
+  virtual int mkjournal() = 0; // journal only
 
   virtual int statfs(struct statfs *buf) = 0;
 
index a8fed43913034eae456b47238ca7ff071c4a155e..7284ed6f7a7084f950390d6126c8dc9d4e818484 100644 (file)
@@ -220,7 +220,7 @@ int OSD::peek_super(const char *dev, nstring& magic, ceph_fsid_t& fsid, int& who
 
 // cons/des
 
-OSD::OSD(int id, Messenger *m, Messenger *hbm, MonClient *mc, const char *dev, const char *jdev) : 
+OSD::OSD(int id, Messenger *m, Messenger *hbm, MonClient *mc, const char *dev, const char *jdev, bool newjournal) : 
   osd_lock("OSD::osd_lock"),
   timer(osd_lock),
   messenger(m),
@@ -265,6 +265,7 @@ OSD::OSD(int id, Messenger *m, Messenger *hbm, MonClient *mc, const char *dev, c
 {
   monc->set_messenger(messenger);
   
+  mknewjournal = newjournal;
   osdmap = 0;
 
   memset(&my_stat, 0, sizeof(my_stat));
@@ -317,10 +318,19 @@ int OSD::init()
     dout(0) << " unable to create object store" << dendl;
     return -ENODEV;
   }
+
+  if (mknewjournal) {
+    int r = store->mkjournal();
+    if (r < 0) {
+      dout(0) << " unable to create new jouranl" << dendl;
+      return r;
+    }
+  }
+
   int r = store->mount();
   if (r < 0) {
     dout(0) << " unable to mount object store" << dendl;
-    return -1;
+    return r;
   }
   
   dout(2) << "boot" << dendl;
index ee8e633aa6c8898744bf4da762ec02aa2b5c49bb..5d662cb1fdc4c87b1ce494e9b2be79b60aee4aed 100644 (file)
@@ -103,6 +103,7 @@ protected:
 
   int whoami;
   const char *dev_path, *journal_path;
+  bool mknewjournal;
 
   class C_Tick : public Context {
     OSD *osd;
@@ -820,7 +821,7 @@ protected:
   void ms_handle_remote_reset(Connection *con) {}
 
  public:
-  OSD(int id, Messenger *m, Messenger *hbm, MonClient *mc, const char *dev = 0, const char *jdev = 0);
+  OSD(int id, Messenger *m, Messenger *hbm, MonClient *mc, const char *dev = 0, const char *jdev = 0, bool newjournal=false);
   ~OSD();
 
   // static bits