From c0f722568709ded9c81bee5e149cdf70ac29cdb4 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Tue, 6 Apr 2021 15:18:42 +0800 Subject: [PATCH] common/buffer.cc: use shift_round_up() when appropriate Signed-off-by: Kefu Chai --- src/common/buffer.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/common/buffer.cc b/src/common/buffer.cc index 6622b395afdb..895d4dc2f170 100644 --- a/src/common/buffer.cc +++ b/src/common/buffer.cc @@ -34,6 +34,7 @@ #include "common/valgrind.h" #include "common/deleter.h" #include "common/error_code.h" +#include "include/intarith.h" #include "include/spinlock.h" #include "include/scope_guard.h" @@ -2276,8 +2277,10 @@ MEMPOOL_DEFINE_OBJECT_FACTORY(buffer::raw_static, buffer_raw_static, void ceph::buffer::list::page_aligned_appender::_refill(size_t len) { - const size_t alloc = \ - std::max(static_cast(min_alloc), static_cast((len + CEPH_PAGE_SIZE - 1) & CEPH_PAGE_MASK)); + const unsigned alloc = + std::max(min_alloc, + shift_round_up(static_cast(len), + static_cast(CEPH_PAGE_SHIFT))); auto new_back = \ ptr_node::create(buffer::create_page_aligned(alloc)); new_back->set_length(0); // unused, so far. -- 2.47.3