]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Fix bug #487: osd: fix hang during mkfs
authorColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Thu, 14 Oct 2010 18:51:47 +0000 (11:51 -0700)
committerColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Thu, 14 Oct 2010 19:09:27 +0000 (12:09 -0700)
If the user has turned on journalling, but left osd_journal_size at 0,
normally we would use the existing size of the journal without
modifications. If the journal doesn't exist (i.e., we are running
mkjournal()), we have to check for this condition and return an error.
We can't create a journal if we don't know what size that journal needs
to be.

This fixes a bug where an extremely small journal file was being
created, leading to an infinite loop in FileJournal::wrap_read_bl().

Signed-off-by: Colin McCabe <colinm@hq.newdream.net>
src/os/FileJournal.cc
src/os/FileStore.cc

index a97d6305b6e68779524ff86fdf8c625b01418641..909345dd30e9b9d78f1ff2e1c5990578ddda5a60 100644 (file)
@@ -157,6 +157,12 @@ int FileJournal::create()
   char buf[80];
   dout(2) << "create " << fn << dendl;
 
+  if (g_conf.osd_journal_size == 0) {
+    dout(0) << "You must set a non-zero journal size in order to create a journal. "
+       "Set osd_journal_size." << dendl;
+    return -EINVAL;
+  }
+
   int err = _open(true, true);
   if (err < 0)
     return err;
index 7b6eb371f3814eabf88123355f7811a3e3dd9399..21ee83d6390313fb82a4564574be1ce6aaa99c31 100644 (file)
@@ -384,18 +384,19 @@ int FileStore::mkjournal()
   ::read(fd, &fsid, sizeof(fsid));
   ::close(fd);
 
+  int ret = 0;
+
   open_journal();
   if (journal) {
-    int err = journal->create();
-    if (err < 0) {
+    ret = journal->create();
+    if (ret)
       dout(0) << "mkjournal error creating journal on " << journalpath << dendl;
-    } else {
+    else
       dout(0) << "mkjournal created journal on " << journalpath << dendl;
-    }
     delete journal;
     journal = 0;
   }
-  return 0;
+  return ret;
 }