These were awkward for typing of the '1' literal vs.
the int64_t settings. The whole max() thing is also
unnecessary now, if we set proper bounds on the option
definitions.
Signed-off-by: John Spray <john.spray@redhat.com>
Option("rbd_concurrent_management_ops", Option::TYPE_INT, Option::LEVEL_ADVANCED)
.set_default(10)
+ .set_min(1)
.set_description(""),
Option("rbd_balance_snap_reads", Option::TYPE_BOOL, Option::LEVEL_ADVANCED)
Option("rbd_mirror_image_state_check_interval", Option::TYPE_INT, Option::LEVEL_ADVANCED)
.set_default(30)
+ .set_min(1)
.set_description(""),
Option("rbd_mirror_leader_heartbeat_interval", Option::TYPE_INT, Option::LEVEL_ADVANCED)
.set_default(5)
+ .set_min(1)
.set_description(""),
Option("rbd_mirror_leader_max_missed_heartbeats", Option::TYPE_INT, Option::LEVEL_ADVANCED)
desc = new_desc;
return *this;
}
+
+ template<typename T>
+ Option& set_min(const T& mi) {
+ set_value(min, mi);
+ return *this;
+ }
+
template<typename T>
Option& set_min_max(const T& mi, const T& ma) {
- min = mi;
- max = ma;
+ set_value(min, mi);
+ set_value(max, ma);
return *this;
}
fd = STDOUT_FILENO;
max_concurrent_ops = 1;
} else {
- max_concurrent_ops = max(g_conf->rbd_concurrent_management_ops, 1);
+ max_concurrent_ops = g_conf->rbd_concurrent_management_ops;
fd = open(path, O_WRONLY | O_CREAT | O_EXCL, 0644);
if (fd < 0) {
return -errno;
ImportDiffContext(librbd::Image *image, int fd, size_t size, bool no_progress)
: image(image), fd(fd), size(size), pc("Importing image diff", no_progress),
throttle((fd == STDIN_FILENO) ? 1 :
- max(g_conf->rbd_concurrent_management_ops, 1), false), last_offset(0) {
+ g_conf->rbd_concurrent_management_ops, false), last_offset(0) {
}
void update_size(size_t new_size)
throttle.reset(new SimpleThrottle(1, false));
} else {
throttle.reset(new SimpleThrottle(
- max(g_conf->rbd_concurrent_management_ops, 1), false));
+ g_conf->rbd_concurrent_management_ops, false));
}
reqlen = min<uint64_t>(reqlen, size);
start_image_replayers();
});
- int after =
- max(1, g_ceph_context->_conf->rbd_mirror_image_state_check_interval);
+ int after = g_ceph_context->_conf->rbd_mirror_image_state_check_interval;
dout(20) << "scheduling image state check after " << after << " sec (task "
<< m_image_state_check_task << ")" << dendl;
cancel_remove_task(instance);
- int after = max(1, m_cct->_conf->rbd_mirror_leader_heartbeat_interval) *
+ int after = m_cct->_conf->rbd_mirror_leader_heartbeat_interval *
(1 + m_cct->_conf->rbd_mirror_leader_max_missed_heartbeats +
m_cct->_conf->rbd_mirror_leader_max_acquire_attempts_before_break);
m_timer_gate->timer_callback = timer_callback;
});
- int after = delay_factor *
- max(1, m_cct->_conf->rbd_mirror_leader_heartbeat_interval);
+ int after = delay_factor * m_cct->_conf->rbd_mirror_leader_heartbeat_interval;
dout(20) << "scheduling " << name << " after " << after << " sec (task "
<< m_timer_task << ")" << dendl;