Skip to content

Commit

Permalink
os/bluestore: min_alloc_size options for different media types
Browse files Browse the repository at this point in the history
Signed-off-by: Ramesh Chander <Ramesh.Chander@sandisk.com>
  • Loading branch information
chhabaramesh authored and liewegas committed Jun 1, 2016
1 parent 6148e1e commit 8185f2d
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 9 deletions.
4 changes: 3 additions & 1 deletion src/common/config_opts.h
Expand Up @@ -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")
Expand Down
6 changes: 5 additions & 1 deletion src/os/bluestore/BlockDevice.h
Expand Up @@ -72,8 +72,11 @@ class BlockDevice {
std::mutex ioc_reap_lock;
vector<IOContext*> 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);
Expand All @@ -82,6 +85,7 @@ class BlockDevice {
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;
Expand Down
30 changes: 23 additions & 7 deletions src/os/bluestore/BlueStore.cc
Expand Up @@ -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();
}
Expand All @@ -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;
Expand All @@ -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()
Expand Down Expand Up @@ -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;
Expand All @@ -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:
Expand Down
1 change: 1 addition & 0 deletions src/os/bluestore/BlueStore.h
Expand Up @@ -900,6 +900,7 @@ class BlueStore : public ObjectStore,
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);
Expand Down
1 change: 1 addition & 0 deletions src/os/bluestore/KernelDevice.cc
Expand Up @@ -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()
Expand Down

0 comments on commit 8185f2d

Please sign in to comment.