]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: create journal of specified size during mkfs
authorSage Weil <sage@newdream.net>
Wed, 27 May 2009 17:03:26 +0000 (10:03 -0700)
committerSage Weil <sage@newdream.net>
Wed, 27 May 2009 17:31:14 +0000 (10:31 -0700)
src/config.cc
src/config.h
src/os/FileJournal.cc
src/os/FileJournal.h
src/vstart.sh

index 75b365658a1f77550207bd26c6a2f5c440c48176..dfbdcc4e4471002b4a31f3f7a340e97780351fc1 100644 (file)
@@ -433,6 +433,7 @@ static struct config_option config_optionsp[] = {
        OPTION(mds_hack_log_expire_for_better_stats, 0, OPT_BOOL, false),
        OPTION(osd_data, 0, OPT_STR, ""),
        OPTION(osd_journal, 0, OPT_STR, ""),
+       OPTION(osd_journal_size, 0, OPT_INT, 0),         // in mb
        OPTION(osd_balance_reads, 0, OPT_BOOL, false),
        OPTION(osd_flash_crowd_iat_threshold, 0, OPT_INT, 0),
        OPTION(osd_flash_crowd_iat_alpha, 0, OPT_DOUBLE, 0.125),
index 6137352ded8c73cd4eb43549c074d4cd3ba1e0ff..cbe425f24d3fc7a75b9b1781539a899b52df5c82 100644 (file)
@@ -250,6 +250,7 @@ struct md_config_t {
   // osd
   const char *osd_data;
   const char *osd_journal;
+  int osd_journal_size;  // in mb
   bool osd_balance_reads;
   int osd_flash_crowd_iat_threshold;  // flash crowd interarrival time threshold in ms
   double osd_flash_crowd_iat_alpha;
index 4aa6bcacc4aaf9d02a6bcd9cf102e8d2b585b5d1..c832cc5e5a5a64c8ab76df05a3ba478cc7d5066e 100644 (file)
@@ -27,7 +27,7 @@
 #define dout_prefix *_dout << dbeginl << "journal "
 
 
-int FileJournal::_open(bool forwrite)
+int FileJournal::_open(bool forwrite, bool create)
 {
   int flags;
 
@@ -37,10 +37,12 @@ int FileJournal::_open(bool forwrite)
   } else {
     flags = O_RDONLY;
   }
+  if (create)
+    flags |= O_CREAT;
   
   if (fd >= 0) 
     ::close(fd);
-  fd = ::open(fn.c_str(), flags);
+  fd = ::open(fn.c_str(), flags, 0644);
   if (fd < 0) {
     dout(2) << "_open failed " << errno << " " << strerror(errno) << dendl;
     return -errno;
@@ -53,6 +55,14 @@ int FileJournal::_open(bool forwrite)
   max_size = st.st_size;
   block_size = st.st_blksize;
 
+  if (create && max_size < (g_conf.osd_journal_size << 20)) {
+    __u64 newsize = g_conf.osd_journal_size << 20;
+    dout(10) << "_open extending to " << newsize << " bytes" << dendl;
+    r = ::ftruncate(fd, newsize);
+    if (r == 0)
+      max_size = newsize;
+  }
+
   if (max_size == 0) {
     // hmm, is this a raw block device?
 #ifdef BLKGETSIZE64
@@ -82,7 +92,7 @@ int FileJournal::create()
 {
   dout(2) << "create " << fn << dendl;
 
-  int err = _open(true);
+  int err = _open(true, true);
   if (err < 0) return err;
 
   // write empty header
index 5f509b53a5858d63c3d80d113fcc99ecd87c51f2..ab64eeac4707fad085e3d9f474e372656b77e173 100644 (file)
@@ -101,7 +101,7 @@ private:
   Cond write_cond;
   bool write_stop;
 
-  int _open(bool wr);
+  int _open(bool wr, bool create=false);
   void print_header();
   void read_header();
   bufferptr prepare_header();
index 9a7cc11c8cb8a5086e992533d0d3b16bb7bb2c2f..5113953e5afeb2a5b47344bcc343e7373ea91b65 100755 (executable)
@@ -259,6 +259,8 @@ if [ "$start_osd" -eq 1 ]; then
            cat <<EOF >> $conf
 [osd$osd]
         osd data = dev/osd$osd
+        osd journal = dev/osd$osd/journal
+        osd journal size = 100
 EOF
            echo mkfs osd$osd
            echo $SUDO $CEPH_BIN/cosd -i $osd $ARGS --mkfs # --debug_journal 20 --debug_osd 20 --debug_filestore 20 --debug_ebofs 20