Motr  M0
dtm0_log_ut.c
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2013-2020 Seagate Technology LLC and/or its Affiliates
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * For any questions about this software or licensing,
18  * please email opensource@seagate.com or cortx-questions@seagate.com.
19  *
20  */
21 
22 #define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_DTM
23 #include "be/dtm0_log.h"
24 #include "be/list.h"
25 #include "be/tx.h"
26 #include "be/tx_credit.h"
27 #include "be/ut/helper.h"
28 #include "dtm0/clk_src.h"
29 #include "dtm0/tx_desc.h"
30 #include "lib/errno.h"
31 #include "lib/memory.h" /* m0_forall */
32 #include "lib/misc.h" /* m0_forall */
33 #include "lib/trace.h" /* M0_ENTRY */
34 #include "ut/ut.h" /* M0_UT_ASSERT */
35 
36 enum {
40 };
41 
42 /* p - participant, state_set, init, check */
43 
44 static void p_state_set(struct m0_dtm0_tx_pa *pa, uint32_t state)
45 {
46  pa->p_state = state;
47 }
48 
49 static void p_init(struct m0_dtm0_tx_pa *pa, int rand)
50 {
51  m0_fid_set(&pa->p_fid, rand + 1, rand + 1);
53 }
54 
55 static bool p_check(const struct m0_dtm0_tx_pa *pa, int rand)
56 {
57  struct m0_fid temp_fid;
58  m0_fid_set(&temp_fid, rand + 1, rand + 1);
59 
60  return m0_fid_cmp(&pa->p_fid, &temp_fid) == 0 &&
61  pa->p_state < M0_DTPS_NR &&
62  pa->p_state >= 0;
63 }
64 
65 /* tid - transaction id, init, check */
66 
67 static void tid_init(struct m0_dtm0_tid *tid, int rand)
68 {
69  m0_fid_set(&tid->dti_fid, rand + 1, rand + 1);
70  tid->dti_ts.dts_phys = rand + 1;
71 }
72 
73 static bool tid_check(const struct m0_dtm0_tid *tid, int rand)
74 {
75  struct m0_fid temp_fid;
76  m0_fid_set(&temp_fid, rand + 1, rand + 1);
77 
78  return (m0_fid_cmp(&tid->dti_fid, &temp_fid) == 0) &&
79  (tid->dti_ts.dts_phys == rand + 1);
80 }
81 
82 /* txd - transaction desc, init, fini, check */
83 
84 static int txd_init(struct m0_dtm0_tx_desc *txd, int rand)
85 {
86  int i;
87  int rc;
88 
90  if (rc != 0)
91  return rc;
92 
93  tid_init(&txd->dtd_id, rand);
94 
95  for (i = 0; i < txd->dtd_ps.dtp_nr; ++i)
96  p_init(&txd->dtd_ps.dtp_pa[i], rand);
97 
98  return rc;
99 }
100 
101 static void txd_fini(struct m0_dtm0_tx_desc *txd)
102 {
104 }
105 
106 static bool txd_check(const struct m0_dtm0_tx_desc *txd, int rand)
107 {
108  return tid_check(&txd->dtd_id, rand) &&
109  txd->dtd_ps.dtp_nr == UT_DTM0_LOG_MAX_PA &&
110  m0_forall(i, txd->dtd_ps.dtp_nr,
111  p_check(&txd->dtd_ps.dtp_pa[i], rand));
112 }
113 
114 static int ut_dl_init_buf(struct m0_buf *buf, int rand)
115 {
116  int rc;
118  if (rc != 0)
119  return rc;
120  memset(buf->b_addr, rand + 1, UT_DTM0_LOG_BUF_SIZE);
121  return rc;
122 }
123 
124 static void ut_dl_fini_buf(struct m0_buf *buf)
125 {
126  m0_buf_free(buf);
127 }
128 
129 static bool ut_dl_verify_buf(struct m0_buf *buf, int rand)
130 {
131  bool rc;
132  struct m0_buf temp_buf = {};
133 
134  M0_ASSERT(buf->b_nob > 0);
135  ut_dl_init_buf(&temp_buf, rand);
136  rc = m0_buf_eq(&temp_buf, buf);
137  m0_buf_free(&temp_buf);
138  return rc;
139 }
140 
141 static int ut_dl_init(struct m0_dtm0_tx_desc *txd, struct m0_buf *buf, int rand)
142 {
143  int rc;
144 
145  rc = txd_init(txd, rand);
146  if (rc != 0)
147  return rc;
148 
150  if (rc != 0)
152 
153  return rc;
154 }
155 
156 static void ut_dl_fini(struct m0_dtm0_tx_desc *txd, struct m0_buf *buf)
157 {
158  txd_fini(txd);
160 }
161 
162 static bool ut_dl_verify_log_rec(struct m0_dtm0_log_rec *rec, int rand)
163 {
164  return ut_dl_verify_buf(&rec->dlr_payload, rand) &&
165  txd_check(&rec->dlr_txd, rand);
166 }
167 
168 
170 {
171  int i;
172  int rc;
173  struct m0_dtm0_clk_src cs;
175  struct m0_dtm0_log_rec *rec[UT_DTM0_LOG_MAX_LOG_REC] = {};
176  struct m0_buf buf[UT_DTM0_LOG_MAX_LOG_REC] = {};
177  struct m0_buf empty_buf = {};
178  struct m0_be_dtm0_log *log = NULL;
179 
181 
182  rc = m0_be_dtm0_log_alloc(&log);
183  M0_UT_ASSERT(rc == 0);
184 
185  rc = m0_be_dtm0_log_init(log, NULL, &cs, false);
186  M0_UT_ASSERT(rc == 0);
187 
188  for (i = 0; i < UT_DTM0_LOG_MAX_LOG_REC; ++i) {
189  rc = ut_dl_init(&txd[i], &buf[i], i);
190  M0_UT_ASSERT(rc == 0);
191  }
192 
193  /* pa[0].st = EX pa[1].st = IP pa[2].st = IP, pyld = valid */
195  m0_mutex_lock(&log->dl_lock);
196  rc = m0_be_dtm0_log_update(log, NULL, &txd[0], &buf[0]);
197  M0_UT_ASSERT(rc == 0);
198  rec[0] = m0_be_dtm0_log_find(log, &txd[0].dtd_id);
199  M0_UT_ASSERT(rec[0] != NULL);
200  rc = ut_dl_verify_log_rec(rec[0], 0);
201  M0_UT_ASSERT(rc != 0);
202 
205  rc = m0_be_dtm0_log_update(log, NULL, &txd[0], &buf[0]);
206  M0_UT_ASSERT(rc == 0);
207  rec[0] = m0_be_dtm0_log_find(log, &txd[0].dtd_id);
208  M0_UT_ASSERT(rec[0] != NULL);
209  rc = ut_dl_verify_log_rec(rec[0], 0);
210  M0_UT_ASSERT(rc != 0);
211 
212  rc = m0_be_dtm0_log_prune(log, NULL, &txd[0].dtd_id);
213  M0_UT_ASSERT(rc == -EPROTO);
214 
216  rc = m0_be_dtm0_log_update(log, NULL, &txd[0], &buf[0]);
217  M0_UT_ASSERT(rc == 0);
218 
219  rc = m0_be_dtm0_log_prune(log, NULL, &txd[0].dtd_id);
220  M0_UT_ASSERT(rc == 0);
221 
222  rec[0] = m0_be_dtm0_log_find(log, &txd[0].dtd_id);
223  M0_UT_ASSERT(rec[0] == NULL);
224 
225  rc = m0_be_dtm0_log_prune(log, NULL, &txd[0].dtd_id);
226  M0_UT_ASSERT(rc == -ENOENT);
227 
231  rc = m0_be_dtm0_log_update(log, NULL, &txd[0], &empty_buf);
232  M0_UT_ASSERT(rc == 0);
233  rec[0] = m0_be_dtm0_log_find(log, &txd[0].dtd_id);
234  M0_UT_ASSERT(rec[0] != NULL);
235  //rc = ut_dl_verify_log_rec(rec[0], 0);
236  //M0_UT_ASSERT(rc != 0);
237 
240  rc = m0_be_dtm0_log_update(log, NULL, &txd[0], &buf[0]);
241  M0_UT_ASSERT(rc == 0);
242  rec[0] = m0_be_dtm0_log_find(log, &txd[0].dtd_id);
243  M0_UT_ASSERT(rec[0] != NULL);
244  rc = ut_dl_verify_log_rec(rec[0], 0);
245  M0_UT_ASSERT(rc != 0);
246  rc = m0_be_dtm0_log_prune(log, NULL, &txd[0].dtd_id);
247  M0_UT_ASSERT(rc == 0);
248  rec[0] = NULL;
249 
250  for (i = 0; i < UT_DTM0_LOG_MAX_LOG_REC; ++i) {
251  p_state_set(&txd[i].dtd_ps.dtp_pa[0],
253  p_state_set(&txd[i].dtd_ps.dtp_pa[1],
255  p_state_set(&txd[i].dtd_ps.dtp_pa[2],
257  rc = m0_be_dtm0_log_update(log, NULL, &txd[i], &buf[i]);
258  M0_UT_ASSERT(rc == 0);
259  rec[i] = m0_be_dtm0_log_find(log, &txd[i].dtd_id);
260  M0_UT_ASSERT(rec[i] != NULL);
261  rc = ut_dl_verify_log_rec(rec[i], i);
262  M0_UT_ASSERT(rc != 0);
263  rec[i] = NULL;
264  }
265 
266  rec[5] = m0_be_dtm0_log_find(log, &txd[5].dtd_id);
267  M0_UT_ASSERT(rec[5] != NULL);
268  rc = ut_dl_verify_log_rec(rec[5], 5);
269  M0_UT_ASSERT(rc != 0);
270  rec[5] = NULL;
271 
272  rc = m0_be_dtm0_log_prune(log, NULL, &txd[9].dtd_id);
273  M0_UT_ASSERT(rc == 0);
274  rec[9] = m0_be_dtm0_log_find(log, &txd[9].dtd_id);
275  M0_UT_ASSERT(rec[9] == NULL);
276 
277  /* Finalization */
278  for (i = 0; i < UT_DTM0_LOG_MAX_LOG_REC; ++i) {
279  ut_dl_fini(&txd[i], &buf[i]);
280  }
281 
282  m0_mutex_unlock(&log->dl_lock);
283  m0_be_dtm0_log_fini(log);
284  m0_be_dtm0_log_free(&log);
286 }
287 
288 
289 static struct m0_be_ut_backend *ut_be;
290 static struct m0_be_ut_seg *ut_seg;
291 static struct m0_be_seg *seg;
292 
293 
295 {
296  struct m0_be_tx_credit cred = {};
297  struct m0_be_dtm0_log *log;
298  struct m0_dtm0_clk_src cs;
299  struct m0_be_tx *tx;
300  int rc;
301 
302  M0_ENTRY();
303 
305 
306  /* Calculate credits */
308 
309  M0_ALLOC_PTR(tx);
310  M0_UT_ASSERT(tx != NULL);
311  m0_be_ut_tx_init(tx, ut_be);
312  m0_be_tx_prep(tx, &cred);
313  rc = m0_be_tx_open_sync(tx);
314  M0_UT_ASSERT(rc == 0);
315 
316  /* Create log and initialize it */
317  rc = m0_be_dtm0_log_create(tx, seg, &log);
318  M0_UT_ASSERT(rc == 0);
319 
320  rc = m0_be_dtm0_log_init(log, seg, &cs, true);
321  M0_UT_ASSERT(rc == 0);
322 
324  m0_be_tx_fini(tx);
325  m0_free(tx);
326  M0_LEAVE();
327 
328  return log;
329 }
330 
331 static void persistent_log_destroy(struct m0_be_dtm0_log *log)
332 {
333 }
334 
335 static void persistent_log_operate(struct m0_be_dtm0_log *log)
336 {
337  struct m0_be_tx_credit cred;
338  struct m0_be_tx *tx;
339 
341  struct m0_buf buf[UT_DTM0_LOG_MAX_LOG_REC] = {};
342  struct m0_dtm0_log_rec *rec[UT_DTM0_LOG_MAX_LOG_REC] = {};
343  int i;
344  int rc;
345  bool can_prune;
346 
347  for (i = 0; i < UT_DTM0_LOG_MAX_LOG_REC; ++i) {
348  rc = ut_dl_init(&txd[i], &buf[i], i);
349  M0_UT_ASSERT(rc == 0);
350  }
351 
352  M0_ENTRY();
353  M0_ALLOC_PTR(tx);
354  M0_UT_ASSERT(tx != NULL);
355 
356  /* Operate over the log */
357 
358  /* pa[0].st = EX pa[1].st = IP pa[2].st = IP, pyld = valid */
360 
361  M0_SET0(&cred);
362  m0_be_dtm0_log_credit(M0_DTML_EXECUTED, &txd[0], &buf[0], seg, NULL, &cred);
363 
364  /* Update the tx descriptor, prepare the tx and open it */
365  m0_be_ut_tx_init(tx, ut_be);
366  m0_be_tx_prep(tx, &cred);
367  rc = m0_be_tx_open_sync(tx);
368  M0_UT_ASSERT(rc == 0);
369  m0_mutex_lock(&log->dl_lock);
370  rc = m0_be_dtm0_log_update(log, tx, &txd[0], &buf[0]);
371  m0_mutex_unlock(&log->dl_lock);
372  M0_UT_ASSERT(rc == 0);
374  m0_be_tx_fini(tx);
375 
376  m0_mutex_lock(&log->dl_lock);
377  rec[0] = m0_be_dtm0_log_find(log, &txd[0].dtd_id);
378  m0_mutex_unlock(&log->dl_lock);
379  M0_UT_ASSERT(rec[0] != NULL);
380  rc = ut_dl_verify_log_rec(rec[0], 0);
381  M0_UT_ASSERT(rc != 0);
382 
385 
386  M0_SET0(&cred);
387  m0_be_dtm0_log_credit(M0_DTML_PERSISTENT, &txd[0], &buf[0], seg, NULL, &cred);
388 
389 
390  m0_be_ut_tx_init(tx, ut_be);
391  m0_be_tx_prep(tx, &cred);
392  rc = m0_be_tx_open_sync(tx);
393  M0_UT_ASSERT(rc == 0);
394  m0_mutex_lock(&log->dl_lock);
395  rc = m0_be_dtm0_log_update(log, tx, &txd[0], &buf[0]);
396  m0_mutex_unlock(&log->dl_lock);
397  M0_UT_ASSERT(rc == 0);
399  m0_be_tx_fini(tx);
400 
401  m0_mutex_lock(&log->dl_lock);
402  rec[0] = m0_be_dtm0_log_find(log, &txd[0].dtd_id);
403  m0_mutex_unlock(&log->dl_lock);
404  M0_UT_ASSERT(rec[0] != NULL);
405 
406  rc = ut_dl_verify_log_rec(rec[0], 0);
407  M0_UT_ASSERT(rc != 0);
408 
409  m0_mutex_lock(&log->dl_lock);
410  can_prune = m0_be_dtm0_plog_can_prune(log, &txd[0].dtd_id, &cred);
411  M0_UT_ASSERT(!can_prune);
412  m0_mutex_unlock(&log->dl_lock);
413 
415 
416  M0_SET0(&cred);
417  m0_be_dtm0_log_credit(M0_DTML_PERSISTENT, &txd[0], &buf[0], seg, NULL, &cred);
418 
419 
420  /* Update the tx descriptor, prepare the tx and open it */
421  m0_be_ut_tx_init(tx, ut_be);
422  m0_be_tx_prep(tx, &cred);
423  rc = m0_be_tx_open_sync(tx);
424  m0_mutex_lock(&log->dl_lock);
425  M0_UT_ASSERT(rc == 0);
426  rc = m0_be_dtm0_log_update(log, tx, &txd[0], &buf[0]);
427  m0_mutex_unlock(&log->dl_lock);
428  M0_UT_ASSERT(rc == 0);
430  m0_be_tx_fini(tx);
431 
432 
433  m0_mutex_lock(&log->dl_lock);
434  M0_SET0(&cred);
435  can_prune = m0_be_dtm0_plog_can_prune(log, &txd[0].dtd_id, &cred);
436  M0_UT_ASSERT(can_prune);
437  m0_be_ut_tx_init(tx, ut_be);
438  m0_be_tx_prep(tx, &cred);
439  rc = m0_be_tx_open_sync(tx);
440  M0_UT_ASSERT(rc == 0);
441  rc = m0_be_dtm0_plog_prune(log, tx, &txd[0].dtd_id);
442  M0_UT_ASSERT(rc == 0);
444  m0_be_tx_fini(tx);
445  m0_mutex_unlock(&log->dl_lock);
446 
447  m0_mutex_lock(&log->dl_lock);
448  rec[0] = m0_be_dtm0_log_find(log, &txd[0].dtd_id);
449  M0_UT_ASSERT(rec[0] == NULL);
450  m0_mutex_unlock(&log->dl_lock);
451 
452  m0_mutex_lock(&log->dl_lock);
453  can_prune = m0_be_dtm0_plog_can_prune(log, &txd[0].dtd_id, &cred);
454  M0_UT_ASSERT(!can_prune);
455  m0_mutex_unlock(&log->dl_lock);
456 
460 
461 
464 
465  M0_SET0(&cred);
466  m0_be_dtm0_log_credit(M0_DTML_PERSISTENT, &txd[0], &buf[0], seg, NULL, &cred);
467  m0_be_ut_tx_init(tx, ut_be);
468  m0_be_tx_prep(tx, &cred);
469  rc = m0_be_tx_open_sync(tx);
470  M0_UT_ASSERT(rc == 0);
471  m0_mutex_lock(&log->dl_lock);
472  rc = m0_be_dtm0_log_update(log, tx, &txd[0], &buf[0]);
473  M0_UT_ASSERT(rc == 0);
475  m0_be_tx_fini(tx);
476 
477  rec[0] = m0_be_dtm0_log_find(log, &txd[0].dtd_id);
478 
479  m0_mutex_unlock(&log->dl_lock);
480  M0_UT_ASSERT(rec[0] != NULL);
481  rc = ut_dl_verify_log_rec(rec[0], 0);
482  M0_UT_ASSERT(rc != 0);
483 
484 
485  M0_SET0(&cred);
486  m0_mutex_lock(&log->dl_lock);
487  can_prune = m0_be_dtm0_plog_can_prune(log, &txd[0].dtd_id, &cred);
488  M0_UT_ASSERT(can_prune);
489  m0_be_ut_tx_init(tx, ut_be);
490  m0_be_tx_prep(tx, &cred);
491  rc = m0_be_tx_open_sync(tx);
492  M0_UT_ASSERT(rc == 0);
493  rc = m0_be_dtm0_plog_prune(log, tx, &txd[0].dtd_id);
494  M0_UT_ASSERT(rc == 0);
496  m0_be_tx_fini(tx);
497  m0_mutex_unlock(&log->dl_lock);
498 
499  rec[0] = NULL;
500 
501  for (i = 0; i < UT_DTM0_LOG_MAX_LOG_REC; ++i) {
502  M0_SET0(&cred);
503  /* pa[0].st = EX pa[1].st = IP pa[2].st = IP, pyld = valid */
507 
508  /* Insert/Update a persistent record in the log. --> */
509  /* Calculate credits for a M0_DTML_PERSISTENT record */
510  m0_be_dtm0_log_credit(M0_DTML_PERSISTENT, &txd[0], &buf[0], seg, NULL, &cred);
511  /* Update the tx descriptor, prepare the tx and open it */
512  m0_be_ut_tx_init(tx, ut_be);
513  m0_be_tx_prep(tx, &cred);
514  rc = m0_be_tx_open_sync(tx);
515  M0_UT_ASSERT(rc == 0);
516 
517  /* lock the log, update/insert the new record, close the log and unlock it. */
518  m0_mutex_lock(&log->dl_lock);
519  rc = m0_be_dtm0_log_update(log, tx, &txd[i], &buf[i]);
520  m0_mutex_unlock(&log->dl_lock);
521  M0_UT_ASSERT(rc == 0);
522  /* <-- .. persistent record in the log. */
524  m0_be_tx_fini(tx);
525  }
526 
527  for (i = 0; i < UT_DTM0_LOG_MAX_LOG_REC; ++i) {
528  m0_mutex_lock(&log->dl_lock);
529  rec[i] = m0_be_dtm0_log_find(log, &txd[i].dtd_id);
530  m0_mutex_unlock(&log->dl_lock);
531  M0_UT_ASSERT(rec[i] != NULL);
532  rc = ut_dl_verify_log_rec(rec[i], i);
533  M0_UT_ASSERT(rc != 0);
534  rec[i] = NULL;
535  }
536 
537  i--;
538  M0_SET0(&cred);
539  m0_mutex_lock(&log->dl_lock);
540  can_prune = m0_be_dtm0_plog_can_prune(log, &txd[i].dtd_id, &cred);
541  M0_UT_ASSERT(can_prune);
542  m0_be_ut_tx_init(tx, ut_be);
543  m0_be_tx_prep(tx, &cred);
544  rc = m0_be_tx_open_sync(tx);
545  M0_UT_ASSERT(rc == 0);
546  rc = m0_be_dtm0_plog_prune(log, tx, &txd[i].dtd_id);
547  M0_UT_ASSERT(rc == 0);
549  m0_be_tx_fini(tx);
550  m0_mutex_unlock(&log->dl_lock);
551 
552  for (i = 0; i < UT_DTM0_LOG_MAX_LOG_REC; ++i) {
553  m0_mutex_lock(&log->dl_lock);
554  rec[i] = m0_be_dtm0_log_find(log, &txd[i].dtd_id);
555  m0_mutex_unlock(&log->dl_lock);
556  M0_UT_ASSERT(rec[i] == NULL);
557  }
558 
559  m0_free(tx);
560  M0_LEAVE();
561 
562  }
563 
564 static void dtm0_log_check(const struct m0_be_dtm0_log *log)
565 {
566 }
567 
568 static void m0_be_ut_dtm0_log_test(void)
569 {
570  struct m0_dtm0_clk_src cs;
571  struct m0_be_dtm0_log *log;
572 
573  M0_ENTRY();
575  M0_UT_ASSERT(ut_be != NULL);
579  m0_be_ut_seg_init(ut_seg, ut_be, 1ULL << 24);
580  seg = ut_seg->bus_seg;
581 
583 
584  log = persistent_log_create();
585  M0_UT_ASSERT(log != NULL);
586 
588  m0_be_dtm0_log_init(log, seg, &cs, true);
589 
592  m0_be_dtm0_log_init(log, seg, &cs, true);
593 
594  dtm0_log_check(log);
596 
597  /* TODO: destroy_log(log); */
598 
602  m0_free(ut_seg);
603  m0_free(ut_be);
604 
605  M0_LEAVE();
606 }
607 
609  .ts_name = "dtm0-log-ut",
610  .ts_init = NULL,
611  .ts_fini = NULL,
612  .ts_tests = {
613  { "dtm0-log-list", test_volatile_dtm0_log },
614  { "dtm0-log-persistent", m0_be_ut_dtm0_log_test },
615  { NULL, NULL }
616  }
617 };
618 
619 #undef M0_TRACE_SUBSYSTEM
620 /*
621  * Local variables:
622  * c-indentation-style: "K&R"
623  * c-basic-offset: 8
624  * tab-width: 8
625  * fill-column: 80
626  * scroll-step: 1
627  * End:
628  */
629 /*
630  * vim: tabstop=8 shiftwidth=8 noexpandtab textwidth=80 nowrap
631  */
static int ut_dl_init(struct m0_dtm0_tx_desc *txd, struct m0_buf *buf, int rand)
Definition: dtm0_log_ut.c:141
static void tid_init(struct m0_dtm0_tid *tid, int rand)
Definition: dtm0_log_ut.c:67
M0_INTERNAL int m0_dtm0_tx_desc_init(struct m0_dtm0_tx_desc *td, uint32_t nr_pa)
Definition: tx_desc.c:97
void m0_be_ut_seg_fini(struct m0_be_ut_seg *ut_seg)
Definition: stubs.c:267
static bool txd_check(const struct m0_dtm0_tx_desc *txd, int rand)
Definition: dtm0_log_ut.c:106
M0_INTERNAL void m0_mutex_unlock(struct m0_mutex *mutex)
Definition: mutex.c:66
static void p_state_set(struct m0_dtm0_tx_pa *pa, uint32_t state)
Definition: dtm0_log_ut.c:44
void m0_be_ut_seg_reload(struct m0_be_ut_seg *ut_seg)
Definition: stubs.c:272
M0_INTERNAL bool m0_be_dtm0_plog_can_prune(struct m0_be_dtm0_log *log, const struct m0_dtm0_tid *id, struct m0_be_tx_credit *accum)
Definition: dtm0_log.c:573
#define NULL
Definition: misc.h:38
M0_INTERNAL void m0_be_dtm0_log_free(struct m0_be_dtm0_log **in_log)
Definition: dtm0_log.c:119
M0_INTERNAL bool m0_buf_eq(const struct m0_buf *x, const struct m0_buf *y)
Definition: buf.c:90
static void txd_fini(struct m0_dtm0_tx_desc *txd)
Definition: dtm0_log_ut.c:101
M0_LEAVE()
static bool ut_dl_verify_buf(struct m0_buf *buf, int rand)
Definition: dtm0_log_ut.c:129
static struct m0_be_dtm0_log * persistent_log_create(void)
Definition: dtm0_log_ut.c:294
struct m0_be_seg * bus_seg
Definition: helper.h:119
static void persistent_log_operate(struct m0_be_dtm0_log *log)
Definition: dtm0_log_ut.c:335
M0_INTERNAL void m0_be_tx_fini(struct m0_be_tx *tx)
Definition: stubs.c:163
struct m0_dtm0_tx_desc dlr_txd
Definition: dtm0_log.h:162
struct m0_dtm0_ts dti_ts
Definition: tx_desc.h:94
M0_INTERNAL void m0_be_dtm0_log_fini(struct m0_be_dtm0_log *log)
Definition: dtm0_log.c:111
M0_INTERNAL void m0_be_tx_prep(struct m0_be_tx *tx, const struct m0_be_tx_credit *credit)
Definition: stubs.c:175
M0_DTPS_INPROGRESS
Definition: tx_desc.h:164
void m0_be_ut_seg_init(struct m0_be_ut_seg *ut_seg, struct m0_be_ut_backend *ut_be, m0_bcount_t size)
Definition: stubs.c:256
static int ut_dl_init_buf(struct m0_buf *buf, int rand)
Definition: dtm0_log_ut.c:114
static bool ut_dl_verify_log_rec(struct m0_dtm0_log_rec *rec, int rand)
Definition: dtm0_log_ut.c:162
#define M0_SET0(obj)
Definition: misc.h:64
M0_INTERNAL void m0_mutex_lock(struct m0_mutex *mutex)
Definition: mutex.c:49
Definition: ut.h:77
M0_INTERNAL int m0_fid_cmp(const struct m0_fid *fid0, const struct m0_fid *fid1)
Definition: fid.c:170
static void ut_dl_fini_buf(struct m0_buf *buf)
Definition: dtm0_log_ut.c:124
Definition: sock.c:887
M0_INTERNAL int m0_be_dtm0_plog_prune(struct m0_be_dtm0_log *log, struct m0_be_tx *tx, const struct m0_dtm0_tid *id)
Definition: dtm0_log.c:609
struct m0_buf dlr_payload
Definition: dtm0_log.h:178
static int txd_init(struct m0_dtm0_tx_desc *txd, int rand)
Definition: dtm0_log_ut.c:84
struct m0_dtm0_tid dtd_id
Definition: tx_desc.h:121
#define M0_ENTRY(...)
Definition: trace.h:170
Definition: buf.h:37
m0_time_t dts_phys
Definition: clk_src.h:93
int i
Definition: dir.c:1033
M0_INTERNAL void m0_fid_set(struct m0_fid *fid, uint64_t container, uint64_t key)
Definition: fid.c:116
static void p_init(struct m0_dtm0_tx_pa *pa, int rand)
Definition: dtm0_log_ut.c:49
static struct m0_be_ut_backend * ut_be
Definition: dtm0_log_ut.c:289
static struct m0_be_seg * seg
Definition: dtm0_log_ut.c:291
M0_INTERNAL int m0_be_dtm0_log_init(struct m0_be_dtm0_log *log, struct m0_be_seg *seg, struct m0_dtm0_clk_src *cs, bool is_plog)
Definition: dtm0_log.c:94
M0_INTERNAL int m0_be_dtm0_log_create(struct m0_be_tx *tx, struct m0_be_seg *seg, struct m0_be_dtm0_log **out)
Definition: dtm0_log.c:237
#define M0_ASSERT(cond)
M0_INTERNAL int m0_be_dtm0_log_alloc(struct m0_be_dtm0_log **out)
Definition: dtm0_log.c:70
struct m0_ut_suite dtm0_log_ut
Definition: dtm0_log_ut.c:608
int rand(void)
M0_INTERNAL int m0_be_tx_open_sync(struct m0_be_tx *tx)
Definition: stubs.c:199
M0_DTPS_NR
Definition: tx_desc.h:164
M0_DTPS_EXECUTED
Definition: tx_desc.h:164
static struct m0_be_ut_seg * ut_seg
Definition: dtm0_log_ut.c:290
void m0_be_ut_backend_init(struct m0_be_ut_backend *ut_be)
Definition: stubs.c:238
static bool tid_check(const struct m0_dtm0_tid *tid, int rand)
Definition: dtm0_log_ut.c:73
M0_INTERNAL int m0_buf_alloc(struct m0_buf *buf, size_t size)
Definition: buf.c:43
static void persistent_log_destroy(struct m0_be_dtm0_log *log)
Definition: dtm0_log_ut.c:331
M0_INTERNAL void m0_buf_free(struct m0_buf *buf)
Definition: buf.c:55
struct m0_fid p_fid
Definition: tx_desc.h:110
M0_INTERNAL int m0_be_dtm0_log_prune(struct m0_be_dtm0_log *log, struct m0_be_tx *tx, const struct m0_dtm0_tid *id)
Definition: dtm0_log.c:477
Definition: seg.h:66
struct m0_dtm0_tx_participants dtd_ps
Definition: tx_desc.h:165
#define m0_forall(var, nr,...)
Definition: misc.h:112
const char * ts_name
Definition: ut.h:99
struct m0_dtm0_tx_pa * dtp_pa
Definition: tx_desc.h:117
static void ut_dl_fini(struct m0_dtm0_tx_desc *txd, struct m0_buf *buf)
Definition: dtm0_log_ut.c:156
static void m0_be_ut_dtm0_log_test(void)
Definition: dtm0_log_ut.c:568
Definition: fid.h:38
static void dtm0_log_check(const struct m0_be_dtm0_log *log)
Definition: dtm0_log_ut.c:564
M0_INTERNAL int m0_be_dtm0_log_update(struct m0_be_dtm0_log *log, struct m0_be_tx *tx, struct m0_dtm0_tx_desc *txd, struct m0_buf *payload)
Definition: dtm0_log.c:460
M0_INTERNAL void m0_dtm0_clk_src_fini(struct m0_dtm0_clk_src *cs)
Definition: clk_src.c:49
#define M0_ALLOC_PTR(ptr)
Definition: memory.h:86
M0_DTPS_PERSISTENT
Definition: tx_desc.h:164
M0_INTERNAL void m0_be_dtm0_log_credit(enum m0_be_dtm0_log_credit_op op, struct m0_dtm0_tx_desc *txd, struct m0_buf *payload, struct m0_be_seg *seg, struct m0_dtm0_log_rec *rec, struct m0_be_tx_credit *accum)
Definition: dtm0_log.c:202
struct m0_fid dti_fid
Definition: tx_desc.h:95
void m0_be_ut_tx_init(struct m0_be_tx *tx, struct m0_be_ut_backend *ut_be)
Definition: stubs.c:286
void m0_be_ut_backend_fini(struct m0_be_ut_backend *ut_be)
Definition: stubs.c:242
struct m0_dtm0_tx_participants dtd_ps
Definition: tx_desc.h:122
M0_INTERNAL struct m0_dtm0_log_rec * m0_be_dtm0_log_find(struct m0_be_dtm0_log *log, const struct m0_dtm0_tid *id)
Definition: dtm0_log.c:270
struct m0_mutex dl_lock
Definition: dtm0_log.h:198
void m0_free(void *data)
Definition: memory.c:146
M0_INTERNAL void m0_dtm0_clk_src_init(struct m0_dtm0_clk_src *cs, enum m0_dtm0_cs_types type)
Definition: clk_src.c:38
static bool p_check(const struct m0_dtm0_tx_pa *pa, int rand)
Definition: dtm0_log_ut.c:55
M0_INTERNAL void m0_dtm0_tx_desc_fini(struct m0_dtm0_tx_desc *td)
Definition: tx_desc.c:111
int32_t rc
Definition: trigger_fop.h:47
#define M0_UT_ASSERT(a)
Definition: ut.h:46
void test_volatile_dtm0_log(void)
Definition: dtm0_log_ut.c:169
struct m0_dtm0_tid dtd_id
Definition: tx_desc.h:164
M0_INTERNAL void m0_be_tx_close_sync(struct m0_be_tx *tx)
Definition: stubs.c:205
Definition: tx.h:280