Motr  M0
tx_service.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 #define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_BE
24 #include "lib/trace.h"
25 
26 #include "be/engine.h"
27 #include "be/tx_service.h"
28 #include "lib/errno.h"
29 #include "lib/memory.h"
30 
36 /* ------------------------------------------------------------------
37  * TX service
38  * ------------------------------------------------------------------ */
39 
41 struct tx_service {
43 };
44 
45 static int txs_allocate(struct m0_reqh_service **out,
46  const struct m0_reqh_service_type *stype);
47 
48 static const struct m0_reqh_service_type_ops txs_stype_ops = {
50 };
51 
53  .rst_name = "be-tx-service",
54  .rst_ops = &txs_stype_ops,
55  .rst_level = M0_BE_TX_SVC_LEVEL,
56 };
57 
58 M0_INTERNAL int m0_be_txs_register(void)
59 {
61 }
62 
63 M0_INTERNAL void m0_be_txs_unregister(void)
64 {
66 }
67 
68 static int txs_start(struct m0_reqh_service *service);
69 static void txs_stop(struct m0_reqh_service *service);
70 static void txs_fini(struct m0_reqh_service *service);
71 
72 static const struct m0_reqh_service_ops txs_ops = {
74  .rso_stop = txs_stop,
75  .rso_fini = txs_fini
76 };
77 
79 static int txs_allocate(struct m0_reqh_service **service,
80  const struct m0_reqh_service_type *stype)
81 {
82  struct tx_service *s;
83 
84  M0_ENTRY();
86 
87  M0_ALLOC_PTR(s);
88  if (s == NULL)
89  return M0_RC(-ENOMEM);
90 
91  *service = &s->ts_reqh;
92  (*service)->rs_ops = &txs_ops;
93 
94  return M0_RC(0);
95 }
96 
98 static void txs_fini(struct m0_reqh_service *service)
99 {
100  M0_ENTRY();
102  M0_LEAVE();
103 }
104 
105 static int txs_start(struct m0_reqh_service *service)
106 {
107  M0_ENTRY();
108  return M0_RC(0);
109 }
110 
111 static void txs_stop(struct m0_reqh_service *service)
112 {
113  M0_ENTRY();
114  M0_LEAVE();
115 }
116 
117 M0_INTERNAL int m0_be_tx_service_init(struct m0_be_engine *en,
118  struct m0_reqh *reqh)
119 {
120  M0_PRE(en->eng_service == NULL);
122  reqh, NULL, NULL);
123 }
124 
125 M0_INTERNAL void m0_be_tx_service_fini(struct m0_be_engine *en)
126 {
128  en->eng_service = NULL;
129 }
130 
133 #undef M0_TRACE_SUBSYSTEM
134 
135 /*
136  * Local variables:
137  * c-indentation-style: "K&R"
138  * c-basic-offset: 8
139  * tab-width: 8
140  * fill-column: 80
141  * scroll-step: 1
142  * End:
143  */
144 /*
145  * vim: tabstop=8 shiftwidth=8 noexpandtab textwidth=80 nowrap
146  */
#define M0_PRE(cond)
int(* rso_start)(struct m0_reqh_service *service)
Definition: reqh_service.h:360
static void txs_stop(struct m0_reqh_service *service)
Definition: tx_service.c:111
#define NULL
Definition: misc.h:38
M0_INTERNAL void m0_be_txs_unregister(void)
Definition: tx_service.c:63
M0_LEAVE()
static int txs_start(struct m0_reqh_service *service)
Definition: tx_service.c:105
M0_INTERNAL int m0_be_txs_register(void)
Definition: tx_service.c:58
#define container_of(ptr, type, member)
Definition: misc.h:33
static int txs_allocate(struct m0_reqh_service **out, const struct m0_reqh_service_type *stype)
Definition: tx_service.c:79
int m0_reqh_service_type_register(struct m0_reqh_service_type *rstype)
Definition: reqh_service.c:473
return M0_RC(rc)
#define M0_ENTRY(...)
Definition: trace.h:170
static const struct socktype stype[]
Definition: sock.c:1156
M0_INTERNAL void m0_reqh_service_quit(struct m0_reqh_service *svc)
Definition: reqh_service.c:588
const char * rst_name
Definition: reqh_service.h:447
Definition: reqh.h:94
M0_INTERNAL int m0_reqh_service_setup(struct m0_reqh_service **out, struct m0_reqh_service_type *stype, struct m0_reqh *reqh, struct m0_reqh_context *rctx, const struct m0_fid *fid)
Definition: reqh_service.c:565
static const struct m0_reqh_service_type_ops txs_stype_ops
Definition: tx_service.c:48
static const struct m0_reqh_service_ops txs_ops
Definition: tx_service.c:72
struct m0_reqh_service * eng_service
Definition: engine.h:110
struct m0_reqh reqh
Definition: rm_foms.c:48
int(* rsto_service_allocate)(struct m0_reqh_service **service, const struct m0_reqh_service_type *stype)
Definition: reqh_service.h:435
static void txs_fini(struct m0_reqh_service *service)
Definition: tx_service.c:98
M0_INTERNAL int m0_be_tx_service_init(struct m0_be_engine *en, struct m0_reqh *reqh)
Definition: tx_service.c:117
#define M0_ALLOC_PTR(ptr)
Definition: memory.h:86
M0_INTERNAL void m0_be_tx_service_fini(struct m0_be_engine *en)
Definition: tx_service.c:125
struct m0_reqh_service ts_reqh
Definition: tx_service.c:42
#define out(...)
Definition: gen.c:41
struct m0_reqh_service_type m0_be_txs_stype
Definition: tx_service.c:52
void m0_free(void *data)
Definition: memory.c:146
static struct m0_addb2_source * s
Definition: consumer.c:39
void m0_reqh_service_type_unregister(struct m0_reqh_service_type *rstype)
Definition: reqh_service.c:490
static struct m0_reqh_service * service[REQH_IN_UT_MAX]
Definition: long_lock_ut.c:46