]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
filejournal: preallocate journal bytes on create
authorSage Weil <sage@newdream.net>
Fri, 16 Dec 2011 17:19:59 +0000 (09:19 -0800)
committerSage Weil <sage@newdream.net>
Fri, 16 Dec 2011 17:19:59 +0000 (09:19 -0800)
This should reduce fragmentation for large journals that are written
slowly the first time around.

Signed-off-by: Sage Weil <sage@newdream.net>
src/os/FileJournal.cc

index 6b9e47e740c6d3c5dbd2289c579a417cca2f7d9c..5e8b285b7c9ea87cd602406dd93b69096622bd70 100644 (file)
@@ -299,6 +299,13 @@ int FileJournal::_open_file(int64_t oldsize, blksize_t blksize,
           << newsize << " bytes: " << cpp_strerror(err) << dendl;
       return -err;
     }
+    ret = ::posix_fallocate(fd, 0, newsize);
+    if (ret < 0) {
+      int err = errno;
+      derr << "FileJournal::_open_file : unable to preallocation journal to "
+          << newsize << " bytes: " << cpp_strerror(err) << dendl;
+      return -err;
+    }
     max_size = newsize;
   }
   else {