23 #define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_UT 44 struct m0_be_log_store_io {
54 BE_UT_LOG_STOR_SIZE = 0x100,
55 BE_UT_LOG_STOR_STEP = 0xF,
56 BE_UT_LOG_STOR_ITER = 0x200,
57 BE_UT_LOG_STOR_CR_NR = 0x7,
60 static char be_ut_log_store_pre[BE_UT_LOG_STOR_SIZE];
61 static char be_ut_log_store_post[BE_UT_LOG_STOR_SIZE];
62 static uint64_t be_ut_log_store_seed;
66 static int be_ut_log_store_rand(
int mod)
68 return m0_rnd64(&be_ut_log_store_seed) % mod;
94 int buf[BE_UT_LOG_STOR_CR_NR];
109 static void be_ut_log_store_io_write_sync(
struct m0_be_io *bio)
121 struct m0_be_log_store_io lsi;
131 char rbuf[BE_UT_LOG_STOR_SIZE];
136 rbuf[
i] = be_ut_log_store_rand(0x100);
138 cblock_size = be_ut_log_store_rand(
size - 1) + 1;
143 be_ut_log_store_rand_cr(&io_cr_log,
data_size);
144 m0_be_log_store_cblock_io_credit(&io_cr_log_cblock, cblock_size);
155 m0_be_log_store_io_init(&lsi,
ls, &io_log, &io_log_cblock,
size);
158 be_ut_log_store_io_read(
ls, be_ut_log_store_pre,
161 m0_be_log_store_io_add(&lsi, rbuf,
data_size);
162 m0_be_log_store_io_add_cblock(&lsi, &rbuf[
data_size], cblock_size);
163 m0_be_log_store_io_sort(&lsi);
164 m0_be_log_store_io_fini(&lsi);
165 be_ut_log_store_io_write_sync(&io_log);
166 be_ut_log_store_io_write_sync(&io_log_cblock);
169 be_ut_log_store_pre[(be_ut_log_store_pos +
i) %
170 BE_UT_LOG_STOR_SIZE] = rbuf[
i];
172 be_ut_log_store_pos +=
size;
174 be_ut_log_store_io_read(
ls, be_ut_log_store_post,
176 cmp = memcmp(be_ut_log_store_pre, be_ut_log_store_post,
size);
188 struct m0_be_log_store_io lsi = {};
202 m0_be_log_store_io_init(&lsi,
ls, &io_log, &io_log_cblock,
size);
203 m0_be_log_store_io_fini(&lsi);
211 static void be_ut_log_store(
bool fake_io)
223 m0_be_log_store_init(&
ls,
stob);
229 be_ut_log_store_seed = 0;
230 be_ut_log_store_pos = 0;
231 for (step = 2; step <= BE_UT_LOG_STOR_STEP; ++step) {
232 for (
i = 0;
i < BE_UT_LOG_STOR_ITER; ++
i) {
234 if (
used + step <= log_size) {
235 rc = m0_be_log_store_reserve(&
ls, step);
239 be_ut_log_store_io_check_nop(&
ls, step);
241 be_ut_log_store_io_check(&
ls, step);
244 rc = m0_be_log_store_reserve(&
ls, step);
246 m0_be_log_store_discard(&
ls, step);
251 m0_be_log_store_discard(&
ls,
used);
254 m0_be_log_store_fini(&
ls);
268 #define BE_UT_LOG_STORE_SDOM_INIT_CFG "directio=true" 279 .lsc_stob_domain_key = 0x1000,
280 .lsc_stob_domain_create_cfg =
NULL,
283 .lsc_stob_create_cfg =
NULL,
287 #undef BE_UT_LOG_STORE_SDOM_INIT_CFG 328 M0_LOG(
M0_DEBUG,
"open() should fail for non-existent log_store");
333 M0_LOG(
M0_DEBUG,
"create() should succeed for non-existent log_store");
347 M0_LOG(
M0_DEBUG,
"create() should fail after successful create()");
387 &ls_cfg[
i].lsc_stob_id);
406 m0_free(ls_cfg[
i].lsc_stob_domain_location);
430 for (
i = 0;
i < 2; ++
i) {
518 for (
i = 1;
i <
nr; ++
i) {
522 }
while (io_length[
index] < 2);
525 io_length[
index] -= delta;
526 io_length[
i] = delta;
541 for (
i = 0;
i <
nr; ++
i)
542 for (j =
i + 1; j <
nr; ++j) {
557 unsigned char *
field;
566 uint64_t alignment = 1ULL << bshift;
577 lio_arr[
i] = &lio[
i];
581 for (
i = 0;
i < field_length; ++
i)
603 io_length[0] = length / alignment;
607 io_length[j] *= alignment;
614 io_offset[j] = io_offset[j - 1] + io_length[j - 1];
664 unsigned nr_lio_read = 0;
665 unsigned nr_lio_write;
673 for (
i = 0;
i < 2; ++
i) {
705 }
while (lio_r !=
NULL || lio_w !=
NULL);
741 #undef M0_TRACE_SUBSYSTEM static void be_ut_log_store_stob_domain_fini(struct m0_stob_domain *sdom)
M0_INTERNAL void m0_be_log_store_io_discard(struct m0_be_log_store *ls, m0_bindex_t offset, struct m0_be_op *op)
#define M0_ALLOC_ARR(arr, nr)
M0_INTERNAL m0_bcount_t m0_be_io_size(struct m0_be_io *bio)
static void be_ut_log_store_length_generate(m0_bcount_t *io_length, unsigned nr, uint64_t *seed)
M0_INTERNAL void m0_be_log_store_close(struct m0_be_log_store *ls)
static void be_ut_log_store_stob_domain_init(struct m0_stob_domain **sdom)
M0_INTERNAL int m0_be_log_store_open(struct m0_be_log_store *ls, struct m0_be_log_store_cfg *ls_cfg)
char * lsc_stob_domain_location
static void be_ut_log_store_test(void(*func)(struct m0_be_log_store *ls, bool first_run))
#define M0_LOG(level,...)
static void be_ut_log_store_io_translate(struct m0_be_log_store *ls, bool first_run)
M0_INTERNAL const struct m0_fid * m0_stob_domain_id_get(const struct m0_stob_domain *dom)
M0_INTERNAL int m0_stob_domain_destroy(struct m0_stob_domain *dom)
#define M0_BE_OP_SYNC(op_obj, action)
M0_INTERNAL void m0_free_aligned(void *data, size_t size, unsigned shift)
#define BE_UT_LOG_STORE_SDOM_INIT_CFG
M0_INTERNAL struct m0_be_log_io * m0_be_log_store_rbuf_io_first(struct m0_be_log_store *ls, enum m0_be_log_store_io_type io_type, struct m0_be_op **op, unsigned *iter)
M0_INTERNAL uint64_t m0_round_down(uint64_t val, uint64_t size)
uint64_t lsc_stob_domain_key
M0_INTERNAL struct m0_be_io * m0_be_log_io_be_io(struct m0_be_log_io *lio)
M0_INTERNAL void m0_be_io_configure(struct m0_be_io *bio, enum m0_stob_io_opcode opcode)
static void be_ut_log_store_io_intersect_check(struct m0_be_log_io **lio, unsigned nr)
M0_INTERNAL void m0_be_log_store_io_translate(struct m0_be_log_store *ls, m0_bindex_t position, struct m0_be_io *bio)
M0_INTERNAL struct m0_stob * m0_ut_stob_linux_get(void)
M0_INTERNAL void m0_be_io_add_nostob(struct m0_be_io *bio, void *ptr_user, m0_bindex_t offset_stob, m0_bcount_t size)
M0_INTERNAL int m0_stob_domain_create(const char *location, const char *str_cfg_init, uint64_t dom_key, const char *str_cfg_create, struct m0_stob_domain **out)
M0_INTERNAL void m0_be_io_fini(struct m0_be_io *bio)
static struct m0_stob * stob
static int field(struct ff2c_context *ctx, struct ff2c_term *term)
M0_INTERNAL void m0_be_io_credit_add(struct m0_be_io_credit *iocred0, const struct m0_be_io_credit *iocred1)
M0_INTERNAL void m0_be_log_io_deallocate(struct m0_be_log_io *lio)
M0_INTERNAL struct m0_be_log_io * m0_be_log_store_rbuf_io_next(struct m0_be_log_store *ls, enum m0_be_log_store_io_type io_type, struct m0_be_op **op, unsigned *iter)
M0_INTERNAL bool m0_be_io_offset_stob_is_eq(const struct m0_be_io *bio1, const struct m0_be_io *bio2)
M0_INTERNAL void m0_stob_id_make(uint64_t container, uint64_t key, const struct m0_fid *dom_id, struct m0_stob_id *stob_id)
static void be_ut_log_store_io_discard(struct m0_be_log_store *ls, bool first_run)
M0_INTERNAL int m0_be_io_init(struct m0_be_io *bio)
static int cmp(const struct m0_ut_suite **s0, const struct m0_ut_suite **s1)
M0_INTERNAL bool m0_be_io_intersect(const struct m0_be_io *bio1, const struct m0_be_io *bio2)
void m0_be_ut_log_store_io_discard(void)
static m0_bindex_t offset
void m0_be_ut_log_store_create_random(void)
static void be_ut_log_store_io_window(struct m0_be_log_store *ls, bool first_run)
void m0_be_ut_log_store_rbuf(void)
#define M0_BE_IO_CREDIT(reg_nr, reg_size, part_nr)
static uint64_t data_size(const struct m0_pdclust_layout *play)
M0_INTERNAL void m0_ut_stob_put(struct m0_stob *stob, bool destroy)
static void be_ut_log_store_rbuf(struct m0_be_log_store *ls, bool first_run)
static const char * be_ut_log_store_sdom_create_cfg
M0_INTERNAL int m0_be_log_io_allocate(struct m0_be_log_io *lio, struct m0_be_io_credit *iocred, uint32_t log_bshift)
M0_INTERNAL int m0_stob_domain_destroy_location(const char *location)
M0_INTERNAL int m0_be_log_io_init(struct m0_be_log_io *lio)
void m0_be_ut_log_store_io_translate(void)
M0_INTERNAL bool m0_be_io_ptr_user_is_eq(const struct m0_be_io *bio1, const struct m0_be_io *bio2)
M0_INTERNAL uint64_t m0_rnd64(uint64_t *seed)
M0_INTERNAL int m0_be_io_allocate(struct m0_be_io *bio, struct m0_be_io_credit *iocred)
static struct m0_be_log_store_cfg be_ut_log_store_cfg
M0_INTERNAL void m0_be_io_deallocate(struct m0_be_io *bio)
M0_INTERNAL int m0_be_log_store_create(struct m0_be_log_store *ls, struct m0_be_log_store_cfg *ls_cfg)
static const char * be_ut_log_store_sdom_init_cfg
M0_INTERNAL void m0_be_log_store_io_credit(struct m0_be_log_store *ls, struct m0_be_io_credit *accum)
M0_INTERNAL void * m0_alloc_aligned(size_t size, unsigned shift)
M0_INTERNAL int m0_be_log_store_io_window(struct m0_be_log_store *ls, m0_bindex_t offset, m0_bcount_t *length)
M0_INTERNAL void m0_be_log_io_fini(struct m0_be_log_io *lio)
M0_INTERNAL void m0_be_io_add(struct m0_be_io *bio, struct m0_stob *stob, void *ptr_user, m0_bindex_t offset_stob, m0_bcount_t size)
M0_INTERNAL void m0_be_io_launch(struct m0_be_io *bio, struct m0_be_op *op)
M0_INTERNAL void m0_be_log_store_destroy(struct m0_be_log_store *ls)
static const char * be_ut_log_store_sdom_location
void m0_be_ut_log_store_create_simple(void)
M0_INTERNAL void m0_be_log_io_reset(struct m0_be_log_io *lio)
void m0_be_ut_log_store_io_window(void)
struct m0_stob_id lsc_stob_id
static struct m0_stob_domain * sdom
M0_INTERNAL uint32_t m0_be_log_store_bshift(struct m0_be_log_store *ls)