Use (uint64_t)1 instead of 1l / 1ul

nfs-proxy-old
Vitaliy Filippov 2022-04-16 01:39:55 +03:00
parent 1493823f9e
commit 842ba8b831
14 changed files with 26 additions and 26 deletions

View File

@ -25,7 +25,7 @@ allocator::allocator(uint64_t blocks)
size = free = blocks; size = free = blocks;
last_one_mask = (blocks % 64) == 0 last_one_mask = (blocks % 64) == 0
? UINT64_MAX ? UINT64_MAX
: ((1l << (blocks % 64)) - 1); : (((uint64_t)1 << (blocks % 64)) - 1);
for (uint64_t i = 0; i < total; i++) for (uint64_t i = 0; i < total; i++)
{ {
mask[i] = 0; mask[i] = 0;
@ -79,7 +79,7 @@ void allocator::set(uint64_t addr, bool value)
} }
if (value) if (value)
{ {
mask[last] = mask[last] | (1l << bit); mask[last] = mask[last] | ((uint64_t)1 << bit);
if (mask[last] != (!is_last || cur_addr/64 < size/64 if (mask[last] != (!is_last || cur_addr/64 < size/64
? UINT64_MAX : last_one_mask)) ? UINT64_MAX : last_one_mask))
{ {
@ -88,7 +88,7 @@ void allocator::set(uint64_t addr, bool value)
} }
else else
{ {
mask[last] = mask[last] & ~(1l << bit); mask[last] = mask[last] & ~((uint64_t)1 << bit);
} }
is_last = false; is_last = false;
if (p2 > 1) if (p2 > 1)

View File

@ -457,13 +457,13 @@ uint64_t parse_size(std::string size_str)
if (type_char == 'k' || type_char == 'm' || type_char == 'g' || type_char == 't') if (type_char == 'k' || type_char == 'm' || type_char == 'g' || type_char == 't')
{ {
if (type_char == 'k') if (type_char == 'k')
mul = 1l<<10; mul = (uint64_t)1<<10;
else if (type_char == 'm') else if (type_char == 'm')
mul = 1l<<20; mul = (uint64_t)1<<20;
else if (type_char == 'g') else if (type_char == 'g')
mul = 1l<<30; mul = (uint64_t)1<<30;
else /*if (type_char == 't')*/ else /*if (type_char == 't')*/
mul = 1l<<40; mul = (uint64_t)1<<40;
size_str = size_str.substr(0, size_str.length()-1); size_str = size_str.substr(0, size_str.length()-1);
} }
uint64_t size = json11::Json(size_str).uint64_value() * mul; uint64_t size = json11::Json(size_str).uint64_value() * mul;

View File

@ -124,8 +124,8 @@ resume_1:
{ "scheme_name", pool_cfg.scheme == POOL_SCHEME_REPLICATED { "scheme_name", pool_cfg.scheme == POOL_SCHEME_REPLICATED
? std::to_string(pool_cfg.pg_size)+"/"+std::to_string(pool_cfg.pg_minsize) ? std::to_string(pool_cfg.pg_size)+"/"+std::to_string(pool_cfg.pg_minsize)
: "EC "+std::to_string(pool_cfg.pg_size-pool_cfg.parity_chunks)+"+"+std::to_string(pool_cfg.parity_chunks) }, : "EC "+std::to_string(pool_cfg.pg_size-pool_cfg.parity_chunks)+"+"+std::to_string(pool_cfg.parity_chunks) },
{ "used_raw", (uint64_t)(pool_stats[pool_cfg.id]["used_raw_tb"].number_value() * (1l<<40)) }, { "used_raw", (uint64_t)(pool_stats[pool_cfg.id]["used_raw_tb"].number_value() * ((uint64_t)1<<40)) },
{ "total_raw", (uint64_t)(pool_stats[pool_cfg.id]["total_raw_tb"].number_value() * (1l<<40)) }, { "total_raw", (uint64_t)(pool_stats[pool_cfg.id]["total_raw_tb"].number_value() * ((uint64_t)1<<40)) },
{ "max_available", pool_avail }, { "max_available", pool_avail },
{ "raw_to_usable", pool_stats[pool_cfg.id]["raw_to_usable"].number_value() }, { "raw_to_usable", pool_stats[pool_cfg.id]["raw_to_usable"].number_value() },
{ "space_efficiency", pool_stats[pool_cfg.id]["space_efficiency"].number_value() }, { "space_efficiency", pool_stats[pool_cfg.id]["space_efficiency"].number_value() },

View File

@ -436,8 +436,8 @@ std::string print_table(json11::Json items, json11::Json header, bool use_esc)
return str; return str;
} }
static uint64_t size_thresh[] = { 1024l*1024*1024*1024, 1024l*1024*1024, 1024l*1024, 1024, 0 }; static uint64_t size_thresh[] = { (uint64_t)1024*1024*1024*1024, (uint64_t)1024*1024*1024, (uint64_t)1024*1024, 1024, 0 };
static uint64_t size_thresh_d[] = { 1000000000000l, 1000000000l, 1000000l, 1000l, 0 }; static uint64_t size_thresh_d[] = { (uint64_t)1000000000000, (uint64_t)1000000000, (uint64_t)1000000, (uint64_t)1000, 0 };
static const int size_thresh_n = sizeof(size_thresh)/sizeof(size_thresh[0]); static const int size_thresh_n = sizeof(size_thresh)/sizeof(size_thresh[0]);
static const char *size_unit = "TGMKB"; static const char *size_unit = "TGMKB";

