---
headers: |
+ #include <bit>
#include <regex>
// rbd feature and io operation validation
#include "include/stringify.h"
uint64_t f = strict_si_cast<uint64_t>(*value, error_message);
if (!error_message->empty()) {
return -EINVAL;
- } else if (!isp2(f)) {
+ } else if (!std::has_single_bit(f)) {
*error_message = "value must be a power of two";
return -EINVAL;
}
#include "include/ceph_assert.h"
#include "include/scope_guard.h"
+#include <bit>
#include <stdlib.h>
namespace librbd {
uint64_t block_size, uint64_t data_offset)
: m_cct(cct), m_data_cryptor(data_cryptor), m_block_size(block_size),
m_data_offset(data_offset), m_iv_size(data_cryptor->get_iv_size()) {
- ceph_assert(isp2(block_size));
+ ceph_assert(std::has_single_bit(block_size));
ceph_assert((block_size % data_cryptor->get_block_size()) == 0);
ceph_assert((block_size % 512) == 0);
}
#include "AvlAllocator.h"
+#include <bit>
#include <limits>
#include "common/config_proxy.h"
<< " max_alloc_size 0x" << max_alloc_size
<< " hint 0x" << hint
<< std::dec << dendl;
- ceph_assert(isp2(unit));
+ ceph_assert(std::has_single_bit(unit));
ceph_assert(want % unit == 0);
if (max_alloc_size == 0) {
// vim: ts=8 sw=2 smarttab
#include "BitmapFreelistManager.h"
+
+#include <bit>
#include "kv/KeyValueDB.h"
#include "os/kv.h"
#include "include/stringify.h"
KeyValueDB::Transaction txn)
{
bytes_per_block = granularity;
- ceph_assert(isp2(bytes_per_block));
+ ceph_assert(std::has_single_bit(bytes_per_block));
size = p2align(new_size, bytes_per_block);
blocks_per_key = cct->_conf->bluestore_freelist_blocks_per_key;
int BitmapFreelistManager::_expand(uint64_t old_size, KeyValueDB* db)
{
assert(old_size < size);
- ceph_assert(isp2(bytes_per_block));
+ ceph_assert(std::has_single_bit(bytes_per_block));
KeyValueDB::Transaction txn;
txn = db->get_transaction();
*
*/
+#include <bit>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
_validate_bdev();
// make sure min_alloc_size is power of 2 aligned.
- if (!isp2(min_alloc_size)) {
+ if (!std::has_single_bit(min_alloc_size)) {
derr << __func__ << " min_alloc_size 0x"
<< std::hex << min_alloc_size << std::dec
<< " is not power of 2 aligned!"
#include <unistd.h>
#include <atomic>
+#include <bit>
#include <chrono>
#include <ratio>
#include <mutex>
uint64_t min_alloc_size,
uint64_t mem_cap = DEF_MEM_CAP) {
ceph_assert(!granularity); // not initialized yet
- ceph_assert(min_alloc_size && isp2(min_alloc_size));
+ ceph_assert(std::has_single_bit(min_alloc_size));
ceph_assert(mem_cap);
total = round_up_to(total, min_alloc_size);
#include "BtreeAllocator.h"
+#include <bit>
#include <limits>
#include "common/config_proxy.h"
<< " max_alloc_size 0x" << max_alloc_size
<< " hint 0x" << hint
<< std::dec << dendl;
- ceph_assert(isp2(unit));
+ ceph_assert(std::has_single_bit(unit));
ceph_assert(want % unit == 0);
if (max_alloc_size == 0) {
#include "HybridAllocator.h"
+#include <bit>
#include <limits>
#include "common/config_proxy.h"
<< " max_alloc_size 0x" << max_alloc_size
<< " hint 0x" << hint
<< std::dec << dendl;
- ceph_assert(isp2(unit));
+ ceph_assert(std::has_single_bit(unit));
ceph_assert(want % unit == 0);
if (max_alloc_size == 0) {
#ifndef CEPH_OSD_BLUESTORE_BLUESTORE_TYPES_H
#define CEPH_OSD_BLUESTORE_BLUESTORE_TYPES_H
+#include <bit>
#include <ostream>
#include <type_traits>
#include <vector>
shared_blob_2hash_tracker_t(uint64_t mem_cap, size_t alloc_unit)
: ref_counter_2hash_tracker_t(mem_cap) {
ceph_assert(alloc_unit);
- ceph_assert(isp2(alloc_unit));
+ ceph_assert(std::has_single_bit(alloc_unit));
au_void_bits = ctz(alloc_unit);
}
void inc(uint64_t sbid, uint64_t offset, int n);
#define __FAST_BITMAP_ALLOCATOR_IMPL_H
#include "include/intarith.h"
+#include <bit>
#include <vector>
#include <algorithm>
#include <mutex>
void _init(uint64_t capacity, uint64_t _alloc_unit, bool mark_as_free = true)
{
- ceph_assert(isp2(_alloc_unit));
+ ceph_assert(std::has_single_bit(_alloc_unit));
l1._init(capacity, _alloc_unit, mark_as_free);
l2_granularity =
*/
#include <algorithm>
+#include <bit>
#include <optional>
#include <random>
if (cct->_conf.get_val<bool>("mon_warn_on_pool_pg_num_not_power_of_two")) {
list<string> detail;
for (auto it : get_pools()) {
- if (!isp2(it.second.get_pg_num_target())) {
+ if (!std::has_single_bit(it.second.get_pg_num_target())) {
ostringstream ss;
ss << "pool '" << get_pool_name(it.first)
<< "' pg_num " << it.second.get_pg_num_target()
* Bitmap allocator fragmentation benchmarks.
* Author: Adam Kupczyk, akupczyk@redhat.com
*/
+#include <bit>
#include <iostream>
#include <boost/scoped_ptr.hpp>
#include <gtest/gtest.h>
uint64_t capacity, uint32_t alloc_unit,
uint64_t high_mark, uint64_t low_mark, uint32_t iterations, double leak_factor)
{
- assert(isp2(alloc_unit));
+ assert(std::has_single_bit(alloc_unit));
cct->_conf->bdev_block_size = alloc_unit;
PExtentVector allocated, tmp;
init_alloc(allocator_name, capacity, alloc_unit);