Motr  M0
service.c
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2012-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_SNSCM
24 #include "lib/trace.h"
25 
26 #include "lib/memory.h"
27 #include "lib/assert.h"
28 #include "lib/errno.h"
29 #include "lib/misc.h"
30 #include "lib/finject.h"
31 
32 #include "reqh/reqh_service.h"
33 #include "sns/cm/trigger_fop.h"
34 #include "sns/cm/service.h"
35 #include "sns/cm/cm.h"
36 #include "sns/cm/sns_cp_onwire.h"
37 
47  const struct m0_reqh_service_type *stype);
48 
51 };
52 
54  &rebalance_svc_type_ops, "M0_CST_SNS_REB", M0_CST_SNS_REB);
55 
57 static int rebalance_svc_start(struct m0_reqh_service *service);
58 static void rebalance_svc_stop(struct m0_reqh_service *service);
59 
60 static const struct m0_reqh_service_ops rebalance_svc_ops = {
62  .rso_start_async = m0_reqh_service_async_start_simple,
63  .rso_stop = rebalance_svc_stop,
64  .rso_fini = m0_sns_cm_svc_fini
65 };
66 
67 extern const struct m0_cm_ops sns_rebalance_ops;
68 extern const struct m0_fom_type_ops rebalance_cp_fom_type_ops;
69 
70 M0_INTERNAL void m0_sns_cm_rebalance_cpx_init(void);
71 M0_INTERNAL void m0_sns_cm_rebalance_cpx_fini(void);
72 
79  const struct m0_reqh_service_type *stype)
80 {
81  M0_ENTRY("stype: %p", stype);
82  M0_PRE(service != NULL && stype != NULL);
85 }
86 
88 {
89  int rc;
90 
92  if (rc == 0) {
97  }
98  return M0_RC(rc);
99 }
100 
102 {
107 }
108 
110 #undef M0_TRACE_SUBSYSTEM
111 
112 /*
113  * Local variables:
114  * c-indentation-style: "K&R"
115  * c-basic-offset: 8
116  * tab-width: 8
117  * fill-column: 80
118  * scroll-step: 1
119  * End:
120  */
#define M0_PRE(cond)
M0_INTERNAL void m0_sns_cm_svc_stop(struct m0_reqh_service *service)
Definition: service.c:108
int(* rso_start)(struct m0_reqh_service *service)
Definition: reqh_service.h:360
static const struct m0_reqh_service_ops rebalance_svc_ops
Definition: service.c:60
#define NULL
Definition: misc.h:38
M0_INTERNAL void m0_sns_cm_rebalance_trigger_fop_init(void)
Definition: trigger_fop.c:54
M0_INTERNAL int m0_sns_cm_svc_start(struct m0_reqh_service *service)
Definition: service.c:73
M0_INTERNAL void m0_sns_cm_rebalance_sw_onwire_fop_fini(void)
Definition: sw_onwire_fop.c:81
const struct m0_cm_ops sns_rebalance_ops
Definition: cm.c:187
const struct m0_fom_type_ops rebalance_cp_fom_type_ops
M0_INTERNAL void m0_sns_cm_rebalance_sw_onwire_fop_init(void)
Definition: sw_onwire_fop.c:63
M0_INTERNAL int m0_sns_cm_svc_allocate(struct m0_reqh_service **service, const struct m0_reqh_service_type *stype, const struct m0_reqh_service_ops *svc_ops, const struct m0_cm_ops *cm_ops)
Definition: service.c:43
return M0_RC(rc)
#define M0_ENTRY(...)
Definition: trace.h:170
M0_INTERNAL void m0_sns_cm_svc_fini(struct m0_reqh_service *service)
Definition: service.c:125
static const struct socktype stype[]
Definition: sock.c:1156
M0_INTERNAL void m0_sns_cm_rebalance_cpx_init(void)
M0_INTERNAL void m0_sns_cm_rebalance_cpx_fini(void)
Definition: cm.h:286
int m0_reqh_service_async_start_simple(struct m0_reqh_service_start_async_ctx *asc)
Definition: reqh_service.c:601
static int rebalance_svc_allocate(struct m0_reqh_service **service, const struct m0_reqh_service_type *stype)
Definition: service.c:78
M0_INTERNAL void m0_sns_cm_rebalance_trigger_fop_fini(void)
Definition: trigger_fop.c:42
static const struct m0_reqh_service_type_ops rebalance_svc_type_ops
Definition: service.c:49
int(* rsto_service_allocate)(struct m0_reqh_service **service, const struct m0_reqh_service_type *stype)
Definition: reqh_service.h:435
static int rebalance_svc_start(struct m0_reqh_service *service)
Definition: service.c:87
M0_CM_TYPE_DECLARE(sns_rebalance, M0_CM_REBALANCE_OPCODE, &rebalance_svc_type_ops, "M0_CST_SNS_REB", M0_CST_SNS_REB)
M0_EXTERN struct m0_cm_type sns_rebalance_cmt
Definition: cm.c:384
M0_INTERNAL void m0_cm_cp_init(struct m0_cm_type *cmtype, const struct m0_fom_type_ops *ft_ops)
Definition: cp.c:580
static void rebalance_svc_stop(struct m0_reqh_service *service)
Definition: service.c:101
static struct m0_reqh_service * service[REQH_IN_UT_MAX]
Definition: long_lock_ut.c:46
int32_t rc
Definition: trigger_fop.h:47