View File

@ -193,7 +193,7 @@ std::function<bool(void)> cli_tool_t::start_rm(json11::Json cfg)
remover->pool_id = cfg["pool"].uint64_value(); remover->pool_id = cfg["pool"].uint64_value();
if (remover->pool_id) if (remover->pool_id)
{ {
remover->inode = (remover->inode & ((1l << (64-POOL_ID_BITS)) - 1)) | (((uint64_t)remover->pool_id) << (64-POOL_ID_BITS)); remover->inode = (remover->inode & (((uint64_t)1 << (64-POOL_ID_BITS)) - 1)) | (((uint64_t)remover->pool_id) << (64-POOL_ID_BITS));
} }
remover->pool_id = INODE_POOL(remover->inode); remover->pool_id = INODE_POOL(remover->inode);
if (!remover->pool_id) if (!remover->pool_id)

View File

@ -968,7 +968,7 @@ void etcd_state_client_t::parse_state(const etcd_kv_t & kv)
{ {
fprintf( fprintf(
stderr, "Inode %lu/%lu parent_pool value is invalid, ignoring parent setting\n", stderr, "Inode %lu/%lu parent_pool value is invalid, ignoring parent setting\n",
inode_num >> (64-POOL_ID_BITS), inode_num & ((1l << (64-POOL_ID_BITS)) - 1) inode_num >> (64-POOL_ID_BITS), inode_num & (((uint64_t)1 << (64-POOL_ID_BITS)) - 1)
); );
parent_inode_num = 0; parent_inode_num = 0;
} }

View File

