]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
common/config_opt: add bool option: bluestore_block_preallocate_file. 8482/head
authorJianpeng Ma <jianpeng.ma@intel.com>
Sat, 7 May 2016 10:49:53 +0000 (18:49 +0800)
committerJianpeng Ma <jianpeng.ma@intel.com>
Sat, 7 May 2016 10:49:53 +0000 (18:49 +0800)
Using this option control whether preallocate space when bluesotre
block/db_path/wal_path use file instead block device.

Signed-off-by: Jianpeng Ma <jianpeng.ma@intel.com>
src/common/config_opts.h
src/os/bluestore/BlueStore.cc

index c98945690f9679a88d02b5790dc1bdbf20358efa..10cd1908238ec51a1201754f3df3bdf4c835f27d 100644 (file)
@@ -938,6 +938,7 @@ OPTION(bluestore_block_db_create, OPT_BOOL, false)
 OPTION(bluestore_block_wal_path, OPT_STR, "")
 OPTION(bluestore_block_wal_size, OPT_U64, 96 * 1024*1024) // rocksdb wal
 OPTION(bluestore_block_wal_create, OPT_BOOL, false)
+OPTION(bluestore_block_preallocate_file, OPT_BOOL, false) //whether preallocate space if block/db_path/wal_path is file rather that block device.
 OPTION(bluestore_min_alloc_size, OPT_U32, 64*1024)
 OPTION(bluestore_onode_map_size, OPT_U32, 1024)   // onodes per collection
 OPTION(bluestore_cache_tails, OPT_BOOL, true)   // cache tail blocks in Onode
index d77d3cdb8c10839a57cbbb4194e65691195073a4..f7b83a596c8dc6b22be1e3cb9b1fda19558e8668 100644 (file)
@@ -1639,31 +1639,34 @@ int BlueStore::_setup_block_symlink_or_file(
          VOID_TEMP_FAILURE_RETRY(::close(fd));
          return r;
        }
+
+       if (g_conf->bluestore_block_preallocate_file) {
 #ifdef HAVE_POSIX_FALLOCATE
-       r = ::posix_fallocate(fd, 0, size);
-       if (r < 0) {
-         r = -errno;
-         derr << __func__ << " failed to prefallocate " << name << " file to "
-              << size << ": " << cpp_strerror(r) << dendl;
-         VOID_TEMP_FAILURE_RETRY(::close(fd));
-         return r;
-       }
-#else
-       char data[1024*128];
-       for (uint64_t off = 0; off < size; off += sizeof(data)) {
-         if (off + sizeof(data) > size)
-           r = ::write(fd, data, size - off);
-         else
-           r = ::write(fd, data, sizeof(data));
+         r = ::posix_fallocate(fd, 0, size);
          if (r < 0) {
            r = -errno;
-           derr << __func__ << " failed to prefallocate w/ write " << name << " file to "
+           derr << __func__ << " failed to prefallocate " << name << " file to "
              << size << ": " << cpp_strerror(r) << dendl;
            VOID_TEMP_FAILURE_RETRY(::close(fd));
            return r;
          }
-       }
+#else
+         char data[1024*128];
+         for (uint64_t off = 0; off < size; off += sizeof(data)) {
+           if (off + sizeof(data) > size)
+             r = ::write(fd, data, size - off);
+           else
+             r = ::write(fd, data, sizeof(data));
+           if (r < 0) {
+             r = -errno;
+             derr << __func__ << " failed to prefallocate w/ write " << name << " file to "
+               << size << ": " << cpp_strerror(r) << dendl;
+             VOID_TEMP_FAILURE_RETRY(::close(fd));
+             return r;
+           }
+         }
 #endif
+       }
        dout(1) << __func__ << " resized " << name << " file to "
                << pretty_si_t(size) << "B" << dendl;
       }