Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup: Replacing MIN,MAX with std::min,std::max #18124

Merged
merged 1 commit into from Dec 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/auth/cephx/CephxKeyServer.cc
Expand Up @@ -200,7 +200,7 @@ int KeyServer::_rotate_secret(uint32_t service_id)
} else {
utime_t next_ttl = now;
next_ttl += ttl;
ek.expiration = MAX(next_ttl, r.next().expiration);
ek.expiration = std::max(next_ttl, r.next().expiration);
}
ek.expiration += ttl;
uint64_t secret_id = r.add(ek);
Expand Down
4 changes: 2 additions & 2 deletions src/cls/journal/cls_journal.cc
Expand Up @@ -139,7 +139,7 @@ int expire_tags(cls_method_context_t hctx, const std::string *skip_client_id) {
}

for (auto object_position : client.commit_position.object_positions) {
minimum_tag_tid = MIN(minimum_tag_tid, object_position.tag_tid);
minimum_tag_tid = std::min(minimum_tag_tid, object_position.tag_tid);
}
}
if (!vals.empty()) {
Expand Down Expand Up @@ -1018,7 +1018,7 @@ int journal_tag_list(cls_method_context_t hctx, bufferlist *in,
}

for (auto object_position : client.commit_position.object_positions) {
minimum_tag_tid = MIN(minimum_tag_tid, object_position.tag_tid);
minimum_tag_tid = std::min(minimum_tag_tid, object_position.tag_tid);
}

// compute minimum tags in use per-class
Expand Down
2 changes: 1 addition & 1 deletion src/common/LogClient.cc
Expand Up @@ -278,7 +278,7 @@ Message *LogClient::_get_mon_log_message()
unsigned num_unsent = last_log - last_log_sent;
unsigned num_send;
if (cct->_conf->mon_client_max_log_entries_per_message > 0)
num_send = MIN(num_unsent, (unsigned)cct->_conf->mon_client_max_log_entries_per_message);
num_send = std::min(num_unsent, (unsigned)cct->_conf->mon_client_max_log_entries_per_message);
else
num_send = num_unsent;

Expand Down
4 changes: 2 additions & 2 deletions src/common/Readahead.cc
Expand Up @@ -82,8 +82,8 @@ Readahead::extent_t Readahead::_compute_readahead(uint64_t limit) {
m_readahead_pos = m_last_pos;
}
}
m_readahead_size = MAX(m_readahead_size, m_readahead_min_bytes);
m_readahead_size = MIN(m_readahead_size, m_readahead_max_bytes);
m_readahead_size = std::max(m_readahead_size, m_readahead_min_bytes);
m_readahead_size = std::min(m_readahead_size, m_readahead_max_bytes);
readahead_offset = m_readahead_pos;
readahead_length = m_readahead_size;

Expand Down
4 changes: 2 additions & 2 deletions src/include/interval_set.h
Expand Up @@ -600,8 +600,8 @@ class interval_set {
continue;
}

T start = MAX(pa->first, pb->first);
T en = MIN(pa->first+pa->second, pb->first+pb->second);
T start = std::max(pa->first, pb->first);
T en = std::min(pa->first+pa->second, pb->first+pb->second);
assert(en > start);
typename decltype(m)::value_type i{start, en - start};
mi = m.insert(mi, i);
Expand Down
4 changes: 2 additions & 2 deletions src/journal/JournalMetadata.cc
Expand Up @@ -757,8 +757,8 @@ void JournalMetadata::handle_refresh_complete(C_Refresh *refresh, int r) {
ldout(m_cct, 0) << "client flagged disconnected: " << m_client_id
<< dendl;
}
m_minimum_set = MAX(m_minimum_set, refresh->minimum_set);
m_active_set = MAX(m_active_set, refresh->active_set);
m_minimum_set = std::max(m_minimum_set, refresh->minimum_set);
m_active_set = std::max(m_active_set, refresh->active_set);
m_registered_clients = refresh->registered_clients;
m_client = *it;

Expand Down
2 changes: 1 addition & 1 deletion src/journal/JournalTrimmer.cc
Expand Up @@ -111,7 +111,7 @@ void JournalTrimmer::trim_objects(uint64_t minimum_set) {
}

