From 8e49bc32c866f3199987d6c222f0f231ddc9441c Mon Sep 17 00:00:00 2001 From: Ilya Dryomov Date: Fri, 21 Feb 2014 16:34:14 +0200 Subject: [PATCH] FileStore: add option to cap alloc hint size 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 --- src/common/config_opts.h | 2 ++ src/os/FileStore.cc | 6 +++++- src/os/FileStore.h | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/common/config_opts.h b/src/common/config_opts.h index 3549e5465ecda..367475d9c0f19 100644 --- a/src/common/config_opts.h +++ b/src/common/config_opts.h @@ -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) diff --git a/src/os/FileStore.cc b/src/os/FileStore.cc index 3a42e45acb0a2..43dea84e67bf2 100644 --- a/src/os/FileStore.cc +++ b/src/os/FileStore.cc @@ -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); diff --git a/src/os/FileStore.h b/src/os/FileStore.h index d00130214c6ff..4c9ffdba2f3e8 100644 --- a/src/os/FileStore.h +++ b/src/os/FileStore.h @@ -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 -- 2.39.5