@ -214,14 +214,14 @@ static int sec_setup(struct thread_data *td)
if (!o->image) if (!o->image)
{ {
if (!(o->inode & ((1l << (64-POOL_ID_BITS)) - 1))) if (!(o->inode & (((uint64_t)1 << (64-POOL_ID_BITS)) - 1)))
{ {
td_verror(td, EINVAL, "inode number is missing"); td_verror(td, EINVAL, "inode number is missing");
return 1; return 1;
} }
if (o->pool) if (o->pool)
{ {
o->inode = (o->inode & ((1l << (64-POOL_ID_BITS)) - 1)) | (o->pool << (64-POOL_ID_BITS)); o->inode = (o->inode & (((uint64_t)1 << (64-POOL_ID_BITS)) - 1)) | (o->pool << (64-POOL_ID_BITS));
} }
if (!(o->inode >> (64-POOL_ID_BITS))) if (!(o->inode >> (64-POOL_ID_BITS)))
{ {

View File

@ -189,7 +189,7 @@ public:
uint64_t pool = cfg["pool"].uint64_value(); uint64_t pool = cfg["pool"].uint64_value();
if (pool) if (pool)
{ {
inode = (inode & ((1l << (64-POOL_ID_BITS)) - 1)) | (pool << (64-POOL_ID_BITS)); inode = (inode & (((uint64_t)1 << (64-POOL_ID_BITS)) - 1)) | (pool << (64-POOL_ID_BITS));
} }
if (!(inode >> (64-POOL_ID_BITS))) if (!(inode >> (64-POOL_ID_BITS)))
{ {

View File

@ -189,7 +189,7 @@ void osd_t::report_statistics()
for (auto kv: bs->get_inode_space_stats()) for (auto kv: bs->get_inode_space_stats())
{ {
pool_id_t pool_id = INODE_POOL(kv.first); pool_id_t pool_id = INODE_POOL(kv.first);
uint64_t only_inode_num = (kv.first & ((1l << (64-POOL_ID_BITS)) - 1)); uint64_t only_inode_num = (kv.first & (((uint64_t)1 << (64-POOL_ID_BITS)) - 1));
if (!last_pool || pool_id != last_pool) if (!last_pool || pool_id != last_pool)
{ {
if (last_pool) if (last_pool)
@ -207,7 +207,7 @@ void osd_t::report_statistics()
for (auto kv: inode_stats) for (auto kv: inode_stats)
{ {
pool_id_t pool_id = INODE_POOL(kv.first); pool_id_t pool_id = INODE_POOL(kv.first);
uint64_t only_inode_num = (kv.first & ((1l << (64-POOL_ID_BITS)) - 1)); uint64_t only_inode_num = (kv.first & (((uint64_t)1 << (64-POOL_ID_BITS)) - 1));
if (!last_pool || pool_id != last_pool) if (!last_pool || pool_id != last_pool)
{ {
if (last_pool) if (last_pool)

View File

@ -9,7 +9,7 @@
#define POOL_ID_MAX 0x10000 #define POOL_ID_MAX 0x10000
#define POOL_ID_BITS 16 #define POOL_ID_BITS 16
#define INODE_POOL(inode) (pool_id_t)((inode) >> (64 - POOL_ID_BITS)) #define INODE_POOL(inode) (pool_id_t)((inode) >> (64 - POOL_ID_BITS))
#define INODE_NO_POOL(inode) (inode_t)(inode & ((1l << (64-POOL_ID_BITS)) - 1)) #define INODE_NO_POOL(inode) (inode_t)(inode & (((uint64_t)1 << (64-POOL_ID_BITS)) - 1))
#define INODE_WITH_POOL(pool_id, inode) (((inode_t)(pool_id) << (64-POOL_ID_BITS)) | INODE_NO_POOL(inode)) #define INODE_WITH_POOL(pool_id, inode) (((inode_t)(pool_id) << (64-POOL_ID_BITS)) | INODE_NO_POOL(inode))
// Pool ID is 16 bits long // Pool ID is 16 bits long

View File

@ -437,7 +437,7 @@ void pg_t::calc_object_states(int log_level)
st.walk(); st.walk();
if (this->state & (PG_DEGRADED|PG_LEFT_ON_DEAD)) if (this->state & (PG_DEGRADED|PG_LEFT_ON_DEAD))
{ {
assert(epoch != ((1ul << PG_EPOCH_BITS)-1)); assert(epoch != (((uint64_t)1 << PG_EPOCH_BITS)-1));
epoch++; epoch++;
} }
} }

View File

@ -144,9 +144,9 @@ resume_3:
} }
else else
{ {
if ((op_data->fact_ver & (1ul<<(64-PG_EPOCH_BITS) - 1)) == (1ul<<(64-PG_EPOCH_BITS) - 1)) if ((op_data->fact_ver & ((uint64_t)1 << (64-PG_EPOCH_BITS) - 1)) == ((uint64_t)1 << (64-PG_EPOCH_BITS) - 1))
{ {
assert(pg.epoch != ((1ul << PG_EPOCH_BITS)-1)); assert(pg.epoch != (((uint64_t)1 << PG_EPOCH_BITS)-1));
pg.epoch++; pg.epoch++;
} }
op_data->target_ver = op_data->fact_ver + 1; op_data->target_ver = op_data->fact_ver + 1;

View File

@ -262,7 +262,7 @@ static int vitastor_file_open(BlockDriverState *bs, QDict *options, int flags, E
client->pool = qdict_get_try_int(options, "pool", 0); client->pool = qdict_get_try_int(options, "pool", 0);
if (client->pool) if (client->pool)
{ {
client->inode = (client->inode & ((1l << (64-POOL_ID_BITS)) - 1)) | (client->pool << (64-POOL_ID_BITS)); client->inode = (client->inode & (((uint64_t)1 << (64-POOL_ID_BITS)) - 1)) | (client->pool << (64-POOL_ID_BITS));
} }
client->size = qdict_get_try_int(options, "size", 0); client->size = qdict_get_try_int(options, "size", 0);
} }

View File

@ -406,7 +406,7 @@ uint64_t crush(uint64_t key, int count, uint64_t *weights)
seed = (key + 0xc6a4a7935bd1e995 + (seed << 6) + (seed >> 2)); seed = (key + 0xc6a4a7935bd1e995 + (seed << 6) + (seed >> 2));
seed ^= (j + 0xc6a4a7935bd1e995 + (seed << 6) + (seed >> 2)); seed ^= (j + 0xc6a4a7935bd1e995 + (seed << 6) + (seed >> 2));
seed = 2862933555777941757ull*seed + 3037000493ull; // LCPRNG seed = 2862933555777941757ull*seed + 3037000493ull; // LCPRNG
seed = -log(((double)seed) / (1ul << 32) / (1ul << 32)) * weights[j]; seed = -log(((double)seed) / ((uint64_t)1 << 32) / ((uint64_t)1 << 32)) * weights[j];
if (seed > max) if (seed > max)
{ {
max = seed; max = seed;
@ -439,8 +439,8 @@ void crush3(uint64_t key, int count, uint64_t *weights, uint64_t *r, uint64_t to
seed ^= (k2 + 0xc6a4a7935bd1e995 + (seed << 6) + (seed >> 2)); seed ^= (k2 + 0xc6a4a7935bd1e995 + (seed << 6) + (seed >> 2));
seed ^= (k3 + 0xc6a4a7935bd1e995 + (seed << 6) + (seed >> 2)); seed ^= (k3 + 0xc6a4a7935bd1e995 + (seed << 6) + (seed >> 2));
seed = 2862933555777941757ull*seed + 3037000493ull; // LCPRNG seed = 2862933555777941757ull*seed + 3037000493ull; // LCPRNG
//seed = ((double)seed) / (1ul << 32) / (1ul << 32) * (weights[k1] + weights[k2] + weights[k3]); //seed = ((double)seed) / ((uint64_t)1 << 32) / ((uint64_t)1 << 32) * (weights[k1] + weights[k2] + weights[k3]);
seed = ((double)seed) / (1ul << 32) / (1ul << 32) * (1 - seed = ((double)seed) / ((uint64_t)1 << 32) / ((uint64_t)1 << 32) * (1 -
(1 - 1.0*weights[k1]/total_weight)* (1 - 1.0*weights[k1]/total_weight)*
(1 - 1.0*weights[k2]/total_weight)* (1 - 1.0*weights[k2]/total_weight)*
(1 - 1.0*weights[k3]/total_weight) (1 - 1.0*weights[k3]/total_weight)