31 #define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_LIB 62 for (
i = 0;
i <
vec->v_nr; ++
i)
63 if (
vec->v_count[
i] > 0)
73 cur->vc_seg <=
cur->vc_vec->v_nr &&
75 cur->vc_offset <
cur->vc_vec->v_count[
cur->vc_seg]) &&
85 while (
cur->vc_seg <
cur->vc_vec->v_nr &&
86 cur->vc_vec->v_count[
cur->vc_seg] == 0) {
108 while (
count > 0 &&
cur->vc_seg <
cur->vc_vec->v_nr) {
122 return cur->vc_seg ==
cur->vc_vec->v_nr;
129 return cur->vc_vec->v_count[
cur->vc_seg] -
cur->vc_offset;
165 bufvec->
ov_buf[0] = (
void*)1;
176 for (
i = 0;
i < num_segs; ++
i) {
232 void **new_buf_arr =
NULL;
233 uint32_t new_num_segs;
244 new_num_segs = bufvec->
ov_vec.
v_nr + num_segs;
246 if (new_seg_count_arr ==
NULL)
248 memcpy(new_seg_count_arr,
250 bufvec->
ov_vec.
v_nr *
sizeof(new_seg_count_arr[0]));
252 if (new_buf_arr ==
NULL)
256 bufvec->
ov_vec.
v_nr *
sizeof(new_buf_arr[0]));
259 if (new_buf_arr[
i] ==
NULL)
266 bufvec->
ov_buf = new_buf_arr;
297 if (new_v_count ==
NULL)
301 if (new_buf ==
NULL) {
322 dst_bufvec->
ov_buf = new_buf;
340 for (
i = 0;
i < num_segs; ++
i) {
384 if (bufvec !=
NULL) {
416 else if (bufvec !=
NULL) {
463 for (j =
i + 1; j <
nr; ++j) {
464 seg_end = idx[
i] +
cnt[
i];
465 if (idx[j] <= seg_end) {
466 if (
cnt[j] > seg_end - idx[j])
467 cnt[
i] +=
cnt[j] - (seg_end - idx[j]);
629 frag_size =
min_check(frag_size, num_bytes);
632 num_bytes -= frag_size;
633 bytes_copied += frag_size;
667 for (
i = 0;
i < frag_size;
i++) {
741 return ivec->
iv_index[
cur->ic_cur.vc_seg] +
cur->ic_cur.vc_offset;
778 i =
cur->ic_cur.vc_seg;
787 if (idx +
cnt > max_seg_end)
788 max_seg_end = idx +
cnt;
805 return ((uint64_t)
addr & M0_0VEC_MASK) == 0;
866 for (
i = 0;
i <
src->ov_vec.v_nr; ++
i) {
889 M0_PRE(segs_nr <= zvec->z_bvec.ov_vec.v_nr);
893 for (
i = 0;
i < segs_nr; ++
i) {
1031 out->iv_vec.v_count[
nr] =
cnt >> bshift;
1079 for (
i = 0;
i < wire_ivec->
ci_nr; ++
i) {
1108 for (
i = 0;
i < wire_ivec->
ci_nr; ++
i) {
1204 (
unsigned long long)
count);
1209 if (
count >= step) {
1245 return *v_index +
cur->vc_offset;
1285 max_seg_end = *idx + *
cnt;
1287 for (
i += 1;
i <
cur->vc_ivv->iv_nr;
i++) {
1293 if (*idx + *
cnt > max_seg_end)
1294 max_seg_end = *idx + *
cnt;
1312 (
size_t)
buf->b_nob));
1326 (
size_t)
buf->b_nob));
1329 #undef M0_TRACE_SUBSYSTEM static m0_bcount_t seg_size
M0_INTERNAL m0_bcount_t m0_bufvec_copy(struct m0_bufvec *dst, struct m0_bufvec *src, m0_bcount_t num_bytes)
static void m0_vec_cursor_normalize(struct m0_vec_cursor *cur)
#define M0_BUFVEC_INIT_BUF(addr_ptr, count_ptr)
M0_INTERNAL int m0_0vec_init(struct m0_0vec *zvec, uint32_t segs_nr)
M0_INTERNAL void m0_ivec_cursor_init(struct m0_ivec_cursor *cur, const struct m0_indexvec *ivec)
M0_INTERNAL int m0_bufvec_to_buf_copy(struct m0_buf *buf, const struct m0_bufvec *bvec)
M0_INTERNAL bool m0_ivec_varr_cursor_move_to(struct m0_ivec_varr_cursor *cur, m0_bindex_t dest)
#define M0_ALLOC_ARR(arr, nr)
M0_INTERNAL int m0_bufvec_alloc_aligned_packed(struct m0_bufvec *bufvec, uint32_t num_segs, m0_bcount_t seg_size, unsigned shift)
M0_INTERNAL int m0_indexvec_alloc(struct m0_indexvec *ivec, uint32_t len)
static int(* diff[M0_PARITY_CAL_ALGO_NR])(struct m0_parity_math *math, struct m0_buf *old, struct m0_buf *new, struct m0_buf *parity, uint32_t index)
M0_INTERNAL void m0_0vec_fini(struct m0_0vec *zvec)
M0_INTERNAL m0_bcount_t m0_ivec_cursor_step(const struct m0_ivec_cursor *cur)
M0_INTERNAL int m0_buf_to_bufvec_copy(struct m0_bufvec *bvec, const struct m0_buf *buf)
static struct buffer * cur(struct m0_addb2_mach *mach, m0_bcount_t space)
M0_INTERNAL m0_bindex_t m0_ivec_cursor_conti(const struct m0_ivec_cursor *cur, m0_bindex_t dest)
static void m0_bufvec__free(struct m0_bufvec *bufvec, bool free_bufs)
static struct io_request req
M0_INTERNAL int m0_bufvec_splice(const struct m0_bufvec *bvec, m0_bcount_t nr, struct m0_buf *buf)
#define M0_LOG(level,...)
M0_INTERNAL uint32_t m0_bufvec_pack(struct m0_bufvec *bv)
static uint32_t vec_pack(uint32_t nr, m0_bcount_t *cnt, m0_bindex_t *idx)
static m0_bcount_t vec_count(const struct m0_vec *vec, uint32_t i)
M0_INTERNAL void m0_0vec_bvec_init(struct m0_0vec *zvec, const struct m0_bufvec *src, const m0_bindex_t *index)
M0_INTERNAL int m0_bufvec_merge(struct m0_bufvec *dst_bufvec, struct m0_bufvec *src_bufvec)
static struct m0_uint128 prefix
M0_INTERNAL m0_bindex_t m0_ivec_varr_cursor_conti(const struct m0_ivec_varr_cursor *cur, m0_bindex_t dest)
M0_INTERNAL m0_bcount_t m0_ivec_varr_cursor_step(const struct m0_ivec_varr_cursor *cur)
M0_INTERNAL m0_bcount_t m0_vec_cursor_end(const struct m0_vec_cursor *cur)
M0_INTERNAL void m0_indexvec_free(struct m0_indexvec *ivec)
M0_INTERNAL void m0_free_aligned(void *data, size_t size, unsigned shift)
static void pack(struct m0_addb2_mach *mach)
M0_INTERNAL void * m0_bufvec_cursor_addr(struct m0_bufvec_cursor *cur)
#define container_of(ptr, type, member)
M0_INTERNAL int m0_data_to_bufvec_copy(struct m0_bufvec_cursor *cur, void *data, size_t len)
static bool m0_vec_cursor_invariant(const struct m0_vec_cursor *cur)
M0_INTERNAL bool m0_ivec_cursor_move_to(struct m0_ivec_cursor *cur, m0_bindex_t dest)
M0_INTERNAL int m0_bufvec_extend(struct m0_bufvec *bufvec, uint32_t num_segs)
M0_INTERNAL int m0_bufvec_cursor_cmp(struct m0_bufvec_cursor *c0, struct m0_bufvec_cursor *c1)
M0_INTERNAL int m0_bufvec_alloc_aligned(struct m0_bufvec *bufvec, uint32_t num_segs, m0_bcount_t seg_size, unsigned shift)
M0_INTERNAL int m0_bufvec_alloc(struct m0_bufvec *bufvec, uint32_t num_segs, m0_bcount_t seg_size)
M0_INTERNAL void * bufvec_cursor_addr(struct m0_bufvec_cursor *cur)
#define M0_ASSERT_EX(cond)
M0_INTERNAL int m0_pagesize_get(void)
M0_INTERNAL void m0_bufvec_free(struct m0_bufvec *bufvec)
M0_INTERNAL bool m0_bufvec_cursor_move(struct m0_bufvec_cursor *cur, m0_bcount_t count)
M0_INTERNAL int m0_bufvec_to_data_copy(struct m0_bufvec_cursor *cur, void *data, size_t len)
M0_INTERNAL int m0_indexvec_varr_alloc(struct m0_indexvec_varr *ivec, uint32_t len)
M0_INTERNAL m0_bcount_t m0_bufvec_cursor_copyfrom(struct m0_bufvec_cursor *scur, void *ddata, m0_bcount_t num_bytes)
M0_INTERNAL bool m0_vec_is_empty(const struct m0_vec *vec)
#define M0_BUFVEC_ENDFOR2
return M0_ERR(-EOPNOTSUPP)
#define M0_AMB(obj, ptr, field)
M0_INTERNAL m0_bindex_t m0_ivec_varr_cursor_index(const struct m0_ivec_varr_cursor *cur)
M0_INTERNAL int m0_dont_dump(void *p, size_t size)
M0_INTERNAL m0_bcount_t m0_bufvec_cursor_copy(struct m0_bufvec_cursor *dcur, struct m0_bufvec_cursor *scur, m0_bcount_t num_bytes)
M0_INTERNAL void m0_vec_cursor_init(struct m0_vec_cursor *cur, const struct m0_vec *vec)
M0_INTERNAL m0_bcount_t m0_bufvec_cursor_step(const struct m0_bufvec_cursor *cur)
M0_INTERNAL uint64_t m0_varr_size(const struct m0_varr *arr)
static struct m0_bufvec bvec
M0_INTERNAL int m0_indexvec_wire2mem(struct m0_io_indexvec *wire_ivec, int max_frags_nr, uint32_t bshift, struct m0_indexvec *mem_ivec)
M0_INTERNAL int m0_varr_init(struct m0_varr *arr, uint64_t nr, size_t size, size_t bufsize)
M0_INTERNAL void m0_bufvec_cursor_init(struct m0_bufvec_cursor *cur, const struct m0_bufvec *bvec)
M0_INTERNAL void bufvec_free_aligned(struct m0_bufvec *bufvec, unsigned shift, bool pack)
M0_INTERNAL int m0_buf_alloc(struct m0_buf *buf, size_t size)
void * m0_alloc(size_t size)
static int bufvec_alloc(struct m0_bufvec *bufvec, uint32_t num_segs, m0_bcount_t seg_size, unsigned shift, bool pack)
m0_bcount_t counts[SEGS_NR]
M0_INTERNAL int m0_0vec_cbuf_add(struct m0_0vec *zvec, const struct m0_buf *buf, const m0_bindex_t *index)
static bool m0_0vec_invariant(const struct m0_0vec *zvec)
static m0_bindex_t offset
M0_INTERNAL bool m0_ivec_cursor_move(struct m0_ivec_cursor *cur, m0_bcount_t count)
static uint64_t min64u(uint64_t a, uint64_t b)
static void m0_ivec_varr_cursor_normalize(struct m0_ivec_varr_cursor *cur)
M0_INTERNAL void m0_indexvec_varr_free(struct m0_indexvec_varr *ivec)
M0_INTERNAL void m0_bufvec_free_aligned(struct m0_bufvec *bufvec, unsigned shift)
M0_INTERNAL m0_bcount_t m0_vec_count(const struct m0_vec *vec)
#define m0_forall(var, nr,...)
M0_INTERNAL uint32_t m0_indexvec_pack(struct m0_indexvec *iv)
static bool addr_is_4k_aligned(void *addr)
M0_INTERNAL void m0_ivec_varr_cursor_init(struct m0_ivec_varr_cursor *cur, struct m0_indexvec_varr *ivec)
static uint8_t fail[DATA_UNIT_COUNT_MAX+PARITY_UNIT_COUNT_MAX]
static long long min(long long a, long long b)
M0_INTERNAL int m0_indexvec_split(struct m0_indexvec *in, m0_bcount_t curr_pos, m0_bcount_t nb_len, uint32_t bshift, struct m0_indexvec *out)
M0_INTERNAL m0_bcount_t m0_vec_cursor_step(const struct m0_vec_cursor *cur)
M0_INTERNAL void m0_varr_fini(struct m0_varr *arr)
#define M0_FI_ENABLED(tag)
M0_INTERNAL m0_bcount_t m0_bufvec_cursor_prefix(struct m0_bufvec_cursor *c0, struct m0_bufvec_cursor *c1)
M0_INTERNAL int m0_indexvec_mem2wire(struct m0_indexvec *mem_ivec, int max_frags_nr, uint32_t bshift, struct m0_io_indexvec *wire_ivec)
M0_INTERNAL bool m0_bufvec_cursor_align(struct m0_bufvec_cursor *cur, uint64_t alignment)
M0_INTERNAL int m0__bufvec_dont_dump(struct m0_bufvec *bufvec)
M0_INTERNAL int m0_indexvec_universal_set(struct m0_indexvec *iv)
M0_INTERNAL bool m0_vec_cursor_move(struct m0_vec_cursor *cur, m0_bcount_t count)
M0_INTERNAL m0_bcount_t m0_io_count(const struct m0_io_indexvec *io_info)
M0_INTERNAL m0_bcount_t m0_bufvec_cursor_copyto(struct m0_bufvec_cursor *dcur, void *sdata, m0_bcount_t num_bytes)
M0_INTERNAL m0_bindex_t m0_ivec_cursor_index(const struct m0_ivec_cursor *cur)
m0_bindex_t z_last_buf_idx
M0_BASSERT(M0_SEG_SIZE==M0_0VEC_ALIGN)
M0_INTERNAL bool m0_indexvec_is_universal(const struct m0_indexvec *iv)
M0_INTERNAL void m0_bufvec_free_aligned_packed(struct m0_bufvec *bufvec, unsigned shift)
static uint32_t ivec_nr_or_prepare(struct m0_indexvec *in, m0_bcount_t offset, int req, uint32_t bshift, struct m0_indexvec *out)
M0_INTERNAL void m0_0vec_bufs_init(struct m0_0vec *zvec, void **bufs, const m0_bindex_t *index, const m0_bcount_t *counts, uint32_t segs_nr)
M0_INTERNAL void * m0_alloc_aligned(size_t size, unsigned shift)
const struct m0_vec * vc_vec
static int m0__bufvec_alloc(struct m0_bufvec *bufvec, uint32_t num_segs, m0_bcount_t seg_size, unsigned shift)
static void data_to_bufvec(struct m0_bufvec *src_buf, void **data, size_t *len)
struct m0_ioseg * ci_iosegs
struct m0_pdclust_src_addr src
M0_INTERNAL void m0_bufvec_free2(struct m0_bufvec *bufvec)
static uint64_t m0_align(uint64_t val, uint64_t alignment)
#define M0_BUFVEC_FOR2(c0, c1, frag)
M0_INTERNAL bool m0_ivec_varr_cursor_move(struct m0_ivec_varr_cursor *cur, m0_bcount_t count)
M0_INTERNAL int m0_bufvec_empty_alloc(struct m0_bufvec *bufvec, uint32_t num_segs)
M0_INTERNAL void * m0_varr_ele_get(struct m0_varr *arr, uint64_t index)