File: | cli/src/cli-rpc-ops.c |
Location: | line 762, column 17 |
Description: | Value stored to 'ret' is never read |
1 | /* |
2 | Copyright (c) 2010-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 | |
16 | #ifndef GSYNC_CONF"geo-replication""/gsyncd.conf" |
17 | #define GSYNC_CONF"geo-replication""/gsyncd.conf" GEOREP"geo-replication""/gsyncd.conf" |
18 | #endif |
19 | |
20 | /* Widths of various columns in top read/write-perf output |
21 | * Total width of top read/write-perf should be 80 chars |
22 | * including one space between column |
23 | */ |
24 | #define VOL_TOP_PERF_FILENAME_DEF_WIDTH47 47 |
25 | #define VOL_TOP_PERF_FILENAME_ALT_WIDTH44 44 |
26 | #define VOL_TOP_PERF_SPEED_WIDTH4 4 |
27 | #define VOL_TOP_PERF_TIME_WIDTH26 26 |
28 | |
29 | #include "cli.h" |
30 | #include "compat-errno.h" |
31 | #include "cli-cmd.h" |
32 | #include <sys/uio.h> |
33 | #include <stdlib.h> |
34 | #include <sys/mount.h> |
35 | #include "cli1-xdr.h" |
36 | #include "xdr-generic.h" |
37 | #include "protocol-common.h" |
38 | #include "cli-mem-types.h" |
39 | #include "compat.h" |
40 | |
41 | #include "syscall.h" |
42 | #include "glusterfs3.h" |
43 | #include "portmap-xdr.h" |
44 | |
45 | #include "run.h" |
46 | |
47 | extern rpc_clnt_prog_t *cli_rpc_prog; |
48 | extern int cli_op_ret; |
49 | extern int connected; |
50 | |
51 | char *cli_vol_type_str[] = {"Distribute", |
52 | "Stripe", |
53 | "Replicate", |
54 | "Striped-Replicate", |
55 | "Distributed-Stripe", |
56 | "Distributed-Replicate", |
57 | "Distributed-Striped-Replicate", |
58 | }; |
59 | |
60 | char *cli_vol_status_str[] = {"Created", |
61 | "Started", |
62 | "Stopped", |
63 | }; |
64 | |
65 | char *cli_volume_backend[] = {"", |
66 | "Volume Group", |
67 | }; |
68 | |
69 | int32_t |
70 | gf_cli_get_volume (call_frame_t *frame, xlator_t *this, |
71 | void *data); |
72 | |
73 | int |
74 | cli_to_glusterd (gf_cli_req *req, call_frame_t *frame, fop_cbk_fn_t cbkfn, |
75 | xdrproc_t xdrproc, dict_t *dict, int procnum, xlator_t *this, |
76 | rpc_clnt_prog_t *prog, struct iobref *iobref); |
77 | |
78 | rpc_clnt_prog_t cli_handshake_prog = { |
79 | .progname = "cli handshake", |
80 | .prognum = GLUSTER_HNDSK_PROGRAM14398633, |
81 | .progver = GLUSTER_HNDSK_VERSION2, |
82 | }; |
83 | |
84 | rpc_clnt_prog_t cli_pmap_prog = { |
85 | .progname = "cli portmap", |
86 | .prognum = GLUSTER_PMAP_PROGRAM34123456, |
87 | .progver = GLUSTER_PMAP_VERSION1, |
88 | }; |
89 | |
90 | void |
91 | gf_cli_probe_strerror (gf1_cli_probe_rsp *rsp, char *msg, size_t len) |
92 | { |
93 | switch (rsp->op_errno) { |
94 | case GF_PROBE_ANOTHER_CLUSTER: |
95 | snprintf (msg, len, "%s is already part of another cluster", |
96 | rsp->hostname); |
97 | break; |
98 | case GF_PROBE_VOLUME_CONFLICT: |
99 | snprintf (msg, len, "Atleast one volume on %s conflicts with " |
100 | "existing volumes in the cluster", rsp->hostname); |
101 | break; |
102 | case GF_PROBE_UNKNOWN_PEER: |
103 | snprintf (msg, len, "%s responded with 'unknown peer' error, " |
104 | "this could happen if %s doesn't have localhost in " |
105 | "its peer database", rsp->hostname, rsp->hostname); |
106 | break; |
107 | case GF_PROBE_ADD_FAILED: |
108 | snprintf (msg, len, "Failed to add peer information on %s" , |
109 | rsp->hostname); |
110 | break; |
111 | case GF_PROBE_SAME_UUID: |
112 | snprintf (msg, len, "Peer uuid (host %s) is same as local uuid", |
113 | rsp->hostname); |
114 | break; |
115 | case GF_PROBE_QUORUM_NOT_MET: |
116 | snprintf (msg, len, "Cluster quorum is not met. Changing " |
117 | "peers is not allowed in this state"); |
118 | break; |
119 | default: |
120 | snprintf (msg, len, "Probe returned with unknown " |
121 | "errno %d", rsp->op_errno); |
122 | break; |
123 | } |
124 | } |
125 | |
126 | int |
127 | gf_cli_probe_cbk (struct rpc_req *req, struct iovec *iov, |
128 | int count, void *myframe) |
129 | { |
130 | gf1_cli_probe_rsp rsp = {0,}; |
131 | int ret = -1; |
132 | char msg[1024] = {0,}; |
133 | |
134 | if (-1 == req->rpc_status) { |
135 | goto out; |
136 | } |
137 | |
138 | ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf1_cli_probe_rsp); |
139 | if (ret < 0) { |
140 | gf_log (((call_frame_t *) myframe)->this->name, GF_LOG_ERROR,do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (((call_frame_t *) myframe)->this->name, "cli-rpc-ops.c" , __FUNCTION__, 141, GF_LOG_ERROR, "Failed to decode xdr response" ); } while (0) |
141 | "Failed to decode xdr response")do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (((call_frame_t *) myframe)->this->name, "cli-rpc-ops.c" , __FUNCTION__, 141, GF_LOG_ERROR, "Failed to decode xdr response" ); } while (0); |
142 | //rsp.op_ret = -1; |
143 | //rsp.op_errno = EINVAL; |
144 | goto out; |
145 | } |
146 | |
147 | gf_log ("cli", GF_LOG_INFO, "Received resp to probe")do { do { if (0) printf ("Received resp to probe"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 147, GF_LOG_INFO , "Received resp to probe"); } while (0); |
148 | if (!rsp.op_ret) { |
149 | switch (rsp.op_errno) { |
150 | case GF_PROBE_SUCCESS: |
151 | snprintf (msg, sizeof (msg), |
152 | "success"); |
153 | break; |
154 | case GF_PROBE_LOCALHOST: |
155 | snprintf (msg, sizeof (msg), |
156 | "success: on localhost not needed"); |
157 | break; |
158 | case GF_PROBE_FRIEND: |
159 | snprintf (msg, sizeof (msg), |
160 | "success: host %s port %d already" |
161 | " in peer list", rsp.hostname, |
162 | rsp.port); |
163 | break; |
164 | default: |
165 | rsp.op_ret = -1; |
166 | snprintf (msg, sizeof (msg), |
167 | "Probe returned with unknown errno" |
168 | " %d", rsp.op_errno); |
169 | break; |
170 | } |
171 | } |
172 | |
173 | if (rsp.op_ret) { |
174 | if (rsp.op_errstr && (strlen (rsp.op_errstr) > 0)) { |
175 | snprintf (msg, sizeof (msg), "%s", rsp.op_errstr); |
176 | } else { |
177 | gf_cli_probe_strerror (&rsp, msg, sizeof (msg)); |
178 | } |
179 | gf_log ("cli", GF_LOG_ERROR, "%s", msg)do { do { if (0) printf ("%s", msg); } while (0); _gf_log ("cli" , "cli-rpc-ops.c", __FUNCTION__, 179, GF_LOG_ERROR, "%s", msg ); } while (0); |
180 | } |
181 | |
182 | if (global_state->mode & GLUSTER_MODE_XML(1 << 2)) { |
183 | ret = cli_xml_output_str (NULL((void*)0), |
184 | (rsp.op_ret)? NULL((void*)0) : msg, |
185 | rsp.op_ret, rsp.op_errno, |
186 | (rsp.op_ret)? msg : NULL((void*)0)); |
187 | if (ret) |
188 | gf_log ("cli", GF_LOG_ERROR,do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 189, GF_LOG_ERROR , "Error outputting to xml"); } while (0) |
189 | "Error outputting to xml")do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 189, GF_LOG_ERROR , "Error outputting to xml"); } while (0); |
190 | goto out; |
191 | } |
192 | |
193 | if (!rsp.op_ret) |
194 | cli_out ("peer probe: %s", msg)do { do { if (0) printf ("peer probe: %s", msg); } while (0); _cli_out("peer probe: %s", msg); } while (0); |
195 | else |
196 | cli_err ("peer probe: failed: %s", msg)do { do { if (0) printf ("peer probe: failed: %s", msg); } while (0); _cli_err("peer probe: failed: %s", msg); } while (0); |
197 | |
198 | ret = rsp.op_ret; |
199 | |
200 | out: |
201 | cli_cmd_broadcast_response (ret); |
202 | return ret; |
203 | } |
204 | |
205 | int |
206 | gf_cli_deprobe_cbk (struct rpc_req *req, struct iovec *iov, |
207 | int count, void *myframe) |
208 | { |
209 | gf1_cli_deprobe_rsp rsp = {0,}; |
210 | int ret = -1; |
211 | char msg[1024] = {0,}; |
212 | |
213 | if (-1 == req->rpc_status) { |
214 | goto out; |
215 | } |
216 | |
217 | ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf1_cli_deprobe_rsp); |
218 | if (ret < 0) { |
219 | gf_log (((call_frame_t *) myframe)->this->name, GF_LOG_ERROR,do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (((call_frame_t *) myframe)->this->name, "cli-rpc-ops.c" , __FUNCTION__, 220, GF_LOG_ERROR, "Failed to decode xdr response" ); } while (0) |
220 | "Failed to decode xdr response")do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (((call_frame_t *) myframe)->this->name, "cli-rpc-ops.c" , __FUNCTION__, 220, GF_LOG_ERROR, "Failed to decode xdr response" ); } while (0); |
221 | //rsp.op_ret = -1; |
222 | //rsp.op_errno = EINVAL; |
223 | goto out; |
224 | } |
225 | |
226 | gf_log ("cli", GF_LOG_INFO, "Received resp to deprobe")do { do { if (0) printf ("Received resp to deprobe"); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 226, GF_LOG_INFO , "Received resp to deprobe"); } while (0); |
227 | if (rsp.op_ret) { |
228 | if (strlen (rsp.op_errstr) > 0) { |
229 | snprintf (msg, sizeof (msg), "%s", rsp.op_errstr); |
230 | gf_log ("cli", GF_LOG_ERROR, "%s", rsp.op_errstr)do { do { if (0) printf ("%s", rsp.op_errstr); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 230, GF_LOG_ERROR, "%s" , rsp.op_errstr); } while (0); |
231 | } else { |
232 | switch (rsp.op_errno) { |
233 | case GF_DEPROBE_LOCALHOST: |
234 | snprintf (msg, sizeof (msg), |
235 | "%s is localhost", |
236 | rsp.hostname); |
237 | break; |
238 | case GF_DEPROBE_NOT_FRIEND: |
239 | snprintf (msg, sizeof (msg), |
240 | "%s is not part of cluster", |
241 | rsp.hostname); |
242 | break; |
243 | case GF_DEPROBE_BRICK_EXIST: |
244 | snprintf (msg, sizeof (msg), |
245 | "Brick(s) with the peer %s " |
246 | "exist in cluster", |
247 | rsp.hostname); |
248 | break; |
249 | case GF_DEPROBE_FRIEND_DOWN: |
250 | snprintf (msg, sizeof (msg), |
251 | "One of the peers is probably" |
252 | " down. Check with 'peer " |
253 | "status'."); |
254 | break; |
255 | case GF_DEPROBE_QUORUM_NOT_MET: |
256 | snprintf (msg, sizeof (msg), "Cluster " |
257 | "quorum is not met. Changing " |
258 | "peers is not allowed in this" |
259 | " state"); |
260 | break; |
261 | default: |
262 | snprintf (msg, sizeof (msg), |
263 | "Detach returned with unknown" |
264 | " errno %d", rsp.op_errno); |
265 | break; |
266 | } |
267 | gf_log ("cli", GF_LOG_ERROR,"Detach failed with op_ret "do { do { if (0) printf ("Detach failed with op_ret " "%d and op_errno %d" , rsp.op_ret, rsp.op_errno); } while (0); _gf_log ("cli", "cli-rpc-ops.c" , __FUNCTION__, 268, GF_LOG_ERROR,"Detach failed with op_ret " "%d and op_errno %d", rsp.op_ret, rsp.op_errno); } while (0) |
268 | "%d and op_errno %d", rsp.op_ret, rsp.op_errno)do { do { if (0) printf ("Detach failed with op_ret " "%d and op_errno %d" , rsp.op_ret, rsp.op_errno); } while (0); _gf_log ("cli", "cli-rpc-ops.c" , __FUNCTION__, 268, GF_LOG_ERROR,"Detach failed with op_ret " "%d and op_errno %d", rsp.op_ret, rsp.op_errno); } while (0); |
269 | } |
270 | } else { |
271 | snprintf (msg, sizeof (msg), "success"); |
272 | } |
273 | |
274 | if (global_state->mode & GLUSTER_MODE_XML(1 << 2)) { |
275 | ret = cli_xml_output_str (NULL((void*)0), |
276 | (rsp.op_ret)? NULL((void*)0) : msg, |
277 | rsp.op_ret, rsp.op_errno, |
278 | (rsp.op_ret)? msg : NULL((void*)0)); |
279 | if (ret) |
280 | gf_log ("cli", GF_LOG_ERROR,do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 281, GF_LOG_ERROR , "Error outputting to xml"); } while (0) |
281 | "Error outputting to xml")do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 281, GF_LOG_ERROR , "Error outputting to xml"); } while (0); |
282 | goto out; |
283 | } |
284 | |
285 | if (!rsp.op_ret) |
286 | cli_out ("peer detach: %s", msg)do { do { if (0) printf ("peer detach: %s", msg); } while (0) ; _cli_out("peer detach: %s", msg); } while (0); |
287 | else |
288 | cli_err ("peer detach: failed: %s", msg)do { do { if (0) printf ("peer detach: failed: %s", msg); } while (0); _cli_err("peer detach: failed: %s", msg); } while (0); |
289 | |
290 | ret = rsp.op_ret; |
291 | |
292 | out: |
293 | cli_cmd_broadcast_response (ret); |
294 | return ret; |
295 | } |
296 | |
297 | int |
298 | gf_cli_output_peer_status (dict_t *dict, int count) |
299 | { |
300 | int ret = -1; |
301 | char *uuid_buf = NULL((void*)0); |
302 | char *hostname_buf = NULL((void*)0); |
303 | int32_t i = 1; |
304 | char key[256] = {0,}; |
305 | char *state = NULL((void*)0); |
306 | int32_t port = 0; |
307 | int32_t connected = 0; |
308 | char *connected_str = NULL((void*)0); |
309 | |
310 | cli_out ("Number of Peers: %d", count)do { do { if (0) printf ("Number of Peers: %d", count); } while (0); _cli_out("Number of Peers: %d", count); } while (0); |
311 | i = 1; |
312 | while ( i <= count) { |
313 | snprintf (key, 256, "friend%d.uuid", i); |
314 | ret = dict_get_str (dict, key, &uuid_buf); |
315 | if (ret) |
316 | goto out; |
317 | |
318 | snprintf (key, 256, "friend%d.hostname", i); |
319 | ret = dict_get_str (dict, key, &hostname_buf); |
320 | if (ret) |
321 | goto out; |
322 | |
323 | snprintf (key, 256, "friend%d.connected", i); |
324 | ret = dict_get_int32 (dict, key, &connected); |
325 | if (ret) |
326 | goto out; |
327 | if (connected) |
328 | connected_str = "Connected"; |
329 | else |
330 | connected_str = "Disconnected"; |
331 | |
332 | snprintf (key, 256, "friend%d.port", i); |
333 | ret = dict_get_int32 (dict, key, &port); |
334 | if (ret) |
335 | goto out; |
336 | |
337 | snprintf (key, 256, "friend%d.state", i); |
338 | ret = dict_get_str (dict, key, &state); |
339 | if (ret) |
340 | goto out; |
341 | |
342 | if (!port) { |
343 | cli_out ("\nHostname: %s\nUuid: %s\nState: %s "do { do { if (0) printf ("\nHostname: %s\nUuid: %s\nState: %s " "(%s)", hostname_buf, uuid_buf, state, connected_str); } while (0); _cli_out("\nHostname: %s\nUuid: %s\nState: %s " "(%s)", hostname_buf, uuid_buf, state, connected_str); } while (0) |
344 | "(%s)",do { do { if (0) printf ("\nHostname: %s\nUuid: %s\nState: %s " "(%s)", hostname_buf, uuid_buf, state, connected_str); } while (0); _cli_out("\nHostname: %s\nUuid: %s\nState: %s " "(%s)", hostname_buf, uuid_buf, state, connected_str); } while (0) |
345 | hostname_buf, uuid_buf, state,do { do { if (0) printf ("\nHostname: %s\nUuid: %s\nState: %s " "(%s)", hostname_buf, uuid_buf, state, connected_str); } while (0); _cli_out("\nHostname: %s\nUuid: %s\nState: %s " "(%s)", hostname_buf, uuid_buf, state, connected_str); } while (0) |
346 | connected_str)do { do { if (0) printf ("\nHostname: %s\nUuid: %s\nState: %s " "(%s)", hostname_buf, uuid_buf, state, connected_str); } while (0); _cli_out("\nHostname: %s\nUuid: %s\nState: %s " "(%s)", hostname_buf, uuid_buf, state, connected_str); } while (0); |
347 | } else { |
348 | cli_out ("\nHostname: %s\nPort: %d\nUuid: %s\n"do { do { if (0) printf ("\nHostname: %s\nPort: %d\nUuid: %s\n" "State: %s (%s)", hostname_buf, port, uuid_buf, state, connected_str ); } while (0); _cli_out("\nHostname: %s\nPort: %d\nUuid: %s\n" "State: %s (%s)", hostname_buf, port, uuid_buf, state, connected_str ); } while (0) |
349 | "State: %s (%s)", hostname_buf, port,do { do { if (0) printf ("\nHostname: %s\nPort: %d\nUuid: %s\n" "State: %s (%s)", hostname_buf, port, uuid_buf, state, connected_str ); } while (0); _cli_out("\nHostname: %s\nPort: %d\nUuid: %s\n" "State: %s (%s)", hostname_buf, port, uuid_buf, state, connected_str ); } while (0) |
350 | uuid_buf, state, connected_str)do { do { if (0) printf ("\nHostname: %s\nPort: %d\nUuid: %s\n" "State: %s (%s)", hostname_buf, port, uuid_buf, state, connected_str ); } while (0); _cli_out("\nHostname: %s\nPort: %d\nUuid: %s\n" "State: %s (%s)", hostname_buf, port, uuid_buf, state, connected_str ); } while (0); |
351 | } |
352 | i++; |
353 | } |
354 | |
355 | ret = 0; |
356 | out: |
357 | return ret; |
358 | } |
359 | |
360 | int |
361 | gf_cli_output_pool_list (dict_t *dict, int count) |
362 | { |
363 | int ret = -1; |
364 | char *uuid_buf = NULL((void*)0); |
365 | char *hostname_buf = NULL((void*)0); |
366 | int32_t i = 1; |
367 | char key[256] = {0,}; |
368 | int32_t connected = 0; |
369 | char *connected_str = NULL((void*)0); |
370 | |
371 | if (count >= 1) |
372 | cli_out ("UUID\t\t\t\t\tHostname\tState")do { do { if (0) printf ("UUID\t\t\t\t\tHostname\tState"); } while (0); _cli_out("UUID\t\t\t\t\tHostname\tState"); } while (0); |
373 | |
374 | while ( i <= count) { |
375 | snprintf (key, 256, "friend%d.uuid", i); |
376 | ret = dict_get_str (dict, key, &uuid_buf); |
377 | if (ret) |
378 | goto out; |
379 | |
380 | snprintf (key, 256, "friend%d.hostname", i); |
381 | ret = dict_get_str (dict, key, &hostname_buf); |
382 | if (ret) |
383 | goto out; |
384 | |
385 | snprintf (key, 256, "friend%d.connected", i); |
386 | ret = dict_get_int32 (dict, key, &connected); |
387 | if (ret) |
388 | goto out; |
389 | if (connected) |
390 | connected_str = "Connected"; |
391 | else |
392 | connected_str = "Disconnected"; |
393 | |
394 | cli_out ("%s\t%s\t%s ", uuid_buf, hostname_buf,do { do { if (0) printf ("%s\t%s\t%s ", uuid_buf, hostname_buf , connected_str); } while (0); _cli_out("%s\t%s\t%s ", uuid_buf , hostname_buf, connected_str); } while (0) |
395 | connected_str)do { do { if (0) printf ("%s\t%s\t%s ", uuid_buf, hostname_buf , connected_str); } while (0); _cli_out("%s\t%s\t%s ", uuid_buf , hostname_buf, connected_str); } while (0); |
396 | i++; |
397 | } |
398 | |
399 | ret = 0; |
400 | out: |
401 | return ret; |
402 | } |
403 | |
404 | /* function pointer for gf_cli_output_{pool_list,peer_status} */ |
405 | typedef int (*cli_friend_output_fn) (dict_t*, int); |
406 | |
407 | int |
408 | gf_cli_list_friends_cbk (struct rpc_req *req, struct iovec *iov, |
409 | int count, void *myframe) |
410 | { |
411 | gf1_cli_peer_list_rsp rsp = {0,}; |
412 | int ret = -1; |
413 | dict_t *dict = NULL((void*)0); |
414 | char msg[1024] = {0,}; |
415 | char *cmd = NULL((void*)0); |
416 | cli_friend_output_fn friend_output_fn; |
417 | call_frame_t *frame = NULL((void*)0); |
418 | unsigned long flags = 0; |
419 | |
420 | frame = myframe; |
421 | flags = (long)frame->local; |
422 | |
423 | if (flags == GF_CLI_LIST_POOL_NODES) { |
424 | cmd = "pool list"; |
425 | friend_output_fn = &gf_cli_output_pool_list; |
426 | } else { |
427 | cmd = "peer status"; |
428 | friend_output_fn = &gf_cli_output_peer_status; |
429 | } |
430 | |
431 | /* 'free' the flags set by gf_cli_list_friends */ |
432 | frame->local = NULL((void*)0); |
433 | |
434 | if (-1 == req->rpc_status) { |
435 | goto out; |
436 | } |
437 | |
438 | ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf1_cli_peer_list_rsp); |
439 | if (ret < 0) { |
440 | gf_log (((call_frame_t *) myframe)->this->name, GF_LOG_ERROR,do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (((call_frame_t *) myframe)->this->name, "cli-rpc-ops.c" , __FUNCTION__, 441, GF_LOG_ERROR, "Failed to decode xdr response" ); } while (0) |
441 | "Failed to decode xdr response")do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (((call_frame_t *) myframe)->this->name, "cli-rpc-ops.c" , __FUNCTION__, 441, GF_LOG_ERROR, "Failed to decode xdr response" ); } while (0); |
442 | //rsp.op_ret = -1; |
443 | //rsp.op_errno = EINVAL; |
444 | goto out; |
445 | } |
446 | |
447 | gf_log ("cli", GF_LOG_DEBUG, "Received resp to list: %d",do { do { if (0) printf ("Received resp to list: %d", rsp.op_ret ); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__ , 448, GF_LOG_DEBUG, "Received resp to list: %d", rsp.op_ret) ; } while (0) |
448 | rsp.op_ret)do { do { if (0) printf ("Received resp to list: %d", rsp.op_ret ); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__ , 448, GF_LOG_DEBUG, "Received resp to list: %d", rsp.op_ret) ; } while (0); |
449 | |
450 | ret = rsp.op_ret; |
451 | |
452 | if (!rsp.op_ret) { |
453 | |
454 | if (!rsp.friends.friends_len) { |
455 | snprintf (msg, sizeof (msg), |
456 | "%s: No peers present", cmd); |
457 | if (global_state->mode & GLUSTER_MODE_XML(1 << 2)) { |
458 | ret = cli_xml_output_peer_status (dict, |
459 | rsp.op_ret, |
460 | rsp.op_errno, |
461 | msg); |
462 | if (ret) |
463 | gf_log ("cli", GF_LOG_ERROR,do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 464, GF_LOG_ERROR , "Error outputting to xml"); } while (0) |
464 | "Error outputting to xml")do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 464, GF_LOG_ERROR , "Error outputting to xml"); } while (0); |
465 | goto out; |
466 | } |
467 | cli_err ("%s", msg)do { do { if (0) printf ("%s", msg); } while (0); _cli_err("%s" , msg); } while (0); |
468 | ret = 0; |
469 | goto out; |
470 | } |
471 | |
472 | dict = dict_new (); |
473 | |
474 | if (!dict) { |
475 | ret = -1; |
476 | goto out; |
477 | } |
478 | |
479 | ret = dict_unserialize (rsp.friends.friends_val, |
480 | rsp.friends.friends_len, |
481 | &dict); |
482 | |
483 | if (ret) { |
484 | gf_log ("", GF_LOG_ERROR,do { do { if (0) printf ("Unable to allocate memory"); } while (0); _gf_log ("", "cli-rpc-ops.c", __FUNCTION__, 485, GF_LOG_ERROR , "Unable to allocate memory"); } while (0) |
485 | "Unable to allocate memory")do { do { if (0) printf ("Unable to allocate memory"); } while (0); _gf_log ("", "cli-rpc-ops.c", __FUNCTION__, 485, GF_LOG_ERROR , "Unable to allocate memory"); } while (0); |
486 | goto out; |
487 | } |
488 | |
489 | if (global_state->mode & GLUSTER_MODE_XML(1 << 2)) { |
490 | ret = cli_xml_output_peer_status (dict, rsp.op_ret, |
491 | rsp.op_errno, msg); |
492 | if (ret) |
493 | gf_log ("cli", GF_LOG_ERROR,do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 494, GF_LOG_ERROR , "Error outputting to xml"); } while (0) |
494 | "Error outputting to xml")do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 494, GF_LOG_ERROR , "Error outputting to xml"); } while (0); |
495 | goto out; |
496 | } |
497 | |
498 | ret = dict_get_int32 (dict, "count", &count); |
499 | if (ret) { |
500 | goto out; |
501 | } |
502 | |
503 | ret = friend_output_fn (dict, count); |
504 | if (ret) { |
505 | goto out; |
506 | } |
507 | } else { |
508 | if (global_state->mode & GLUSTER_MODE_XML(1 << 2)) { |
509 | ret = cli_xml_output_peer_status (dict, rsp.op_ret, |
510 | rsp.op_errno, NULL((void*)0)); |
511 | if (ret) |
512 | gf_log ("cli", GF_LOG_ERROR,do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 513, GF_LOG_ERROR , "Error outputting to xml"); } while (0) |
513 | "Error outputting to xml")do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 513, GF_LOG_ERROR , "Error outputting to xml"); } while (0); |
514 | } else { |
515 | ret = -1; |
516 | } |
517 | goto out; |
518 | } |
519 | |
520 | |
521 | ret = 0; |
522 | |
523 | out: |
524 | cli_cmd_broadcast_response (ret); |
525 | if (ret) |
526 | cli_err ("%s: failed", cmd)do { do { if (0) printf ("%s: failed", cmd); } while (0); _cli_err ("%s: failed", cmd); } while (0); |
527 | |
528 | if (dict) |
529 | dict_destroy (dict); |
530 | |
531 | return ret; |
532 | } |
533 | |
534 | void |
535 | cli_out_options ( char *substr, char *optstr, char *valstr) |
536 | { |
537 | char *ptr1 = NULL((void*)0); |
538 | char *ptr2 = NULL((void*)0); |
539 | |
540 | ptr1 = substr; |
541 | ptr2 = optstr; |
542 | |
543 | while (ptr1) |
544 | { |
545 | if (*ptr1 != *ptr2) |
546 | break; |
547 | ptr1++; |
548 | ptr2++; |
549 | if (!ptr1) |
550 | return; |
551 | if (!ptr2) |
552 | return; |
553 | } |
554 | |
555 | if (*ptr2 == '\0') |
556 | return; |
557 | cli_out ("%s: %s",ptr2 , valstr)do { do { if (0) printf ("%s: %s",ptr2 , valstr); } while (0) ; _cli_out("%s: %s",ptr2 , valstr); } while (0); |
558 | } |
559 | |
560 | static int |
561 | _gf_cli_output_volinfo_opts (dict_t *d, char *k, |
562 | data_t *v, void *tmp) |
563 | { |
564 | int ret = 0; |
565 | char *key = NULL((void*)0); |
566 | char *ptr = NULL((void*)0); |
567 | data_t *value = NULL((void*)0); |
568 | |
569 | key = tmp; |
570 | |
571 | ptr = strstr (k, "option."); |
572 | if (ptr) { |
573 | value = v; |
574 | if (!value) { |
575 | ret = -1; |
576 | goto out; |
577 | } |
578 | cli_out_options (key, k, v->data); |
579 | } |
580 | out: |
581 | return ret; |
582 | } |
583 | |
584 | |
585 | int |
586 | gf_cli_get_volume_cbk (struct rpc_req *req, struct iovec *iov, |
587 | int count, void *myframe) |
588 | { |
589 | int ret = -1; |
590 | int opt_count = 0; |
591 | int32_t i = 0; |
592 | int32_t j = 1; |
593 | int32_t status = 0; |
594 | int32_t type = 0; |
595 | int32_t brick_count = 0; |
596 | int32_t dist_count = 0; |
597 | int32_t stripe_count = 0; |
598 | int32_t replica_count = 0; |
599 | int32_t vol_type = 0; |
600 | int32_t transport = 0; |
601 | char *volume_id_str = NULL((void*)0); |
602 | char *brick = NULL((void*)0); |
603 | char *volname = NULL((void*)0); |
604 | dict_t *dict = NULL((void*)0); |
605 | cli_local_t *local = NULL((void*)0); |
606 | char key[1024] = {0}; |
607 | char err_str[2048] = {0}; |
608 | gf_cli_rsp rsp = {0}; |
609 | int32_t backend = 0; |
610 | |
611 | if (-1 == req->rpc_status) |
612 | goto out; |
613 | |
614 | ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_cli_rsp); |
615 | if (ret < 0) { |
616 | gf_log (((call_frame_t *) myframe)->this->name, GF_LOG_ERROR,do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (((call_frame_t *) myframe)->this->name, "cli-rpc-ops.c" , __FUNCTION__, 617, GF_LOG_ERROR, "Failed to decode xdr response" ); } while (0) |
617 | "Failed to decode xdr response")do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (((call_frame_t *) myframe)->this->name, "cli-rpc-ops.c" , __FUNCTION__, 617, GF_LOG_ERROR, "Failed to decode xdr response" ); } while (0); |
618 | goto out; |
619 | } |
620 | |
621 | gf_log ("cli", GF_LOG_INFO, "Received resp to get vol: %d",do { do { if (0) printf ("Received resp to get vol: %d", rsp. op_ret); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__ , 622, GF_LOG_INFO, "Received resp to get vol: %d", rsp.op_ret ); } while (0) |
622 | rsp.op_ret)do { do { if (0) printf ("Received resp to get vol: %d", rsp. op_ret); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__ , 622, GF_LOG_INFO, "Received resp to get vol: %d", rsp.op_ret ); } while (0); |
623 | |
624 | if (rsp.op_ret) { |
625 | ret = -1; |
626 | goto out; |
627 | } |
628 | |
629 | if (!rsp.dict.dict_len) { |
630 | if (global_state->mode & GLUSTER_MODE_XML(1 << 2)) |
631 | goto xml_output; |
632 | cli_err ("No volumes present")do { do { if (0) printf ("No volumes present"); } while (0); _cli_err ("No volumes present"); } while (0); |
633 | ret = 0; |
634 | goto out; |
635 | } |
636 | |
637 | dict = dict_new (); |
638 | |
639 | if (!dict) { |
640 | ret = -1; |
641 | goto out; |
642 | } |
643 | |
644 | ret = dict_unserialize (rsp.dict.dict_val, |
645 | rsp.dict.dict_len, |
646 | &dict); |
647 | |
648 | if (ret) { |
649 | gf_log ("cli", GF_LOG_ERROR,do { do { if (0) printf ("Unable to allocate memory"); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 650, GF_LOG_ERROR , "Unable to allocate memory"); } while (0) |
650 | "Unable to allocate memory")do { do { if (0) printf ("Unable to allocate memory"); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 650, GF_LOG_ERROR , "Unable to allocate memory"); } while (0); |
651 | goto out; |
652 | } |
653 | |
654 | ret = dict_get_int32 (dict, "count", &count); |
655 | if (ret) |
656 | goto out; |
657 | |
658 | local = ((call_frame_t *)myframe)->local; |
659 | |
660 | if (!count) { |
661 | switch (local->get_vol.flags) { |
662 | |
663 | case GF_CLI_GET_NEXT_VOLUME: |
664 | GF_FREE (local->get_vol.volname)__gf_free (local->get_vol.volname); |
665 | local->get_vol.volname = NULL((void*)0); |
666 | ret = 0; |
667 | goto out; |
668 | |
669 | case GF_CLI_GET_VOLUME: |
670 | memset (err_str, 0, sizeof (err_str)); |
671 | snprintf (err_str, sizeof (err_str), |
672 | "Volume %s does not exist", |
673 | local->get_vol.volname); |
674 | ret = -1; |
675 | if (!(global_state->mode & GLUSTER_MODE_XML(1 << 2))) |
676 | goto out; |
677 | } |
678 | } |
679 | |
680 | xml_output: |
681 | if (global_state->mode & GLUSTER_MODE_XML(1 << 2)) { |
682 | /* For GET_NEXT_VOLUME output is already begun in |
683 | * and will also end in gf_cli_get_next_volume() |
684 | */ |
685 | if (local->get_vol.flags == GF_CLI_GET_VOLUME) { |
686 | ret = cli_xml_output_vol_info_begin |
687 | (local, rsp.op_ret, rsp.op_errno, |
688 | rsp.op_errstr); |
689 | if (ret) { |
690 | gf_log ("cli", GF_LOG_ERROR,do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 691, GF_LOG_ERROR , "Error outputting to xml"); } while (0) |
691 | "Error outputting to xml")do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 691, GF_LOG_ERROR , "Error outputting to xml"); } while (0); |
692 | goto out; |
693 | } |
694 | } |
695 | |
696 | if (dict) { |
697 | ret = cli_xml_output_vol_info (local, dict); |
698 | if (ret) { |
699 | gf_log ("cli", GF_LOG_ERROR,do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 700, GF_LOG_ERROR , "Error outputting to xml"); } while (0) |
700 | "Error outputting to xml")do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 700, GF_LOG_ERROR , "Error outputting to xml"); } while (0); |
701 | goto out; |
702 | } |
703 | } |
704 | |
705 | if (local->get_vol.flags == GF_CLI_GET_VOLUME) { |
706 | ret = cli_xml_output_vol_info_end (local); |
707 | if (ret) |
708 | gf_log ("cli", GF_LOG_ERROR,do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 709, GF_LOG_ERROR , "Error outputting to xml"); } while (0) |
709 | "Error outputting to xml")do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 709, GF_LOG_ERROR , "Error outputting to xml"); } while (0); |
710 | } |
711 | goto out; |
712 | } |
713 | |
714 | while ( i < count) { |
715 | cli_out (" ")do { do { if (0) printf (" "); } while (0); _cli_out(" "); } while (0); |
716 | snprintf (key, 256, "volume%d.name", i); |
717 | ret = dict_get_str (dict, key, &volname); |
718 | if (ret) |
719 | goto out; |
720 | |
721 | snprintf (key, 256, "volume%d.type", i); |
722 | ret = dict_get_int32 (dict, key, &type); |
723 | if (ret) |
724 | goto out; |
725 | |
726 | snprintf (key, 256, "volume%d.status", i); |
727 | ret = dict_get_int32 (dict, key, &status); |
728 | if (ret) |
729 | goto out; |
730 | |
731 | snprintf (key, 256, "volume%d.brick_count", i); |
732 | ret = dict_get_int32 (dict, key, &brick_count); |
733 | if (ret) |
734 | goto out; |
735 | |
736 | snprintf (key, 256, "volume%d.dist_count", i); |
737 | ret = dict_get_int32 (dict, key, &dist_count); |
738 | if (ret) |
739 | goto out; |
740 | |
741 | snprintf (key, 256, "volume%d.stripe_count", i); |
742 | ret = dict_get_int32 (dict, key, &stripe_count); |
743 | if (ret) |
744 | goto out; |
745 | |
746 | snprintf (key, 256, "volume%d.replica_count", i); |
747 | ret = dict_get_int32 (dict, key, &replica_count); |
748 | if (ret) |
749 | goto out; |
750 | |
751 | snprintf (key, 256, "volume%d.transport", i); |
752 | ret = dict_get_int32 (dict, key, &transport); |
753 | if (ret) |
754 | goto out; |
755 | |
756 | snprintf (key, 256, "volume%d.volume_id", i); |
757 | ret = dict_get_str (dict, key, &volume_id_str); |
758 | if (ret) |
759 | goto out; |
760 | |
761 | snprintf (key, 256, "volume%d.backend", i); |
762 | ret = dict_get_int32 (dict, key, &backend); |
Value stored to 'ret' is never read | |
763 | |
764 | vol_type = type; |
765 | |
766 | // Distributed (stripe/replicate/stripe-replica) setups |
767 | if ((type > 0) && ( dist_count < brick_count)) |
768 | vol_type = type + 3; |
769 | |
770 | cli_out ("Volume Name: %s", volname)do { do { if (0) printf ("Volume Name: %s", volname); } while (0); _cli_out("Volume Name: %s", volname); } while (0); |
771 | cli_out ("Type: %s", cli_vol_type_str[vol_type])do { do { if (0) printf ("Type: %s", cli_vol_type_str[vol_type ]); } while (0); _cli_out("Type: %s", cli_vol_type_str[vol_type ]); } while (0); |
772 | cli_out ("Volume ID: %s", volume_id_str)do { do { if (0) printf ("Volume ID: %s", volume_id_str); } while (0); _cli_out("Volume ID: %s", volume_id_str); } while (0); |
773 | cli_out ("Status: %s", cli_vol_status_str[status])do { do { if (0) printf ("Status: %s", cli_vol_status_str[status ]); } while (0); _cli_out("Status: %s", cli_vol_status_str[status ]); } while (0); |
774 | |
775 | if (backend) |
776 | goto next; |
777 | |
778 | if (type == GF_CLUSTER_TYPE_STRIPE_REPLICATE) { |
779 | cli_out ("Number of Bricks: %d x %d x %d = %d",do { do { if (0) printf ("Number of Bricks: %d x %d x %d = %d" , (brick_count / dist_count), stripe_count, replica_count, brick_count ); } while (0); _cli_out("Number of Bricks: %d x %d x %d = %d" , (brick_count / dist_count), stripe_count, replica_count, brick_count ); } while (0) |
780 | (brick_count / dist_count),do { do { if (0) printf ("Number of Bricks: %d x %d x %d = %d" , (brick_count / dist_count), stripe_count, replica_count, brick_count ); } while (0); _cli_out("Number of Bricks: %d x %d x %d = %d" , (brick_count / dist_count), stripe_count, replica_count, brick_count ); } while (0) |
781 | stripe_count,do { do { if (0) printf ("Number of Bricks: %d x %d x %d = %d" , (brick_count / dist_count), stripe_count, replica_count, brick_count ); } while (0); _cli_out("Number of Bricks: %d x %d x %d = %d" , (brick_count / dist_count), stripe_count, replica_count, brick_count ); } while (0) |
782 | replica_count,do { do { if (0) printf ("Number of Bricks: %d x %d x %d = %d" , (brick_count / dist_count), stripe_count, replica_count, brick_count ); } while (0); _cli_out("Number of Bricks: %d x %d x %d = %d" , (brick_count / dist_count), stripe_count, replica_count, brick_count ); } while (0) |
783 | brick_count)do { do { if (0) printf ("Number of Bricks: %d x %d x %d = %d" , (brick_count / dist_count), stripe_count, replica_count, brick_count ); } while (0); _cli_out("Number of Bricks: %d x %d x %d = %d" , (brick_count / dist_count), stripe_count, replica_count, brick_count ); } while (0); |
784 | } else if (type == GF_CLUSTER_TYPE_NONE) { |
785 | cli_out ("Number of Bricks: %d", brick_count)do { do { if (0) printf ("Number of Bricks: %d", brick_count) ; } while (0); _cli_out("Number of Bricks: %d", brick_count); } while (0); |
786 | } else { |
787 | /* For both replicate and stripe, dist_count is |
788 | good enough */ |
789 | cli_out ("Number of Bricks: %d x %d = %d",do { do { if (0) printf ("Number of Bricks: %d x %d = %d", (brick_count / dist_count), dist_count, brick_count); } while (0); _cli_out ("Number of Bricks: %d x %d = %d", (brick_count / dist_count) , dist_count, brick_count); } while (0) |
790 | (brick_count / dist_count),do { do { if (0) printf ("Number of Bricks: %d x %d = %d", (brick_count / dist_count), dist_count, brick_count); } while (0); _cli_out ("Number of Bricks: %d x %d = %d", (brick_count / dist_count) , dist_count, brick_count); } while (0) |
791 | dist_count, brick_count)do { do { if (0) printf ("Number of Bricks: %d x %d = %d", (brick_count / dist_count), dist_count, brick_count); } while (0); _cli_out ("Number of Bricks: %d x %d = %d", (brick_count / dist_count) , dist_count, brick_count); } while (0); |
792 | } |
793 | |
794 | cli_out ("Transport-type: %s",do { do { if (0) printf ("Transport-type: %s", ((transport == 0)?"tcp": (transport == 1)?"rdma": "tcp,rdma")); } while (0) ; _cli_out("Transport-type: %s", ((transport == 0)?"tcp": (transport == 1)?"rdma": "tcp,rdma")); } while (0) |
795 | ((transport == 0)?"tcp":do { do { if (0) printf ("Transport-type: %s", ((transport == 0)?"tcp": (transport == 1)?"rdma": "tcp,rdma")); } while (0) ; _cli_out("Transport-type: %s", ((transport == 0)?"tcp": (transport == 1)?"rdma": "tcp,rdma")); } while (0) |
796 | (transport == 1)?"rdma":do { do { if (0) printf ("Transport-type: %s", ((transport == 0)?"tcp": (transport == 1)?"rdma": "tcp,rdma")); } while (0) ; _cli_out("Transport-type: %s", ((transport == 0)?"tcp": (transport == 1)?"rdma": "tcp,rdma")); } while (0) |
797 | "tcp,rdma"))do { do { if (0) printf ("Transport-type: %s", ((transport == 0)?"tcp": (transport == 1)?"rdma": "tcp,rdma")); } while (0) ; _cli_out("Transport-type: %s", ((transport == 0)?"tcp": (transport == 1)?"rdma": "tcp,rdma")); } while (0); |
798 | |
799 | next: |
800 | if (backend) { |
801 | cli_out ("Backend Type: Block, %s",do { do { if (0) printf ("Backend Type: Block, %s", cli_volume_backend [backend]); } while (0); _cli_out("Backend Type: Block, %s", cli_volume_backend [backend]); } while (0) |
802 | cli_volume_backend[backend])do { do { if (0) printf ("Backend Type: Block, %s", cli_volume_backend [backend]); } while (0); _cli_out("Backend Type: Block, %s", cli_volume_backend [backend]); } while (0); |
803 | } |
804 | j = 1; |
805 | |
806 | GF_FREE (local->get_vol.volname)__gf_free (local->get_vol.volname); |
807 | local->get_vol.volname = gf_strdup (volname); |
808 | |
809 | if (brick_count) |
810 | cli_out ("Bricks:")do { do { if (0) printf ("Bricks:"); } while (0); _cli_out("Bricks:" ); } while (0); |
811 | |
812 | while (j <= brick_count) { |
813 | snprintf (key, 1024, "volume%d.brick%d", i, j); |
814 | ret = dict_get_str (dict, key, &brick); |
815 | if (ret) |
816 | goto out; |
817 | |
818 | cli_out ("Brick%d: %s", j, brick)do { do { if (0) printf ("Brick%d: %s", j, brick); } while (0 ); _cli_out("Brick%d: %s", j, brick); } while (0); |
819 | j++; |
820 | } |
821 | |
822 | snprintf (key, 256, "volume%d.opt_count",i); |
823 | ret = dict_get_int32 (dict, key, &opt_count); |
824 | if (ret) |
825 | goto out; |
826 | |
827 | if (!opt_count) |
828 | goto out; |
829 | |
830 | cli_out ("Options Reconfigured:")do { do { if (0) printf ("Options Reconfigured:"); } while (0 ); _cli_out("Options Reconfigured:"); } while (0); |
831 | |
832 | snprintf (key, 256, "volume%d.option.",i); |
833 | |
834 | ret = dict_foreach (dict, _gf_cli_output_volinfo_opts, key); |
835 | if (ret) |
836 | goto out; |
837 | |
838 | i++; |
839 | } |
840 | |
841 | |
842 | ret = 0; |
843 | out: |
844 | cli_cmd_broadcast_response (ret); |
845 | if (ret) |
846 | cli_err ("%s", err_str)do { do { if (0) printf ("%s", err_str); } while (0); _cli_err ("%s", err_str); } while (0); |
847 | |
848 | if (dict) |
849 | dict_destroy (dict); |
850 | |
851 | free (rsp.dict.dict_val); |
852 | |
853 | free (rsp.op_errstr); |
854 | |
855 | gf_log ("cli", GF_LOG_INFO, "Returning: %d", ret)do { do { if (0) printf ("Returning: %d", ret); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 855, GF_LOG_INFO, "Returning: %d" , ret); } while (0); |
856 | return ret; |
857 | } |
858 | |
859 | int |
860 | gf_cli_create_volume_cbk (struct rpc_req *req, struct iovec *iov, |
861 | int count, void *myframe) |
862 | { |
863 | gf_cli_rsp rsp = {0,}; |
864 | int ret = -1; |
865 | cli_local_t *local = NULL((void*)0); |
866 | char *volname = NULL((void*)0); |
867 | dict_t *dict = NULL((void*)0); |
868 | dict_t *rsp_dict = NULL((void*)0); |
869 | |
870 | if (-1 == req->rpc_status) { |
871 | goto out; |
872 | } |
873 | |
874 | local = ((call_frame_t *) (myframe))->local; |
875 | |
876 | ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_cli_rsp); |
877 | if (ret < 0) { |
878 | gf_log (((call_frame_t *) myframe)->this->name, GF_LOG_ERROR,do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (((call_frame_t *) myframe)->this->name, "cli-rpc-ops.c" , __FUNCTION__, 879, GF_LOG_ERROR, "Failed to decode xdr response" ); } while (0) |
879 | "Failed to decode xdr response")do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (((call_frame_t *) myframe)->this->name, "cli-rpc-ops.c" , __FUNCTION__, 879, GF_LOG_ERROR, "Failed to decode xdr response" ); } while (0); |
880 | goto out; |
881 | } |
882 | |
883 | gf_log ("cli", GF_LOG_INFO, "Received resp to create volume")do { do { if (0) printf ("Received resp to create volume"); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 883 , GF_LOG_INFO, "Received resp to create volume"); } while (0); |
884 | |
885 | dict = local->dict; |
886 | |
887 | ret = dict_get_str (dict, "volname", &volname); |
888 | if (ret) |
889 | goto out; |
890 | |
891 | if (global_state->mode & GLUSTER_MODE_XML(1 << 2)) { |
892 | if (rsp.op_ret == 0) { |
893 | rsp_dict = dict_new (); |
894 | ret = dict_unserialize (rsp.dict.dict_val, |
895 | rsp.dict.dict_len, |
896 | &rsp_dict); |
897 | if (ret) { |
898 | gf_log ("cli", GF_LOG_ERROR,do { do { if (0) printf ("Failed rsp_dict unserialization"); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 899 , GF_LOG_ERROR, "Failed rsp_dict unserialization"); } while ( 0) |
899 | "Failed rsp_dict unserialization")do { do { if (0) printf ("Failed rsp_dict unserialization"); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 899 , GF_LOG_ERROR, "Failed rsp_dict unserialization"); } while ( 0); |
900 | goto out; |
901 | } |
902 | } |
903 | |
904 | ret = cli_xml_output_vol_create (rsp_dict, rsp.op_ret, |
905 | rsp.op_errno, rsp.op_errstr); |
906 | if (ret) |
907 | gf_log ("cli", GF_LOG_ERROR,do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 908, GF_LOG_ERROR , "Error outputting to xml"); } while (0) |
908 | "Error outputting to xml")do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 908, GF_LOG_ERROR , "Error outputting to xml"); } while (0); |
909 | goto out; |
910 | } |
911 | |
912 | if (rsp.op_ret && strcmp (rsp.op_errstr, "")) |
913 | cli_err ("volume create: %s: failed: %s", volname,do { do { if (0) printf ("volume create: %s: failed: %s", volname , rsp.op_errstr); } while (0); _cli_err("volume create: %s: failed: %s" , volname, rsp.op_errstr); } while (0) |
914 | rsp.op_errstr)do { do { if (0) printf ("volume create: %s: failed: %s", volname , rsp.op_errstr); } while (0); _cli_err("volume create: %s: failed: %s" , volname, rsp.op_errstr); } while (0); |
915 | else if (rsp.op_ret) |
916 | cli_err ("volume create: %s: failed", volname)do { do { if (0) printf ("volume create: %s: failed", volname ); } while (0); _cli_err("volume create: %s: failed", volname ); } while (0); |
917 | else |
918 | cli_out ("volume create: %s: success: "do { do { if (0) printf ("volume create: %s: success: " "please start the volume to access data" , volname); } while (0); _cli_out("volume create: %s: success: " "please start the volume to access data", volname); } while ( 0) |
919 | "please start the volume to access data", volname)do { do { if (0) printf ("volume create: %s: success: " "please start the volume to access data" , volname); } while (0); _cli_out("volume create: %s: success: " "please start the volume to access data", volname); } while ( 0); |
920 | |
921 | ret = rsp.op_ret; |
922 | |
923 | out: |
924 | cli_cmd_broadcast_response (ret); |
925 | free (rsp.dict.dict_val); |
926 | free (rsp.op_errstr); |
927 | return ret; |
928 | } |
929 | |
930 | int |
931 | gf_cli_delete_volume_cbk (struct rpc_req *req, struct iovec *iov, |
932 | int count, void *myframe) |
933 | { |
934 | gf_cli_rsp rsp = {0,}; |
935 | int ret = -1; |
936 | cli_local_t *local = NULL((void*)0); |
937 | char *volname = NULL((void*)0); |
938 | call_frame_t *frame = NULL((void*)0); |
939 | dict_t *dict = NULL((void*)0); |
940 | dict_t *rsp_dict = NULL((void*)0); |
941 | |
942 | if (-1 == req->rpc_status) { |
943 | goto out; |
944 | } |
945 | |
946 | frame = myframe; |
947 | |
948 | ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_cli_rsp); |
949 | if (ret < 0) { |
950 | gf_log (frame->this->name, GF_LOG_ERROR,do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__ , 951, GF_LOG_ERROR, "Failed to decode xdr response"); } while (0) |
951 | "Failed to decode xdr response")do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__ , 951, GF_LOG_ERROR, "Failed to decode xdr response"); } while (0); |
952 | goto out; |
953 | } |
954 | |
955 | local = frame->local; |
956 | |
957 | if (local) |
958 | dict = local->dict; |
959 | ret = dict_get_str (dict, "volname", &volname); |
960 | if (ret) { |
961 | gf_log (frame->this->name, GF_LOG_ERROR,do { do { if (0) printf ("dict get failed"); } while (0); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__, 962 , GF_LOG_ERROR, "dict get failed"); } while (0) |
962 | "dict get failed")do { do { if (0) printf ("dict get failed"); } while (0); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__, 962 , GF_LOG_ERROR, "dict get failed"); } while (0); |
963 | goto out; |
964 | } |
965 | |
966 | gf_log ("cli", GF_LOG_INFO, "Received resp to delete volume")do { do { if (0) printf ("Received resp to delete volume"); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 966 , GF_LOG_INFO, "Received resp to delete volume"); } while (0); |
967 | |
968 | if (global_state->mode & GLUSTER_MODE_XML(1 << 2)) { |
969 | if (rsp.op_ret == 0) { |
970 | rsp_dict = dict_new (); |
971 | ret = dict_unserialize (rsp.dict.dict_val, |
972 | rsp.dict.dict_len, |
973 | &rsp_dict); |
974 | if (ret) { |
975 | gf_log ("cli", GF_LOG_ERROR,do { do { if (0) printf ("Failed rsp_dict unserialization"); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 976 , GF_LOG_ERROR, "Failed rsp_dict unserialization"); } while ( 0) |
976 | "Failed rsp_dict unserialization")do { do { if (0) printf ("Failed rsp_dict unserialization"); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 976 , GF_LOG_ERROR, "Failed rsp_dict unserialization"); } while ( 0); |
977 | goto out; |
978 | } |
979 | } |
980 | |
981 | ret = cli_xml_output_generic_volume ("volDelete", rsp_dict, |
982 | rsp.op_ret, rsp.op_errno, |
983 | rsp.op_errstr); |
984 | if (ret) |
985 | gf_log ("cli", GF_LOG_ERROR,do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 986, GF_LOG_ERROR , "Error outputting to xml"); } while (0) |
986 | "Error outputting to xml")do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 986, GF_LOG_ERROR , "Error outputting to xml"); } while (0); |
987 | goto out; |
988 | } |
989 | |
990 | if (rsp.op_ret && strcmp (rsp.op_errstr, "")) |
991 | cli_err ("volume delete: %s: failed: %s", volname,do { do { if (0) printf ("volume delete: %s: failed: %s", volname , rsp.op_errstr); } while (0); _cli_err("volume delete: %s: failed: %s" , volname, rsp.op_errstr); } while (0) |
992 | rsp.op_errstr)do { do { if (0) printf ("volume delete: %s: failed: %s", volname , rsp.op_errstr); } while (0); _cli_err("volume delete: %s: failed: %s" , volname, rsp.op_errstr); } while (0); |
993 | else if (rsp.op_ret) |
994 | cli_err ("volume delete: %s: failed", volname)do { do { if (0) printf ("volume delete: %s: failed", volname ); } while (0); _cli_err("volume delete: %s: failed", volname ); } while (0); |
995 | else |
996 | cli_out ("volume delete: %s: success", volname)do { do { if (0) printf ("volume delete: %s: success", volname ); } while (0); _cli_out("volume delete: %s: success", volname ); } while (0); |
997 | |
998 | ret = rsp.op_ret; |
999 | |
1000 | out: |
1001 | cli_cmd_broadcast_response (ret); |
1002 | free (rsp.dict.dict_val); |
1003 | |
1004 | gf_log ("", GF_LOG_INFO, "Returning with %d", ret)do { do { if (0) printf ("Returning with %d", ret); } while ( 0); _gf_log ("", "cli-rpc-ops.c", __FUNCTION__, 1004, GF_LOG_INFO , "Returning with %d", ret); } while (0); |
1005 | return ret; |
1006 | } |
1007 | |
1008 | int |
1009 | gf_cli3_1_uuid_reset_cbk (struct rpc_req *req, struct iovec *iov, |
1010 | int count, void *myframe) |
1011 | { |
1012 | gf_cli_rsp rsp = {0,}; |
1013 | int ret = -1; |
1014 | cli_local_t *local = NULL((void*)0); |
1015 | call_frame_t *frame = NULL((void*)0); |
1016 | dict_t *dict = NULL((void*)0); |
1017 | |
1018 | if (-1 == req->rpc_status) { |
1019 | goto out; |
1020 | } |
1021 | |
1022 | frame = myframe; |
1023 | |
1024 | ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_cli_rsp); |
1025 | if (ret < 0) { |
1026 | gf_log (frame->this->name, GF_LOG_ERROR,do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__ , 1027, GF_LOG_ERROR, "Failed to decode xdr response"); } while (0) |
1027 | "Failed to decode xdr response")do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__ , 1027, GF_LOG_ERROR, "Failed to decode xdr response"); } while (0); |
1028 | goto out; |
1029 | } |
1030 | |
1031 | local = frame->local; |
1032 | frame->local = NULL((void*)0); |
1033 | |
1034 | gf_log ("cli", GF_LOG_INFO, "Received resp to uuid reset")do { do { if (0) printf ("Received resp to uuid reset"); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 1034, GF_LOG_INFO , "Received resp to uuid reset"); } while (0); |
1035 | |
1036 | if (global_state->mode & GLUSTER_MODE_XML(1 << 2)) { |
1037 | ret = cli_xml_output_dict ("uuidReset", dict, rsp.op_ret, |
1038 | rsp.op_errno, rsp.op_errstr); |
1039 | if (ret) |
1040 | gf_log ("cli", GF_LOG_ERROR,do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 1041, GF_LOG_ERROR , "Error outputting to xml"); } while (0) |
1041 | "Error outputting to xml")do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 1041, GF_LOG_ERROR , "Error outputting to xml"); } while (0); |
1042 | goto out; |
1043 | } |
1044 | |
1045 | if (rsp.op_ret && strcmp (rsp.op_errstr, "")) |
1046 | cli_err ("%s", rsp.op_errstr)do { do { if (0) printf ("%s", rsp.op_errstr); } while (0); _cli_err ("%s", rsp.op_errstr); } while (0); |
1047 | else |
1048 | cli_out ("resetting the peer uuid has been %s",do { do { if (0) printf ("resetting the peer uuid has been %s" , (rsp.op_ret) ? "unsuccessful": "successful"); } while (0); _cli_out ("resetting the peer uuid has been %s", (rsp.op_ret) ? "unsuccessful" : "successful"); } while (0) |
1049 | (rsp.op_ret) ? "unsuccessful": "successful")do { do { if (0) printf ("resetting the peer uuid has been %s" , (rsp.op_ret) ? "unsuccessful": "successful"); } while (0); _cli_out ("resetting the peer uuid has been %s", (rsp.op_ret) ? "unsuccessful" : "successful"); } while (0); |
1050 | ret = rsp.op_ret; |
1051 | |
1052 | out: |
1053 | cli_cmd_broadcast_response (ret); |
1054 | cli_local_wipe (local); |
1055 | if (rsp.dict.dict_val) |
1056 | free (rsp.dict.dict_val); |
1057 | if (dict) |
1058 | dict_unref (dict); |
1059 | |
1060 | gf_log ("", GF_LOG_INFO, "Returning with %d", ret)do { do { if (0) printf ("Returning with %d", ret); } while ( 0); _gf_log ("", "cli-rpc-ops.c", __FUNCTION__, 1060, GF_LOG_INFO , "Returning with %d", ret); } while (0); |
1061 | return ret; |
1062 | } |
1063 | |
1064 | int |
1065 | gf_cli_start_volume_cbk (struct rpc_req *req, struct iovec *iov, |
1066 | int count, void *myframe) |
1067 | { |
1068 | gf_cli_rsp rsp = {0,}; |
1069 | int ret = -1; |
1070 | cli_local_t *local = NULL((void*)0); |
1071 | char *volname = NULL((void*)0); |
1072 | call_frame_t *frame = NULL((void*)0); |
1073 | dict_t *dict = NULL((void*)0); |
1074 | dict_t *rsp_dict = NULL((void*)0); |
1075 | |
1076 | if (-1 == req->rpc_status) { |
1077 | goto out; |
1078 | } |
1079 | |
1080 | frame = myframe; |
1081 | |
1082 | ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_cli_rsp); |
1083 | if (ret < 0) { |
1084 | gf_log (frame->this->name, GF_LOG_ERROR,do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__ , 1085, GF_LOG_ERROR, "Failed to decode xdr response"); } while (0) |
1085 | "Failed to decode xdr response")do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__ , 1085, GF_LOG_ERROR, "Failed to decode xdr response"); } while (0); |
1086 | goto out; |
1087 | } |
1088 | |
1089 | if (frame) |
1090 | local = frame->local; |
1091 | |
1092 | if (local) |
1093 | dict = local->dict; |
1094 | |
1095 | ret = dict_get_str (dict, "volname", &volname); |
1096 | if (ret) { |
1097 | gf_log (frame->this->name, GF_LOG_ERROR, "dict get failed")do { do { if (0) printf ("dict get failed"); } while (0); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__, 1097 , GF_LOG_ERROR, "dict get failed"); } while (0); |
1098 | goto out; |
1099 | } |
1100 | |
1101 | gf_log ("cli", GF_LOG_INFO, "Received resp to start volume")do { do { if (0) printf ("Received resp to start volume"); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 1101, GF_LOG_INFO , "Received resp to start volume"); } while (0); |
1102 | |
1103 | if (global_state->mode & GLUSTER_MODE_XML(1 << 2)) { |
1104 | if (rsp.op_ret == 0) { |
1105 | rsp_dict = dict_new (); |
1106 | ret = dict_unserialize (rsp.dict.dict_val, |
1107 | rsp.dict.dict_len, |
1108 | &rsp_dict); |
1109 | if (ret) { |
1110 | gf_log ("cli", GF_LOG_ERROR,do { do { if (0) printf ("Failed rsp_dict unserialization"); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 1111 , GF_LOG_ERROR, "Failed rsp_dict unserialization"); } while ( 0) |
1111 | "Failed rsp_dict unserialization")do { do { if (0) printf ("Failed rsp_dict unserialization"); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 1111 , GF_LOG_ERROR, "Failed rsp_dict unserialization"); } while ( 0); |
1112 | goto out; |
1113 | } |
1114 | } |
1115 | |
1116 | ret = cli_xml_output_generic_volume ("volStart", rsp_dict, |
1117 | rsp.op_ret, rsp.op_errno, |
1118 | rsp.op_errstr); |
1119 | if (ret) |
1120 | gf_log ("cli", GF_LOG_ERROR,do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 1121, GF_LOG_ERROR , "Error outputting to xml"); } while (0) |
1121 | "Error outputting to xml")do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 1121, GF_LOG_ERROR , "Error outputting to xml"); } while (0); |
1122 | goto out; |
1123 | } |
1124 | |
1125 | if (rsp.op_ret && strcmp (rsp.op_errstr, "")) |
1126 | cli_err ("volume start: %s: failed: %s", volname,do { do { if (0) printf ("volume start: %s: failed: %s", volname , rsp.op_errstr); } while (0); _cli_err("volume start: %s: failed: %s" , volname, rsp.op_errstr); } while (0) |
1127 | rsp.op_errstr)do { do { if (0) printf ("volume start: %s: failed: %s", volname , rsp.op_errstr); } while (0); _cli_err("volume start: %s: failed: %s" , volname, rsp.op_errstr); } while (0); |
1128 | else if (rsp.op_ret) |
1129 | cli_err ("volume start: %s: failed", volname)do { do { if (0) printf ("volume start: %s: failed", volname) ; } while (0); _cli_err("volume start: %s: failed", volname); } while (0); |
1130 | else |
1131 | cli_out ("volume start: %s: success", volname)do { do { if (0) printf ("volume start: %s: success", volname ); } while (0); _cli_out("volume start: %s: success", volname ); } while (0); |
1132 | |
1133 | ret = rsp.op_ret; |
1134 | |
1135 | out: |
1136 | cli_cmd_broadcast_response (ret); |
1137 | free (rsp.dict.dict_val); |
1138 | free (rsp.op_errstr); |
1139 | return ret; |
1140 | } |
1141 | |
1142 | int |
1143 | gf_cli_stop_volume_cbk (struct rpc_req *req, struct iovec *iov, |
1144 | int count, void *myframe) |
1145 | { |
1146 | gf_cli_rsp rsp = {0,}; |
1147 | int ret = -1; |
1148 | cli_local_t *local = NULL((void*)0); |
1149 | char *volname = NULL((void*)0); |
1150 | call_frame_t *frame = NULL((void*)0); |
1151 | dict_t *dict = NULL((void*)0); |
1152 | dict_t *rsp_dict = NULL((void*)0); |
1153 | |
1154 | if (-1 == req->rpc_status) { |
1155 | goto out; |
1156 | } |
1157 | |
1158 | frame = myframe; |
1159 | |
1160 | ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_cli_rsp); |
1161 | if (ret < 0) { |
1162 | gf_log (frame->this->name, GF_LOG_ERROR,do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__ , 1163, GF_LOG_ERROR, "Failed to decode xdr response"); } while (0) |
1163 | "Failed to decode xdr response")do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__ , 1163, GF_LOG_ERROR, "Failed to decode xdr response"); } while (0); |
1164 | goto out; |
1165 | } |
1166 | |
1167 | if (frame) |
1168 | local = frame->local; |
1169 | |
1170 | if (local) { |
1171 | dict = local->dict; |
1172 | ret = dict_get_str (dict, "volname", &volname); |
1173 | if (ret) { |
1174 | gf_log (frame->this->name, GF_LOG_ERROR,do { do { if (0) printf ("Unable to get volname from dict"); } while (0); _gf_log (frame->this->name, "cli-rpc-ops.c" , __FUNCTION__, 1175, GF_LOG_ERROR, "Unable to get volname from dict" ); } while (0) |
1175 | "Unable to get volname from dict")do { do { if (0) printf ("Unable to get volname from dict"); } while (0); _gf_log (frame->this->name, "cli-rpc-ops.c" , __FUNCTION__, 1175, GF_LOG_ERROR, "Unable to get volname from dict" ); } while (0); |
1176 | goto out; |
1177 | } |
1178 | } |
1179 | |
1180 | gf_log ("cli", GF_LOG_INFO, "Received resp to stop volume")do { do { if (0) printf ("Received resp to stop volume"); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 1180, GF_LOG_INFO , "Received resp to stop volume"); } while (0); |
1181 | |
1182 | if (global_state->mode & GLUSTER_MODE_XML(1 << 2)) { |
1183 | if (rsp.op_ret == 0) { |
1184 | rsp_dict = dict_new (); |
1185 | ret = dict_unserialize (rsp.dict.dict_val, |
1186 | rsp.dict.dict_len, |
1187 | &rsp_dict); |
1188 | if (ret) { |
1189 | gf_log ("cli", GF_LOG_ERROR,do { do { if (0) printf ("Failed rsp_dict unserialization"); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 1190 , GF_LOG_ERROR, "Failed rsp_dict unserialization"); } while ( 0) |
1190 | "Failed rsp_dict unserialization")do { do { if (0) printf ("Failed rsp_dict unserialization"); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 1190 , GF_LOG_ERROR, "Failed rsp_dict unserialization"); } while ( 0); |
1191 | goto out; |
1192 | } |
1193 | } |
1194 | |
1195 | ret = cli_xml_output_generic_volume ("volStop", rsp_dict, |
1196 | rsp.op_ret, rsp.op_errno, |
1197 | rsp.op_errstr); |
1198 | if (ret) |
1199 | gf_log ("cli", GF_LOG_ERROR,do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 1200, GF_LOG_ERROR , "Error outputting to xml"); } while (0) |
1200 | "Error outputting to xml")do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 1200, GF_LOG_ERROR , "Error outputting to xml"); } while (0); |
1201 | goto out; |
1202 | } |
1203 | |
1204 | if (rsp.op_ret && strcmp (rsp.op_errstr, "")) |
1205 | cli_err ("volume stop: %s: failed: %s", volname, rsp.op_errstr)do { do { if (0) printf ("volume stop: %s: failed: %s", volname , rsp.op_errstr); } while (0); _cli_err("volume stop: %s: failed: %s" , volname, rsp.op_errstr); } while (0); |
1206 | else if (rsp.op_ret) |
1207 | cli_err ("volume stop: %s: failed", volname)do { do { if (0) printf ("volume stop: %s: failed", volname); } while (0); _cli_err("volume stop: %s: failed", volname); } while (0); |
1208 | else |
1209 | cli_out ("volume stop: %s: success", volname)do { do { if (0) printf ("volume stop: %s: success", volname) ; } while (0); _cli_out("volume stop: %s: success", volname); } while (0); |
1210 | |
1211 | ret = rsp.op_ret; |
1212 | |
1213 | out: |
1214 | cli_cmd_broadcast_response (ret); |
1215 | free (rsp.op_errstr); |
1216 | free (rsp.dict.dict_val); |
1217 | |
1218 | return ret; |
1219 | } |
1220 | |
1221 | int |
1222 | gf_cli_defrag_volume_cbk (struct rpc_req *req, struct iovec *iov, |
1223 | int count, void *myframe) |
1224 | { |
1225 | gf_cli_rsp rsp = {0,}; |
1226 | cli_local_t *local = NULL((void*)0); |
1227 | char *volname = NULL((void*)0); |
1228 | call_frame_t *frame = NULL((void*)0); |
1229 | char *status = "unknown"; |
1230 | int cmd = 0; |
1231 | int ret = -1; |
1232 | dict_t *dict = NULL((void*)0); |
1233 | dict_t *local_dict = NULL((void*)0); |
1234 | uint64_t files = 0; |
1235 | uint64_t size = 0; |
1236 | uint64_t lookup = 0; |
1237 | char msg[1024] = {0,}; |
1238 | gf_defrag_status_t status_rcd = GF_DEFRAG_STATUS_NOT_STARTED; |
1239 | int32_t counter = 0; |
1240 | char *node_uuid = NULL((void*)0); |
1241 | char key[256] = {0,}; |
1242 | int32_t i = 1; |
1243 | uint64_t failures = 0; |
1244 | double elapsed = 0; |
1245 | char *size_str = NULL((void*)0); |
1246 | char *task_id_str = NULL((void*)0); |
1247 | |
1248 | if (-1 == req->rpc_status) { |
1249 | goto out; |
1250 | } |
1251 | |
1252 | frame = myframe; |
1253 | |
1254 | ret = xdr_to_generic (*iov, &rsp, |
1255 | (xdrproc_t)xdr_gf_cli_rsp); |
1256 | if (ret < 0) { |
1257 | gf_log (frame->this->name, GF_LOG_ERROR,do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__ , 1258, GF_LOG_ERROR, "Failed to decode xdr response"); } while (0) |
1258 | "Failed to decode xdr response")do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__ , 1258, GF_LOG_ERROR, "Failed to decode xdr response"); } while (0); |
1259 | goto out; |
1260 | } |
1261 | |
1262 | if (frame) |
1263 | local = frame->local; |
1264 | |
1265 | if (local) |
1266 | local_dict = local->dict; |
1267 | |
1268 | ret = dict_get_str (local_dict, "volname", &volname); |
1269 | if (ret) { |
1270 | gf_log (frame->this->name, GF_LOG_ERROR,do { do { if (0) printf ("Failed to get volname"); } while (0 ); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__ , 1271, GF_LOG_ERROR, "Failed to get volname"); } while (0) |
1271 | "Failed to get volname")do { do { if (0) printf ("Failed to get volname"); } while (0 ); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__ , 1271, GF_LOG_ERROR, "Failed to get volname"); } while (0); |
1272 | goto out; |
1273 | } |
1274 | |
1275 | ret = dict_get_int32 (local_dict, "rebalance-command", (int32_t*)&cmd); |
1276 | if (ret) { |
1277 | gf_log (frame->this->name, GF_LOG_ERROR,do { do { if (0) printf ("Failed to get command"); } while (0 ); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__ , 1278, GF_LOG_ERROR, "Failed to get command"); } while (0) |
1278 | "Failed to get command")do { do { if (0) printf ("Failed to get command"); } while (0 ); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__ , 1278, GF_LOG_ERROR, "Failed to get command"); } while (0); |
1279 | goto out; |
1280 | } |
1281 | |
1282 | if (rsp.dict.dict_len) { |
1283 | /* Unserialize the dictionary */ |
1284 | dict = dict_new (); |
1285 | |
1286 | ret = dict_unserialize (rsp.dict.dict_val, |
1287 | rsp.dict.dict_len, |
1288 | &dict); |
1289 | if (ret < 0) { |
1290 | gf_log ("glusterd", GF_LOG_ERROR,do { do { if (0) printf ("failed to " "unserialize req-buffer to dictionary" ); } while (0); _gf_log ("glusterd", "cli-rpc-ops.c", __FUNCTION__ , 1292, GF_LOG_ERROR, "failed to " "unserialize req-buffer to dictionary" ); } while (0) |
1291 | "failed to "do { do { if (0) printf ("failed to " "unserialize req-buffer to dictionary" ); } while (0); _gf_log ("glusterd", "cli-rpc-ops.c", __FUNCTION__ , 1292, GF_LOG_ERROR, "failed to " "unserialize req-buffer to dictionary" ); } while (0) |
1292 | "unserialize req-buffer to dictionary")do { do { if (0) printf ("failed to " "unserialize req-buffer to dictionary" ); } while (0); _gf_log ("glusterd", "cli-rpc-ops.c", __FUNCTION__ , 1292, GF_LOG_ERROR, "failed to " "unserialize req-buffer to dictionary" ); } while (0); |
1293 | goto out; |
1294 | } |
1295 | } |
1296 | |
1297 | if (!((cmd == GF_DEFRAG_CMD_STOP) || (cmd == GF_DEFRAG_CMD_STATUS)) && |
1298 | !(global_state->mode & GLUSTER_MODE_XML(1 << 2))) { |
1299 | /* All other possibilites are about starting a rebalance */ |
1300 | ret = dict_get_str (dict, GF_REBALANCE_TID_KEY"rebalance-id", &task_id_str); |
1301 | if (rsp.op_ret && strcmp (rsp.op_errstr, "")) { |
1302 | snprintf (msg, sizeof (msg), "%s", rsp.op_errstr); |
1303 | } else { |
1304 | if (!rsp.op_ret) { |
1305 | snprintf (msg, sizeof (msg), |
1306 | "Starting rebalance on volume %s has " |
1307 | "been successful.\nID: %s", volname, |
1308 | task_id_str); |
1309 | } else { |
1310 | snprintf (msg, sizeof (msg), |
1311 | "Starting rebalance on volume %s has " |
1312 | "been unsuccessful.", volname); |
1313 | } |
1314 | } |
1315 | goto done; |
1316 | } |
1317 | |
1318 | if (cmd == GF_DEFRAG_CMD_STOP) { |
1319 | if (rsp.op_ret == -1) { |
1320 | if (strcmp (rsp.op_errstr, "")) |
1321 | snprintf (msg, sizeof (msg), |
1322 | "%s", rsp.op_errstr); |
1323 | else |
1324 | snprintf (msg, sizeof (msg), |
1325 | "rebalance volume %s stop failed", |
1326 | volname); |
1327 | goto done; |
1328 | } else { |
1329 | snprintf (msg, sizeof (msg), |
1330 | "rebalance process may be in the middle of a " |
1331 | "file migration.\nThe process will be fully " |
1332 | "stopped once the migration of the file is " |
1333 | "complete.\nPlease check rebalance process " |
1334 | "for completion before doing any further " |
1335 | "brick related tasks on the volume."); |
1336 | } |
1337 | } |
1338 | if (cmd == GF_DEFRAG_CMD_STATUS) { |
1339 | if (rsp.op_ret == -1) { |
1340 | if (strcmp (rsp.op_errstr, "")) |
1341 | snprintf (msg, sizeof (msg), |
1342 | "%s", rsp.op_errstr); |
1343 | else |
1344 | snprintf (msg, sizeof (msg), |
1345 | "Failed to get the status of " |
1346 | "rebalance process"); |
1347 | goto done; |
1348 | } |
1349 | } |
1350 | |
1351 | if (global_state->mode & GLUSTER_MODE_XML(1 << 2)) { |
1352 | ret = cli_xml_output_vol_rebalance (cmd, dict, rsp.op_ret, |
1353 | rsp.op_errno, |
1354 | rsp.op_errstr); |
1355 | goto out; |
1356 | } |
1357 | |
1358 | ret = dict_get_int32 (dict, "count", &counter); |
1359 | if (ret) { |
1360 | gf_log (frame->this->name, GF_LOG_ERROR, "count not set")do { do { if (0) printf ("count not set"); } while (0); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__, 1360 , GF_LOG_ERROR, "count not set"); } while (0); |
1361 | goto out; |
1362 | } |
1363 | |
1364 | cli_out ("%40s %16s %13s %13s %13s %14s %s", "Node", "Rebalanced-files",do { do { if (0) printf ("%40s %16s %13s %13s %13s %14s %s", "Node" , "Rebalanced-files", "size", "scanned", "failures", "status" , "run time in secs"); } while (0); _cli_out("%40s %16s %13s %13s %13s %14s %s" , "Node", "Rebalanced-files", "size", "scanned", "failures", "status" , "run time in secs"); } while (0) |
1365 | "size", "scanned", "failures", "status", "run time in secs")do { do { if (0) printf ("%40s %16s %13s %13s %13s %14s %s", "Node" , "Rebalanced-files", "size", "scanned", "failures", "status" , "run time in secs"); } while (0); _cli_out("%40s %16s %13s %13s %13s %14s %s" , "Node", "Rebalanced-files", "size", "scanned", "failures", "status" , "run time in secs"); } while (0); |
1366 | cli_out ("%40s %16s %13s %13s %13s %14s %16s", "---------",do { do { if (0) printf ("%40s %16s %13s %13s %13s %14s %16s" , "---------", "-----------", "-----------", "-----------", "-----------" , "------------", "--------------"); } while (0); _cli_out("%40s %16s %13s %13s %13s %14s %16s" , "---------", "-----------", "-----------", "-----------", "-----------" , "------------", "--------------"); } while (0) |
1367 | "-----------", "-----------", "-----------", "-----------",do { do { if (0) printf ("%40s %16s %13s %13s %13s %14s %16s" , "---------", "-----------", "-----------", "-----------", "-----------" , "------------", "--------------"); } while (0); _cli_out("%40s %16s %13s %13s %13s %14s %16s" , "---------", "-----------", "-----------", "-----------", "-----------" , "------------", "--------------"); } while (0) |
1368 | "------------", "--------------")do { do { if (0) printf ("%40s %16s %13s %13s %13s %14s %16s" , "---------", "-----------", "-----------", "-----------", "-----------" , "------------", "--------------"); } while (0); _cli_out("%40s %16s %13s %13s %13s %14s %16s" , "---------", "-----------", "-----------", "-----------", "-----------" , "------------", "--------------"); } while (0); |
1369 | do { |
1370 | snprintf (key, 256, "node-uuid-%d", i); |
1371 | ret = dict_get_str (dict, key, &node_uuid); |
1372 | if (ret) |
1373 | gf_log (frame->this->name, GF_LOG_TRACE,do { do { if (0) printf ("failed to get node-uuid"); } while ( 0); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__ , 1374, GF_LOG_TRACE, "failed to get node-uuid"); } while (0) |
1374 | "failed to get node-uuid")do { do { if (0) printf ("failed to get node-uuid"); } while ( 0); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__ , 1374, GF_LOG_TRACE, "failed to get node-uuid"); } while (0); |
1375 | |
1376 | memset (key, 0, 256); |
1377 | snprintf (key, 256, "files-%d", i); |
1378 | ret = dict_get_uint64 (dict, key, &files); |
1379 | if (ret) |
1380 | gf_log (frame->this->name, GF_LOG_TRACE,do { do { if (0) printf ("failed to get file count"); } while (0); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__ , 1381, GF_LOG_TRACE, "failed to get file count"); } while (0 ) |
1381 | "failed to get file count")do { do { if (0) printf ("failed to get file count"); } while (0); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__ , 1381, GF_LOG_TRACE, "failed to get file count"); } while (0 ); |
1382 | |
1383 | memset (key, 0, 256); |
1384 | snprintf (key, 256, "size-%d", i); |
1385 | ret = dict_get_uint64 (dict, key, &size); |
1386 | if (ret) |
1387 | gf_log (frame->this->name, GF_LOG_TRACE,do { do { if (0) printf ("failed to get size of xfer"); } while (0); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__ , 1388, GF_LOG_TRACE, "failed to get size of xfer"); } while ( 0) |
1388 | "failed to get size of xfer")do { do { if (0) printf ("failed to get size of xfer"); } while (0); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__ , 1388, GF_LOG_TRACE, "failed to get size of xfer"); } while ( 0); |
1389 | |
1390 | memset (key, 0, 256); |
1391 | snprintf (key, 256, "lookups-%d", i); |
1392 | ret = dict_get_uint64 (dict, key, &lookup); |
1393 | if (ret) |
1394 | gf_log (frame->this->name, GF_LOG_TRACE,do { do { if (0) printf ("failed to get lookedup file count") ; } while (0); _gf_log (frame->this->name, "cli-rpc-ops.c" , __FUNCTION__, 1395, GF_LOG_TRACE, "failed to get lookedup file count" ); } while (0) |
1395 | "failed to get lookedup file count")do { do { if (0) printf ("failed to get lookedup file count") ; } while (0); _gf_log (frame->this->name, "cli-rpc-ops.c" , __FUNCTION__, 1395, GF_LOG_TRACE, "failed to get lookedup file count" ); } while (0); |
1396 | |
1397 | memset (key, 0, 256); |
1398 | snprintf (key, 256, "status-%d", i); |
1399 | ret = dict_get_int32 (dict, key, (int32_t *)&status_rcd); |
1400 | if (ret) |
1401 | gf_log (frame->this->name, GF_LOG_TRACE,do { do { if (0) printf ("failed to get status"); } while (0) ; _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__ , 1402, GF_LOG_TRACE, "failed to get status"); } while (0) |
1402 | "failed to get status")do { do { if (0) printf ("failed to get status"); } while (0) ; _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__ , 1402, GF_LOG_TRACE, "failed to get status"); } while (0); |
1403 | |
1404 | memset (key, 0, 256); |
1405 | snprintf (key, 256, "failures-%d", i); |
1406 | ret = dict_get_uint64 (dict, key, &failures); |
1407 | if (ret) |
1408 | gf_log (frame->this->name, GF_LOG_TRACE,do { do { if (0) printf ("failed to get failures count"); } while (0); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__ , 1409, GF_LOG_TRACE, "failed to get failures count"); } while (0) |
1409 | "failed to get failures count")do { do { if (0) printf ("failed to get failures count"); } while (0); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__ , 1409, GF_LOG_TRACE, "failed to get failures count"); } while (0); |
1410 | |
1411 | memset (key, 0, 256); |
1412 | snprintf (key, 256, "run-time-%d", i); |
1413 | ret = dict_get_double (dict, key, &elapsed); |
1414 | if (ret) |
1415 | gf_log (frame->this->name, GF_LOG_TRACE,do { do { if (0) printf ("failed to get run-time"); } while ( 0); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__ , 1416, GF_LOG_TRACE, "failed to get run-time"); } while (0) |
1416 | "failed to get run-time")do { do { if (0) printf ("failed to get run-time"); } while ( 0); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__ , 1416, GF_LOG_TRACE, "failed to get run-time"); } while (0); |
1417 | |
1418 | switch (status_rcd) { |
1419 | case GF_DEFRAG_STATUS_NOT_STARTED: |
1420 | status = "not started"; |
1421 | break; |
1422 | case GF_DEFRAG_STATUS_STARTED: |
1423 | status = "in progress"; |
1424 | break; |
1425 | case GF_DEFRAG_STATUS_STOPPED: |
1426 | status = "stopped"; |
1427 | break; |
1428 | case GF_DEFRAG_STATUS_COMPLETE: |
1429 | status = "completed"; |
1430 | break; |
1431 | case GF_DEFRAG_STATUS_FAILED: |
1432 | status = "failed"; |
1433 | break; |
1434 | } |
1435 | |
1436 | size_str = gf_uint64_2human_readable(size); |
1437 | cli_out ("%40s %16"PRIu64 " %13s" " %13"PRIu64 " %13"PRIu64do { do { if (0) printf ("%40s %16""ll" "u" " %13s" " %13""ll" "u" " %13""ll" "u" " %14s %16.2f", node_uuid, files, size_str , lookup, failures, status, elapsed); } while (0); _cli_out("%40s %16" "ll" "u" " %13s" " %13""ll" "u" " %13""ll" "u" " %14s %16.2f" , node_uuid, files, size_str, lookup, failures, status, elapsed ); } while (0) |
1438 | " %14s %16.2f", node_uuid, files, size_str, lookup,do { do { if (0) printf ("%40s %16""ll" "u" " %13s" " %13""ll" "u" " %13""ll" "u" " %14s %16.2f", node_uuid, files, size_str , lookup, failures, status, elapsed); } while (0); _cli_out("%40s %16" "ll" "u" " %13s" " %13""ll" "u" " %13""ll" "u" " %14s %16.2f" , node_uuid, files, size_str, lookup, failures, status, elapsed ); } while (0) |
1439 | failures, status, elapsed)do { do { if (0) printf ("%40s %16""ll" "u" " %13s" " %13""ll" "u" " %13""ll" "u" " %14s %16.2f", node_uuid, files, size_str , lookup, failures, status, elapsed); } while (0); _cli_out("%40s %16" "ll" "u" " %13s" " %13""ll" "u" " %13""ll" "u" " %14s %16.2f" , node_uuid, files, size_str, lookup, failures, status, elapsed ); } while (0); |
1440 | GF_FREE(size_str)__gf_free (size_str); |
1441 | |
1442 | i++; |
1443 | } while (i <= counter); |
1444 | |
1445 | |
1446 | done: |
1447 | if (rsp.op_ret) |
1448 | cli_err ("volume rebalance: %s: failed: %s", volname, msg)do { do { if (0) printf ("volume rebalance: %s: failed: %s", volname , msg); } while (0); _cli_err("volume rebalance: %s: failed: %s" , volname, msg); } while (0); |
1449 | else |
1450 | cli_out ("volume rebalance: %s: success: %s", volname, msg)do { do { if (0) printf ("volume rebalance: %s: success: %s", volname, msg); } while (0); _cli_out("volume rebalance: %s: success: %s" , volname, msg); } while (0); |
1451 | ret = rsp.op_ret; |
1452 | |
1453 | out: |
1454 | free (rsp.op_errstr); //malloced by xdr |
1455 | free (rsp.dict.dict_val); //malloced by xdr |
1456 | if (dict) |
1457 | dict_unref (dict); |
1458 | cli_cmd_broadcast_response (ret); |
1459 | return ret; |
1460 | } |
1461 | |
1462 | int |
1463 | gf_cli_rename_volume_cbk (struct rpc_req *req, struct iovec *iov, |
1464 | int count, void *myframe) |
1465 | { |
1466 | gf_cli_rsp rsp = {0,}; |
1467 | int ret = -1; |
1468 | char msg[1024] = {0,}; |
1469 | |
1470 | if (-1 == req->rpc_status) { |
1471 | goto out; |
1472 | } |
1473 | |
1474 | ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_cli_rsp); |
1475 | if (ret < 0) { |
1476 | gf_log (((call_frame_t *) myframe)->this->name, GF_LOG_ERROR,do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (((call_frame_t *) myframe)->this->name, "cli-rpc-ops.c" , __FUNCTION__, 1477, GF_LOG_ERROR, "Failed to decode xdr response" ); } while (0) |
1477 | "Failed to decode xdr response")do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (((call_frame_t *) myframe)->this->name, "cli-rpc-ops.c" , __FUNCTION__, 1477, GF_LOG_ERROR, "Failed to decode xdr response" ); } while (0); |
1478 | goto out; |
1479 | } |
1480 | |
1481 | |
1482 | gf_log ("cli", GF_LOG_INFO, "Received resp to probe")do { do { if (0) printf ("Received resp to probe"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 1482, GF_LOG_INFO , "Received resp to probe"); } while (0); |
1483 | snprintf (msg, sizeof (msg), "Rename volume %s", |
1484 | (rsp.op_ret) ? "unsuccessful": "successful"); |
1485 | |
1486 | if (global_state->mode & GLUSTER_MODE_XML(1 << 2)) { |
1487 | ret = cli_xml_output_str ("volRename", msg, rsp.op_ret, |
1488 | rsp.op_errno, rsp.op_errstr); |
1489 | if (ret) |
1490 | gf_log ("cli", GF_LOG_ERROR,do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 1491, GF_LOG_ERROR , "Error outputting to xml"); } while (0) |
1491 | "Error outputting to xml")do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 1491, GF_LOG_ERROR , "Error outputting to xml"); } while (0); |
1492 | goto out; |
1493 | } |
1494 | |
1495 | if (rsp.op_ret) |
1496 | cli_err ("volume rename: failed")do { do { if (0) printf ("volume rename: failed"); } while (0 ); _cli_err("volume rename: failed"); } while (0); |
1497 | else |
1498 | cli_out ("volume rename: success")do { do { if (0) printf ("volume rename: success"); } while ( 0); _cli_out("volume rename: success"); } while (0); |
1499 | |
1500 | ret = rsp.op_ret; |
1501 | |
1502 | out: |
1503 | cli_cmd_broadcast_response (ret); |
1504 | return ret; |
1505 | } |
1506 | |
1507 | int |
1508 | gf_cli_reset_volume_cbk (struct rpc_req *req, struct iovec *iov, |
1509 | int count, void *myframe) |
1510 | { |
1511 | gf_cli_rsp rsp = {0,}; |
1512 | int ret = -1; |
1513 | char msg[1024] = {0,}; |
1514 | |
1515 | if (-1 == req->rpc_status) { |
1516 | goto out; |
1517 | } |
1518 | |
1519 | ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_cli_rsp); |
1520 | if (ret < 0) { |
1521 | gf_log (((call_frame_t *) myframe)->this->name, GF_LOG_ERROR,do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (((call_frame_t *) myframe)->this->name, "cli-rpc-ops.c" , __FUNCTION__, 1522, GF_LOG_ERROR, "Failed to decode xdr response" ); } while (0) |
1522 | "Failed to decode xdr response")do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (((call_frame_t *) myframe)->this->name, "cli-rpc-ops.c" , __FUNCTION__, 1522, GF_LOG_ERROR, "Failed to decode xdr response" ); } while (0); |
1523 | goto out; |
1524 | } |
1525 | |
1526 | gf_log ("cli", GF_LOG_INFO, "Received resp to reset")do { do { if (0) printf ("Received resp to reset"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 1526, GF_LOG_INFO , "Received resp to reset"); } while (0); |
1527 | |
1528 | if (rsp.op_ret && strcmp (rsp.op_errstr, "")) |
1529 | snprintf (msg, sizeof (msg), "%s", rsp.op_errstr); |
1530 | else |
1531 | snprintf (msg, sizeof (msg), "reset volume %s", |
1532 | (rsp.op_ret) ? "unsuccessful": "successful"); |
1533 | |
1534 | if (global_state->mode & GLUSTER_MODE_XML(1 << 2)) { |
1535 | ret = cli_xml_output_str ("volReset", msg, rsp.op_ret, |
1536 | rsp.op_errno, rsp.op_errstr); |
1537 | if (ret) |
1538 | gf_log ("cli", GF_LOG_ERROR,do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 1539, GF_LOG_ERROR , "Error outputting to xml"); } while (0) |
1539 | "Error outputting to xml")do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 1539, GF_LOG_ERROR , "Error outputting to xml"); } while (0); |
1540 | goto out; |
1541 | } |
1542 | |
1543 | if (rsp.op_ret) |
1544 | cli_err ("volume reset: failed: %s", msg)do { do { if (0) printf ("volume reset: failed: %s", msg); } while (0); _cli_err("volume reset: failed: %s", msg); } while (0); |
1545 | else |
1546 | cli_out ("volume reset: success")do { do { if (0) printf ("volume reset: success"); } while (0 ); _cli_out("volume reset: success"); } while (0); |
1547 | |
1548 | ret = rsp.op_ret; |
1549 | |
1550 | out: |
1551 | cli_cmd_broadcast_response (ret); |
1552 | return ret; |
1553 | } |
1554 | |
1555 | char * |
1556 | is_server_debug_xlator (void *myframe) |
1557 | { |
1558 | call_frame_t *frame = NULL((void*)0); |
1559 | cli_local_t *local = NULL((void*)0); |
1560 | char **words = NULL((void*)0); |
1561 | char *key = NULL((void*)0); |
1562 | char *value = NULL((void*)0); |
1563 | char *debug_xlator = NULL((void*)0); |
1564 | |
1565 | frame = myframe; |
1566 | local = frame->local; |
1567 | words = (char **)local->words; |
1568 | |
1569 | while (*words != NULL((void*)0)) { |
1570 | if (strstr (*words, "trace") == NULL((void*)0) && |
1571 | strstr (*words, "error-gen") == NULL((void*)0)) { |
1572 | words++; |
1573 | continue; |
1574 | } |
1575 | |
1576 | key = *words; |
1577 | words++; |
1578 | value = *words; |
1579 | if (strstr (value, "client")) { |
1580 | words++; |
1581 | continue; |
1582 | } else { |
1583 | if (!(strstr (value, "posix") || strstr (value, "acl") |
1584 | || strstr (value, "locks") || |
1585 | strstr (value, "io-threads") || |
1586 | strstr (value, "marker") || |
1587 | strstr (value, "index"))) { |
1588 | words++; |
1589 | continue; |
1590 | } else { |
1591 | debug_xlator = gf_strdup (key); |
1592 | break; |
1593 | } |
1594 | } |
1595 | } |
1596 | |
1597 | return debug_xlator; |
1598 | } |
1599 | |
1600 | int |
1601 | gf_cli_set_volume_cbk (struct rpc_req *req, struct iovec *iov, |
1602 | int count, void *myframe) |
1603 | { |
1604 | gf_cli_rsp rsp = {0,}; |
1605 | int ret = -1; |
1606 | dict_t *dict = NULL((void*)0); |
1607 | char *help_str = NULL((void*)0); |
1608 | char msg[1024] = {0,}; |
1609 | char *debug_xlator = _gf_false; |
1610 | char tmp_str[512] = {0,}; |
1611 | |
1612 | if (-1 == req->rpc_status) { |
1613 | goto out; |
1614 | } |
1615 | |
1616 | ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_cli_rsp); |
1617 | if (ret < 0) { |
1618 | gf_log (((call_frame_t *) myframe)->this->name, GF_LOG_ERROR,do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (((call_frame_t *) myframe)->this->name, "cli-rpc-ops.c" , __FUNCTION__, 1619, GF_LOG_ERROR, "Failed to decode xdr response" ); } while (0) |
1619 | "Failed to decode xdr response")do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (((call_frame_t *) myframe)->this->name, "cli-rpc-ops.c" , __FUNCTION__, 1619, GF_LOG_ERROR, "Failed to decode xdr response" ); } while (0); |
1620 | goto out; |
1621 | } |
1622 | |
1623 | gf_log ("cli", GF_LOG_INFO, "Received resp to set")do { do { if (0) printf ("Received resp to set"); } while (0) ; _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 1623, GF_LOG_INFO , "Received resp to set"); } while (0); |
1624 | |
1625 | dict = dict_new (); |
1626 | |
1627 | if (!dict) { |
1628 | ret = -1; |
1629 | goto out; |
1630 | } |
1631 | |
1632 | ret = dict_unserialize (rsp.dict.dict_val, rsp.dict.dict_len, &dict); |
1633 | |
1634 | /* For brick processes graph change does not happen on the fly. |
1635 | * The proces has to be restarted. So this is a check from the |
1636 | * volume set option such that if debug xlators such as trace/errorgen |
1637 | * are provided in the set command, warn the user. |
1638 | */ |
1639 | debug_xlator = is_server_debug_xlator (myframe); |
1640 | |
1641 | if (dict_get_str (dict, "help-str", &help_str) && !msg[0]) |
1642 | snprintf (msg, sizeof (msg), "Set volume %s", |
1643 | (rsp.op_ret) ? "unsuccessful": "successful"); |
1644 | if (rsp.op_ret == 0 && debug_xlator) { |
1645 | snprintf (tmp_str, sizeof (tmp_str), "\n%s translator has been " |
1646 | "added to the server volume file. Please restart the" |
1647 | " volume for enabling the translator", debug_xlator); |
1648 | } |
1649 | |
1650 | if ((global_state->mode & GLUSTER_MODE_XML(1 << 2)) && (help_str == NULL((void*)0))) { |
1651 | ret = cli_xml_output_str ("volSet", msg, rsp.op_ret, |
1652 | rsp.op_errno, rsp.op_errstr); |
1653 | if (ret) |
1654 | gf_log ("cli", GF_LOG_ERROR,do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 1655, GF_LOG_ERROR , "Error outputting to xml"); } while (0) |
1655 | "Error outputting to xml")do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 1655, GF_LOG_ERROR , "Error outputting to xml"); } while (0); |
1656 | goto out; |
1657 | } |
1658 | |
1659 | if (rsp.op_ret) { |
1660 | if (strcmp (rsp.op_errstr, "")) |
1661 | cli_err ("volume set: failed: %s", rsp.op_errstr)do { do { if (0) printf ("volume set: failed: %s", rsp.op_errstr ); } while (0); _cli_err("volume set: failed: %s", rsp.op_errstr ); } while (0); |
1662 | else |
1663 | cli_err ("volume set: failed")do { do { if (0) printf ("volume set: failed"); } while (0); _cli_err ("volume set: failed"); } while (0); |
1664 | } else { |
1665 | if (help_str == NULL((void*)0)) { |
1666 | if (debug_xlator == NULL((void*)0)) |
1667 | cli_out ("volume set: success")do { do { if (0) printf ("volume set: success"); } while (0); _cli_out("volume set: success"); } while (0); |
1668 | else |
1669 | cli_out ("volume set: success%s", tmp_str)do { do { if (0) printf ("volume set: success%s", tmp_str); } while (0); _cli_out("volume set: success%s", tmp_str); } while (0); |
1670 | }else { |
1671 | cli_out ("%s", help_str)do { do { if (0) printf ("%s", help_str); } while (0); _cli_out ("%s", help_str); } while (0); |
1672 | } |
1673 | } |
1674 | |
1675 | ret = rsp.op_ret; |
1676 | |
1677 | out: |
1678 | if (dict) |
1679 | dict_unref (dict); |
1680 | GF_FREE (debug_xlator)__gf_free (debug_xlator); |
1681 | cli_cmd_broadcast_response (ret); |
1682 | return ret; |
1683 | } |
1684 | |
1685 | int |
1686 | gf_cli_add_brick_cbk (struct rpc_req *req, struct iovec *iov, |
1687 | int count, void *myframe) |
1688 | { |
1689 | gf_cli_rsp rsp = {0,}; |
1690 | int ret = -1; |
1691 | char msg[1024] = {0,}; |
1692 | |
1693 | if (-1 == req->rpc_status) { |
1694 | goto out; |
1695 | } |
1696 | |
1697 | ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_cli_rsp); |
1698 | if (ret < 0) { |
1699 | gf_log (((call_frame_t *) myframe)->this->name, GF_LOG_ERROR,do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (((call_frame_t *) myframe)->this->name, "cli-rpc-ops.c" , __FUNCTION__, 1700, GF_LOG_ERROR, "Failed to decode xdr response" ); } while (0) |
1700 | "Failed to decode xdr response")do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (((call_frame_t *) myframe)->this->name, "cli-rpc-ops.c" , __FUNCTION__, 1700, GF_LOG_ERROR, "Failed to decode xdr response" ); } while (0); |
1701 | goto out; |
1702 | } |
1703 | |
1704 | |
1705 | gf_log ("cli", GF_LOG_INFO, "Received resp to add brick")do { do { if (0) printf ("Received resp to add brick"); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 1705, GF_LOG_INFO , "Received resp to add brick"); } while (0); |
1706 | |
1707 | if (rsp.op_ret && strcmp (rsp.op_errstr, "")) |
1708 | snprintf (msg, sizeof (msg), "%s", rsp.op_errstr); |
1709 | else |
1710 | snprintf (msg, sizeof (msg), "Add Brick %s", |
1711 | (rsp.op_ret) ? "unsuccessful": "successful"); |
1712 | |
1713 | if (global_state->mode & GLUSTER_MODE_XML(1 << 2)) { |
1714 | ret = cli_xml_output_str ("volAddBrick", msg, rsp.op_ret, |
1715 | rsp.op_errno, rsp.op_errstr); |
1716 | if (ret) |
1717 | gf_log ("cli", GF_LOG_ERROR,do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 1718, GF_LOG_ERROR , "Error outputting to xml"); } while (0) |
1718 | "Error outputting to xml")do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 1718, GF_LOG_ERROR , "Error outputting to xml"); } while (0); |
1719 | goto out; |
1720 | } |
1721 | |
1722 | if (rsp.op_ret) |
1723 | cli_err ("volume add-brick: failed: %s", rsp.op_errstr)do { do { if (0) printf ("volume add-brick: failed: %s", rsp. op_errstr); } while (0); _cli_err("volume add-brick: failed: %s" , rsp.op_errstr); } while (0); |
1724 | else |
1725 | cli_out ("volume add-brick: success")do { do { if (0) printf ("volume add-brick: success"); } while (0); _cli_out("volume add-brick: success"); } while (0); |
1726 | ret = rsp.op_ret; |
1727 | |
1728 | out: |
1729 | cli_cmd_broadcast_response (ret); |
1730 | free (rsp.dict.dict_val); |
1731 | free (rsp.op_errstr); |
1732 | return ret; |
1733 | } |
1734 | |
1735 | int |
1736 | gf_cli3_remove_brick_status_cbk (struct rpc_req *req, struct iovec *iov, |
1737 | int count, void *myframe) |
1738 | { |
1739 | gf_cli_rsp rsp = {0,}; |
1740 | char *status = "unknown"; |
1741 | int ret = -1; |
1742 | uint64_t files = 0; |
1743 | uint64_t size = 0; |
1744 | uint64_t lookup = 0; |
1745 | dict_t *dict = NULL((void*)0); |
1746 | char msg[1024] = {0,}; |
1747 | char key[256] = {0,}; |
1748 | int32_t i = 1; |
1749 | int32_t counter = 0; |
1750 | char *node_uuid = 0; |
1751 | gf_defrag_status_t status_rcd = GF_DEFRAG_STATUS_NOT_STARTED; |
1752 | uint64_t failures = 0; |
1753 | double elapsed = 0; |
1754 | char *size_str = NULL((void*)0); |
1755 | int32_t command = 0; |
1756 | gf1_op_commands cmd = GF_OP_CMD_NONE; |
1757 | cli_local_t *local = NULL((void*)0); |
1758 | call_frame_t *frame = NULL((void*)0); |
1759 | char *cmd_str = "unknown"; |
1760 | |
1761 | if (-1 == req->rpc_status) { |
1762 | goto out; |
1763 | } |
1764 | |
1765 | frame = myframe; |
1766 | |
1767 | ret = xdr_to_generic (*iov, &rsp, |
1768 | (xdrproc_t)xdr_gf_cli_rsp); |
1769 | if (ret < 0) { |
1770 | gf_log (frame->this->name, GF_LOG_ERROR,do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__ , 1771, GF_LOG_ERROR, "Failed to decode xdr response"); } while (0) |
1771 | "Failed to decode xdr response")do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__ , 1771, GF_LOG_ERROR, "Failed to decode xdr response"); } while (0); |
1772 | goto out; |
1773 | } |
1774 | |
1775 | if (frame) |
1776 | local = frame->local; |
1777 | ret = dict_get_int32 (local->dict, "command", &command); |
1778 | if (ret) |
1779 | goto out; |
1780 | cmd = command; |
1781 | |
1782 | switch (cmd) { |
1783 | case GF_OP_CMD_STOP: |
1784 | cmd_str = "stop"; |
1785 | break; |
1786 | case GF_OP_CMD_STATUS: |
1787 | cmd_str = "status"; |
1788 | break; |
1789 | default: |
1790 | break; |
1791 | } |
1792 | |
1793 | ret = rsp.op_ret; |
1794 | if (rsp.op_ret == -1) { |
1795 | if (strcmp (rsp.op_errstr, "")) |
1796 | snprintf (msg, sizeof (msg), "volume remove-brick %s: " |
1797 | "failed: %s", cmd_str, rsp.op_errstr); |
1798 | else |
1799 | snprintf (msg, sizeof (msg), "volume remove-brick %s: " |
1800 | "failed", cmd_str); |
1801 | |
1802 | if (global_state->mode & GLUSTER_MODE_XML(1 << 2)) |
1803 | goto xml_output; |
1804 | |
1805 | cli_err ("%s", msg)do { do { if (0) printf ("%s", msg); } while (0); _cli_err("%s" , msg); } while (0); |
1806 | goto out; |
1807 | } |
1808 | |
1809 | if (rsp.dict.dict_len) { |
1810 | /* Unserialize the dictionary */ |
1811 | dict = dict_new (); |
1812 | |
1813 | ret = dict_unserialize (rsp.dict.dict_val, |
1814 | rsp.dict.dict_len, |
1815 | &dict); |
1816 | if (ret < 0) { |
1817 | strncpy (msg, "failed to unserialize req-buffer to " |
1818 | "dictionary", sizeof (msg)); |
1819 | |
1820 | if (global_state->mode & GLUSTER_MODE_XML(1 << 2)) { |
1821 | rsp.op_ret = -1; |
1822 | goto xml_output; |
1823 | } |
1824 | |
1825 | gf_log ("cli", GF_LOG_ERROR, "%s", msg)do { do { if (0) printf ("%s", msg); } while (0); _gf_log ("cli" , "cli-rpc-ops.c", __FUNCTION__, 1825, GF_LOG_ERROR, "%s", msg ); } while (0); |
1826 | goto out; |
1827 | } |
1828 | } |
1829 | |
1830 | xml_output: |
1831 | if (global_state->mode & GLUSTER_MODE_XML(1 << 2)) { |
1832 | if (strcmp (rsp.op_errstr, "")) { |
1833 | ret = cli_xml_output_vol_remove_brick (_gf_true, dict, |
1834 | rsp.op_ret, |
1835 | rsp.op_errno, |
1836 | rsp.op_errstr); |
1837 | } else { |
1838 | ret = cli_xml_output_vol_remove_brick (_gf_true, dict, |
1839 | rsp.op_ret, |
1840 | rsp.op_errno, |
1841 | msg); |
1842 | } |
1843 | goto out; |
1844 | } |
1845 | |
1846 | ret = dict_get_int32 (dict, "count", &counter); |
1847 | if (ret) { |
1848 | gf_log (frame->this->name, GF_LOG_ERROR, "count not set")do { do { if (0) printf ("count not set"); } while (0); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__, 1848 , GF_LOG_ERROR, "count not set"); } while (0); |
1849 | goto out; |
1850 | } |
1851 | |
1852 | |
1853 | cli_out ("%40s %16s %13s %13s %13s %14s %s", "Node", "Rebalanced-files",do { do { if (0) printf ("%40s %16s %13s %13s %13s %14s %s", "Node" , "Rebalanced-files", "size", "scanned", "failures", "status" , "run-time in secs"); } while (0); _cli_out("%40s %16s %13s %13s %13s %14s %s" , "Node", "Rebalanced-files", "size", "scanned", "failures", "status" , "run-time in secs"); } while (0) |
1854 | "size", "scanned", "failures", "status", "run-time in secs")do { do { if (0) printf ("%40s %16s %13s %13s %13s %14s %s", "Node" , "Rebalanced-files", "size", "scanned", "failures", "status" , "run-time in secs"); } while (0); _cli_out("%40s %16s %13s %13s %13s %14s %s" , "Node", "Rebalanced-files", "size", "scanned", "failures", "status" , "run-time in secs"); } while (0); |
1855 | cli_out ("%40s %16s %13s %13s %13s %14s %16s", "---------",do { do { if (0) printf ("%40s %16s %13s %13s %13s %14s %16s" , "---------", "-----------", "-----------", "-----------", "-----------" , "------------", "--------------"); } while (0); _cli_out("%40s %16s %13s %13s %13s %14s %16s" , "---------", "-----------", "-----------", "-----------", "-----------" , "------------", "--------------"); } while (0) |
1856 | "-----------", "-----------", "-----------", "-----------",do { do { if (0) printf ("%40s %16s %13s %13s %13s %14s %16s" , "---------", "-----------", "-----------", "-----------", "-----------" , "------------", "--------------"); } while (0); _cli_out("%40s %16s %13s %13s %13s %14s %16s" , "---------", "-----------", "-----------", "-----------", "-----------" , "------------", "--------------"); } while (0) |
1857 | "------------", "--------------")do { do { if (0) printf ("%40s %16s %13s %13s %13s %14s %16s" , "---------", "-----------", "-----------", "-----------", "-----------" , "------------", "--------------"); } while (0); _cli_out("%40s %16s %13s %13s %13s %14s %16s" , "---------", "-----------", "-----------", "-----------", "-----------" , "------------", "--------------"); } while (0); |
1858 | |
1859 | do { |
1860 | snprintf (key, 256, "node-uuid-%d", i); |
1861 | ret = dict_get_str (dict, key, &node_uuid); |
1862 | if (ret) |
1863 | gf_log (frame->this->name, GF_LOG_TRACE,do { do { if (0) printf ("failed to get node-uuid"); } while ( 0); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__ , 1864, GF_LOG_TRACE, "failed to get node-uuid"); } while (0) |
1864 | "failed to get node-uuid")do { do { if (0) printf ("failed to get node-uuid"); } while ( 0); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__ , 1864, GF_LOG_TRACE, "failed to get node-uuid"); } while (0); |
1865 | |
1866 | memset (key, 0, 256); |
1867 | snprintf (key, 256, "files-%d", i); |
1868 | ret = dict_get_uint64 (dict, key, &files); |
1869 | if (ret) |
1870 | gf_log (frame->this->name, GF_LOG_TRACE,do { do { if (0) printf ("failed to get file count"); } while (0); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__ , 1871, GF_LOG_TRACE, "failed to get file count"); } while (0 ) |
1871 | "failed to get file count")do { do { if (0) printf ("failed to get file count"); } while (0); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__ , 1871, GF_LOG_TRACE, "failed to get file count"); } while (0 ); |
1872 | |
1873 | memset (key, 0, 256); |
1874 | snprintf (key, 256, "size-%d", i); |
1875 | ret = dict_get_uint64 (dict, key, &size); |
1876 | if (ret) |
1877 | gf_log (frame->this->name, GF_LOG_TRACE,do { do { if (0) printf ("failed to get size of xfer"); } while (0); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__ , 1878, GF_LOG_TRACE, "failed to get size of xfer"); } while ( 0) |
1878 | "failed to get size of xfer")do { do { if (0) printf ("failed to get size of xfer"); } while (0); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__ , 1878, GF_LOG_TRACE, "failed to get size of xfer"); } while ( 0); |
1879 | |
1880 | memset (key, 0, 256); |
1881 | snprintf (key, 256, "lookups-%d", i); |
1882 | ret = dict_get_uint64 (dict, key, &lookup); |
1883 | if (ret) |
1884 | gf_log (frame->this->name, GF_LOG_TRACE,do { do { if (0) printf ("failed to get lookedup file count") ; } while (0); _gf_log (frame->this->name, "cli-rpc-ops.c" , __FUNCTION__, 1885, GF_LOG_TRACE, "failed to get lookedup file count" ); } while (0) |
1885 | "failed to get lookedup file count")do { do { if (0) printf ("failed to get lookedup file count") ; } while (0); _gf_log (frame->this->name, "cli-rpc-ops.c" , __FUNCTION__, 1885, GF_LOG_TRACE, "failed to get lookedup file count" ); } while (0); |
1886 | |
1887 | memset (key, 0, 256); |
1888 | snprintf (key, 256, "status-%d", i); |
1889 | ret = dict_get_int32 (dict, key, (int32_t *)&status_rcd); |
1890 | if (ret) |
1891 | gf_log (frame->this->name, GF_LOG_TRACE,do { do { if (0) printf ("failed to get status"); } while (0) ; _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__ , 1892, GF_LOG_TRACE, "failed to get status"); } while (0) |
1892 | "failed to get status")do { do { if (0) printf ("failed to get status"); } while (0) ; _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__ , 1892, GF_LOG_TRACE, "failed to get status"); } while (0); |
1893 | |
1894 | snprintf (key, 256, "failures-%d", i); |
1895 | ret = dict_get_uint64 (dict, key, &failures); |
1896 | if (ret) |
1897 | gf_log (frame->this->name, GF_LOG_TRACE,do { do { if (0) printf ("Failed to get failure on files"); } while (0); _gf_log (frame->this->name, "cli-rpc-ops.c" , __FUNCTION__, 1898, GF_LOG_TRACE, "Failed to get failure on files" ); } while (0) |
1898 | "Failed to get failure on files")do { do { if (0) printf ("Failed to get failure on files"); } while (0); _gf_log (frame->this->name, "cli-rpc-ops.c" , __FUNCTION__, 1898, GF_LOG_TRACE, "Failed to get failure on files" ); } while (0); |
1899 | |
1900 | memset (key, 0, 256); |
1901 | snprintf (key, 256, "run-time-%d", i); |
1902 | ret = dict_get_double (dict, key, &elapsed); |
1903 | if (ret) |
1904 | gf_log (frame->this->name, GF_LOG_TRACE,do { do { if (0) printf ("Failed to get run-time"); } while ( 0); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__ , 1905, GF_LOG_TRACE, "Failed to get run-time"); } while (0) |
1905 | "Failed to get run-time")do { do { if (0) printf ("Failed to get run-time"); } while ( 0); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__ , 1905, GF_LOG_TRACE, "Failed to get run-time"); } while (0); |
1906 | |
1907 | switch (status_rcd) { |
1908 | case GF_DEFRAG_STATUS_NOT_STARTED: |
1909 | status = "not started"; |
1910 | break; |
1911 | case GF_DEFRAG_STATUS_STARTED: |
1912 | status = "in progress"; |
1913 | break; |
1914 | case GF_DEFRAG_STATUS_STOPPED: |
1915 | status = "stopped"; |
1916 | break; |
1917 | case GF_DEFRAG_STATUS_COMPLETE: |
1918 | status = "completed"; |
1919 | break; |
1920 | case GF_DEFRAG_STATUS_FAILED: |
1921 | status = "failed"; |
1922 | break; |
1923 | } |
1924 | |
1925 | size_str = gf_uint64_2human_readable(size); |
1926 | cli_out ("%40s %16"PRIu64 " %13s" " %13"PRIu64 " %13"PRIu64do { do { if (0) printf ("%40s %16""ll" "u" " %13s" " %13""ll" "u" " %13""ll" "u" " %14s %16.2f", node_uuid, files, size_str , lookup, failures, status, elapsed); } while (0); _cli_out("%40s %16" "ll" "u" " %13s" " %13""ll" "u" " %13""ll" "u" " %14s %16.2f" , node_uuid, files, size_str, lookup, failures, status, elapsed ); } while (0) |
1927 | " %14s %16.2f", node_uuid, files, size_str, lookup,do { do { if (0) printf ("%40s %16""ll" "u" " %13s" " %13""ll" "u" " %13""ll" "u" " %14s %16.2f", node_uuid, files, size_str , lookup, failures, status, elapsed); } while (0); _cli_out("%40s %16" "ll" "u" " %13s" " %13""ll" "u" " %13""ll" "u" " %14s %16.2f" , node_uuid, files, size_str, lookup, failures, status, elapsed ); } while (0) |
1928 | failures, status, elapsed)do { do { if (0) printf ("%40s %16""ll" "u" " %13s" " %13""ll" "u" " %13""ll" "u" " %14s %16.2f", node_uuid, files, size_str , lookup, failures, status, elapsed); } while (0); _cli_out("%40s %16" "ll" "u" " %13s" " %13""ll" "u" " %13""ll" "u" " %14s %16.2f" , node_uuid, files, size_str, lookup, failures, status, elapsed ); } while (0); |
1929 | GF_FREE(size_str)__gf_free (size_str); |
1930 | |
1931 | i++; |
1932 | } while (i <= counter); |
1933 | |
1934 | if ((cmd == GF_OP_CMD_STOP) && (rsp.op_ret == 0)) { |
1935 | cli_out ("'remove-brick' process may be in the middle of a "do { do { if (0) printf ("'remove-brick' process may be in the middle of a " "file migration.\nThe process will be fully stopped " "once the migration of the file is complete.\nPlease " "check remove-brick process for completion before " "doing any further brick related tasks on the " "volume."); } while (0); _cli_out("'remove-brick' process may be in the middle of a " "file migration.\nThe process will be fully stopped " "once the migration of the file is complete.\nPlease " "check remove-brick process for completion before " "doing any further brick related tasks on the " "volume."); } while (0) |
1936 | "file migration.\nThe process will be fully stopped "do { do { if (0) printf ("'remove-brick' process may be in the middle of a " "file migration.\nThe process will be fully stopped " "once the migration of the file is complete.\nPlease " "check remove-brick process for completion before " "doing any further brick related tasks on the " "volume."); } while (0); _cli_out("'remove-brick' process may be in the middle of a " "file migration.\nThe process will be fully stopped " "once the migration of the file is complete.\nPlease " "check remove-brick process for completion before " "doing any further brick related tasks on the " "volume."); } while (0) |
1937 | "once the migration of the file is complete.\nPlease "do { do { if (0) printf ("'remove-brick' process may be in the middle of a " "file migration.\nThe process will be fully stopped " "once the migration of the file is complete.\nPlease " "check remove-brick process for completion before " "doing any further brick related tasks on the " "volume."); } while (0); _cli_out("'remove-brick' process may be in the middle of a " "file migration.\nThe process will be fully stopped " "once the migration of the file is complete.\nPlease " "check remove-brick process for completion before " "doing any further brick related tasks on the " "volume."); } while (0) |
1938 | "check remove-brick process for completion before "do { do { if (0) printf ("'remove-brick' process may be in the middle of a " "file migration.\nThe process will be fully stopped " "once the migration of the file is complete.\nPlease " "check remove-brick process for completion before " "doing any further brick related tasks on the " "volume."); } while (0); _cli_out("'remove-brick' process may be in the middle of a " "file migration.\nThe process will be fully stopped " "once the migration of the file is complete.\nPlease " "check remove-brick process for completion before " "doing any further brick related tasks on the " "volume."); } while (0) |
1939 | "doing any further brick related tasks on the "do { do { if (0) printf ("'remove-brick' process may be in the middle of a " "file migration.\nThe process will be fully stopped " "once the migration of the file is complete.\nPlease " "check remove-brick process for completion before " "doing any further brick related tasks on the " "volume."); } while (0); _cli_out("'remove-brick' process may be in the middle of a " "file migration.\nThe process will be fully stopped " "once the migration of the file is complete.\nPlease " "check remove-brick process for completion before " "doing any further brick related tasks on the " "volume."); } while (0) |
1940 | "volume.")do { do { if (0) printf ("'remove-brick' process may be in the middle of a " "file migration.\nThe process will be fully stopped " "once the migration of the file is complete.\nPlease " "check remove-brick process for completion before " "doing any further brick related tasks on the " "volume."); } while (0); _cli_out("'remove-brick' process may be in the middle of a " "file migration.\nThe process will be fully stopped " "once the migration of the file is complete.\nPlease " "check remove-brick process for completion before " "doing any further brick related tasks on the " "volume."); } while (0); |
1941 | } |
1942 | |
1943 | out: |
1944 | free (rsp.dict.dict_val); //malloced by xdr |
1945 | if (dict) |
1946 | dict_unref (dict); |
1947 | cli_cmd_broadcast_response (ret); |
1948 | return ret; |
1949 | } |
1950 | |
1951 | |
1952 | int |
1953 | gf_cli_remove_brick_cbk (struct rpc_req *req, struct iovec *iov, |
1954 | int count, void *myframe) |
1955 | { |
1956 | gf_cli_rsp rsp = {0,}; |
1957 | int ret = -1; |
1958 | char msg[1024] = {0,}; |
1959 | gf1_op_commands cmd = GF_OP_CMD_NONE; |
1960 | char *cmd_str = "unknown"; |
1961 | cli_local_t *local = NULL((void*)0); |
1962 | call_frame_t *frame = NULL((void*)0); |
1963 | char *task_id_str = NULL((void*)0); |
1964 | dict_t *rsp_dict = NULL((void*)0); |
1965 | |
1966 | if (-1 == req->rpc_status) { |
1967 | goto out; |
1968 | } |
1969 | |
1970 | frame = myframe; |
1971 | local = frame->local; |
1972 | |
1973 | ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_cli_rsp); |
1974 | if (ret < 0) { |
1975 | gf_log (frame->this->name, GF_LOG_ERROR,do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__ , 1976, GF_LOG_ERROR, "Failed to decode xdr response"); } while (0) |
1976 | "Failed to decode xdr response")do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__ , 1976, GF_LOG_ERROR, "Failed to decode xdr response"); } while (0); |
1977 | goto out; |
1978 | } |
1979 | |
1980 | ret = dict_get_int32 (local->dict, "command", (int32_t *)&cmd); |
1981 | if (ret) { |
1982 | gf_log ("", GF_LOG_ERROR, "failed to get command")do { do { if (0) printf ("failed to get command"); } while (0 ); _gf_log ("", "cli-rpc-ops.c", __FUNCTION__, 1982, GF_LOG_ERROR , "failed to get command"); } while (0); |
1983 | goto out; |
1984 | } |
1985 | |
1986 | if (rsp.dict.dict_len) { |
1987 | rsp_dict = dict_new (); |
1988 | if (!rsp_dict) { |
1989 | ret = -1; |
1990 | goto out; |
1991 | } |
1992 | |
1993 | ret = dict_unserialize (rsp.dict.dict_val, rsp.dict.dict_len, |
1994 | &rsp_dict); |
1995 | if (ret) { |
1996 | gf_log ("cli", GF_LOG_ERROR,do { do { if (0) printf ("Failed to unserialize rsp_dict"); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 1997 , GF_LOG_ERROR, "Failed to unserialize rsp_dict"); } while (0 ) |
1997 | "Failed to unserialize rsp_dict")do { do { if (0) printf ("Failed to unserialize rsp_dict"); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 1997 , GF_LOG_ERROR, "Failed to unserialize rsp_dict"); } while (0 ); |
1998 | goto out; |
1999 | } |
2000 | } |
2001 | |
2002 | switch (cmd) { |
2003 | case GF_OP_CMD_START: |
2004 | cmd_str = "start"; |
2005 | |
2006 | ret = dict_get_str (rsp_dict, GF_REMOVE_BRICK_TID_KEY"remove-brick-id", &task_id_str); |
2007 | if (ret) { |
2008 | gf_log ("cli", GF_LOG_ERROR,do { do { if (0) printf ("remove-brick-id is not present in dict" ); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__ , 2009, GF_LOG_ERROR, "remove-brick-id is not present in dict" ); } while (0) |
2009 | "remove-brick-id is not present in dict")do { do { if (0) printf ("remove-brick-id is not present in dict" ); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__ , 2009, GF_LOG_ERROR, "remove-brick-id is not present in dict" ); } while (0); |
2010 | goto out; |
2011 | } |
2012 | break; |
2013 | case GF_OP_CMD_COMMIT: |
2014 | cmd_str = "commit"; |
2015 | break; |
2016 | case GF_OP_CMD_COMMIT_FORCE: |
2017 | cmd_str = "commit force"; |
2018 | break; |
2019 | default: |
2020 | cmd_str = "unknown"; |
2021 | break; |
2022 | } |
2023 | |
2024 | gf_log ("cli", GF_LOG_INFO, "Received resp to remove brick")do { do { if (0) printf ("Received resp to remove brick"); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 2024, GF_LOG_INFO , "Received resp to remove brick"); } while (0); |
2025 | |
2026 | if (rsp.op_ret && strcmp (rsp.op_errstr, "")) |
2027 | snprintf (msg, sizeof (msg), "%s", rsp.op_errstr); |
2028 | else |
2029 | snprintf (msg, sizeof (msg), "Remove Brick %s %s", cmd_str, |
2030 | (rsp.op_ret) ? "unsuccessful": "successful"); |
2031 | |
2032 | if (global_state->mode & GLUSTER_MODE_XML(1 << 2)) { |
2033 | ret = cli_xml_output_vol_remove_brick (_gf_false, rsp_dict, |
2034 | rsp.op_ret, rsp.op_errno, |
2035 | rsp.op_errstr); |
2036 | if (ret) |
2037 | gf_log ("cli", GF_LOG_ERROR,do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 2038, GF_LOG_ERROR , "Error outputting to xml"); } while (0) |
2038 | "Error outputting to xml")do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 2038, GF_LOG_ERROR , "Error outputting to xml"); } while (0); |
2039 | goto out; |
2040 | } |
2041 | |
2042 | if (rsp.op_ret) { |
2043 | cli_err ("volume remove-brick %s: failed: %s", cmd_str,do { do { if (0) printf ("volume remove-brick %s: failed: %s" , cmd_str, rsp.op_errstr); } while (0); _cli_err("volume remove-brick %s: failed: %s" , cmd_str, rsp.op_errstr); } while (0) |
2044 | rsp.op_errstr)do { do { if (0) printf ("volume remove-brick %s: failed: %s" , cmd_str, rsp.op_errstr); } while (0); _cli_err("volume remove-brick %s: failed: %s" , cmd_str, rsp.op_errstr); } while (0); |
2045 | } else { |
2046 | cli_out ("volume remove-brick %s: success", cmd_str)do { do { if (0) printf ("volume remove-brick %s: success", cmd_str ); } while (0); _cli_out("volume remove-brick %s: success", cmd_str ); } while (0); |
2047 | if (GF_OP_CMD_START == cmd) |
2048 | cli_out ("ID: %s", task_id_str)do { do { if (0) printf ("ID: %s", task_id_str); } while (0); _cli_out("ID: %s", task_id_str); } while (0); |
2049 | } |
2050 | |
2051 | ret = rsp.op_ret; |
2052 | |
2053 | out: |
2054 | cli_cmd_broadcast_response (ret); |
2055 | free (rsp.dict.dict_val); |
2056 | free (rsp.op_errstr); |
2057 | |
2058 | return ret; |
2059 | } |
2060 | |
2061 | |
2062 | |
2063 | int |
2064 | gf_cli_replace_brick_cbk (struct rpc_req *req, struct iovec *iov, |
2065 | int count, void *myframe) |
2066 | { |
2067 | gf_cli_rsp rsp = {0,}; |
2068 | int ret = -1; |
2069 | cli_local_t *local = NULL((void*)0); |
2070 | call_frame_t *frame = NULL((void*)0); |
2071 | dict_t *dict = NULL((void*)0); |
2072 | char *src_brick = NULL((void*)0); |
2073 | char *dst_brick = NULL((void*)0); |
2074 | char *status_reply = NULL((void*)0); |
2075 | gf1_cli_replace_op replace_op = 0; |
2076 | char *rb_operation_str = NULL((void*)0); |
2077 | dict_t *rsp_dict = NULL((void*)0); |
2078 | char msg[1024] = {0,}; |
2079 | char *task_id_str = NULL((void*)0); |
2080 | |
2081 | if (-1 == req->rpc_status) { |
2082 | goto out; |
2083 | } |
2084 | |
2085 | frame = (call_frame_t *) myframe; |
2086 | |
2087 | ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_cli_rsp); |
2088 | if (ret < 0) { |
2089 | gf_log (frame->this->name, GF_LOG_ERROR,do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__ , 2090, GF_LOG_ERROR, "Failed to decode xdr response"); } while (0) |
2090 | "Failed to decode xdr response")do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__ , 2090, GF_LOG_ERROR, "Failed to decode xdr response"); } while (0); |
2091 | goto out; |
2092 | } |
2093 | |
2094 | local = frame->local; |
2095 | GF_ASSERT (local)do { if (!(local)) { do { do { if (0) printf ("Assertion failed: " "local"); } while (0); _gf_log_callingfn ("", "cli-rpc-ops.c" , __FUNCTION__, 2095, GF_LOG_ERROR, "Assertion failed: " "local" ); } while (0); } } while (0); |
2096 | dict = local->dict; |
2097 | |
2098 | ret = dict_get_int32 (dict, "operation", (int32_t *)&replace_op); |
2099 | if (ret) { |
2100 | gf_log ("", GF_LOG_DEBUG,do { do { if (0) printf ("dict_get on operation failed"); } while (0); _gf_log ("", "cli-rpc-ops.c", __FUNCTION__, 2101, GF_LOG_DEBUG , "dict_get on operation failed"); } while (0) |
2101 | "dict_get on operation failed")do { do { if (0) printf ("dict_get on operation failed"); } while (0); _gf_log ("", "cli-rpc-ops.c", __FUNCTION__, 2101, GF_LOG_DEBUG , "dict_get on operation failed"); } while (0); |
2102 | goto out; |
2103 | } |
2104 | |
2105 | if (rsp.dict.dict_len) { |
2106 | /* Unserialize the dictionary */ |
2107 | rsp_dict = dict_new (); |
2108 | |
2109 | ret = dict_unserialize (rsp.dict.dict_val, |
2110 | rsp.dict.dict_len, |
2111 | &rsp_dict); |
2112 | if (ret < 0) { |
2113 | gf_log ("glusterd", GF_LOG_ERROR,do { do { if (0) printf ("failed to " "unserialize rsp buffer to dictionary" ); } while (0); _gf_log ("glusterd", "cli-rpc-ops.c", __FUNCTION__ , 2115, GF_LOG_ERROR, "failed to " "unserialize rsp buffer to dictionary" ); } while (0) |
2114 | "failed to "do { do { if (0) printf ("failed to " "unserialize rsp buffer to dictionary" ); } while (0); _gf_log ("glusterd", "cli-rpc-ops.c", __FUNCTION__ , 2115, GF_LOG_ERROR, "failed to " "unserialize rsp buffer to dictionary" ); } while (0) |
2115 | "unserialize rsp buffer to dictionary")do { do { if (0) printf ("failed to " "unserialize rsp buffer to dictionary" ); } while (0); _gf_log ("glusterd", "cli-rpc-ops.c", __FUNCTION__ , 2115, GF_LOG_ERROR, "failed to " "unserialize rsp buffer to dictionary" ); } while (0); |
2116 | goto out; |
2117 | } |
2118 | } |
2119 | |
2120 | switch (replace_op) { |
2121 | case GF_REPLACE_OP_START: |
2122 | if (rsp.op_ret) { |
2123 | rb_operation_str = gf_strdup ("replace-brick failed to" |
2124 | " start"); |
2125 | } else { |
2126 | ret = dict_get_str (rsp_dict, GF_REPLACE_BRICK_TID_KEY"replace-brick-id", |
2127 | &task_id_str); |
2128 | if (ret) { |
2129 | gf_log ("cli", GF_LOG_ERROR, "Failed to get "do { do { if (0) printf ("Failed to get " "\"replace-brick-id\" from dict" ); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__ , 2130, GF_LOG_ERROR, "Failed to get " "\"replace-brick-id\" from dict" ); } while (0) |
2130 | "\"replace-brick-id\" from dict")do { do { if (0) printf ("Failed to get " "\"replace-brick-id\" from dict" ); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__ , 2130, GF_LOG_ERROR, "Failed to get " "\"replace-brick-id\" from dict" ); } while (0); |
2131 | goto out; |
2132 | } |
2133 | ret = gf_asprintf (&rb_operation_str, |
2134 | "replace-brick started successfully" |
2135 | "\nID: %s", task_id_str); |
2136 | if (ret < 0) |
2137 | goto out; |
2138 | } |
2139 | break; |
2140 | |
2141 | case GF_REPLACE_OP_STATUS: |
2142 | |
2143 | if (rsp.op_ret || ret) { |
2144 | rb_operation_str = gf_strdup ("replace-brick status " |
2145 | "unknown"); |
2146 | } else { |
2147 | ret = dict_get_str (rsp_dict, "status-reply", |
2148 | &status_reply); |
2149 | if (ret) { |
2150 | gf_log (frame->this->name, GF_LOG_ERROR, "failed to"do { do { if (0) printf ("failed to" "get status"); } while ( 0); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__ , 2151, GF_LOG_ERROR, "failed to" "get status"); } while (0) |
2151 | "get status")do { do { if (0) printf ("failed to" "get status"); } while ( 0); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__ , 2151, GF_LOG_ERROR, "failed to" "get status"); } while (0); |
2152 | goto out; |
2153 | } |
2154 | |
2155 | rb_operation_str = gf_strdup (status_reply); |
2156 | } |
2157 | |
2158 | break; |
2159 | |
2160 | case GF_REPLACE_OP_PAUSE: |
2161 | if (rsp.op_ret) |
2162 | rb_operation_str = gf_strdup ("replace-brick pause " |
2163 | "failed"); |
2164 | else |
2165 | rb_operation_str = gf_strdup ("replace-brick paused " |
2166 | "successfully"); |
2167 | break; |
2168 | |
2169 | case GF_REPLACE_OP_ABORT: |
2170 | if (rsp.op_ret) |
2171 | rb_operation_str = gf_strdup ("replace-brick abort " |
2172 | "failed"); |
2173 | else |
2174 | rb_operation_str = gf_strdup ("replace-brick aborted " |
2175 | "successfully"); |
2176 | break; |
2177 | |
2178 | case GF_REPLACE_OP_COMMIT: |
2179 | case GF_REPLACE_OP_COMMIT_FORCE: |
2180 | ret = dict_get_str (dict, "src-brick", &src_brick); |
2181 | if (ret) { |
2182 | gf_log ("", GF_LOG_DEBUG,do { do { if (0) printf ("dict_get on src-brick failed"); } while (0); _gf_log ("", "cli-rpc-ops.c", __FUNCTION__, 2183, GF_LOG_DEBUG , "dict_get on src-brick failed"); } while (0) |
2183 | "dict_get on src-brick failed")do { do { if (0) printf ("dict_get on src-brick failed"); } while (0); _gf_log ("", "cli-rpc-ops.c", __FUNCTION__, 2183, GF_LOG_DEBUG , "dict_get on src-brick failed"); } while (0); |
2184 | goto out; |
2185 | } |
2186 | |
2187 | ret = dict_get_str (dict, "dst-brick", &dst_brick); |
2188 | if (ret) { |
2189 | gf_log ("", GF_LOG_DEBUG,do { do { if (0) printf ("dict_get on dst-brick failed"); } while (0); _gf_log ("", "cli-rpc-ops.c", __FUNCTION__, 2190, GF_LOG_DEBUG , "dict_get on dst-brick failed"); } while (0) |
2190 | "dict_get on dst-brick failed")do { do { if (0) printf ("dict_get on dst-brick failed"); } while (0); _gf_log ("", "cli-rpc-ops.c", __FUNCTION__, 2190, GF_LOG_DEBUG , "dict_get on dst-brick failed"); } while (0); |
2191 | goto out; |
2192 | } |
2193 | |
2194 | |
2195 | if (rsp.op_ret || ret) |
2196 | rb_operation_str = gf_strdup ("replace-brick commit " |
2197 | "failed"); |
2198 | else |
2199 | rb_operation_str = gf_strdup ("replace-brick commit " |
2200 | "successful"); |
2201 | |
2202 | break; |
2203 | |
2204 | default: |
2205 | gf_log ("", GF_LOG_DEBUG,do { do { if (0) printf ("Unknown operation"); } while (0); _gf_log ("", "cli-rpc-ops.c", __FUNCTION__, 2206, GF_LOG_DEBUG, "Unknown operation" ); } while (0) |
2206 | "Unknown operation")do { do { if (0) printf ("Unknown operation"); } while (0); _gf_log ("", "cli-rpc-ops.c", __FUNCTION__, 2206, GF_LOG_DEBUG, "Unknown operation" ); } while (0); |
2207 | break; |
2208 | } |
2209 | |
2210 | if (rsp.op_ret && (strcmp (rsp.op_errstr, ""))) { |
2211 | rb_operation_str = gf_strdup (rsp.op_errstr); |
2212 | } |
2213 | |
2214 | gf_log ("cli", GF_LOG_INFO, "Received resp to replace brick")do { do { if (0) printf ("Received resp to replace brick"); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 2214 , GF_LOG_INFO, "Received resp to replace brick"); } while (0); |
2215 | snprintf (msg, sizeof (msg), "%s", |
2216 | rb_operation_str ? rb_operation_str : "Unknown operation"); |
2217 | |
2218 | if (global_state->mode & GLUSTER_MODE_XML(1 << 2)) { |
2219 | ret = cli_xml_output_vol_replace_brick (replace_op, rsp_dict, |
2220 | rsp.op_ret, |
2221 | rsp.op_errno, msg); |
2222 | if (ret) |
2223 | gf_log ("cli", GF_LOG_ERROR,do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 2224, GF_LOG_ERROR , "Error outputting to xml"); } while (0) |
2224 | "Error outputting to xml")do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 2224, GF_LOG_ERROR , "Error outputting to xml"); } while (0); |
2225 | goto out; |
2226 | } |
2227 | |
2228 | if (rsp.op_ret) |
2229 | cli_err ("volume replace-brick: failed: %s", msg)do { do { if (0) printf ("volume replace-brick: failed: %s", msg ); } while (0); _cli_err("volume replace-brick: failed: %s", msg ); } while (0); |
2230 | else |
2231 | cli_out ("volume replace-brick: success: %s", msg)do { do { if (0) printf ("volume replace-brick: success: %s", msg); } while (0); _cli_out("volume replace-brick: success: %s" , msg); } while (0); |
2232 | ret = rsp.op_ret; |
2233 | |
2234 | out: |
2235 | if (frame) |
2236 | frame->local = NULL((void*)0); |
2237 | |
2238 | if (local) { |
2239 | dict_unref (local->dict); |
2240 | cli_local_wipe (local); |
2241 | } |
2242 | |
2243 | if (rb_operation_str) |
2244 | GF_FREE (rb_operation_str)__gf_free (rb_operation_str); |
2245 | |
2246 | cli_cmd_broadcast_response (ret); |
2247 | free (rsp.dict.dict_val); |
2248 | if (rsp_dict) |
2249 | dict_unref (rsp_dict); |
2250 | |
2251 | return ret; |
2252 | } |
2253 | |
2254 | |
2255 | static int |
2256 | gf_cli_log_rotate_cbk (struct rpc_req *req, struct iovec *iov, |
2257 | int count, void *myframe) |
2258 | { |
2259 | gf_cli_rsp rsp = {0,}; |
2260 | int ret = -1; |
2261 | char msg[1024] = {0,}; |
2262 | |
2263 | if (-1 == req->rpc_status) { |
2264 | goto out; |
2265 | } |
2266 | |
2267 | ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_cli_rsp); |
2268 | if (ret < 0) { |
2269 | gf_log (((call_frame_t *) myframe)->this->name, GF_LOG_ERROR,do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (((call_frame_t *) myframe)->this->name, "cli-rpc-ops.c" , __FUNCTION__, 2270, GF_LOG_ERROR, "Failed to decode xdr response" ); } while (0) |
2270 | "Failed to decode xdr response")do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (((call_frame_t *) myframe)->this->name, "cli-rpc-ops.c" , __FUNCTION__, 2270, GF_LOG_ERROR, "Failed to decode xdr response" ); } while (0); |
2271 | goto out; |
2272 | } |
2273 | |
2274 | gf_log ("cli", GF_LOG_DEBUG, "Received resp to log rotate")do { do { if (0) printf ("Received resp to log rotate"); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 2274, GF_LOG_DEBUG , "Received resp to log rotate"); } while (0); |
2275 | |
2276 | if (rsp.op_ret && strcmp (rsp.op_errstr, "")) |
2277 | snprintf (msg, sizeof (msg), "%s", rsp.op_errstr); |
2278 | else |
2279 | snprintf (msg, sizeof (msg), "log rotate %s", |
2280 | (rsp.op_ret) ? "unsuccessful": "successful"); |
2281 | |
2282 | if (global_state->mode & GLUSTER_MODE_XML(1 << 2)) { |
2283 | ret = cli_xml_output_str ("volLogRotate", msg, rsp.op_ret, |
2284 | rsp.op_errno, rsp.op_errstr); |
2285 | if (ret) |
2286 | gf_log ("cli", GF_LOG_ERROR,do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 2287, GF_LOG_ERROR , "Error outputting to xml"); } while (0) |
2287 | "Error outputting to xml")do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 2287, GF_LOG_ERROR , "Error outputting to xml"); } while (0); |
2288 | goto out; |
2289 | } |
2290 | |
2291 | if (rsp.op_ret) |
2292 | cli_err ("volume log-rotate: failed: %s", msg)do { do { if (0) printf ("volume log-rotate: failed: %s", msg ); } while (0); _cli_err("volume log-rotate: failed: %s", msg ); } while (0); |
2293 | else |
2294 | cli_out ("volume log-rotate: success")do { do { if (0) printf ("volume log-rotate: success"); } while (0); _cli_out("volume log-rotate: success"); } while (0); |
2295 | ret = rsp.op_ret; |
2296 | |
2297 | out: |
2298 | cli_cmd_broadcast_response (ret); |
2299 | free (rsp.dict.dict_val); |
2300 | |
2301 | return ret; |
2302 | } |
2303 | |
2304 | static int |
2305 | gf_cli_sync_volume_cbk (struct rpc_req *req, struct iovec *iov, |
2306 | int count, void *myframe) |
2307 | { |
2308 | gf_cli_rsp rsp = {0,}; |
2309 | int ret = -1; |
2310 | char msg[1024] = {0,}; |
2311 | |
2312 | if (-1 == req->rpc_status) { |
2313 | goto out; |
2314 | } |
2315 | |
2316 | ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_cli_rsp); |
2317 | if (ret < 0) { |
2318 | gf_log (((call_frame_t *) myframe)->this->name, GF_LOG_ERROR,do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (((call_frame_t *) myframe)->this->name, "cli-rpc-ops.c" , __FUNCTION__, 2319, GF_LOG_ERROR, "Failed to decode xdr response" ); } while (0) |
2319 | "Failed to decode xdr response")do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (((call_frame_t *) myframe)->this->name, "cli-rpc-ops.c" , __FUNCTION__, 2319, GF_LOG_ERROR, "Failed to decode xdr response" ); } while (0); |
2320 | goto out; |
2321 | } |
2322 | |
2323 | gf_log ("cli", GF_LOG_DEBUG, "Received resp to sync")do { do { if (0) printf ("Received resp to sync"); } while (0 ); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 2323, GF_LOG_DEBUG , "Received resp to sync"); } while (0); |
2324 | |
2325 | if (rsp.op_ret && strcmp (rsp.op_errstr, "")) |
2326 | snprintf (msg, sizeof (msg), "volume sync: failed: %s", |
2327 | rsp.op_errstr); |
2328 | else |
2329 | snprintf (msg, sizeof (msg), "volume sync: %s", |
2330 | (rsp.op_ret) ? "failed": "success"); |
2331 | |
2332 | if (global_state->mode & GLUSTER_MODE_XML(1 << 2)) { |
2333 | ret = cli_xml_output_str ("volSync", msg, rsp.op_ret, |
2334 | rsp.op_errno, rsp.op_errstr); |
2335 | if (ret) |
2336 | gf_log ("cli", GF_LOG_ERROR,do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 2337, GF_LOG_ERROR , "Error outputting to xml"); } while (0) |
2337 | "Error outputting to xml")do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 2337, GF_LOG_ERROR , "Error outputting to xml"); } while (0); |
2338 | goto out; |
2339 | } |
2340 | |
2341 | if (rsp.op_ret) |
2342 | cli_err ("%s", msg)do { do { if (0) printf ("%s", msg); } while (0); _cli_err("%s" , msg); } while (0); |
2343 | else |
2344 | cli_out ("%s", msg)do { do { if (0) printf ("%s", msg); } while (0); _cli_out("%s" , msg); } while (0); |
2345 | ret = rsp.op_ret; |
2346 | |
2347 | out: |
2348 | cli_cmd_broadcast_response (ret); |
2349 | return ret; |
2350 | } |
2351 | |
2352 | int32_t |
2353 | gf_cli_print_limit_list (char *volname, char *limit_list, |
2354 | char *op_errstr) |
2355 | { |
2356 | int64_t size = 0; |
2357 | int64_t limit_value = 0; |
2358 | int32_t i, j; |
2359 | int32_t len = 0, ret = -1; |
2360 | char *size_str = NULL((void*)0); |
2361 | char path [PATH_MAX4096] = {0, }; |
2362 | char ret_str [1024] = {0, }; |
2363 | char value [1024] = {0, }; |
2364 | char mountdir [] = "/tmp/mntXXXXXX"; |
2365 | char abspath [PATH_MAX4096] = {0, }; |
2366 | char *colon_ptr = NULL((void*)0); |
2367 | runner_t runner = {0,}; |
2368 | |
2369 | GF_VALIDATE_OR_GOTO ("cli", volname, out)do { if (!volname) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "volname"); } while (0); _gf_log_callingfn ("cli", "cli-rpc-ops.c", __FUNCTION__, 2369, GF_LOG_ERROR, "invalid argument: " "volname"); } while (0); goto out; } } while (0); |
2370 | GF_VALIDATE_OR_GOTO ("cli", limit_list, out)do { if (!limit_list) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "limit_list"); } while ( 0); _gf_log_callingfn ("cli", "cli-rpc-ops.c", __FUNCTION__, 2370 , GF_LOG_ERROR, "invalid argument: " "limit_list"); } while ( 0); goto out; } } while (0); |
2371 | |
2372 | if (!connected) |
2373 | goto out; |
2374 | |
2375 | len = strlen (limit_list); |
2376 | if (len == 0) { |
2377 | cli_err ("%s", op_errstr?op_errstr:"quota limit not set ")do { do { if (0) printf ("%s", op_errstr?op_errstr:"quota limit not set " ); } while (0); _cli_err("%s", op_errstr?op_errstr:"quota limit not set " ); } while (0); |
2378 | goto out; |
2379 | } |
2380 | |
2381 | if (mkdtemp (mountdir) == NULL((void*)0)) { |
2382 | gf_log ("cli", GF_LOG_WARNING, "failed to create a temporary "do { do { if (0) printf ("failed to create a temporary " "mount directory" ); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__ , 2383, GF_LOG_WARNING, "failed to create a temporary " "mount directory" ); } while (0) |
2383 | "mount directory")do { do { if (0) printf ("failed to create a temporary " "mount directory" ); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__ , 2383, GF_LOG_WARNING, "failed to create a temporary " "mount directory" ); } while (0); |
2384 | ret = -1; |
2385 | goto out; |
2386 | } |
2387 | |
2388 | /* Mount a temporary client to fetch the disk usage |
2389 | * of the directory on which the limit is set. |
2390 | */ |
2391 | ret = runcmd (SBIN_DIR"/usr/local/sbin""/glusterfs", "-s", |
2392 | "localhost", "--volfile-id", volname, "-l", |
2393 | DEFAULT_LOG_FILE_DIRECTORY"/usr/local/var" "/log/glusterfs""/quota-list.log", |
2394 | mountdir, NULL((void*)0)); |
2395 | if (ret) { |
2396 | gf_log ("cli", GF_LOG_WARNING, "failed to mount glusterfs client")do { do { if (0) printf ("failed to mount glusterfs client"); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 2396 , GF_LOG_WARNING, "failed to mount glusterfs client"); } while (0); |
2397 | ret = -1; |
2398 | goto rm_dir; |
2399 | } |
2400 | |
2401 | len = strlen (limit_list); |
2402 | if (len == 0) { |
2403 | cli_err ("quota limit not set ")do { do { if (0) printf ("quota limit not set "); } while (0) ; _cli_err("quota limit not set "); } while (0); |
2404 | goto unmount; |
2405 | } |
2406 | |
2407 | i = 0; |
2408 | |
2409 | cli_out ("\tpath\t\t limit_set\t size")do { do { if (0) printf ("\tpath\t\t limit_set\t size"); } while (0); _cli_out("\tpath\t\t limit_set\t size"); } while (0); |
2410 | cli_out ("-----------------------------------------------------------"do { do { if (0) printf ("-----------------------------------------------------------" "-----------------------"); } while (0); _cli_out("-----------------------------------------------------------" "-----------------------"); } while (0) |
2411 | "-----------------------")do { do { if (0) printf ("-----------------------------------------------------------" "-----------------------"); } while (0); _cli_out("-----------------------------------------------------------" "-----------------------"); } while (0); |
2412 | while (i < len) { |
2413 | j = 0; |
2414 | |
2415 | while (limit_list [i] != ',' && limit_list [i] != '\0') { |
2416 | path [j++] = limit_list[i++]; |
2417 | } |
2418 | path [j] = '\0'; |
2419 | //here path[] contains both path and limit value |
2420 | |
2421 | colon_ptr = strrchr (path, ':'); |
2422 | *colon_ptr = '\0'; |
2423 | strcpy (value, ++colon_ptr); |
2424 | |
2425 | snprintf (abspath, sizeof (abspath), "%s/%s", mountdir, path); |
2426 | |
2427 | ret = sys_lgetxattr (abspath, "trusted.limit.list", (void *) ret_str, 4096); |
2428 | if (ret < 0) { |
2429 | cli_out ("%-20s %10s", path, value)do { do { if (0) printf ("%-20s %10s", path, value); } while ( 0); _cli_out("%-20s %10s", path, value); } while (0); |
2430 | } else { |
2431 | sscanf (ret_str, "%"PRId64"ll" "d"",%"PRId64"ll" "d", &size, |
2432 | &limit_value); |
2433 | size_str = gf_uint64_2human_readable ((uint64_t) size); |
2434 | if (size_str == NULL((void*)0)) { |
2435 | cli_out ("%-20s %10s %20"PRId64, path,do { do { if (0) printf ("%-20s %10s %20""ll" "d", path, value , size); } while (0); _cli_out("%-20s %10s %20""ll" "d", path , value, size); } while (0) |
2436 | value, size)do { do { if (0) printf ("%-20s %10s %20""ll" "d", path, value , size); } while (0); _cli_out("%-20s %10s %20""ll" "d", path , value, size); } while (0); |
2437 | } else { |
2438 | cli_out ("%-20s %10s %20s", path,do { do { if (0) printf ("%-20s %10s %20s", path, value, size_str ); } while (0); _cli_out("%-20s %10s %20s", path, value, size_str ); } while (0) |
2439 | value, size_str)do { do { if (0) printf ("%-20s %10s %20s", path, value, size_str ); } while (0); _cli_out("%-20s %10s %20s", path, value, size_str ); } while (0); |
2440 | GF_FREE (size_str)__gf_free (size_str); |
2441 | } |
2442 | } |
2443 | i++; |
2444 | } |
2445 | |
2446 | unmount: |
2447 | |
2448 | runinit (&runner); |
2449 | runner_add_args (&runner, "umount", |
2450 | #if GF_LINUX_HOST_OS1 |
2451 | "-l", |
2452 | #endif |
2453 | mountdir, NULL((void*)0)); |
2454 | ret = runner_run_reuse (&runner); |
2455 | if (ret) |
2456 | runner_log (&runner, "cli", GF_LOG_WARNING, "error executing"); |
2457 | runner_end (&runner); |
2458 | |
2459 | rm_dir: |
2460 | rmdir (mountdir); |
2461 | out: |
2462 | return ret; |
2463 | } |
2464 | |
2465 | int |
2466 | gf_cli_quota_cbk (struct rpc_req *req, struct iovec *iov, |
2467 | int count, void *myframe) |
2468 | { |
2469 | gf_cli_rsp rsp = {0,}; |
2470 | int ret = -1; |
2471 | dict_t *dict = NULL((void*)0); |
2472 | char *volname = NULL((void*)0); |
2473 | char *limit_list = NULL((void*)0); |
2474 | int32_t type = 0; |
2475 | char msg[1024] = {0,}; |
2476 | call_frame_t *frame = NULL((void*)0); |
2477 | |
2478 | if (-1 == req->rpc_status) { |
2479 | goto out; |
2480 | } |
2481 | |
2482 | frame = myframe; |
2483 | |
2484 | ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_cli_rsp); |
2485 | if (ret < 0) { |
2486 | gf_log (frame->this->name, GF_LOG_ERROR,do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__ , 2487, GF_LOG_ERROR, "Failed to decode xdr response"); } while (0) |
2487 | "Failed to decode xdr response")do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__ , 2487, GF_LOG_ERROR, "Failed to decode xdr response"); } while (0); |
2488 | goto out; |
2489 | } |
2490 | |
2491 | if (rsp.op_ret && |
2492 | strcmp (rsp.op_errstr, "") == 0) { |
2493 | snprintf (msg, sizeof (msg), "command unsuccessful %s", |
2494 | rsp.op_errstr); |
2495 | |
2496 | if (global_state->mode & GLUSTER_MODE_XML(1 << 2)) |
2497 | goto xml_output; |
2498 | goto out; |
2499 | } |
2500 | |
2501 | if (rsp.dict.dict_len) { |
2502 | /* Unserialize the dictionary */ |
2503 | dict = dict_new (); |
2504 | |
2505 | ret = dict_unserialize (rsp.dict.dict_val, |
2506 | rsp.dict.dict_len, |
2507 | &dict); |
2508 | if (ret < 0) { |
2509 | gf_log ("glusterd", GF_LOG_ERROR,do { do { if (0) printf ("failed to " "unserialize req-buffer to dictionary" ); } while (0); _gf_log ("glusterd", "cli-rpc-ops.c", __FUNCTION__ , 2511, GF_LOG_ERROR, "failed to " "unserialize req-buffer to dictionary" ); } while (0) |
2510 | "failed to "do { do { if (0) printf ("failed to " "unserialize req-buffer to dictionary" ); } while (0); _gf_log ("glusterd", "cli-rpc-ops.c", __FUNCTION__ , 2511, GF_LOG_ERROR, "failed to " "unserialize req-buffer to dictionary" ); } while (0) |
2511 | "unserialize req-buffer to dictionary")do { do { if (0) printf ("failed to " "unserialize req-buffer to dictionary" ); } while (0); _gf_log ("glusterd", "cli-rpc-ops.c", __FUNCTION__ , 2511, GF_LOG_ERROR, "failed to " "unserialize req-buffer to dictionary" ); } while (0); |
2512 | goto out; |
2513 | } |
2514 | } |
2515 | |
2516 | ret = dict_get_str (dict, "volname", &volname); |
2517 | if (ret) |
2518 | gf_log (frame->this->name, GF_LOG_TRACE,do { do { if (0) printf ("failed to get volname"); } while (0 ); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__ , 2519, GF_LOG_TRACE, "failed to get volname"); } while (0) |
2519 | "failed to get volname")do { do { if (0) printf ("failed to get volname"); } while (0 ); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__ , 2519, GF_LOG_TRACE, "failed to get volname"); } while (0); |
2520 | |
2521 | ret = dict_get_str (dict, "limit_list", &limit_list); |
2522 | if (ret) |
2523 | gf_log (frame->this->name, GF_LOG_TRACE,do { do { if (0) printf ("failed to get limit_list"); } while (0); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__ , 2524, GF_LOG_TRACE, "failed to get limit_list"); } while (0 ) |
2524 | "failed to get limit_list")do { do { if (0) printf ("failed to get limit_list"); } while (0); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__ , 2524, GF_LOG_TRACE, "failed to get limit_list"); } while (0 ); |
2525 | |
2526 | ret = dict_get_int32 (dict, "type", &type); |
2527 | if (ret) |
2528 | gf_log (frame->this->name, GF_LOG_TRACE,do { do { if (0) printf ("failed to get type"); } while (0); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__, 2529 , GF_LOG_TRACE, "failed to get type"); } while (0) |
2529 | "failed to get type")do { do { if (0) printf ("failed to get type"); } while (0); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__, 2529 , GF_LOG_TRACE, "failed to get type"); } while (0); |
2530 | |
2531 | if (type == GF_QUOTA_OPTION_TYPE_LIST) { |
2532 | if (global_state->mode & GLUSTER_MODE_XML(1 << 2)) { |
2533 | ret = cli_xml_output_vol_quota_limit_list |
2534 | (volname, limit_list, rsp.op_ret, |
2535 | rsp.op_errno, rsp.op_errstr); |
2536 | if (ret) |
2537 | gf_log ("cli", GF_LOG_ERROR,do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 2538, GF_LOG_ERROR , "Error outputting to xml"); } while (0) |
2538 | "Error outputting to xml")do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 2538, GF_LOG_ERROR , "Error outputting to xml"); } while (0); |
2539 | goto out; |
2540 | |
2541 | } |
2542 | |
2543 | if (limit_list) { |
2544 | gf_cli_print_limit_list (volname, |
2545 | limit_list, |
2546 | rsp.op_errstr); |
2547 | } else { |
2548 | gf_log ("cli", GF_LOG_INFO, "Received resp to quota "do { do { if (0) printf ("Received resp to quota " "command " ); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__ , 2549, GF_LOG_INFO, "Received resp to quota " "command "); } while (0) |
2549 | "command ")do { do { if (0) printf ("Received resp to quota " "command " ); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__ , 2549, GF_LOG_INFO, "Received resp to quota " "command "); } while (0); |
2550 | if (rsp.op_errstr) |
2551 | snprintf (msg, sizeof (msg), "%s", |
2552 | rsp.op_errstr); |
2553 | } |
2554 | } else { |
2555 | gf_log ("cli", GF_LOG_INFO, "Received resp to quota command ")do { do { if (0) printf ("Received resp to quota command "); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 2555 , GF_LOG_INFO, "Received resp to quota command "); } while (0 ); |
2556 | if (rsp.op_errstr) |
2557 | snprintf (msg, sizeof (msg), "%s", rsp.op_errstr); |
2558 | else |
2559 | snprintf (msg, sizeof (msg), "successful"); |
2560 | } |
2561 | |
2562 | xml_output: |
2563 | if (global_state->mode & GLUSTER_MODE_XML(1 << 2)) { |
2564 | ret = cli_xml_output_str ("volQuota", msg, rsp.op_ret, |
2565 | rsp.op_errno, rsp.op_errstr); |
2566 | if (ret) |
2567 | gf_log ("cli", GF_LOG_ERROR,do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 2568, GF_LOG_ERROR , "Error outputting to xml"); } while (0) |
2568 | "Error outputting to xml")do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 2568, GF_LOG_ERROR , "Error outputting to xml"); } while (0); |
2569 | goto out; |
2570 | } |
2571 | |
2572 | if (strlen (msg) > 0) { |
2573 | if (rsp.op_ret) |
2574 | cli_err ("%s", msg)do { do { if (0) printf ("%s", msg); } while (0); _cli_err("%s" , msg); } while (0); |
2575 | else |
2576 | cli_out ("%s", msg)do { do { if (0) printf ("%s", msg); } while (0); _cli_out("%s" , msg); } while (0); |
2577 | } |
2578 | |
2579 | ret = rsp.op_ret; |
2580 | out: |
2581 | cli_cmd_broadcast_response (ret); |
2582 | if (dict) |
2583 | dict_unref (dict); |
2584 | |
2585 | free (rsp.dict.dict_val); |
2586 | |
2587 | return ret; |
2588 | } |
2589 | |
2590 | int |
2591 | gf_cli_getspec_cbk (struct rpc_req *req, struct iovec *iov, |
2592 | int count, void *myframe) |
2593 | { |
2594 | gf_getspec_rsp rsp = {0,}; |
2595 | int ret = -1; |
2596 | char *spec = NULL((void*)0); |
2597 | call_frame_t *frame = NULL((void*)0); |
2598 | |
2599 | if (-1 == req->rpc_status) { |
2600 | goto out; |
2601 | } |
2602 | |
2603 | frame = myframe; |
2604 | |
2605 | ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_getspec_rsp); |
2606 | if (ret < 0) { |
2607 | gf_log (frame->this->name, GF_LOG_ERROR,do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__ , 2608, GF_LOG_ERROR, "Failed to decode xdr response"); } while (0) |
2608 | "Failed to decode xdr response")do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__ , 2608, GF_LOG_ERROR, "Failed to decode xdr response"); } while (0); |
2609 | goto out; |
2610 | } |
2611 | |
2612 | if (rsp.op_ret == -1) { |
2613 | gf_log (frame->this->name, GF_LOG_ERROR,do { do { if (0) printf ("getspec failed"); } while (0); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__, 2614 , GF_LOG_ERROR, "getspec failed"); } while (0) |
2614 | "getspec failed")do { do { if (0) printf ("getspec failed"); } while (0); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__, 2614 , GF_LOG_ERROR, "getspec failed"); } while (0); |
2615 | goto out; |
2616 | } |
2617 | |
2618 | gf_log ("cli", GF_LOG_INFO, "Received resp to getspec")do { do { if (0) printf ("Received resp to getspec"); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 2618, GF_LOG_INFO , "Received resp to getspec"); } while (0); |
2619 | |
2620 | spec = GF_MALLOC (rsp.op_ret + 1, cli_mt_char)__gf_malloc (rsp.op_ret + 1, cli_mt_char); |
2621 | if (!spec) { |
2622 | gf_log("", GF_LOG_ERROR, "out of memory")do { do { if (0) printf ("out of memory"); } while (0); _gf_log ("", "cli-rpc-ops.c", __FUNCTION__, 2622, GF_LOG_ERROR, "out of memory" ); } while (0); |
2623 | goto out; |
2624 | } |
2625 | memcpy (spec, rsp.spec, rsp.op_ret); |
2626 | spec[rsp.op_ret] = '\0'; |
2627 | cli_out ("%s", spec)do { do { if (0) printf ("%s", spec); } while (0); _cli_out("%s" , spec); } while (0); |
2628 | GF_FREE (spec)__gf_free (spec); |
2629 | |
2630 | ret = 0; |
2631 | |
2632 | out: |
2633 | cli_cmd_broadcast_response (ret); |
2634 | return ret; |
2635 | } |
2636 | |
2637 | int |
2638 | gf_cli_pmap_b2p_cbk (struct rpc_req *req, struct iovec *iov, |
2639 | int count, void *myframe) |
2640 | { |
2641 | pmap_port_by_brick_rsp rsp = {0,}; |
2642 | int ret = -1; |
2643 | char *spec = NULL((void*)0); |
2644 | call_frame_t *frame = NULL((void*)0); |
2645 | |
2646 | if (-1 == req->rpc_status) { |
2647 | goto out; |
2648 | } |
2649 | |
2650 | frame = myframe; |
2651 | |
2652 | ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_pmap_port_by_brick_rsp); |
2653 | if (ret < 0) { |
2654 | gf_log (frame->this->name, GF_LOG_ERROR,do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__ , 2655, GF_LOG_ERROR, "Failed to decode xdr response"); } while (0) |
2655 | "Failed to decode xdr response")do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__ , 2655, GF_LOG_ERROR, "Failed to decode xdr response"); } while (0); |
2656 | goto out; |
2657 | } |
2658 | |
2659 | if (rsp.op_ret == -1) { |
2660 | gf_log (frame->this->name, GF_LOG_ERROR,do { do { if (0) printf ("pump_b2p failed"); } while (0); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__, 2661 , GF_LOG_ERROR, "pump_b2p failed"); } while (0) |
2661 | "pump_b2p failed")do { do { if (0) printf ("pump_b2p failed"); } while (0); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__, 2661 , GF_LOG_ERROR, "pump_b2p failed"); } while (0); |
2662 | goto out; |
2663 | } |
2664 | |
2665 | gf_log ("cli", GF_LOG_INFO, "Received resp to pmap b2p")do { do { if (0) printf ("Received resp to pmap b2p"); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 2665, GF_LOG_INFO , "Received resp to pmap b2p"); } while (0); |
2666 | |
2667 | cli_out ("%d", rsp.port)do { do { if (0) printf ("%d", rsp.port); } while (0); _cli_out ("%d", rsp.port); } while (0); |
2668 | GF_FREE (spec)__gf_free (spec); |
2669 | |
2670 | ret = rsp.op_ret; |
2671 | |
2672 | out: |
2673 | cli_cmd_broadcast_response (ret); |
2674 | return ret; |
2675 | } |
2676 | |
2677 | |
2678 | int32_t |
2679 | gf_cli_probe (call_frame_t *frame, xlator_t *this, |
2680 | void *data) |
2681 | { |
2682 | gf1_cli_probe_req req = {0,}; |
2683 | int ret = 0; |
2684 | dict_t *dict = NULL((void*)0); |
2685 | char *hostname = NULL((void*)0); |
2686 | int port = 0; |
2687 | |
2688 | if (!frame || !this || !data) { |
2689 | ret = -1; |
2690 | goto out; |
2691 | } |
2692 | |
2693 | dict = data; |
2694 | ret = dict_get_str (dict, "hostname", &hostname); |
2695 | if (ret) |
2696 | goto out; |
2697 | |
2698 | ret = dict_get_int32 (dict, "port", &port); |
2699 | if (ret) |
2700 | port = CLI_GLUSTERD_PORT24007; |
2701 | |
2702 | req.hostname = hostname; |
2703 | req.port = port; |
2704 | |
2705 | ret = cli_cmd_submit (&req, frame, cli_rpc_prog, |
2706 | GLUSTER_CLI_PROBE, NULL((void*)0), |
2707 | this, gf_cli_probe_cbk, |
2708 | (xdrproc_t)xdr_gf1_cli_probe_req); |
2709 | |
2710 | out: |
2711 | gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret)do { do { if (0) printf ("Returning %d", ret); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 2711, GF_LOG_DEBUG, "Returning %d" , ret); } while (0); |
2712 | return ret; |
2713 | } |
2714 | |
2715 | int32_t |
2716 | gf_cli_deprobe (call_frame_t *frame, xlator_t *this, |
2717 | void *data) |
2718 | { |
2719 | gf1_cli_deprobe_req req = {0,}; |
2720 | int ret = 0; |
2721 | dict_t *dict = NULL((void*)0); |
2722 | char *hostname = NULL((void*)0); |
2723 | int port = 0; |
2724 | int flags = 0; |
2725 | |
2726 | if (!frame || !this || !data) { |
2727 | ret = -1; |
2728 | goto out; |
2729 | } |
2730 | |
2731 | dict = data; |
2732 | ret = dict_get_str (dict, "hostname", &hostname); |
2733 | if (ret) |
2734 | goto out; |
2735 | |
2736 | ret = dict_get_int32 (dict, "port", &port); |
2737 | if (ret) |
2738 | port = CLI_GLUSTERD_PORT24007; |
2739 | |
2740 | ret = dict_get_int32 (dict, "flags", &flags); |
2741 | if (ret) |
2742 | flags = 0; |
2743 | |
2744 | req.hostname = hostname; |
2745 | req.port = port; |
2746 | req.flags = flags; |
2747 | ret = cli_cmd_submit (&req, frame, cli_rpc_prog, |
2748 | GLUSTER_CLI_DEPROBE, NULL((void*)0), |
2749 | this, gf_cli_deprobe_cbk, |
2750 | (xdrproc_t)xdr_gf1_cli_deprobe_req); |
2751 | |
2752 | out: |
2753 | gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret)do { do { if (0) printf ("Returning %d", ret); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 2753, GF_LOG_DEBUG, "Returning %d" , ret); } while (0); |
2754 | return ret; |
2755 | } |
2756 | |
2757 | int32_t |
2758 | gf_cli_list_friends (call_frame_t *frame, xlator_t *this, |
2759 | void *data) |
2760 | { |
2761 | gf1_cli_peer_list_req req = {0,}; |
2762 | int ret = 0; |
2763 | unsigned long flags = 0; |
2764 | |
2765 | if (!frame || !this) { |
2766 | ret = -1; |
2767 | goto out; |
2768 | } |
2769 | |
2770 | GF_ASSERT (frame->local == NULL)do { if (!(frame->local == ((void*)0))) { do { do { if (0) printf ("Assertion failed: " "frame->local == NULL"); } while (0); _gf_log_callingfn ("", "cli-rpc-ops.c", __FUNCTION__, 2770 , GF_LOG_ERROR, "Assertion failed: " "frame->local == NULL" ); } while (0); } } while (0); |
2771 | |
2772 | flags = (long)data; |
2773 | req.flags = flags; |
2774 | frame->local = (void*)flags; |
2775 | ret = cli_cmd_submit (&req, frame, cli_rpc_prog, |
2776 | GLUSTER_CLI_LIST_FRIENDS, NULL((void*)0), |
2777 | this, gf_cli_list_friends_cbk, |
2778 | (xdrproc_t) xdr_gf1_cli_peer_list_req); |
2779 | |
2780 | out: |
2781 | gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret)do { do { if (0) printf ("Returning %d", ret); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 2781, GF_LOG_DEBUG, "Returning %d" , ret); } while (0); |
2782 | return ret; |
2783 | } |
2784 | |
2785 | int32_t |
2786 | gf_cli_get_next_volume (call_frame_t *frame, xlator_t *this, |
2787 | void *data) |
2788 | { |
2789 | |
2790 | int ret = 0; |
2791 | cli_cmd_volume_get_ctx_t *ctx = NULL((void*)0); |
2792 | cli_local_t *local = NULL((void*)0); |
2793 | |
2794 | if (!frame || !this || !data) { |
2795 | ret = -1; |
2796 | goto out; |
2797 | } |
2798 | |
2799 | ctx = data; |
2800 | local = frame->local; |
2801 | |
2802 | if (global_state->mode & GLUSTER_MODE_XML(1 << 2)) { |
2803 | ret = cli_xml_output_vol_info_begin (local, 0, 0, ""); |
2804 | if (ret) { |
2805 | gf_log ("cli", GF_LOG_ERROR, "Error outputting to xml")do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 2805, GF_LOG_ERROR , "Error outputting to xml"); } while (0); |
2806 | goto out; |
2807 | } |
2808 | } |
2809 | |
2810 | ret = gf_cli_get_volume (frame, this, data); |
2811 | |
2812 | |
2813 | if (!local || !local->get_vol.volname) { |
2814 | if ((global_state->mode & GLUSTER_MODE_XML(1 << 2))) |
2815 | goto end_xml; |
2816 | |
2817 | cli_err ("No volumes present")do { do { if (0) printf ("No volumes present"); } while (0); _cli_err ("No volumes present"); } while (0); |
2818 | goto out; |
2819 | } |
2820 | |
2821 | |
2822 | ctx->volname = local->get_vol.volname; |
2823 | |
2824 | while (ctx->volname) { |
2825 | ret = gf_cli_get_volume (frame, this, ctx); |
2826 | if (ret) |
2827 | goto out; |
2828 | ctx->volname = local->get_vol.volname; |
2829 | } |
2830 | |
2831 | end_xml: |
2832 | if (global_state->mode & GLUSTER_MODE_XML(1 << 2)) { |
2833 | ret = cli_xml_output_vol_info_end (local); |
2834 | if (ret) |
2835 | gf_log ("cli", GF_LOG_ERROR, "Error outputting to xml")do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 2835, GF_LOG_ERROR , "Error outputting to xml"); } while (0); |
2836 | } |
2837 | |
2838 | out: |
2839 | gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret)do { do { if (0) printf ("Returning %d", ret); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 2839, GF_LOG_DEBUG, "Returning %d" , ret); } while (0); |
2840 | return ret; |
2841 | } |
2842 | |
2843 | int32_t |
2844 | gf_cli_get_volume (call_frame_t *frame, xlator_t *this, |
2845 | void *data) |
2846 | { |
2847 | gf_cli_req req = {{0,}}; |
2848 | int ret = 0; |
2849 | cli_cmd_volume_get_ctx_t *ctx = NULL((void*)0); |
2850 | dict_t *dict = NULL((void*)0); |
2851 | int32_t flags = 0; |
2852 | |
2853 | if (!frame || !this || !data) { |
2854 | ret = -1; |
2855 | goto out; |
2856 | } |
2857 | |
2858 | ctx = data; |
2859 | |
2860 | dict = dict_new (); |
2861 | if (!dict) |
2862 | goto out; |
2863 | |
2864 | if (ctx->volname) { |
2865 | ret = dict_set_str (dict, "volname", ctx->volname); |
2866 | if (ret) |
2867 | goto out; |
2868 | } |
2869 | |
2870 | flags = ctx->flags; |
2871 | ret = dict_set_int32 (dict, "flags", flags); |
2872 | if (ret) { |
2873 | gf_log (frame->this->name, GF_LOG_ERROR, "failed to set flags")do { do { if (0) printf ("failed to set flags"); } while (0); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__ , 2873, GF_LOG_ERROR, "failed to set flags"); } while (0); |
2874 | goto out; |
2875 | } |
2876 | |
2877 | ret = dict_allocate_and_serialize (dict, &req.dict.dict_val, |
2878 | &req.dict.dict_len); |
2879 | |
2880 | ret = cli_cmd_submit (&req, frame, cli_rpc_prog, |
2881 | GLUSTER_CLI_GET_VOLUME, NULL((void*)0), |
2882 | this, gf_cli_get_volume_cbk, |
2883 | (xdrproc_t) xdr_gf_cli_req); |
2884 | |
2885 | out: |
2886 | if (dict) |
2887 | dict_unref (dict); |
2888 | |
2889 | GF_FREE (req.dict.dict_val)__gf_free (req.dict.dict_val); |
2890 | |
2891 | gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret)do { do { if (0) printf ("Returning %d", ret); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 2891, GF_LOG_DEBUG, "Returning %d" , ret); } while (0); |
2892 | return ret; |
2893 | } |
2894 | |
2895 | int32_t |
2896 | gf_cli3_1_uuid_reset (call_frame_t *frame, xlator_t *this, |
2897 | void *data) |
2898 | { |
2899 | gf_cli_req req = {{0,}}; |
2900 | int ret = 0; |
2901 | dict_t *dict = NULL((void*)0); |
2902 | |
2903 | if (!frame || !this || !data) { |
2904 | ret = -1; |
2905 | goto out; |
2906 | } |
2907 | |
2908 | dict = data; |
2909 | ret = cli_to_glusterd (&req, frame, gf_cli3_1_uuid_reset_cbk, |
2910 | (xdrproc_t)xdr_gf_cli_req, dict, |
2911 | GLUSTER_CLI_UUID_RESET, this, cli_rpc_prog, |
2912 | NULL((void*)0)); |
2913 | out: |
2914 | gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret)do { do { if (0) printf ("Returning %d", ret); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 2914, GF_LOG_DEBUG, "Returning %d" , ret); } while (0); |
2915 | return ret; |
2916 | } |
2917 | |
2918 | #ifdef HAVE_BD_XLATOR |
2919 | int |
2920 | gf_cli_bd_op_cbk (struct rpc_req *req, struct iovec *iov, |
2921 | int count, void *myframe) |
2922 | { |
2923 | gf_cli_rsp rsp = {0,}; |
2924 | int ret = -1; |
2925 | cli_local_t *local = NULL((void*)0); |
2926 | dict_t *dict = NULL((void*)0); |
2927 | dict_t *input_dict = NULL((void*)0); |
2928 | gf_xl_bd_op_t bd_op = GF_BD_OP_INVALID; |
2929 | char *operation = NULL((void*)0); |
2930 | call_frame_t *frame = NULL((void*)0); |
2931 | |
2932 | if (-1 == req->rpc_status) |
2933 | goto out; |
2934 | |
2935 | frame = myframe; |
2936 | |
2937 | ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_cli_rsp); |
2938 | if (ret < 0) { |
2939 | gf_log (frame->this->name, GF_LOG_ERROR,do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__ , 2940, GF_LOG_ERROR, "Failed to decode xdr response"); } while (0) |
2940 | "Failed to decode xdr response")do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__ , 2940, GF_LOG_ERROR, "Failed to decode xdr response"); } while (0); |
2941 | goto out; |
2942 | } |
2943 | |
2944 | dict = dict_new (); |
2945 | if (!dict) { |
2946 | ret = -1; |
2947 | goto out; |
2948 | } |
2949 | |
2950 | if (frame) |
2951 | local = frame->local; |
2952 | |
2953 | if (local) { |
2954 | input_dict = local->dict; |
2955 | ret = dict_get_int32 (input_dict, "bd-op", |
2956 | (int32_t *)&bd_op); |
2957 | } |
2958 | |
2959 | switch (bd_op) { |
2960 | case GF_BD_OP_NEW_BD: |
2961 | operation = gf_strdup ("create"); |
2962 | break; |
2963 | case GF_BD_OP_DELETE_BD: |
2964 | operation = gf_strdup ("delete"); |
2965 | break; |
2966 | case GF_BD_OP_CLONE_BD: |
2967 | operation = gf_strdup ("clone"); |
2968 | break; |
2969 | case GF_BD_OP_SNAPSHOT_BD: |
2970 | operation = gf_strdup ("snapshot"); |
2971 | break; |
2972 | default: |
2973 | break; |
2974 | } |
2975 | |
2976 | ret = dict_unserialize (rsp.dict.dict_val, rsp.dict.dict_len, &dict); |
2977 | if (ret) |
2978 | goto out; |
2979 | |
2980 | gf_log ("cli", GF_LOG_INFO, "Received resp to %s bd op", operation)do { do { if (0) printf ("Received resp to %s bd op", operation ); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__ , 2980, GF_LOG_INFO, "Received resp to %s bd op", operation); } while (0); |
2981 | |
2982 | if (global_state->mode & GLUSTER_MODE_XML(1 << 2)) { |
2983 | ret = cli_xml_output_dict ("BdOp", dict, rsp.op_ret, |
2984 | rsp.op_errno, rsp.op_errstr); |
2985 | if (ret) |
2986 | gf_log ("cli", GF_LOG_ERROR,do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 2987, GF_LOG_ERROR , "Error outputting to xml"); } while (0) |
2987 | "Error outputting to xml")do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 2987, GF_LOG_ERROR , "Error outputting to xml"); } while (0); |
2988 | goto out; |
2989 | } |
2990 | |
2991 | if (rsp.op_ret && strcmp (rsp.op_errstr, "")) |
2992 | cli_err ("%s", rsp.op_errstr)do { do { if (0) printf ("%s", rsp.op_errstr); } while (0); _cli_err ("%s", rsp.op_errstr); } while (0); |
2993 | else |
2994 | cli_out ("BD %s has been %s", operation,do { do { if (0) printf ("BD %s has been %s", operation, (rsp .op_ret) ? "unsuccessful": "successful."); } while (0); _cli_out ("BD %s has been %s", operation, (rsp.op_ret) ? "unsuccessful" : "successful."); } while (0) |
2995 | (rsp.op_ret) ? "unsuccessful":do { do { if (0) printf ("BD %s has been %s", operation, (rsp .op_ret) ? "unsuccessful": "successful."); } while (0); _cli_out ("BD %s has been %s", operation, (rsp.op_ret) ? "unsuccessful" : "successful."); } while (0) |
2996 | "successful.")do { do { if (0) printf ("BD %s has been %s", operation, (rsp .op_ret) ? "unsuccessful": "successful."); } while (0); _cli_out ("BD %s has been %s", operation, (rsp.op_ret) ? "unsuccessful" : "successful."); } while (0); |
2997 | ret = rsp.op_ret; |
2998 | |
2999 | out: |
3000 | cli_cmd_broadcast_response (ret); |
3001 | |
3002 | if (dict) |
3003 | dict_unref (dict); |
3004 | |
3005 | if (operation) |
3006 | GF_FREE (operation)__gf_free (operation); |
3007 | |
3008 | if (rsp.dict.dict_val) |
3009 | free (rsp.dict.dict_val); |
3010 | if (rsp.op_errstr) |
3011 | free (rsp.op_errstr); |
3012 | return ret; |
3013 | } |
3014 | |
3015 | int32_t |
3016 | gf_cli_bd_op (call_frame_t *frame, xlator_t *this, |
3017 | void *data) |
3018 | { |
3019 | gf_cli_req req = { {0,} }; |
3020 | int ret = 0; |
3021 | dict_t *dict = NULL((void*)0); |
3022 | |
3023 | if (!frame || !this || !data) { |
3024 | ret = -1; |
3025 | goto out; |
3026 | } |
3027 | |
3028 | dict = dict_ref ((dict_t *)data); |
3029 | if (!dict) |
3030 | goto out; |
3031 | |
3032 | ret = dict_allocate_and_serialize (dict, |
3033 | &req.dict.dict_val, |
3034 | &req.dict.dict_len); |
3035 | |
3036 | |
3037 | ret = cli_cmd_submit (&req, frame, cli_rpc_prog, |
3038 | GLUSTER_CLI_BD_OP, NULL((void*)0), |
3039 | this, gf_cli_bd_op_cbk, |
3040 | (xdrproc_t) xdr_gf_cli_req); |
3041 | |
3042 | out: |
3043 | if (dict) |
3044 | dict_unref (dict); |
3045 | |
3046 | if (req.dict.dict_val) |
3047 | GF_FREE (req.dict.dict_val)__gf_free (req.dict.dict_val); |
3048 | |
3049 | gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret)do { do { if (0) printf ("Returning %d", ret); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 3049, GF_LOG_DEBUG, "Returning %d" , ret); } while (0); |
3050 | return ret; |
3051 | } |
3052 | #endif |
3053 | |
3054 | int32_t |
3055 | gf_cli_create_volume (call_frame_t *frame, xlator_t *this, |
3056 | void *data) |
3057 | { |
3058 | gf_cli_req req = {{0,}}; |
3059 | int ret = 0; |
3060 | dict_t *dict = NULL((void*)0); |
3061 | |
3062 | if (!frame || !this || !data) { |
3063 | ret = -1; |
3064 | goto out; |
3065 | } |
3066 | |
3067 | dict = data; |
3068 | |
3069 | ret = cli_to_glusterd (&req, frame, gf_cli_create_volume_cbk, |
3070 | (xdrproc_t) xdr_gf_cli_req, dict, |
3071 | GLUSTER_CLI_CREATE_VOLUME, this, cli_rpc_prog, |
3072 | NULL((void*)0)); |
3073 | |
3074 | out: |
3075 | gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret)do { do { if (0) printf ("Returning %d", ret); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 3075, GF_LOG_DEBUG, "Returning %d" , ret); } while (0); |
3076 | |
3077 | GF_FREE (req.dict.dict_val)__gf_free (req.dict.dict_val); |
3078 | |
3079 | return ret; |
3080 | } |
3081 | |
3082 | int32_t |
3083 | gf_cli_delete_volume (call_frame_t *frame, xlator_t *this, |
3084 | void *data) |
3085 | { |
3086 | gf_cli_req req = {{0,}}; |
3087 | int ret = 0; |
3088 | dict_t *dict = NULL((void*)0); |
3089 | |
3090 | if (!frame || !this || !data) { |
3091 | ret = -1; |
3092 | goto out; |
3093 | } |
3094 | |
3095 | dict = data; |
3096 | |
3097 | ret = cli_to_glusterd (&req, frame, gf_cli_delete_volume_cbk, |
3098 | (xdrproc_t) xdr_gf_cli_req, dict, |
3099 | GLUSTER_CLI_DELETE_VOLUME, this, cli_rpc_prog, |
3100 | NULL((void*)0)); |
3101 | |
3102 | out: |
3103 | GF_FREE (req.dict.dict_val)__gf_free (req.dict.dict_val); |
3104 | gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret)do { do { if (0) printf ("Returning %d", ret); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 3104, GF_LOG_DEBUG, "Returning %d" , ret); } while (0); |
3105 | |
3106 | return ret; |
3107 | } |
3108 | |
3109 | int32_t |
3110 | gf_cli_start_volume (call_frame_t *frame, xlator_t *this, |
3111 | void *data) |
3112 | { |
3113 | gf_cli_req req = {{0,}}; |
3114 | int ret = 0; |
3115 | dict_t *dict = NULL((void*)0); |
3116 | |
3117 | if (!frame || !this || !data) { |
3118 | ret = -1; |
3119 | goto out; |
3120 | } |
3121 | |
3122 | dict = data; |
3123 | |
3124 | ret = cli_to_glusterd (&req, frame, gf_cli_start_volume_cbk, |
3125 | (xdrproc_t) xdr_gf_cli_req, dict, |
3126 | GLUSTER_CLI_START_VOLUME, this, cli_rpc_prog, |
3127 | NULL((void*)0)); |
3128 | |
3129 | out: |
3130 | gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret)do { do { if (0) printf ("Returning %d", ret); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 3130, GF_LOG_DEBUG, "Returning %d" , ret); } while (0); |
3131 | |
3132 | return ret; |
3133 | } |
3134 | |
3135 | int32_t |
3136 | gf_cli_stop_volume (call_frame_t *frame, xlator_t *this, |
3137 | void *data) |
3138 | { |
3139 | gf_cli_req req = {{0,}}; |
3140 | int ret = 0; |
3141 | dict_t *dict = data; |
3142 | |
3143 | if (!frame || !this || !data) { |
3144 | ret = -1; |
3145 | goto out; |
3146 | } |
3147 | |
3148 | dict = data; |
3149 | |
3150 | ret = cli_to_glusterd (&req, frame, gf_cli_stop_volume_cbk, |
3151 | (xdrproc_t) xdr_gf_cli_req, dict, |
3152 | GLUSTER_CLI_STOP_VOLUME, this, cli_rpc_prog, |
3153 | NULL((void*)0)); |
3154 | |
3155 | out: |
3156 | gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret)do { do { if (0) printf ("Returning %d", ret); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 3156, GF_LOG_DEBUG, "Returning %d" , ret); } while (0); |
3157 | |
3158 | return ret; |
3159 | } |
3160 | |
3161 | int32_t |
3162 | gf_cli_defrag_volume (call_frame_t *frame, xlator_t *this, |
3163 | void *data) |
3164 | { |
3165 | gf_cli_req req = {{0,}}; |
3166 | int ret = 0; |
3167 | dict_t *dict = NULL((void*)0); |
3168 | |
3169 | if (!frame || !this || !data) { |
3170 | ret = -1; |
3171 | goto out; |
3172 | } |
3173 | |
3174 | dict = data; |
3175 | |
3176 | ret = cli_to_glusterd (&req, frame, gf_cli_defrag_volume_cbk, |
3177 | (xdrproc_t) xdr_gf_cli_req, dict, |
3178 | GLUSTER_CLI_DEFRAG_VOLUME, this, cli_rpc_prog, |
3179 | NULL((void*)0)); |
3180 | |
3181 | out: |
3182 | gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret)do { do { if (0) printf ("Returning %d", ret); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 3182, GF_LOG_DEBUG, "Returning %d" , ret); } while (0); |
3183 | |
3184 | return ret; |
3185 | } |
3186 | |
3187 | int32_t |
3188 | gf_cli_rename_volume (call_frame_t *frame, xlator_t *this, |
3189 | void *data) |
3190 | { |
3191 | gf_cli_req req = {{0,}}; |
3192 | int ret = 0; |
3193 | dict_t *dict = NULL((void*)0); |
3194 | |
3195 | if (!frame || !this || !data) { |
3196 | ret = -1; |
3197 | goto out; |
3198 | } |
3199 | |
3200 | dict = data; |
3201 | |
3202 | ret = dict_allocate_and_serialize (dict, &req.dict.dict_val, |
3203 | &req.dict.dict_len); |
3204 | if (ret < 0) { |
3205 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("failed to serialize the data"); } while (0); _gf_log (this->name, "cli-rpc-ops.c", __FUNCTION__, 3206 , GF_LOG_ERROR, "failed to serialize the data"); } while (0) |
3206 | "failed to serialize the data")do { do { if (0) printf ("failed to serialize the data"); } while (0); _gf_log (this->name, "cli-rpc-ops.c", __FUNCTION__, 3206 , GF_LOG_ERROR, "failed to serialize the data"); } while (0); |
3207 | |
3208 | goto out; |
3209 | } |
3210 | |
3211 | |
3212 | ret = cli_cmd_submit (&req, frame, cli_rpc_prog, |
3213 | GLUSTER_CLI_RENAME_VOLUME, NULL((void*)0), |
3214 | this, gf_cli_rename_volume_cbk, |
3215 | (xdrproc_t) xdr_gf_cli_req); |
3216 | |
3217 | out: |
3218 | gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret)do { do { if (0) printf ("Returning %d", ret); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 3218, GF_LOG_DEBUG, "Returning %d" , ret); } while (0); |
3219 | |
3220 | return ret; |
3221 | } |
3222 | |
3223 | int32_t |
3224 | gf_cli_reset_volume (call_frame_t *frame, xlator_t *this, |
3225 | void *data) |
3226 | { |
3227 | gf_cli_req req = {{0,}}; |
3228 | int ret = 0; |
3229 | dict_t *dict = NULL((void*)0); |
3230 | |
3231 | if (!frame || !this || !data) { |
3232 | ret = -1; |
3233 | goto out; |
3234 | } |
3235 | |
3236 | dict = data; |
3237 | |
3238 | ret = cli_to_glusterd (&req, frame, gf_cli_reset_volume_cbk, |
3239 | (xdrproc_t) xdr_gf_cli_req, dict, |
3240 | GLUSTER_CLI_RESET_VOLUME, this, cli_rpc_prog, |
3241 | NULL((void*)0)); |
3242 | |
3243 | out: |
3244 | gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret)do { do { if (0) printf ("Returning %d", ret); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 3244, GF_LOG_DEBUG, "Returning %d" , ret); } while (0); |
3245 | return ret; |
3246 | } |
3247 | |
3248 | int32_t |
3249 | gf_cli_set_volume (call_frame_t *frame, xlator_t *this, |
3250 | void *data) |
3251 | { |
3252 | gf_cli_req req = {{0,}}; |
3253 | int ret = 0; |
3254 | dict_t *dict = NULL((void*)0); |
3255 | |
3256 | if (!frame || !this || !data) { |
3257 | ret = -1; |
3258 | goto out; |
3259 | } |
3260 | |
3261 | dict = data; |
3262 | |
3263 | ret = cli_to_glusterd (&req, frame, gf_cli_set_volume_cbk, |
3264 | (xdrproc_t) xdr_gf_cli_req, dict, |
3265 | GLUSTER_CLI_SET_VOLUME, this, cli_rpc_prog, |
3266 | NULL((void*)0)); |
3267 | |
3268 | out: |
3269 | gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret)do { do { if (0) printf ("Returning %d", ret); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 3269, GF_LOG_DEBUG, "Returning %d" , ret); } while (0); |
3270 | |
3271 | return ret; |
3272 | } |
3273 | |
3274 | int32_t |
3275 | gf_cli_add_brick (call_frame_t *frame, xlator_t *this, |
3276 | void *data) |
3277 | { |
3278 | gf_cli_req req = {{0,}}; |
3279 | int ret = 0; |
3280 | dict_t *dict = NULL((void*)0); |
3281 | char *volname = NULL((void*)0); |
3282 | int32_t count = 0; |
3283 | |
3284 | if (!frame || !this || !data) { |
3285 | ret = -1; |
3286 | goto out; |
3287 | } |
3288 | |
3289 | dict = data; |
3290 | |
3291 | ret = dict_get_str (dict, "volname", &volname); |
3292 | |
3293 | if (ret) |
3294 | goto out; |
3295 | |
3296 | ret = dict_get_int32 (dict, "count", &count); |
3297 | if (ret) |
3298 | goto out; |
3299 | |
3300 | ret = cli_to_glusterd (&req, frame, gf_cli_add_brick_cbk, |
3301 | (xdrproc_t) xdr_gf_cli_req, dict, |
3302 | GLUSTER_CLI_ADD_BRICK, this, cli_rpc_prog, NULL((void*)0)); |
3303 | |
3304 | out: |
3305 | gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret)do { do { if (0) printf ("Returning %d", ret); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 3305, GF_LOG_DEBUG, "Returning %d" , ret); } while (0); |
3306 | |
3307 | GF_FREE (req.dict.dict_val)__gf_free (req.dict.dict_val); |
3308 | |
3309 | return ret; |
3310 | } |
3311 | |
3312 | int32_t |
3313 | gf_cli_remove_brick (call_frame_t *frame, xlator_t *this, |
3314 | void *data) |
3315 | { |
3316 | gf_cli_req req = {{0,}};; |
3317 | gf_cli_req status_req = {{0,}};; |
3318 | int ret = 0; |
3319 | dict_t *dict = NULL((void*)0); |
3320 | int32_t command = 0; |
3321 | char *volname = NULL((void*)0); |
3322 | dict_t *req_dict = NULL((void*)0); |
3323 | int32_t cmd = 0; |
3324 | |
3325 | if (!frame || !this || !data) { |
3326 | ret = -1; |
3327 | goto out; |
3328 | } |
3329 | |
3330 | dict = data; |
3331 | |
3332 | ret = dict_get_str (dict, "volname", &volname); |
3333 | if (ret) |
3334 | goto out; |
3335 | |
3336 | ret = dict_get_int32 (dict, "command", &command); |
3337 | if (ret) |
3338 | goto out; |
3339 | |
3340 | if ((command != GF_OP_CMD_STATUS) && |
3341 | (command != GF_OP_CMD_STOP)) { |
3342 | |
3343 | |
3344 | ret = cli_to_glusterd (&req, frame, gf_cli_remove_brick_cbk, |
3345 | (xdrproc_t) xdr_gf_cli_req, dict, |
3346 | GLUSTER_CLI_REMOVE_BRICK, this, |
3347 | cli_rpc_prog, NULL((void*)0)); |
3348 | } else { |
3349 | /* Need rebalance status to be sent :-) */ |
3350 | req_dict = dict_new (); |
3351 | if (!req_dict) { |
3352 | ret = -1; |
3353 | goto out; |
3354 | } |
3355 | |
3356 | ret = dict_set_str (req_dict, "volname", volname); |
3357 | if (ret) { |
3358 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("Failed to set dict"); } while (0); _gf_log (this->name, "cli-rpc-ops.c", __FUNCTION__, 3359, GF_LOG_ERROR , "Failed to set dict"); } while (0) |
3359 | "Failed to set dict")do { do { if (0) printf ("Failed to set dict"); } while (0); _gf_log (this->name, "cli-rpc-ops.c", __FUNCTION__, 3359, GF_LOG_ERROR , "Failed to set dict"); } while (0); |
3360 | goto out; |
3361 | } |
3362 | |
3363 | if (command == GF_OP_CMD_STATUS) |
3364 | cmd |= GF_DEFRAG_CMD_STATUS; |
3365 | else |
3366 | cmd |= GF_DEFRAG_CMD_STOP; |
3367 | |
3368 | ret = dict_set_int32 (req_dict, "rebalance-command", (int32_t) cmd); |
3369 | if (ret) { |
3370 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("Failed to set dict"); } while (0); _gf_log (this->name, "cli-rpc-ops.c", __FUNCTION__, 3371, GF_LOG_ERROR , "Failed to set dict"); } while (0) |
3371 | "Failed to set dict")do { do { if (0) printf ("Failed to set dict"); } while (0); _gf_log (this->name, "cli-rpc-ops.c", __FUNCTION__, 3371, GF_LOG_ERROR , "Failed to set dict"); } while (0); |
3372 | goto out; |
3373 | } |
3374 | |
3375 | ret = cli_to_glusterd (&status_req, frame, |
3376 | gf_cli3_remove_brick_status_cbk, |
3377 | (xdrproc_t) xdr_gf_cli_req, req_dict, |
3378 | GLUSTER_CLI_DEFRAG_VOLUME, this, |
3379 | cli_rpc_prog, NULL((void*)0)); |
3380 | |
3381 | } |
3382 | |
3383 | out: |
3384 | if (req_dict) |
3385 | dict_unref (req_dict); |
3386 | gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret)do { do { if (0) printf ("Returning %d", ret); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 3386, GF_LOG_DEBUG, "Returning %d" , ret); } while (0); |
3387 | |
3388 | GF_FREE (req.dict.dict_val)__gf_free (req.dict.dict_val); |
3389 | |
3390 | GF_FREE (status_req.dict.dict_val)__gf_free (status_req.dict.dict_val); |
3391 | |
3392 | return ret; |
3393 | } |
3394 | |
3395 | int32_t |
3396 | gf_cli_replace_brick (call_frame_t *frame, xlator_t *this, |
3397 | void *data) |
3398 | { |
3399 | gf_cli_req req = {{0,}}; |
3400 | int ret = 0; |
3401 | dict_t *dict = NULL((void*)0); |
3402 | char *src_brick = NULL((void*)0); |
3403 | char *dst_brick = NULL((void*)0); |
3404 | char *volname = NULL((void*)0); |
3405 | int32_t op = 0; |
3406 | |
3407 | if (!frame || !this || !data) { |
3408 | ret = -1; |
3409 | goto out; |
3410 | } |
3411 | |
3412 | dict = data; |
3413 | |
3414 | ret = dict_get_int32 (dict, "operation", &op); |
3415 | if (ret) { |
3416 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("dict_get on operation failed"); } while (0); _gf_log (this->name, "cli-rpc-ops.c", __FUNCTION__, 3417 , GF_LOG_DEBUG, "dict_get on operation failed"); } while (0) |
3417 | "dict_get on operation failed")do { do { if (0) printf ("dict_get on operation failed"); } while (0); _gf_log (this->name, "cli-rpc-ops.c", __FUNCTION__, 3417 , GF_LOG_DEBUG, "dict_get on operation failed"); } while (0); |
3418 | goto out; |
3419 | } |
3420 | ret = dict_get_str (dict, "volname", &volname); |
3421 | if (ret) { |
3422 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("dict_get on volname failed"); } while (0); _gf_log (this->name, "cli-rpc-ops.c", __FUNCTION__, 3423 , GF_LOG_DEBUG, "dict_get on volname failed"); } while (0) |
3423 | "dict_get on volname failed")do { do { if (0) printf ("dict_get on volname failed"); } while (0); _gf_log (this->name, "cli-rpc-ops.c", __FUNCTION__, 3423 , GF_LOG_DEBUG, "dict_get on volname failed"); } while (0); |
3424 | goto out; |
3425 | } |
3426 | |
3427 | ret = dict_get_str (dict, "src-brick", &src_brick); |
3428 | if (ret) { |
3429 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("dict_get on src-brick failed"); } while (0); _gf_log (this->name, "cli-rpc-ops.c", __FUNCTION__, 3430 , GF_LOG_DEBUG, "dict_get on src-brick failed"); } while (0) |
3430 | "dict_get on src-brick failed")do { do { if (0) printf ("dict_get on src-brick failed"); } while (0); _gf_log (this->name, "cli-rpc-ops.c", __FUNCTION__, 3430 , GF_LOG_DEBUG, "dict_get on src-brick failed"); } while (0); |
3431 | goto out; |
3432 | } |
3433 | |
3434 | ret = dict_get_str (dict, "dst-brick", &dst_brick); |
3435 | if (ret) { |
3436 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("dict_get on dst-brick failed"); } while (0); _gf_log (this->name, "cli-rpc-ops.c", __FUNCTION__, 3437 , GF_LOG_DEBUG, "dict_get on dst-brick failed"); } while (0) |
3437 | "dict_get on dst-brick failed")do { do { if (0) printf ("dict_get on dst-brick failed"); } while (0); _gf_log (this->name, "cli-rpc-ops.c", __FUNCTION__, 3437 , GF_LOG_DEBUG, "dict_get on dst-brick failed"); } while (0); |
3438 | goto out; |
3439 | } |
3440 | |
3441 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("Received command replace-brick %s with " "%s with operation=%d", src_brick, dst_brick, op); } while ( 0); _gf_log (this->name, "cli-rpc-ops.c", __FUNCTION__, 3444 , GF_LOG_DEBUG, "Received command replace-brick %s with " "%s with operation=%d" , src_brick, dst_brick, op); } while (0) |
3442 | "Received command replace-brick %s with "do { do { if (0) printf ("Received command replace-brick %s with " "%s with operation=%d", src_brick, dst_brick, op); } while ( 0); _gf_log (this->name, "cli-rpc-ops.c", __FUNCTION__, 3444 , GF_LOG_DEBUG, "Received command replace-brick %s with " "%s with operation=%d" , src_brick, dst_brick, op); } while (0) |
3443 | "%s with operation=%d", src_brick,do { do { if (0) printf ("Received command replace-brick %s with " "%s with operation=%d", src_brick, dst_brick, op); } while ( 0); _gf_log (this->name, "cli-rpc-ops.c", __FUNCTION__, 3444 , GF_LOG_DEBUG, "Received command replace-brick %s with " "%s with operation=%d" , src_brick, dst_brick, op); } while (0) |
3444 | dst_brick, op)do { do { if (0) printf ("Received command replace-brick %s with " "%s with operation=%d", src_brick, dst_brick, op); } while ( 0); _gf_log (this->name, "cli-rpc-ops.c", __FUNCTION__, 3444 , GF_LOG_DEBUG, "Received command replace-brick %s with " "%s with operation=%d" , src_brick, dst_brick, op); } while (0); |
3445 | |
3446 | ret = cli_to_glusterd (&req, frame, gf_cli_replace_brick_cbk, |
3447 | (xdrproc_t) xdr_gf_cli_req, dict, |
3448 | GLUSTER_CLI_REPLACE_BRICK, this, cli_rpc_prog, |
3449 | NULL((void*)0)); |
3450 | |
3451 | out: |
3452 | gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret)do { do { if (0) printf ("Returning %d", ret); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 3452, GF_LOG_DEBUG, "Returning %d" , ret); } while (0); |
3453 | |
3454 | GF_FREE (req.dict.dict_val)__gf_free (req.dict.dict_val); |
3455 | |
3456 | return ret; |
3457 | } |
3458 | |
3459 | |
3460 | int32_t |
3461 | gf_cli_log_rotate (call_frame_t *frame, xlator_t *this, |
3462 | void *data) |
3463 | { |
3464 | gf_cli_req req = {{0,}}; |
3465 | int ret = 0; |
3466 | dict_t *dict = NULL((void*)0); |
3467 | |
3468 | if (!frame || !this || !data) { |
3469 | ret = -1; |
3470 | goto out; |
3471 | } |
3472 | |
3473 | dict = data; |
3474 | |
3475 | ret = cli_to_glusterd (&req, frame, gf_cli_log_rotate_cbk, |
3476 | (xdrproc_t) xdr_gf_cli_req, dict, |
3477 | GLUSTER_CLI_LOG_ROTATE, this, cli_rpc_prog, |
3478 | NULL((void*)0)); |
3479 | |
3480 | out: |
3481 | gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret)do { do { if (0) printf ("Returning %d", ret); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 3481, GF_LOG_DEBUG, "Returning %d" , ret); } while (0); |
3482 | |
3483 | GF_FREE (req.dict.dict_val)__gf_free (req.dict.dict_val); |
3484 | return ret; |
3485 | } |
3486 | |
3487 | int32_t |
3488 | gf_cli_sync_volume (call_frame_t *frame, xlator_t *this, |
3489 | void *data) |
3490 | { |
3491 | int ret = 0; |
3492 | gf_cli_req req = {{0,}}; |
3493 | dict_t *dict = NULL((void*)0); |
3494 | |
3495 | if (!frame || !this || !data) { |
3496 | ret = -1; |
3497 | goto out; |
3498 | } |
3499 | |
3500 | dict = data; |
3501 | |
3502 | ret = cli_to_glusterd (&req, frame, gf_cli_sync_volume_cbk, |
3503 | (xdrproc_t) xdr_gf_cli_req, dict, |
3504 | GLUSTER_CLI_SYNC_VOLUME, this, cli_rpc_prog, |
3505 | NULL((void*)0)); |
3506 | |
3507 | out: |
3508 | gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret)do { do { if (0) printf ("Returning %d", ret); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 3508, GF_LOG_DEBUG, "Returning %d" , ret); } while (0); |
3509 | GF_FREE (req.dict.dict_val)__gf_free (req.dict.dict_val); |
3510 | |
3511 | return ret; |
3512 | } |
3513 | |
3514 | int32_t |
3515 | gf_cli_getspec (call_frame_t *frame, xlator_t *this, |
3516 | void *data) |
3517 | { |
3518 | gf_getspec_req req = {0,}; |
3519 | int ret = 0; |
3520 | dict_t *dict = NULL((void*)0); |
3521 | |
3522 | if (!frame || !this || !data) { |
3523 | ret = -1; |
3524 | goto out; |
3525 | } |
3526 | |
3527 | dict = data; |
3528 | |
3529 | ret = dict_get_str (dict, "volid", &req.key); |
3530 | if (ret) |
3531 | goto out; |
3532 | |
3533 | ret = cli_cmd_submit (&req, frame, &cli_handshake_prog, |
3534 | GF_HNDSK_GETSPEC, NULL((void*)0), |
3535 | this, gf_cli_getspec_cbk, |
3536 | (xdrproc_t) xdr_gf_getspec_req); |
3537 | |
3538 | out: |
3539 | gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret)do { do { if (0) printf ("Returning %d", ret); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 3539, GF_LOG_DEBUG, "Returning %d" , ret); } while (0); |
3540 | |
3541 | return ret; |
3542 | } |
3543 | |
3544 | int32_t |
3545 | gf_cli_quota (call_frame_t *frame, xlator_t *this, |
3546 | void *data) |
3547 | { |
3548 | gf_cli_req req = {{0,}}; |
3549 | int ret = 0; |
3550 | dict_t *dict = NULL((void*)0); |
3551 | |
3552 | if (!frame || !this || !data) { |
3553 | ret = -1; |
3554 | goto out; |
3555 | } |
3556 | |
3557 | dict = data; |
3558 | |
3559 | ret = cli_to_glusterd (&req, frame, gf_cli_quota_cbk, |
3560 | (xdrproc_t) xdr_gf_cli_req, dict, |
3561 | GLUSTER_CLI_QUOTA, this, cli_rpc_prog, NULL((void*)0)); |
3562 | |
3563 | out: |
3564 | GF_FREE (req.dict.dict_val)__gf_free (req.dict.dict_val); |
3565 | |
3566 | return ret; |
3567 | } |
3568 | |
3569 | int32_t |
3570 | gf_cli_pmap_b2p (call_frame_t *frame, xlator_t *this, void *data) |
3571 | { |
3572 | pmap_port_by_brick_req req = {0,}; |
3573 | int ret = 0; |
3574 | dict_t *dict = NULL((void*)0); |
3575 | |
3576 | if (!frame || !this || !data) { |
3577 | ret = -1; |
3578 | goto out; |
3579 | } |
3580 | |
3581 | dict = data; |
3582 | |
3583 | ret = dict_get_str (dict, "brick", &req.brick); |
3584 | if (ret) |
3585 | goto out; |
3586 | |
3587 | ret = cli_cmd_submit (&req, frame, &cli_pmap_prog, |
3588 | GF_PMAP_PORTBYBRICK, NULL((void*)0), |
3589 | this, gf_cli_pmap_b2p_cbk, |
3590 | (xdrproc_t) xdr_pmap_port_by_brick_req); |
3591 | |
3592 | out: |
3593 | gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret)do { do { if (0) printf ("Returning %d", ret); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 3593, GF_LOG_DEBUG, "Returning %d" , ret); } while (0); |
3594 | |
3595 | return ret; |
3596 | } |
3597 | |
3598 | static int |
3599 | gf_cli_fsm_log_cbk (struct rpc_req *req, struct iovec *iov, |
3600 | int count, void *myframe) |
3601 | { |
3602 | gf1_cli_fsm_log_rsp rsp = {0,}; |
3603 | int ret = -1; |
3604 | dict_t *dict = NULL((void*)0); |
3605 | int tr_count = 0; |
3606 | char key[256] = {0}; |
3607 | int i = 0; |
3608 | char *old_state = NULL((void*)0); |
3609 | char *new_state = NULL((void*)0); |
3610 | char *event = NULL((void*)0); |
3611 | char *time = NULL((void*)0); |
3612 | |
3613 | if (-1 == req->rpc_status) { |
3614 | goto out; |
3615 | } |
3616 | |
3617 | ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf1_cli_fsm_log_rsp); |
3618 | if (ret < 0) { |
3619 | gf_log (((call_frame_t *) myframe)->this->name, GF_LOG_ERROR,do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (((call_frame_t *) myframe)->this->name, "cli-rpc-ops.c" , __FUNCTION__, 3620, GF_LOG_ERROR, "Failed to decode xdr response" ); } while (0) |
3620 | "Failed to decode xdr response")do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (((call_frame_t *) myframe)->this->name, "cli-rpc-ops.c" , __FUNCTION__, 3620, GF_LOG_ERROR, "Failed to decode xdr response" ); } while (0); |
3621 | goto out; |
3622 | } |
3623 | |
3624 | if (rsp.op_ret) { |
3625 | if (strcmp (rsp.op_errstr, "")) |
3626 | cli_err ("%s", rsp.op_errstr)do { do { if (0) printf ("%s", rsp.op_errstr); } while (0); _cli_err ("%s", rsp.op_errstr); } while (0); |
3627 | cli_err ("fsm log unsuccessful")do { do { if (0) printf ("fsm log unsuccessful"); } while (0) ; _cli_err("fsm log unsuccessful"); } while (0); |
3628 | ret = rsp.op_ret; |
3629 | goto out; |
3630 | } |
3631 | |
3632 | dict = dict_new (); |
3633 | if (!dict) { |
3634 | ret = -1; |
3635 | goto out; |
3636 | } |
3637 | |
3638 | ret = dict_unserialize (rsp.fsm_log.fsm_log_val, |
3639 | rsp.fsm_log.fsm_log_len, |
3640 | &dict); |
3641 | |
3642 | if (ret) { |
3643 | cli_err ("bad response")do { do { if (0) printf ("bad response"); } while (0); _cli_err ("bad response"); } while (0); |
3644 | goto out; |
3645 | } |
3646 | |
3647 | ret = dict_get_int32 (dict, "count", &tr_count); |
3648 | if (tr_count) |
3649 | cli_out("number of transitions: %d", tr_count)do { do { if (0) printf ("number of transitions: %d", tr_count ); } while (0); _cli_out("number of transitions: %d", tr_count ); } while (0); |
3650 | else |
3651 | cli_err("No transitions")do { do { if (0) printf ("No transitions"); } while (0); _cli_err ("No transitions"); } while (0); |
3652 | for (i = 0; i < tr_count; i++) { |
3653 | memset (key, 0, sizeof (key)); |
3654 | snprintf (key, sizeof (key), "log%d-old-state", i); |
3655 | ret = dict_get_str (dict, key, &old_state); |
3656 | if (ret) |
3657 | goto out; |
3658 | |
3659 | memset (key, 0, sizeof (key)); |
3660 | snprintf (key, sizeof (key), "log%d-event", i); |
3661 | ret = dict_get_str (dict, key, &event); |
3662 | if (ret) |
3663 | goto out; |
3664 | |
3665 | memset (key, 0, sizeof (key)); |
3666 | snprintf (key, sizeof (key), "log%d-new-state", i); |
3667 | ret = dict_get_str (dict, key, &new_state); |
3668 | if (ret) |
3669 | goto out; |
3670 | |
3671 | memset (key, 0, sizeof (key)); |
3672 | snprintf (key, sizeof (key), "log%d-time", i); |
3673 | ret = dict_get_str (dict, key, &time); |
3674 | if (ret) |
3675 | goto out; |
3676 | cli_out ("Old State: [%s]\n"do { do { if (0) printf ("Old State: [%s]\n" "New State: [%s]\n" "Event : [%s]\n" "timestamp: [%s]\n", old_state, new_state , event, time); } while (0); _cli_out("Old State: [%s]\n" "New State: [%s]\n" "Event : [%s]\n" "timestamp: [%s]\n", old_state, new_state , event, time); } while (0) |
3677 | "New State: [%s]\n"do { do { if (0) printf ("Old State: [%s]\n" "New State: [%s]\n" "Event : [%s]\n" "timestamp: [%s]\n", old_state, new_state , event, time); } while (0); _cli_out("Old State: [%s]\n" "New State: [%s]\n" "Event : [%s]\n" "timestamp: [%s]\n", old_state, new_state , event, time); } while (0) |
3678 | "Event : [%s]\n"do { do { if (0) printf ("Old State: [%s]\n" "New State: [%s]\n" "Event : [%s]\n" "timestamp: [%s]\n", old_state, new_state , event, time); } while (0); _cli_out("Old State: [%s]\n" "New State: [%s]\n" "Event : [%s]\n" "timestamp: [%s]\n", old_state, new_state , event, time); } while (0) |
3679 | "timestamp: [%s]\n", old_state, new_state, event, time)do { do { if (0) printf ("Old State: [%s]\n" "New State: [%s]\n" "Event : [%s]\n" "timestamp: [%s]\n", old_state, new_state , event, time); } while (0); _cli_out("Old State: [%s]\n" "New State: [%s]\n" "Event : [%s]\n" "timestamp: [%s]\n", old_state, new_state , event, time); } while (0); |
3680 | } |
3681 | |
3682 | ret = rsp.op_ret; |
3683 | |
3684 | out: |
3685 | cli_cmd_broadcast_response (ret); |
3686 | return ret; |
3687 | } |
3688 | |
3689 | int32_t |
3690 | gf_cli_fsm_log (call_frame_t *frame, xlator_t *this, void *data) |
3691 | { |
3692 | int ret = -1; |
3693 | gf1_cli_fsm_log_req req = {0,}; |
3694 | |
3695 | GF_ASSERT (frame)do { if (!(frame)) { do { do { if (0) printf ("Assertion failed: " "frame"); } while (0); _gf_log_callingfn ("", "cli-rpc-ops.c" , __FUNCTION__, 3695, GF_LOG_ERROR, "Assertion failed: " "frame" ); } while (0); } } while (0); |
3696 | GF_ASSERT (this)do { if (!(this)) { do { do { if (0) printf ("Assertion failed: " "this"); } while (0); _gf_log_callingfn ("", "cli-rpc-ops.c" , __FUNCTION__, 3696, GF_LOG_ERROR, "Assertion failed: " "this" ); } while (0); } } while (0); |
3697 | GF_ASSERT (data)do { if (!(data)) { do { do { if (0) printf ("Assertion failed: " "data"); } while (0); _gf_log_callingfn ("", "cli-rpc-ops.c" , __FUNCTION__, 3697, GF_LOG_ERROR, "Assertion failed: " "data" ); } while (0); } } while (0); |
3698 | |
3699 | if (!frame || !this || !data) |
3700 | goto out; |
3701 | req.name = data; |
3702 | ret = cli_cmd_submit (&req, frame, cli_rpc_prog, |
3703 | GLUSTER_CLI_FSM_LOG, NULL((void*)0), |
3704 | this, gf_cli_fsm_log_cbk, |
3705 | (xdrproc_t) xdr_gf1_cli_fsm_log_req); |
3706 | |
3707 | out: |
3708 | gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret)do { do { if (0) printf ("Returning %d", ret); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 3708, GF_LOG_DEBUG, "Returning %d" , ret); } while (0); |
3709 | |
3710 | return ret; |
3711 | } |
3712 | |
3713 | int |
3714 | gf_cli_gsync_config_command (dict_t *dict) |
3715 | { |
3716 | runner_t runner = {0,}; |
3717 | char *subop = NULL((void*)0); |
3718 | char *gwd = NULL((void*)0); |
3719 | char *slave = NULL((void*)0); |
3720 | char *master = NULL((void*)0); |
3721 | char *op_name = NULL((void*)0); |
3722 | |
3723 | if (dict_get_str (dict, "subop", &subop) != 0) |
3724 | return -1; |
3725 | |
3726 | if (strcmp (subop, "get") != 0 && strcmp (subop, "get-all") != 0) { |
3727 | cli_out (GEOREP" config updated successfully")do { do { if (0) printf ("geo-replication"" config updated successfully" ); } while (0); _cli_out("geo-replication"" config updated successfully" ); } while (0); |
3728 | return 0; |
3729 | } |
3730 | |
3731 | if (dict_get_str (dict, "glusterd_workdir", &gwd) != 0 || |
3732 | dict_get_str (dict, "slave", &slave) != 0) |
3733 | return -1; |
3734 | |
3735 | if (dict_get_str (dict, "master", &master) != 0) |
3736 | master = NULL((void*)0); |
3737 | if (dict_get_str (dict, "op_name", &op_name) != 0) |
3738 | op_name = NULL((void*)0); |
3739 | |
3740 | runinit (&runner); |
3741 | runner_add_args (&runner, GSYNCD_PREFIX"/usr/local/libexec/glusterfs""/gsyncd", "-c", NULL((void*)0)); |
3742 | runner_argprintf (&runner, "%s/"GSYNC_CONF"geo-replication""/gsyncd.conf", gwd); |
3743 | if (master) |
3744 | runner_argprintf (&runner, ":%s", master); |
3745 | runner_add_arg (&runner, slave); |
3746 | runner_argprintf (&runner, "--config-%s", subop); |
3747 | if (op_name) |
3748 | runner_add_arg (&runner, op_name); |
3749 | |
3750 | return runner_run (&runner); |
3751 | } |
3752 | |
3753 | int |
3754 | gf_cli_gsync_out_status (dict_t *dict) |
3755 | { |
3756 | int gsync_count = 0; |
3757 | int i = 0; |
3758 | int ret = 0; |
3759 | char mst[PATH_MAX4096] = {0, }; |
3760 | char slv[PATH_MAX4096] = {0, }; |
3761 | char sts[PATH_MAX4096] = {0, }; |
3762 | char nds[PATH_MAX4096] = {0, }; |
3763 | char hyphens[100] = {0, }; |
3764 | char *mst_val = NULL((void*)0); |
3765 | char *slv_val = NULL((void*)0); |
3766 | char *sts_val = NULL((void*)0); |
3767 | char *nds_val = NULL((void*)0); |
3768 | |
3769 | cli_out ("%-20s %-20s %-50s %-10s", "NODE", "MASTER", "SLAVE", "STATUS")do { do { if (0) printf ("%-20s %-20s %-50s %-10s", "NODE", "MASTER" , "SLAVE", "STATUS"); } while (0); _cli_out("%-20s %-20s %-50s %-10s" , "NODE", "MASTER", "SLAVE", "STATUS"); } while (0); |
3770 | |
3771 | for (i=0; i<sizeof(hyphens)-1; i++) |
3772 | hyphens[i] = '-'; |
3773 | |
3774 | cli_out ("%s", hyphens)do { do { if (0) printf ("%s", hyphens); } while (0); _cli_out ("%s", hyphens); } while (0); |
3775 | |
3776 | |
3777 | ret = dict_get_int32 (dict, "gsync-count", &gsync_count); |
3778 | if (ret) { |
3779 | gf_log ("cli", GF_LOG_INFO, "No active geo-replication sessions"do { do { if (0) printf ("No active geo-replication sessions" "present for the selected"); } while (0); _gf_log ("cli", "cli-rpc-ops.c" , __FUNCTION__, 3780, GF_LOG_INFO, "No active geo-replication sessions" "present for the selected"); } while (0) |
3780 | "present for the selected")do { do { if (0) printf ("No active geo-replication sessions" "present for the selected"); } while (0); _gf_log ("cli", "cli-rpc-ops.c" , __FUNCTION__, 3780, GF_LOG_INFO, "No active geo-replication sessions" "present for the selected"); } while (0); |
3781 | ret = 0; |
3782 | goto out; |
3783 | } |
3784 | |
3785 | for (i = 1; i <= gsync_count; i++) { |
3786 | snprintf (nds, sizeof(nds), "node%d", i); |
3787 | snprintf (mst, sizeof(mst), "master%d", i); |
3788 | snprintf (slv, sizeof(slv), "slave%d", i); |
3789 | snprintf (sts, sizeof(sts), "status%d", i); |
3790 | |
3791 | ret = dict_get_str (dict, nds, &nds_val); |
3792 | if (ret) |
3793 | goto out; |
3794 | |
3795 | ret = dict_get_str (dict, mst, &mst_val); |
3796 | if (ret) |
3797 | goto out; |
3798 | |
3799 | ret = dict_get_str (dict, slv, &slv_val); |
3800 | if (ret) |
3801 | goto out; |
3802 | |
3803 | ret = dict_get_str (dict, sts, &sts_val); |
3804 | if (ret) |
3805 | goto out; |
3806 | |
3807 | cli_out ("%-20s %-20s %-50s %-10s", nds_val, mst_val,do { do { if (0) printf ("%-20s %-20s %-50s %-10s", nds_val, mst_val , slv_val, sts_val); } while (0); _cli_out("%-20s %-20s %-50s %-10s" , nds_val, mst_val, slv_val, sts_val); } while (0) |
3808 | slv_val, sts_val)do { do { if (0) printf ("%-20s %-20s %-50s %-10s", nds_val, mst_val , slv_val, sts_val); } while (0); _cli_out("%-20s %-20s %-50s %-10s" , nds_val, mst_val, slv_val, sts_val); } while (0); |
3809 | |
3810 | } |
3811 | |
3812 | out: |
3813 | return ret; |
3814 | |
3815 | } |
3816 | |
3817 | int |
3818 | gf_cli_gsync_set_cbk (struct rpc_req *req, struct iovec *iov, |
3819 | int count, void *myframe) |
3820 | { |
3821 | int ret = -1; |
3822 | gf_cli_rsp rsp = {0, }; |
3823 | dict_t *dict = NULL((void*)0); |
3824 | char *gsync_status = NULL((void*)0); |
3825 | char *master = NULL((void*)0); |
3826 | char *slave = NULL((void*)0); |
3827 | int32_t type = 0; |
3828 | call_frame_t *frame = NULL((void*)0); |
3829 | |
3830 | if (req->rpc_status == -1) { |
3831 | ret = -1; |
3832 | goto out; |
3833 | } |
3834 | |
3835 | frame = myframe; |
3836 | |
3837 | ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_cli_rsp); |
3838 | if (ret < 0) { |
3839 | gf_log (frame->this->name, GF_LOG_ERROR,do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__ , 3840, GF_LOG_ERROR, "Failed to decode xdr response"); } while (0) |
3840 | "Failed to decode xdr response")do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__ , 3840, GF_LOG_ERROR, "Failed to decode xdr response"); } while (0); |
3841 | goto out; |
3842 | } |
3843 | |
3844 | dict = dict_new (); |
3845 | |
3846 | if (!dict) { |
3847 | ret = -1; |
3848 | goto out; |
3849 | } |
3850 | |
3851 | ret = dict_unserialize (rsp.dict.dict_val, rsp.dict.dict_len, &dict); |
3852 | |
3853 | if (ret) |
3854 | goto out; |
3855 | |
3856 | if (global_state->mode & GLUSTER_MODE_XML(1 << 2)) { |
3857 | ret = cli_xml_output_vol_gsync (dict, rsp.op_ret, rsp.op_errno, |
3858 | rsp.op_errstr); |
3859 | if (ret) |
3860 | gf_log ("cli", GF_LOG_ERROR,do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 3861, GF_LOG_ERROR , "Error outputting to xml"); } while (0) |
3861 | "Error outputting to xml")do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 3861, GF_LOG_ERROR , "Error outputting to xml"); } while (0); |
3862 | goto out; |
3863 | } |
3864 | |
3865 | if (rsp.op_ret) { |
3866 | cli_err ("%s", rsp.op_errstr ? rsp.op_errstr :do { do { if (0) printf ("%s", rsp.op_errstr ? rsp.op_errstr : "geo-replication"" command unsuccessful"); } while (0); _cli_err ("%s", rsp.op_errstr ? rsp.op_errstr : "geo-replication"" command unsuccessful" ); } while (0) |
3867 | GEOREP" command unsuccessful")do { do { if (0) printf ("%s", rsp.op_errstr ? rsp.op_errstr : "geo-replication"" command unsuccessful"); } while (0); _cli_err ("%s", rsp.op_errstr ? rsp.op_errstr : "geo-replication"" command unsuccessful" ); } while (0); |
3868 | ret = rsp.op_ret; |
3869 | goto out; |
3870 | } |
3871 | |
3872 | ret = dict_get_str (dict, "gsync-status", &gsync_status); |
3873 | if (!ret) |
3874 | cli_out ("%s", gsync_status)do { do { if (0) printf ("%s", gsync_status); } while (0); _cli_out ("%s", gsync_status); } while (0); |
3875 | else |
3876 | ret = 0; |
3877 | |
3878 | ret = dict_get_int32 (dict, "type", &type); |
3879 | if (ret) { |
3880 | gf_log (frame->this->name, GF_LOG_ERROR, "failed to get type")do { do { if (0) printf ("failed to get type"); } while (0); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__, 3880 , GF_LOG_ERROR, "failed to get type"); } while (0); |
3881 | goto out; |
3882 | } |
3883 | |
3884 | switch (type) { |
3885 | case GF_GSYNC_OPTION_TYPE_START: |
3886 | case GF_GSYNC_OPTION_TYPE_STOP: |
3887 | if (dict_get_str (dict, "master", &master) != 0) |
3888 | master = "???"; |
3889 | if (dict_get_str (dict, "slave", &slave) != 0) |
3890 | slave = "???"; |
3891 | |
3892 | cli_out ("%s " GEOREP " session between %s & %s"do { do { if (0) printf ("%s " "geo-replication" " session between %s & %s" " has been successful", type == GF_GSYNC_OPTION_TYPE_START ? "Starting" : "Stopping", master, slave); } while (0); _cli_out ("%s " "geo-replication" " session between %s & %s" " has been successful" , type == GF_GSYNC_OPTION_TYPE_START ? "Starting" : "Stopping" , master, slave); } while (0) |
3893 | " has been successful",do { do { if (0) printf ("%s " "geo-replication" " session between %s & %s" " has been successful", type == GF_GSYNC_OPTION_TYPE_START ? "Starting" : "Stopping", master, slave); } while (0); _cli_out ("%s " "geo-replication" " session between %s & %s" " has been successful" , type == GF_GSYNC_OPTION_TYPE_START ? "Starting" : "Stopping" , master, slave); } while (0) |
3894 | type == GF_GSYNC_OPTION_TYPE_START ?do { do { if (0) printf ("%s " "geo-replication" " session between %s & %s" " has been successful", type == GF_GSYNC_OPTION_TYPE_START ? "Starting" : "Stopping", master, slave); } while (0); _cli_out ("%s " "geo-replication" " session between %s & %s" " has been successful" , type == GF_GSYNC_OPTION_TYPE_START ? "Starting" : "Stopping" , master, slave); } while (0) |
3895 | "Starting" : "Stopping",do { do { if (0) printf ("%s " "geo-replication" " session between %s & %s" " has been successful", type == GF_GSYNC_OPTION_TYPE_START ? "Starting" : "Stopping", master, slave); } while (0); _cli_out ("%s " "geo-replication" " session between %s & %s" " has been successful" , type == GF_GSYNC_OPTION_TYPE_START ? "Starting" : "Stopping" , master, slave); } while (0) |
3896 | master, slave)do { do { if (0) printf ("%s " "geo-replication" " session between %s & %s" " has been successful", type == GF_GSYNC_OPTION_TYPE_START ? "Starting" : "Stopping", master, slave); } while (0); _cli_out ("%s " "geo-replication" " session between %s & %s" " has been successful" , type == GF_GSYNC_OPTION_TYPE_START ? "Starting" : "Stopping" , master, slave); } while (0); |
3897 | break; |
3898 | |
3899 | case GF_GSYNC_OPTION_TYPE_CONFIG: |
3900 | ret = gf_cli_gsync_config_command (dict); |
3901 | break; |
3902 | |
3903 | case GF_GSYNC_OPTION_TYPE_STATUS: |
3904 | ret = gf_cli_gsync_out_status (dict); |
3905 | goto out; |
3906 | default: |
3907 | cli_out (GEOREP" command executed successfully")do { do { if (0) printf ("geo-replication"" command executed successfully" ); } while (0); _cli_out("geo-replication"" command executed successfully" ); } while (0); |
3908 | } |
3909 | |
3910 | out: |
3911 | if (dict) |
3912 | dict_unref (dict); |
3913 | cli_cmd_broadcast_response (ret); |
3914 | |
3915 | free (rsp.dict.dict_val); |
3916 | |
3917 | return ret; |
3918 | } |
3919 | |
3920 | int32_t |
3921 | gf_cli_gsync_set (call_frame_t *frame, xlator_t *this, |
3922 | void *data) |
3923 | { |
3924 | int ret = 0; |
3925 | dict_t *dict = NULL((void*)0); |
3926 | gf_cli_req req = {{0,}}; |
3927 | |
3928 | if (!frame || !this || !data) { |
3929 | ret = -1; |
3930 | goto out; |
3931 | } |
3932 | |
3933 | dict = data; |
3934 | |
3935 | ret = cli_to_glusterd (&req, frame, gf_cli_gsync_set_cbk, |
3936 | (xdrproc_t) xdr_gf_cli_req, dict, |
3937 | GLUSTER_CLI_GSYNC_SET, this, cli_rpc_prog, |
3938 | NULL((void*)0)); |
3939 | |
3940 | out: |
3941 | GF_FREE (req.dict.dict_val)__gf_free (req.dict.dict_val); |
3942 | |
3943 | return ret; |
3944 | } |
3945 | |
3946 | |
3947 | int |
3948 | cli_profile_info_percentage_cmp (void *a, void *b) |
3949 | { |
3950 | cli_profile_info_t *ia = NULL((void*)0); |
3951 | cli_profile_info_t *ib = NULL((void*)0); |
3952 | int ret = 0; |
3953 | |
3954 | ia = a; |
3955 | ib = b; |
3956 | if (ia->percentage_avg_latency < ib->percentage_avg_latency) |
3957 | ret = -1; |
3958 | else if (ia->percentage_avg_latency > ib->percentage_avg_latency) |
3959 | ret = 1; |
3960 | else |
3961 | ret = 0; |
3962 | return ret; |
3963 | } |
3964 | |
3965 | |
3966 | void |
3967 | cmd_profile_volume_brick_out (dict_t *dict, int count, int interval) |
3968 | { |
3969 | char key[256] = {0}; |
3970 | int i = 0; |
3971 | uint64_t sec = 0; |
3972 | uint64_t r_count = 0; |
3973 | uint64_t w_count = 0; |
3974 | uint64_t rb_counts[32] = {0}; |
3975 | uint64_t wb_counts[32] = {0}; |
3976 | cli_profile_info_t profile_info[GF_FOP_MAXVALUE] = {{0}}; |
3977 | char output[128] = {0}; |
3978 | int per_line = 0; |
3979 | char read_blocks[128] = {0}; |
3980 | char write_blocks[128] = {0}; |
3981 | int index = 0; |
3982 | int is_header_printed = 0; |
3983 | int ret = 0; |
3984 | double total_percentage_latency = 0; |
3985 | |
3986 | for (i = 0; i < 32; i++) { |
3987 | memset (key, 0, sizeof (key)); |
3988 | snprintf (key, sizeof (key), "%d-%d-read-%d", count, |
3989 | interval, (1 << i)); |
3990 | ret = dict_get_uint64 (dict, key, &rb_counts[i]); |
3991 | } |
3992 | |
3993 | for (i = 0; i < 32; i++) { |
3994 | memset (key, 0, sizeof (key)); |
3995 | snprintf (key, sizeof (key), "%d-%d-write-%d", count, interval, |
3996 | (1<<i)); |
3997 | ret = dict_get_uint64 (dict, key, &wb_counts[i]); |
3998 | } |
3999 | |
4000 | for (i = 0; i < GF_FOP_MAXVALUE; i++) { |
4001 | memset (key, 0, sizeof (key)); |
4002 | snprintf (key, sizeof (key), "%d-%d-%d-hits", count, |
4003 | interval, i); |
4004 | ret = dict_get_uint64 (dict, key, &profile_info[i].fop_hits); |
4005 | |
4006 | memset (key, 0, sizeof (key)); |
4007 | snprintf (key, sizeof (key), "%d-%d-%d-avglatency", count, |
4008 | interval, i); |
4009 | ret = dict_get_double (dict, key, &profile_info[i].avg_latency); |
4010 | |
4011 | memset (key, 0, sizeof (key)); |
4012 | snprintf (key, sizeof (key), "%d-%d-%d-minlatency", count, |
4013 | interval, i); |
4014 | ret = dict_get_double (dict, key, &profile_info[i].min_latency); |
4015 | |
4016 | memset (key, 0, sizeof (key)); |
4017 | snprintf (key, sizeof (key), "%d-%d-%d-maxlatency", count, |
4018 | interval, i); |
4019 | ret = dict_get_double (dict, key, &profile_info[i].max_latency); |
4020 | profile_info[i].fop_name = (char *)gf_fop_list[i]; |
4021 | |
4022 | total_percentage_latency += |
4023 | (profile_info[i].fop_hits * profile_info[i].avg_latency); |
4024 | } |
4025 | if (total_percentage_latency) { |
4026 | for (i = 0; i < GF_FOP_MAXVALUE; i++) { |
4027 | profile_info[i].percentage_avg_latency = 100 * ( |
4028 | (profile_info[i].avg_latency* profile_info[i].fop_hits) / |
4029 | total_percentage_latency); |
4030 | } |
4031 | gf_array_insertionsort (profile_info, 1, GF_FOP_MAXVALUE - 1, |
4032 | sizeof (cli_profile_info_t), |
4033 | cli_profile_info_percentage_cmp); |
4034 | } |
4035 | memset (key, 0, sizeof (key)); |
4036 | snprintf (key, sizeof (key), "%d-%d-duration", count, interval); |
4037 | ret = dict_get_uint64 (dict, key, &sec); |
4038 | |
4039 | memset (key, 0, sizeof (key)); |
4040 | snprintf (key, sizeof (key), "%d-%d-total-read", count, interval); |
4041 | ret = dict_get_uint64 (dict, key, &r_count); |
4042 | |
4043 | memset (key, 0, sizeof (key)); |
4044 | snprintf (key, sizeof (key), "%d-%d-total-write", count, interval); |
4045 | ret = dict_get_uint64 (dict, key, &w_count); |
4046 | |
4047 | if (ret == 0) { |
4048 | } |
4049 | |
4050 | if (interval == -1) |
4051 | cli_out ("Cumulative Stats:")do { do { if (0) printf ("Cumulative Stats:"); } while (0); _cli_out ("Cumulative Stats:"); } while (0); |
4052 | else |
4053 | cli_out ("Interval %d Stats:", interval)do { do { if (0) printf ("Interval %d Stats:", interval); } while (0); _cli_out("Interval %d Stats:", interval); } while (0); |
4054 | snprintf (output, sizeof (output), "%14s", "Block Size:"); |
4055 | snprintf (read_blocks, sizeof (read_blocks), "%14s", "No. of Reads:"); |
4056 | snprintf (write_blocks, sizeof (write_blocks), "%14s", "No. of Writes:"); |
4057 | index = 14; |
4058 | for (i = 0; i < 32; i++) { |
4059 | if ((rb_counts[i] == 0) && (wb_counts[i] == 0)) |
4060 | continue; |
4061 | per_line++; |
4062 | snprintf (output+index, sizeof (output)-index, "%19db+ ", (1<<i)); |
4063 | if (rb_counts[i]) { |
4064 | snprintf (read_blocks+index, sizeof (read_blocks)-index, |
4065 | "%21"PRId64"ll" "d"" ", rb_counts[i]); |
4066 | } else { |
4067 | snprintf (read_blocks+index, sizeof (read_blocks)-index, |
4068 | "%21s ", "0"); |
4069 | } |
4070 | if (wb_counts[i]) { |
4071 | snprintf (write_blocks+index, sizeof (write_blocks)-index, |
4072 | "%21"PRId64"ll" "d"" ", wb_counts[i]); |
4073 | } else { |
4074 | snprintf (write_blocks+index, sizeof (write_blocks)-index, |
4075 | "%21s ", "0"); |
4076 | } |
4077 | index += 22; |
4078 | if (per_line == 3) { |
4079 | cli_out ("%s", output)do { do { if (0) printf ("%s", output); } while (0); _cli_out ("%s", output); } while (0); |
4080 | cli_out ("%s", read_blocks)do { do { if (0) printf ("%s", read_blocks); } while (0); _cli_out ("%s", read_blocks); } while (0); |
4081 | cli_out ("%s", write_blocks)do { do { if (0) printf ("%s", write_blocks); } while (0); _cli_out ("%s", write_blocks); } while (0); |
4082 | cli_out (" ")do { do { if (0) printf (" "); } while (0); _cli_out(" "); } while (0); |
4083 | per_line = 0; |
4084 | memset (output, 0, sizeof (output)); |
4085 | memset (read_blocks, 0, sizeof (read_blocks)); |
4086 | memset (write_blocks, 0, sizeof (write_blocks)); |
4087 | snprintf (output, sizeof (output), "%14s", "Block Size:"); |
4088 | snprintf (read_blocks, sizeof (read_blocks), "%14s", |
4089 | "No. of Reads:"); |
4090 | snprintf (write_blocks, sizeof (write_blocks), "%14s", |
4091 | "No. of Writes:"); |
4092 | index = 14; |
4093 | } |
4094 | } |
4095 | |
4096 | if (per_line != 0) { |
4097 | cli_out ("%s", output)do { do { if (0) printf ("%s", output); } while (0); _cli_out ("%s", output); } while (0); |
4098 | cli_out ("%s", read_blocks)do { do { if (0) printf ("%s", read_blocks); } while (0); _cli_out ("%s", read_blocks); } while (0); |
4099 | cli_out ("%s", write_blocks)do { do { if (0) printf ("%s", write_blocks); } while (0); _cli_out ("%s", write_blocks); } while (0); |
4100 | } |
4101 | for (i = 0; i < GF_FOP_MAXVALUE; i++) { |
4102 | if (profile_info[i].fop_hits == 0) |
4103 | continue; |
4104 | if (is_header_printed == 0) { |
4105 | cli_out ("%10s %13s %13s %13s %14s %11s", "%-latency",do { do { if (0) printf ("%10s %13s %13s %13s %14s %11s", "%-latency" , "Avg-latency", "Min-Latency", "Max-Latency", "No. of calls" , "Fop"); } while (0); _cli_out("%10s %13s %13s %13s %14s %11s" , "%-latency", "Avg-latency", "Min-Latency", "Max-Latency", "No. of calls" , "Fop"); } while (0) |
4106 | "Avg-latency", "Min-Latency", "Max-Latency",do { do { if (0) printf ("%10s %13s %13s %13s %14s %11s", "%-latency" , "Avg-latency", "Min-Latency", "Max-Latency", "No. of calls" , "Fop"); } while (0); _cli_out("%10s %13s %13s %13s %14s %11s" , "%-latency", "Avg-latency", "Min-Latency", "Max-Latency", "No. of calls" , "Fop"); } while (0) |
4107 | "No. of calls", "Fop")do { do { if (0) printf ("%10s %13s %13s %13s %14s %11s", "%-latency" , "Avg-latency", "Min-Latency", "Max-Latency", "No. of calls" , "Fop"); } while (0); _cli_out("%10s %13s %13s %13s %14s %11s" , "%-latency", "Avg-latency", "Min-Latency", "Max-Latency", "No. of calls" , "Fop"); } while (0); |
4108 | cli_out ("%10s %13s %13s %13s %14s %11s", "---------",do { do { if (0) printf ("%10s %13s %13s %13s %14s %11s", "---------" , "-----------", "-----------", "-----------", "------------" , "----"); } while (0); _cli_out("%10s %13s %13s %13s %14s %11s" , "---------", "-----------", "-----------", "-----------", "------------" , "----"); } while (0) |
4109 | "-----------", "-----------", "-----------",do { do { if (0) printf ("%10s %13s %13s %13s %14s %11s", "---------" , "-----------", "-----------", "-----------", "------------" , "----"); } while (0); _cli_out("%10s %13s %13s %13s %14s %11s" , "---------", "-----------", "-----------", "-----------", "------------" , "----"); } while (0) |
4110 | "------------", "----")do { do { if (0) printf ("%10s %13s %13s %13s %14s %11s", "---------" , "-----------", "-----------", "-----------", "------------" , "----"); } while (0); _cli_out("%10s %13s %13s %13s %14s %11s" , "---------", "-----------", "-----------", "-----------", "------------" , "----"); } while (0); |
4111 | is_header_printed = 1; |
4112 | } |
4113 | if (profile_info[i].fop_hits) { |
4114 | cli_out ("%10.2lf %10.2lf us %10.2lf us %10.2lf us"do { do { if (0) printf ("%10.2lf %10.2lf us %10.2lf us %10.2lf us" " %14""ll" "d"" %11s", profile_info[i].percentage_avg_latency , profile_info[i].avg_latency, profile_info[i].min_latency, profile_info [i].max_latency, profile_info[i].fop_hits, profile_info[i].fop_name ); } while (0); _cli_out("%10.2lf %10.2lf us %10.2lf us %10.2lf us" " %14""ll" "d"" %11s", profile_info[i].percentage_avg_latency , profile_info[i].avg_latency, profile_info[i].min_latency, profile_info [i].max_latency, profile_info[i].fop_hits, profile_info[i].fop_name ); } while (0) |
4115 | " %14"PRId64" %11s",do { do { if (0) printf ("%10.2lf %10.2lf us %10.2lf us %10.2lf us" " %14""ll" "d"" %11s", profile_info[i].percentage_avg_latency , profile_info[i].avg_latency, profile_info[i].min_latency, profile_info [i].max_latency, profile_info[i].fop_hits, profile_info[i].fop_name ); } while (0); _cli_out("%10.2lf %10.2lf us %10.2lf us %10.2lf us" " %14""ll" "d"" %11s", profile_info[i].percentage_avg_latency , profile_info[i].avg_latency, profile_info[i].min_latency, profile_info [i].max_latency, profile_info[i].fop_hits, profile_info[i].fop_name ); } while (0) |
4116 | profile_info[i].percentage_avg_latency,do { do { if (0) printf ("%10.2lf %10.2lf us %10.2lf us %10.2lf us" " %14""ll" "d"" %11s", profile_info[i].percentage_avg_latency , profile_info[i].avg_latency, profile_info[i].min_latency, profile_info [i].max_latency, profile_info[i].fop_hits, profile_info[i].fop_name ); } while (0); _cli_out("%10.2lf %10.2lf us %10.2lf us %10.2lf us" " %14""ll" "d"" %11s", profile_info[i].percentage_avg_latency , profile_info[i].avg_latency, profile_info[i].min_latency, profile_info [i].max_latency, profile_info[i].fop_hits, profile_info[i].fop_name ); } while (0) |
4117 | profile_info[i].avg_latency,do { do { if (0) printf ("%10.2lf %10.2lf us %10.2lf us %10.2lf us" " %14""ll" "d"" %11s", profile_info[i].percentage_avg_latency , profile_info[i].avg_latency, profile_info[i].min_latency, profile_info [i].max_latency, profile_info[i].fop_hits, profile_info[i].fop_name ); } while (0); _cli_out("%10.2lf %10.2lf us %10.2lf us %10.2lf us" " %14""ll" "d"" %11s", profile_info[i].percentage_avg_latency , profile_info[i].avg_latency, profile_info[i].min_latency, profile_info [i].max_latency, profile_info[i].fop_hits, profile_info[i].fop_name ); } while (0) |
4118 | profile_info[i].min_latency,do { do { if (0) printf ("%10.2lf %10.2lf us %10.2lf us %10.2lf us" " %14""ll" "d"" %11s", profile_info[i].percentage_avg_latency , profile_info[i].avg_latency, profile_info[i].min_latency, profile_info [i].max_latency, profile_info[i].fop_hits, profile_info[i].fop_name ); } while (0); _cli_out("%10.2lf %10.2lf us %10.2lf us %10.2lf us" " %14""ll" "d"" %11s", profile_info[i].percentage_avg_latency , profile_info[i].avg_latency, profile_info[i].min_latency, profile_info [i].max_latency, profile_info[i].fop_hits, profile_info[i].fop_name ); } while (0) |
4119 | profile_info[i].max_latency,do { do { if (0) printf ("%10.2lf %10.2lf us %10.2lf us %10.2lf us" " %14""ll" "d"" %11s", profile_info[i].percentage_avg_latency , profile_info[i].avg_latency, profile_info[i].min_latency, profile_info [i].max_latency, profile_info[i].fop_hits, profile_info[i].fop_name ); } while (0); _cli_out("%10.2lf %10.2lf us %10.2lf us %10.2lf us" " %14""ll" "d"" %11s", profile_info[i].percentage_avg_latency , profile_info[i].avg_latency, profile_info[i].min_latency, profile_info [i].max_latency, profile_info[i].fop_hits, profile_info[i].fop_name ); } while (0) |
4120 | profile_info[i].fop_hits,do { do { if (0) printf ("%10.2lf %10.2lf us %10.2lf us %10.2lf us" " %14""ll" "d"" %11s", profile_info[i].percentage_avg_latency , profile_info[i].avg_latency, profile_info[i].min_latency, profile_info [i].max_latency, profile_info[i].fop_hits, profile_info[i].fop_name ); } while (0); _cli_out("%10.2lf %10.2lf us %10.2lf us %10.2lf us" " %14""ll" "d"" %11s", profile_info[i].percentage_avg_latency , profile_info[i].avg_latency, profile_info[i].min_latency, profile_info [i].max_latency, profile_info[i].fop_hits, profile_info[i].fop_name ); } while (0) |
4121 | profile_info[i].fop_name)do { do { if (0) printf ("%10.2lf %10.2lf us %10.2lf us %10.2lf us" " %14""ll" "d"" %11s", profile_info[i].percentage_avg_latency , profile_info[i].avg_latency, profile_info[i].min_latency, profile_info [i].max_latency, profile_info[i].fop_hits, profile_info[i].fop_name ); } while (0); _cli_out("%10.2lf %10.2lf us %10.2lf us %10.2lf us" " %14""ll" "d"" %11s", profile_info[i].percentage_avg_latency , profile_info[i].avg_latency, profile_info[i].min_latency, profile_info [i].max_latency, profile_info[i].fop_hits, profile_info[i].fop_name ); } while (0); |
4122 | } |
4123 | } |
4124 | cli_out (" ")do { do { if (0) printf (" "); } while (0); _cli_out(" "); } while (0); |
4125 | cli_out ("%12s: %"PRId64" seconds", "Duration", sec)do { do { if (0) printf ("%12s: %""ll" "d"" seconds", "Duration" , sec); } while (0); _cli_out("%12s: %""ll" "d"" seconds", "Duration" , sec); } while (0); |
4126 | cli_out ("%12s: %"PRId64" bytes", "Data Read", r_count)do { do { if (0) printf ("%12s: %""ll" "d"" bytes", "Data Read" , r_count); } while (0); _cli_out("%12s: %""ll" "d"" bytes", "Data Read" , r_count); } while (0); |
4127 | cli_out ("%12s: %"PRId64" bytes", "Data Written", w_count)do { do { if (0) printf ("%12s: %""ll" "d"" bytes", "Data Written" , w_count); } while (0); _cli_out("%12s: %""ll" "d"" bytes", "Data Written" , w_count); } while (0); |
4128 | cli_out (" ")do { do { if (0) printf (" "); } while (0); _cli_out(" "); } while (0); |
4129 | } |
4130 | |
4131 | int32_t |
4132 | gf_cli_profile_volume_cbk (struct rpc_req *req, struct iovec *iov, |
4133 | int count, void *myframe) |
4134 | { |
4135 | gf_cli_rsp rsp = {0,}; |
4136 | int ret = -1; |
4137 | dict_t *dict = NULL((void*)0); |
4138 | gf1_cli_stats_op op = GF_CLI_STATS_NONE; |
4139 | char key[256] = {0}; |
4140 | int interval = 0; |
4141 | int i = 1; |
4142 | int32_t brick_count = 0; |
4143 | char *volname = NULL((void*)0); |
4144 | char *brick = NULL((void*)0); |
4145 | char str[1024] = {0,}; |
4146 | |
4147 | if (-1 == req->rpc_status) { |
4148 | goto out; |
4149 | } |
4150 | |
4151 | gf_log ("cli", GF_LOG_DEBUG, "Received resp to profile")do { do { if (0) printf ("Received resp to profile"); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 4151, GF_LOG_DEBUG , "Received resp to profile"); } while (0); |
4152 | ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_cli_rsp); |
4153 | if (ret < 0) { |
4154 | gf_log (((call_frame_t *) myframe)->this->name, GF_LOG_ERROR,do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (((call_frame_t *) myframe)->this->name, "cli-rpc-ops.c" , __FUNCTION__, 4155, GF_LOG_ERROR, "Failed to decode xdr response" ); } while (0) |
4155 | "Failed to decode xdr response")do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (((call_frame_t *) myframe)->this->name, "cli-rpc-ops.c" , __FUNCTION__, 4155, GF_LOG_ERROR, "Failed to decode xdr response" ); } while (0); |
4156 | goto out; |
4157 | } |
4158 | |
4159 | dict = dict_new (); |
4160 | |
4161 | if (!dict) { |
4162 | ret = -1; |
4163 | goto out; |
4164 | } |
4165 | |
4166 | ret = dict_unserialize (rsp.dict.dict_val, |
4167 | rsp.dict.dict_len, |
4168 | &dict); |
4169 | |
4170 | if (ret) { |
4171 | gf_log ("", GF_LOG_ERROR,do { do { if (0) printf ("Unable to allocate memory"); } while (0); _gf_log ("", "cli-rpc-ops.c", __FUNCTION__, 4172, GF_LOG_ERROR , "Unable to allocate memory"); } while (0) |
4172 | "Unable to allocate memory")do { do { if (0) printf ("Unable to allocate memory"); } while (0); _gf_log ("", "cli-rpc-ops.c", __FUNCTION__, 4172, GF_LOG_ERROR , "Unable to allocate memory"); } while (0); |
4173 | goto out; |
4174 | } else { |
4175 | dict->extra_stdfree = rsp.dict.dict_val; |
4176 | } |
4177 | |
4178 | if (global_state->mode & GLUSTER_MODE_XML(1 << 2)) { |
4179 | ret = cli_xml_output_vol_profile (dict, rsp.op_ret, |
4180 | rsp.op_errno, |
4181 | rsp.op_errstr); |
4182 | if (ret) |
4183 | gf_log ("cli", GF_LOG_ERROR,do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 4184, GF_LOG_ERROR , "Error outputting to xml"); } while (0) |
4184 | "Error outputting to xml")do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 4184, GF_LOG_ERROR , "Error outputting to xml"); } while (0); |
4185 | goto out; |
4186 | } |
4187 | |
4188 | ret = dict_get_str (dict, "volname", &volname); |
4189 | if (ret) |
4190 | goto out; |
4191 | |
4192 | ret = dict_get_int32 (dict, "op", (int32_t*)&op); |
4193 | if (ret) |
4194 | goto out; |
4195 | |
4196 | if (rsp.op_ret && strcmp (rsp.op_errstr, "")) { |
4197 | cli_err ("%s", rsp.op_errstr)do { do { if (0) printf ("%s", rsp.op_errstr); } while (0); _cli_err ("%s", rsp.op_errstr); } while (0); |
4198 | } else { |
4199 | switch (op) { |
4200 | case GF_CLI_STATS_START: |
4201 | cli_out ("Starting volume profile on %s has been %s ",do { do { if (0) printf ("Starting volume profile on %s has been %s " , volname, (rsp.op_ret) ? "unsuccessful": "successful"); } while (0); _cli_out("Starting volume profile on %s has been %s ", volname , (rsp.op_ret) ? "unsuccessful": "successful"); } while (0) |
4202 | volname,do { do { if (0) printf ("Starting volume profile on %s has been %s " , volname, (rsp.op_ret) ? "unsuccessful": "successful"); } while (0); _cli_out("Starting volume profile on %s has been %s ", volname , (rsp.op_ret) ? "unsuccessful": "successful"); } while (0) |
4203 | (rsp.op_ret) ? "unsuccessful": "successful")do { do { if (0) printf ("Starting volume profile on %s has been %s " , volname, (rsp.op_ret) ? "unsuccessful": "successful"); } while (0); _cli_out("Starting volume profile on %s has been %s ", volname , (rsp.op_ret) ? "unsuccessful": "successful"); } while (0); |
4204 | break; |
4205 | case GF_CLI_STATS_STOP: |
4206 | cli_out ("Stopping volume profile on %s has been %s ",do { do { if (0) printf ("Stopping volume profile on %s has been %s " , volname, (rsp.op_ret) ? "unsuccessful": "successful"); } while (0); _cli_out("Stopping volume profile on %s has been %s ", volname , (rsp.op_ret) ? "unsuccessful": "successful"); } while (0) |
4207 | volname,do { do { if (0) printf ("Stopping volume profile on %s has been %s " , volname, (rsp.op_ret) ? "unsuccessful": "successful"); } while (0); _cli_out("Stopping volume profile on %s has been %s ", volname , (rsp.op_ret) ? "unsuccessful": "successful"); } while (0) |
4208 | (rsp.op_ret) ? "unsuccessful": "successful")do { do { if (0) printf ("Stopping volume profile on %s has been %s " , volname, (rsp.op_ret) ? "unsuccessful": "successful"); } while (0); _cli_out("Stopping volume profile on %s has been %s ", volname , (rsp.op_ret) ? "unsuccessful": "successful"); } while (0); |
4209 | break; |
4210 | case GF_CLI_STATS_INFO: |
4211 | break; |
4212 | default: |
4213 | cli_out ("volume profile on %s has been %s ",do { do { if (0) printf ("volume profile on %s has been %s ", volname, (rsp.op_ret) ? "unsuccessful": "successful"); } while (0); _cli_out("volume profile on %s has been %s ", volname, ( rsp.op_ret) ? "unsuccessful": "successful"); } while (0) |
4214 | volname,do { do { if (0) printf ("volume profile on %s has been %s ", volname, (rsp.op_ret) ? "unsuccessful": "successful"); } while (0); _cli_out("volume profile on %s has been %s ", volname, ( rsp.op_ret) ? "unsuccessful": "successful"); } while (0) |
4215 | (rsp.op_ret) ? "unsuccessful": "successful")do { do { if (0) printf ("volume profile on %s has been %s ", volname, (rsp.op_ret) ? "unsuccessful": "successful"); } while (0); _cli_out("volume profile on %s has been %s ", volname, ( rsp.op_ret) ? "unsuccessful": "successful"); } while (0); |
4216 | break; |
4217 | } |
4218 | } |
4219 | |
4220 | if (rsp.op_ret) { |
4221 | ret = rsp.op_ret; |
4222 | goto out; |
4223 | } |
4224 | |
4225 | if (op != GF_CLI_STATS_INFO) { |
4226 | ret = 0; |
4227 | goto out; |
4228 | } |
4229 | |
4230 | ret = dict_get_int32 (dict, "count", &brick_count); |
4231 | if (ret) |
4232 | goto out; |
4233 | |
4234 | if (!brick_count) { |
4235 | cli_err ("All bricks of volume %s are down.", volname)do { do { if (0) printf ("All bricks of volume %s are down.", volname); } while (0); _cli_err("All bricks of volume %s are down." , volname); } while (0); |
4236 | goto out; |
4237 | } |
4238 | |
4239 | while (i <= brick_count) { |
4240 | memset (key, 0, sizeof (key)); |
4241 | snprintf (key, sizeof (key), "%d-brick", i); |
4242 | ret = dict_get_str (dict, key, &brick); |
4243 | if (ret) { |
4244 | gf_log ("cli", GF_LOG_ERROR, "Couldn't get brick name")do { do { if (0) printf ("Couldn't get brick name"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 4244, GF_LOG_ERROR , "Couldn't get brick name"); } while (0); |
4245 | goto out; |
4246 | } |
4247 | |
4248 | ret = dict_get_str_boolean (dict, "nfs", _gf_false); |
4249 | if (ret) |
4250 | snprintf (str, sizeof (str), "NFS Server : %s", brick); |
4251 | else |
4252 | snprintf (str, sizeof (str), "Brick: %s", brick); |
4253 | cli_out ("%s", str)do { do { if (0) printf ("%s", str); } while (0); _cli_out("%s" , str); } while (0); |
4254 | memset (str, '-', strlen (str)); |
4255 | cli_out ("%s", str)do { do { if (0) printf ("%s", str); } while (0); _cli_out("%s" , str); } while (0); |
4256 | |
4257 | snprintf (key, sizeof (key), "%d-cumulative", i); |
4258 | ret = dict_get_int32 (dict, key, &interval); |
4259 | if (ret == 0) { |
4260 | cmd_profile_volume_brick_out (dict, i, interval); |
4261 | } |
4262 | snprintf (key, sizeof (key), "%d-interval", i); |
4263 | ret = dict_get_int32 (dict, key, &interval); |
4264 | if (ret == 0) { |
4265 | cmd_profile_volume_brick_out (dict, i, interval); |
4266 | } |
4267 | i++; |
4268 | } |
4269 | ret = rsp.op_ret; |
4270 | |
4271 | out: |
4272 | if (dict) |
4273 | dict_unref (dict); |
4274 | free (rsp.op_errstr); |
4275 | cli_cmd_broadcast_response (ret); |
4276 | return ret; |
4277 | } |
4278 | |
4279 | int32_t |
4280 | gf_cli_profile_volume (call_frame_t *frame, xlator_t *this, void *data) |
4281 | { |
4282 | int ret = -1; |
4283 | gf_cli_req req = {{0,}}; |
4284 | dict_t *dict = NULL((void*)0); |
4285 | |
4286 | GF_ASSERT (frame)do { if (!(frame)) { do { do { if (0) printf ("Assertion failed: " "frame"); } while (0); _gf_log_callingfn ("", "cli-rpc-ops.c" , __FUNCTION__, 4286, GF_LOG_ERROR, "Assertion failed: " "frame" ); } while (0); } } while (0); |
4287 | GF_ASSERT (this)do { if (!(this)) { do { do { if (0) printf ("Assertion failed: " "this"); } while (0); _gf_log_callingfn ("", "cli-rpc-ops.c" , __FUNCTION__, 4287, GF_LOG_ERROR, "Assertion failed: " "this" ); } while (0); } } while (0); |
4288 | GF_ASSERT (data)do { if (!(data)) { do { do { if (0) printf ("Assertion failed: " "data"); } while (0); _gf_log_callingfn ("", "cli-rpc-ops.c" , __FUNCTION__, 4288, GF_LOG_ERROR, "Assertion failed: " "data" ); } while (0); } } while (0); |
4289 | |
4290 | if (!frame || !this || !data) |
4291 | goto out; |
4292 | dict = data; |
4293 | |
4294 | ret = cli_to_glusterd (&req, frame, gf_cli_profile_volume_cbk, |
4295 | (xdrproc_t) xdr_gf_cli_req, dict, |
4296 | GLUSTER_CLI_PROFILE_VOLUME, this, cli_rpc_prog, |
4297 | NULL((void*)0)); |
4298 | |
4299 | out: |
4300 | gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret)do { do { if (0) printf ("Returning %d", ret); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 4300, GF_LOG_DEBUG, "Returning %d" , ret); } while (0); |
4301 | |
4302 | GF_FREE (req.dict.dict_val)__gf_free (req.dict.dict_val); |
4303 | return ret; |
4304 | } |
4305 | |
4306 | int32_t |
4307 | gf_cli_top_volume_cbk (struct rpc_req *req, struct iovec *iov, |
4308 | int count, void *myframe) |
4309 | { |
4310 | gf_cli_rsp rsp = {0,}; |
4311 | int ret = -1; |
4312 | dict_t *dict = NULL((void*)0); |
4313 | gf1_cli_stats_op op = GF_CLI_STATS_NONE; |
4314 | char key[256] = {0}; |
4315 | int i = 0; |
4316 | int32_t brick_count = 0; |
4317 | char brick[1024]; |
4318 | int32_t members = 0; |
4319 | char *filename; |
4320 | char *bricks; |
4321 | uint64_t value = 0; |
4322 | int32_t j = 0; |
4323 | gf1_cli_top_op top_op = GF_CLI_TOP_NONE; |
4324 | uint64_t nr_open = 0; |
4325 | uint64_t max_nr_open = 0; |
4326 | double throughput = 0; |
4327 | double time = 0; |
4328 | int32_t time_sec = 0; |
4329 | long int time_usec = 0; |
4330 | char timestr[256] = {0, }; |
4331 | char *openfd_str = NULL((void*)0); |
4332 | gf_boolean_t nfs = _gf_false; |
4333 | gf_boolean_t clear_stats = _gf_false; |
4334 | int stats_cleared = 0; |
4335 | |
4336 | if (-1 == req->rpc_status) { |
4337 | goto out; |
4338 | } |
4339 | |
4340 | gf_log ("cli", GF_LOG_DEBUG, "Received resp to top")do { do { if (0) printf ("Received resp to top"); } while (0) ; _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 4340, GF_LOG_DEBUG , "Received resp to top"); } while (0); |
4341 | ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_cli_rsp); |
4342 | if (ret < 0) { |
4343 | gf_log (((call_frame_t *) myframe)->this->name, GF_LOG_ERROR,do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (((call_frame_t *) myframe)->this->name, "cli-rpc-ops.c" , __FUNCTION__, 4344, GF_LOG_ERROR, "Failed to decode xdr response" ); } while (0) |
4344 | "Failed to decode xdr response")do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (((call_frame_t *) myframe)->this->name, "cli-rpc-ops.c" , __FUNCTION__, 4344, GF_LOG_ERROR, "Failed to decode xdr response" ); } while (0); |
4345 | goto out; |
4346 | } |
4347 | |
4348 | if (rsp.op_ret) { |
4349 | if (strcmp (rsp.op_errstr, "")) |
4350 | cli_err ("%s", rsp.op_errstr)do { do { if (0) printf ("%s", rsp.op_errstr); } while (0); _cli_err ("%s", rsp.op_errstr); } while (0); |
4351 | cli_err ("volume top unsuccessful")do { do { if (0) printf ("volume top unsuccessful"); } while ( 0); _cli_err("volume top unsuccessful"); } while (0); |
4352 | ret = rsp.op_ret; |
4353 | goto out; |
4354 | } |
4355 | |
4356 | dict = dict_new (); |
4357 | |
4358 | if (!dict) { |
4359 | ret = -1; |
4360 | goto out; |
4361 | } |
4362 | |
4363 | ret = dict_unserialize (rsp.dict.dict_val, |
4364 | rsp.dict.dict_len, |
4365 | &dict); |
4366 | |
4367 | if (ret) { |
4368 | gf_log ("", GF_LOG_ERROR,do { do { if (0) printf ("Unable to allocate memory"); } while (0); _gf_log ("", "cli-rpc-ops.c", __FUNCTION__, 4369, GF_LOG_ERROR , "Unable to allocate memory"); } while (0) |
4369 | "Unable to allocate memory")do { do { if (0) printf ("Unable to allocate memory"); } while (0); _gf_log ("", "cli-rpc-ops.c", __FUNCTION__, 4369, GF_LOG_ERROR , "Unable to allocate memory"); } while (0); |
4370 | goto out; |
4371 | } |
4372 | |
4373 | ret = dict_get_int32 (dict, "op", (int32_t*)&op); |
4374 | |
4375 | if (op != GF_CLI_STATS_TOP) { |
4376 | ret = 0; |
4377 | goto out; |
4378 | } |
4379 | |
4380 | if (global_state->mode & GLUSTER_MODE_XML(1 << 2)) { |
4381 | ret = cli_xml_output_vol_top (dict, rsp.op_ret, |
4382 | rsp.op_errno, |
4383 | rsp.op_errstr); |
4384 | if (ret) { |
4385 | gf_log ("cli", GF_LOG_ERROR,do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 4386, GF_LOG_ERROR , "Error outputting to xml"); } while (0) |
4386 | "Error outputting to xml")do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 4386, GF_LOG_ERROR , "Error outputting to xml"); } while (0); |
4387 | } |
4388 | goto out; |
4389 | } |
4390 | |
4391 | ret = dict_get_int32 (dict, "count", &brick_count); |
4392 | if (ret) |
4393 | goto out; |
4394 | snprintf (key, sizeof (key), "%d-top-op", 1); |
4395 | ret = dict_get_int32 (dict, key, (int32_t*)&top_op); |
4396 | if (ret) |
4397 | goto out; |
4398 | |
4399 | clear_stats = dict_get_str_boolean (dict, "clear-stats", _gf_false); |
4400 | |
4401 | while (i < brick_count) { |
4402 | i++; |
4403 | snprintf (brick, sizeof (brick), "%d-brick", i); |
4404 | ret = dict_get_str (dict, brick, &bricks); |
4405 | if (ret) |
4406 | goto out; |
4407 | |
4408 | nfs = dict_get_str_boolean (dict, "nfs", _gf_false); |
4409 | |
4410 | if (clear_stats) { |
4411 | memset (key, 0, sizeof (key)); |
4412 | snprintf (key, sizeof (key), "%d-stats-cleared", i); |
4413 | ret = dict_get_int32 (dict, key, &stats_cleared); |
4414 | if (ret) |
4415 | goto out; |
4416 | cli_out (stats_cleared ? "Cleared stats for %s %s" :do { do { if (0) printf (stats_cleared ? "Cleared stats for %s %s" : "Failed to clear stats for %s %s", nfs ? "NFS server on" : "brick", bricks); } while (0); _cli_out(stats_cleared ? "Cleared stats for %s %s" : "Failed to clear stats for %s %s", nfs ? "NFS server on" : "brick", bricks); } while (0) |
4417 | "Failed to clear stats for %s %s",do { do { if (0) printf (stats_cleared ? "Cleared stats for %s %s" : "Failed to clear stats for %s %s", nfs ? "NFS server on" : "brick", bricks); } while (0); _cli_out(stats_cleared ? "Cleared stats for %s %s" : "Failed to clear stats for %s %s", nfs ? "NFS server on" : "brick", bricks); } while (0) |
4418 | nfs ? "NFS server on" : "brick", bricks)do { do { if (0) printf (stats_cleared ? "Cleared stats for %s %s" : "Failed to clear stats for %s %s", nfs ? "NFS server on" : "brick", bricks); } while (0); _cli_out(stats_cleared ? "Cleared stats for %s %s" : "Failed to clear stats for %s %s", nfs ? "NFS server on" : "brick", bricks); } while (0); |
4419 | continue; |
4420 | } |
4421 | |
4422 | if (nfs) |
4423 | cli_out ("NFS Server : %s", bricks)do { do { if (0) printf ("NFS Server : %s", bricks); } while ( 0); _cli_out("NFS Server : %s", bricks); } while (0); |
4424 | else |
4425 | cli_out ("Brick: %s", bricks)do { do { if (0) printf ("Brick: %s", bricks); } while (0); _cli_out ("Brick: %s", bricks); } while (0); |
4426 | |
4427 | snprintf(key, sizeof (key), "%d-members", i); |
4428 | ret = dict_get_int32 (dict, key, &members); |
4429 | |
4430 | switch (top_op) { |
4431 | case GF_CLI_TOP_OPEN: |
4432 | snprintf (key, sizeof (key), "%d-current-open", i); |
4433 | ret = dict_get_uint64 (dict, key, &nr_open); |
4434 | if (ret) |
4435 | break; |
4436 | snprintf (key, sizeof (key), "%d-max-open", i); |
4437 | ret = dict_get_uint64 (dict, key, &max_nr_open); |
4438 | if (ret) |
4439 | goto out; |
4440 | snprintf (key, sizeof (key), "%d-max-openfd-time", i); |
4441 | ret = dict_get_str (dict, key, &openfd_str); |
4442 | if (ret) |
4443 | goto out; |
4444 | cli_out ("Current open fds: %"PRIu64", Max open"do { do { if (0) printf ("Current open fds: %""ll" "u"", Max open" " fds: %""ll" "u"", Max openfd time: %s", nr_open, max_nr_open , openfd_str); } while (0); _cli_out("Current open fds: %""ll" "u"", Max open" " fds: %""ll" "u"", Max openfd time: %s", nr_open , max_nr_open, openfd_str); } while (0) |
4445 | " fds: %"PRIu64", Max openfd time: %s", nr_open,do { do { if (0) printf ("Current open fds: %""ll" "u"", Max open" " fds: %""ll" "u"", Max openfd time: %s", nr_open, max_nr_open , openfd_str); } while (0); _cli_out("Current open fds: %""ll" "u"", Max open" " fds: %""ll" "u"", Max openfd time: %s", nr_open , max_nr_open, openfd_str); } while (0) |
4446 | max_nr_open, openfd_str)do { do { if (0) printf ("Current open fds: %""ll" "u"", Max open" " fds: %""ll" "u"", Max openfd time: %s", nr_open, max_nr_open , openfd_str); } while (0); _cli_out("Current open fds: %""ll" "u"", Max open" " fds: %""ll" "u"", Max openfd time: %s", nr_open , max_nr_open, openfd_str); } while (0); |
4447 | case GF_CLI_TOP_READ: |
4448 | case GF_CLI_TOP_WRITE: |
4449 | case GF_CLI_TOP_OPENDIR: |
4450 | case GF_CLI_TOP_READDIR: |
4451 | if (!members) { |
4452 | continue; |
4453 | } |
4454 | cli_out ("Count\t\tfilename\n=======================")do { do { if (0) printf ("Count\t\tfilename\n=======================" ); } while (0); _cli_out("Count\t\tfilename\n=======================" ); } while (0); |
4455 | break; |
4456 | case GF_CLI_TOP_READ_PERF: |
4457 | case GF_CLI_TOP_WRITE_PERF: |
4458 | snprintf (key, sizeof (key), "%d-throughput", i); |
4459 | ret = dict_get_double (dict, key, &throughput); |
4460 | if (!ret) { |
4461 | snprintf (key, sizeof (key), "%d-time", i); |
4462 | ret = dict_get_double (dict, key, &time); |
4463 | } |
4464 | if (!ret) |
4465 | cli_out ("Throughput %.2f MBps time %.4f secs", throughput,do { do { if (0) printf ("Throughput %.2f MBps time %.4f secs" , throughput, time / 1e6); } while (0); _cli_out("Throughput %.2f MBps time %.4f secs" , throughput, time / 1e6); } while (0) |
4466 | time / 1e6)do { do { if (0) printf ("Throughput %.2f MBps time %.4f secs" , throughput, time / 1e6); } while (0); _cli_out("Throughput %.2f MBps time %.4f secs" , throughput, time / 1e6); } while (0); |
4467 | |
4468 | if (!members) { |
4469 | continue; |
4470 | } |
4471 | cli_out ("%*s %-*s %-*s",do { do { if (0) printf ("%*s %-*s %-*s", 4, "MBps", 47, "Filename" , 26, "Time"); } while (0); _cli_out("%*s %-*s %-*s", 4, "MBps" , 47, "Filename", 26, "Time"); } while (0) |
4472 | VOL_TOP_PERF_SPEED_WIDTH, "MBps",do { do { if (0) printf ("%*s %-*s %-*s", 4, "MBps", 47, "Filename" , 26, "Time"); } while (0); _cli_out("%*s %-*s %-*s", 4, "MBps" , 47, "Filename", 26, "Time"); } while (0) |
4473 | VOL_TOP_PERF_FILENAME_DEF_WIDTH, "Filename",do { do { if (0) printf ("%*s %-*s %-*s", 4, "MBps", 47, "Filename" , 26, "Time"); } while (0); _cli_out("%*s %-*s %-*s", 4, "MBps" , 47, "Filename", 26, "Time"); } while (0) |
4474 | VOL_TOP_PERF_TIME_WIDTH, "Time")do { do { if (0) printf ("%*s %-*s %-*s", 4, "MBps", 47, "Filename" , 26, "Time"); } while (0); _cli_out("%*s %-*s %-*s", 4, "MBps" , 47, "Filename", 26, "Time"); } while (0); |
4475 | cli_out ("%*s %-*s %-*s",do { do { if (0) printf ("%*s %-*s %-*s", 4, "====", 47, "========" , 26, "===="); } while (0); _cli_out("%*s %-*s %-*s", 4, "====" , 47, "========", 26, "===="); } while (0) |
4476 | VOL_TOP_PERF_SPEED_WIDTH, "====",do { do { if (0) printf ("%*s %-*s %-*s", 4, "====", 47, "========" , 26, "===="); } while (0); _cli_out("%*s %-*s %-*s", 4, "====" , 47, "========", 26, "===="); } while (0) |
4477 | VOL_TOP_PERF_FILENAME_DEF_WIDTH, "========",do { do { if (0) printf ("%*s %-*s %-*s", 4, "====", 47, "========" , 26, "===="); } while (0); _cli_out("%*s %-*s %-*s", 4, "====" , 47, "========", 26, "===="); } while (0) |
4478 | VOL_TOP_PERF_TIME_WIDTH, "====")do { do { if (0) printf ("%*s %-*s %-*s", 4, "====", 47, "========" , 26, "===="); } while (0); _cli_out("%*s %-*s %-*s", 4, "====" , 47, "========", 26, "===="); } while (0); |
4479 | break; |
4480 | default: |
4481 | goto out; |
4482 | } |
4483 | |
4484 | for (j = 1; j <= members; j++) { |
4485 | snprintf (key, sizeof (key), "%d-filename-%d", i, j); |
4486 | ret = dict_get_str (dict, key, &filename); |
4487 | if (ret) |
4488 | break; |
4489 | snprintf (key, sizeof (key), "%d-value-%d", i, j); |
4490 | ret = dict_get_uint64 (dict, key, &value); |
4491 | if (ret) |
4492 | goto out; |
4493 | if ( top_op == GF_CLI_TOP_READ_PERF || |
4494 | top_op == GF_CLI_TOP_WRITE_PERF) { |
4495 | snprintf (key, sizeof (key), "%d-time-sec-%d", i, j); |
4496 | ret = dict_get_int32 (dict, key, (int32_t *)&time_sec); |
4497 | if (ret) |
4498 | goto out; |
4499 | snprintf (key, sizeof (key), "%d-time-usec-%d", i, j); |
4500 | ret = dict_get_int32 (dict, key, (int32_t *)&time_usec); |
4501 | if (ret) |
4502 | goto out; |
4503 | gf_time_fmt (timestr, sizeof timestr, |
4504 | time_sec, gf_timefmt_FT); |
4505 | snprintf (timestr + strlen (timestr), sizeof timestr - strlen (timestr), |
4506 | ".%"GF_PRI_SUSECONDS"06ld", time_usec); |
4507 | if (strlen (filename) < VOL_TOP_PERF_FILENAME_DEF_WIDTH47) |
4508 | cli_out ("%*"PRIu64" %-*s %-*s",do { do { if (0) printf ("%*""ll" "u"" %-*s %-*s", 4, value, 47 , filename, 26, timestr); } while (0); _cli_out("%*""ll" "u"" %-*s %-*s" , 4, value, 47, filename, 26, timestr); } while (0) |
4509 | VOL_TOP_PERF_SPEED_WIDTH,do { do { if (0) printf ("%*""ll" "u"" %-*s %-*s", 4, value, 47 , filename, 26, timestr); } while (0); _cli_out("%*""ll" "u"" %-*s %-*s" , 4, value, 47, filename, 26, timestr); } while (0) |
4510 | value,do { do { if (0) printf ("%*""ll" "u"" %-*s %-*s", 4, value, 47 , filename, 26, timestr); } while (0); _cli_out("%*""ll" "u"" %-*s %-*s" , 4, value, 47, filename, 26, timestr); } while (0) |
4511 | VOL_TOP_PERF_FILENAME_DEF_WIDTH,do { do { if (0) printf ("%*""ll" "u"" %-*s %-*s", 4, value, 47 , filename, 26, timestr); } while (0); _cli_out("%*""ll" "u"" %-*s %-*s" , 4, value, 47, filename, 26, timestr); } while (0) |
4512 | filename,do { do { if (0) printf ("%*""ll" "u"" %-*s %-*s", 4, value, 47 , filename, 26, timestr); } while (0); _cli_out("%*""ll" "u"" %-*s %-*s" , 4, value, 47, filename, 26, timestr); } while (0) |
4513 | VOL_TOP_PERF_TIME_WIDTH,do { do { if (0) printf ("%*""ll" "u"" %-*s %-*s", 4, value, 47 , filename, 26, timestr); } while (0); _cli_out("%*""ll" "u"" %-*s %-*s" , 4, value, 47, filename, 26, timestr); } while (0) |
4514 | timestr)do { do { if (0) printf ("%*""ll" "u"" %-*s %-*s", 4, value, 47 , filename, 26, timestr); } while (0); _cli_out("%*""ll" "u"" %-*s %-*s" , 4, value, 47, filename, 26, timestr); } while (0); |
4515 | else |
4516 | cli_out ("%*"PRIu64" ...%-*s %-*s",do { do { if (0) printf ("%*""ll" "u"" ...%-*s %-*s", 4, value , 44 , filename + strlen (filename) - 44, 26, timestr); } while (0); _cli_out("%*""ll" "u"" ...%-*s %-*s", 4, value, 44 , filename + strlen (filename) - 44, 26, timestr); } while (0) |
4517 | VOL_TOP_PERF_SPEED_WIDTH,do { do { if (0) printf ("%*""ll" "u"" ...%-*s %-*s", 4, value , 44 , filename + strlen (filename) - 44, 26, timestr); } while (0); _cli_out("%*""ll" "u"" ...%-*s %-*s", 4, value, 44 , filename + strlen (filename) - 44, 26, timestr); } while (0) |
4518 | value,do { do { if (0) printf ("%*""ll" "u"" ...%-*s %-*s", 4, value , 44 , filename + strlen (filename) - 44, 26, timestr); } while (0); _cli_out("%*""ll" "u"" ...%-*s %-*s", 4, value, 44 , filename + strlen (filename) - 44, 26, timestr); } while (0) |
4519 | VOL_TOP_PERF_FILENAME_ALT_WIDTH ,do { do { if (0) printf ("%*""ll" "u"" ...%-*s %-*s", 4, value , 44 , filename + strlen (filename) - 44, 26, timestr); } while (0); _cli_out("%*""ll" "u"" ...%-*s %-*s", 4, value, 44 , filename + strlen (filename) - 44, 26, timestr); } while (0) |
4520 | filename + strlen (filename) -do { do { if (0) printf ("%*""ll" "u"" ...%-*s %-*s", 4, value , 44 , filename + strlen (filename) - 44, 26, timestr); } while (0); _cli_out("%*""ll" "u"" ...%-*s %-*s", 4, value, 44 , filename + strlen (filename) - 44, 26, timestr); } while (0) |
4521 | VOL_TOP_PERF_FILENAME_ALT_WIDTH,do { do { if (0) printf ("%*""ll" "u"" ...%-*s %-*s", 4, value , 44 , filename + strlen (filename) - 44, 26, timestr); } while (0); _cli_out("%*""ll" "u"" ...%-*s %-*s", 4, value, 44 , filename + strlen (filename) - 44, 26, timestr); } while (0) |
4522 | VOL_TOP_PERF_TIME_WIDTH,do { do { if (0) printf ("%*""ll" "u"" ...%-*s %-*s", 4, value , 44 , filename + strlen (filename) - 44, 26, timestr); } while (0); _cli_out("%*""ll" "u"" ...%-*s %-*s", 4, value, 44 , filename + strlen (filename) - 44, 26, timestr); } while (0) |
4523 | timestr)do { do { if (0) printf ("%*""ll" "u"" ...%-*s %-*s", 4, value , 44 , filename + strlen (filename) - 44, 26, timestr); } while (0); _cli_out("%*""ll" "u"" ...%-*s %-*s", 4, value, 44 , filename + strlen (filename) - 44, 26, timestr); } while (0); |
4524 | } else { |
4525 | cli_out ("%"PRIu64"\t\t%s", value, filename)do { do { if (0) printf ("%""ll" "u""\t\t%s", value, filename ); } while (0); _cli_out("%""ll" "u""\t\t%s", value, filename ); } while (0); |
4526 | } |
4527 | } |
4528 | } |
4529 | ret = rsp.op_ret; |
4530 | |
4531 | out: |
4532 | cli_cmd_broadcast_response (ret); |
4533 | |
4534 | if (dict) |
4535 | dict_unref (dict); |
4536 | |
4537 | free (rsp.dict.dict_val); |
4538 | return ret; |
4539 | } |
4540 | |
4541 | int32_t |
4542 | gf_cli_top_volume (call_frame_t *frame, xlator_t *this, void *data) |
4543 | { |
4544 | int ret = -1; |
4545 | gf_cli_req req = {{0,}}; |
4546 | dict_t *dict = NULL((void*)0); |
4547 | |
4548 | GF_ASSERT (frame)do { if (!(frame)) { do { do { if (0) printf ("Assertion failed: " "frame"); } while (0); _gf_log_callingfn ("", "cli-rpc-ops.c" , __FUNCTION__, 4548, GF_LOG_ERROR, "Assertion failed: " "frame" ); } while (0); } } while (0); |
4549 | GF_ASSERT (this)do { if (!(this)) { do { do { if (0) printf ("Assertion failed: " "this"); } while (0); _gf_log_callingfn ("", "cli-rpc-ops.c" , __FUNCTION__, 4549, GF_LOG_ERROR, "Assertion failed: " "this" ); } while (0); } } while (0); |
4550 | GF_ASSERT (data)do { if (!(data)) { do { do { if (0) printf ("Assertion failed: " "data"); } while (0); _gf_log_callingfn ("", "cli-rpc-ops.c" , __FUNCTION__, 4550, GF_LOG_ERROR, "Assertion failed: " "data" ); } while (0); } } while (0); |
4551 | |
4552 | if (!frame || !this || !data) |
4553 | goto out; |
4554 | dict = data; |
4555 | |
4556 | ret = cli_to_glusterd (&req, frame, gf_cli_top_volume_cbk, |
4557 | (xdrproc_t) xdr_gf_cli_req, dict, |
4558 | GLUSTER_CLI_PROFILE_VOLUME, this, cli_rpc_prog, |
4559 | NULL((void*)0)); |
4560 | |
4561 | out: |
4562 | gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret)do { do { if (0) printf ("Returning %d", ret); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 4562, GF_LOG_DEBUG, "Returning %d" , ret); } while (0); |
4563 | GF_FREE (req.dict.dict_val)__gf_free (req.dict.dict_val); |
4564 | return ret; |
4565 | } |
4566 | |
4567 | |
4568 | int |
4569 | gf_cli_getwd_cbk (struct rpc_req *req, struct iovec *iov, |
4570 | int count, void *myframe) |
4571 | { |
4572 | gf1_cli_getwd_rsp rsp = {0,}; |
4573 | int ret = -1; |
4574 | |
4575 | if (-1 == req->rpc_status) { |
4576 | goto out; |
4577 | } |
4578 | |
4579 | ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf1_cli_getwd_rsp); |
4580 | if (ret < 0) { |
4581 | gf_log (((call_frame_t *) myframe)->this->name, GF_LOG_ERROR,do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (((call_frame_t *) myframe)->this->name, "cli-rpc-ops.c" , __FUNCTION__, 4582, GF_LOG_ERROR, "Failed to decode xdr response" ); } while (0) |
4582 | "Failed to decode xdr response")do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (((call_frame_t *) myframe)->this->name, "cli-rpc-ops.c" , __FUNCTION__, 4582, GF_LOG_ERROR, "Failed to decode xdr response" ); } while (0); |
4583 | goto out; |
4584 | } |
4585 | |
4586 | if (rsp.op_ret == -1) { |
4587 | cli_err ("getwd failed")do { do { if (0) printf ("getwd failed"); } while (0); _cli_err ("getwd failed"); } while (0); |
4588 | ret = rsp.op_ret; |
4589 | goto out; |
4590 | } |
4591 | |
4592 | gf_log ("cli", GF_LOG_INFO, "Received resp to getwd")do { do { if (0) printf ("Received resp to getwd"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 4592, GF_LOG_INFO , "Received resp to getwd"); } while (0); |
4593 | |
4594 | cli_out ("%s", rsp.wd)do { do { if (0) printf ("%s", rsp.wd); } while (0); _cli_out ("%s", rsp.wd); } while (0); |
4595 | |
4596 | ret = 0; |
4597 | |
4598 | out: |
4599 | cli_cmd_broadcast_response (ret); |
4600 | return ret; |
4601 | } |
4602 | |
4603 | int32_t |
4604 | gf_cli_getwd (call_frame_t *frame, xlator_t *this, void *data) |
4605 | { |
4606 | int ret = -1; |
4607 | gf1_cli_getwd_req req = {0,}; |
4608 | |
4609 | GF_ASSERT (frame)do { if (!(frame)) { do { do { if (0) printf ("Assertion failed: " "frame"); } while (0); _gf_log_callingfn ("", "cli-rpc-ops.c" , __FUNCTION__, 4609, GF_LOG_ERROR, "Assertion failed: " "frame" ); } while (0); } } while (0); |
4610 | GF_ASSERT (this)do { if (!(this)) { do { do { if (0) printf ("Assertion failed: " "this"); } while (0); _gf_log_callingfn ("", "cli-rpc-ops.c" , __FUNCTION__, 4610, GF_LOG_ERROR, "Assertion failed: " "this" ); } while (0); } } while (0); |
4611 | |
4612 | if (!frame || !this) |
4613 | goto out; |
4614 | |
4615 | ret = cli_cmd_submit (&req, frame, cli_rpc_prog, |
4616 | GLUSTER_CLI_GETWD, NULL((void*)0), |
4617 | this, gf_cli_getwd_cbk, |
4618 | (xdrproc_t) xdr_gf1_cli_getwd_req); |
4619 | |
4620 | out: |
4621 | gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret)do { do { if (0) printf ("Returning %d", ret); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 4621, GF_LOG_DEBUG, "Returning %d" , ret); } while (0); |
4622 | |
4623 | return ret; |
4624 | } |
4625 | |
4626 | void |
4627 | cli_print_volume_status_mempool (dict_t *dict, char *prefix) |
4628 | { |
4629 | int ret = -1; |
4630 | int32_t mempool_count = 0; |
4631 | char *name = NULL((void*)0); |
4632 | int32_t hotcount = 0; |
4633 | int32_t coldcount = 0; |
4634 | uint64_t paddedsizeof = 0; |
4635 | uint64_t alloccount = 0; |
4636 | int32_t maxalloc = 0; |
4637 | uint64_t pool_misses = 0; |
4638 | int32_t maxstdalloc = 0; |
4639 | char key[1024] = {0,}; |
4640 | int i = 0; |
4641 | |
4642 | GF_ASSERT (dict)do { if (!(dict)) { do { do { if (0) printf ("Assertion failed: " "dict"); } while (0); _gf_log_callingfn ("", "cli-rpc-ops.c" , __FUNCTION__, 4642, GF_LOG_ERROR, "Assertion failed: " "dict" ); } while (0); } } while (0); |
4643 | GF_ASSERT (prefix)do { if (!(prefix)) { do { do { if (0) printf ("Assertion failed: " "prefix"); } while (0); _gf_log_callingfn ("", "cli-rpc-ops.c" , __FUNCTION__, 4643, GF_LOG_ERROR, "Assertion failed: " "prefix" ); } while (0); } } while (0); |
4644 | |
4645 | memset (key, 0, sizeof (key)); |
4646 | snprintf (key, sizeof (key), "%s.mempool-count",prefix); |
4647 | ret = dict_get_int32 (dict, key, &mempool_count); |
4648 | if (ret) |
4649 | goto out; |
4650 | |
4651 | cli_out ("Mempool Stats\n-------------")do { do { if (0) printf ("Mempool Stats\n-------------"); } while (0); _cli_out("Mempool Stats\n-------------"); } while (0); |
4652 | cli_out ("%-30s %9s %9s %12s %10s %8s %8s %12s", "Name", "HotCount",do { do { if (0) printf ("%-30s %9s %9s %12s %10s %8s %8s %12s" , "Name", "HotCount", "ColdCount", "PaddedSizeof", "AllocCount" , "MaxAlloc", "Misses", "Max-StdAlloc"); } while (0); _cli_out ("%-30s %9s %9s %12s %10s %8s %8s %12s", "Name", "HotCount", "ColdCount" , "PaddedSizeof", "AllocCount", "MaxAlloc", "Misses", "Max-StdAlloc" ); } while (0) |
4653 | "ColdCount", "PaddedSizeof", "AllocCount", "MaxAlloc",do { do { if (0) printf ("%-30s %9s %9s %12s %10s %8s %8s %12s" , "Name", "HotCount", "ColdCount", "PaddedSizeof", "AllocCount" , "MaxAlloc", "Misses", "Max-StdAlloc"); } while (0); _cli_out ("%-30s %9s %9s %12s %10s %8s %8s %12s", "Name", "HotCount", "ColdCount" , "PaddedSizeof", "AllocCount", "MaxAlloc", "Misses", "Max-StdAlloc" ); } while (0) |
4654 | "Misses", "Max-StdAlloc")do { do { if (0) printf ("%-30s %9s %9s %12s %10s %8s %8s %12s" , "Name", "HotCount", "ColdCount", "PaddedSizeof", "AllocCount" , "MaxAlloc", "Misses", "Max-StdAlloc"); } while (0); _cli_out ("%-30s %9s %9s %12s %10s %8s %8s %12s", "Name", "HotCount", "ColdCount" , "PaddedSizeof", "AllocCount", "MaxAlloc", "Misses", "Max-StdAlloc" ); } while (0); |
4655 | cli_out ("%-30s %9s %9s %12s %10s %8s %8s %12s", "----", "--------",do { do { if (0) printf ("%-30s %9s %9s %12s %10s %8s %8s %12s" , "----", "--------", "---------", "------------", "----------" , "--------", "--------", "------------"); } while (0); _cli_out ("%-30s %9s %9s %12s %10s %8s %8s %12s", "----", "--------", "---------" , "------------", "----------", "--------", "--------", "------------" ); } while (0) |
4656 | "---------", "------------", "----------",do { do { if (0) printf ("%-30s %9s %9s %12s %10s %8s %8s %12s" , "----", "--------", "---------", "------------", "----------" , "--------", "--------", "------------"); } while (0); _cli_out ("%-30s %9s %9s %12s %10s %8s %8s %12s", "----", "--------", "---------" , "------------", "----------", "--------", "--------", "------------" ); } while (0) |
4657 | "--------", "--------", "------------")do { do { if (0) printf ("%-30s %9s %9s %12s %10s %8s %8s %12s" , "----", "--------", "---------", "------------", "----------" , "--------", "--------", "------------"); } while (0); _cli_out ("%-30s %9s %9s %12s %10s %8s %8s %12s", "----", "--------", "---------" , "------------", "----------", "--------", "--------", "------------" ); } while (0); |
4658 | |
4659 | for (i = 0; i < mempool_count; i++) { |
4660 | memset (key, 0, sizeof (key)); |
4661 | snprintf (key, sizeof (key), "%s.pool%d.name", prefix, i); |
4662 | ret = dict_get_str (dict, key, &name); |
4663 | if (ret) |
4664 | goto out; |
4665 | |
4666 | memset (key, 0, sizeof (key)); |
4667 | snprintf (key, sizeof (key), "%s.pool%d.hotcount", prefix, i); |
4668 | ret = dict_get_int32 (dict, key, &hotcount); |
4669 | if (ret) |
4670 | goto out; |
4671 | |
4672 | memset (key, 0, sizeof (key)); |
4673 | snprintf (key, sizeof (key), "%s.pool%d.coldcount", prefix, i); |
4674 | ret = dict_get_int32 (dict, key, &coldcount); |
4675 | if (ret) |
4676 | goto out; |
4677 | |
4678 | memset (key, 0, sizeof (key)); |
4679 | snprintf (key, sizeof (key), "%s.pool%d.paddedsizeof", |
4680 | prefix, i); |
4681 | ret = dict_get_uint64 (dict, key, &paddedsizeof); |
4682 | if (ret) |
4683 | goto out; |
4684 | |
4685 | memset (key, 0, sizeof (key)); |
4686 | snprintf (key, sizeof (key), "%s.pool%d.alloccount", prefix, i); |
4687 | ret = dict_get_uint64 (dict, key, &alloccount); |
4688 | if (ret) |
4689 | goto out; |
4690 | |
4691 | memset (key, 0, sizeof (key)); |
4692 | snprintf (key, sizeof (key), "%s.pool%d.max_alloc", prefix, i); |
4693 | ret = dict_get_int32 (dict, key, &maxalloc); |
4694 | if (ret) |
4695 | goto out; |
4696 | |
4697 | memset (key, 0, sizeof (key)); |
4698 | snprintf (key, sizeof (key), "%s.pool%d.max-stdalloc", prefix, i); |
4699 | ret = dict_get_int32 (dict, key, &maxstdalloc); |
4700 | if (ret) |
4701 | goto out; |
4702 | |
4703 | memset (key, 0, sizeof (key)); |
4704 | snprintf (key, sizeof (key), "%s.pool%d.pool-misses", prefix, i); |
4705 | ret = dict_get_uint64 (dict, key, &pool_misses); |
4706 | if (ret) |
4707 | goto out; |
4708 | |
4709 | cli_out ("%-30s %9d %9d %12"PRIu64" %10"PRIu64" %8d %8"PRIu64do { do { if (0) printf ("%-30s %9d %9d %12""ll" "u"" %10""ll" "u"" %8d %8""ll" "u" " %12d", name, hotcount, coldcount, paddedsizeof , alloccount, maxalloc, pool_misses, maxstdalloc); } while (0 ); _cli_out("%-30s %9d %9d %12""ll" "u"" %10""ll" "u"" %8d %8" "ll" "u" " %12d", name, hotcount, coldcount, paddedsizeof, alloccount , maxalloc, pool_misses, maxstdalloc); } while (0) |
4710 | " %12d", name, hotcount, coldcount, paddedsizeof,do { do { if (0) printf ("%-30s %9d %9d %12""ll" "u"" %10""ll" "u"" %8d %8""ll" "u" " %12d", name, hotcount, coldcount, paddedsizeof , alloccount, maxalloc, pool_misses, maxstdalloc); } while (0 ); _cli_out("%-30s %9d %9d %12""ll" "u"" %10""ll" "u"" %8d %8" "ll" "u" " %12d", name, hotcount, coldcount, paddedsizeof, alloccount , maxalloc, pool_misses, maxstdalloc); } while (0) |
4711 | alloccount, maxalloc, pool_misses, maxstdalloc)do { do { if (0) printf ("%-30s %9d %9d %12""ll" "u"" %10""ll" "u"" %8d %8""ll" "u" " %12d", name, hotcount, coldcount, paddedsizeof , alloccount, maxalloc, pool_misses, maxstdalloc); } while (0 ); _cli_out("%-30s %9d %9d %12""ll" "u"" %10""ll" "u"" %8d %8" "ll" "u" " %12d", name, hotcount, coldcount, paddedsizeof, alloccount , maxalloc, pool_misses, maxstdalloc); } while (0); |
4712 | } |
4713 | |
4714 | out: |
4715 | return; |
4716 | |
4717 | } |
4718 | |
4719 | void |
4720 | cli_print_volume_status_mem (dict_t *dict, gf_boolean_t notbrick) |
4721 | { |
4722 | int ret = -1; |
4723 | char *volname = NULL((void*)0); |
4724 | char *hostname = NULL((void*)0); |
4725 | char *path = NULL((void*)0); |
4726 | int online = -1; |
4727 | char key[1024] = {0,}; |
4728 | int brick_index_max = -1; |
4729 | int other_count = 0; |
4730 | int index_max = 0; |
4731 | int val = 0; |
4732 | int i = 0; |
4733 | |
4734 | GF_ASSERT (dict)do { if (!(dict)) { do { do { if (0) printf ("Assertion failed: " "dict"); } while (0); _gf_log_callingfn ("", "cli-rpc-ops.c" , __FUNCTION__, 4734, GF_LOG_ERROR, "Assertion failed: " "dict" ); } while (0); } } while (0); |
4735 | |
4736 | ret = dict_get_str (dict, "volname", &volname); |
4737 | if (ret) |
4738 | goto out; |
4739 | cli_out ("Memory status for volume : %s", volname)do { do { if (0) printf ("Memory status for volume : %s", volname ); } while (0); _cli_out("Memory status for volume : %s", volname ); } while (0); |
4740 | |
4741 | ret = dict_get_int32 (dict, "brick-index-max", &brick_index_max); |
4742 | if (ret) |
4743 | goto out; |
4744 | ret = dict_get_int32 (dict, "other-count", &other_count); |
4745 | if (ret) |
4746 | goto out; |
4747 | |
4748 | index_max = brick_index_max + other_count; |
4749 | |
4750 | for (i = 0; i <= index_max; i++) { |
4751 | cli_out ("----------------------------------------------")do { do { if (0) printf ("----------------------------------------------" ); } while (0); _cli_out("----------------------------------------------" ); } while (0); |
4752 | |
4753 | memset (key, 0, sizeof (key)); |
4754 | snprintf (key, sizeof (key), "brick%d.hostname", i); |
4755 | ret = dict_get_str (dict, key, &hostname); |
4756 | if (ret) |
4757 | continue; |
4758 | memset (key, 0, sizeof (key)); |
4759 | snprintf (key, sizeof (key), "brick%d.path", i); |
4760 | ret = dict_get_str (dict, key, &path); |
4761 | if (ret) |
4762 | continue; |
4763 | if (notbrick) |
4764 | cli_out ("%s : %s", hostname, path)do { do { if (0) printf ("%s : %s", hostname, path); } while ( 0); _cli_out("%s : %s", hostname, path); } while (0); |
4765 | else |
4766 | cli_out ("Brick : %s:%s", hostname, path)do { do { if (0) printf ("Brick : %s:%s", hostname, path); } while (0); _cli_out("Brick : %s:%s", hostname, path); } while (0); |
4767 | |
4768 | memset (key, 0, sizeof (key)); |
4769 | snprintf (key, sizeof (key), "brick%d.status", i); |
4770 | ret = dict_get_int32 (dict, key, &online); |
4771 | if (ret) |
4772 | goto out; |
4773 | if (!online) { |
4774 | if (notbrick) |
4775 | cli_out ("%s is offline", hostname)do { do { if (0) printf ("%s is offline", hostname); } while ( 0); _cli_out("%s is offline", hostname); } while (0); |
4776 | else |
4777 | cli_out ("Brick is offline")do { do { if (0) printf ("Brick is offline"); } while (0); _cli_out ("Brick is offline"); } while (0); |
4778 | continue; |
4779 | } |
4780 | |
4781 | cli_out ("Mallinfo\n--------")do { do { if (0) printf ("Mallinfo\n--------"); } while (0); _cli_out ("Mallinfo\n--------"); } while (0); |
4782 | |
4783 | memset (key, 0, sizeof (key)); |
4784 | snprintf (key, sizeof (key), "brick%d.mallinfo.arena", i); |
4785 | ret = dict_get_int32 (dict, key, &val); |
4786 | if (ret) |
4787 | goto out; |
4788 | cli_out ("%-8s : %d","Arena", val)do { do { if (0) printf ("%-8s : %d","Arena", val); } while ( 0); _cli_out("%-8s : %d","Arena", val); } while (0); |
4789 | |
4790 | memset (key, 0, sizeof (key)); |
4791 | snprintf (key, sizeof (key), "brick%d.mallinfo.ordblks", i); |
4792 | ret = dict_get_int32 (dict, key, &val); |
4793 | if(ret) |
4794 | goto out; |
4795 | cli_out ("%-8s : %d","Ordblks", val)do { do { if (0) printf ("%-8s : %d","Ordblks", val); } while (0); _cli_out("%-8s : %d","Ordblks", val); } while (0); |
4796 | |
4797 | memset (key, 0, sizeof (key)); |
4798 | snprintf (key, sizeof (key), "brick%d.mallinfo.smblks", i); |
4799 | ret = dict_get_int32 (dict, key, &val); |
4800 | if(ret) |
4801 | goto out; |
4802 | cli_out ("%-8s : %d","Smblks", val)do { do { if (0) printf ("%-8s : %d","Smblks", val); } while ( 0); _cli_out("%-8s : %d","Smblks", val); } while (0); |
4803 | |
4804 | memset (key, 0, sizeof (key)); |
4805 | snprintf (key, sizeof (key), "brick%d.mallinfo.hblks", i); |
4806 | ret = dict_get_int32 (dict, key, &val); |
4807 | if(ret) |
4808 | goto out; |
4809 | cli_out ("%-8s : %d", "Hblks", val)do { do { if (0) printf ("%-8s : %d", "Hblks", val); } while ( 0); _cli_out("%-8s : %d", "Hblks", val); } while (0); |
4810 | |
4811 | memset (key, 0, sizeof (key)); |
4812 | snprintf (key, sizeof (key), "brick%d.mallinfo.hblkhd", i); |
4813 | ret = dict_get_int32 (dict, key, &val); |
4814 | if (ret) |
4815 | goto out; |
4816 | cli_out ("%-8s : %d", "Hblkhd", val)do { do { if (0) printf ("%-8s : %d", "Hblkhd", val); } while (0); _cli_out("%-8s : %d", "Hblkhd", val); } while (0); |
4817 | |
4818 | memset (key, 0, sizeof (key)); |
4819 | snprintf (key, sizeof (key), "brick%d.mallinfo.usmblks", i); |
4820 | ret = dict_get_int32 (dict, key, &val); |
4821 | if (ret) |
4822 | goto out; |
4823 | cli_out ("%-8s : %d", "Usmblks", val)do { do { if (0) printf ("%-8s : %d", "Usmblks", val); } while (0); _cli_out("%-8s : %d", "Usmblks", val); } while (0); |
4824 | |
4825 | memset (key, 0, sizeof (key)); |
4826 | snprintf (key, sizeof (key), "brick%d.mallinfo.fsmblks", i); |
4827 | ret = dict_get_int32 (dict, key, &val); |
4828 | if (ret) |
4829 | goto out; |
4830 | cli_out ("%-8s : %d", "Fsmblks", val)do { do { if (0) printf ("%-8s : %d", "Fsmblks", val); } while (0); _cli_out("%-8s : %d", "Fsmblks", val); } while (0); |
4831 | |
4832 | memset (key, 0, sizeof (key)); |
4833 | snprintf (key, sizeof (key), "brick%d.mallinfo.uordblks", i); |
4834 | ret = dict_get_int32 (dict, key, &val); |
4835 | if (ret) |
4836 | goto out; |
4837 | cli_out ("%-8s : %d", "Uordblks", val)do { do { if (0) printf ("%-8s : %d", "Uordblks", val); } while (0); _cli_out("%-8s : %d", "Uordblks", val); } while (0); |
4838 | |
4839 | memset (key, 0, sizeof (key)); |
4840 | snprintf (key, sizeof (key), "brick%d.mallinfo.fordblks", i); |
4841 | ret = dict_get_int32 (dict, key, &val); |
4842 | if (ret) |
4843 | goto out; |
4844 | cli_out ("%-8s : %d", "Fordblks", val)do { do { if (0) printf ("%-8s : %d", "Fordblks", val); } while (0); _cli_out("%-8s : %d", "Fordblks", val); } while (0); |
4845 | |
4846 | memset (key, 0, sizeof (key)); |
4847 | snprintf (key, sizeof (key), "brick%d.mallinfo.keepcost", i); |
4848 | ret = dict_get_int32 (dict, key, &val); |
4849 | if (ret) |
4850 | goto out; |
4851 | cli_out ("%-8s : %d", "Keepcost", val)do { do { if (0) printf ("%-8s : %d", "Keepcost", val); } while (0); _cli_out("%-8s : %d", "Keepcost", val); } while (0); |
4852 | |
4853 | cli_out (" ")do { do { if (0) printf (" "); } while (0); _cli_out(" "); } while (0); |
4854 | memset (key, 0, sizeof (key)); |
4855 | snprintf (key, sizeof (key), "brick%d", i); |
4856 | cli_print_volume_status_mempool (dict, key); |
4857 | } |
4858 | out: |
4859 | cli_out ("----------------------------------------------\n")do { do { if (0) printf ("----------------------------------------------\n" ); } while (0); _cli_out("----------------------------------------------\n" ); } while (0); |
4860 | return; |
4861 | } |
4862 | |
4863 | void |
4864 | cli_print_volume_status_clients (dict_t *dict, gf_boolean_t notbrick) |
4865 | { |
4866 | int ret = -1; |
4867 | char *volname = NULL((void*)0); |
4868 | int brick_index_max = -1; |
4869 | int other_count = 0; |
4870 | int index_max = 0; |
4871 | char *hostname = NULL((void*)0); |
4872 | char *path = NULL((void*)0); |
4873 | int online = -1; |
4874 | int client_count = 0; |
4875 | char *clientname = NULL((void*)0); |
4876 | uint64_t bytesread = 0; |
4877 | uint64_t byteswrite = 0; |
4878 | char key[1024] = {0,}; |
4879 | int i = 0; |
4880 | int j = 0; |
4881 | |
4882 | GF_ASSERT (dict)do { if (!(dict)) { do { do { if (0) printf ("Assertion failed: " "dict"); } while (0); _gf_log_callingfn ("", "cli-rpc-ops.c" , __FUNCTION__, 4882, GF_LOG_ERROR, "Assertion failed: " "dict" ); } while (0); } } while (0); |
4883 | |
4884 | ret = dict_get_str (dict, "volname", &volname); |
4885 | if (ret) |
4886 | goto out; |
4887 | cli_out ("Client connections for volume %s", volname)do { do { if (0) printf ("Client connections for volume %s", volname ); } while (0); _cli_out("Client connections for volume %s", volname ); } while (0); |
4888 | |
4889 | ret = dict_get_int32 (dict, "brick-index-max", &brick_index_max); |
4890 | if (ret) |
4891 | goto out; |
4892 | ret = dict_get_int32 (dict, "other-count", &other_count); |
4893 | if (ret) |
4894 | goto out; |
4895 | |
4896 | index_max = brick_index_max + other_count; |
4897 | |
4898 | for (i = 0; i <= index_max; i++) { |
4899 | cli_out ("----------------------------------------------")do { do { if (0) printf ("----------------------------------------------" ); } while (0); _cli_out("----------------------------------------------" ); } while (0); |
4900 | |
4901 | memset (key, 0, sizeof (key)); |
4902 | snprintf (key, sizeof (key), "brick%d.hostname", i); |
4903 | ret = dict_get_str (dict, key, &hostname); |
4904 | if (ret) |
4905 | goto out; |
4906 | memset (key, 0, sizeof (key)); |
4907 | snprintf (key, sizeof (key), "brick%d.path", i); |
4908 | ret = dict_get_str (dict, key, &path); |
4909 | if (ret) |
4910 | goto out; |
4911 | |
4912 | if (notbrick) |
4913 | cli_out ("%s : %s", hostname, path)do { do { if (0) printf ("%s : %s", hostname, path); } while ( 0); _cli_out("%s : %s", hostname, path); } while (0); |
4914 | else |
4915 | cli_out ("Brick : %s:%s", hostname, path)do { do { if (0) printf ("Brick : %s:%s", hostname, path); } while (0); _cli_out("Brick : %s:%s", hostname, path); } while (0); |
4916 | |
4917 | memset (key, 0, sizeof (key)); |
4918 | snprintf (key, sizeof (key), "brick%d.status", i); |
4919 | ret = dict_get_int32 (dict, key, &online); |
4920 | if (ret) |
4921 | goto out; |
4922 | if (!online) { |
4923 | if (notbrick) |
4924 | cli_out ("%s is offline", hostname)do { do { if (0) printf ("%s is offline", hostname); } while ( 0); _cli_out("%s is offline", hostname); } while (0); |
4925 | else |
4926 | cli_out ("Brick is offline")do { do { if (0) printf ("Brick is offline"); } while (0); _cli_out ("Brick is offline"); } while (0); |
4927 | continue; |
4928 | } |
4929 | |
4930 | memset (key, 0, sizeof (key)); |
4931 | snprintf (key, sizeof (key), "brick%d.clientcount", i); |
4932 | ret = dict_get_int32 (dict, key, &client_count); |
4933 | if (ret) |
4934 | goto out; |
4935 | |
4936 | cli_out ("Clients connected : %d", client_count)do { do { if (0) printf ("Clients connected : %d", client_count ); } while (0); _cli_out("Clients connected : %d", client_count ); } while (0); |
4937 | if (client_count == 0) |
4938 | continue; |
4939 | |
4940 | cli_out ("%-48s %15s %15s", "Hostname", "BytesRead",do { do { if (0) printf ("%-48s %15s %15s", "Hostname", "BytesRead" , "BytesWritten"); } while (0); _cli_out("%-48s %15s %15s", "Hostname" , "BytesRead", "BytesWritten"); } while (0) |
4941 | "BytesWritten")do { do { if (0) printf ("%-48s %15s %15s", "Hostname", "BytesRead" , "BytesWritten"); } while (0); _cli_out("%-48s %15s %15s", "Hostname" , "BytesRead", "BytesWritten"); } while (0); |
4942 | cli_out ("%-48s %15s %15s", "--------", "---------",do { do { if (0) printf ("%-48s %15s %15s", "--------", "---------" , "------------"); } while (0); _cli_out("%-48s %15s %15s", "--------" , "---------", "------------"); } while (0) |
4943 | "------------")do { do { if (0) printf ("%-48s %15s %15s", "--------", "---------" , "------------"); } while (0); _cli_out("%-48s %15s %15s", "--------" , "---------", "------------"); } while (0); |
4944 | for (j =0; j < client_count; j++) { |
4945 | memset (key, 0, sizeof (key)); |
4946 | snprintf (key, sizeof (key), |
4947 | "brick%d.client%d.hostname", i, j); |
4948 | ret = dict_get_str (dict, key, &clientname); |
4949 | if (ret) |
4950 | goto out; |
4951 | |
4952 | memset (key, 0, sizeof (key)); |
4953 | snprintf (key, sizeof (key), |
4954 | "brick%d.client%d.bytesread", i, j); |
4955 | ret = dict_get_uint64 (dict, key, &bytesread); |
4956 | if (ret) |
4957 | goto out; |
4958 | |
4959 | memset (key, 0, sizeof (key)); |
4960 | snprintf (key, sizeof (key), |
4961 | "brick%d.client%d.byteswrite", i, j); |
4962 | ret = dict_get_uint64 (dict, key, &byteswrite); |
4963 | if (ret) |
4964 | goto out; |
4965 | |
4966 | cli_out ("%-48s %15"PRIu64" %15"PRIu64,do { do { if (0) printf ("%-48s %15""ll" "u"" %15""ll" "u", clientname , bytesread, byteswrite); } while (0); _cli_out("%-48s %15""ll" "u"" %15""ll" "u", clientname, bytesread, byteswrite); } while (0) |
4967 | clientname, bytesread, byteswrite)do { do { if (0) printf ("%-48s %15""ll" "u"" %15""ll" "u", clientname , bytesread, byteswrite); } while (0); _cli_out("%-48s %15""ll" "u"" %15""ll" "u", clientname, bytesread, byteswrite); } while (0); |
4968 | } |
4969 | } |
4970 | out: |
4971 | cli_out ("----------------------------------------------\n")do { do { if (0) printf ("----------------------------------------------\n" ); } while (0); _cli_out("----------------------------------------------\n" ); } while (0); |
4972 | return; |
4973 | } |
4974 | |
4975 | void |
4976 | cli_print_volume_status_inode_entry (dict_t *dict, char *prefix) |
4977 | { |
4978 | int ret = -1; |
4979 | char key[1024] = {0,}; |
4980 | char *gfid = NULL((void*)0); |
4981 | uint64_t nlookup = 0; |
4982 | uint32_t ref = 0; |
4983 | int ia_type = 0; |
4984 | char inode_type; |
4985 | |
4986 | GF_ASSERT (dict)do { if (!(dict)) { do { do { if (0) printf ("Assertion failed: " "dict"); } while (0); _gf_log_callingfn ("", "cli-rpc-ops.c" , __FUNCTION__, 4986, GF_LOG_ERROR, "Assertion failed: " "dict" ); } while (0); } } while (0); |
4987 | GF_ASSERT (prefix)do { if (!(prefix)) { do { do { if (0) printf ("Assertion failed: " "prefix"); } while (0); _gf_log_callingfn ("", "cli-rpc-ops.c" , __FUNCTION__, 4987, GF_LOG_ERROR, "Assertion failed: " "prefix" ); } while (0); } } while (0); |
4988 | |
4989 | memset (key, 0, sizeof (key)); |
4990 | snprintf (key, sizeof (key), "%s.gfid", prefix); |
4991 | ret = dict_get_str (dict, key, &gfid); |
4992 | if (ret) |
4993 | goto out; |
4994 | |
4995 | memset (key, 0, sizeof (key)); |
4996 | snprintf (key, sizeof (key), "%s.nlookup", prefix); |
4997 | ret = dict_get_uint64 (dict, key, &nlookup); |
4998 | if (ret) |
4999 | goto out; |
5000 | |
5001 | memset (key, 0, sizeof (key)); |
5002 | snprintf (key, sizeof (key), "%s.ref", prefix); |
5003 | ret = dict_get_uint32 (dict, key, &ref); |
5004 | if (ret) |
5005 | goto out; |
5006 | |
5007 | memset (key, 0, sizeof (key)); |
5008 | snprintf (key, sizeof (key), "%s.ia_type", prefix); |
5009 | ret = dict_get_int32 (dict, key, &ia_type); |
5010 | if (ret) |
5011 | goto out; |
5012 | |
5013 | switch (ia_type) { |
5014 | case IA_IFREG: |
5015 | inode_type = 'R'; |
5016 | break; |
5017 | case IA_IFDIR: |
5018 | inode_type = 'D'; |
5019 | break; |
5020 | case IA_IFLNK: |
5021 | inode_type = 'L'; |
5022 | break; |
5023 | case IA_IFBLK: |
5024 | inode_type = 'B'; |
5025 | break; |
5026 | case IA_IFCHR: |
5027 | inode_type = 'C'; |
5028 | break; |
5029 | case IA_IFIFO: |
5030 | inode_type = 'F'; |
5031 | break; |
5032 | case IA_IFSOCK: |
5033 | inode_type = 'S'; |
5034 | break; |
5035 | default: |
5036 | inode_type = 'I'; |
5037 | break; |
5038 | } |
5039 | |
5040 | cli_out ("%-40s %14"PRIu64" %14"PRIu32" %9c",do { do { if (0) printf ("%-40s %14""ll" "u"" %14""u"" %9c", gfid , nlookup, ref, inode_type); } while (0); _cli_out("%-40s %14" "ll" "u"" %14""u"" %9c", gfid, nlookup, ref, inode_type); } while (0) |
5041 | gfid, nlookup, ref, inode_type)do { do { if (0) printf ("%-40s %14""ll" "u"" %14""u"" %9c", gfid , nlookup, ref, inode_type); } while (0); _cli_out("%-40s %14" "ll" "u"" %14""u"" %9c", gfid, nlookup, ref, inode_type); } while (0); |
5042 | |
5043 | out: |
5044 | return; |
5045 | |
5046 | } |
5047 | |
5048 | void |
5049 | cli_print_volume_status_itables (dict_t *dict, char *prefix) |
5050 | { |
5051 | int ret = -1; |
5052 | char key[1024] = {0,}; |
5053 | uint32_t active_size = 0; |
5054 | uint32_t lru_size = 0; |
5055 | uint32_t purge_size = 0; |
5056 | int i =0; |
5057 | |
5058 | GF_ASSERT (dict)do { if (!(dict)) { do { do { if (0) printf ("Assertion failed: " "dict"); } while (0); _gf_log_callingfn ("", "cli-rpc-ops.c" , __FUNCTION__, 5058, GF_LOG_ERROR, "Assertion failed: " "dict" ); } while (0); } } while (0); |
5059 | GF_ASSERT (prefix)do { if (!(prefix)) { do { do { if (0) printf ("Assertion failed: " "prefix"); } while (0); _gf_log_callingfn ("", "cli-rpc-ops.c" , __FUNCTION__, 5059, GF_LOG_ERROR, "Assertion failed: " "prefix" ); } while (0); } } while (0); |
5060 | |
5061 | memset (key, 0, sizeof (key)); |
5062 | snprintf (key, sizeof (key), "%s.active_size", prefix); |
5063 | ret = dict_get_uint32 (dict, key, &active_size); |
5064 | if (ret) |
5065 | goto out; |
5066 | if (active_size != 0) { |
5067 | cli_out ("Active inodes:")do { do { if (0) printf ("Active inodes:"); } while (0); _cli_out ("Active inodes:"); } while (0); |
5068 | cli_out ("%-40s %14s %14s %9s", "GFID", "Lookups", "Ref",do { do { if (0) printf ("%-40s %14s %14s %9s", "GFID", "Lookups" , "Ref", "IA type"); } while (0); _cli_out("%-40s %14s %14s %9s" , "GFID", "Lookups", "Ref", "IA type"); } while (0) |
5069 | "IA type")do { do { if (0) printf ("%-40s %14s %14s %9s", "GFID", "Lookups" , "Ref", "IA type"); } while (0); _cli_out("%-40s %14s %14s %9s" , "GFID", "Lookups", "Ref", "IA type"); } while (0); |
5070 | cli_out ("%-40s %14s %14s %9s", "----", "-------", "---",do { do { if (0) printf ("%-40s %14s %14s %9s", "----", "-------" , "---", "-------"); } while (0); _cli_out("%-40s %14s %14s %9s" , "----", "-------", "---", "-------"); } while (0) |
5071 | "-------")do { do { if (0) printf ("%-40s %14s %14s %9s", "----", "-------" , "---", "-------"); } while (0); _cli_out("%-40s %14s %14s %9s" , "----", "-------", "---", "-------"); } while (0); |
5072 | } |
5073 | for (i = 0; i < active_size; i++) { |
5074 | memset (key, 0, sizeof (key)); |
5075 | snprintf (key, sizeof (key), "%s.active%d", prefix, i); |
5076 | cli_print_volume_status_inode_entry (dict, key); |
5077 | } |
5078 | cli_out (" ")do { do { if (0) printf (" "); } while (0); _cli_out(" "); } while (0); |
5079 | |
5080 | memset (key, 0, sizeof (key)); |
5081 | snprintf (key, sizeof (key), "%s.lru_size", prefix); |
5082 | ret = dict_get_uint32 (dict, key, &lru_size); |
5083 | if (ret) |
5084 | goto out; |
5085 | if (lru_size != 0) { |
5086 | cli_out ("LRU inodes:")do { do { if (0) printf ("LRU inodes:"); } while (0); _cli_out ("LRU inodes:"); } while (0); |
5087 | cli_out ("%-40s %14s %14s %9s", "GFID", "Lookups", "Ref",do { do { if (0) printf ("%-40s %14s %14s %9s", "GFID", "Lookups" , "Ref", "IA type"); } while (0); _cli_out("%-40s %14s %14s %9s" , "GFID", "Lookups", "Ref", "IA type"); } while (0) |
5088 | "IA type")do { do { if (0) printf ("%-40s %14s %14s %9s", "GFID", "Lookups" , "Ref", "IA type"); } while (0); _cli_out("%-40s %14s %14s %9s" , "GFID", "Lookups", "Ref", "IA type"); } while (0); |
5089 | cli_out ("%-40s %14s %14s %9s", "----", "-------", "---",do { do { if (0) printf ("%-40s %14s %14s %9s", "----", "-------" , "---", "-------"); } while (0); _cli_out("%-40s %14s %14s %9s" , "----", "-------", "---", "-------"); } while (0) |
5090 | "-------")do { do { if (0) printf ("%-40s %14s %14s %9s", "----", "-------" , "---", "-------"); } while (0); _cli_out("%-40s %14s %14s %9s" , "----", "-------", "---", "-------"); } while (0); |
5091 | } |
5092 | for (i = 0; i < lru_size; i++) { |
5093 | memset (key, 0, sizeof (key)); |
5094 | snprintf (key, sizeof (key), "%s.lru%d", prefix, i); |
5095 | cli_print_volume_status_inode_entry (dict, key); |
5096 | } |
5097 | cli_out (" ")do { do { if (0) printf (" "); } while (0); _cli_out(" "); } while (0); |
5098 | |
5099 | memset (key, 0, sizeof (key)); |
5100 | snprintf (key, sizeof (key), "%s.purge_size", prefix); |
5101 | ret = dict_get_uint32 (dict, key, &purge_size); |
5102 | if (ret) |
5103 | goto out; |
5104 | if (purge_size != 0) { |
5105 | cli_out ("Purged inodes:")do { do { if (0) printf ("Purged inodes:"); } while (0); _cli_out ("Purged inodes:"); } while (0); |
5106 | cli_out ("%-40s %14s %14s %9s", "GFID", "Lookups", "Ref",do { do { if (0) printf ("%-40s %14s %14s %9s", "GFID", "Lookups" , "Ref", "IA type"); } while (0); _cli_out("%-40s %14s %14s %9s" , "GFID", "Lookups", "Ref", "IA type"); } while (0) |
5107 | "IA type")do { do { if (0) printf ("%-40s %14s %14s %9s", "GFID", "Lookups" , "Ref", "IA type"); } while (0); _cli_out("%-40s %14s %14s %9s" , "GFID", "Lookups", "Ref", "IA type"); } while (0); |
5108 | cli_out ("%-40s %14s %14s %9s", "----", "-------", "---",do { do { if (0) printf ("%-40s %14s %14s %9s", "----", "-------" , "---", "-------"); } while (0); _cli_out("%-40s %14s %14s %9s" , "----", "-------", "---", "-------"); } while (0) |
5109 | "-------")do { do { if (0) printf ("%-40s %14s %14s %9s", "----", "-------" , "---", "-------"); } while (0); _cli_out("%-40s %14s %14s %9s" , "----", "-------", "---", "-------"); } while (0); |
5110 | } |
5111 | for (i = 0; i < purge_size; i++) { |
5112 | memset (key, 0, sizeof (key)); |
5113 | snprintf (key, sizeof (key), "%s.purge%d", prefix, i); |
5114 | cli_print_volume_status_inode_entry (dict, key); |
5115 | } |
5116 | |
5117 | out: |
5118 | return; |
5119 | } |
5120 | |
5121 | void |
5122 | cli_print_volume_status_inode (dict_t *dict, gf_boolean_t notbrick) |
5123 | { |
5124 | int ret = -1; |
5125 | char *volname = NULL((void*)0); |
5126 | int brick_index_max = -1; |
5127 | int other_count = 0; |
5128 | int index_max = 0; |
5129 | char *hostname = NULL((void*)0); |
5130 | char *path = NULL((void*)0); |
5131 | int online = -1; |
5132 | int conn_count = 0; |
5133 | char key[1024] = {0,}; |
5134 | int i = 0; |
5135 | int j = 0; |
5136 | |
5137 | GF_ASSERT (dict)do { if (!(dict)) { do { do { if (0) printf ("Assertion failed: " "dict"); } while (0); _gf_log_callingfn ("", "cli-rpc-ops.c" , __FUNCTION__, 5137, GF_LOG_ERROR, "Assertion failed: " "dict" ); } while (0); } } while (0); |
5138 | |
5139 | ret = dict_get_str (dict, "volname", &volname); |
5140 | if (ret) |
5141 | goto out; |
5142 | cli_out ("Inode tables for volume %s", volname)do { do { if (0) printf ("Inode tables for volume %s", volname ); } while (0); _cli_out("Inode tables for volume %s", volname ); } while (0); |
5143 | |
5144 | ret = dict_get_int32 (dict, "brick-index-max", &brick_index_max); |
5145 | if (ret) |
5146 | goto out; |
5147 | ret = dict_get_int32 (dict, "other-count", &other_count); |
5148 | if (ret) |
5149 | goto out; |
5150 | |
5151 | index_max = brick_index_max + other_count; |
5152 | |
5153 | for ( i = 0; i <= index_max; i++) { |
5154 | cli_out ("----------------------------------------------")do { do { if (0) printf ("----------------------------------------------" ); } while (0); _cli_out("----------------------------------------------" ); } while (0); |
5155 | |
5156 | memset (key, 0, sizeof (key)); |
5157 | snprintf (key, sizeof (key), "brick%d.hostname", i); |
5158 | ret = dict_get_str (dict, key, &hostname); |
5159 | if (ret) |
5160 | goto out; |
5161 | memset (key, 0, sizeof (key)); |
5162 | snprintf (key, sizeof (key), "brick%d.path", i); |
5163 | ret = dict_get_str (dict, key, &path); |
5164 | if (ret) |
5165 | goto out; |
5166 | if (notbrick) |
5167 | cli_out ("%s : %s", hostname, path)do { do { if (0) printf ("%s : %s", hostname, path); } while ( 0); _cli_out("%s : %s", hostname, path); } while (0); |
5168 | else |
5169 | cli_out ("Brick : %s:%s", hostname, path)do { do { if (0) printf ("Brick : %s:%s", hostname, path); } while (0); _cli_out("Brick : %s:%s", hostname, path); } while (0); |
5170 | |
5171 | memset (key, 0, sizeof (key)); |
5172 | snprintf (key, sizeof (key), "brick%d.status", i); |
5173 | ret = dict_get_int32 (dict, key, &online); |
5174 | if (ret) |
5175 | goto out; |
5176 | if (!online) { |
5177 | if (notbrick) |
5178 | cli_out ("%s is offline", hostname)do { do { if (0) printf ("%s is offline", hostname); } while ( 0); _cli_out("%s is offline", hostname); } while (0); |
5179 | else |
5180 | cli_out ("Brick is offline")do { do { if (0) printf ("Brick is offline"); } while (0); _cli_out ("Brick is offline"); } while (0); |
5181 | continue; |
5182 | } |
5183 | |
5184 | memset (key, 0, sizeof (key)); |
5185 | snprintf (key, sizeof (key), "brick%d.conncount", i); |
5186 | ret = dict_get_int32 (dict, key, &conn_count); |
5187 | if (ret) |
5188 | goto out; |
5189 | |
5190 | for (j = 0; j < conn_count; j++) { |
5191 | if (conn_count > 1) |
5192 | cli_out ("Connection %d:", j+1)do { do { if (0) printf ("Connection %d:", j+1); } while (0); _cli_out("Connection %d:", j+1); } while (0); |
5193 | |
5194 | memset (key, 0, sizeof (key)); |
5195 | snprintf (key, sizeof (key), "brick%d.conn%d.itable", |
5196 | i, j); |
5197 | cli_print_volume_status_itables (dict, key); |
5198 | cli_out (" ")do { do { if (0) printf (" "); } while (0); _cli_out(" "); } while (0); |
5199 | } |
5200 | } |
5201 | out: |
5202 | cli_out ("----------------------------------------------")do { do { if (0) printf ("----------------------------------------------" ); } while (0); _cli_out("----------------------------------------------" ); } while (0); |
5203 | return; |
5204 | } |
5205 | |
5206 | void |
5207 | cli_print_volume_status_fdtable (dict_t *dict, char *prefix) |
5208 | { |
5209 | int ret = -1; |
5210 | char key[1024] = {0,}; |
5211 | int refcount = 0; |
5212 | uint32_t maxfds = 0; |
5213 | int firstfree = 0; |
5214 | int openfds = 0; |
5215 | int fd_pid = 0; |
5216 | int fd_refcount = 0; |
5217 | int fd_flags = 0; |
5218 | int i = 0; |
5219 | |
5220 | GF_ASSERT (dict)do { if (!(dict)) { do { do { if (0) printf ("Assertion failed: " "dict"); } while (0); _gf_log_callingfn ("", "cli-rpc-ops.c" , __FUNCTION__, 5220, GF_LOG_ERROR, "Assertion failed: " "dict" ); } while (0); } } while (0); |
5221 | GF_ASSERT (prefix)do { if (!(prefix)) { do { do { if (0) printf ("Assertion failed: " "prefix"); } while (0); _gf_log_callingfn ("", "cli-rpc-ops.c" , __FUNCTION__, 5221, GF_LOG_ERROR, "Assertion failed: " "prefix" ); } while (0); } } while (0); |
5222 | |
5223 | memset (key, 0, sizeof (key)); |
5224 | snprintf (key, sizeof (key), "%s.refcount", prefix); |
5225 | ret = dict_get_int32 (dict, key, &refcount); |
5226 | if (ret) |
5227 | goto out; |
5228 | |
5229 | memset (key, 0, sizeof (key)); |
5230 | snprintf (key, sizeof (key), "%s.maxfds", prefix); |
5231 | ret = dict_get_uint32 (dict, key, &maxfds); |
5232 | if (ret) |
5233 | goto out; |
5234 | |
5235 | memset (key, 0 ,sizeof (key)); |
5236 | snprintf (key, sizeof (key), "%s.firstfree", prefix); |
5237 | ret = dict_get_int32 (dict, key, &firstfree); |
5238 | if (ret) |
5239 | goto out; |
5240 | |
5241 | cli_out ("RefCount = %d MaxFDs = %d FirstFree = %d",do { do { if (0) printf ("RefCount = %d MaxFDs = %d FirstFree = %d" , refcount, maxfds, firstfree); } while (0); _cli_out("RefCount = %d MaxFDs = %d FirstFree = %d" , refcount, maxfds, firstfree); } while (0) |
5242 | refcount, maxfds, firstfree)do { do { if (0) printf ("RefCount = %d MaxFDs = %d FirstFree = %d" , refcount, maxfds, firstfree); } while (0); _cli_out("RefCount = %d MaxFDs = %d FirstFree = %d" , refcount, maxfds, firstfree); } while (0); |
5243 | |
5244 | memset (key, 0, sizeof (key)); |
5245 | snprintf (key, sizeof (key), "%s.openfds", prefix); |
5246 | ret = dict_get_int32 (dict, key, &openfds); |
5247 | if (ret) |
5248 | goto out; |
5249 | if (0 == openfds) { |
5250 | cli_err ("No open fds")do { do { if (0) printf ("No open fds"); } while (0); _cli_err ("No open fds"); } while (0); |
5251 | goto out; |
5252 | } |
5253 | |
5254 | cli_out ("%-19s %-19s %-19s %-19s", "FD Entry", "PID",do { do { if (0) printf ("%-19s %-19s %-19s %-19s", "FD Entry" , "PID", "RefCount", "Flags"); } while (0); _cli_out("%-19s %-19s %-19s %-19s" , "FD Entry", "PID", "RefCount", "Flags"); } while (0) |
5255 | "RefCount", "Flags")do { do { if (0) printf ("%-19s %-19s %-19s %-19s", "FD Entry" , "PID", "RefCount", "Flags"); } while (0); _cli_out("%-19s %-19s %-19s %-19s" , "FD Entry", "PID", "RefCount", "Flags"); } while (0); |
5256 | cli_out ("%-19s %-19s %-19s %-19s", "--------", "---",do { do { if (0) printf ("%-19s %-19s %-19s %-19s", "--------" , "---", "--------", "-----"); } while (0); _cli_out("%-19s %-19s %-19s %-19s" , "--------", "---", "--------", "-----"); } while (0) |
5257 | "--------", "-----")do { do { if (0) printf ("%-19s %-19s %-19s %-19s", "--------" , "---", "--------", "-----"); } while (0); _cli_out("%-19s %-19s %-19s %-19s" , "--------", "---", "--------", "-----"); } while (0); |
5258 | |
5259 | for (i = 0; i < maxfds ; i++) { |
5260 | memset (key, 0, sizeof (key)); |
5261 | snprintf (key, sizeof (key), "%s.fdentry%d.pid", prefix, i); |
5262 | ret = dict_get_int32 (dict, key, &fd_pid); |
5263 | if (ret) |
5264 | continue; |
5265 | |
5266 | memset (key, 0, sizeof (key)); |
5267 | snprintf (key, sizeof (key), "%s.fdentry%d.refcount", |
5268 | prefix, i); |
5269 | ret = dict_get_int32 (dict, key, &fd_refcount); |
5270 | if (ret) |
5271 | continue; |
5272 | |
5273 | memset (key, 0, sizeof (key)); |
5274 | snprintf (key, sizeof (key), "%s.fdentry%d.flags", prefix, i); |
5275 | ret = dict_get_int32 (dict, key, &fd_flags); |
5276 | if (ret) |
5277 | continue; |
5278 | |
5279 | cli_out ("%-19d %-19d %-19d %-19d", i, fd_pid, fd_refcount,do { do { if (0) printf ("%-19d %-19d %-19d %-19d", i, fd_pid , fd_refcount, fd_flags); } while (0); _cli_out("%-19d %-19d %-19d %-19d" , i, fd_pid, fd_refcount, fd_flags); } while (0) |
5280 | fd_flags)do { do { if (0) printf ("%-19d %-19d %-19d %-19d", i, fd_pid , fd_refcount, fd_flags); } while (0); _cli_out("%-19d %-19d %-19d %-19d" , i, fd_pid, fd_refcount, fd_flags); } while (0); |
5281 | } |
5282 | |
5283 | out: |
5284 | return; |
5285 | } |
5286 | |
5287 | void |
5288 | cli_print_volume_status_fd (dict_t *dict, gf_boolean_t notbrick) |
5289 | { |
5290 | int ret = -1; |
5291 | char *volname = NULL((void*)0); |
5292 | int brick_index_max = -1; |
5293 | int other_count = 0; |
5294 | int index_max = 0; |
5295 | char *hostname = NULL((void*)0); |
5296 | char *path = NULL((void*)0); |
5297 | int online = -1; |
5298 | int conn_count = 0; |
5299 | char key[1024] = {0,}; |
5300 | int i = 0; |
5301 | int j = 0; |
5302 | |
5303 | GF_ASSERT (dict)do { if (!(dict)) { do { do { if (0) printf ("Assertion failed: " "dict"); } while (0); _gf_log_callingfn ("", "cli-rpc-ops.c" , __FUNCTION__, 5303, GF_LOG_ERROR, "Assertion failed: " "dict" ); } while (0); } } while (0); |
5304 | |
5305 | ret = dict_get_str (dict, "volname", &volname); |
5306 | if (ret) |
5307 | goto out; |
5308 | cli_out ("FD tables for volume %s", volname)do { do { if (0) printf ("FD tables for volume %s", volname); } while (0); _cli_out("FD tables for volume %s", volname); } while (0); |
5309 | |
5310 | ret = dict_get_int32 (dict, "brick-index-max", &brick_index_max); |
5311 | if (ret) |
5312 | goto out; |
5313 | ret = dict_get_int32 (dict, "other-count", &other_count); |
5314 | if (ret) |
5315 | goto out; |
5316 | |
5317 | index_max = brick_index_max + other_count; |
5318 | |
5319 | for (i = 0; i <= index_max; i++) { |
5320 | cli_out ("----------------------------------------------")do { do { if (0) printf ("----------------------------------------------" ); } while (0); _cli_out("----------------------------------------------" ); } while (0); |
5321 | |
5322 | memset (key, 0, sizeof (key)); |
5323 | snprintf (key, sizeof (key), "brick%d.hostname", i); |
5324 | ret = dict_get_str (dict, key, &hostname); |
5325 | if (ret) |
5326 | goto out; |
5327 | memset (key, 0, sizeof (key)); |
5328 | snprintf (key, sizeof (key), "brick%d.path", i); |
5329 | ret = dict_get_str (dict, key, &path); |
5330 | if (ret) |
5331 | goto out; |
5332 | |
5333 | if (notbrick) |
5334 | cli_out ("%s : %s", hostname, path)do { do { if (0) printf ("%s : %s", hostname, path); } while ( 0); _cli_out("%s : %s", hostname, path); } while (0); |
5335 | else |
5336 | cli_out ("Brick : %s:%s", hostname, path)do { do { if (0) printf ("Brick : %s:%s", hostname, path); } while (0); _cli_out("Brick : %s:%s", hostname, path); } while (0); |
5337 | |
5338 | memset (key, 0, sizeof (key)); |
5339 | snprintf (key, sizeof (key), "brick%d.status", i); |
5340 | ret = dict_get_int32 (dict, key, &online); |
5341 | if (ret) |
5342 | goto out; |
5343 | if (!online) { |
5344 | if (notbrick) |
5345 | cli_out ("%s is offline", hostname)do { do { if (0) printf ("%s is offline", hostname); } while ( 0); _cli_out("%s is offline", hostname); } while (0); |
5346 | else |
5347 | cli_out ("Brick is offline")do { do { if (0) printf ("Brick is offline"); } while (0); _cli_out ("Brick is offline"); } while (0); |
5348 | continue; |
5349 | } |
5350 | |
5351 | memset (key, 0, sizeof (key)); |
5352 | snprintf (key, sizeof (key), "brick%d.conncount", i); |
5353 | ret = dict_get_int32 (dict, key, &conn_count); |
5354 | if (ret) |
5355 | goto out; |
5356 | |
5357 | for (j = 0; j < conn_count; j++) { |
5358 | cli_out ("Connection %d:", j+1)do { do { if (0) printf ("Connection %d:", j+1); } while (0); _cli_out("Connection %d:", j+1); } while (0); |
5359 | |
5360 | memset (key, 0, sizeof (key)); |
5361 | snprintf (key, sizeof (key), "brick%d.conn%d.fdtable", |
5362 | i, j); |
5363 | cli_print_volume_status_fdtable (dict, key); |
5364 | cli_out (" ")do { do { if (0) printf (" "); } while (0); _cli_out(" "); } while (0); |
5365 | } |
5366 | } |
5367 | out: |
5368 | cli_out ("----------------------------------------------")do { do { if (0) printf ("----------------------------------------------" ); } while (0); _cli_out("----------------------------------------------" ); } while (0); |
5369 | return; |
5370 | } |
5371 | |
5372 | void |
5373 | cli_print_volume_status_call_frame (dict_t *dict, char *prefix) |
5374 | { |
5375 | int ret = -1; |
5376 | char key[1024] = {0,}; |
5377 | int ref_count = 0; |
5378 | char *translator = 0; |
5379 | int complete = 0; |
5380 | char *parent = NULL((void*)0); |
5381 | char *wind_from = NULL((void*)0); |
5382 | char *wind_to = NULL((void*)0); |
5383 | char *unwind_from = NULL((void*)0); |
5384 | char *unwind_to = NULL((void*)0); |
5385 | |
5386 | if (!dict || !prefix) |
5387 | return; |
5388 | |
5389 | memset (key, 0, sizeof (key)); |
5390 | snprintf (key, sizeof (key), "%s.refcount", prefix); |
5391 | ret = dict_get_int32 (dict, key, &ref_count); |
5392 | if (ret) |
5393 | return; |
5394 | |
5395 | memset (key, 0, sizeof (key)); |
5396 | snprintf (key, sizeof (key), "%s.translator", prefix); |
5397 | ret = dict_get_str (dict, key, &translator); |
5398 | if (ret) |
5399 | return; |
5400 | |
5401 | memset (key, 0, sizeof (key)); |
5402 | snprintf (key, sizeof (key), "%s.complete", prefix); |
5403 | ret = dict_get_int32 (dict, key, &complete); |
5404 | if (ret) |
5405 | return; |
5406 | |
5407 | cli_out (" Ref Count = %d", ref_count)do { do { if (0) printf (" Ref Count = %d", ref_count); } while (0); _cli_out(" Ref Count = %d", ref_count); } while (0); |
5408 | cli_out (" Translator = %s", translator)do { do { if (0) printf (" Translator = %s", translator); } while (0); _cli_out(" Translator = %s", translator); } while (0); |
5409 | cli_out (" Completed = %s", (complete ? "Yes" : "No"))do { do { if (0) printf (" Completed = %s", (complete ? "Yes" : "No")); } while (0); _cli_out(" Completed = %s", (complete ? "Yes" : "No")); } while (0); |
5410 | |
5411 | memset (key, 0, sizeof (key)); |
5412 | snprintf (key, sizeof (key), "%s.parent", prefix); |
5413 | ret = dict_get_str (dict, key, &parent); |
5414 | if (!ret) |
5415 | cli_out (" Parent = %s", parent)do { do { if (0) printf (" Parent = %s", parent); } while (0); _cli_out(" Parent = %s", parent); } while (0); |
5416 | |
5417 | memset (key, 0, sizeof (key)); |
5418 | snprintf (key, sizeof (key), "%s.windfrom", prefix); |
5419 | ret = dict_get_str (dict, key, &wind_from); |
5420 | if (!ret) |
5421 | cli_out (" Wind From = %s", wind_from)do { do { if (0) printf (" Wind From = %s", wind_from); } while (0); _cli_out(" Wind From = %s", wind_from); } while (0); |
5422 | |
5423 | memset (key, 0, sizeof (key)); |
5424 | snprintf (key, sizeof (key), "%s.windto", prefix); |
5425 | ret = dict_get_str (dict, key, &wind_to); |
5426 | if (!ret) |
5427 | cli_out (" Wind To = %s", wind_to)do { do { if (0) printf (" Wind To = %s", wind_to); } while (0); _cli_out(" Wind To = %s", wind_to); } while (0); |
5428 | |
5429 | memset (key, 0, sizeof (key)); |
5430 | snprintf (key, sizeof (key), "%s.unwindfrom", prefix); |
5431 | ret = dict_get_str (dict, key, &unwind_from); |
5432 | if (!ret) |
5433 | cli_out (" Unwind From = %s", unwind_from)do { do { if (0) printf (" Unwind From = %s", unwind_from); } while (0); _cli_out(" Unwind From = %s", unwind_from); } while (0); |
5434 | |
5435 | memset (key, 0, sizeof (key)); |
5436 | snprintf (key, sizeof (key), "%s.unwindto", prefix); |
5437 | ret = dict_get_str (dict, key, &unwind_to); |
5438 | if (!ret) |
5439 | cli_out (" Unwind To = %s", unwind_to)do { do { if (0) printf (" Unwind To = %s", unwind_to); } while (0); _cli_out(" Unwind To = %s", unwind_to); } while (0); |
5440 | } |
5441 | |
5442 | void |
5443 | cli_print_volume_status_call_stack (dict_t *dict, char *prefix) |
5444 | { |
5445 | int ret = -1; |
5446 | char key[1024] = {0,}; |
5447 | int uid = 0; |
5448 | int gid = 0; |
5449 | int pid = 0; |
5450 | uint64_t unique = 0; |
5451 | //char *op = NULL; |
5452 | int count = 0; |
5453 | int i = 0; |
5454 | |
5455 | if (!dict || !prefix) |
5456 | return; |
5457 | |
5458 | memset (key, 0, sizeof (key)); |
5459 | snprintf (key, sizeof (key), "%s.uid", prefix); |
5460 | ret = dict_get_int32 (dict, key, &uid); |
5461 | if (ret) |
5462 | return; |
5463 | |
5464 | memset (key, 0, sizeof (key)); |
5465 | snprintf (key, sizeof (key), "%s.gid", prefix); |
5466 | ret = dict_get_int32 (dict, key, &gid); |
5467 | if (ret) |
5468 | return; |
5469 | |
5470 | memset (key, 0, sizeof (key)); |
5471 | snprintf (key, sizeof (key), "%s.pid", prefix); |
5472 | ret = dict_get_int32 (dict, key, &pid); |
5473 | if (ret) |
5474 | return; |
5475 | |
5476 | memset (key, 0, sizeof (key)); |
5477 | snprintf (key, sizeof (key), "%s.unique", prefix); |
5478 | ret = dict_get_uint64 (dict, key, &unique); |
5479 | if (ret) |
5480 | return; |
5481 | |
5482 | /* |
5483 | memset (key, 0, sizeof (key)); |
5484 | snprintf (key, sizeof (key), "%s.op", prefix); |
5485 | ret = dict_get_str (dict, key, &op); |
5486 | if (ret) |
5487 | return; |
5488 | */ |
5489 | |
5490 | |
5491 | memset (key, 0, sizeof (key)); |
5492 | snprintf (key, sizeof (key), "%s.count", prefix); |
5493 | ret = dict_get_int32 (dict, key, &count); |
5494 | if (ret) |
5495 | return; |
5496 | |
5497 | cli_out (" UID : %d", uid)do { do { if (0) printf (" UID : %d", uid); } while (0); _cli_out (" UID : %d", uid); } while (0); |
5498 | cli_out (" GID : %d", gid)do { do { if (0) printf (" GID : %d", gid); } while (0); _cli_out (" GID : %d", gid); } while (0); |
5499 | cli_out (" PID : %d", pid)do { do { if (0) printf (" PID : %d", pid); } while (0); _cli_out (" PID : %d", pid); } while (0); |
5500 | cli_out (" Unique : %"PRIu64, unique)do { do { if (0) printf (" Unique : %""ll" "u", unique); } while (0); _cli_out(" Unique : %""ll" "u", unique); } while (0); |
5501 | //cli_out ("\tOp : %s", op); |
5502 | cli_out (" Frames : %d", count)do { do { if (0) printf (" Frames : %d", count); } while (0); _cli_out(" Frames : %d", count); } while (0); |
5503 | |
5504 | for (i = 0; i < count; i++) { |
5505 | cli_out (" Frame %d", i+1)do { do { if (0) printf (" Frame %d", i+1); } while (0); _cli_out (" Frame %d", i+1); } while (0); |
5506 | |
5507 | memset (key, 0, sizeof (key)); |
5508 | snprintf (key, sizeof (key), "%s.frame%d", prefix, i); |
5509 | cli_print_volume_status_call_frame (dict, key); |
5510 | } |
5511 | |
5512 | cli_out (" ")do { do { if (0) printf (" "); } while (0); _cli_out(" "); } while (0); |
5513 | } |
5514 | |
5515 | void |
5516 | cli_print_volume_status_callpool (dict_t *dict, gf_boolean_t notbrick) |
5517 | { |
5518 | int ret = -1; |
5519 | char *volname = NULL((void*)0); |
5520 | int brick_index_max = -1; |
5521 | int other_count = 0; |
5522 | int index_max = 0; |
5523 | char *hostname = NULL((void*)0); |
5524 | char *path = NULL((void*)0); |
5525 | int online = -1; |
5526 | int call_count = 0; |
5527 | char key[1024] = {0,}; |
5528 | int i = 0; |
5529 | int j = 0; |
5530 | |
5531 | GF_ASSERT (dict)do { if (!(dict)) { do { do { if (0) printf ("Assertion failed: " "dict"); } while (0); _gf_log_callingfn ("", "cli-rpc-ops.c" , __FUNCTION__, 5531, GF_LOG_ERROR, "Assertion failed: " "dict" ); } while (0); } } while (0); |
5532 | |
5533 | ret = dict_get_str (dict, "volname", &volname); |
5534 | if (ret) |
5535 | goto out; |
5536 | cli_out ("Pending calls for volume %s", volname)do { do { if (0) printf ("Pending calls for volume %s", volname ); } while (0); _cli_out("Pending calls for volume %s", volname ); } while (0); |
5537 | |
5538 | ret = dict_get_int32 (dict, "brick-index-max", &brick_index_max); |
5539 | if (ret) |
5540 | goto out; |
5541 | ret = dict_get_int32 (dict, "other-count", &other_count); |
5542 | if (ret) |
5543 | goto out; |
5544 | |
5545 | index_max = brick_index_max + other_count; |
5546 | |
5547 | for (i = 0; i <= index_max; i++) { |
5548 | cli_out ("----------------------------------------------")do { do { if (0) printf ("----------------------------------------------" ); } while (0); _cli_out("----------------------------------------------" ); } while (0); |
5549 | |
5550 | memset (key, 0, sizeof (key)); |
5551 | snprintf (key, sizeof (key), "brick%d.hostname", i); |
5552 | ret = dict_get_str (dict, key, &hostname); |
5553 | if (ret) |
5554 | goto out; |
5555 | memset (key, 0, sizeof (key)); |
5556 | snprintf (key, sizeof (key), "brick%d.path", i); |
5557 | ret = dict_get_str (dict, key, &path); |
5558 | if (ret) |
5559 | goto out; |
5560 | |
5561 | if (notbrick) |
5562 | cli_out ("%s : %s", hostname, path)do { do { if (0) printf ("%s : %s", hostname, path); } while ( 0); _cli_out("%s : %s", hostname, path); } while (0); |
5563 | else |
5564 | cli_out ("Brick : %s:%s", hostname, path)do { do { if (0) printf ("Brick : %s:%s", hostname, path); } while (0); _cli_out("Brick : %s:%s", hostname, path); } while (0); |
5565 | |
5566 | memset (key, 0, sizeof (key)); |
5567 | snprintf (key, sizeof (key), "brick%d.status", i); |
5568 | ret = dict_get_int32 (dict, key, &online); |
5569 | if (ret) |
5570 | goto out; |
5571 | if (!online) { |
5572 | if (notbrick) |
5573 | cli_out ("%s is offline", hostname)do { do { if (0) printf ("%s is offline", hostname); } while ( 0); _cli_out("%s is offline", hostname); } while (0); |
5574 | else |
5575 | cli_out ("Brick is offline")do { do { if (0) printf ("Brick is offline"); } while (0); _cli_out ("Brick is offline"); } while (0); |
5576 | continue; |
5577 | } |
5578 | |
5579 | memset (key, 0, sizeof (key)); |
5580 | snprintf (key, sizeof (key), "brick%d.callpool.count", i); |
5581 | ret = dict_get_int32 (dict, key, &call_count); |
5582 | if (ret) |
5583 | goto out; |
5584 | cli_out ("Pending calls: %d", call_count)do { do { if (0) printf ("Pending calls: %d", call_count); } while (0); _cli_out("Pending calls: %d", call_count); } while (0); |
5585 | |
5586 | if (0 == call_count) |
5587 | continue; |
5588 | |
5589 | for (j = 0; j < call_count; j++) { |
5590 | cli_out ("Call Stack%d", j+1)do { do { if (0) printf ("Call Stack%d", j+1); } while (0); _cli_out ("Call Stack%d", j+1); } while (0); |
5591 | |
5592 | memset (key, 0, sizeof (key)); |
5593 | snprintf (key, sizeof (key), |
5594 | "brick%d.callpool.stack%d", i, j); |
5595 | cli_print_volume_status_call_stack (dict, key); |
5596 | } |
5597 | } |
5598 | |
5599 | out: |
5600 | cli_out ("----------------------------------------------")do { do { if (0) printf ("----------------------------------------------" ); } while (0); _cli_out("----------------------------------------------" ); } while (0); |
5601 | return; |
5602 | } |
5603 | |
5604 | |
5605 | static void |
5606 | cli_print_volume_tasks (dict_t *dict) { |
5607 | int ret = -1; |
5608 | int tasks = 0; |
5609 | char *op = 0; |
5610 | char *task_id_str = NULL((void*)0); |
5611 | int status = 0; |
5612 | char key[1024] = {0,}; |
5613 | int i = 0; |
5614 | |
5615 | ret = dict_get_int32 (dict, "tasks", &tasks); |
5616 | if (ret) { |
5617 | gf_log ("cli", GF_LOG_ERROR,do { do { if (0) printf ("Failed to get tasks count"); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 5618, GF_LOG_ERROR , "Failed to get tasks count"); } while (0) |
5618 | "Failed to get tasks count")do { do { if (0) printf ("Failed to get tasks count"); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 5618, GF_LOG_ERROR , "Failed to get tasks count"); } while (0); |
5619 | return; |
5620 | } |
5621 | |
5622 | if (tasks == 0) { |
5623 | cli_out ("There are no active volume tasks")do { do { if (0) printf ("There are no active volume tasks"); } while (0); _cli_out("There are no active volume tasks"); } while (0); |
5624 | return; |
5625 | } |
5626 | |
5627 | cli_out ("%15s%40s%15s", "Task", "ID", "Status")do { do { if (0) printf ("%15s%40s%15s", "Task", "ID", "Status" ); } while (0); _cli_out("%15s%40s%15s", "Task", "ID", "Status" ); } while (0); |
5628 | cli_out ("%15s%40s%15s", "----", "--", "------")do { do { if (0) printf ("%15s%40s%15s", "----", "--", "------" ); } while (0); _cli_out("%15s%40s%15s", "----", "--", "------" ); } while (0); |
5629 | for (i = 0; i < tasks; i++) { |
5630 | memset (key, 0, sizeof (key)); |
5631 | snprintf (key, sizeof (key), "task%d.type", i); |
5632 | ret = dict_get_str(dict, key, &op); |
5633 | if (ret) |
5634 | return; |
5635 | |
5636 | memset (key, 0, sizeof (key)); |
5637 | snprintf (key, sizeof (key), "task%d.id", i); |
5638 | ret = dict_get_str (dict, key, &task_id_str); |
5639 | if (ret) |
5640 | return; |
5641 | |
5642 | memset (key, 0, sizeof (key)); |
5643 | snprintf (key, sizeof (key), "task%d.status", i); |
5644 | ret = dict_get_int32 (dict, key, &status); |
5645 | if (ret) |
5646 | return; |
5647 | |
5648 | cli_out ("%15s%40s%15d", op, task_id_str, status)do { do { if (0) printf ("%15s%40s%15d", op, task_id_str, status ); } while (0); _cli_out("%15s%40s%15d", op, task_id_str, status ); } while (0); |
5649 | } |
5650 | |
5651 | } |
5652 | |
5653 | static int |
5654 | gf_cli_status_cbk (struct rpc_req *req, struct iovec *iov, |
5655 | int count, void *myframe) |
5656 | { |
5657 | int ret = -1; |
5658 | int brick_index_max = -1; |
5659 | int other_count = 0; |
5660 | int index_max = 0; |
5661 | int i = 0; |
5662 | int pid = -1; |
5663 | uint32_t cmd = 0; |
5664 | gf_boolean_t notbrick = _gf_false; |
5665 | char key[1024] = {0,}; |
5666 | char *hostname = NULL((void*)0); |
5667 | char *path = NULL((void*)0); |
5668 | char *volname = NULL((void*)0); |
5669 | dict_t *dict = NULL((void*)0); |
5670 | gf_cli_rsp rsp = {0,}; |
5671 | cli_volume_status_t status = {0}; |
5672 | cli_local_t *local = NULL((void*)0); |
5673 | gf_boolean_t wipe_local = _gf_false; |
5674 | char msg[1024] = {0,}; |
5675 | |
5676 | if (req->rpc_status == -1) |
5677 | goto out; |
5678 | |
5679 | ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_cli_rsp); |
5680 | if (ret < 0) { |
5681 | gf_log (((call_frame_t *) myframe)->this->name, GF_LOG_ERROR,do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (((call_frame_t *) myframe)->this->name, "cli-rpc-ops.c" , __FUNCTION__, 5682, GF_LOG_ERROR, "Failed to decode xdr response" ); } while (0) |
5682 | "Failed to decode xdr response")do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (((call_frame_t *) myframe)->this->name, "cli-rpc-ops.c" , __FUNCTION__, 5682, GF_LOG_ERROR, "Failed to decode xdr response" ); } while (0); |
5683 | goto out; |
5684 | } |
5685 | |
5686 | gf_log ("cli", GF_LOG_DEBUG, "Received response to status cmd")do { do { if (0) printf ("Received response to status cmd"); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 5686 , GF_LOG_DEBUG, "Received response to status cmd"); } while ( 0); |
5687 | |
5688 | local = ((call_frame_t *)myframe)->local; |
5689 | if (!local) { |
5690 | local = cli_local_get (); |
5691 | if (!local) { |
5692 | ret = -1; |
5693 | gf_log ("cli", GF_LOG_ERROR, "Failed to get local")do { do { if (0) printf ("Failed to get local"); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 5693, GF_LOG_ERROR , "Failed to get local"); } while (0); |
5694 | goto out; |
5695 | } |
5696 | wipe_local = _gf_true; |
5697 | } |
5698 | |
5699 | if (rsp.op_ret) { |
5700 | if (strcmp (rsp.op_errstr, "")) |
5701 | snprintf (msg, sizeof (msg), "%s", rsp.op_errstr); |
5702 | else |
5703 | snprintf (msg, sizeof (msg), "Unable to obtain volume " |
5704 | "status information."); |
5705 | |
5706 | if (global_state->mode & GLUSTER_MODE_XML(1 << 2)) { |
5707 | cli_xml_output_str ("volStatus", msg, rsp.op_ret, |
5708 | rsp.op_errno, rsp.op_errstr); |
5709 | ret = 0; |
5710 | goto out; |
5711 | } |
5712 | |
5713 | cli_err ("%s", msg)do { do { if (0) printf ("%s", msg); } while (0); _cli_err("%s" , msg); } while (0); |
5714 | if (local && local->all) { |
5715 | ret = 0; |
5716 | cli_out (" ")do { do { if (0) printf (" "); } while (0); _cli_out(" "); } while (0); |
5717 | } else |
5718 | ret = -1; |
5719 | |
5720 | goto out; |
5721 | } |
5722 | |
5723 | dict = dict_new (); |
5724 | if (!dict) |
5725 | goto out; |
5726 | |
5727 | ret = dict_unserialize (rsp.dict.dict_val, |
5728 | rsp.dict.dict_len, |
5729 | &dict); |
5730 | if (ret) |
5731 | goto out; |
5732 | |
5733 | ret = dict_get_uint32 (dict, "cmd", &cmd); |
5734 | if (ret) |
5735 | goto out; |
5736 | |
5737 | if ((cmd & GF_CLI_STATUS_ALL)) { |
5738 | if (local && local->dict) { |
5739 | dict_ref (dict); |
5740 | ret = dict_set_static_ptr (local->dict, "rsp-dict", dict); |
5741 | ret = 0; |
5742 | } else { |
5743 | gf_log ("cli", GF_LOG_ERROR, "local not found")do { do { if (0) printf ("local not found"); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 5743, GF_LOG_ERROR, "local not found" ); } while (0); |
5744 | ret = -1; |
5745 | } |
5746 | goto out; |
5747 | } |
5748 | |
5749 | if ((cmd & GF_CLI_STATUS_NFS) || (cmd & GF_CLI_STATUS_SHD)) |
5750 | notbrick = _gf_true; |
5751 | |
5752 | ret = dict_get_int32 (dict, "count", &count); |
5753 | if (ret) |
5754 | goto out; |
5755 | if (count == 0) { |
5756 | ret = -1; |
5757 | goto out; |
5758 | } |
5759 | |
5760 | ret = dict_get_int32 (dict, "brick-index-max", &brick_index_max); |
5761 | if (ret) |
5762 | goto out; |
5763 | ret = dict_get_int32 (dict, "other-count", &other_count); |
5764 | if (ret) |
5765 | goto out; |
5766 | |
5767 | index_max = brick_index_max + other_count; |
5768 | |
5769 | if (global_state->mode & GLUSTER_MODE_XML(1 << 2)) { |
5770 | if (!local->all) { |
5771 | ret = cli_xml_output_vol_status_begin (local, |
5772 | rsp.op_ret, |
5773 | rsp.op_errno, |
5774 | rsp.op_errstr); |
5775 | if (ret) { |
5776 | gf_log ("cli", GF_LOG_ERROR,do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 5777, GF_LOG_ERROR , "Error outputting to xml"); } while (0) |
5777 | "Error outputting to xml")do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 5777, GF_LOG_ERROR , "Error outputting to xml"); } while (0); |
5778 | goto out; |
5779 | } |
5780 | } |
5781 | ret = cli_xml_output_vol_status (local, dict); |
5782 | if (ret) { |
5783 | gf_log ("cli", GF_LOG_ERROR,do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 5784, GF_LOG_ERROR , "Error outputting to xml"); } while (0) |
5784 | "Error outputting to xml")do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 5784, GF_LOG_ERROR , "Error outputting to xml"); } while (0); |
5785 | goto out; |
5786 | } |
5787 | |
5788 | if (!local->all) { |
5789 | ret = cli_xml_output_vol_status_end (local); |
5790 | if (ret) { |
5791 | gf_log ("cli", GF_LOG_ERROR,do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 5792, GF_LOG_ERROR , "Error outputting to xml"); } while (0) |
5792 | "Error outputting to xml")do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 5792, GF_LOG_ERROR , "Error outputting to xml"); } while (0); |
5793 | } |
5794 | } |
5795 | goto out; |
5796 | } |
5797 | |
5798 | status.brick = GF_CALLOC (1, PATH_MAX + 256, gf_common_mt_strdup)__gf_calloc (1, 4096 + 256, gf_common_mt_strdup); |
5799 | |
5800 | switch (cmd & GF_CLI_STATUS_MASK) { |
5801 | case GF_CLI_STATUS_MEM: |
5802 | cli_print_volume_status_mem (dict, notbrick); |
5803 | goto cont; |
5804 | break; |
5805 | case GF_CLI_STATUS_CLIENTS: |
5806 | cli_print_volume_status_clients (dict, notbrick); |
5807 | goto cont; |
5808 | break; |
5809 | case GF_CLI_STATUS_INODE: |
5810 | cli_print_volume_status_inode (dict, notbrick); |
5811 | goto cont; |
5812 | break; |
5813 | case GF_CLI_STATUS_FD: |
5814 | cli_print_volume_status_fd (dict, notbrick); |
5815 | goto cont; |
5816 | break; |
5817 | case GF_CLI_STATUS_CALLPOOL: |
5818 | cli_print_volume_status_callpool (dict, notbrick); |
5819 | goto cont; |
5820 | break; |
5821 | default: |
5822 | break; |
5823 | } |
5824 | |
5825 | ret = dict_get_str (dict, "volname", &volname); |
5826 | if (ret) |
5827 | goto out; |
5828 | |
5829 | cli_out ("Status of volume: %s", volname)do { do { if (0) printf ("Status of volume: %s", volname); } while (0); _cli_out("Status of volume: %s", volname); } while (0); |
5830 | |
5831 | if ((cmd & GF_CLI_STATUS_DETAIL) == 0) { |
5832 | cli_out ("Gluster process\t\t\t\t\t\tPort\tOnline\tPid")do { do { if (0) printf ("Gluster process\t\t\t\t\t\tPort\tOnline\tPid" ); } while (0); _cli_out("Gluster process\t\t\t\t\t\tPort\tOnline\tPid" ); } while (0); |
5833 | cli_print_line (CLI_BRICK_STATUS_LINE_LEN78); |
5834 | } |
5835 | |
5836 | for (i = 0; i <= index_max; i++) { |
5837 | |
5838 | |
5839 | memset (key, 0, sizeof (key)); |
5840 | snprintf (key, sizeof (key), "brick%d.hostname", i); |
5841 | ret = dict_get_str (dict, key, &hostname); |
5842 | if (ret) |
5843 | continue; |
5844 | |
5845 | memset (key, 0, sizeof (key)); |
5846 | snprintf (key, sizeof (key), "brick%d.path", i); |
5847 | ret = dict_get_str (dict, key, &path); |
5848 | if (ret) |
5849 | continue; |
5850 | |
5851 | /* Brick/not-brick is handled seperately here as all |
5852 | * types of nodes are contained in the default output |
5853 | */ |
5854 | memset (status.brick, 0, PATH_MAX4096 + 255); |
5855 | if (!strcmp (hostname, "NFS Server") || |
5856 | !strcmp (hostname, "Self-heal Daemon")) |
5857 | snprintf (status.brick, PATH_MAX4096 + 255, "%s on %s", |
5858 | hostname, path); |
5859 | else |
5860 | snprintf (status.brick, PATH_MAX4096 + 255, "Brick %s:%s", |
5861 | hostname, path); |
5862 | |
5863 | memset (key, 0, sizeof (key)); |
5864 | snprintf (key, sizeof (key), "brick%d.port", i); |
5865 | ret = dict_get_int32 (dict, key, &(status.port)); |
5866 | if (ret) |
5867 | continue; |
5868 | |
5869 | memset (key, 0, sizeof (key)); |
5870 | snprintf (key, sizeof (key), "brick%d.status", i); |
5871 | ret = dict_get_int32 (dict, key, &(status.online)); |
5872 | if (ret) |
5873 | continue; |
5874 | |
5875 | memset (key, 0, sizeof (key)); |
5876 | snprintf (key, sizeof (key), "brick%d.pid", i); |
5877 | ret = dict_get_int32 (dict, key, &pid); |
5878 | if (ret) |
5879 | continue; |
5880 | if (pid == -1) |
5881 | ret = gf_asprintf (&(status.pid_str), "%s", "N/A"); |
5882 | else |
5883 | ret = gf_asprintf (&(status.pid_str), "%d", pid); |
5884 | |
5885 | if (ret == -1) |
5886 | goto out; |
5887 | |
5888 | if ((cmd & GF_CLI_STATUS_DETAIL)) { |
5889 | ret = cli_get_detail_status (dict, i, &status); |
5890 | if (ret) |
5891 | goto out; |
5892 | cli_print_line (CLI_BRICK_STATUS_LINE_LEN78); |
5893 | cli_print_detailed_status (&status); |
5894 | |
5895 | } else { |
5896 | cli_print_brick_status (&status); |
5897 | } |
5898 | } |
5899 | cli_out (" ")do { do { if (0) printf (" "); } while (0); _cli_out(" "); } while (0); |
5900 | |
5901 | if ((cmd & GF_CLI_STATUS_MASK) == GF_CLI_STATUS_NONE) |
5902 | cli_print_volume_tasks (dict); |
5903 | cont: |
5904 | ret = rsp.op_ret; |
5905 | |
5906 | out: |
5907 | if (dict) |
5908 | dict_unref (dict); |
5909 | GF_FREE (status.brick)__gf_free (status.brick); |
5910 | if (local && wipe_local) { |
5911 | cli_local_wipe (local); |
5912 | } |
5913 | |
5914 | cli_cmd_broadcast_response (ret); |
5915 | return ret; |
5916 | } |
5917 | |
5918 | int32_t |
5919 | gf_cli_status_volume (call_frame_t *frame, xlator_t *this, |
5920 | void *data) |
5921 | { |
5922 | gf_cli_req req = {{0,}}; |
5923 | int ret = -1; |
5924 | dict_t *dict = NULL((void*)0); |
5925 | |
5926 | if (!frame || !this || !data) |
5927 | goto out; |
5928 | |
5929 | dict = data; |
5930 | |
5931 | ret = cli_to_glusterd (&req, frame, gf_cli_status_cbk, |
5932 | (xdrproc_t) xdr_gf_cli_req, dict, |
5933 | GLUSTER_CLI_STATUS_VOLUME, this, cli_rpc_prog, |
5934 | NULL((void*)0)); |
5935 | out: |
5936 | gf_log ("cli", GF_LOG_DEBUG, "Returning: %d", ret)do { do { if (0) printf ("Returning: %d", ret); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 5936, GF_LOG_DEBUG, "Returning: %d" , ret); } while (0); |
5937 | return ret; |
5938 | } |
5939 | |
5940 | int |
5941 | gf_cli_status_volume_all (call_frame_t *frame, xlator_t *this, void *data) |
5942 | { |
5943 | int i = 0; |
5944 | int ret = -1; |
5945 | int vol_count = -1; |
5946 | uint32_t cmd = 0; |
5947 | char key[1024] = {0}; |
5948 | char *volname = NULL((void*)0); |
5949 | void *vol_dict = NULL((void*)0); |
5950 | dict_t *dict = NULL((void*)0); |
5951 | cli_local_t *local = NULL((void*)0); |
5952 | |
5953 | if (frame->local) { |
5954 | local = frame->local; |
5955 | local->all = _gf_true; |
5956 | } else |
5957 | goto out; |
5958 | |
5959 | ret = dict_get_uint32 (local->dict, "cmd", &cmd); |
5960 | if (ret) |
5961 | goto out; |
5962 | |
5963 | |
5964 | ret = gf_cli_status_volume (frame, this, data); |
5965 | if (ret) |
5966 | goto out; |
5967 | |
5968 | ret = dict_get_ptr (local->dict, "rsp-dict", &vol_dict); |
5969 | if (ret) |
5970 | goto out; |
5971 | |
5972 | ret = dict_get_int32 ((dict_t *)vol_dict, "vol_count", &vol_count); |
5973 | if (ret) { |
5974 | cli_err ("Failed to get names of volumes")do { do { if (0) printf ("Failed to get names of volumes"); } while (0); _cli_err("Failed to get names of volumes"); } while (0); |
5975 | goto out; |
5976 | } |
5977 | |
5978 | if (vol_count == 0) { |
5979 | cli_err ("No volumes present")do { do { if (0) printf ("No volumes present"); } while (0); _cli_err ("No volumes present"); } while (0); |
5980 | ret = 0; |
5981 | goto out; |
5982 | } |
5983 | |
5984 | /* remove the "all" flag in cmd */ |
5985 | cmd &= ~GF_CLI_STATUS_ALL; |
5986 | cmd |= GF_CLI_STATUS_VOL; |
5987 | |
5988 | if (global_state->mode & GLUSTER_MODE_XML(1 << 2)) { |
5989 | //TODO: Pass proper op_* values |
5990 | ret = cli_xml_output_vol_status_begin (local, 0,0, NULL((void*)0)); |
5991 | if (ret) { |
5992 | gf_log ("cli", GF_LOG_ERROR,do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 5993, GF_LOG_ERROR , "Error outputting to xml"); } while (0) |
5993 | "Error outputting to xml")do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 5993, GF_LOG_ERROR , "Error outputting to xml"); } while (0); |
5994 | goto out; |
5995 | } |
5996 | } |
5997 | |
5998 | for (i = 0; i < vol_count; i++) { |
5999 | |
6000 | dict = dict_new (); |
6001 | if (!dict) |
6002 | goto out; |
6003 | |
6004 | memset (key, 0, sizeof (key)); |
6005 | snprintf (key, sizeof (key), "vol%d", i); |
6006 | ret = dict_get_str (vol_dict, key, &volname); |
6007 | if (ret) |
6008 | goto out; |
6009 | |
6010 | ret = dict_set_str (dict, "volname", volname); |
6011 | if (ret) |
6012 | goto out; |
6013 | |
6014 | ret = dict_set_uint32 (dict, "cmd", cmd); |
6015 | if (ret) |
6016 | goto out; |
6017 | |
6018 | ret = gf_cli_status_volume (frame, this, dict); |
6019 | if (ret) |
6020 | goto out; |
6021 | |
6022 | dict_unref (dict); |
6023 | } |
6024 | |
6025 | if (global_state->mode & GLUSTER_MODE_XML(1 << 2)) { |
6026 | ret = cli_xml_output_vol_status_end (local); |
6027 | } |
6028 | |
6029 | out: |
6030 | if (ret) |
6031 | gf_log ("cli", GF_LOG_ERROR, "status all failed")do { do { if (0) printf ("status all failed"); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 6031, GF_LOG_ERROR, "status all failed" ); } while (0); |
6032 | |
6033 | if (vol_dict) |
6034 | dict_unref (vol_dict); |
6035 | |
6036 | if (ret && dict) |
6037 | dict_unref (dict); |
6038 | |
6039 | if (local) |
6040 | cli_local_wipe (local); |
6041 | |
6042 | if (frame) |
6043 | frame->local = NULL((void*)0); |
6044 | |
6045 | return ret; |
6046 | } |
6047 | |
6048 | static int |
6049 | gf_cli_mount_cbk (struct rpc_req *req, struct iovec *iov, |
6050 | int count, void *myframe) |
6051 | { |
6052 | gf1_cli_mount_rsp rsp = {0,}; |
6053 | int ret = -1; |
6054 | |
6055 | if (-1 == req->rpc_status) { |
6056 | goto out; |
6057 | } |
6058 | |
6059 | ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf1_cli_mount_rsp); |
6060 | if (ret < 0) { |
6061 | gf_log (((call_frame_t *) myframe)->this->name, GF_LOG_ERROR,do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (((call_frame_t *) myframe)->this->name, "cli-rpc-ops.c" , __FUNCTION__, 6062, GF_LOG_ERROR, "Failed to decode xdr response" ); } while (0) |
6062 | "Failed to decode xdr response")do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (((call_frame_t *) myframe)->this->name, "cli-rpc-ops.c" , __FUNCTION__, 6062, GF_LOG_ERROR, "Failed to decode xdr response" ); } while (0); |
6063 | goto out; |
6064 | } |
6065 | |
6066 | gf_log ("cli", GF_LOG_INFO, "Received resp to mount")do { do { if (0) printf ("Received resp to mount"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 6066, GF_LOG_INFO , "Received resp to mount"); } while (0); |
6067 | |
6068 | if (rsp.op_ret == 0) { |
6069 | ret = 0; |
6070 | cli_out ("%s", rsp.path)do { do { if (0) printf ("%s", rsp.path); } while (0); _cli_out ("%s", rsp.path); } while (0); |
6071 | } else { |
6072 | /* weird sounding but easy to parse... */ |
6073 | cli_err ("%d : failed with this errno (%s)",do { do { if (0) printf ("%d : failed with this errno (%s)", rsp .op_errno, strerror (rsp.op_errno)); } while (0); _cli_err("%d : failed with this errno (%s)" , rsp.op_errno, strerror (rsp.op_errno)); } while (0) |
6074 | rsp.op_errno, strerror (rsp.op_errno))do { do { if (0) printf ("%d : failed with this errno (%s)", rsp .op_errno, strerror (rsp.op_errno)); } while (0); _cli_err("%d : failed with this errno (%s)" , rsp.op_errno, strerror (rsp.op_errno)); } while (0); |
6075 | ret = -1; |
6076 | } |
6077 | |
6078 | out: |
6079 | cli_cmd_broadcast_response (ret); |
6080 | return ret; |
6081 | } |
6082 | |
6083 | int32_t |
6084 | gf_cli_mount (call_frame_t *frame, xlator_t *this, void *data) |
6085 | { |
6086 | gf1_cli_mount_req req = {0,}; |
6087 | int ret = -1; |
6088 | void **dataa = data; |
6089 | char *label = NULL((void*)0); |
6090 | dict_t *dict = NULL((void*)0); |
6091 | |
6092 | if (!frame || !this || !data) |
6093 | goto out; |
6094 | |
6095 | label = dataa[0]; |
6096 | dict = dataa[1]; |
6097 | |
6098 | req.label = label; |
6099 | ret = dict_allocate_and_serialize (dict, &req.dict.dict_val, |
6100 | &req.dict.dict_len); |
6101 | if (ret) { |
6102 | ret = -1; |
6103 | goto out; |
6104 | } |
6105 | |
6106 | ret = cli_cmd_submit (&req, frame, cli_rpc_prog, |
6107 | GLUSTER_CLI_MOUNT, NULL((void*)0), |
6108 | this, gf_cli_mount_cbk, |
6109 | (xdrproc_t)xdr_gf1_cli_mount_req); |
6110 | |
6111 | out: |
6112 | gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret)do { do { if (0) printf ("Returning %d", ret); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 6112, GF_LOG_DEBUG, "Returning %d" , ret); } while (0); |
6113 | return ret; |
6114 | } |
6115 | |
6116 | static int |
6117 | gf_cli_umount_cbk (struct rpc_req *req, struct iovec *iov, |
6118 | int count, void *myframe) |
6119 | { |
6120 | gf1_cli_umount_rsp rsp = {0,}; |
6121 | int ret = -1; |
6122 | |
6123 | if (-1 == req->rpc_status) { |
6124 | goto out; |
6125 | } |
6126 | |
6127 | ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf1_cli_umount_rsp); |
6128 | if (ret < 0) { |
6129 | gf_log (((call_frame_t *) myframe)->this->name, GF_LOG_ERROR,do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (((call_frame_t *) myframe)->this->name, "cli-rpc-ops.c" , __FUNCTION__, 6130, GF_LOG_ERROR, "Failed to decode xdr response" ); } while (0) |
6130 | "Failed to decode xdr response")do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (((call_frame_t *) myframe)->this->name, "cli-rpc-ops.c" , __FUNCTION__, 6130, GF_LOG_ERROR, "Failed to decode xdr response" ); } while (0); |
6131 | goto out; |
6132 | } |
6133 | |
6134 | gf_log ("cli", GF_LOG_INFO, "Received resp to mount")do { do { if (0) printf ("Received resp to mount"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 6134, GF_LOG_INFO , "Received resp to mount"); } while (0); |
6135 | |
6136 | if (rsp.op_ret == 0) |
6137 | ret = 0; |
6138 | else { |
6139 | cli_err ("umount failed")do { do { if (0) printf ("umount failed"); } while (0); _cli_err ("umount failed"); } while (0); |
6140 | ret = -1; |
6141 | } |
6142 | |
6143 | out: |
6144 | cli_cmd_broadcast_response (ret); |
6145 | return ret; |
6146 | } |
6147 | |
6148 | int32_t |
6149 | gf_cli_umount (call_frame_t *frame, xlator_t *this, void *data) |
6150 | { |
6151 | gf1_cli_umount_req req = {0,}; |
6152 | int ret = -1; |
6153 | dict_t *dict = NULL((void*)0); |
6154 | |
6155 | if (!frame || !this || !data) |
6156 | goto out; |
6157 | |
6158 | dict = data; |
6159 | |
6160 | ret = dict_get_str (dict, "path", &req.path); |
6161 | if (ret == 0) |
6162 | ret = dict_get_int32 (dict, "lazy", &req.lazy); |
6163 | |
6164 | if (ret) { |
6165 | ret = -1; |
6166 | goto out; |
6167 | } |
6168 | |
6169 | ret = cli_cmd_submit (&req, frame, cli_rpc_prog, |
6170 | GLUSTER_CLI_UMOUNT, NULL((void*)0), |
6171 | this, gf_cli_umount_cbk, |
6172 | (xdrproc_t)xdr_gf1_cli_umount_req); |
6173 | |
6174 | out: |
6175 | gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret)do { do { if (0) printf ("Returning %d", ret); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 6175, GF_LOG_DEBUG, "Returning %d" , ret); } while (0); |
6176 | return ret; |
6177 | } |
6178 | |
6179 | void |
6180 | cmd_heal_volume_brick_out (dict_t *dict, int brick) |
6181 | { |
6182 | uint64_t num_entries = 0; |
6183 | int ret = 0; |
6184 | char key[256] = {0}; |
6185 | char *hostname = NULL((void*)0); |
6186 | char *path = NULL((void*)0); |
6187 | char *status = NULL((void*)0); |
6188 | uint64_t i = 0; |
6189 | uint32_t time = 0; |
6190 | char timestr[32] = {0}; |
6191 | char *shd_status = NULL((void*)0); |
6192 | |
6193 | snprintf (key, sizeof key, "%d-hostname", brick); |
6194 | ret = dict_get_str (dict, key, &hostname); |
6195 | if (ret) |
6196 | goto out; |
6197 | snprintf (key, sizeof key, "%d-path", brick); |
6198 | ret = dict_get_str (dict, key, &path); |
6199 | if (ret) |
6200 | goto out; |
6201 | cli_out ("\nBrick %s:%s", hostname, path)do { do { if (0) printf ("\nBrick %s:%s", hostname, path); } while (0); _cli_out("\nBrick %s:%s", hostname, path); } while (0); |
6202 | |
6203 | snprintf (key, sizeof key, "%d-status", brick); |
6204 | ret = dict_get_str (dict, key, &status); |
6205 | if (status && strlen (status)) |
6206 | cli_out ("Status: %s", status)do { do { if (0) printf ("Status: %s", status); } while (0); _cli_out ("Status: %s", status); } while (0); |
6207 | |
6208 | snprintf (key, sizeof key, "%d-shd-status",brick); |
6209 | ret = dict_get_str (dict, key, &shd_status); |
6210 | |
6211 | if(!shd_status) |
6212 | { |
6213 | snprintf (key, sizeof key, "%d-count", brick); |
6214 | ret = dict_get_uint64 (dict, key, &num_entries); |
6215 | cli_out ("Number of entries: %"PRIu64, num_entries)do { do { if (0) printf ("Number of entries: %""ll" "u", num_entries ); } while (0); _cli_out("Number of entries: %""ll" "u", num_entries ); } while (0); |
6216 | |
6217 | |
6218 | for (i = 0; i < num_entries; i++) { |
6219 | snprintf (key, sizeof key, "%d-%"PRIu64"ll" "u", brick, i); |
6220 | ret = dict_get_str (dict, key, &path); |
6221 | if (ret) |
6222 | continue; |
6223 | time = 0; |
6224 | snprintf (key, sizeof key, "%d-%"PRIu64"ll" "u""-time", |
6225 | brick, i); |
6226 | ret = dict_get_uint32 (dict, key, &time); |
6227 | if (!time) { |
6228 | cli_out ("%s", path)do { do { if (0) printf ("%s", path); } while (0); _cli_out("%s" , path); } while (0); |
6229 | } else { |
6230 | gf_time_fmt (timestr, sizeof timestr, |
6231 | time, gf_timefmt_FT); |
6232 | if (i == 0) { |
6233 | cli_out ("at path on brick")do { do { if (0) printf ("at path on brick" ); } while (0); _cli_out("at path on brick" ); } while (0); |
6234 | cli_out ("-----------------------------------")do { do { if (0) printf ("-----------------------------------" ); } while (0); _cli_out("-----------------------------------" ); } while (0); |
6235 | } |
6236 | cli_out ("%s %s", timestr, path)do { do { if (0) printf ("%s %s", timestr, path); } while (0) ; _cli_out("%s %s", timestr, path); } while (0); |
6237 | } |
6238 | } |
6239 | } |
6240 | |
6241 | out: |
6242 | return; |
6243 | } |
6244 | |
6245 | int |
6246 | gf_cli_heal_volume_cbk (struct rpc_req *req, struct iovec *iov, |
6247 | int count, void *myframe) |
6248 | { |
6249 | gf_cli_rsp rsp = {0,}; |
6250 | int ret = -1; |
6251 | cli_local_t *local = NULL((void*)0); |
6252 | char *volname = NULL((void*)0); |
6253 | call_frame_t *frame = NULL((void*)0); |
6254 | dict_t *input_dict = NULL((void*)0); |
6255 | dict_t *dict = NULL((void*)0); |
6256 | int brick_count = 0; |
6257 | int i = 0; |
6258 | gf_xl_afr_op_t heal_op = GF_AFR_OP_INVALID; |
6259 | char *operation = NULL((void*)0); |
6260 | char *substr = NULL((void*)0); |
6261 | |
6262 | if (-1 == req->rpc_status) { |
6263 | goto out; |
6264 | } |
6265 | |
6266 | frame = myframe; |
6267 | |
6268 | ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_cli_rsp); |
6269 | if (ret < 0) { |
6270 | gf_log (frame->this->name, GF_LOG_ERROR,do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__ , 6271, GF_LOG_ERROR, "Failed to decode xdr response"); } while (0) |
6271 | "Failed to decode xdr response")do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__ , 6271, GF_LOG_ERROR, "Failed to decode xdr response"); } while (0); |
6272 | goto out; |
6273 | } |
6274 | |
6275 | if (frame) |
6276 | local = frame->local; |
6277 | |
6278 | if (local) { |
6279 | input_dict = local->dict; |
6280 | ret = dict_get_int32 (input_dict, "heal-op", |
6281 | (int32_t*)&heal_op); |
6282 | } |
6283 | //TODO: Proper XML output |
6284 | //#if (HAVE_LIB_XML) |
6285 | // if (global_state->mode & GLUSTER_MODE_XML) { |
6286 | // ret = cli_xml_output_dict ("volHeal", dict, rsp.op_ret, |
6287 | // rsp.op_errno, rsp.op_errstr); |
6288 | // if (ret) |
6289 | // gf_log ("cli", GF_LOG_ERROR, |
6290 | // "Error outputting to xml"); |
6291 | // goto out; |
6292 | // } |
6293 | //#endif |
6294 | |
6295 | ret = dict_get_str (input_dict, "volname", &volname); |
6296 | if (ret) { |
6297 | gf_log (frame->this->name, GF_LOG_ERROR, "failed to get volname")do { do { if (0) printf ("failed to get volname"); } while (0 ); _gf_log (frame->this->name, "cli-rpc-ops.c", __FUNCTION__ , 6297, GF_LOG_ERROR, "failed to get volname"); } while (0); |
6298 | goto out; |
6299 | } |
6300 | |
6301 | gf_log ("cli", GF_LOG_INFO, "Received resp to heal volume")do { do { if (0) printf ("Received resp to heal volume"); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 6301, GF_LOG_INFO , "Received resp to heal volume"); } while (0); |
6302 | |
6303 | if ((heal_op == GF_AFR_OP_HEAL_FULL) || |
6304 | (heal_op == GF_AFR_OP_HEAL_INDEX)) { |
6305 | operation = "Launching Heal operation"; |
6306 | substr = "\nUse heal info commands to check status"; |
6307 | } else { |
6308 | operation = "Gathering Heal info"; |
6309 | substr = ""; |
6310 | } |
6311 | |
6312 | if (rsp.op_ret) { |
6313 | if (strcmp (rsp.op_errstr, "")) { |
6314 | cli_err ("%s", rsp.op_errstr)do { do { if (0) printf ("%s", rsp.op_errstr); } while (0); _cli_err ("%s", rsp.op_errstr); } while (0); |
6315 | } else { |
6316 | cli_err ("%s on volume %s has been unsuccessful",do { do { if (0) printf ("%s on volume %s has been unsuccessful" , operation, volname); } while (0); _cli_err("%s on volume %s has been unsuccessful" , operation, volname); } while (0) |
6317 | operation, volname)do { do { if (0) printf ("%s on volume %s has been unsuccessful" , operation, volname); } while (0); _cli_err("%s on volume %s has been unsuccessful" , operation, volname); } while (0); |
6318 | } |
6319 | |
6320 | ret = rsp.op_ret; |
6321 | goto out; |
6322 | } else { |
6323 | cli_out ("%s on volume %s has been successful%s", operation,do { do { if (0) printf ("%s on volume %s has been successful%s" , operation, volname, substr); } while (0); _cli_out("%s on volume %s has been successful%s" , operation, volname, substr); } while (0) |
6324 | volname, substr)do { do { if (0) printf ("%s on volume %s has been successful%s" , operation, volname, substr); } while (0); _cli_out("%s on volume %s has been successful%s" , operation, volname, substr); } while (0); |
6325 | } |
6326 | |
6327 | ret = rsp.op_ret; |
6328 | if ((heal_op == GF_AFR_OP_HEAL_FULL) || |
6329 | (heal_op == GF_AFR_OP_HEAL_INDEX)) |
6330 | goto out; |
6331 | |
6332 | dict = dict_new (); |
6333 | if (!dict) { |
6334 | ret = -1; |
6335 | goto out; |
6336 | } |
6337 | |
6338 | ret = dict_unserialize (rsp.dict.dict_val, |
6339 | rsp.dict.dict_len, |
6340 | &dict); |
6341 | |
6342 | if (ret) { |
6343 | gf_log ("", GF_LOG_ERROR,do { do { if (0) printf ("Unable to allocate memory"); } while (0); _gf_log ("", "cli-rpc-ops.c", __FUNCTION__, 6344, GF_LOG_ERROR , "Unable to allocate memory"); } while (0) |
6344 | "Unable to allocate memory")do { do { if (0) printf ("Unable to allocate memory"); } while (0); _gf_log ("", "cli-rpc-ops.c", __FUNCTION__, 6344, GF_LOG_ERROR , "Unable to allocate memory"); } while (0); |
6345 | goto out; |
6346 | } else { |
6347 | dict->extra_stdfree = rsp.dict.dict_val; |
6348 | } |
6349 | ret = dict_get_int32 (dict, "count", &brick_count); |
6350 | if (ret) |
6351 | goto out; |
6352 | |
6353 | if (!brick_count) { |
6354 | cli_err ("All bricks of volume %s are down.", volname)do { do { if (0) printf ("All bricks of volume %s are down.", volname); } while (0); _cli_err("All bricks of volume %s are down." , volname); } while (0); |
6355 | goto out; |
6356 | } |
6357 | |
6358 | for (i = 0; i < brick_count; i++) |
6359 | cmd_heal_volume_brick_out (dict, i); |
6360 | ret = rsp.op_ret; |
6361 | |
6362 | out: |
6363 | cli_cmd_broadcast_response (ret); |
6364 | free (rsp.op_errstr); |
6365 | if (dict) |
6366 | dict_unref (dict); |
6367 | return ret; |
6368 | } |
6369 | |
6370 | int32_t |
6371 | gf_cli_heal_volume (call_frame_t *frame, xlator_t *this, |
6372 | void *data) |
6373 | { |
6374 | gf_cli_req req = {{0,}}; |
6375 | int ret = 0; |
6376 | dict_t *dict = NULL((void*)0); |
6377 | |
6378 | if (!frame || !this || !data) { |
6379 | ret = -1; |
6380 | goto out; |
6381 | } |
6382 | |
6383 | dict = data; |
6384 | |
6385 | ret = cli_to_glusterd (&req, frame, gf_cli_heal_volume_cbk, |
6386 | (xdrproc_t) xdr_gf_cli_req, dict, |
6387 | GLUSTER_CLI_HEAL_VOLUME, this, cli_rpc_prog, |
6388 | NULL((void*)0)); |
6389 | |
6390 | out: |
6391 | gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret)do { do { if (0) printf ("Returning %d", ret); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 6391, GF_LOG_DEBUG, "Returning %d" , ret); } while (0); |
6392 | |
6393 | GF_FREE (req.dict.dict_val)__gf_free (req.dict.dict_val); |
6394 | |
6395 | return ret; |
6396 | } |
6397 | |
6398 | int32_t |
6399 | gf_cli_statedump_volume_cbk (struct rpc_req *req, struct iovec *iov, |
6400 | int count, void *myframe) |
6401 | { |
6402 | gf_cli_rsp rsp = {0,}; |
6403 | int ret = -1; |
6404 | char msg[1024] = {0,}; |
6405 | |
6406 | if (-1 == req->rpc_status) |
6407 | goto out; |
6408 | ret = xdr_to_generic (*iov, &rsp, |
6409 | (xdrproc_t)xdr_gf_cli_rsp); |
6410 | if (ret < 0) { |
6411 | gf_log (((call_frame_t *) myframe)->this->name, GF_LOG_ERROR,do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (((call_frame_t *) myframe)->this->name, "cli-rpc-ops.c" , __FUNCTION__, 6412, GF_LOG_ERROR, "Failed to decode xdr response" ); } while (0) |
6412 | "Failed to decode xdr response")do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (((call_frame_t *) myframe)->this->name, "cli-rpc-ops.c" , __FUNCTION__, 6412, GF_LOG_ERROR, "Failed to decode xdr response" ); } while (0); |
6413 | goto out; |
6414 | } |
6415 | gf_log ("cli", GF_LOG_DEBUG, "Received response to statedump")do { do { if (0) printf ("Received response to statedump"); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 6415 , GF_LOG_DEBUG, "Received response to statedump"); } while (0 ); |
6416 | if (rsp.op_ret) |
6417 | snprintf (msg, sizeof(msg), "%s", rsp.op_errstr); |
6418 | else |
6419 | snprintf (msg, sizeof (msg), "Volume statedump successful"); |
6420 | |
6421 | if (global_state->mode & GLUSTER_MODE_XML(1 << 2)) { |
6422 | ret = cli_xml_output_str ("volStatedump", msg, rsp.op_ret, |
6423 | rsp.op_errno, rsp.op_errstr); |
6424 | if (ret) |
6425 | gf_log ("cli", GF_LOG_ERROR,do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 6426, GF_LOG_ERROR , "Error outputting to xml"); } while (0) |
6426 | "Error outputting to xml")do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 6426, GF_LOG_ERROR , "Error outputting to xml"); } while (0); |
6427 | goto out; |
6428 | } |
6429 | |
6430 | if (rsp.op_ret) |
6431 | cli_err ("volume statedump: failed: %s", msg)do { do { if (0) printf ("volume statedump: failed: %s", msg) ; } while (0); _cli_err("volume statedump: failed: %s", msg); } while (0); |
6432 | else |
6433 | cli_out ("volume statedump: success")do { do { if (0) printf ("volume statedump: success"); } while (0); _cli_out("volume statedump: success"); } while (0); |
6434 | ret = rsp.op_ret; |
6435 | |
6436 | out: |
6437 | cli_cmd_broadcast_response (ret); |
6438 | return ret; |
6439 | } |
6440 | |
6441 | int32_t |
6442 | gf_cli_statedump_volume (call_frame_t *frame, xlator_t *this, |
6443 | void *data) |
6444 | { |
6445 | gf_cli_req req = {{0,}}; |
6446 | dict_t *options = NULL((void*)0); |
6447 | int ret = -1; |
6448 | |
6449 | if (!frame || !this || !data) |
6450 | goto out; |
6451 | |
6452 | options = data; |
6453 | |
6454 | ret = cli_to_glusterd (&req, frame, gf_cli_statedump_volume_cbk, |
6455 | (xdrproc_t) xdr_gf_cli_req, options, |
6456 | GLUSTER_CLI_STATEDUMP_VOLUME, this, cli_rpc_prog, |
6457 | NULL((void*)0)); |
6458 | |
6459 | out: |
6460 | gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret)do { do { if (0) printf ("Returning %d", ret); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 6460, GF_LOG_DEBUG, "Returning %d" , ret); } while (0); |
6461 | |
6462 | GF_FREE (req.dict.dict_val)__gf_free (req.dict.dict_val); |
6463 | return ret; |
6464 | } |
6465 | |
6466 | int32_t |
6467 | gf_cli_list_volume_cbk (struct rpc_req *req, struct iovec *iov, |
6468 | int count, void *myframe) |
6469 | { |
6470 | int ret = -1; |
6471 | gf_cli_rsp rsp = {0,}; |
6472 | dict_t *dict = NULL((void*)0); |
6473 | int vol_count = 0;; |
6474 | char *volname = NULL((void*)0); |
6475 | char key[1024] = {0,}; |
6476 | int i = 0; |
6477 | |
6478 | if (-1 == req->rpc_status) |
6479 | goto out; |
6480 | ret = xdr_to_generic (*iov, &rsp, |
6481 | (xdrproc_t)xdr_gf_cli_rsp); |
6482 | if (ret < 0) { |
6483 | gf_log (((call_frame_t *) myframe)->this->name, GF_LOG_ERROR,do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (((call_frame_t *) myframe)->this->name, "cli-rpc-ops.c" , __FUNCTION__, 6484, GF_LOG_ERROR, "Failed to decode xdr response" ); } while (0) |
6484 | "Failed to decode xdr response")do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (((call_frame_t *) myframe)->this->name, "cli-rpc-ops.c" , __FUNCTION__, 6484, GF_LOG_ERROR, "Failed to decode xdr response" ); } while (0); |
6485 | goto out; |
6486 | } |
6487 | |
6488 | dict = dict_new (); |
6489 | if (!dict) { |
6490 | ret = -1; |
6491 | goto out; |
6492 | } |
6493 | |
6494 | ret = dict_unserialize (rsp.dict.dict_val, rsp.dict.dict_len, &dict); |
6495 | if (ret) { |
6496 | gf_log ("cli", GF_LOG_ERROR, "Unable to allocate memory")do { do { if (0) printf ("Unable to allocate memory"); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 6496, GF_LOG_ERROR , "Unable to allocate memory"); } while (0); |
6497 | goto out; |
6498 | } |
6499 | |
6500 | if (global_state->mode & GLUSTER_MODE_XML(1 << 2)) { |
6501 | ret = cli_xml_output_vol_list (dict, rsp.op_ret, rsp.op_errno, |
6502 | rsp.op_errstr); |
6503 | if (ret) |
6504 | gf_log ("cli", GF_LOG_ERROR,do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 6505, GF_LOG_ERROR , "Error outputting to xml"); } while (0) |
6505 | "Error outputting to xml")do { do { if (0) printf ("Error outputting to xml"); } while ( 0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 6505, GF_LOG_ERROR , "Error outputting to xml"); } while (0); |
6506 | goto out; |
6507 | } |
6508 | |
6509 | if (rsp.op_ret) |
6510 | cli_err ("%s", rsp.op_errstr)do { do { if (0) printf ("%s", rsp.op_errstr); } while (0); _cli_err ("%s", rsp.op_errstr); } while (0); |
6511 | else { |
6512 | ret = dict_get_int32 (dict, "count", &vol_count); |
6513 | if (ret) |
6514 | goto out; |
6515 | |
6516 | if (vol_count == 0) { |
6517 | cli_err ("No volumes present in cluster")do { do { if (0) printf ("No volumes present in cluster"); } while (0); _cli_err("No volumes present in cluster"); } while (0); |
6518 | goto out; |
6519 | } |
6520 | for (i = 0; i < vol_count; i++) { |
6521 | memset (key, 0, sizeof (key)); |
6522 | snprintf (key, sizeof (key), "volume%d", i); |
6523 | ret = dict_get_str (dict, key, &volname); |
6524 | if (ret) |
6525 | goto out; |
6526 | cli_out ("%s", volname)do { do { if (0) printf ("%s", volname); } while (0); _cli_out ("%s", volname); } while (0); |
6527 | } |
6528 | } |
6529 | |
6530 | ret = rsp.op_ret; |
6531 | |
6532 | out: |
6533 | cli_cmd_broadcast_response (ret); |
6534 | return ret; |
6535 | } |
6536 | |
6537 | int32_t |
6538 | gf_cli_list_volume (call_frame_t *frame, xlator_t *this, void *data) |
6539 | { |
6540 | int ret = -1; |
6541 | gf_cli_req req = {{0,}}; |
6542 | |
6543 | if (!frame || !this) |
6544 | goto out; |
6545 | |
6546 | ret = cli_cmd_submit (&req, frame, cli_rpc_prog, |
6547 | GLUSTER_CLI_LIST_VOLUME, NULL((void*)0), |
6548 | this, gf_cli_list_volume_cbk, |
6549 | (xdrproc_t)xdr_gf_cli_req); |
6550 | |
6551 | out: |
6552 | gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret)do { do { if (0) printf ("Returning %d", ret); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 6552, GF_LOG_DEBUG, "Returning %d" , ret); } while (0); |
6553 | return ret; |
6554 | } |
6555 | |
6556 | int32_t |
6557 | gf_cli_clearlocks_volume_cbk (struct rpc_req *req, struct iovec *iov, |
6558 | int count, void *myframe) |
6559 | { |
6560 | gf_cli_rsp rsp = {0,}; |
6561 | int ret = -1; |
6562 | char *lk_summary = NULL((void*)0); |
6563 | char *volname = NULL((void*)0); |
6564 | dict_t *dict = NULL((void*)0); |
6565 | |
6566 | if (-1 == req->rpc_status) |
6567 | goto out; |
6568 | ret = xdr_to_generic (*iov, &rsp, |
6569 | (xdrproc_t)xdr_gf_cli_rsp); |
6570 | if (ret < 0) { |
6571 | gf_log (((call_frame_t *) myframe)->this->name, GF_LOG_ERROR,do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (((call_frame_t *) myframe)->this->name, "cli-rpc-ops.c" , __FUNCTION__, 6572, GF_LOG_ERROR, "Failed to decode xdr response" ); } while (0) |
6572 | "Failed to decode xdr response")do { do { if (0) printf ("Failed to decode xdr response"); } while (0); _gf_log (((call_frame_t *) myframe)->this->name, "cli-rpc-ops.c" , __FUNCTION__, 6572, GF_LOG_ERROR, "Failed to decode xdr response" ); } while (0); |
6573 | goto out; |
6574 | } |
6575 | gf_log ("cli", GF_LOG_DEBUG, "Received response to clear-locks")do { do { if (0) printf ("Received response to clear-locks"); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 6575 , GF_LOG_DEBUG, "Received response to clear-locks"); } while ( 0); |
6576 | |
6577 | if (rsp.op_ret) { |
6578 | cli_err ("Volume clear-locks unsuccessful")do { do { if (0) printf ("Volume clear-locks unsuccessful"); } while (0); _cli_err("Volume clear-locks unsuccessful"); } while (0); |
6579 | cli_err ("%s", rsp.op_errstr)do { do { if (0) printf ("%s", rsp.op_errstr); } while (0); _cli_err ("%s", rsp.op_errstr); } while (0); |
6580 | |
6581 | } else { |
6582 | if (!rsp.dict.dict_len) { |
6583 | cli_err ("Possibly no locks cleared")do { do { if (0) printf ("Possibly no locks cleared"); } while (0); _cli_err("Possibly no locks cleared"); } while (0); |
6584 | ret = 0; |
6585 | goto out; |
6586 | } |
6587 | |
6588 | dict = dict_new (); |
6589 | |
6590 | if (!dict) { |
6591 | ret = -1; |
6592 | goto out; |
6593 | } |
6594 | |
6595 | ret = dict_unserialize (rsp.dict.dict_val, |
6596 | rsp.dict.dict_len, |
6597 | &dict); |
6598 | |
6599 | if (ret) { |
6600 | gf_log ("cli", GF_LOG_ERROR,do { do { if (0) printf ("Unable to serialize response dictionary" ); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__ , 6601, GF_LOG_ERROR, "Unable to serialize response dictionary" ); } while (0) |
6601 | "Unable to serialize response dictionary")do { do { if (0) printf ("Unable to serialize response dictionary" ); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__ , 6601, GF_LOG_ERROR, "Unable to serialize response dictionary" ); } while (0); |
6602 | goto out; |
6603 | } |
6604 | |
6605 | ret = dict_get_str (dict, "volname", &volname); |
6606 | if (ret) { |
6607 | gf_log ("cli", GF_LOG_ERROR, "Unable to get volname "do { do { if (0) printf ("Unable to get volname " "from dictionary" ); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__ , 6608, GF_LOG_ERROR, "Unable to get volname " "from dictionary" ); } while (0) |
6608 | "from dictionary")do { do { if (0) printf ("Unable to get volname " "from dictionary" ); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__ , 6608, GF_LOG_ERROR, "Unable to get volname " "from dictionary" ); } while (0); |
6609 | goto out; |
6610 | } |
6611 | |
6612 | ret = dict_get_str (dict, "lk-summary", &lk_summary); |
6613 | if (ret) { |
6614 | gf_log ("cli", GF_LOG_ERROR, "Unable to get lock "do { do { if (0) printf ("Unable to get lock " "summary from dictionary" ); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__ , 6615, GF_LOG_ERROR, "Unable to get lock " "summary from dictionary" ); } while (0) |
6615 | "summary from dictionary")do { do { if (0) printf ("Unable to get lock " "summary from dictionary" ); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__ , 6615, GF_LOG_ERROR, "Unable to get lock " "summary from dictionary" ); } while (0); |
6616 | goto out; |
6617 | } |
6618 | cli_out ("Volume clear-locks successful")do { do { if (0) printf ("Volume clear-locks successful"); } while (0); _cli_out("Volume clear-locks successful"); } while (0); |
6619 | cli_out ("%s", lk_summary)do { do { if (0) printf ("%s", lk_summary); } while (0); _cli_out ("%s", lk_summary); } while (0); |
6620 | |
6621 | } |
6622 | |
6623 | ret = rsp.op_ret; |
6624 | |
6625 | out: |
6626 | if (dict) |
6627 | dict_unref (dict); |
6628 | cli_cmd_broadcast_response (ret); |
6629 | return ret; |
6630 | } |
6631 | |
6632 | int32_t |
6633 | gf_cli_clearlocks_volume (call_frame_t *frame, xlator_t *this, |
6634 | void *data) |
6635 | { |
6636 | gf_cli_req req = {{0,}}; |
6637 | dict_t *options = NULL((void*)0); |
6638 | int ret = -1; |
6639 | |
6640 | if (!frame || !this || !data) |
6641 | goto out; |
6642 | |
6643 | options = data; |
6644 | |
6645 | ret = cli_to_glusterd (&req, frame, gf_cli_clearlocks_volume_cbk, |
6646 | (xdrproc_t) xdr_gf_cli_req, options, |
6647 | GLUSTER_CLI_CLRLOCKS_VOLUME, this, cli_rpc_prog, |
6648 | NULL((void*)0)); |
6649 | out: |
6650 | gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret)do { do { if (0) printf ("Returning %d", ret); } while (0); _gf_log ("cli", "cli-rpc-ops.c", __FUNCTION__, 6650, GF_LOG_DEBUG, "Returning %d" , ret); } while (0); |
6651 | |
6652 | GF_FREE (req.dict.dict_val)__gf_free (req.dict.dict_val); |
6653 | return ret; |
6654 | } |
6655 | |
6656 | int |
6657 | cli_to_glusterd (gf_cli_req *req, call_frame_t *frame, |
6658 | fop_cbk_fn_t cbkfn, xdrproc_t xdrproc, dict_t *dict, |
6659 | int procnum, xlator_t *this, rpc_clnt_prog_t *prog, |
6660 | struct iobref *iobref) |
6661 | { |
6662 | int ret = 0; |
6663 | size_t len = 0; |
6664 | char *cmd = NULL((void*)0); |
6665 | int i = 0; |
6666 | const char **words = NULL((void*)0); |
6667 | cli_local_t *local = NULL((void*)0); |
6668 | |
6669 | if (!this || !frame || !dict) { |
6670 | ret = -1; |
6671 | goto out; |
6672 | } |
6673 | |
6674 | if (!frame->local) { |
6675 | ret = -1; |
6676 | goto out; |
6677 | } |
6678 | |
6679 | local = frame->local; |
6680 | |
6681 | if (!local->words) { |
6682 | ret = -1; |
6683 | goto out; |
6684 | } |
6685 | |
6686 | words = local->words; |
6687 | |
6688 | while (words[i]) |
6689 | len += strlen (words[i++]) + 1; |
6690 | |
6691 | cmd = GF_CALLOC (1, len, gf_common_mt_char)__gf_calloc (1, len, gf_common_mt_char); |
6692 | |
6693 | if (!cmd) { |
6694 | ret = -1; |
6695 | goto out; |
6696 | } |
6697 | |
6698 | for (i = 0; words[i]; i++) { |
6699 | strncat (cmd, words[i], strlen (words[i])); |
6700 | if (words[i+1] != NULL((void*)0)) |
6701 | strncat (cmd, " ", strlen (" ")); |
6702 | } |
6703 | |
6704 | cmd [len - 1] = '\0'; |
6705 | |
6706 | ret = dict_set_dynstr (dict, "cmd-str", cmd); |
6707 | if (ret) |
6708 | goto out; |
6709 | |
6710 | ret = dict_allocate_and_serialize (dict, &(req->dict).dict_val, |
6711 | &(req->dict).dict_len); |
6712 | |
6713 | if (ret < 0) { |
6714 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("failed to get serialized length of dict" ); } while (0); _gf_log (this->name, "cli-rpc-ops.c", __FUNCTION__ , 6715, GF_LOG_DEBUG, "failed to get serialized length of dict" ); } while (0) |
6715 | "failed to get serialized length of dict")do { do { if (0) printf ("failed to get serialized length of dict" ); } while (0); _gf_log (this->name, "cli-rpc-ops.c", __FUNCTION__ , 6715, GF_LOG_DEBUG, "failed to get serialized length of dict" ); } while (0); |
6716 | goto out; |
6717 | } |
6718 | |
6719 | ret = cli_cmd_submit (req, frame, prog, procnum, iobref, this, |
6720 | cbkfn, (xdrproc_t) xdrproc); |
6721 | |
6722 | out: |
6723 | return ret; |
6724 | |
6725 | } |
6726 | |
6727 | struct rpc_clnt_procedure gluster_cli_actors[GLUSTER_CLI_MAXVALUE] = { |
6728 | [GLUSTER_CLI_NULL] = {"NULL", NULL((void*)0) }, |
6729 | [GLUSTER_CLI_PROBE] = {"PROBE_QUERY", gf_cli_probe}, |
6730 | [GLUSTER_CLI_DEPROBE] = {"DEPROBE_QUERY", gf_cli_deprobe}, |
6731 | [GLUSTER_CLI_LIST_FRIENDS] = {"LIST_FRIENDS", gf_cli_list_friends}, |
6732 | [GLUSTER_CLI_UUID_RESET] = {"UUID_RESET", gf_cli3_1_uuid_reset}, |
6733 | [GLUSTER_CLI_CREATE_VOLUME] = {"CREATE_VOLUME", gf_cli_create_volume}, |
6734 | [GLUSTER_CLI_DELETE_VOLUME] = {"DELETE_VOLUME", gf_cli_delete_volume}, |
6735 | [GLUSTER_CLI_START_VOLUME] = {"START_VOLUME", gf_cli_start_volume}, |
6736 | [GLUSTER_CLI_STOP_VOLUME] = {"STOP_VOLUME", gf_cli_stop_volume}, |
6737 | [GLUSTER_CLI_RENAME_VOLUME] = {"RENAME_VOLUME", gf_cli_rename_volume}, |
6738 | [GLUSTER_CLI_DEFRAG_VOLUME] = {"DEFRAG_VOLUME", gf_cli_defrag_volume}, |
6739 | [GLUSTER_CLI_GET_VOLUME] = {"GET_VOLUME", gf_cli_get_volume}, |
6740 | [GLUSTER_CLI_GET_NEXT_VOLUME] = {"GET_NEXT_VOLUME", gf_cli_get_next_volume}, |
6741 | [GLUSTER_CLI_SET_VOLUME] = {"SET_VOLUME", gf_cli_set_volume}, |
6742 | [GLUSTER_CLI_ADD_BRICK] = {"ADD_BRICK", gf_cli_add_brick}, |
6743 | [GLUSTER_CLI_REMOVE_BRICK] = {"REMOVE_BRICK", gf_cli_remove_brick}, |
6744 | [GLUSTER_CLI_REPLACE_BRICK] = {"REPLACE_BRICK", gf_cli_replace_brick}, |
6745 | [GLUSTER_CLI_LOG_ROTATE] = {"LOG ROTATE", gf_cli_log_rotate}, |
6746 | [GLUSTER_CLI_GETSPEC] = {"GETSPEC", gf_cli_getspec}, |
6747 | [GLUSTER_CLI_PMAP_PORTBYBRICK] = {"PMAP PORTBYBRICK", gf_cli_pmap_b2p}, |
6748 | [GLUSTER_CLI_SYNC_VOLUME] = {"SYNC_VOLUME", gf_cli_sync_volume}, |
6749 | [GLUSTER_CLI_RESET_VOLUME] = {"RESET_VOLUME", gf_cli_reset_volume}, |
6750 | [GLUSTER_CLI_FSM_LOG] = {"FSM_LOG", gf_cli_fsm_log}, |
6751 | [GLUSTER_CLI_GSYNC_SET] = {"GSYNC_SET", gf_cli_gsync_set}, |
6752 | [GLUSTER_CLI_PROFILE_VOLUME] = {"PROFILE_VOLUME", gf_cli_profile_volume}, |
6753 | [GLUSTER_CLI_QUOTA] = {"QUOTA", gf_cli_quota}, |
6754 | [GLUSTER_CLI_TOP_VOLUME] = {"TOP_VOLUME", gf_cli_top_volume}, |
6755 | [GLUSTER_CLI_GETWD] = {"GETWD", gf_cli_getwd}, |
6756 | [GLUSTER_CLI_STATUS_VOLUME] = {"STATUS_VOLUME", gf_cli_status_volume}, |
6757 | [GLUSTER_CLI_STATUS_ALL] = {"STATUS_ALL", gf_cli_status_volume_all}, |
6758 | [GLUSTER_CLI_MOUNT] = {"MOUNT", gf_cli_mount}, |
6759 | [GLUSTER_CLI_UMOUNT] = {"UMOUNT", gf_cli_umount}, |
6760 | [GLUSTER_CLI_HEAL_VOLUME] = {"HEAL_VOLUME", gf_cli_heal_volume}, |
6761 | [GLUSTER_CLI_STATEDUMP_VOLUME] = {"STATEDUMP_VOLUME", gf_cli_statedump_volume}, |
6762 | [GLUSTER_CLI_LIST_VOLUME] = {"LIST_VOLUME", gf_cli_list_volume}, |
6763 | [GLUSTER_CLI_CLRLOCKS_VOLUME] = {"CLEARLOCKS_VOLUME", gf_cli_clearlocks_volume}, |
6764 | #ifdef HAVE_BD_XLATOR |
6765 | [GLUSTER_CLI_BD_OP] = {"BD_OP", gf_cli_bd_op}, |
6766 | #endif |
6767 | }; |
6768 | |
6769 | struct rpc_clnt_program cli_prog = { |
6770 | .progname = "Gluster CLI", |
6771 | .prognum = GLUSTER_CLI_PROGRAM1238463, |
6772 | .progver = GLUSTER_CLI_VERSION2, |
6773 | .numproc = GLUSTER_CLI_MAXVALUE, |
6774 | .proctable = gluster_cli_actors, |
6775 | }; |