static inline bool is_copy_on_read(ImageCtx *ictx, librados::snap_t snap_id) {
assert(ictx->snap_lock.is_locked());
- return (ictx->cct->_conf->rbd_clone_copy_on_read) &&
+ return (ictx->rbd_clone_copy_on_read) &&
(!ictx->read_only) && (snap_id == CEPH_NOSNAP);
}
AsyncObjectThrottle *throttle = new AsyncObjectThrottle(
*this, context_factory, create_callback_context(), m_prog_ctx, 0,
m_overlap_objects);
- throttle->start_ops(cct->_conf->rbd_concurrent_management_ops);
+ throttle->start_ops(m_image_ctx.rbd_concurrent_management_ops);
}
bool AsyncFlattenRequest::send_update_header() {
}
void AsyncTrimRequest::send_remove_objects() {
- CephContext *cct = m_image_ctx.cct;
ldout(m_image_ctx.cct, 5) << this << " send_remove_objects: "
<< " delete_start=" << m_delete_start
<< " num_objects=" << m_num_objects << dendl;
boost::lambda::_1, &m_image_ctx, boost::lambda::_2));
AsyncObjectThrottle *throttle = new AsyncObjectThrottle(
*this, context_factory, ctx, m_prog_ctx, m_delete_start, m_num_objects);
- throttle->start_ops(cct->_conf->rbd_concurrent_management_ops);
+ throttle->start_ops(m_image_ctx.rbd_concurrent_management_ops);
}
void AsyncTrimRequest::send_pre_remove() {
}
header_oid = header_name(id);
+ aware_metadata_confs();
r = cls_client::get_immutable_metadata(&md_ctx, header_oid,
&object_prefix, &order);
if (r < 0) {
init_layout();
} else {
+ aware_metadata_confs();
header_oid = old_header_name(name);
}
- if (cct->_conf->rbd_cache) {
+ if (rbd_cache) {
Mutex::Locker l(cache_lock);
ldout(cct, 20) << "enabling caching..." << dendl;
writeback_handler = new LibrbdWriteback(this, cache_lock);
- uint64_t init_max_dirty = cct->_conf->rbd_cache_max_dirty;
- if (cct->_conf->rbd_cache_writethrough_until_flush)
+ uint64_t init_max_dirty = rbd_cache_max_dirty;
+ if (rbd_cache_writethrough_until_flush)
init_max_dirty = 0;
ldout(cct, 20) << "Initial cache settings:"
- << " size=" << cct->_conf->rbd_cache_size
+ << " size=" << rbd_cache_size
<< " num_objects=" << 10
<< " max_dirty=" << init_max_dirty
- << " target_dirty=" << cct->_conf->rbd_cache_target_dirty
+ << " target_dirty=" << rbd_cache_target_dirty
<< " max_dirty_age="
- << cct->_conf->rbd_cache_max_dirty_age << dendl;
+ << rbd_cache_max_dirty_age << dendl;
object_cacher = new ObjectCacher(cct, pname, *writeback_handler, cache_lock,
NULL, NULL,
- cct->_conf->rbd_cache_size,
+ rbd_cache_size,
10, /* reset this in init */
init_max_dirty,
- cct->_conf->rbd_cache_target_dirty,
- cct->_conf->rbd_cache_max_dirty_age,
- cct->_conf->rbd_cache_block_writes_upfront);
+ rbd_cache_target_dirty,
+ rbd_cache_max_dirty_age,
+ rbd_cache_block_writes_upfront);
object_set = new ObjectCacher::ObjectSet(NULL, data_ctx.get_id(), 0);
object_set->return_enoent = true;
object_cacher->start();
}
- if (cct->_conf->rbd_clone_copy_on_read) {
+ if (rbd_clone_copy_on_read) {
copyup_finisher = new Finisher(cct);
copyup_finisher->start();
}
- md_config_t *conf = cct->_conf;
- readahead.set_trigger_requests(conf->rbd_readahead_trigger_requests);
- readahead.set_max_readahead_size(conf->rbd_readahead_max_bytes);
+ readahead.set_trigger_requests(rbd_readahead_trigger_requests);
+ readahead.set_max_readahead_size(rbd_readahead_max_bytes);
perf_start(pname);
return 0;
// size object cache appropriately
if (object_cacher) {
- uint64_t obj = cct->_conf->rbd_cache_max_dirty_object;
+ uint64_t obj = rbd_cache_max_dirty_object;
if (!obj) {
- obj = cct->_conf->rbd_cache_size / (1ull << order);
+ obj = rbd_cache_size / (1ull << order);
obj = obj * 4 + 10;
}
- ldout(cct, 10) << " cache bytes " << cct->_conf->rbd_cache_size << " order " << (int)order
+ ldout(cct, 10) << " cache bytes " << rbd_cache_size << " order " << (int)order
<< " -> about " << obj << " objects" << dendl;
object_cacher->set_max_objects(obj);
}
if (snap_id == LIBRADOS_SNAP_HEAD)
return flags;
- if (cct->_conf->rbd_balance_snap_reads)
+ if (rbd_balance_snap_reads)
flags |= librados::OPERATION_BALANCE_READS;
- else if (cct->_conf->rbd_localize_snap_reads)
+ else if (rbd_localize_snap_reads)
flags |= librados::OPERATION_LOCALIZE_READS;
return flags;
}
}
void ImageCtx::user_flushed() {
- if (object_cacher && cct->_conf->rbd_cache_writethrough_until_flush) {
+ if (object_cacher && rbd_cache_writethrough_until_flush) {
md_lock.get_read();
bool flushed_before = flush_encountered;
md_lock.put_read();
- uint64_t max_dirty = cct->_conf->rbd_cache_max_dirty;
+ uint64_t max_dirty = rbd_cache_max_dirty;
if (!flushed_before && max_dirty > 0) {
md_lock.get_write();
flush_encountered = true;
}
start = pairs.rbegin()->first;
} while (is_continue);
+
cct->_conf->apply_changes(NULL);
- }
+ 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;
+ }
}
xlist<AsyncResizeRequest*> async_resize_reqs;
+ // Configuration
static const string METADATA_CONF_PREFIX;
+ static const char *AWARE_CONFS[];
+ static const size_t AWARE_CONFS_LEN;
+ 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 _aware_metadata_confs(const string &prefix, const char **configs, size_t len,
+ map<string, bufferlist> &pairs, map<string, bufferlist> *res);
+
/**
* Either image_name or image_id must be set.
* If id is not known, pass the empty std::string,
void cancel_async_requests();
void aware_metadata_confs();
- static bool _aware_metadata_confs(const string &prefix, const char **configs, size_t len,
- map<string, bufferlist> &pairs, map<string, bufferlist> *res);
- static const char *AWARE_CONFS[];
- static const size_t AWARE_CONFS_LEN;
};
}
}
}
- md_config_t *conf = m_image_ctx.cct->_conf;
- if (conf->rbd_blacklist_on_break_lock) {
+ if (m_image_ctx.rbd_blacklist_on_break_lock) {
ldout(m_image_ctx.cct, 1) << "blacklisting client: " << locker << "@"
<< locker_address << dendl;
librados::Rados rados(m_image_ctx.md_ctx);
r = rados.blacklist_add(locker_address,
- conf->rbd_blacklist_expire_seconds);
+ m_image_ctx.rbd_blacklist_expire_seconds);
if (r < 0) {
lderr(m_image_ctx.cct) << "unable to blacklist client: "
<< cpp_strerror(r) << dendl;
Task task(TASK_CODE_ASYNC_REQUEST, id);
m_task_finisher->cancel(task);
- md_config_t *conf = m_image_ctx.cct->_conf;
- m_task_finisher->add_event_after(task, conf->rbd_request_timed_out_seconds,
- ctx);
+ m_task_finisher->add_event_after(task, m_image_ctx.rbd_request_timed_out_seconds, ctx);
}
void ImageWatcher::async_request_timed_out(const AsyncRequestId &id) {
int r;
CephContext *cct = ictx->cct;
- SimpleThrottle throttle(cct->_conf->rbd_concurrent_management_ops, true);
+ SimpleThrottle throttle(ictx->rbd_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->cct->_conf->rbd_balance_parent_reads)
+ if (ictx->rbd_balance_parent_reads)
ictx->parent->set_read_flag(librados::OPERATION_BALANCE_READS);
- else if (ictx->cct->_conf->rbd_localize_parent_reads)
+ else if (ictx->rbd_localize_parent_reads)
ictx->parent->set_read_flag(librados::OPERATION_LOCALIZE_READS);
r = open_image(ictx->parent);
return r;
}
- SimpleThrottle throttle(cct->_conf->rbd_concurrent_management_ops, false);
+ SimpleThrottle throttle(src->rbd_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);
int r = ictx->init();
if (r < 0)
goto err_close;
- ictx->aware_metadata_confs();
if (!ictx->read_only) {
r = ictx->register_watch();
return -EINVAL;
}
- md_config_t *conf = ictx->cct->_conf;
- if (conf->rbd_blacklist_on_break_lock) {
+ if (ictx->rbd_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,
- conf->rbd_blacklist_expire_seconds);
+ ictx->rbd_blacklist_expire_seconds);
if (r < 0) {
lderr(ictx->cct) << "unable to blacklist client: " << cpp_strerror(r)
<< dendl;
};
static void readahead(ImageCtx *ictx,
- const vector<pair<uint64_t,uint64_t> >& image_extents,
- const md_config_t *conf)
+ const vector<pair<uint64_t,uint64_t> >& image_extents)
{
uint64_t total_bytes = 0;
for (vector<pair<uint64_t,uint64_t> >::const_iterator p = image_extents.begin();
total_bytes += p->second;
}
ictx->md_lock.get_write();
- bool abort = conf->rbd_readahead_disable_after_bytes != 0 &&
- ictx->total_bytes_read > (uint64_t)conf->rbd_readahead_disable_after_bytes;
+ bool abort = ictx->rbd_readahead_disable_after_bytes != 0 &&
+ ictx->total_bytes_read > ictx->rbd_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
- const md_config_t *conf = ictx->cct->_conf;
- if (ictx->object_cacher && conf->rbd_readahead_max_bytes > 0 &&
+ if (ictx->object_cacher && ictx->rbd_readahead_max_bytes > 0 &&
!(op_flags & LIBRADOS_OP_FLAG_FADVISE_RANDOM)) {
- readahead(ictx, image_extents, conf);
+ readahead(ictx, image_extents);
}
snap_t snap_id;