From 1b7f7a05d19c720d7c12d38f4336da2da2989ac6 Mon Sep 17 00:00:00 2001 From: "Adam C. Emerson" Date: Wed, 10 Jan 2018 22:24:17 -0500 Subject: [PATCH] cephfs: Switch MIN/MAX for std::min/max and use intarith templates Signed-off-by: Adam C. Emerson --- src/client/Client.cc | 8 ++++---- src/client/SyntheticClient.cc | 4 ++-- src/tools/cephfs/Dumper.cc | 4 ++-- src/tools/cephfs/Resetter.cc | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/client/Client.cc b/src/client/Client.cc index 1ef925903bb..41c53caeded 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -7110,7 +7110,7 @@ int Client::fill_stat(Inode *in, struct stat *st, frag_info_t *dirstat, nest_inf st->st_size = in->size; st->st_blocks = (in->size + 511) >> 9; } - st->st_blksize = MAX(in->layout.stripe_unit, 4096); + st->st_blksize = std::max(in->layout.stripe_unit, 4096); if (dirstat) *dirstat = in->dirstat; @@ -7136,7 +7136,7 @@ void Client::fill_statx(Inode *in, unsigned int mask, struct ceph_statx *stx) /* These are always considered to be available */ stx->stx_dev = in->snapid; - stx->stx_blksize = MAX(in->layout.stripe_unit, 4096); + stx->stx_blksize = std::max(in->layout.stripe_unit, 4096); /* Type bits are always set, even when CEPH_STATX_MODE is not */ stx->stx_mode = S_IFMT & in->mode; @@ -8351,10 +8351,10 @@ Fh *Client::_create_fh(Inode *in, int flags, int cmode, const UserPerm& perms) f->readahead.set_min_readahead_size(conf->client_readahead_min); uint64_t max_readahead = Readahead::NO_LIMIT; if (conf->client_readahead_max_bytes) { - max_readahead = MIN(max_readahead, (uint64_t)conf->client_readahead_max_bytes); + max_readahead = std::min(max_readahead, (uint64_t)conf->client_readahead_max_bytes); } if (conf->client_readahead_max_periods) { - max_readahead = MIN(max_readahead, in->layout.get_period()*(uint64_t)conf->client_readahead_max_periods); + max_readahead = std::min(max_readahead, in->layout.get_period()*(uint64_t)conf->client_readahead_max_periods); } f->readahead.set_max_readahead_size(max_readahead); vector alignments; diff --git a/src/client/SyntheticClient.cc b/src/client/SyntheticClient.cc index 89f8498d888..a610f1aebd8 100644 --- a/src/client/SyntheticClient.cc +++ b/src/client/SyntheticClient.cc @@ -3366,13 +3366,13 @@ int SyntheticClient::chunk_file(string &filename) uint64_t pos = 0; bufferlist from_before; while (pos < size) { - int get = MIN(size-pos, 1048576); + int get = std::min(size - pos, 1048576); Mutex flock("synclient chunk_file lock"); Cond cond; bool done; bufferlist bl; - + flock.Lock(); Context *onfinish = new C_SafeCond(&flock, &cond, &done); client->filer->read(inode.ino, &inode.layout, CEPH_NOSNAP, pos, get, &bl, 0, diff --git a/src/tools/cephfs/Dumper.cc b/src/tools/cephfs/Dumper.cc index 2bc379b94f8..22ef544a8f3 100644 --- a/src/tools/cephfs/Dumper.cc +++ b/src/tools/cephfs/Dumper.cc @@ -135,7 +135,7 @@ int Dumper::dump(const char *dump_file) bufferlist bl; dout(10) << "Reading at pos=0x" << std::hex << pos << std::dec << dendl; - const uint32_t read_size = MIN(chunk_size, end - pos); + const uint32_t read_size = std::min(chunk_size, end - pos); C_SaferCond cond; lock.Lock(); @@ -298,7 +298,7 @@ int Dumper::undump(const char *dump_file) // Read bufferlist j; lseek64(fd, pos, SEEK_SET); - uint64_t l = MIN(left, 1024*1024); + uint64_t l = std::min(left, 1024*1024); j.read_fd(fd, l); // Write diff --git a/src/tools/cephfs/Resetter.cc b/src/tools/cephfs/Resetter.cc index 58465c2ffc7..32ada622982 100644 --- a/src/tools/cephfs/Resetter.cc +++ b/src/tools/cephfs/Resetter.cc @@ -78,7 +78,7 @@ int Resetter::reset(mds_role_t role) uint64_t old_len = old_end - old_start; cout << "old journal was " << old_start << "~" << old_len << std::endl; - uint64_t new_start = ROUND_UP_TO(old_end+1, journaler.get_layout_period()); + uint64_t new_start = round_up_to(old_end+1, journaler.get_layout_period()); cout << "new journal start will be " << new_start << " (" << (new_start - old_end) << " bytes past old end)" << std::endl; -- 2.39.5