Motr  M0
ltx.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 
23 
30 #include "lib/assert.h"
31 #include "lib/locality.h"
32 
33 #include "dtm/update.h"
34 #include "dtm/ltx.h"
35 
36 static void ltx_persistent_hook(const struct m0_be_tx *tx);
37 static const struct m0_dtm_history_ops ltx_ops;
38 static const struct m0_uint128 ltxid = M0_UINT128(0x10ca1, 0x10ca1);
39 
40 M0_INTERNAL void m0_dtm_ltx_init(struct m0_dtm_ltx *ltx, struct m0_dtm *dtm,
41  struct m0_be_domain *dom)
42 {
43  m0_dtm_controlh_init(&ltx->lx_ch, dtm);
44  ltx->lx_ch.ch_history.h_ops = &ltx_ops;
46  ltx->lx_ch.ch_history.h_rem = NULL;
47  ltx->lx_dom = dom;
48 }
49 
50 M0_INTERNAL void m0_dtm_ltx_open(struct m0_dtm_ltx *ltx)
51 {
52  m0_be_tx_init(&ltx->lx_tx, 0, ltx->lx_dom, m0_locality_here()->lo_grp,
54 }
55 
56 M0_INTERNAL void m0_dtm_ltx_close(struct m0_dtm_ltx *ltx)
57 {
60  m0_be_tx_close(&ltx->lx_tx);
61 }
62 
63 M0_INTERNAL void m0_dtm_ltx_fini(struct m0_dtm_ltx *ltx)
64 {
66  m0_be_tx_fini(&ltx->lx_tx);
67 }
68 
69 M0_INTERNAL void m0_dtm_ltx_add(struct m0_dtm_ltx *ltx,
70  struct m0_dtm_oper *oper)
71 {
72  m0_dtm_controlh_add(&ltx->lx_ch, oper);
73 }
74 
75 static void ltx_persistent_hook(const struct m0_be_tx *tx)
76 {
77  struct m0_dtm_ltx *ltx = M0_AMB(ltx, tx, lx_tx);
80 }
81 
82 static int ltx_find(struct m0_dtm *dtm, const struct m0_dtm_history_type *ht,
83  const struct m0_uint128 *id,
84  struct m0_dtm_history **out)
85 {
86  M0_IMPOSSIBLE("Looking for ltx?");
87  return 0;
88 }
89 
90 static const struct m0_dtm_history_type_ops ltx_htype_ops = {
92 };
93 
94 enum {
96 };
97 
98 M0_INTERNAL const struct m0_dtm_history_type m0_dtm_ltx_htype = {
100  .hit_name = "local transaction",
101  .hit_ops = &ltx_htype_ops
102 };
103 
104 static const struct m0_uint128 *ltx_id(const struct m0_dtm_history *history)
105 {
106  return &ltxid;
107 }
108 
109 static void ltx_noop(struct m0_dtm_history *history)
110 {
111 }
112 
113 static const struct m0_dtm_history_ops ltx_ops = {
115  .hio_id = &ltx_id,
116  .hio_persistent = &ltx_noop,
117  .hio_fixed = &ltx_noop,
118  .hio_update = &m0_dtm_controlh_update
119 };
120 
121 
124 /*
125  * Local variables:
126  * c-indentation-style: "K&R"
127  * c-basic-offset: 8
128  * tab-width: 8
129  * fill-column: 80
130  * scroll-step: 1
131  * End:
132  */
133 /*
134  * vim: tabstop=8 shiftwidth=8 noexpandtab textwidth=80 nowrap
135  */
static const struct m0_dtm_history_ops ltx_ops
Definition: ltx.c:37
M0_INTERNAL const struct m0_dtm_history_type m0_dtm_ltx_htype
Definition: ltx.c:98
M0_INTERNAL void m0_dtm_controlh_fini(struct m0_dtm_controlh *ch)
Definition: history.c:340
#define NULL
Definition: misc.h:38
struct m0_dtm_controlh lx_ch
Definition: ltx.h:45
uint64_t hi_flags
Definition: nucleus.h:65
struct m0_dtm_remote * h_rem
Definition: history.h:59
M0_INTERNAL void m0_dtm_controlh_init(struct m0_dtm_controlh *ch, struct m0_dtm *dtm)
Definition: history.c:328
M0_INTERNAL void m0_be_tx_fini(struct m0_be_tx *tx)
Definition: stubs.c:163
uint8_t hit_id
Definition: history.h:88
M0_INTERNAL void m0_dtm_controlh_close(struct m0_dtm_controlh *ch)
Definition: history.c:346
struct m0_dtm_hi h_hi
Definition: history.h:56
M0_INTERNAL void m0_dtm_oper_done(const struct m0_dtm_oper *oper, const struct m0_dtm_remote *rem)
Definition: operation.c:144
static void ltx_noop(struct m0_dtm_history *history)
Definition: ltx.c:109
struct m0_be_tx lx_tx
Definition: ltx.h:47
struct m0_dtm_oper ch_clop
Definition: history.h:103
struct m0_dtm_history ch_history
Definition: history.h:102
M0_INTERNAL void m0_dtm_history_persistent(struct m0_dtm_history *history, m0_dtm_ver_t upto)
Definition: history.c:107
static const struct m0_uint128 ltxid
Definition: ltx.c:38
#define M0_AMB(obj, ptr, field)
Definition: misc.h:320
#define M0_ASSERT(cond)
static struct m0_stob_domain * dom
Definition: storage.c:38
M0_INTERNAL void m0_be_tx_close(struct m0_be_tx *tx)
Definition: stubs.c:194
Definition: ltx.h:44
static void ltx_persistent_hook(const struct m0_be_tx *tx)
Definition: ltx.c:75
M0_INTERNAL struct m0_locality * m0_locality_here(void)
Definition: locality.c:146
static const struct m0_uint128 * ltx_id(const struct m0_dtm_history *history)
Definition: ltx.c:104
M0_INTERNAL void m0_be_tx_init(struct m0_be_tx *tx, uint64_t tid, struct m0_be_domain *dom, struct m0_sm_group *sm_group, m0_be_tx_cb_t persistent, m0_be_tx_cb_t discarded, void(*filler)(struct m0_be_tx *tx, void *payload), void *datum)
Definition: stubs.c:150
int(* hito_find)(struct m0_dtm *dtm, const struct m0_dtm_history_type *ht, const struct m0_uint128 *id, struct m0_dtm_history **out)
Definition: history.h:95
const struct m0_dtm_history_type * hio_type
Definition: history.h:79
static const struct m0_dtm_history_type_ops ltx_htype_ops
Definition: ltx.c:90
M0_INTERNAL int m0_dtm_controlh_update(struct m0_dtm_history *history, uint8_t id, struct m0_dtm_update *update)
Definition: history.c:393
M0_INTERNAL void m0_dtm_ltx_fini(struct m0_dtm_ltx *ltx)
Definition: ltx.c:63
#define M0_UINT128(hi, lo)
Definition: types.h:40
Definition: dtm.h:529
struct m0_be_domain * lx_dom
Definition: ltx.h:46
#define out(...)
Definition: gen.c:41
M0_INTERNAL void m0_dtm_ltx_add(struct m0_dtm_ltx *ltx, struct m0_dtm_oper *oper)
Definition: ltx.c:69
M0_INTERNAL void m0_dtm_controlh_add(struct m0_dtm_controlh *ch, struct m0_dtm_oper *oper)
Definition: history.c:352
M0_INTERNAL void m0_dtm_ltx_close(struct m0_dtm_ltx *ltx)
Definition: ltx.c:56
M0_INTERNAL void m0_dtm_ltx_init(struct m0_dtm_ltx *ltx, struct m0_dtm *dtm, struct m0_be_domain *dom)
Definition: ltx.c:40
M0_INTERNAL void m0_dtm_ltx_open(struct m0_dtm_ltx *ltx)
Definition: ltx.c:50
static int ltx_find(struct m0_dtm *dtm, const struct m0_dtm_history_type *ht, const struct m0_uint128 *id, struct m0_dtm_history **out)
Definition: ltx.c:82
Definition: tx.h:280
const struct m0_dtm_history_ops * h_ops
Definition: history.h:65
#define M0_IMPOSSIBLE(fmt,...)