]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
FileStore: add option to cap alloc hint size
authorIlya Dryomov <ilya.dryomov@inktank.com>
Fri, 21 Feb 2014 14:34:14 +0000 (16:34 +0200)
committerIlya Dryomov <ilya.dryomov@inktank.com>
Mon, 3 Mar 2014 18:33:44 +0000 (20:33 +0200)
Add a new config option, filestore_max_alloc_hint_size, to cap
SETALLOCHINT hint size.  The unit is a byte, the default value is
1 megabyte.

Signed-off-by: Ilya Dryomov <ilya.dryomov@inktank.com>
src/common/config_opts.h
src/os/FileStore.cc
src/os/FileStore.h

index 3549e5465ecdadaca48c90cee5c039f78e2a9943..367475d9c0f19017ed6d6cfa3a3af5d4c8cbba12 100644 (file)
@@ -616,6 +616,8 @@ OPTION(filestore_max_inline_xattrs_other, OPT_U32, 2)
 OPTION(filestore_sloppy_crc, OPT_BOOL, false)         // track sloppy crcs
 OPTION(filestore_sloppy_crc_block_size, OPT_INT, 65536)
 
+OPTION(filestore_max_alloc_hint_size, OPT_U64, 1ULL << 20) // bytes
+
 OPTION(filestore_max_sync_interval, OPT_DOUBLE, 5)    // seconds
 OPTION(filestore_min_sync_interval, OPT_DOUBLE, .01)  // seconds
 OPTION(filestore_btrfs_snap, OPT_BOOL, true)
index 3a42e45acb0a203c67bf7396c0d039e1c14a6d2a..43dea84e67bf25ccce138b3d7d8945e2a9edd45e 100644 (file)
@@ -461,6 +461,7 @@ FileStore::FileStore(const std::string &base, const std::string &jdev, const cha
   m_filestore_dump_fmt(true),
   m_filestore_sloppy_crc(g_conf->filestore_sloppy_crc),
   m_filestore_sloppy_crc_block_size(g_conf->filestore_sloppy_crc_block_size),
+  m_filestore_max_alloc_hint_size(g_conf->filestore_max_alloc_hint_size),
   m_fs_type(FS_TYPE_NONE),
   m_filestore_max_inline_xattr_size(0),
   m_filestore_max_inline_xattrs(0)
@@ -4727,7 +4728,7 @@ int FileStore::_set_alloc_hint(coll_t cid, const ghobject_t& oid,
 
   {
     // TODO: a more elaborate hint calculation
-    uint64_t hint = expected_write_size;
+    uint64_t hint = MIN(expected_write_size, m_filestore_max_alloc_hint_size);
 
     ret = backend->set_alloc_hint(**fd, hint);
     dout(20) << "set_alloc_hint hint " << hint << " ret " << ret << dendl;
@@ -4756,6 +4757,7 @@ const char** FileStore::get_tracked_conf_keys() const
     "filestore_replica_fadvise",
     "filestore_sloppy_crc",
     "filestore_sloppy_crc_block_size",
+    "filestore_max_alloc_hint_size",
     NULL
   };
   return KEYS;
@@ -4785,6 +4787,7 @@ void FileStore::handle_conf_change(const struct md_config_t *conf,
       changed.count("filestore_fail_eio") ||
       changed.count("filestore_sloppy_crc") ||
       changed.count("filestore_sloppy_crc_block_size") ||
+      changed.count("filestore_max_alloc_hint_size") ||
       changed.count("filestore_replica_fadvise")) {
     Mutex::Locker l(lock);
     m_filestore_min_sync_interval = conf->filestore_min_sync_interval;
@@ -4798,6 +4801,7 @@ void FileStore::handle_conf_change(const struct md_config_t *conf,
     m_filestore_replica_fadvise = conf->filestore_replica_fadvise;
     m_filestore_sloppy_crc = conf->filestore_sloppy_crc;
     m_filestore_sloppy_crc_block_size = conf->filestore_sloppy_crc_block_size;
+    m_filestore_max_alloc_hint_size = conf->filestore_max_alloc_hint_size;
   }
   if (changed.count("filestore_commit_timeout")) {
     Mutex::Locker l(sync_entry_timeo_lock);
index d00130214c6ffb05f7c2715d57e3924458ea57cf..4c9ffdba2f3e87915e1f7b7474cb87b30954d70d 100644 (file)
@@ -612,6 +612,7 @@ private:
   atomic_t m_filestore_kill_at;
   bool m_filestore_sloppy_crc;
   int m_filestore_sloppy_crc_block_size;
+  uint64_t m_filestore_max_alloc_hint_size;
   enum fs_types m_fs_type;
 
   //Determined xattr handling based on fs type