Motr  M0
dtm0_log.h
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2021 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 #pragma once
23 #ifndef __MOTR_BE_DTM0_LOG_H__
24 #define __MOTR_BE_DTM0_LOG_H__
25 
26 #include "be/list.h" /* m0_be_list */
27 #include "dtm0/tx_desc.h" /* m0_dtm0_tx_desc */
28 #include "fid/fid.h" /* m0_fid */
29 #include "lib/buf.h" /* m0_buf */
30 #include "dtm0/dtx.h" /* struct m0_dtm0_dtx */
31 
32 struct m0_be_tx;
33 struct m0_be_tx_credit;
34 struct m0_dtm0_clk_src;
35 
148 };
149 
163  uint64_t dlr_magic;
164  union {
166  * used when this record is
167  * stored within a persistent
168  * log that is going to stored
169  * in BE.
170  */
171  struct m0_tlink dlr_tlink; /*
172  * used when this record is
173  * stored within a volatile
174  * log that is going to stored
175  * in memory.
176  */
177  } u;
179 };
180 
201  struct m0_be_seg *dl_seg;
204  union {
208  struct m0_tl *dl_inmem;
209  } u;
210 };
211 
239 M0_INTERNAL int m0_be_dtm0_log_alloc(struct m0_be_dtm0_log **log);
240 
257 M0_INTERNAL int m0_be_dtm0_log_init(struct m0_be_dtm0_log *log,
258  struct m0_be_seg *seg,
259  struct m0_dtm0_clk_src *cs,
260  bool is_plog);
261 
274 M0_INTERNAL void m0_be_dtm0_log_fini(struct m0_be_dtm0_log *log);
275 
286 M0_INTERNAL void m0_be_dtm0_log_free(struct m0_be_dtm0_log **log);
287 
310  struct m0_dtm0_tx_desc *txd,
311  struct m0_buf *payload,
312  struct m0_be_seg *seg,
313  struct m0_dtm0_log_rec *rec,
314  struct m0_be_tx_credit *accum);
315 
329 M0_INTERNAL int m0_be_dtm0_log_create(struct m0_be_tx *tx,
330  struct m0_be_seg *seg,
331  struct m0_be_dtm0_log **out);
332 
344 M0_INTERNAL void m0_be_dtm0_log_destroy(struct m0_be_tx *tx,
345  struct m0_be_dtm0_log **log);
346 
365 M0_INTERNAL int m0_be_dtm0_log_update(struct m0_be_dtm0_log *log,
366  struct m0_be_tx *tx,
367  struct m0_dtm0_tx_desc *txd,
368  struct m0_buf *payload);
369 
386 M0_INTERNAL
388  const struct m0_dtm0_tid *id);
389 
409 M0_INTERNAL int m0_be_dtm0_log_prune(struct m0_be_dtm0_log *log,
410  struct m0_be_tx *tx,
411  const struct m0_dtm0_tid *id);
412 
435 M0_INTERNAL bool m0_be_dtm0_plog_can_prune(struct m0_be_dtm0_log *log,
436  const struct m0_dtm0_tid *id,
437  struct m0_be_tx_credit *cred);
438 
458 M0_INTERNAL int m0_be_dtm0_plog_prune(struct m0_be_dtm0_log *log,
459  struct m0_be_tx *tx,
460  const struct m0_dtm0_tid *id);
461 
477 M0_INTERNAL void m0_be_dtm0_log_clear(struct m0_be_dtm0_log *log);
478 
491 M0_INTERNAL int m0_be_dtm0_volatile_log_insert(struct m0_be_dtm0_log *log,
492  struct m0_dtm0_log_rec *rec);
493 
505 M0_INTERNAL void m0_be_dtm0_volatile_log_update(struct m0_be_dtm0_log *log,
506  struct m0_dtm0_log_rec *rec);
507 
520 M0_INTERNAL void m0_be_dtm0_volatile_log_del(struct m0_be_dtm0_log *log,
521  struct m0_dtm0_log_rec *rec,
522  bool fini);
523 
524 
535 };
536 
537 M0_INTERNAL int m0_dtm0_log_rec_copy(struct m0_dtm0_log_rec *dst,
538  const struct m0_dtm0_log_rec *src);
543 M0_INTERNAL void m0_dtm0_log_iter_rec_fini(struct m0_dtm0_log_rec *rec);
544 
545 M0_INTERNAL void m0_be_dtm0_log_iter_init(struct m0_be_dtm0_log_iter *iter,
546  struct m0_be_dtm0_log *log);
547 
548 M0_INTERNAL void m0_be_dtm0_log_iter_fini(struct m0_be_dtm0_log_iter *iter);
549 
559 M0_INTERNAL int m0_be_dtm0_log_iter_next(struct m0_be_dtm0_log_iter *iter,
560  struct m0_dtm0_log_rec *out);
561  /* end DTM0Internals */
563 
564 #endif /* __MOTR_BE_DTM0_LOG_H__ */
565 
566 /*
567  * Local variables:
568  * c-indentation-style: "K&R"
569  * c-basic-offset: 8
570  * tab-width: 8
571  * fill-column: 80
572  * scroll-step: 1
573  * End:
574  */
575 /*
576  * vim: tabstop=8 shiftwidth=8 noexpandtab textwidth=80 nowrap
577  */
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 *cred)
Definition: dtm0_log.c:580
static struct m0_bufvec dst
Definition: xform.c:61
M0_INTERNAL void m0_be_dtm0_log_free(struct m0_be_dtm0_log **log)
Definition: dtm0_log.c:119
struct m0_dtm0_dtx dlr_dtx
Definition: dtm0_log.h:161
struct m0_tl * dl_inmem
Definition: dtm0_log.h:208
struct m0_dtm0_tx_desc dlr_txd
Definition: dtm0_log.h:162
struct m0_be_seg * dl_seg
Definition: dtm0_log.h:201
M0_INTERNAL void m0_be_dtm0_log_fini(struct m0_be_dtm0_log *log)
Definition: dtm0_log.c:111
struct m0_be_dtm0_log * dli_log
Definition: dtm0_log.h:533
M0_INTERNAL void m0_be_dtm0_volatile_log_update(struct m0_be_dtm0_log *log, struct m0_dtm0_log_rec *rec)
Definition: dtm0_log.c:551
struct m0_be_list_link dlr_link
Definition: dtm0_log.h:165
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:616
struct m0_buf dlr_payload
Definition: dtm0_log.h:178
M0_INTERNAL void m0_be_dtm0_log_clear(struct m0_be_dtm0_log *log)
Definition: dtm0_log.c:512
op
Definition: libdemo.c:64
Definition: buf.h:37
M0_INTERNAL int m0_be_dtm0_log_iter_next(struct m0_be_dtm0_log_iter *iter, struct m0_dtm0_log_rec *out)
Definition: dtm0_log.c:673
struct m0_be_list * dl_persist
Definition: dtm0_log.h:206
M0_INTERNAL void m0_be_dtm0_volatile_log_del(struct m0_be_dtm0_log *log, struct m0_dtm0_log_rec *rec, bool fini)
Definition: dtm0_log.c:558
M0_INTERNAL int m0_be_dtm0_volatile_log_insert(struct m0_be_dtm0_log *log, struct m0_dtm0_log_rec *rec)
Definition: dtm0_log.c:536
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
M0_INTERNAL int m0_be_dtm0_log_alloc(struct m0_be_dtm0_log **log)
Definition: dtm0_log.c:70
union m0_dtm0_log_rec::@30 u
union m0_be_dtm0_log::@31 u
Definition: tlist.h:251
uint64_t dlr_magic
Definition: dtm0_log.h:163
M0_INTERNAL void m0_be_dtm0_log_destroy(struct m0_be_tx *tx, struct m0_be_dtm0_log **log)
Definition: dtm0_log.c:260
M0_INTERNAL void m0_dtm0_log_iter_rec_fini(struct m0_dtm0_log_rec *rec)
Definition: dtm0_log.c:713
m0_be_dtm0_log_credit_op
Definition: dtm0_log.h:141
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:469
struct m0_tlink dlr_tlink
Definition: dtm0_log.h:171
Definition: seg.h:66
M0_INTERNAL void m0_be_dtm0_log_iter_init(struct m0_be_dtm0_log_iter *iter, struct m0_be_dtm0_log *log)
Definition: dtm0_log.c:660
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:452
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_dtm0_clk_src * dl_cs
Definition: dtm0_log.h:203
int fini(struct workload *w)
static struct m0_be_seg * seg
Definition: btree.c:40
M0_INTERNAL void m0_be_dtm0_log_iter_fini(struct m0_be_dtm0_log_iter *iter)
Definition: dtm0_log.c:668
bool dl_is_persistent
Definition: dtm0_log.h:194
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
#define out(...)
Definition: gen.c:41
struct m0_mutex dl_lock
Definition: dtm0_log.h:200
struct m0_dtm0_tid dli_current_tid
Definition: dtm0_log.h:534
Definition: mutex.h:47
struct m0_pdclust_src_addr src
Definition: fd.c:108
M0_INTERNAL int m0_dtm0_log_rec_copy(struct m0_dtm0_log_rec *dst, const struct m0_dtm0_log_rec *src)
Definition: dtm0_log.c:705
const uint64_t payload[]
Definition: base.c:65
Definition: tx.h:280