File: | xlators/mgmt/glusterd/src/glusterd.c |
Location: | line 120, column 16 |
Description: | Access to field 'private' results in a dereference of a null pointer (loaded from variable 'this') |
1 | /* | |||
2 | Copyright (c) 2006-2012 Red Hat, Inc. <http://www.redhat.com> | |||
3 | This file is part of GlusterFS. | |||
4 | ||||
5 | This file is licensed to you under your choice of the GNU Lesser | |||
6 | General Public License, version 3 or any later version (LGPLv3 or | |||
7 | later), or the GNU General Public License, version 2 (GPLv2), in all | |||
8 | cases as published by the Free Software Foundation. | |||
9 | */ | |||
10 | ||||
11 | #ifndef _CONFIG_H | |||
12 | #define _CONFIG_H | |||
13 | #include "config.h" | |||
14 | #endif | |||
15 | #include <time.h> | |||
16 | #include <grp.h> | |||
17 | #include <sys/uio.h> | |||
18 | #include <sys/resource.h> | |||
19 | ||||
20 | #include <libgen.h> | |||
21 | #include "uuid.h" | |||
22 | ||||
23 | #include "glusterd.h" | |||
24 | #include "rpcsvc.h" | |||
25 | #include "fnmatch.h" | |||
26 | #include "xlator.h" | |||
27 | #include "call-stub.h" | |||
28 | #include "defaults.h" | |||
29 | #include "list.h" | |||
30 | #include "dict.h" | |||
31 | #include "compat.h" | |||
32 | #include "compat-errno.h" | |||
33 | #include "statedump.h" | |||
34 | #include "glusterd-sm.h" | |||
35 | #include "glusterd-op-sm.h" | |||
36 | #include "glusterd-store.h" | |||
37 | #include "glusterd-hooks.h" | |||
38 | #include "glusterd-utils.h" | |||
39 | #include "common-utils.h" | |||
40 | #include "run.h" | |||
41 | ||||
42 | #include "syncop.h" | |||
43 | ||||
44 | #include "glusterd-mountbroker.h" | |||
45 | ||||
46 | extern struct rpcsvc_program gluster_handshake_prog; | |||
47 | extern struct rpcsvc_program gluster_pmap_prog; | |||
48 | extern glusterd_op_info_t opinfo; | |||
49 | extern struct rpcsvc_program gd_svc_mgmt_prog; | |||
50 | extern struct rpcsvc_program gd_svc_peer_prog; | |||
51 | extern struct rpcsvc_program gd_svc_cli_prog; | |||
52 | extern struct rpc_clnt_program gd_brick_prog; | |||
53 | extern struct rpcsvc_program glusterd_mgmt_hndsk_prog; | |||
54 | ||||
55 | rpcsvc_cbk_program_t glusterd_cbk_prog = { | |||
56 | .progname = "Gluster Callback", | |||
57 | .prognum = GLUSTER_CBK_PROGRAM52743234, | |||
58 | .progver = GLUSTER_CBK_VERSION1, | |||
59 | }; | |||
60 | ||||
61 | struct rpcsvc_program *all_programs[] = { | |||
62 | &gd_svc_peer_prog, | |||
63 | &gd_svc_cli_prog, | |||
64 | &gd_svc_mgmt_prog, | |||
65 | &gluster_pmap_prog, | |||
66 | &gluster_handshake_prog, | |||
67 | &glusterd_mgmt_hndsk_prog, | |||
68 | }; | |||
69 | int rpcsvc_programs_count = (sizeof (all_programs) / sizeof (all_programs[0])); | |||
70 | ||||
71 | const char *gd_op_list[GD_OP_MAX + 1] = { | |||
72 | [GD_OP_NONE] = "Invalid op", | |||
73 | [GD_OP_CREATE_VOLUME] = "Create", | |||
74 | [GD_OP_START_BRICK] = "Start Brick", | |||
75 | [GD_OP_STOP_BRICK] = "Stop Brick", | |||
76 | [GD_OP_DELETE_VOLUME] = "Delete", | |||
77 | [GD_OP_START_VOLUME] = "Start", | |||
78 | [GD_OP_STOP_VOLUME] = "Stop", | |||
79 | [GD_OP_DEFRAG_VOLUME] = "Rebalance", | |||
80 | [GD_OP_ADD_BRICK] = "Add brick", | |||
81 | [GD_OP_REMOVE_BRICK] = "Remove brick", | |||
82 | [GD_OP_REPLACE_BRICK] = "Replace brick", | |||
83 | [GD_OP_SET_VOLUME] = "Set", | |||
84 | [GD_OP_RESET_VOLUME] = "Reset", | |||
85 | [GD_OP_SYNC_VOLUME] = "Sync", | |||
86 | [GD_OP_LOG_ROTATE] = "Log rotate", | |||
87 | [GD_OP_GSYNC_SET] = "Geo-replication", | |||
88 | [GD_OP_PROFILE_VOLUME] = "Profile", | |||
89 | [GD_OP_QUOTA] = "Quota", | |||
90 | [GD_OP_STATUS_VOLUME] = "Status", | |||
91 | [GD_OP_REBALANCE] = "Rebalance", | |||
92 | [GD_OP_HEAL_VOLUME] = "Heal", | |||
93 | [GD_OP_STATEDUMP_VOLUME] = "Statedump", | |||
94 | [GD_OP_LIST_VOLUME] = "Lists", | |||
95 | [GD_OP_CLEARLOCKS_VOLUME] = "Clear locks", | |||
96 | [GD_OP_DEFRAG_BRICK_VOLUME] = "Rebalance", | |||
97 | [GD_OP_MAX] = "Invalid op" | |||
98 | }; | |||
99 | ||||
100 | static int | |||
101 | glusterd_opinfo_init () | |||
102 | { | |||
103 | int32_t ret = -1; | |||
104 | ||||
105 | opinfo.op = GD_OP_NONE; | |||
106 | ||||
107 | return ret; | |||
108 | } | |||
109 | ||||
110 | ||||
111 | int | |||
112 | glusterd_uuid_init () | |||
113 | { | |||
114 | int ret = -1; | |||
115 | xlator_t *this = NULL((void*)0); | |||
116 | glusterd_conf_t *priv = NULL((void*)0); | |||
117 | ||||
118 | this = THIS(*__glusterfs_this_location()); | |||
| ||||
119 | GF_ASSERT (this)do { if (!(this)) { do { do { if (0) printf ("Assertion failed: " "this"); } while (0); _gf_log_callingfn ("", "glusterd.c", __FUNCTION__ , 119, GF_LOG_ERROR, "Assertion failed: " "this"); } while (0 ); } } while (0); | |||
120 | priv = this->private; | |||
| ||||
121 | ||||
122 | ret = glusterd_retrieve_uuid (); | |||
123 | if (ret == 0) { | |||
124 | gf_log (this->name, GF_LOG_INFO,do { do { if (0) printf ("retrieved UUID: %s", uuid_utoa (priv ->uuid)); } while (0); _gf_log (this->name, "glusterd.c" , __FUNCTION__, 125, GF_LOG_INFO, "retrieved UUID: %s", uuid_utoa (priv->uuid)); } while (0) | |||
125 | "retrieved UUID: %s", uuid_utoa (priv->uuid))do { do { if (0) printf ("retrieved UUID: %s", uuid_utoa (priv ->uuid)); } while (0); _gf_log (this->name, "glusterd.c" , __FUNCTION__, 125, GF_LOG_INFO, "retrieved UUID: %s", uuid_utoa (priv->uuid)); } while (0); | |||
126 | return 0; | |||
127 | } | |||
128 | ||||
129 | ret = glusterd_uuid_generate_save (); | |||
130 | ||||
131 | if (ret) { | |||
132 | gf_log ("glusterd", GF_LOG_ERROR,do { do { if (0) printf ("Unable to generate and save new UUID" ); } while (0); _gf_log ("glusterd", "glusterd.c", __FUNCTION__ , 133, GF_LOG_ERROR, "Unable to generate and save new UUID"); } while (0) | |||
133 | "Unable to generate and save new UUID")do { do { if (0) printf ("Unable to generate and save new UUID" ); } while (0); _gf_log ("glusterd", "glusterd.c", __FUNCTION__ , 133, GF_LOG_ERROR, "Unable to generate and save new UUID"); } while (0); | |||
134 | return ret; | |||
135 | } | |||
136 | ||||
137 | return 0; | |||
138 | } | |||
139 | ||||
140 | int | |||
141 | glusterd_uuid_generate_save () | |||
142 | { | |||
143 | int ret = -1; | |||
144 | glusterd_conf_t *priv = NULL((void*)0); | |||
145 | xlator_t *this = NULL((void*)0); | |||
146 | ||||
147 | this = THIS(*__glusterfs_this_location()); | |||
148 | GF_ASSERT (this)do { if (!(this)) { do { do { if (0) printf ("Assertion failed: " "this"); } while (0); _gf_log_callingfn ("", "glusterd.c", __FUNCTION__ , 148, GF_LOG_ERROR, "Assertion failed: " "this"); } while (0 ); } } while (0); | |||
149 | priv = this->private; | |||
150 | GF_ASSERT (priv)do { if (!(priv)) { do { do { if (0) printf ("Assertion failed: " "priv"); } while (0); _gf_log_callingfn ("", "glusterd.c", __FUNCTION__ , 150, GF_LOG_ERROR, "Assertion failed: " "priv"); } while (0 ); } } while (0); | |||
151 | ||||
152 | uuid_generate (priv->uuid); | |||
153 | ||||
154 | gf_log (this->name, GF_LOG_INFO, "generated UUID: %s",do { do { if (0) printf ("generated UUID: %s", uuid_utoa (priv ->uuid)); } while (0); _gf_log (this->name, "glusterd.c" , __FUNCTION__, 155, GF_LOG_INFO, "generated UUID: %s", uuid_utoa (priv->uuid)); } while (0) | |||
155 | uuid_utoa (priv->uuid))do { do { if (0) printf ("generated UUID: %s", uuid_utoa (priv ->uuid)); } while (0); _gf_log (this->name, "glusterd.c" , __FUNCTION__, 155, GF_LOG_INFO, "generated UUID: %s", uuid_utoa (priv->uuid)); } while (0); | |||
156 | ||||
157 | ret = glusterd_store_global_info (this); | |||
158 | ||||
159 | if (ret) | |||
160 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("Unable to store the generated uuid %s" , uuid_utoa (priv->uuid)); } while (0); _gf_log (this-> name, "glusterd.c", __FUNCTION__, 162, GF_LOG_ERROR, "Unable to store the generated uuid %s" , uuid_utoa (priv->uuid)); } while (0) | |||
161 | "Unable to store the generated uuid %s",do { do { if (0) printf ("Unable to store the generated uuid %s" , uuid_utoa (priv->uuid)); } while (0); _gf_log (this-> name, "glusterd.c", __FUNCTION__, 162, GF_LOG_ERROR, "Unable to store the generated uuid %s" , uuid_utoa (priv->uuid)); } while (0) | |||
162 | uuid_utoa (priv->uuid))do { do { if (0) printf ("Unable to store the generated uuid %s" , uuid_utoa (priv->uuid)); } while (0); _gf_log (this-> name, "glusterd.c", __FUNCTION__, 162, GF_LOG_ERROR, "Unable to store the generated uuid %s" , uuid_utoa (priv->uuid)); } while (0); | |||
163 | ||||
164 | return ret; | |||
165 | } | |||
166 | ||||
167 | int | |||
168 | glusterd_options_init (xlator_t *this) | |||
169 | { | |||
170 | int ret = -1; | |||
171 | glusterd_conf_t *priv = NULL((void*)0); | |||
172 | char *initial_version = "0"; | |||
173 | ||||
174 | priv = this->private; | |||
175 | ||||
176 | priv->opts = dict_new (); | |||
177 | if (!priv->opts) | |||
178 | goto out; | |||
179 | ||||
180 | ret = glusterd_store_retrieve_options (this); | |||
181 | if (ret == 0) | |||
182 | goto out; | |||
183 | ||||
184 | ret = dict_set_str (priv->opts, GLUSTERD_GLOBAL_OPT_VERSION"global-option-version", | |||
185 | initial_version); | |||
186 | if (ret) | |||
187 | goto out; | |||
188 | ret = glusterd_store_options (this, priv->opts); | |||
189 | if (ret) { | |||
190 | gf_log (this->name, GF_LOG_ERROR, "Unable to store version")do { do { if (0) printf ("Unable to store version"); } while ( 0); _gf_log (this->name, "glusterd.c", __FUNCTION__, 190, GF_LOG_ERROR , "Unable to store version"); } while (0); | |||
191 | return ret; | |||
192 | } | |||
193 | out: | |||
194 | ||||
195 | return 0; | |||
196 | } | |||
197 | int | |||
198 | glusterd_fetchspec_notify (xlator_t *this) | |||
199 | { | |||
200 | int ret = -1; | |||
201 | glusterd_conf_t *priv = NULL((void*)0); | |||
202 | rpc_transport_t *trans = NULL((void*)0); | |||
203 | ||||
204 | priv = this->private; | |||
205 | ||||
206 | pthread_mutex_lock (&priv->xprt_lock); | |||
207 | { | |||
208 | list_for_each_entry (trans, &priv->xprt_list, list)for (trans = ((typeof(*trans) *)((char *)((&priv->xprt_list )->next)-(unsigned long)(&((typeof(*trans) *)0)->list ))); &trans->list != (&priv->xprt_list); trans = ((typeof(*trans) *)((char *)(trans->list.next)-(unsigned long )(&((typeof(*trans) *)0)->list)))) { | |||
209 | rpcsvc_callback_submit (priv->rpc, trans, | |||
210 | &glusterd_cbk_prog, | |||
211 | GF_CBK_FETCHSPEC, NULL((void*)0), 0); | |||
212 | } | |||
213 | } | |||
214 | pthread_mutex_unlock (&priv->xprt_lock); | |||
215 | ||||
216 | ret = 0; | |||
217 | ||||
218 | return ret; | |||
219 | } | |||
220 | ||||
221 | int | |||
222 | glusterd_priv (xlator_t *this) | |||
223 | { | |||
224 | return 0; | |||
225 | } | |||
226 | ||||
227 | ||||
228 | ||||
229 | int32_t | |||
230 | mem_acct_init (xlator_t *this) | |||
231 | { | |||
232 | int ret = -1; | |||
233 | ||||
234 | if (!this) | |||
235 | return ret; | |||
236 | ||||
237 | ret = xlator_mem_acct_init (this, gf_gld_mt_end + 1); | |||
238 | ||||
239 | if (ret != 0) { | |||
240 | gf_log (this->name, GF_LOG_ERROR, "Memory accounting init"do { do { if (0) printf ("Memory accounting init" " failed"); } while (0); _gf_log (this->name, "glusterd.c", __FUNCTION__ , 241, GF_LOG_ERROR, "Memory accounting init" " failed"); } while (0) | |||
241 | " failed")do { do { if (0) printf ("Memory accounting init" " failed"); } while (0); _gf_log (this->name, "glusterd.c", __FUNCTION__ , 241, GF_LOG_ERROR, "Memory accounting init" " failed"); } while (0); | |||
242 | return ret; | |||
243 | } | |||
244 | ||||
245 | return ret; | |||
246 | } | |||
247 | ||||
248 | int | |||
249 | glusterd_rpcsvc_notify (rpcsvc_t *rpc, void *xl, rpcsvc_event_t event, | |||
250 | void *data) | |||
251 | { | |||
252 | xlator_t *this = NULL((void*)0); | |||
253 | rpc_transport_t *xprt = NULL((void*)0); | |||
254 | glusterd_conf_t *priv = NULL((void*)0); | |||
255 | ||||
256 | if (!xl || !data) { | |||
257 | gf_log ("glusterd", GF_LOG_WARNING,do { do { if (0) printf ("Calling rpc_notify without initializing" ); } while (0); _gf_log ("glusterd", "glusterd.c", __FUNCTION__ , 258, GF_LOG_WARNING, "Calling rpc_notify without initializing" ); } while (0) | |||
258 | "Calling rpc_notify without initializing")do { do { if (0) printf ("Calling rpc_notify without initializing" ); } while (0); _gf_log ("glusterd", "glusterd.c", __FUNCTION__ , 258, GF_LOG_WARNING, "Calling rpc_notify without initializing" ); } while (0); | |||
259 | goto out; | |||
260 | } | |||
261 | ||||
262 | this = xl; | |||
263 | xprt = data; | |||
264 | ||||
265 | priv = this->private; | |||
266 | ||||
267 | switch (event) { | |||
268 | case RPCSVC_EVENT_ACCEPT: | |||
269 | { | |||
270 | INIT_LIST_HEAD (&xprt->list)do { (&xprt->list)->next = (&xprt->list)-> prev = &xprt->list; } while (0); | |||
271 | ||||
272 | pthread_mutex_lock (&priv->xprt_lock); | |||
273 | list_add_tail (&xprt->list, &priv->xprt_list); | |||
274 | pthread_mutex_unlock (&priv->xprt_lock); | |||
275 | break; | |||
276 | } | |||
277 | case RPCSVC_EVENT_DISCONNECT: | |||
278 | { | |||
279 | pthread_mutex_lock (&priv->xprt_lock); | |||
280 | list_del (&xprt->list); | |||
281 | pthread_mutex_unlock (&priv->xprt_lock); | |||
282 | pmap_registry_remove (this, 0, NULL((void*)0), GF_PMAP_PORT_NONE, xprt); | |||
283 | break; | |||
284 | } | |||
285 | ||||
286 | default: | |||
287 | break; | |||
288 | } | |||
289 | ||||
290 | out: | |||
291 | return 0; | |||
292 | } | |||
293 | ||||
294 | ||||
295 | inline int32_t | |||
296 | glusterd_program_register (xlator_t *this, rpcsvc_t *svc, | |||
297 | rpcsvc_program_t *prog) | |||
298 | { | |||
299 | int32_t ret = -1; | |||
300 | ||||
301 | ret = rpcsvc_program_register (svc, prog); | |||
302 | if (ret) { | |||
303 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("cannot register program (name: %s, prognum:%d, " "progver:%d)", prog->progname, prog->prognum, prog-> progver); } while (0); _gf_log (this->name, "glusterd.c", __FUNCTION__ , 306, GF_LOG_DEBUG, "cannot register program (name: %s, prognum:%d, " "progver:%d)", prog->progname, prog->prognum, prog-> progver); } while (0) | |||
304 | "cannot register program (name: %s, prognum:%d, "do { do { if (0) printf ("cannot register program (name: %s, prognum:%d, " "progver:%d)", prog->progname, prog->prognum, prog-> progver); } while (0); _gf_log (this->name, "glusterd.c", __FUNCTION__ , 306, GF_LOG_DEBUG, "cannot register program (name: %s, prognum:%d, " "progver:%d)", prog->progname, prog->prognum, prog-> progver); } while (0) | |||
305 | "progver:%d)", prog->progname, prog->prognum,do { do { if (0) printf ("cannot register program (name: %s, prognum:%d, " "progver:%d)", prog->progname, prog->prognum, prog-> progver); } while (0); _gf_log (this->name, "glusterd.c", __FUNCTION__ , 306, GF_LOG_DEBUG, "cannot register program (name: %s, prognum:%d, " "progver:%d)", prog->progname, prog->prognum, prog-> progver); } while (0) | |||
306 | prog->progver)do { do { if (0) printf ("cannot register program (name: %s, prognum:%d, " "progver:%d)", prog->progname, prog->prognum, prog-> progver); } while (0); _gf_log (this->name, "glusterd.c", __FUNCTION__ , 306, GF_LOG_DEBUG, "cannot register program (name: %s, prognum:%d, " "progver:%d)", prog->progname, prog->prognum, prog-> progver); } while (0); | |||
307 | goto out; | |||
308 | } | |||
309 | ||||
310 | out: | |||
311 | return ret; | |||
312 | } | |||
313 | ||||
314 | int | |||
315 | glusterd_rpcsvc_options_build (dict_t *options) | |||
316 | { | |||
317 | int ret = 0; | |||
318 | uint32_t backlog = 0; | |||
319 | ||||
320 | ret = dict_get_uint32 (options, "transport.socket.listen-backlog", | |||
321 | &backlog); | |||
322 | ||||
323 | if (ret) { | |||
324 | backlog = GLUSTERD_SOCKET_LISTEN_BACKLOG128; | |||
325 | ret = dict_set_uint32 (options, | |||
326 | "transport.socket.listen-backlog", | |||
327 | backlog); | |||
328 | if (ret) | |||
329 | goto out; | |||
330 | } | |||
331 | ||||
332 | gf_log ("", GF_LOG_DEBUG, "listen-backlog value: %d", backlog)do { do { if (0) printf ("listen-backlog value: %d", backlog) ; } while (0); _gf_log ("", "glusterd.c", __FUNCTION__, 332, GF_LOG_DEBUG , "listen-backlog value: %d", backlog); } while (0); | |||
333 | ||||
334 | out: | |||
335 | return ret; | |||
336 | } | |||
337 | ||||
338 | #if SYNCDAEMON_COMPILE1 | |||
339 | static int | |||
340 | glusterd_check_gsync_present (int *valid_state) | |||
341 | { | |||
342 | char buff[PATH_MAX4096] = {0, }; | |||
343 | runner_t runner = {0,}; | |||
344 | char *ptr = NULL((void*)0); | |||
345 | int ret = 0; | |||
346 | ||||
347 | runinit (&runner); | |||
348 | runner_add_args (&runner, GSYNCD_PREFIX"/usr/local/libexec/glusterfs""/gsyncd", "--version", NULL((void*)0)); | |||
349 | runner_redir (&runner, STDOUT_FILENO1, RUN_PIPE-1); | |||
350 | ret = runner_start (&runner); | |||
351 | if (ret == -1) { | |||
352 | if (errno(*__errno_location ()) == ENOENT2) { | |||
353 | gf_log ("glusterd", GF_LOG_INFO, GEOREPdo { do { if (0) printf ("geo-replication" " module not installed in the system" ); } while (0); _gf_log ("glusterd", "glusterd.c", __FUNCTION__ , 354, GF_LOG_INFO, "geo-replication" " module not installed in the system" ); } while (0) | |||
354 | " module not installed in the system")do { do { if (0) printf ("geo-replication" " module not installed in the system" ); } while (0); _gf_log ("glusterd", "glusterd.c", __FUNCTION__ , 354, GF_LOG_INFO, "geo-replication" " module not installed in the system" ); } while (0); | |||
355 | *valid_state = 0; | |||
356 | } | |||
357 | else { | |||
358 | gf_log ("glusterd", GF_LOG_ERROR, GEOREPdo { do { if (0) printf ("geo-replication" " module not working as desired" ); } while (0); _gf_log ("glusterd", "glusterd.c", __FUNCTION__ , 359, GF_LOG_ERROR, "geo-replication" " module not working as desired" ); } while (0) | |||
359 | " module not working as desired")do { do { if (0) printf ("geo-replication" " module not working as desired" ); } while (0); _gf_log ("glusterd", "glusterd.c", __FUNCTION__ , 359, GF_LOG_ERROR, "geo-replication" " module not working as desired" ); } while (0); | |||
360 | *valid_state = -1; | |||
361 | } | |||
362 | goto out; | |||
363 | } | |||
364 | ||||
365 | ptr = fgets(buff, sizeof(buff), runner_chio (&runner, STDOUT_FILENO1)); | |||
366 | if (ptr) { | |||
367 | if (!strstr (buff, "gsyncd")) { | |||
368 | ret = -1; | |||
369 | gf_log ("glusterd", GF_LOG_ERROR, GEOREP" module not "do { do { if (0) printf ("geo-replication"" module not " "working as desired" ); } while (0); _gf_log ("glusterd", "glusterd.c", __FUNCTION__ , 370, GF_LOG_ERROR, "geo-replication"" module not " "working as desired" ); } while (0) | |||
370 | "working as desired")do { do { if (0) printf ("geo-replication"" module not " "working as desired" ); } while (0); _gf_log ("glusterd", "glusterd.c", __FUNCTION__ , 370, GF_LOG_ERROR, "geo-replication"" module not " "working as desired" ); } while (0); | |||
371 | *valid_state = -1; | |||
372 | goto out; | |||
373 | } | |||
374 | } else { | |||
375 | ret = -1; | |||
376 | gf_log ("glusterd", GF_LOG_ERROR, GEOREP" module not "do { do { if (0) printf ("geo-replication"" module not " "working as desired" ); } while (0); _gf_log ("glusterd", "glusterd.c", __FUNCTION__ , 377, GF_LOG_ERROR, "geo-replication"" module not " "working as desired" ); } while (0) | |||
377 | "working as desired")do { do { if (0) printf ("geo-replication"" module not " "working as desired" ); } while (0); _gf_log ("glusterd", "glusterd.c", __FUNCTION__ , 377, GF_LOG_ERROR, "geo-replication"" module not " "working as desired" ); } while (0); | |||
378 | *valid_state = -1; | |||
379 | goto out; | |||
380 | } | |||
381 | ||||
382 | ret = 0; | |||
383 | out: | |||
384 | ||||
385 | runner_end (&runner); | |||
386 | ||||
387 | gf_log ("glusterd", GF_LOG_DEBUG, "Returning %d", ret)do { do { if (0) printf ("Returning %d", ret); } while (0); _gf_log ("glusterd", "glusterd.c", __FUNCTION__, 387, GF_LOG_DEBUG, "Returning %d" , ret); } while (0); | |||
388 | return ret; | |||
389 | ||||
390 | } | |||
391 | ||||
392 | static int | |||
393 | group_write_allow (char *path, gid_t gid) | |||
394 | { | |||
395 | struct stat st = {0,}; | |||
396 | int ret = 0; | |||
397 | ||||
398 | ret = stat (path, &st); | |||
399 | if (ret == -1) | |||
400 | goto out; | |||
401 | GF_ASSERT (S_ISDIR (st.st_mode))do { if (!(((((st.st_mode)) & 0170000) == (0040000)))) { do { do { if (0) printf ("Assertion failed: " "S_ISDIR (st.st_mode)" ); } while (0); _gf_log_callingfn ("", "glusterd.c", __FUNCTION__ , 401, GF_LOG_ERROR, "Assertion failed: " "S_ISDIR (st.st_mode)" ); } while (0); } } while (0); | |||
402 | ||||
403 | ret = chown (path, -1, gid); | |||
404 | if (ret == -1) | |||
405 | goto out; | |||
406 | ||||
407 | ret = chmod (path, (st.st_mode & ~S_IFMT0170000) | S_IWGRP(0200 >> 3)|S_IXGRP(0100 >> 3)|S_ISVTX01000); | |||
408 | ||||
409 | out: | |||
410 | if (ret == -1) | |||
411 | gf_log ("", GF_LOG_CRITICAL,do { do { if (0) printf ("failed to set up write access to %s for group %d (%s)" , path, gid, strerror ((*__errno_location ()))); } while (0); _gf_log ("", "glusterd.c", __FUNCTION__, 413, GF_LOG_CRITICAL , "failed to set up write access to %s for group %d (%s)", path , gid, strerror ((*__errno_location ()))); } while (0) | |||
412 | "failed to set up write access to %s for group %d (%s)",do { do { if (0) printf ("failed to set up write access to %s for group %d (%s)" , path, gid, strerror ((*__errno_location ()))); } while (0); _gf_log ("", "glusterd.c", __FUNCTION__, 413, GF_LOG_CRITICAL , "failed to set up write access to %s for group %d (%s)", path , gid, strerror ((*__errno_location ()))); } while (0) | |||
413 | path, gid, strerror (errno))do { do { if (0) printf ("failed to set up write access to %s for group %d (%s)" , path, gid, strerror ((*__errno_location ()))); } while (0); _gf_log ("", "glusterd.c", __FUNCTION__, 413, GF_LOG_CRITICAL , "failed to set up write access to %s for group %d (%s)", path , gid, strerror ((*__errno_location ()))); } while (0); | |||
414 | return ret; | |||
415 | } | |||
416 | ||||
417 | static int | |||
418 | glusterd_crt_georep_folders (char *georepdir, glusterd_conf_t *conf) | |||
419 | { | |||
420 | char *greplg_s = NULL((void*)0); | |||
421 | struct group *gr = NULL((void*)0); | |||
422 | int ret = 0; | |||
423 | ||||
424 | GF_ASSERT (georepdir)do { if (!(georepdir)) { do { do { if (0) printf ("Assertion failed: " "georepdir"); } while (0); _gf_log_callingfn ("", "glusterd.c" , __FUNCTION__, 424, GF_LOG_ERROR, "Assertion failed: " "georepdir" ); } while (0); } } while (0); | |||
425 | GF_ASSERT (conf)do { if (!(conf)) { do { do { if (0) printf ("Assertion failed: " "conf"); } while (0); _gf_log_callingfn ("", "glusterd.c", __FUNCTION__ , 425, GF_LOG_ERROR, "Assertion failed: " "conf"); } while (0 ); } } while (0); | |||
426 | ||||
427 | if (strlen (conf->workdir)+2 > PATH_MAX4096-strlen(GEOREP"geo-replication")) { | |||
428 | ret = -1; | |||
429 | gf_log ("glusterd", GF_LOG_CRITICAL,do { do { if (0) printf ("directory path %s/""geo-replication" " is longer than PATH_MAX", conf->workdir); } while (0); _gf_log ("glusterd", "glusterd.c", __FUNCTION__, 431, GF_LOG_CRITICAL , "directory path %s/""geo-replication"" is longer than PATH_MAX" , conf->workdir); } while (0) | |||
430 | "directory path %s/"GEOREP" is longer than PATH_MAX",do { do { if (0) printf ("directory path %s/""geo-replication" " is longer than PATH_MAX", conf->workdir); } while (0); _gf_log ("glusterd", "glusterd.c", __FUNCTION__, 431, GF_LOG_CRITICAL , "directory path %s/""geo-replication"" is longer than PATH_MAX" , conf->workdir); } while (0) | |||
431 | conf->workdir)do { do { if (0) printf ("directory path %s/""geo-replication" " is longer than PATH_MAX", conf->workdir); } while (0); _gf_log ("glusterd", "glusterd.c", __FUNCTION__, 431, GF_LOG_CRITICAL , "directory path %s/""geo-replication"" is longer than PATH_MAX" , conf->workdir); } while (0); | |||
432 | goto out; | |||
433 | } | |||
434 | ||||
435 | snprintf (georepdir, PATH_MAX4096, "%s/"GEOREP"geo-replication", conf->workdir); | |||
436 | ret = mkdir_p (georepdir, 0777, _gf_true); | |||
437 | if (-1 == ret) { | |||
438 | gf_log ("glusterd", GF_LOG_CRITICAL,do { do { if (0) printf ("Unable to create ""geo-replication" " directory %s", georepdir); } while (0); _gf_log ("glusterd" , "glusterd.c", __FUNCTION__, 440, GF_LOG_CRITICAL, "Unable to create " "geo-replication"" directory %s", georepdir); } while (0) | |||
439 | "Unable to create "GEOREP" directory %s",do { do { if (0) printf ("Unable to create ""geo-replication" " directory %s", georepdir); } while (0); _gf_log ("glusterd" , "glusterd.c", __FUNCTION__, 440, GF_LOG_CRITICAL, "Unable to create " "geo-replication"" directory %s", georepdir); } while (0) | |||
440 | georepdir)do { do { if (0) printf ("Unable to create ""geo-replication" " directory %s", georepdir); } while (0); _gf_log ("glusterd" , "glusterd.c", __FUNCTION__, 440, GF_LOG_CRITICAL, "Unable to create " "geo-replication"" directory %s", georepdir); } while (0); | |||
441 | goto out; | |||
442 | } | |||
443 | ||||
444 | if (strlen (DEFAULT_LOG_FILE_DIRECTORY"/usr/local/var" "/log/glusterfs""/"GEOREP"geo-replication") >= PATH_MAX4096) { | |||
445 | ret = -1; | |||
446 | gf_log ("glusterd", GF_LOG_CRITICAL,do { do { if (0) printf ("directory path ""/usr/local/var" "/log/glusterfs" "/" "geo-replication"" is longer than PATH_MAX"); } while (0) ; _gf_log ("glusterd", "glusterd.c", __FUNCTION__, 448, GF_LOG_CRITICAL , "directory path ""/usr/local/var" "/log/glusterfs""/" "geo-replication" " is longer than PATH_MAX"); } while (0) | |||
447 | "directory path "DEFAULT_LOG_FILE_DIRECTORY"/"do { do { if (0) printf ("directory path ""/usr/local/var" "/log/glusterfs" "/" "geo-replication"" is longer than PATH_MAX"); } while (0) ; _gf_log ("glusterd", "glusterd.c", __FUNCTION__, 448, GF_LOG_CRITICAL , "directory path ""/usr/local/var" "/log/glusterfs""/" "geo-replication" " is longer than PATH_MAX"); } while (0) | |||
448 | GEOREP" is longer than PATH_MAX")do { do { if (0) printf ("directory path ""/usr/local/var" "/log/glusterfs" "/" "geo-replication"" is longer than PATH_MAX"); } while (0) ; _gf_log ("glusterd", "glusterd.c", __FUNCTION__, 448, GF_LOG_CRITICAL , "directory path ""/usr/local/var" "/log/glusterfs""/" "geo-replication" " is longer than PATH_MAX"); } while (0); | |||
449 | goto out; | |||
450 | } | |||
451 | ret = mkdir_p (DEFAULT_LOG_FILE_DIRECTORY"/usr/local/var" "/log/glusterfs""/"GEOREP"geo-replication", 0777, _gf_true); | |||
452 | if (-1 == ret) { | |||
453 | gf_log ("glusterd", GF_LOG_CRITICAL,do { do { if (0) printf ("Unable to create ""geo-replication" " log directory"); } while (0); _gf_log ("glusterd", "glusterd.c" , __FUNCTION__, 454, GF_LOG_CRITICAL, "Unable to create ""geo-replication" " log directory"); } while (0) | |||
454 | "Unable to create "GEOREP" log directory")do { do { if (0) printf ("Unable to create ""geo-replication" " log directory"); } while (0); _gf_log ("glusterd", "glusterd.c" , __FUNCTION__, 454, GF_LOG_CRITICAL, "Unable to create ""geo-replication" " log directory"); } while (0); | |||
455 | goto out; | |||
456 | } | |||
457 | ||||
458 | /* Slave log file directory */ | |||
459 | if (strlen(DEFAULT_LOG_FILE_DIRECTORY"/usr/local/var" "/log/glusterfs""/"GEOREP"geo-replication""-slaves") >= PATH_MAX4096) { | |||
460 | ret = -1; | |||
461 | gf_log ("glusterd", GF_LOG_CRITICAL,do { do { if (0) printf ("directory path ""/usr/local/var" "/log/glusterfs" "/" "geo-replication""-slaves"" is longer than PATH_MAX"); } while (0); _gf_log ("glusterd", "glusterd.c", __FUNCTION__, 463, GF_LOG_CRITICAL , "directory path ""/usr/local/var" "/log/glusterfs""/" "geo-replication" "-slaves"" is longer than PATH_MAX"); } while (0) | |||
462 | "directory path "DEFAULT_LOG_FILE_DIRECTORY"/"do { do { if (0) printf ("directory path ""/usr/local/var" "/log/glusterfs" "/" "geo-replication""-slaves"" is longer than PATH_MAX"); } while (0); _gf_log ("glusterd", "glusterd.c", __FUNCTION__, 463, GF_LOG_CRITICAL , "directory path ""/usr/local/var" "/log/glusterfs""/" "geo-replication" "-slaves"" is longer than PATH_MAX"); } while (0) | |||
463 | GEOREP"-slaves"" is longer than PATH_MAX")do { do { if (0) printf ("directory path ""/usr/local/var" "/log/glusterfs" "/" "geo-replication""-slaves"" is longer than PATH_MAX"); } while (0); _gf_log ("glusterd", "glusterd.c", __FUNCTION__, 463, GF_LOG_CRITICAL , "directory path ""/usr/local/var" "/log/glusterfs""/" "geo-replication" "-slaves"" is longer than PATH_MAX"); } while (0); | |||
464 | goto out; | |||
465 | } | |||
466 | ret = mkdir_p (DEFAULT_LOG_FILE_DIRECTORY"/usr/local/var" "/log/glusterfs""/"GEOREP"geo-replication""-slaves", 0777, | |||
467 | _gf_true); | |||
468 | if (-1 == ret) { | |||
469 | gf_log ("glusterd", GF_LOG_CRITICAL,do { do { if (0) printf ("Unable to create ""geo-replication" " slave log directory"); } while (0); _gf_log ("glusterd", "glusterd.c" , __FUNCTION__, 470, GF_LOG_CRITICAL, "Unable to create ""geo-replication" " slave log directory"); } while (0) | |||
470 | "Unable to create "GEOREP" slave log directory")do { do { if (0) printf ("Unable to create ""geo-replication" " slave log directory"); } while (0); _gf_log ("glusterd", "glusterd.c" , __FUNCTION__, 470, GF_LOG_CRITICAL, "Unable to create ""geo-replication" " slave log directory"); } while (0); | |||
471 | goto out; | |||
472 | } | |||
473 | ||||
474 | /* MountBroker log file directory */ | |||
475 | if (strlen(DEFAULT_LOG_FILE_DIRECTORY"/usr/local/var" "/log/glusterfs""/"GEOREP"geo-replication""-slaves/mbr") >= PATH_MAX4096) { | |||
476 | ret = -1; | |||
477 | gf_log ("glusterd", GF_LOG_CRITICAL,do { do { if (0) printf ("directory path ""/usr/local/var" "/log/glusterfs" "/""geo-replication" "-slaves/mbr"" is longer than PATH_MAX") ; } while (0); _gf_log ("glusterd", "glusterd.c", __FUNCTION__ , 479, GF_LOG_CRITICAL, "directory path ""/usr/local/var" "/log/glusterfs" "/""geo-replication" "-slaves/mbr"" is longer than PATH_MAX") ; } while (0) | |||
478 | "directory path "DEFAULT_LOG_FILE_DIRECTORY"/"GEOREPdo { do { if (0) printf ("directory path ""/usr/local/var" "/log/glusterfs" "/""geo-replication" "-slaves/mbr"" is longer than PATH_MAX") ; } while (0); _gf_log ("glusterd", "glusterd.c", __FUNCTION__ , 479, GF_LOG_CRITICAL, "directory path ""/usr/local/var" "/log/glusterfs" "/""geo-replication" "-slaves/mbr"" is longer than PATH_MAX") ; } while (0) | |||
479 | "-slaves/mbr"" is longer than PATH_MAX")do { do { if (0) printf ("directory path ""/usr/local/var" "/log/glusterfs" "/""geo-replication" "-slaves/mbr"" is longer than PATH_MAX") ; } while (0); _gf_log ("glusterd", "glusterd.c", __FUNCTION__ , 479, GF_LOG_CRITICAL, "directory path ""/usr/local/var" "/log/glusterfs" "/""geo-replication" "-slaves/mbr"" is longer than PATH_MAX") ; } while (0); | |||
480 | goto out; | |||
481 | } | |||
482 | ret = mkdir_p (DEFAULT_LOG_FILE_DIRECTORY"/usr/local/var" "/log/glusterfs""/"GEOREP"geo-replication""-slaves/mbr", 0777, | |||
483 | _gf_true); | |||
484 | if (-1 == ret) { | |||
485 | gf_log ("glusterd", GF_LOG_CRITICAL,do { do { if (0) printf ("Unable to create ""geo-replication" " mountbroker slave log directory"); } while (0); _gf_log ("glusterd" , "glusterd.c", __FUNCTION__, 486, GF_LOG_CRITICAL, "Unable to create " "geo-replication"" mountbroker slave log directory"); } while (0) | |||
486 | "Unable to create "GEOREP" mountbroker slave log directory")do { do { if (0) printf ("Unable to create ""geo-replication" " mountbroker slave log directory"); } while (0); _gf_log ("glusterd" , "glusterd.c", __FUNCTION__, 486, GF_LOG_CRITICAL, "Unable to create " "geo-replication"" mountbroker slave log directory"); } while (0); | |||
487 | goto out; | |||
488 | } | |||
489 | ||||
490 | ret = dict_get_str (THIS(*__glusterfs_this_location())->options, GEOREP"geo-replication""-log-group", &greplg_s); | |||
491 | if (ret) | |||
492 | ret = 0; | |||
493 | else { | |||
494 | gr = getgrnam (greplg_s); | |||
495 | if (!gr) { | |||
496 | gf_log ("glusterd", GF_LOG_CRITICAL,do { do { if (0) printf ("group ""geo-replication""-log-group %s does not exist" , greplg_s); } while (0); _gf_log ("glusterd", "glusterd.c", __FUNCTION__ , 497, GF_LOG_CRITICAL, "group ""geo-replication""-log-group %s does not exist" , greplg_s); } while (0) | |||
497 | "group "GEOREP"-log-group %s does not exist", greplg_s)do { do { if (0) printf ("group ""geo-replication""-log-group %s does not exist" , greplg_s); } while (0); _gf_log ("glusterd", "glusterd.c", __FUNCTION__ , 497, GF_LOG_CRITICAL, "group ""geo-replication""-log-group %s does not exist" , greplg_s); } while (0); | |||
498 | ret = -1; | |||
499 | goto out; | |||
500 | } | |||
501 | ||||
502 | ret = group_write_allow (DEFAULT_LOG_FILE_DIRECTORY"/usr/local/var" "/log/glusterfs""/"GEOREP"geo-replication", | |||
503 | gr->gr_gid); | |||
504 | if (ret == 0) | |||
505 | ret = group_write_allow (DEFAULT_LOG_FILE_DIRECTORY"/usr/local/var" "/log/glusterfs""/" | |||
506 | GEOREP"geo-replication""-slaves", gr->gr_gid); | |||
507 | if (ret == 0) | |||
508 | ret = group_write_allow (DEFAULT_LOG_FILE_DIRECTORY"/usr/local/var" "/log/glusterfs""/" | |||
509 | GEOREP"geo-replication""-slaves/mbr", gr->gr_gid); | |||
510 | } | |||
511 | ||||
512 | out: | |||
513 | gf_log("", GF_LOG_DEBUG, "Returning %d", ret)do { do { if (0) printf ("Returning %d", ret); } while (0); _gf_log ("", "glusterd.c", __FUNCTION__, 513, GF_LOG_DEBUG, "Returning %d" , ret); } while (0); | |||
514 | return ret; | |||
515 | } | |||
516 | ||||
517 | static void | |||
518 | runinit_gsyncd_setrx (runner_t *runner, glusterd_conf_t *conf) | |||
519 | { | |||
520 | runinit (runner); | |||
521 | runner_add_args (runner, GSYNCD_PREFIX"/usr/local/libexec/glusterfs""/gsyncd", "-c", NULL((void*)0)); | |||
522 | runner_argprintf (runner, "%s/"GSYNC_CONF"geo-replication""/gsyncd.conf",conf->workdir); | |||
523 | runner_add_arg (runner, "--config-set-rx"); | |||
524 | } | |||
525 | ||||
526 | static int | |||
527 | configure_syncdaemon (glusterd_conf_t *conf) | |||
528 | #define RUN_GSYNCD_CMD do { \ | |||
529 | ret = runner_run_reuse (&runner); \ | |||
530 | if (ret == -1) { \ | |||
531 | runner_log (&runner, "glusterd", GF_LOG_ERROR, "command failed"); \ | |||
532 | runner_end (&runner); \ | |||
533 | goto out; \ | |||
534 | } \ | |||
535 | runner_end (&runner); \ | |||
536 | } while (0) | |||
537 | { | |||
538 | int ret = 0; | |||
539 | runner_t runner = {0,}; | |||
540 | char georepdir[PATH_MAX4096] = {0,}; | |||
541 | int valid_state = 0; | |||
542 | ||||
543 | ret = setenv ("_GLUSTERD_CALLED_", "1", 1); | |||
544 | if (ret < 0) { | |||
545 | ret = 0; | |||
546 | goto out; | |||
547 | } | |||
548 | valid_state = -1; | |||
549 | ret = glusterd_check_gsync_present (&valid_state); | |||
550 | if (-1 == ret) { | |||
551 | ret = valid_state; | |||
552 | goto out; | |||
553 | } | |||
554 | ||||
555 | glusterd_crt_georep_folders (georepdir, conf); | |||
556 | if (ret) { | |||
557 | ret = 0; | |||
558 | goto out; | |||
559 | } | |||
560 | ||||
561 | /************ | |||
562 | * master pre-configuration | |||
563 | ************/ | |||
564 | ||||
565 | /* remote-gsyncd */ | |||
566 | runinit_gsyncd_setrx (&runner, conf); | |||
567 | runner_add_args (&runner, "remote-gsyncd", GSYNCD_PREFIX"/usr/local/libexec/glusterfs""/gsyncd", ".", ".", NULL((void*)0)); | |||
568 | RUN_GSYNCD_CMD; | |||
569 | ||||
570 | runinit_gsyncd_setrx (&runner, conf); | |||
571 | runner_add_args (&runner, "remote-gsyncd", "/nonexistent/gsyncd", | |||
572 | ".", "^ssh:", NULL((void*)0)); | |||
573 | RUN_GSYNCD_CMD; | |||
574 | ||||
575 | /* gluster-command-dir */ | |||
576 | runinit_gsyncd_setrx (&runner, conf); | |||
577 | runner_add_args (&runner, "gluster-command-dir", SBIN_DIR"/usr/local/sbin""/", | |||
578 | ".", ".", NULL((void*)0)); | |||
579 | RUN_GSYNCD_CMD; | |||
580 | ||||
581 | /* gluster-params */ | |||
582 | runinit_gsyncd_setrx (&runner, conf); | |||
583 | runner_add_args (&runner, "gluster-params", | |||
584 | "xlator-option=*-dht.assert-no-child-down=true", | |||
585 | ".", ".", NULL((void*)0)); | |||
586 | RUN_GSYNCD_CMD; | |||
587 | ||||
588 | /* ssh-command */ | |||
589 | runinit_gsyncd_setrx (&runner, conf); | |||
590 | runner_add_arg (&runner, "ssh-command"); | |||
591 | runner_argprintf (&runner, | |||
592 | "ssh -oPasswordAuthentication=no " | |||
593 | "-oStrictHostKeyChecking=no " | |||
594 | "-i %s/secret.pem", georepdir); | |||
595 | runner_add_args (&runner, ".", ".", NULL((void*)0)); | |||
596 | RUN_GSYNCD_CMD; | |||
597 | ||||
598 | /* pid-file */ | |||
599 | runinit_gsyncd_setrx (&runner, conf); | |||
600 | runner_add_arg (&runner, "pid-file"); | |||
601 | runner_argprintf (&runner, "%s/${mastervol}/${eSlave}.pid", georepdir); | |||
602 | runner_add_args (&runner, ".", ".", NULL((void*)0)); | |||
603 | RUN_GSYNCD_CMD; | |||
604 | ||||
605 | /* state-file */ | |||
606 | runinit_gsyncd_setrx (&runner, conf); | |||
607 | runner_add_arg (&runner, "state-file"); | |||
608 | runner_argprintf (&runner, "%s/${mastervol}/${eSlave}.status", georepdir); | |||
609 | runner_add_args (&runner, ".", ".", NULL((void*)0)); | |||
610 | RUN_GSYNCD_CMD; | |||
611 | ||||
612 | /* state-socket */ | |||
613 | runinit_gsyncd_setrx (&runner, conf); | |||
614 | runner_add_arg (&runner, "state-socket-unencoded"); | |||
615 | runner_argprintf (&runner, "%s/${mastervol}/${eSlave}.socket", georepdir); | |||
616 | runner_add_args (&runner, ".", ".", NULL((void*)0)); | |||
617 | RUN_GSYNCD_CMD; | |||
618 | ||||
619 | /* socketdir */ | |||
620 | runinit_gsyncd_setrx (&runner, conf); | |||
621 | runner_add_args (&runner, "socketdir", GLUSTERD_SOCK_DIR"/var/run", ".", ".", NULL((void*)0)); | |||
622 | RUN_GSYNCD_CMD; | |||
623 | ||||
624 | /* log-file */ | |||
625 | runinit_gsyncd_setrx (&runner, conf); | |||
626 | runner_add_args (&runner, | |||
627 | "log-file", | |||
628 | DEFAULT_LOG_FILE_DIRECTORY"/usr/local/var" "/log/glusterfs""/"GEOREP"geo-replication""/${mastervol}/${eSlave}.log", | |||
629 | ".", ".", NULL((void*)0)); | |||
630 | RUN_GSYNCD_CMD; | |||
631 | ||||
632 | /* gluster-log-file */ | |||
633 | runinit_gsyncd_setrx (&runner, conf); | |||
634 | runner_add_args (&runner, | |||
635 | "gluster-log-file", | |||
636 | DEFAULT_LOG_FILE_DIRECTORY"/usr/local/var" "/log/glusterfs""/"GEOREP"geo-replication""/${mastervol}/${eSlave}.gluster.log", | |||
637 | ".", ".", NULL((void*)0)); | |||
638 | RUN_GSYNCD_CMD; | |||
639 | ||||
640 | /************ | |||
641 | * slave pre-configuration | |||
642 | ************/ | |||
643 | ||||
644 | /* gluster-command-dir */ | |||
645 | runinit_gsyncd_setrx (&runner, conf); | |||
646 | runner_add_args (&runner, "gluster-command-dir", SBIN_DIR"/usr/local/sbin""/", | |||
647 | ".", NULL((void*)0)); | |||
648 | RUN_GSYNCD_CMD; | |||
649 | ||||
650 | /* gluster-params */ | |||
651 | runinit_gsyncd_setrx (&runner, conf); | |||
652 | runner_add_args (&runner, "gluster-params", | |||
653 | "xlator-option=*-dht.assert-no-child-down=true", | |||
654 | ".", NULL((void*)0)); | |||
655 | RUN_GSYNCD_CMD; | |||
656 | ||||
657 | /* log-file */ | |||
658 | runinit_gsyncd_setrx (&runner, conf); | |||
659 | runner_add_args (&runner, | |||
660 | "log-file", | |||
661 | DEFAULT_LOG_FILE_DIRECTORY"/usr/local/var" "/log/glusterfs""/"GEOREP"geo-replication""-slaves/${session_owner}:${eSlave}.log", | |||
662 | ".", NULL((void*)0)); | |||
663 | RUN_GSYNCD_CMD; | |||
664 | ||||
665 | /* MountBroker log-file */ | |||
666 | runinit_gsyncd_setrx (&runner, conf); | |||
667 | runner_add_args (&runner, | |||
668 | "log-file-mbr", | |||
669 | DEFAULT_LOG_FILE_DIRECTORY"/usr/local/var" "/log/glusterfs""/"GEOREP"geo-replication""-slaves/mbr/${session_owner}:${eSlave}.log", | |||
670 | ".", NULL((void*)0)); | |||
671 | RUN_GSYNCD_CMD; | |||
672 | ||||
673 | /* gluster-log-file */ | |||
674 | runinit_gsyncd_setrx (&runner, conf); | |||
675 | runner_add_args (&runner, | |||
676 | "gluster-log-file", | |||
677 | DEFAULT_LOG_FILE_DIRECTORY"/usr/local/var" "/log/glusterfs""/"GEOREP"geo-replication""-slaves/${session_owner}:${eSlave}.gluster.log", | |||
678 | ".", NULL((void*)0)); | |||
679 | RUN_GSYNCD_CMD; | |||
680 | ||||
681 | out: | |||
682 | return ret ? -1 : 0; | |||
683 | } | |||
684 | #undef RUN_GSYNCD_CMD | |||
685 | #else /* SYNCDAEMON_COMPILE */ | |||
686 | static int | |||
687 | configure_syncdaemon (glusterd_conf_t *conf) | |||
688 | { | |||
689 | return 0; | |||
690 | } | |||
691 | #endif /* !SYNCDAEMON_COMPILE */ | |||
692 | ||||
693 | ||||
694 | static int | |||
695 | check_prepare_mountbroker_root (char *mountbroker_root) | |||
696 | { | |||
697 | int dfd0 = -1; | |||
698 | int dfd = -1; | |||
699 | int dfd2 = -1; | |||
700 | struct stat st = {0,}; | |||
701 | struct stat st2 = {0,}; | |||
702 | int ret = 0; | |||
703 | ||||
704 | ret = open (mountbroker_root, O_RDONLY00); | |||
705 | if (ret != -1) { | |||
706 | dfd = ret; | |||
707 | ret = fstat (dfd, &st); | |||
708 | } | |||
709 | if (ret == -1 || !S_ISDIR (st.st_mode)((((st.st_mode)) & 0170000) == (0040000))) { | |||
710 | gf_log ("", GF_LOG_ERROR,do { do { if (0) printf ("cannot access mountbroker-root directory %s" , mountbroker_root); } while (0); _gf_log ("", "glusterd.c", __FUNCTION__ , 712, GF_LOG_ERROR, "cannot access mountbroker-root directory %s" , mountbroker_root); } while (0) | |||
711 | "cannot access mountbroker-root directory %s",do { do { if (0) printf ("cannot access mountbroker-root directory %s" , mountbroker_root); } while (0); _gf_log ("", "glusterd.c", __FUNCTION__ , 712, GF_LOG_ERROR, "cannot access mountbroker-root directory %s" , mountbroker_root); } while (0) | |||
712 | mountbroker_root)do { do { if (0) printf ("cannot access mountbroker-root directory %s" , mountbroker_root); } while (0); _gf_log ("", "glusterd.c", __FUNCTION__ , 712, GF_LOG_ERROR, "cannot access mountbroker-root directory %s" , mountbroker_root); } while (0); | |||
713 | ret = -1; | |||
714 | goto out; | |||
715 | } | |||
716 | if (st.st_uid != 0 || | |||
717 | (st.st_mode & (S_IWGRP(0200 >> 3)|S_IWOTH((0200 >> 3) >> 3)))) { | |||
718 | gf_log ("", GF_LOG_ERROR,do { do { if (0) printf ("permissions on mountbroker-root directory %s are " "too liberal", mountbroker_root); } while (0); _gf_log ("", "glusterd.c" , __FUNCTION__, 720, GF_LOG_ERROR, "permissions on mountbroker-root directory %s are " "too liberal", mountbroker_root); } while (0) | |||
719 | "permissions on mountbroker-root directory %s are "do { do { if (0) printf ("permissions on mountbroker-root directory %s are " "too liberal", mountbroker_root); } while (0); _gf_log ("", "glusterd.c" , __FUNCTION__, 720, GF_LOG_ERROR, "permissions on mountbroker-root directory %s are " "too liberal", mountbroker_root); } while (0) | |||
720 | "too liberal", mountbroker_root)do { do { if (0) printf ("permissions on mountbroker-root directory %s are " "too liberal", mountbroker_root); } while (0); _gf_log ("", "glusterd.c" , __FUNCTION__, 720, GF_LOG_ERROR, "permissions on mountbroker-root directory %s are " "too liberal", mountbroker_root); } while (0); | |||
721 | ret = -1; | |||
722 | goto out; | |||
723 | } | |||
724 | if (!(st.st_mode & (S_IXGRP(0100 >> 3)|S_IXOTH((0100 >> 3) >> 3)))) { | |||
725 | gf_log ("", GF_LOG_WARNING,do { do { if (0) printf ("permissions on mountbroker-root directory %s are " "probably too strict", mountbroker_root); } while (0); _gf_log ("", "glusterd.c", __FUNCTION__, 727, GF_LOG_WARNING, "permissions on mountbroker-root directory %s are " "probably too strict", mountbroker_root); } while (0) | |||
726 | "permissions on mountbroker-root directory %s are "do { do { if (0) printf ("permissions on mountbroker-root directory %s are " "probably too strict", mountbroker_root); } while (0); _gf_log ("", "glusterd.c", __FUNCTION__, 727, GF_LOG_WARNING, "permissions on mountbroker-root directory %s are " "probably too strict", mountbroker_root); } while (0) | |||
727 | "probably too strict", mountbroker_root)do { do { if (0) printf ("permissions on mountbroker-root directory %s are " "probably too strict", mountbroker_root); } while (0); _gf_log ("", "glusterd.c", __FUNCTION__, 727, GF_LOG_WARNING, "permissions on mountbroker-root directory %s are " "probably too strict", mountbroker_root); } while (0); | |||
728 | } | |||
729 | ||||
730 | dfd0 = dup (dfd); | |||
731 | ||||
732 | for (;;) { | |||
733 | ret = openat (dfd, "..", O_RDONLY00); | |||
734 | if (ret != -1) { | |||
735 | dfd2 = ret; | |||
736 | ret = fstat (dfd2, &st2); | |||
737 | } | |||
738 | if (ret == -1) { | |||
739 | gf_log ("", GF_LOG_ERROR,do { do { if (0) printf ("error while checking mountbroker-root ancestors " "%d (%s)", (*__errno_location ()), strerror ((*__errno_location ()))); } while (0); _gf_log ("", "glusterd.c", __FUNCTION__, 741, GF_LOG_ERROR, "error while checking mountbroker-root ancestors " "%d (%s)", (*__errno_location ()), strerror ((*__errno_location ()))); } while (0) | |||
740 | "error while checking mountbroker-root ancestors "do { do { if (0) printf ("error while checking mountbroker-root ancestors " "%d (%s)", (*__errno_location ()), strerror ((*__errno_location ()))); } while (0); _gf_log ("", "glusterd.c", __FUNCTION__, 741, GF_LOG_ERROR, "error while checking mountbroker-root ancestors " "%d (%s)", (*__errno_location ()), strerror ((*__errno_location ()))); } while (0) | |||
741 | "%d (%s)", errno, strerror (errno))do { do { if (0) printf ("error while checking mountbroker-root ancestors " "%d (%s)", (*__errno_location ()), strerror ((*__errno_location ()))); } while (0); _gf_log ("", "glusterd.c", __FUNCTION__, 741, GF_LOG_ERROR, "error while checking mountbroker-root ancestors " "%d (%s)", (*__errno_location ()), strerror ((*__errno_location ()))); } while (0); | |||
742 | goto out; | |||
743 | } | |||
744 | ||||
745 | if (st2.st_ino == st.st_ino) | |||
746 | break; /* arrived to root */ | |||
747 | ||||
748 | if (st2.st_uid != 0 || | |||
749 | ((st2.st_mode & (S_IWGRP(0200 >> 3)|S_IWOTH((0200 >> 3) >> 3))) && | |||
750 | !(st2.st_mode & S_ISVTX01000))) { | |||
751 | gf_log ("", GF_LOG_ERROR,do { do { if (0) printf ("permissions on ancestors of mountbroker-root " "directory are too liberal"); } while (0); _gf_log ("", "glusterd.c" , __FUNCTION__, 753, GF_LOG_ERROR, "permissions on ancestors of mountbroker-root " "directory are too liberal"); } while (0) | |||
752 | "permissions on ancestors of mountbroker-root "do { do { if (0) printf ("permissions on ancestors of mountbroker-root " "directory are too liberal"); } while (0); _gf_log ("", "glusterd.c" , __FUNCTION__, 753, GF_LOG_ERROR, "permissions on ancestors of mountbroker-root " "directory are too liberal"); } while (0) | |||
753 | "directory are too liberal")do { do { if (0) printf ("permissions on ancestors of mountbroker-root " "directory are too liberal"); } while (0); _gf_log ("", "glusterd.c" , __FUNCTION__, 753, GF_LOG_ERROR, "permissions on ancestors of mountbroker-root " "directory are too liberal"); } while (0); | |||
754 | ret = -1; | |||
755 | goto out; | |||
756 | } | |||
757 | if (!(st.st_mode & (S_IXGRP(0100 >> 3)|S_IXOTH((0100 >> 3) >> 3)))) { | |||
758 | gf_log ("", GF_LOG_WARNING,do { do { if (0) printf ("permissions on ancestors of mountbroker-root " "directory are probably too strict"); } while (0); _gf_log ( "", "glusterd.c", __FUNCTION__, 760, GF_LOG_WARNING, "permissions on ancestors of mountbroker-root " "directory are probably too strict"); } while (0) | |||
759 | "permissions on ancestors of mountbroker-root "do { do { if (0) printf ("permissions on ancestors of mountbroker-root " "directory are probably too strict"); } while (0); _gf_log ( "", "glusterd.c", __FUNCTION__, 760, GF_LOG_WARNING, "permissions on ancestors of mountbroker-root " "directory are probably too strict"); } while (0) | |||
760 | "directory are probably too strict")do { do { if (0) printf ("permissions on ancestors of mountbroker-root " "directory are probably too strict"); } while (0); _gf_log ( "", "glusterd.c", __FUNCTION__, 760, GF_LOG_WARNING, "permissions on ancestors of mountbroker-root " "directory are probably too strict"); } while (0); | |||
761 | } | |||
762 | ||||
763 | close (dfd); | |||
764 | dfd = dfd2; | |||
765 | st = st2; | |||
766 | } | |||
767 | ||||
768 | ret = mkdirat (dfd0, MB_HIVE"mb_hive", 0711); | |||
769 | if (ret == -1 && errno(*__errno_location ()) == EEXIST17) | |||
770 | ret = 0; | |||
771 | if (ret != -1) | |||
772 | ret = fstatat (dfd0, MB_HIVE"mb_hive", &st, AT_SYMLINK_NOFOLLOW0x100); | |||
773 | if (ret == -1 || st.st_mode != (S_IFDIR0040000|0711)) { | |||
774 | gf_log ("", GF_LOG_ERROR,do { do { if (0) printf ("failed to set up mountbroker-root directory %s" , mountbroker_root); } while (0); _gf_log ("", "glusterd.c", __FUNCTION__ , 776, GF_LOG_ERROR, "failed to set up mountbroker-root directory %s" , mountbroker_root); } while (0) | |||
775 | "failed to set up mountbroker-root directory %s",do { do { if (0) printf ("failed to set up mountbroker-root directory %s" , mountbroker_root); } while (0); _gf_log ("", "glusterd.c", __FUNCTION__ , 776, GF_LOG_ERROR, "failed to set up mountbroker-root directory %s" , mountbroker_root); } while (0) | |||
776 | mountbroker_root)do { do { if (0) printf ("failed to set up mountbroker-root directory %s" , mountbroker_root); } while (0); _gf_log ("", "glusterd.c", __FUNCTION__ , 776, GF_LOG_ERROR, "failed to set up mountbroker-root directory %s" , mountbroker_root); } while (0); | |||
777 | ret = -1; | |||
778 | goto out; | |||
779 | } | |||
780 | ||||
781 | ret = 0; | |||
782 | ||||
783 | out: | |||
784 | if (dfd0 != -1) | |||
785 | close (dfd0); | |||
786 | if (dfd != -1) | |||
787 | close (dfd); | |||
788 | if (dfd2 != -1) | |||
789 | close (dfd2); | |||
790 | ||||
791 | return ret; | |||
792 | } | |||
793 | ||||
794 | static int | |||
795 | _install_mount_spec (dict_t *opts, char *key, data_t *value, void *data) | |||
796 | { | |||
797 | glusterd_conf_t *priv = THIS(*__glusterfs_this_location())->private; | |||
798 | char *label = NULL((void*)0); | |||
799 | gf_boolean_t georep = _gf_false; | |||
800 | gf_boolean_t ghadoop = _gf_false; | |||
801 | char *pdesc = value->data; | |||
802 | char *volname = NULL((void*)0); | |||
803 | int rv = 0; | |||
804 | gf_mount_spec_t *mspec = NULL((void*)0); | |||
805 | char *user = NULL((void*)0); | |||
806 | char *volfile_server = NULL((void*)0); | |||
807 | ||||
808 | label = strtail (key, "mountbroker."); | |||
809 | ||||
810 | /* check for presence of geo-rep/hadoop label */ | |||
811 | if (!label) { | |||
812 | label = strtail (key, "mountbroker-"GEOREP"geo-replication""."); | |||
813 | if (label) | |||
814 | georep = _gf_true; | |||
815 | else { | |||
816 | label = strtail (key, "mountbroker-"GHADOOP"glusterfs-hadoop""."); | |||
817 | if (label) | |||
818 | ghadoop = _gf_true; | |||
819 | } | |||
820 | } | |||
821 | ||||
822 | if (!label) | |||
823 | return 0; | |||
824 | ||||
825 | mspec = GF_CALLOC (1, sizeof (*mspec), gf_gld_mt_mount_spec)__gf_calloc (1, sizeof (*mspec), gf_gld_mt_mount_spec); | |||
826 | if (!mspec) | |||
827 | goto err; | |||
828 | mspec->label = label; | |||
829 | ||||
830 | if (georep || ghadoop) { | |||
831 | volname = gf_strdup (pdesc); | |||
832 | if (!volname) | |||
833 | goto err; | |||
834 | user = strchr (volname, ':'); | |||
835 | if (user) { | |||
836 | *user = '\0'; | |||
837 | user++; | |||
838 | } else | |||
839 | user = label; | |||
840 | ||||
841 | if (georep) | |||
842 | rv = make_georep_mountspec (mspec, volname, user); | |||
843 | ||||
844 | if (ghadoop) { | |||
845 | volfile_server = strchr (user, ':'); | |||
846 | if (volfile_server) | |||
847 | *volfile_server++ = '\0'; | |||
848 | else | |||
849 | volfile_server = "localhost"; | |||
850 | ||||
851 | rv = make_ghadoop_mountspec (mspec, volname, user, volfile_server); | |||
852 | } | |||
853 | ||||
854 | GF_FREE (volname)__gf_free (volname); | |||
855 | if (rv != 0) | |||
856 | goto err; | |||
857 | } else if (parse_mount_pattern_desc (mspec, pdesc) != 0) | |||
858 | goto err; | |||
859 | ||||
860 | list_add_tail (&mspec->speclist, &priv->mount_specs); | |||
861 | ||||
862 | return 0; | |||
863 | err: | |||
864 | ||||
865 | gf_log ("", GF_LOG_ERROR,do { do { if (0) printf ("adding %smount spec failed: label: %s desc: %s" , georep ? "geo-replication"" " : "", label, pdesc); } while ( 0); _gf_log ("", "glusterd.c", __FUNCTION__, 867, GF_LOG_ERROR , "adding %smount spec failed: label: %s desc: %s", georep ? "geo-replication" " " : "", label, pdesc); } while (0) | |||
866 | "adding %smount spec failed: label: %s desc: %s",do { do { if (0) printf ("adding %smount spec failed: label: %s desc: %s" , georep ? "geo-replication"" " : "", label, pdesc); } while ( 0); _gf_log ("", "glusterd.c", __FUNCTION__, 867, GF_LOG_ERROR , "adding %smount spec failed: label: %s desc: %s", georep ? "geo-replication" " " : "", label, pdesc); } while (0) | |||
867 | georep ? GEOREP" " : "", label, pdesc)do { do { if (0) printf ("adding %smount spec failed: label: %s desc: %s" , georep ? "geo-replication"" " : "", label, pdesc); } while ( 0); _gf_log ("", "glusterd.c", __FUNCTION__, 867, GF_LOG_ERROR , "adding %smount spec failed: label: %s desc: %s", georep ? "geo-replication" " " : "", label, pdesc); } while (0); | |||
868 | ||||
869 | return -1; | |||
870 | } | |||
871 | ||||
872 | ||||
873 | static int | |||
874 | gd_default_synctask_cbk (int ret, call_frame_t *frame, void *opaque) | |||
875 | { | |||
876 | glusterd_conf_t *priv = THIS(*__glusterfs_this_location())->private; | |||
877 | synclock_unlock (&priv->big_lock); | |||
878 | return ret; | |||
879 | } | |||
880 | ||||
881 | static void | |||
882 | glusterd_launch_synctask (synctask_fn_t fn, void *opaque) | |||
883 | { | |||
884 | xlator_t *this = NULL((void*)0); | |||
885 | glusterd_conf_t *priv = NULL((void*)0); | |||
886 | int ret = -1; | |||
887 | ||||
888 | this = THIS(*__glusterfs_this_location()); | |||
889 | priv = this->private; | |||
890 | ||||
891 | synclock_lock (&priv->big_lock); | |||
892 | ret = synctask_new (this->ctx->env, fn, gd_default_synctask_cbk, NULL((void*)0), | |||
893 | opaque); | |||
894 | if (ret) | |||
895 | gf_log (this->name, GF_LOG_CRITICAL, "Failed to spawn bricks"do { do { if (0) printf ("Failed to spawn bricks" " and other volume related services" ); } while (0); _gf_log (this->name, "glusterd.c", __FUNCTION__ , 896, GF_LOG_CRITICAL, "Failed to spawn bricks" " and other volume related services" ); } while (0) | |||
896 | " and other volume related services")do { do { if (0) printf ("Failed to spawn bricks" " and other volume related services" ); } while (0); _gf_log (this->name, "glusterd.c", __FUNCTION__ , 896, GF_LOG_CRITICAL, "Failed to spawn bricks" " and other volume related services" ); } while (0); | |||
897 | } | |||
898 | ||||
899 | /* | |||
900 | * init - called during glusterd initialization | |||
901 | * | |||
902 | * @this: | |||
903 | * | |||
904 | */ | |||
905 | int | |||
906 | init (xlator_t *this) | |||
907 | { | |||
908 | int32_t ret = -1; | |||
909 | rpcsvc_t *rpc = NULL((void*)0); | |||
910 | glusterd_conf_t *conf = NULL((void*)0); | |||
911 | data_t *dir_data = NULL((void*)0); | |||
912 | struct stat buf = {0,}; | |||
913 | char storedir [PATH_MAX4096] = {0,}; | |||
914 | char workdir [PATH_MAX4096] = {0,}; | |||
915 | char hooks_dir [PATH_MAX4096] = {0,}; | |||
916 | char cmd_log_filename [PATH_MAX4096] = {0,}; | |||
917 | int first_time = 0; | |||
918 | char *mountbroker_root = NULL((void*)0); | |||
919 | int i = 0; | |||
920 | char *valgrind_str = NULL((void*)0); | |||
921 | ||||
922 | dir_data = dict_get (this->options, "working-directory"); | |||
923 | ||||
924 | if (!dir_data) { | |||
925 | //Use default working dir | |||
926 | strncpy (workdir, GLUSTERD_DEFAULT_WORKDIR"/var/lib/glusterd", PATH_MAX4096); | |||
927 | } else { | |||
928 | strncpy (workdir, dir_data->data, PATH_MAX4096); | |||
929 | } | |||
930 | ||||
931 | ret = stat (workdir, &buf); | |||
932 | if ((ret != 0) && (ENOENT2 != errno(*__errno_location ()))) { | |||
933 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("stat fails on %s, exiting. (errno = %d)" , workdir, (*__errno_location ())); } while (0); _gf_log (this ->name, "glusterd.c", __FUNCTION__, 935, GF_LOG_ERROR, "stat fails on %s, exiting. (errno = %d)" , workdir, (*__errno_location ())); } while (0) | |||
934 | "stat fails on %s, exiting. (errno = %d)",do { do { if (0) printf ("stat fails on %s, exiting. (errno = %d)" , workdir, (*__errno_location ())); } while (0); _gf_log (this ->name, "glusterd.c", __FUNCTION__, 935, GF_LOG_ERROR, "stat fails on %s, exiting. (errno = %d)" , workdir, (*__errno_location ())); } while (0) | |||
935 | workdir, errno)do { do { if (0) printf ("stat fails on %s, exiting. (errno = %d)" , workdir, (*__errno_location ())); } while (0); _gf_log (this ->name, "glusterd.c", __FUNCTION__, 935, GF_LOG_ERROR, "stat fails on %s, exiting. (errno = %d)" , workdir, (*__errno_location ())); } while (0); | |||
936 | exit (1); | |||
937 | } | |||
938 | ||||
939 | if ((!ret) && (!S_ISDIR(buf.st_mode)((((buf.st_mode)) & 0170000) == (0040000)))) { | |||
940 | gf_log (this->name, GF_LOG_CRITICAL,do { do { if (0) printf ("Provided working area %s is not a directory," "exiting", workdir); } while (0); _gf_log (this->name, "glusterd.c" , __FUNCTION__, 942, GF_LOG_CRITICAL, "Provided working area %s is not a directory," "exiting", workdir); } while (0) | |||
941 | "Provided working area %s is not a directory,"do { do { if (0) printf ("Provided working area %s is not a directory," "exiting", workdir); } while (0); _gf_log (this->name, "glusterd.c" , __FUNCTION__, 942, GF_LOG_CRITICAL, "Provided working area %s is not a directory," "exiting", workdir); } while (0) | |||
942 | "exiting", workdir)do { do { if (0) printf ("Provided working area %s is not a directory," "exiting", workdir); } while (0); _gf_log (this->name, "glusterd.c" , __FUNCTION__, 942, GF_LOG_CRITICAL, "Provided working area %s is not a directory," "exiting", workdir); } while (0); | |||
943 | exit (1); | |||
944 | } | |||
945 | ||||
946 | ||||
947 | if ((-1 == ret) && (ENOENT2 == errno(*__errno_location ()))) { | |||
948 | ret = mkdir (workdir, 0777); | |||
949 | ||||
950 | if (-1 == ret) { | |||
951 | gf_log (this->name, GF_LOG_CRITICAL,do { do { if (0) printf ("Unable to create directory %s" " ,errno = %d" , workdir, (*__errno_location ())); } while (0); _gf_log (this ->name, "glusterd.c", __FUNCTION__, 953, GF_LOG_CRITICAL, "Unable to create directory %s" " ,errno = %d", workdir, (*__errno_location ())); } while (0 ) | |||
952 | "Unable to create directory %s"do { do { if (0) printf ("Unable to create directory %s" " ,errno = %d" , workdir, (*__errno_location ())); } while (0); _gf_log (this ->name, "glusterd.c", __FUNCTION__, 953, GF_LOG_CRITICAL, "Unable to create directory %s" " ,errno = %d", workdir, (*__errno_location ())); } while (0 ) | |||
953 | " ,errno = %d", workdir, errno)do { do { if (0) printf ("Unable to create directory %s" " ,errno = %d" , workdir, (*__errno_location ())); } while (0); _gf_log (this ->name, "glusterd.c", __FUNCTION__, 953, GF_LOG_CRITICAL, "Unable to create directory %s" " ,errno = %d", workdir, (*__errno_location ())); } while (0 ); | |||
954 | exit (1); | |||
955 | } | |||
956 | ||||
957 | first_time = 1; | |||
958 | } | |||
959 | ||||
960 | gf_log (this->name, GF_LOG_INFO, "Using %s as working directory",do { do { if (0) printf ("Using %s as working directory", workdir ); } while (0); _gf_log (this->name, "glusterd.c", __FUNCTION__ , 961, GF_LOG_INFO, "Using %s as working directory", workdir) ; } while (0) | |||
961 | workdir)do { do { if (0) printf ("Using %s as working directory", workdir ); } while (0); _gf_log (this->name, "glusterd.c", __FUNCTION__ , 961, GF_LOG_INFO, "Using %s as working directory", workdir) ; } while (0); | |||
962 | ||||
963 | snprintf (cmd_log_filename, PATH_MAX4096,"%s/.cmd_log_history", | |||
964 | DEFAULT_LOG_FILE_DIRECTORY"/usr/local/var" "/log/glusterfs"); | |||
965 | ret = gf_cmd_log_init (cmd_log_filename); | |||
966 | ||||
967 | if (ret == -1) { | |||
968 | gf_log ("this->name", GF_LOG_CRITICAL,do { do { if (0) printf ("Unable to create cmd log file %s", cmd_log_filename ); } while (0); _gf_log ("this->name", "glusterd.c", __FUNCTION__ , 969, GF_LOG_CRITICAL, "Unable to create cmd log file %s", cmd_log_filename ); } while (0) | |||
969 | "Unable to create cmd log file %s", cmd_log_filename)do { do { if (0) printf ("Unable to create cmd log file %s", cmd_log_filename ); } while (0); _gf_log ("this->name", "glusterd.c", __FUNCTION__ , 969, GF_LOG_CRITICAL, "Unable to create cmd log file %s", cmd_log_filename ); } while (0); | |||
970 | exit (1); | |||
971 | } | |||
972 | ||||
973 | snprintf (storedir, PATH_MAX4096, "%s/vols", workdir); | |||
974 | ||||
975 | ret = mkdir (storedir, 0777); | |||
976 | ||||
977 | if ((-1 == ret) && (errno(*__errno_location ()) != EEXIST17)) { | |||
978 | gf_log (this->name, GF_LOG_CRITICAL,do { do { if (0) printf ("Unable to create volume directory %s" " ,errno = %d", storedir, (*__errno_location ())); } while ( 0); _gf_log (this->name, "glusterd.c", __FUNCTION__, 980, GF_LOG_CRITICAL , "Unable to create volume directory %s" " ,errno = %d", storedir , (*__errno_location ())); } while (0) | |||
979 | "Unable to create volume directory %s"do { do { if (0) printf ("Unable to create volume directory %s" " ,errno = %d", storedir, (*__errno_location ())); } while ( 0); _gf_log (this->name, "glusterd.c", __FUNCTION__, 980, GF_LOG_CRITICAL , "Unable to create volume directory %s" " ,errno = %d", storedir , (*__errno_location ())); } while (0) | |||
980 | " ,errno = %d", storedir, errno)do { do { if (0) printf ("Unable to create volume directory %s" " ,errno = %d", storedir, (*__errno_location ())); } while ( 0); _gf_log (this->name, "glusterd.c", __FUNCTION__, 980, GF_LOG_CRITICAL , "Unable to create volume directory %s" " ,errno = %d", storedir , (*__errno_location ())); } while (0); | |||
981 | exit (1); | |||
982 | } | |||
983 | ||||
984 | snprintf (storedir, PATH_MAX4096, "%s/peers", workdir); | |||
985 | ||||
986 | ret = mkdir (storedir, 0777); | |||
987 | ||||
988 | if ((-1 == ret) && (errno(*__errno_location ()) != EEXIST17)) { | |||
989 | gf_log (this->name, GF_LOG_CRITICAL,do { do { if (0) printf ("Unable to create peers directory %s" " ,errno = %d", storedir, (*__errno_location ())); } while ( 0); _gf_log (this->name, "glusterd.c", __FUNCTION__, 991, GF_LOG_CRITICAL , "Unable to create peers directory %s" " ,errno = %d", storedir , (*__errno_location ())); } while (0) | |||
990 | "Unable to create peers directory %s"do { do { if (0) printf ("Unable to create peers directory %s" " ,errno = %d", storedir, (*__errno_location ())); } while ( 0); _gf_log (this->name, "glusterd.c", __FUNCTION__, 991, GF_LOG_CRITICAL , "Unable to create peers directory %s" " ,errno = %d", storedir , (*__errno_location ())); } while (0) | |||
991 | " ,errno = %d", storedir, errno)do { do { if (0) printf ("Unable to create peers directory %s" " ,errno = %d", storedir, (*__errno_location ())); } while ( 0); _gf_log (this->name, "glusterd.c", __FUNCTION__, 991, GF_LOG_CRITICAL , "Unable to create peers directory %s" " ,errno = %d", storedir , (*__errno_location ())); } while (0); | |||
992 | exit (1); | |||
993 | } | |||
994 | ||||
995 | snprintf (storedir, PATH_MAX4096, "%s/bricks", DEFAULT_LOG_FILE_DIRECTORY"/usr/local/var" "/log/glusterfs"); | |||
996 | ret = mkdir (storedir, 0777); | |||
997 | if ((-1 == ret) && (errno(*__errno_location ()) != EEXIST17)) { | |||
998 | gf_log (this->name, GF_LOG_CRITICAL,do { do { if (0) printf ("Unable to create logs directory %s" " ,errno = %d", storedir, (*__errno_location ())); } while ( 0); _gf_log (this->name, "glusterd.c", __FUNCTION__, 1000, GF_LOG_CRITICAL, "Unable to create logs directory %s" " ,errno = %d" , storedir, (*__errno_location ())); } while (0) | |||
999 | "Unable to create logs directory %s"do { do { if (0) printf ("Unable to create logs directory %s" " ,errno = %d", storedir, (*__errno_location ())); } while ( 0); _gf_log (this->name, "glusterd.c", __FUNCTION__, 1000, GF_LOG_CRITICAL, "Unable to create logs directory %s" " ,errno = %d" , storedir, (*__errno_location ())); } while (0) | |||
1000 | " ,errno = %d", storedir, errno)do { do { if (0) printf ("Unable to create logs directory %s" " ,errno = %d", storedir, (*__errno_location ())); } while ( 0); _gf_log (this->name, "glusterd.c", __FUNCTION__, 1000, GF_LOG_CRITICAL, "Unable to create logs directory %s" " ,errno = %d" , storedir, (*__errno_location ())); } while (0); | |||
1001 | exit (1); | |||
1002 | } | |||
1003 | ||||
1004 | snprintf (storedir, PATH_MAX4096, "%s/nfs", workdir); | |||
1005 | ret = mkdir (storedir, 0777); | |||
1006 | if ((-1 == ret) && (errno(*__errno_location ()) != EEXIST17)) { | |||
1007 | gf_log (this->name, GF_LOG_CRITICAL,do { do { if (0) printf ("Unable to create nfs directory %s" " ,errno = %d" , storedir, (*__errno_location ())); } while (0); _gf_log (this ->name, "glusterd.c", __FUNCTION__, 1009, GF_LOG_CRITICAL, "Unable to create nfs directory %s" " ,errno = %d", storedir , (*__errno_location ())); } while (0) | |||
1008 | "Unable to create nfs directory %s"do { do { if (0) printf ("Unable to create nfs directory %s" " ,errno = %d" , storedir, (*__errno_location ())); } while (0); _gf_log (this ->name, "glusterd.c", __FUNCTION__, 1009, GF_LOG_CRITICAL, "Unable to create nfs directory %s" " ,errno = %d", storedir , (*__errno_location ())); } while (0) | |||
1009 | " ,errno = %d", storedir, errno)do { do { if (0) printf ("Unable to create nfs directory %s" " ,errno = %d" , storedir, (*__errno_location ())); } while (0); _gf_log (this ->name, "glusterd.c", __FUNCTION__, 1009, GF_LOG_CRITICAL, "Unable to create nfs directory %s" " ,errno = %d", storedir , (*__errno_location ())); } while (0); | |||
1010 | exit (1); | |||
1011 | } | |||
1012 | ||||
1013 | snprintf (storedir, PATH_MAX4096, "%s/glustershd", workdir); | |||
1014 | ret = mkdir (storedir, 0777); | |||
1015 | if ((-1 == ret) && (errno(*__errno_location ()) != EEXIST17)) { | |||
1016 | gf_log (this->name, GF_LOG_CRITICAL,do { do { if (0) printf ("Unable to create glustershd directory %s" " ,errno = %d", storedir, (*__errno_location ())); } while ( 0); _gf_log (this->name, "glusterd.c", __FUNCTION__, 1018, GF_LOG_CRITICAL, "Unable to create glustershd directory %s" " ,errno = %d" , storedir, (*__errno_location ())); } while (0) | |||
1017 | "Unable to create glustershd directory %s"do { do { if (0) printf ("Unable to create glustershd directory %s" " ,errno = %d", storedir, (*__errno_location ())); } while ( 0); _gf_log (this->name, "glusterd.c", __FUNCTION__, 1018, GF_LOG_CRITICAL, "Unable to create glustershd directory %s" " ,errno = %d" , storedir, (*__errno_location ())); } while (0) | |||
1018 | " ,errno = %d", storedir, errno)do { do { if (0) printf ("Unable to create glustershd directory %s" " ,errno = %d", storedir, (*__errno_location ())); } while ( 0); _gf_log (this->name, "glusterd.c", __FUNCTION__, 1018, GF_LOG_CRITICAL, "Unable to create glustershd directory %s" " ,errno = %d" , storedir, (*__errno_location ())); } while (0); | |||
1019 | exit (1); | |||
1020 | } | |||
1021 | ||||
1022 | snprintf (storedir, PATH_MAX4096, "%s/groups", workdir); | |||
1023 | ret = mkdir (storedir, 0777); | |||
1024 | if ((-1 == ret) && (errno(*__errno_location ()) != EEXIST17)) { | |||
1025 | gf_log (this->name, GF_LOG_CRITICAL,do { do { if (0) printf ("Unable to create glustershd directory %s" " ,errno = %d", storedir, (*__errno_location ())); } while ( 0); _gf_log (this->name, "glusterd.c", __FUNCTION__, 1027, GF_LOG_CRITICAL, "Unable to create glustershd directory %s" " ,errno = %d" , storedir, (*__errno_location ())); } while (0) | |||
1026 | "Unable to create glustershd directory %s"do { do { if (0) printf ("Unable to create glustershd directory %s" " ,errno = %d", storedir, (*__errno_location ())); } while ( 0); _gf_log (this->name, "glusterd.c", __FUNCTION__, 1027, GF_LOG_CRITICAL, "Unable to create glustershd directory %s" " ,errno = %d" , storedir, (*__errno_location ())); } while (0) | |||
1027 | " ,errno = %d", storedir, errno)do { do { if (0) printf ("Unable to create glustershd directory %s" " ,errno = %d", storedir, (*__errno_location ())); } while ( 0); _gf_log (this->name, "glusterd.c", __FUNCTION__, 1027, GF_LOG_CRITICAL, "Unable to create glustershd directory %s" " ,errno = %d" , storedir, (*__errno_location ())); } while (0); | |||
1028 | exit (1); | |||
1029 | } | |||
1030 | ||||
1031 | ret = glusterd_rpcsvc_options_build (this->options); | |||
1032 | if (ret) | |||
1033 | goto out; | |||
1034 | rpc = rpcsvc_init (this, this->ctx, this->options, 64); | |||
1035 | if (rpc == NULL((void*)0)) { | |||
1036 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("failed to init rpc"); } while (0); _gf_log (this->name, "glusterd.c", __FUNCTION__, 1037, GF_LOG_ERROR , "failed to init rpc"); } while (0) | |||
1037 | "failed to init rpc")do { do { if (0) printf ("failed to init rpc"); } while (0); _gf_log (this->name, "glusterd.c", __FUNCTION__, 1037, GF_LOG_ERROR , "failed to init rpc"); } while (0); | |||
1038 | goto out; | |||
1039 | } | |||
1040 | ||||
1041 | ret = rpcsvc_register_notify (rpc, glusterd_rpcsvc_notify, this); | |||
1042 | if (ret) { | |||
1043 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("rpcsvc_register_notify returned %d" , ret); } while (0); _gf_log (this->name, "glusterd.c", __FUNCTION__ , 1044, GF_LOG_ERROR, "rpcsvc_register_notify returned %d", ret ); } while (0) | |||
1044 | "rpcsvc_register_notify returned %d", ret)do { do { if (0) printf ("rpcsvc_register_notify returned %d" , ret); } while (0); _gf_log (this->name, "glusterd.c", __FUNCTION__ , 1044, GF_LOG_ERROR, "rpcsvc_register_notify returned %d", ret ); } while (0); | |||
1045 | goto out; | |||
1046 | } | |||
1047 | ||||
1048 | /* | |||
1049 | * only one (atmost a pair - rdma and socket) listener for | |||
1050 | * glusterd1_mop_prog, gluster_pmap_prog and gluster_handshake_prog. | |||
1051 | */ | |||
1052 | ret = rpcsvc_create_listeners (rpc, this->options, this->name); | |||
1053 | if (ret < 1) { | |||
1054 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("creation of listener failed"); } while (0); _gf_log (this->name, "glusterd.c", __FUNCTION__, 1055 , GF_LOG_ERROR, "creation of listener failed"); } while (0) | |||
1055 | "creation of listener failed")do { do { if (0) printf ("creation of listener failed"); } while (0); _gf_log (this->name, "glusterd.c", __FUNCTION__, 1055 , GF_LOG_ERROR, "creation of listener failed"); } while (0); | |||
1056 | ret = -1; | |||
1057 | goto out; | |||
1058 | } | |||
1059 | ||||
1060 | for (i = 0; i < rpcsvc_programs_count; i++) { | |||
1061 | ret = glusterd_program_register (this, rpc, all_programs[i]); | |||
1062 | if (ret) { | |||
1063 | i--; | |||
1064 | for (; i >= 0; i--) | |||
1065 | rpcsvc_program_unregister (rpc, | |||
1066 | all_programs[i]); | |||
1067 | ||||
1068 | goto out; | |||
1069 | } | |||
1070 | } | |||
1071 | ||||
1072 | conf = GF_CALLOC (1, sizeof (glusterd_conf_t),__gf_calloc (1, sizeof (glusterd_conf_t), gf_gld_mt_glusterd_conf_t ) | |||
1073 | gf_gld_mt_glusterd_conf_t)__gf_calloc (1, sizeof (glusterd_conf_t), gf_gld_mt_glusterd_conf_t ); | |||
1074 | GF_VALIDATE_OR_GOTO(this->name, conf, out)do { if (!conf) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "conf"); } while (0); _gf_log_callingfn (this->name, "glusterd.c", __FUNCTION__, 1074, GF_LOG_ERROR , "invalid argument: " "conf"); } while (0); goto out; } } while (0); | |||
1075 | conf->shd = GF_CALLOC (1, sizeof (nodesrv_t),__gf_calloc (1, sizeof (nodesrv_t), gf_gld_mt_nodesrv_t) | |||
1076 | gf_gld_mt_nodesrv_t)__gf_calloc (1, sizeof (nodesrv_t), gf_gld_mt_nodesrv_t); | |||
1077 | GF_VALIDATE_OR_GOTO(this->name, conf->shd, out)do { if (!conf->shd) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "conf->shd"); } while (0); _gf_log_callingfn (this->name, "glusterd.c", __FUNCTION__ , 1077, GF_LOG_ERROR, "invalid argument: " "conf->shd"); } while (0); goto out; } } while (0); | |||
1078 | conf->nfs = GF_CALLOC (1, sizeof (nodesrv_t),__gf_calloc (1, sizeof (nodesrv_t), gf_gld_mt_nodesrv_t) | |||
1079 | gf_gld_mt_nodesrv_t)__gf_calloc (1, sizeof (nodesrv_t), gf_gld_mt_nodesrv_t); | |||
1080 | GF_VALIDATE_OR_GOTO(this->name, conf->nfs, out)do { if (!conf->nfs) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "conf->nfs"); } while (0); _gf_log_callingfn (this->name, "glusterd.c", __FUNCTION__ , 1080, GF_LOG_ERROR, "invalid argument: " "conf->nfs"); } while (0); goto out; } } while (0); | |||
1081 | ||||
1082 | INIT_LIST_HEAD (&conf->peers)do { (&conf->peers)->next = (&conf->peers)-> prev = &conf->peers; } while (0); | |||
1083 | INIT_LIST_HEAD (&conf->volumes)do { (&conf->volumes)->next = (&conf->volumes )->prev = &conf->volumes; } while (0); | |||
1084 | pthread_mutex_init (&conf->mutex, NULL((void*)0)); | |||
1085 | conf->rpc = rpc; | |||
1086 | conf->gfs_mgmt = &gd_brick_prog; | |||
1087 | strncpy (conf->workdir, workdir, PATH_MAX4096); | |||
1088 | ||||
1089 | synclock_init (&conf->big_lock); | |||
1090 | pthread_mutex_init (&conf->xprt_lock, NULL((void*)0)); | |||
1091 | INIT_LIST_HEAD (&conf->xprt_list)do { (&conf->xprt_list)->next = (&conf->xprt_list )->prev = &conf->xprt_list; } while (0); | |||
1092 | ||||
1093 | glusterd_friend_sm_init (); | |||
1094 | glusterd_op_sm_init (); | |||
1095 | glusterd_opinfo_init (); | |||
1096 | ret = glusterd_sm_tr_log_init (&conf->op_sm_log, | |||
1097 | glusterd_op_sm_state_name_get, | |||
1098 | glusterd_op_sm_event_name_get, | |||
1099 | GLUSTERD_TR_LOG_SIZE50); | |||
1100 | if (ret) | |||
1101 | goto out; | |||
1102 | ||||
1103 | /* Set option to run bricks on valgrind if enabled in glusterd.vol */ | |||
1104 | conf->valgrind = _gf_false; | |||
1105 | ret = dict_get_str (this->options, "run-with-valgrind", &valgrind_str); | |||
1106 | if (ret < 0) { | |||
1107 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("cannot get run-with-valgrind value" ); } while (0); _gf_log (this->name, "glusterd.c", __FUNCTION__ , 1108, GF_LOG_DEBUG, "cannot get run-with-valgrind value"); } while (0) | |||
1108 | "cannot get run-with-valgrind value")do { do { if (0) printf ("cannot get run-with-valgrind value" ); } while (0); _gf_log (this->name, "glusterd.c", __FUNCTION__ , 1108, GF_LOG_DEBUG, "cannot get run-with-valgrind value"); } while (0); | |||
1109 | } | |||
1110 | if (valgrind_str) { | |||
1111 | if (gf_string2boolean (valgrind_str, &(conf->valgrind))) { | |||
1112 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("run-with-valgrind value not a boolean string" ); } while (0); _gf_log (this->name, "glusterd.c", __FUNCTION__ , 1113, GF_LOG_WARNING, "run-with-valgrind value not a boolean string" ); } while (0) | |||
1113 | "run-with-valgrind value not a boolean string")do { do { if (0) printf ("run-with-valgrind value not a boolean string" ); } while (0); _gf_log (this->name, "glusterd.c", __FUNCTION__ , 1113, GF_LOG_WARNING, "run-with-valgrind value not a boolean string" ); } while (0); | |||
1114 | } | |||
1115 | } | |||
1116 | ||||
1117 | this->private = conf; | |||
1118 | (void) glusterd_nodesvc_set_online_status ("glustershd", _gf_false); | |||
1119 | ||||
1120 | GLUSTERD_GET_HOOKS_DIR (hooks_dir, GLUSTERD_HOOK_VER, conf)snprintf (hooks_dir, 4096, "%s/hooks/%d", conf->workdir, 1 );; | |||
1121 | if (stat (hooks_dir, &buf)) { | |||
1122 | ret = glusterd_hooks_create_hooks_directory (conf->workdir); | |||
1123 | if (-1 == ret) { | |||
1124 | gf_log (this->name, GF_LOG_CRITICAL,do { do { if (0) printf ("Unable to create hooks directory ") ; } while (0); _gf_log (this->name, "glusterd.c", __FUNCTION__ , 1125, GF_LOG_CRITICAL, "Unable to create hooks directory ") ; } while (0) | |||
1125 | "Unable to create hooks directory ")do { do { if (0) printf ("Unable to create hooks directory ") ; } while (0); _gf_log (this->name, "glusterd.c", __FUNCTION__ , 1125, GF_LOG_CRITICAL, "Unable to create hooks directory ") ; } while (0); | |||
1126 | exit (1); | |||
1127 | } | |||
1128 | } | |||
1129 | ||||
1130 | INIT_LIST_HEAD (&conf->mount_specs)do { (&conf->mount_specs)->next = (&conf->mount_specs )->prev = &conf->mount_specs; } while (0); | |||
1131 | ||||
1132 | ret = dict_foreach (this->options, _install_mount_spec, NULL((void*)0)); | |||
1133 | if (ret) | |||
1134 | goto out; | |||
1135 | ret = dict_get_str (this->options, "mountbroker-root", | |||
1136 | &mountbroker_root); | |||
1137 | if (ret) | |||
1138 | ret = 0; | |||
1139 | else | |||
1140 | ret = check_prepare_mountbroker_root (mountbroker_root); | |||
1141 | if (ret) | |||
1142 | goto out; | |||
1143 | ||||
1144 | ret = configure_syncdaemon (conf); | |||
1145 | if (ret) | |||
1146 | goto out; | |||
1147 | ||||
1148 | ret = glusterd_restore (); | |||
1149 | if (ret < 0) | |||
1150 | goto out; | |||
1151 | ||||
1152 | /* If there are no 'friends', this would be the best time to | |||
1153 | * spawn process/bricks that may need (re)starting since last | |||
1154 | * time (this) glusterd was up.*/ | |||
1155 | ||||
1156 | if (list_empty (&conf->peers)) { | |||
1157 | glusterd_launch_synctask (glusterd_spawn_daemons, | |||
1158 | (void*) _gf_true); | |||
1159 | } | |||
1160 | ret = glusterd_options_init (this); | |||
1161 | if (ret < 0) | |||
1162 | goto out; | |||
1163 | ||||
1164 | ret = glusterd_handle_upgrade_downgrade (this->options, conf); | |||
1165 | if (ret) | |||
1166 | goto out; | |||
1167 | ||||
1168 | ret = glusterd_hooks_spawn_worker (this); | |||
1169 | if (ret) | |||
1170 | goto out; | |||
1171 | ||||
1172 | ret = 0; | |||
1173 | out: | |||
1174 | if (ret < 0) { | |||
1175 | if (this->private != NULL((void*)0)) { | |||
1176 | GF_FREE (this->private)__gf_free (this->private); | |||
1177 | this->private = NULL((void*)0); | |||
1178 | } | |||
1179 | ||||
1180 | } | |||
1181 | ||||
1182 | return ret; | |||
1183 | } | |||
1184 | ||||
1185 | ||||
1186 | ||||
1187 | ||||
1188 | /* | |||
1189 | * fini - finish function for glusterd, called before | |||
1190 | * unloading gluster. | |||
1191 | * | |||
1192 | * @this: | |||
1193 | * | |||
1194 | */ | |||
1195 | void | |||
1196 | fini (xlator_t *this) | |||
1197 | { | |||
1198 | glusterd_conf_t *conf = NULL((void*)0); | |||
1199 | if (!this || !this->private) | |||
1200 | goto out; | |||
1201 | ||||
1202 | conf = this->private; | |||
1203 | FREE (conf->pmap)if (conf->pmap != ((void*)0)) { free ((void *)conf->pmap ); conf->pmap = (void *)0xeeeeeeee; }; | |||
1204 | if (conf->handle) | |||
1205 | glusterd_store_handle_destroy (conf->handle); | |||
1206 | glusterd_sm_tr_log_delete (&conf->op_sm_log); | |||
1207 | GF_FREE (conf)__gf_free (conf); | |||
1208 | this->private = NULL((void*)0); | |||
1209 | out: | |||
1210 | return; | |||
1211 | } | |||
1212 | ||||
1213 | /* | |||
1214 | * notify - notify function for glusterd | |||
1215 | * @this: | |||
1216 | * @trans: | |||
1217 | * @event: | |||
1218 | * | |||
1219 | */ | |||
1220 | int | |||
1221 | notify (xlator_t *this, int32_t event, void *data, ...) | |||
1222 | { | |||
1223 | int ret = 0; | |||
1224 | ||||
1225 | switch (event) { | |||
1226 | case GF_EVENT_POLLIN: | |||
1227 | break; | |||
1228 | ||||
1229 | case GF_EVENT_POLLERR: | |||
1230 | break; | |||
1231 | ||||
1232 | case GF_EVENT_TRANSPORT_CLEANUP: | |||
1233 | break; | |||
1234 | ||||
1235 | default: | |||
1236 | default_notify (this, event, data); | |||
1237 | break; | |||
1238 | ||||
1239 | } | |||
1240 | ||||
1241 | return ret; | |||
1242 | } | |||
1243 | ||||
1244 | ||||
1245 | struct xlator_fops fops; | |||
1246 | ||||
1247 | struct xlator_cbks cbks; | |||
1248 | ||||
1249 | struct xlator_dumpops dumpops = { | |||
1250 | .priv = glusterd_priv, | |||
1251 | }; | |||
1252 | ||||
1253 | ||||
1254 | struct volume_options options[] = { | |||
1255 | { .key = {"working-directory"}, | |||
1256 | .type = GF_OPTION_TYPE_PATH, | |||
1257 | }, | |||
1258 | { .key = {"transport-type"}, | |||
1259 | .type = GF_OPTION_TYPE_ANY, | |||
1260 | }, | |||
1261 | { .key = {"transport.*"}, | |||
1262 | .type = GF_OPTION_TYPE_ANY, | |||
1263 | }, | |||
1264 | { .key = {"rpc-auth.*"}, | |||
1265 | .type = GF_OPTION_TYPE_ANY, | |||
1266 | }, | |||
1267 | { .key = {"rpc-auth-allow-insecure"}, | |||
1268 | .type = GF_OPTION_TYPE_BOOL, | |||
1269 | }, | |||
1270 | { .key = {"upgrade"}, | |||
1271 | .type = GF_OPTION_TYPE_BOOL, | |||
1272 | }, | |||
1273 | { .key = {"downgrade"}, | |||
1274 | .type = GF_OPTION_TYPE_BOOL, | |||
1275 | }, | |||
1276 | { .key = {"bind-insecure"}, | |||
1277 | .type = GF_OPTION_TYPE_BOOL, | |||
1278 | }, | |||
1279 | { .key = {"mountbroker-root"}, | |||
1280 | .type = GF_OPTION_TYPE_PATH, | |||
1281 | }, | |||
1282 | { .key = {"mountbroker.*"}, | |||
1283 | .type = GF_OPTION_TYPE_ANY, | |||
1284 | }, | |||
1285 | { .key = {"mountbroker-"GEOREP"geo-replication"".*"}, | |||
1286 | .type = GF_OPTION_TYPE_ANY, | |||
1287 | }, | |||
1288 | { .key = {"mountbroker-"GHADOOP"glusterfs-hadoop"".*"}, | |||
1289 | .type = GF_OPTION_TYPE_ANY, | |||
1290 | }, | |||
1291 | { .key = {GEOREP"geo-replication""-log-group"}, | |||
1292 | .type = GF_OPTION_TYPE_ANY, | |||
1293 | }, | |||
1294 | { .key = {"run-with-valgrind"}, | |||
1295 | .type = GF_OPTION_TYPE_BOOL, | |||
1296 | }, | |||
1297 | { .key = {"server-quorum-type"}, | |||
1298 | .type = GF_OPTION_TYPE_STR, | |||
1299 | .value = { "none", "server"}, | |||
1300 | .description = "If set to server, enables the specified " | |||
1301 | "volume to participate in quorum." | |||
1302 | }, | |||
1303 | { .key = {"server-quorum-ratio"}, | |||
1304 | .type = GF_OPTION_TYPE_PERCENT, | |||
1305 | .description = "Sets the quorum percentage for the trusted " | |||
1306 | "storage pool." | |||
1307 | }, | |||
1308 | { .key = {NULL((void*)0)} }, | |||
1309 | }; |