// vim: ts=8 sw=2 smarttab
#include <errno.h>
#include <boost/assign/list_of.hpp>
+#include <stddef.h>
#include "common/ceph_context.h"
#include "common/dout.h"
header_oid = old_header_name(name);
}
- if (rbd_cache) {
+ if (cache) {
Mutex::Locker l(cache_lock);
ldout(cct, 20) << "enabling caching..." << dendl;
writeback_handler = new LibrbdWriteback(this, cache_lock);
- uint64_t init_max_dirty = rbd_cache_max_dirty;
- if (rbd_cache_writethrough_until_flush)
+ uint64_t init_max_dirty = cache_max_dirty;
+ if (cache_writethrough_until_flush)
init_max_dirty = 0;
ldout(cct, 20) << "Initial cache settings:"
- << " size=" << rbd_cache_size
+ << " size=" << cache_size
<< " num_objects=" << 10
<< " max_dirty=" << init_max_dirty
- << " target_dirty=" << rbd_cache_target_dirty
+ << " target_dirty=" << cache_target_dirty
<< " max_dirty_age="
- << rbd_cache_max_dirty_age << dendl;
+ << cache_max_dirty_age << dendl;
object_cacher = new ObjectCacher(cct, pname, *writeback_handler, cache_lock,
NULL, NULL,
- rbd_cache_size,
+ cache_size,
10, /* reset this in init */
init_max_dirty,
- rbd_cache_target_dirty,
- rbd_cache_max_dirty_age,
- rbd_cache_block_writes_upfront);
+ cache_target_dirty,
+ cache_max_dirty_age,
+ cache_block_writes_upfront);
object_set = new ObjectCacher::ObjectSet(NULL, data_ctx.get_id(), 0);
object_set->return_enoent = true;
object_cacher->start();
}
- if (rbd_clone_copy_on_read) {
+ if (clone_copy_on_read) {
copyup_finisher = new Finisher(cct);
copyup_finisher->start();
}
- readahead.set_trigger_requests(rbd_readahead_trigger_requests);
- readahead.set_max_readahead_size(rbd_readahead_max_bytes);
+ readahead.set_trigger_requests(readahead_trigger_requests);
+ readahead.set_max_readahead_size(readahead_max_bytes);
perf_start(pname);
return 0;
// size object cache appropriately
if (object_cacher) {
- uint64_t obj = rbd_cache_max_dirty_object;
+ uint64_t obj = cache_max_dirty_object;
if (!obj) {
- obj = rbd_cache_size / (1ull << order);
+ obj = cache_size / (1ull << order);
obj = obj * 4 + 10;
}
- ldout(cct, 10) << " cache bytes " << rbd_cache_size << " order " << (int)order
+ ldout(cct, 10) << " cache bytes " << cache_size << " order " << (int)order
<< " -> about " << obj << " objects" << dendl;
object_cacher->set_max_objects(obj);
}
if (snap_id == LIBRADOS_SNAP_HEAD)
return flags;
- if (rbd_balance_snap_reads)
+ if (balance_snap_reads)
flags |= librados::OPERATION_BALANCE_READS;
- else if (rbd_localize_snap_reads)
+ else if (localize_snap_reads)
flags |= librados::OPERATION_LOCALIZE_READS;
return flags;
}
}
void ImageCtx::user_flushed() {
- if (object_cacher && rbd_cache_writethrough_until_flush) {
+ if (object_cacher && cache_writethrough_until_flush) {
md_lock.get_read();
bool flushed_before = flush_encountered;
md_lock.put_read();
- uint64_t max_dirty = rbd_cache_max_dirty;
+ uint64_t max_dirty = cache_max_dirty;
if (!flushed_before && max_dirty > 0) {
md_lock.get_write();
flush_encountered = true;
}
}
- bool ImageCtx::_filter_metadata_confs(const string &prefix, const vector<string> &configs,
+ bool ImageCtx::_filter_metadata_confs(const string &prefix, map<string, bool> &configs,
map<string, bufferlist> &pairs, map<string, bufferlist> *res) {
size_t conf_prefix_len = prefix.size();
return false;
string key = it->first.substr(conf_prefix_len, it->first.size() - conf_prefix_len);
- for (std::vector<string>::const_iterator cit = configs.begin();
+ for (map<string, bool>::iterator cit = configs.begin();
cit != configs.end(); ++cit) {
- if (!key.compare(*cit)) {
+ if (!key.compare(cit->first)) {
+ cit->second = true;
res->insert(make_pair(key, it->second));
break;
}
void ImageCtx::apply_metadata_confs() {
ldout(cct, 20) << __func__ << dendl;
static uint64_t max_conf_items = 128;
- const std::vector<string> configs = boost::assign::list_of(
- "rbd_cache")(
- "rbd_cache_writethrough_until_flush")(
- "rbd_cache_size")(
- "rbd_cache_max_dirty")(
- "rbd_cache_target_dirty")(
- "rbd_cache_max_dirty_age")(
- "rbd_cache_max_dirty_object")(
- "rbd_cache_block_writes_upfront")(
- "rbd_concurrent_management_ops")(
- "rbd_balance_snap_reads")(
- "rbd_localize_snap_reads")(
- "rbd_balance_parent_reads")(
- "rbd_localize_parent_reads")(
- "rbd_readahead_trigger_requests")(
- "rbd_readahead_max_bytes")(
- "rbd_readahead_disable_after_bytes")(
- "rbd_clone_copy_on_read")(
- "rbd_blacklist_on_break_lock")(
- "rbd_blacklist_expire_seconds")(
- "rbd_request_timed_out_seconds");
+ std::map<string, bool> configs = boost::assign::map_list_of(
+ "rbd_cache", false)(
+ "rbd_cache_writethrough_until_flush", false)(
+ "rbd_cache_size", false)(
+ "rbd_cache_max_dirty", false)(
+ "rbd_cache_target_dirty", false)(
+ "rbd_cache_max_dirty_age", false)(
+ "rbd_cache_max_dirty_object", false)(
+ "rbd_cache_block_writes_upfront", false)(
+ "rbd_concurrent_management_ops", false)(
+ "rbd_balance_snap_reads", false)(
+ "rbd_localize_snap_reads", false)(
+ "rbd_balance_parent_reads", false)(
+ "rbd_localize_parent_reads", false)(
+ "rbd_readahead_trigger_requests", false)(
+ "rbd_readahead_max_bytes", false)(
+ "rbd_readahead_disable_after_bytes", false)(
+ "rbd_clone_copy_on_read", false)(
+ "rbd_blacklist_on_break_lock", false)(
+ "rbd_blacklist_expire_seconds", false)(
+ "rbd_request_timed_out_seconds", false);
string start = METADATA_CONF_PREFIX;
int r = 0, j = 0;
bool is_continue;
+ md_config_t local_config_t;
do {
map<string, bufferlist> pairs, res;
r = cls_client::metadata_list(&md_ctx, header_oid, start, max_conf_items, &pairs);
is_continue = _filter_metadata_confs(METADATA_CONF_PREFIX, configs, pairs, &res);
for (map<string, bufferlist>::iterator it = res.begin(); it != res.end(); ++it) {
- j = cct->_conf->set_val(it->first.c_str(), it->second.c_str());
+ j = local_config_t.set_val(it->first.c_str(), it->second.c_str());
if (j < 0)
lderr(cct) << __func__ << " failed to set config " << it->first << " with value "
<< it->second.c_str() << ": " << j << dendl;
start = pairs.rbegin()->first;
} while (is_continue);
- md_config_t *conf = cct->_conf;
- rbd_cache = conf->rbd_cache;
- rbd_cache_writethrough_until_flush = conf->rbd_cache_writethrough_until_flush;
- rbd_cache_size = conf->rbd_cache_size;
- rbd_cache_max_dirty = conf->rbd_cache_max_dirty;
- rbd_cache_target_dirty = conf->rbd_cache_target_dirty;
- rbd_cache_max_dirty_age = conf->rbd_cache_max_dirty_age;
- rbd_cache_max_dirty_object = conf->rbd_cache_max_dirty_object;
- rbd_cache_block_writes_upfront = conf->rbd_cache_block_writes_upfront;
- rbd_concurrent_management_ops = conf->rbd_concurrent_management_ops;
- rbd_balance_snap_reads = conf->rbd_balance_snap_reads;
- rbd_localize_snap_reads = conf->rbd_localize_snap_reads;
- rbd_balance_parent_reads = conf->rbd_balance_parent_reads;
- rbd_localize_parent_reads = conf->rbd_localize_parent_reads;
- rbd_readahead_trigger_requests = conf->rbd_readahead_trigger_requests;
- rbd_readahead_max_bytes = conf->rbd_readahead_max_bytes;
- rbd_readahead_disable_after_bytes = conf->rbd_readahead_disable_after_bytes;
- rbd_clone_copy_on_read = conf->rbd_clone_copy_on_read;
- rbd_blacklist_on_break_lock = conf->rbd_blacklist_on_break_lock;
- rbd_blacklist_expire_seconds = conf->rbd_blacklist_expire_seconds;
- rbd_request_timed_out_seconds = conf->rbd_request_timed_out_seconds;
+#define ASSIGN_OPTION(config) \
+ do { \
+ if (configs[#config]) \
+ config = local_config_t.rbd_##config; \
+ else \
+ config = cct->_conf->rbd_##config; \
+ } while (0);
+
+ ASSIGN_OPTION(cache);
+ ASSIGN_OPTION(cache_writethrough_until_flush);
+ ASSIGN_OPTION(cache_size);
+ ASSIGN_OPTION(cache_max_dirty);
+ ASSIGN_OPTION(cache_target_dirty);
+ ASSIGN_OPTION(cache_max_dirty_age);
+ ASSIGN_OPTION(cache_max_dirty_object);
+ ASSIGN_OPTION(cache_block_writes_upfront);
+ ASSIGN_OPTION(concurrent_management_ops);
+ ASSIGN_OPTION(balance_snap_reads);
+ ASSIGN_OPTION(localize_snap_reads);
+ ASSIGN_OPTION(balance_parent_reads);
+ ASSIGN_OPTION(localize_parent_reads);
+ ASSIGN_OPTION(readahead_trigger_requests);
+ ASSIGN_OPTION(readahead_max_bytes);
+ ASSIGN_OPTION(readahead_disable_after_bytes);
+ ASSIGN_OPTION(clone_copy_on_read);
+ ASSIGN_OPTION(blacklist_on_break_lock);
+ ASSIGN_OPTION(blacklist_expire_seconds);
+ ASSIGN_OPTION(request_timed_out_seconds);
}
}
// Configuration
static const string METADATA_CONF_PREFIX;
- bool rbd_cache;
- bool rbd_cache_writethrough_until_flush;
- uint64_t rbd_cache_size;
- uint64_t rbd_cache_max_dirty;
- uint64_t rbd_cache_target_dirty;
- double rbd_cache_max_dirty_age;
- uint32_t rbd_cache_max_dirty_object;
- bool rbd_cache_block_writes_upfront;
- uint32_t rbd_concurrent_management_ops;
- bool rbd_balance_snap_reads;
- bool rbd_localize_snap_reads;
- bool rbd_balance_parent_reads;
- bool rbd_localize_parent_reads;
- uint32_t rbd_readahead_trigger_requests;
- uint64_t rbd_readahead_max_bytes;
- uint64_t rbd_readahead_disable_after_bytes;
- bool rbd_clone_copy_on_read;
- bool rbd_blacklist_on_break_lock;
- uint32_t rbd_blacklist_expire_seconds;
- uint32_t rbd_request_timed_out_seconds;
- static bool _filter_metadata_confs(const string &prefix, const std::vector<string> &configs,
+ bool cache;
+ bool cache_writethrough_until_flush;
+ uint64_t cache_size;
+ uint64_t cache_max_dirty;
+ uint64_t cache_target_dirty;
+ double cache_max_dirty_age;
+ uint32_t cache_max_dirty_object;
+ bool cache_block_writes_upfront;
+ uint32_t concurrent_management_ops;
+ bool balance_snap_reads;
+ bool localize_snap_reads;
+ bool balance_parent_reads;
+ bool localize_parent_reads;
+ uint32_t readahead_trigger_requests;
+ uint64_t readahead_max_bytes;
+ uint64_t readahead_disable_after_bytes;
+ bool clone_copy_on_read;
+ bool blacklist_on_break_lock;
+ uint32_t blacklist_expire_seconds;
+ uint32_t request_timed_out_seconds;
+ static bool _filter_metadata_confs(const string &prefix, std::map<string, bool> &configs,
map<string, bufferlist> &pairs, map<string, bufferlist> *res);
/**
int r;
CephContext *cct = ictx->cct;
- SimpleThrottle throttle(ictx->rbd_concurrent_management_ops, true);
+ SimpleThrottle throttle(ictx->concurrent_management_ops, true);
for (uint64_t i = 0; i < numseg; i++) {
string oid = ictx->get_object_name(i);
ictx->parent = new ImageCtx("", parent_image_id, NULL, p_ioctx, true);
// set rados flags for reading the parent image
- if (ictx->rbd_balance_parent_reads)
+ if (ictx->balance_parent_reads)
ictx->parent->set_read_flag(librados::OPERATION_BALANCE_READS);
- else if (ictx->rbd_localize_parent_reads)
+ else if (ictx->localize_parent_reads)
ictx->parent->set_read_flag(librados::OPERATION_LOCALIZE_READS);
r = open_image(ictx->parent);
return r;
}
- SimpleThrottle throttle(src->rbd_concurrent_management_ops, false);
+ SimpleThrottle throttle(src->concurrent_management_ops, false);
uint64_t period = src->get_stripe_period();
for (uint64_t offset = 0; offset < src_size; offset += period) {
uint64_t len = min(period, src_size - offset);
return -EINVAL;
}
- if (ictx->rbd_blacklist_on_break_lock) {
+ if (ictx->blacklist_on_break_lock) {
typedef std::map<rados::cls::lock::locker_id_t,
rados::cls::lock::locker_info_t> Lockers;
Lockers lockers;
RWLock::RLocker locker(ictx->md_lock);
librados::Rados rados(ictx->md_ctx);
r = rados.blacklist_add(client_address,
- ictx->rbd_blacklist_expire_seconds);
+ ictx->blacklist_expire_seconds);
if (r < 0) {
lderr(ictx->cct) << "unable to blacklist client: " << cpp_strerror(r)
<< dendl;
total_bytes += p->second;
}
ictx->md_lock.get_write();
- bool abort = ictx->rbd_readahead_disable_after_bytes != 0 &&
- ictx->total_bytes_read > ictx->rbd_readahead_disable_after_bytes;
+ bool abort = ictx->readahead_disable_after_bytes != 0 &&
+ ictx->total_bytes_read > ictx->readahead_disable_after_bytes;
ictx->total_bytes_read += total_bytes;
ictx->snap_lock.get_read();
uint64_t image_size = ictx->get_image_size(ictx->snap_id);
}
// readahead
- if (ictx->object_cacher && ictx->rbd_readahead_max_bytes > 0 &&
+ if (ictx->object_cacher && ictx->readahead_max_bytes > 0 &&
!(op_flags & LIBRADOS_OP_FLAG_FADVISE_RANDOM)) {
readahead(ictx, image_extents);
}