]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
filejournal: add journal pre-allocate for osx 837/head
authorNoah Watkins <noahwatkins@gmail.com>
Sun, 10 Nov 2013 23:50:13 +0000 (15:50 -0800)
committerNoah Watkins <noahwatkins@gmail.com>
Sun, 10 Nov 2013 23:50:13 +0000 (15:50 -0800)
Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
configure.ac
src/os/FileJournal.cc

index 13d80856f00601e38f0ceeb6b2fcac2c3ee5c832..ccb48103a72eefdb3abd432b885bb8a01c72f3ee 100644 (file)
@@ -541,6 +541,7 @@ AC_CHECK_FUNC([fallocate],
 
 
 AC_CHECK_HEADERS([arpa/nameser_compat.h])
+AC_CHECK_FUNCS([posix_fallocate])
 AC_CHECK_HEADERS([sys/prctl.h])
 AC_CHECK_FUNCS([prctl])
 AC_CHECK_FUNCS([pipe2])
index 4a2af08dd4c0a2b03a9b42161ae08738808cc41b..9c2526cb573b2f2671fcf3c2f71d8b11884e7e77 100644 (file)
@@ -11,6 +11,7 @@
  * Foundation.  See file COPYING.
  * 
  */
+#include "acconfig.h"
 
 #include "common/debug.h"
 #include "common/errno.h"
@@ -298,6 +299,7 @@ int FileJournal::_open_file(int64_t oldsize, blksize_t blksize,
           << newsize << " bytes: " << cpp_strerror(err) << dendl;
       return -err;
     }
+#ifdef HAVE_POSIX_FALLOCATE
     ret = ::posix_fallocate(fd, 0, newsize);
     if (ret) {
       derr << "FileJournal::_open_file : unable to preallocation journal to "
@@ -305,6 +307,24 @@ int FileJournal::_open_file(int64_t oldsize, blksize_t blksize,
       return -ret;
     }
     max_size = newsize;
+#elif defined(__APPLE__)
+    fstore_t store;
+    store.fst_flags = F_ALLOCATECONTIG;
+    store.fst_posmode = F_PEOFPOSMODE;
+    store.fst_offset = 0;
+    store.fst_length = newsize;
+
+    ret = ::fcntl(fd, F_PREALLOCATE, &store);
+    if (ret == -1) {
+      ret = -errno;
+      derr << "FileJournal::_open_file : unable to preallocation journal to "
+          << newsize << " bytes: " << cpp_strerror(ret) << dendl;
+      return ret;
+    }
+    max_size = newsize;
+#else
+# error "Journal pre-allocation not supported on platform."
+#endif
   }
   else {
     max_size = oldsize;