Skip to content

Commit

Permalink
FileStore: add option to cap alloc hint size
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
idryomov committed Mar 3, 2014
1 parent 1f5b796 commit 8e49bc3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/common/config_opts.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 5 additions & 1 deletion src/os/FileStore.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/os/FileStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,7 @@ class FileStore : public JournalingObjectStore,
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
Expand Down

0 comments on commit 8e49bc3

Please sign in to comment.