]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd: Switch MIN/MAX for std::min/max and use intarith templates 19912/head
authorAdam C. Emerson <aemerson@redhat.com>
Thu, 11 Jan 2018 03:23:14 +0000 (22:23 -0500)
committerAdam C. Emerson <aemerson@redhat.com>
Sat, 13 Jan 2018 19:04:53 +0000 (14:04 -0500)
Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
src/cls/rbd/cls_rbd.cc
src/librbd/ImageCtx.cc
src/librbd/object_map/UpdateRequest.cc
src/rbd_replay/BufferReader.cc
src/test/librbd/test_internal.cc

index 0bb3778fbacdf07a1620588349aae0ce13cb7391..65c1b0f028ac6178b1f34e5a749cad6e061b89ad 100644 (file)
@@ -1158,7 +1158,7 @@ int set_parent(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
   parent.pool = pool;
   parent.id = id;
   parent.snapid = snapid;
-  parent.overlap = MIN(our_size, size);
+  parent.overlap = std::min(our_size, size);
   encode(parent, parentbl);
   r = cls_cxx_map_set_val(hctx, "parent", &parentbl);
   if (r < 0) {
@@ -2772,7 +2772,7 @@ int metadata_list(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
 
   while (more && data.size() < max_return) {
     map<string, bufferlist> raw_data;
-    int max_read = MIN(RBD_MAX_KEYS_READ, max_return - data.size());
+    int max_read = std::min<uint64_t>(RBD_MAX_KEYS_READ, max_return - data.size());
     int r = cls_cxx_map_get_vals(hctx, last_read, RBD_METADATA_KEY_PREFIX,
                                  max_read, &raw_data, &more);
     if (r < 0) {
@@ -3853,7 +3853,7 @@ int mirror_image_map_list(cls_method_context_t hctx,
     std::map<std::string, bufferlist> vals;
     CLS_LOG(20, "last read: '%s'", last_read.c_str());
 
-    int max_read = MIN(RBD_MAX_KEYS_READ, max_return - image_mapping->size());
+    int max_read = std::min<uint64_t>(RBD_MAX_KEYS_READ, max_return - image_mapping->size());
     int r = cls_cxx_map_get_vals(hctx, last_read, MIRROR_IMAGE_MAP_KEY_PREFIX,
                                  max_read, &vals, &more);
     if (r < 0) {
index 6c26d490e49eeecb5a69d12aeaa7df887c974203..ca4de1b3c1477e05edfe7589d166407070c9f34a 100644 (file)
@@ -308,7 +308,10 @@ struct C_InvalidateCache : public Context {
       // size object cache appropriately
       uint64_t obj = cache_max_dirty_object;
       if (!obj) {
-       obj = MIN(2000, MAX(10, cache_size / 100 / sizeof(ObjectCacher::Object)));
+       obj = std::min<uint64_t>(2000,
+                                std::max<uint64_t>(
+                                  10, cache_size / 100 /
+                                  sizeof(ObjectCacher::Object)));
       }
       ldout(cct, 10) << " cache bytes " << cache_size
        << " -> about " << obj << " objects" << dendl;
@@ -969,7 +972,7 @@ struct C_InvalidateCache : public Context {
     size_t conf_prefix_len = prefix.size();
 
     for (auto it : pairs) {
-      if (it.first.compare(0, MIN(conf_prefix_len, it.first.size()), prefix) > 0)
+      if (it.first.compare(0, std::min(conf_prefix_len, it.first.size()), prefix) > 0)
         return false;
 
       if (it.first.size() <= conf_prefix_len)
index 9ceb28a177379b1fbeae984d1e09c3d4b99bce52..36ccc6159aa46ab76e4bac76ac01db1e335ef2fe 100644 (file)
@@ -38,7 +38,7 @@ void UpdateRequest<I>::update_object_map() {
   CephContext *cct = m_image_ctx.cct;
 
   // break very large requests into manageable batches
-  m_update_end_object_no = MIN(
+  m_update_end_object_no = std::min(
     m_end_object_no, m_update_start_object_no + MAX_OBJECTS_PER_UPDATE);
 
   std::string oid(ObjectMap<>::object_map_name(m_image_ctx.id, m_snap_id));
@@ -98,9 +98,9 @@ void UpdateRequest<I>::update_in_memory_object_map() {
     ldout(m_image_ctx.cct, 20) << dendl;
 
     auto it = m_object_map.begin() +
-                    MIN(m_update_start_object_no, m_object_map.size());
+      std::min(m_update_start_object_no, m_object_map.size());
     auto end_it = m_object_map.begin() +
-                    MIN(m_update_end_object_no, m_object_map.size());
+      std::min(m_update_end_object_no, m_object_map.size());
     for (; it != end_it; ++it) {
       auto state_ref = *it;
       uint8_t state = state_ref;
index ad78b9944306a330dff25789f625b56e35956cc9..631c17e7a9e7ce1551debd468dd7e160da192185 100644 (file)
@@ -15,7 +15,7 @@ BufferReader::BufferReader(int fd, size_t min_bytes, size_t max_bytes)
 
 int BufferReader::fetch(bufferlist::iterator **it) {
   if (m_bl_it.get_remaining() < m_min_bytes) {
-    ssize_t bytes_to_read = ROUND_UP_TO(m_max_bytes - m_bl_it.get_remaining(),
+    ssize_t bytes_to_read = round_up_to(m_max_bytes - m_bl_it.get_remaining(),
                                         CEPH_PAGE_SIZE);
     while (!m_eof_reached && bytes_to_read > 0) {
       int r = m_bl.read_fd(m_fd, CEPH_PAGE_SIZE);
index 9f68c248e61a97ad7ce29461f4c76a1ca3d716b4..3fb4312b43784a58da8a3e8dfc6c74b77325fae7 100644 (file)
@@ -398,7 +398,7 @@ TEST_F(TestInternal, CancelAsyncResize) {
     C_SaferCond ctx;
     librbd::NoOpProgressContext prog_ctx;
 
-    size -= MIN(size, 1<<18);
+    size -= std::min<uint64_t>(size, 1 << 18);
     {
       RWLock::RLocker l(ictx->owner_lock);
       ictx->operations->execute_resize(size, true, prog_ctx, &ctx, 0);
@@ -443,7 +443,7 @@ TEST_F(TestInternal, MultipleResize) {
   while (size > 0) {
     uint64_t new_size = original_size;
     if (attempts++ % 2 == 0) {
-      size -= MIN(size, 1<<18);
+      size -= std::min<uint64_t>(size, 1 << 18);
       new_size = size;
     }