From: Ramesh Chander Date: Fri, 20 May 2016 17:05:15 +0000 (-0700) Subject: os/bluestore: min_alloc_size options for different media types X-Git-Tag: v11.0.0~359^2~38 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8185f2d356911274ca679614611dc335e3efd187;p=ceph.git os/bluestore: min_alloc_size options for different media types Signed-off-by: Ramesh Chander --- diff --git a/src/common/config_opts.h b/src/common/config_opts.h index a3ee4647d858..6d4fa06167df 100644 --- a/src/common/config_opts.h +++ b/src/common/config_opts.h @@ -953,7 +953,9 @@ OPTION(bluestore_csum, OPT_BOOL, true) OPTION(bluestore_csum_type, OPT_STR, "crc32c") OPTION(bluestore_min_csum_block, OPT_U32, 4096) OPTION(bluestore_max_csum_block, OPT_U32, 64*1024) -OPTION(bluestore_min_alloc_size, OPT_U32, 64*1024) +OPTION(bluestore_min_alloc_size, OPT_U32, 0) +OPTION(bluestore_min_alloc_size_hdd, OPT_U32, 64*1024) +OPTION(bluestore_min_alloc_size_ssd, OPT_U32, 4*1024) OPTION(bluestore_onode_map_size, OPT_U32, 1024) // onodes per collection OPTION(bluestore_cache_tails, OPT_BOOL, true) // cache tail blocks in Onode OPTION(bluestore_kvbackend, OPT_STR, "rocksdb") diff --git a/src/os/bluestore/BlockDevice.h b/src/os/bluestore/BlockDevice.h index 14608ebcca80..07380d8634eb 100644 --- a/src/os/bluestore/BlockDevice.h +++ b/src/os/bluestore/BlockDevice.h @@ -72,8 +72,11 @@ class BlockDevice { std::mutex ioc_reap_lock; vector ioc_reap_queue; std::atomic_int ioc_reap_count = {0}; -public: + +protected: bool rotational; + +public: BlockDevice() = default; virtual ~BlockDevice() = default; typedef void (*aio_callback_t)(void *handle, void *aio); @@ -82,6 +85,7 @@ public: const string& path, aio_callback_t cb, void *cbpriv); virtual bool supported_bdev_label() { return true; } virtual bool is_rotational() { return rotational; } + virtual void aio_submit(IOContext *ioc) = 0; virtual uint64_t get_size() const = 0; diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 5f86630948c2..15cac81c050f 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -771,7 +771,7 @@ BlueStore::BlueStore(CephContext *cct, const string& path) kv_stop(false), logger(NULL), csum_type(bluestore_blob_t::CSUM_CRC32C), - min_alloc_size(g_conf->bluestore_min_alloc_size) + min_alloc_size(0) { _init_logger(); } @@ -790,7 +790,6 @@ const char **BlueStore::get_tracked_conf_keys() const static const char* KEYS[] = { "bluestore_csum", "bluestore_csum_type", - "bluestore_min_alloc_size", NULL }; return KEYS; @@ -810,11 +809,6 @@ void BlueStore::handle_conf_change(const struct md_config_t *conf, << bluestore_blob_t::get_csum_type_string(csum_type) << dendl; } - if (changed.count("bluestore_min_alloc_size")) { - min_alloc_size = g_conf->bluestore_min_alloc_size; - dout(10) << __func__ << " min_alloc_size 0x" << std::hex << min_alloc_size - << std::dec << dendl; - } } void BlueStore::_init_logger() @@ -969,6 +963,26 @@ int BlueStore::_check_or_set_bdev_label( return 0; } +void BlueStore::_set_min_alloc(void) +{ + /* + * Set device block size according to its media + */ + if (g_conf->bluestore_min_alloc_size) { + min_alloc_size = g_conf->bluestore_min_alloc_size; + } else { + assert(bdev); + if (bdev->is_rotational()) { + min_alloc_size = g_conf->bluestore_min_alloc_size_hdd; + } else { + min_alloc_size = g_conf->bluestore_min_alloc_size_ssd; + } + } + + dout(10) << __func__ << " min_alloc_size 0x" << std::hex << min_alloc_size + << std::dec << dendl; +} + int BlueStore::_open_bdev(bool create) { bluestore_bdev_label_t label; @@ -992,6 +1006,8 @@ int BlueStore::_open_bdev(bool create) for (uint64_t t = 1; t < block_size; t <<= 1) { ++block_size_order; } + + _set_min_alloc(); return 0; fail_close: diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index 736c9c0a2421..0525e2ac2b51 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -900,6 +900,7 @@ private: int _read_fsid(uuid_d *f); int _write_fsid(); void _close_fsid(); + void _set_min_alloc(); int _open_bdev(bool create); void _close_bdev(); int _open_db(bool create); diff --git a/src/os/bluestore/KernelDevice.cc b/src/os/bluestore/KernelDevice.cc index a61d3615eeca..09dc7bc8f69f 100644 --- a/src/os/bluestore/KernelDevice.cc +++ b/src/os/bluestore/KernelDevice.cc @@ -46,6 +46,7 @@ KernelDevice::KernelDevice(aio_callback_t cb, void *cbpriv) { zeros = buffer::create_page_aligned(1048576); zeros.zero(); + rotational = true; } int KernelDevice::_lock()