35 #include <linux/pagemap.h> 36 #include <linux/limits.h> 39 #define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_LIB 68 uint64_t target_idx, uint32_t
depth);
82 uint64_t start_index);
87 unsigned long obj_nr_in_1_cont,
88 uint8_t obj_nr_shift);
93 uint64_t carry, uint32_t
depth);
95 uint64_t carry, uint32_t
depth);
104 void *buff, uint32_t inc);
106 #define safe_bitshift(num, shift, operator) \ 108 uint8_t __shift = (shift); \ 109 typeof(num) __num = (num); \ 110 M0_ASSERT(__shift < CHAR_BIT * sizeof __num); \ 111 __num operator __shift; \ 139 m0_varr_bob_init(arr);
159 size_t aligned_num = 1;
160 uint8_t aligned_shift = 0;
164 while (
num > aligned_num) {
168 return aligned_shift;
179 unsigned long obj_nr_in_1_cont,
180 uint8_t obj_nr_shift)
183 M0_PRE(obj_nr_in_1_cont > 0);
186 buff_nr += (
nr & (obj_nr_in_1_cont - 1)) == 0 ? 0 : 1;
221 uint64_t total_leaves)
250 if (holder ==
NULL) {
273 M0_PRE(depth <= arr->va_depth);
334 uint64_t max_idx_in_level;
335 uint64_t idx_in_level;
338 M0_PRE(d <= cursor->vc_arr->va_depth);
342 target_idx = cursor->
vc_done + inc;
343 if (target_idx > max_idx_in_level)
345 else if (target_idx == cursor->
vc_done)
347 idx_in_level = pe->
vp_idx + inc;
348 while (d > 0 && idx_in_level >= pe->
vp_width) {
354 idx_in_level = pe->
vp_idx + inc;
358 pe->
vp_idx = idx_in_level;
359 while (d < cursor->vc_depth) {
389 uint64_t carry, uint32_t
depth)
392 M0_PRE(depth <= cursor->vc_arr->va_depth);
397 uint64_t carry, uint32_t
depth)
400 M0_PRE(depth <= cursor->vc_arr->va_depth);
407 M0_PRE(level <= arr->va_depth);
418 uint64_t target_idx, uint32_t
depth)
424 M0_PRE(depth <= arr->va_depth);
445 void *buff, uint32_t inc)
455 buff += inc*inc_unit;
477 if ((
void *)holder !=
NULL) {
493 m0_varr_bob_fini(arr);
500 return m0_varr_bob_check(arr) &&
523 holder = *(
void **)holder;
550 uint64_t index_in_level;
559 cache->vc_buff = holder;
560 cache->vc_first_index =
index - index_in_level;
573 #undef M0_TRACE_SUBSYSTEM M0_INTERNAL int m0_varr_cursor_init(struct m0_varr_cursor *cursor, const struct m0_varr *arr, uint32_t depth)
M0_INTERNAL uint64_t total_leaf_buffers(unsigned long nr, unsigned long obj_nr_in_1_cont, uint8_t obj_nr_shift)
void * va_tree[M0_VA_TNODE_NR]
enum m0_trace_level level
struct m0_varr_path_element vc_path[M0_VA_DEPTH_MAX]
M0_INTERNAL int m0_varr_cursor_move(struct m0_varr_cursor *cursor, uint64_t inc)
M0_INTERNAL uint64_t max_idx_within_level(const struct m0_varr_cursor *cursor, uint32_t depth)
M0_EXTERN void * m0_varr_buf_alloc(size_t bufsize)
struct varr_cache * va_cache
struct m0_conf_root * root
return M0_ERR(-EOPNOTSUPP)
M0_INTERNAL uint32_t index_within_level(const struct m0_varr *arr, uint64_t target_idx, uint32_t depth)
M0_INTERNAL const struct m0_bob_type varr_bobtype
M0_INTERNAL uint64_t m0_varr_size(const struct m0_varr *arr)
M0_INTERNAL uint8_t nearest_power_of_two(size_t num)
M0_EXTERN void m0_varr_buf_free(void *buf, size_t bufsize)
M0_INTERNAL void * m0_varr_cursor_get(struct m0_varr_cursor *cursor)
M0_INTERNAL int m0_varr_init(struct m0_varr *arr, uint64_t nr, size_t size, size_t bufsize)
M0_BOB_DEFINE(M0_INTERNAL, &varr_bobtype, m0_varr)
M0_INTERNAL uint32_t children_of_level(const struct m0_varr *arr, uint32_t level)
M0_INTERNAL void varr_buffers_dealloc(struct m0_varr *arr)
M0_INTERNAL int m0_varr_cursor_next(struct m0_varr_cursor *cursor)
static uint64_t min64u(uint64_t a, uint64_t b)
M0_INTERNAL int varr_buffers_alloc(struct m0_varr *arr)
M0_INTERNAL uint64_t inc_for_next_level(const struct m0_varr_cursor *cursor, uint64_t carry, uint32_t depth)
#define safe_bitshift(num, shift, operator)
uint32_t va_failure_depth
M0_INTERNAL void * buff_incr(const struct m0_varr *arr, uint32_t depth, void *buff, uint32_t inc)
M0_INTERNAL void m0_varr_fini(struct m0_varr *arr)
M0_INTERNAL uint32_t inc_to_idx_xlate(const struct m0_varr_cursor *cursor, uint64_t carry, uint32_t depth)
#define M0_ALLOC_PTR(ptr)
M0_INTERNAL bool varr_invariant(const struct m0_varr *arr)
M0_INTERNAL void * cache_fetch(const struct m0_varr *arr, uint64_t index)
uint8_t va_bufptr_nr_shift
M0_INTERNAL uint8_t log_radix(const struct m0_varr *arr, uint32_t level)
M0_INTERNAL uint64_t last_nbits_set(uint8_t n)
M0_INTERNAL unsigned long varr_obj_nr_in_buff(const struct m0_varr *arr)
M0_INTERNAL uint32_t depth_find(const struct m0_varr *arr, uint64_t buff_nr)
M0_INTERNAL void cache_update(struct m0_varr *arr, void *holder, uint64_t start_index)
#define offsetof(typ, memb)
M0_INTERNAL void * m0_varr_ele_get(struct m0_varr *arr, uint64_t index)