Motr  M0
spiel.c
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2015-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_SPIEL
24 #include "lib/trace.h"
25 
26 #include "lib/tlist.h"
27 #include "lib/memory.h"
28 #include "lib/string.h" /* m0_strdup, m0_strings_dup, m0_strings_free */
29 #include "lib/errno.h"
30 #include "lib/finject.h" /* M0_FI_ENABLED */
31 #include "lib/locality.h" /* m0_locality0_get */
32 #include "fid/fid.h" /* m0_fid_sscanf */
33 #include "conf/obj.h"
34 
35 #include "reqh/reqh.h"
36 #include "spiel/spiel.h"
37 #include "spiel/spiel_internal.h"
38 
44 int m0_spiel_init(struct m0_spiel *spiel, struct m0_reqh *reqh)
45 {
46  M0_PRE(reqh != NULL);
47  M0_ENTRY("spiel=%p reqh=%p", spiel, reqh);
48 
49  M0_SET0(spiel);
51  m0_reqh_rpc_mach_tlist_head(&reqh->rh_rpc_machines);
53  return M0_ERR(-ENOENT);
55  return M0_RC(0);
56 }
57 M0_EXPORTED(m0_spiel_init);
58 
60 {
61  M0_ENTRY("spiel=%p", spiel);
62  M0_LEAVE();
63 }
64 M0_EXPORTED(m0_spiel_fini);
65 
67  m0_rconfc_cb_t expired_cb)
68 {
69  int rc;
70  struct m0_rconfc *rconfc = &spiel->spl_rconfc;
71 
72  M0_ENTRY();
75 
78  expired_cb, NULL);
79  if (rc != 0)
80  return M0_ERR(rc);
81 
83  if (rc != 0) {
86  }
87  return M0_RC(rc);
88 }
89 M0_EXPORTED(m0_spiel_rconfc_start);
90 
92 {
93  M0_ENTRY();
96  M0_LEAVE();
97 }
98 M0_EXPORTED(m0_spiel_rconfc_stop);
99 
100 int m0_spiel_cmd_profile_set(struct m0_spiel *spiel, const char *profile_str)
101 {
102  M0_ENTRY("spiel = %p, profile = %s", spiel, profile_str);
103  M0_PRE(spiel != NULL);
104  if (profile_str == NULL)
105  profile_str = "<0:0>";
106  return M0_RC(m0_fid_sscanf(profile_str, spiel_profile(spiel)));
107 }
108 M0_EXPORTED(m0_spiel_cmd_profile_set);
109 
111 #undef M0_TRACE_SUBSYSTEM
112 
113 /*
114  * Local variables:
115  * c-indentation-style: "K&R"
116  * c-basic-offset: 8
117  * tab-width: 8
118  * fill-column: 80
119  * scroll-step: 1
120  * End:
121  */
int m0_spiel_cmd_profile_set(struct m0_spiel *spiel, const char *profile_str)
Definition: spiel.c:100
#define M0_PRE(cond)
#define NULL
Definition: misc.h:38
struct m0_rpc_machine * spc_rmachine
Definition: spiel.h:198
M0_LEAVE()
void m0_spiel_fini(struct m0_spiel *spiel)
Definition: spiel.c:59
void(* m0_rconfc_cb_t)(struct m0_rconfc *rconfc)
Definition: rconfc.h:215
void m0_spiel_rconfc_stop(struct m0_spiel *spiel)
Definition: spiel.c:91
M0_INTERNAL void m0_rconfc_stop_sync(struct m0_rconfc *rconfc)
Definition: rconfc.c:2995
#define M0_SET0(obj)
Definition: misc.h:64
M0_INTERNAL bool m0_fid_is_set(const struct m0_fid *fid)
Definition: fid.c:106
return M0_RC(rc)
#define M0_ENTRY(...)
Definition: trace.h:170
struct m0_spiel::m0_spiel_core spl_core
return M0_ERR(-EOPNOTSUPP)
struct m0_fid spc_profile
Definition: spiel.h:200
struct m0_tl rh_rpc_machines
Definition: reqh.h:135
struct m0_confc * spc_confc
Definition: spiel.h:210
static int m0_rconfc_start_sync(struct m0_rconfc *rconfc)
Definition: rconfc.h:502
Definition: reqh.h:94
static struct m0_rpc_machine * spiel_rmachine(struct m0_spiel *spl)
M0_INTERNAL int m0_fid_sscanf(const char *s, struct m0_fid *fid)
Definition: fid.c:227
M0_INTERNAL void m0_rconfc_fini(struct m0_rconfc *rconfc)
Definition: rconfc.c:3009
struct m0_reqh reqh
Definition: rm_foms.c:48
int m0_spiel_rconfc_start(struct m0_spiel *spiel, m0_rconfc_cb_t expired_cb)
Definition: spiel.c:66
M0_INTERNAL struct m0_locality * m0_locality0_get(void)
Definition: locality.c:169
struct m0_confc rc_confc
Definition: rconfc.h:235
struct m0_spiel spiel
Definition: spiel_conf_ut.c:42
static struct m0_rconfc * rconfc(struct m0_client *m0c)
Definition: client_init.c:310
struct m0_rconfc spl_rconfc
Definition: spiel.h:213
static struct m0_fid * spiel_profile(struct m0_spiel *spl)
M0_INTERNAL int m0_rconfc_init(struct m0_rconfc *rconfc, const struct m0_fid *profile, struct m0_sm_group *sm_group, struct m0_rpc_machine *rmach, m0_rconfc_cb_t expired_cb, m0_rconfc_cb_t ready_cb)
Definition: rconfc.c:2860
int32_t rc
Definition: trigger_fop.h:47
int m0_spiel_init(struct m0_spiel *spiel, struct m0_reqh *reqh)
Definition: spiel.c:44