if (m_remove_set_pending) {
m_remove_set = MAX(m_remove_set, minimum_set);
m_remove_set = std::max(m_remove_set, minimum_set);
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/librbd/Journal.cc
Expand Up @@ -749,7 +749,7 @@ uint64_t Journal<I>::append_write_event(uint64_t offset, size_t length,
uint64_t bytes_remaining = length;
uint64_t event_offset = 0;
do {
uint64_t event_length = MIN(bytes_remaining, max_write_data_size);
uint64_t event_length = std::min(bytes_remaining, max_write_data_size);

bufferlist event_bl;
event_bl.substr_of(bl, event_offset, event_length);
Expand Down
2 changes: 1 addition & 1 deletion src/librbd/api/DiffIterate.cc
Expand Up @@ -457,7 +457,7 @@ int DiffIterate<I>::diff_object_map(uint64_t from_snap_id, uint64_t to_snap_id,
}
object_map.resize(num_objs);

uint64_t overlap = MIN(object_map.size(), prev_object_map.size());
uint64_t overlap = std::min(object_map.size(), prev_object_map.size());
for (uint64_t i = 0; i < overlap; ++i) {
ldout(cct, 20) << __func__ << ": object state: " << i << " "
<< static_cast<uint32_t>(prev_object_map[i])
Expand Down
2 changes: 1 addition & 1 deletion src/librbd/io/ReadResult.cc
Expand Up @@ -62,7 +62,7 @@ struct ReadResult::AssembleResultVisitor : public boost::static_visitor<void> {
size_t offset = 0;
int idx = 0;
for (; offset < length && idx < vector.iov_count; idx++) {
size_t len = MIN(vector.iov[idx].iov_len, length - offset);
size_t len = std::min(vector.iov[idx].iov_len, length - offset);
it.copy(len, static_cast<char *>(vector.iov[idx].iov_base));
offset += len;
}
Expand Down
2 changes: 1 addition & 1 deletion src/librbd/object_map/CreateRequest.cc
Expand Up @@ -35,7 +35,7 @@ void CreateRequest<I>::send() {
RWLock::WLocker snap_locker(m_image_ctx->snap_lock);
m_snap_ids.push_back(CEPH_NOSNAP);
for (auto it : m_image_ctx->snap_info) {
max_size = MAX(max_size, it.second.size);
max_size = std::max(max_size, it.second.size);
m_snap_ids.push_back(it.first);
}

Expand Down
2 changes: 1 addition & 1 deletion src/librbd/operation/ResizeRequest.cc
Expand Up @@ -422,7 +422,7 @@ void ResizeRequest<I>::compute_parent_overlap() {
if (image_ctx.parent == NULL) {
m_new_parent_overlap = 0;
} else {
m_new_parent_overlap = MIN(m_new_size, image_ctx.parent_md.overlap);
m_new_parent_overlap = std::min(m_new_size, image_ctx.parent_md.overlap);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/librbd/operation/TrimRequest.cc
Expand Up @@ -103,7 +103,7 @@ TrimRequest<I>::TrimRequest(I &image_ctx, Context *on_finish,
{
uint64_t period = image_ctx.get_stripe_period();
uint64_t new_num_periods = ((m_new_size + period - 1) / period);
m_delete_off = MIN(new_num_periods * period, original_size);
m_delete_off = std::min(new_num_periods * period, original_size);
// first object we can delete free and clear
m_delete_start = new_num_periods * image_ctx.get_stripe_count();
m_delete_start_min = m_delete_start;
Expand Down
8 changes: 4 additions & 4 deletions src/mds/CInode.cc
Expand Up @@ -459,7 +459,7 @@ void CInode::project_past_snaprealm_parent(SnapRealm *newparent)
new_snap->past_parents[oldparentseq].ino = oldparent->inode->ino();
new_snap->past_parents[oldparentseq].first = new_snap->current_parent_since;
}
new_snap->current_parent_since = MAX(oldparentseq, newparent->get_last_created()) + 1;
new_snap->current_parent_since = std::max(oldparentseq, newparent->get_last_created()) + 1;
}
}

Expand Down Expand Up @@ -2538,7 +2538,7 @@ snapid_t CInode::get_oldest_snap()
snapid_t t = first;
if (!old_inodes.empty())
t = old_inodes.begin()->second.first;
return MIN(t, oldest_snap);
return std::min(t, oldest_snap);
}

old_inode_t& CInode::cow_old_inode(snapid_t follows, bool cow_head)
Expand Down Expand Up @@ -3204,7 +3204,7 @@ int CInode::encode_inodestat(bufferlist& bl, Session *session,

// max_size is min of projected, actual
uint64_t max_size =
MIN(oi->client_ranges.count(client) ?
std::min(oi->client_ranges.count(client) ?
oi->client_ranges[client].range.last : 0,
pi->client_ranges.count(client) ?
pi->client_ranges[client].range.last : 0);
Expand Down Expand Up @@ -3476,7 +3476,7 @@ void CInode::encode_cap_message(MClientCaps *m, Capability *cap)
// max_size is min of projected, actual.
uint64_t oldms = oi->client_ranges.count(client) ? oi->client_ranges[client].range.last : 0;
uint64_t newms = pi->client_ranges.count(client) ? pi->client_ranges[client].range.last : 0;
m->max_size = MIN(oldms, newms);
m->max_size = std::min(oldms, newms);

i = pauth ? pi:oi;
m->head.mode = i->mode;
Expand Down
8 changes: 4 additions & 4 deletions src/mds/Locker.cc
Expand Up @@ -2297,7 +2297,7 @@ uint64_t Locker::calc_new_max_size(inode_t *pi, uint64_t size)
uint64_t max_inc = g_conf->mds_client_writeable_range_max_inc_objs;
if (max_inc > 0) {
max_inc *= pi->get_layout_size_increment();
new_max = MIN(new_max, size + max_inc);
new_max = std::min(new_max, size + max_inc);
}
return ROUND_UP_TO(new_max, pi->get_layout_size_increment());
}
Expand Down Expand Up @@ -2327,7 +2327,7 @@ void Locker::calc_new_client_ranges(CInode *in, uint64_t size,
client_writeable_range_t& oldr = latest->client_ranges[p->first];
if (ms > oldr.range.last)
*max_increased = true;
nr.range.last = MAX(ms, oldr.range.last);
nr.range.last = std::max(ms, oldr.range.last);
nr.follows = oldr.follows;
} else {
*max_increased = true;
Expand All @@ -2353,8 +2353,8 @@ bool Locker::check_inode_max_size(CInode *in, bool force_wrlock,
bool max_increased = false;

if (update_size) {
new_size = size = MAX(size, new_size);
new_mtime = MAX(new_mtime, latest->mtime);
new_size = size = std::max(size, new_size);
new_mtime = std::max(new_mtime, latest->mtime);
if (latest->size == new_size && latest->mtime == new_mtime)
update_size = false;
}
Expand Down
10 changes: 5 additions & 5 deletions src/mds/MDCache.cc
Expand Up @@ -1745,7 +1745,7 @@ void MDCache::project_rstat_inode_to_frag(CInode *cur, CDir *parent, snapid_t fi

if (cur->last != CEPH_NOSNAP) {
assert(cur->dirty_old_rstats.empty());
set<snapid_t>::const_iterator q = snaps.lower_bound(MAX(first, floor));
set<snapid_t>::const_iterator q = snaps.lower_bound(std::max(first, floor));
if (q == snaps.end() || *q > cur->last)
return;
}
Expand All @@ -1759,7 +1759,7 @@ void MDCache::project_rstat_inode_to_frag(CInode *cur, CDir *parent, snapid_t fi
assert(cur->is_frozen_inode());
update = false;
}
_project_rstat_inode_to_frag(*curi, MAX(first, floor), cur->last, parent,
_project_rstat_inode_to_frag(*curi, std::max(first, floor), cur->last, parent,
linkunlink, update);
}

Expand All @@ -1768,7 +1768,7 @@ void MDCache::project_rstat_inode_to_frag(CInode *cur, CDir *parent, snapid_t fi
p != cur->dirty_old_rstats.end();
++p) {
old_inode_t& old = cur->old_inodes[*p];
snapid_t ofirst = MAX(old.first, floor);
snapid_t ofirst = std::max(old.first, floor);
set<snapid_t>::const_iterator q = snaps.lower_bound(ofirst);
if (q == snaps.end() || *q > *p)
continue;
Expand Down Expand Up @@ -1813,7 +1813,7 @@ void MDCache::_project_rstat_inode_to_frag(inode_t& inode, snapid_t ofirst, snap
fnode_t *pf = parent->get_projected_fnode();
if (last == CEPH_NOSNAP) {
if (g_conf->mds_snap_rstat)
first = MAX(ofirst, parent->first);
first = std::max(ofirst, parent->first);
else
first = parent->first;
prstat = &pf->rstat;
Expand Down Expand Up @@ -1915,7 +1915,7 @@ void MDCache::project_rstat_frag_to_inode(nest_info_t& rstat, nest_info_t& accou
snapid_t first;
if (last == pin->last) {
pi = pin->get_projected_inode();
first = MAX(ofirst, pin->first);
first = std::max(ofirst, pin->first);
if (first > pin->first) {
old_inode_t& old = pin->cow_old_inode(first-1, cow_head);
dout(20) << " cloned old_inode rstat is " << old.inode.rstat << dendl;
Expand Down
4 changes: 2 additions & 2 deletions src/mds/PurgeQueue.cc
Expand Up @@ -301,7 +301,7 @@ uint32_t PurgeQueue::_calculate_ops(const PurgeItem &item) const
const uint64_t num = (item.size > 0) ?
Striper::get_num_objects(item.layout, item.size) : 1;

ops_required = MIN(num, g_conf->filer_max_purge_ops);
ops_required = std::min(num, g_conf->filer_max_purge_ops);

// Account for removing (or zeroing) backtrace
ops_required += 1;
Expand Down Expand Up @@ -564,7 +564,7 @@ void PurgeQueue::update_op_limit(const MDSMap &mds_map)

// User may also specify a hard limit, apply this if so.
if (cct->_conf->mds_max_purge_ops) {
max_purge_ops = MIN(max_purge_ops, cct->_conf->mds_max_purge_ops);
max_purge_ops = std::min(max_purge_ops, cct->_conf->mds_max_purge_ops);
}
}

Expand Down
24 changes: 12 additions & 12 deletions src/mds/SnapRealm.cc
Expand Up @@ -133,7 +133,7 @@ bool SnapRealm::_open_parents(MDSInternalContextBase *finish, snapid_t first, sn
dout(10) << " current parent [" << srnode.current_parent_since << ",head] is " << *parent
<< " on " << *parent->inode << dendl;
if (last >= srnode.current_parent_since &&
!parent->_open_parents(finish, MAX(first, srnode.current_parent_since), last))
!parent->_open_parents(finish, std::max(first, srnode.current_parent_since), last))
return false;
}

Expand Down Expand Up @@ -197,8 +197,8 @@ bool SnapRealm::have_past_parents_open(snapid_t first, snapid_t last)
return false;
}
SnapRealm *parent_realm = open_past_parents[p->second.ino].first;
if (!parent_realm->have_past_parents_open(MAX(first, p->second.first),
MIN(last, p->first)))
if (!parent_realm->have_past_parents_open(std::max(first, p->second.first),
std::min(last, p->first)))
return false;
}

Expand Down Expand Up @@ -248,12 +248,12 @@ void SnapRealm::build_snap_set(set<snapid_t> &s,
assert(oldparent); // call open_parents first!
assert(oldparent->snaprealm);
oldparent->snaprealm->build_snap_set(s, max_seq, max_last_created, max_last_destroyed,
MAX(first, p->second.first),
MIN(last, p->first));
std::max(first, p->second.first),
std::min(last, p->first));
}
if (srnode.current_parent_since <= last && parent)
parent->build_snap_set(s, max_seq, max_last_created, max_last_destroyed,
MAX(first, srnode.current_parent_since), last);
std::max(first, srnode.current_parent_since), last);
}


Expand Down Expand Up @@ -331,11 +331,11 @@ void SnapRealm::get_snap_info(map<snapid_t,SnapInfo*>& infomap, snapid_t first,
assert(oldparent); // call open_parents first!
assert(oldparent->snaprealm);
oldparent->snaprealm->get_snap_info(infomap,
MAX(first, p->second.first),
MIN(last, p->first));
std::max(first, p->second.first),
std::min(last, p->first));
}
if (srnode.current_parent_since <= last && parent)
parent->get_snap_info(infomap, MAX(first, srnode.current_parent_since), last);
parent->get_snap_info(infomap, std::max(first, srnode.current_parent_since), last);
}

const string& SnapRealm::get_snapname(snapid_t snapid, inodeno_t atino)
Expand Down Expand Up @@ -402,13 +402,13 @@ snapid_t SnapRealm::resolve_snapname(const string& n, inodeno_t atino, snapid_t
assert(oldparent); // call open_parents first!
assert(oldparent->snaprealm);
snapid_t r = oldparent->snaprealm->resolve_snapname(n, atino,
MAX(first, p->second.first),
MIN(last, p->first));
std::max(first, p->second.first),
std::min(last, p->first));
if (r)
return r;
}
if (parent && srnode.current_parent_since <= last)
return parent->resolve_snapname(n, atino, MAX(first, srnode.current_parent_since), last);
return parent->resolve_snapname(n, atino, std::max(first, srnode.current_parent_since), last);
return 0;
}

Expand Down
8 changes: 4 additions & 4 deletions src/mds/StrayManager.cc
Expand Up @@ -118,11 +118,11 @@ void StrayManager::purge(CDentry *dn)
uint64_t to = 0;
if (in->is_file()) {
to = in->inode.get_max_size();
to = MAX(in->inode.size, to);
to = std::max(in->inode.size, to);
// when truncating a file, the filer does not delete stripe objects that are
// truncated to zero. so we need to purge stripe objects up to the max size
// the file has ever been.
to = MAX(in->inode.max_size_ever, to);
to = std::max(in->inode.max_size_ever, to);
}

inode_t *pi = in->get_projected_inode();
Expand Down Expand Up @@ -719,11 +719,11 @@ void StrayManager::truncate(CDentry *dn)
const SnapContext *snapc = &realm->get_snap_context();

uint64_t to = in->inode.get_max_size();
to = MAX(in->inode.size, to);
to = std::max(in->inode.size, to);
// when truncating a file, the filer does not delete stripe objects that are
// truncated to zero. so we need to purge stripe objects up to the max size
// the file has ever been.
to = MAX(in->inode.max_size_ever, to);
to = std::max(in->inode.max_size_ever, to);

assert(to > 0);

Expand Down
4 changes: 2 additions & 2 deletions src/mon/MDSMonitor.cc
Expand Up @@ -1816,11 +1816,11 @@ void MDSMonitor::maybe_replace_gid(mds_gid_t gid, const MDSMap::mds_info_t& info
// getting beacons through recently.
utime_t latest_beacon;
for (const auto & i : last_beacon) {
latest_beacon = MAX(i.second.stamp, latest_beacon);
latest_beacon = std::max(i.second.stamp, latest_beacon);
}
const bool may_replace = latest_beacon >
(ceph_clock_now() -
MAX(g_conf->mds_beacon_interval, g_conf->mds_beacon_grace * 0.5));
std::max(g_conf->mds_beacon_interval, g_conf->mds_beacon_grace * 0.5));

// are we in?
// and is there a non-laggy standby that can take over for us?
Expand Down
2 changes: 1 addition & 1 deletion src/mon/MonClient.cc
Expand Up @@ -880,7 +880,7 @@ int MonClient::_check_auth_rotating()

utime_t now = ceph_clock_now();
utime_t cutoff = now;
cutoff -= MIN(30.0, cct->_conf->auth_service_ticket_ttl / 4.0);
cutoff -= std::min(30.0, cct->_conf->auth_service_ticket_ttl / 4.0);
utime_t issued_at_lower_bound = now;
issued_at_lower_bound -= cct->_conf->auth_service_ticket_ttl;
if (!rotating_secrets->need_new_secrets(cutoff)) {
Expand Down
2 changes: 1 addition & 1 deletion src/mon/Monitor.cc
Expand Up @@ -1177,7 +1177,7 @@ void Monitor::sync_start(entity_inst_t &other, bool full)
sync_stash_critical_state(t);
t->put("mon_sync", "in_sync", 1);

sync_last_committed_floor = MAX(sync_last_committed_floor, paxos->get_version());
sync_last_committed_floor = std::max(sync_last_committed_floor, paxos->get_version());
dout(10) << __func__ << " marking sync in progress, storing sync_last_committed_floor "
<< sync_last_committed_floor << dendl;
t->put("mon_sync", "last_committed_floor", sync_last_committed_floor);
Expand Down