summaryrefslogtreecommitdiffstats
path: root/cli/src/cli-rpc-ops.c
Commit message (Collapse)AuthorAgeFilesLines
* cli: type mismatch global_quotad_rpc in cli-quotad-client.cKaleb S. KEITHLEY2020-07-091-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | ... [ 236s] (.text+0x0): multiple definition of `cli_default_conn_timeout'; cli.o (symbol from plugin):(.text+0x0): first defined here [ 236s] cli-quotad-client.c:13:24: warning: type of 'global_quotad_rpc' does not match original declaration [-Wlto-type-mismatch] [ 236s] 13 | extern struct rpc_clnt global_quotad_rpc; [ 236s] | ^ [ 236s] cli.c:80:18: note: 'global_quotad_rpc' was previously declared here [ 236s] 80 | struct rpc_clnt *global_quotad_rpc; [ 236s] | ^ [ 236s] cli.c:80:18: note: code may be misoptimized unless '-fno-strict-aliasing' is used [ 239s] collect2: error: ld returned 1 exit status ... move several global extern decls to cli.h. Found on SUSE Tumbleweed w/ gcc-10 and LTO. This bug goes back at least as far as release-6. Curiously this only popped up as an error when building 6.9, not 7.4 or 8.0. And not when building 8.0 on Fedora rawhide/33. Change-Id: I765642cea77b524a36368a7ff1a2976ef049dd0f Fixes: #1356 Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
* cli: fix data race when handling connection statusDmitry Antipov2020-06-181-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Found with GCC ThreadSanitizer: WARNING: ThreadSanitizer: data race (pid=287943) Write of size 4 at 0x00000047dfa0 by thread T4: #0 cli_rpc_notify /path/to/glusterfs/cli/src/cli.c:313 (gluster+0x40a6df) #1 rpc_clnt_handle_disconnect /path/to/glusterfs/rpc/rpc-lib/src/rpc-clnt.c:821 (libgfrpc.so.0+0x13f04) #2 rpc_clnt_notify /path/to/glusterfs/rpc/rpc-lib/src/rpc-clnt.c:882 (libgfrpc.so.0+0x13f04) #3 rpc_transport_notify /path/to/glusterfs/rpc/rpc-lib/src/rpc-transport.c:520 (libgfrpc.so.0+0xf070) #4 socket_event_poll_err /path/to/glusterfs/rpc/rpc-transport/socket/src/socket.c:1364 (socket.so+0x812c) #5 socket_event_handler /path/to/glusterfs/rpc/rpc-transport/socket/src/socket.c:2958 (socket.so+0xc453) #6 socket_event_handler /path/to/glusterfs/rpc/rpc-transport/socket/src/socket.c:2854 (socket.so+0xc453) #7 event_dispatch_epoll_handler /path/to/glusterfs/libglusterfs/src/event-epoll.c:640 (libglusterfs.so.0+0xcaf23) #8 event_dispatch_epoll_worker /path/to/glusterfs/libglusterfs/src/event-epoll.c:751 (libglusterfs.so.0+0xcaf23) #9 <null> <null> (libtsan.so.0+0x2d33f) Previous read of size 4 at 0x00000047dfa0 by thread T3 (mutexes: write M3587): #0 cli_cmd_await_connected /path/to/glusterfs/cli/src/cli-cmd.c:321 (gluster+0x40ca37) #1 cli_cmd_process /path/to/glusterfs/cli/src/cli-cmd.c:123 (gluster+0x40cc74) #2 cli_batch /path/to/glusterfs/cli/src/input.c:29 (gluster+0x40c2b9) #3 <null> <null> (libtsan.so.0+0x2d33f) Location is global 'connected' of size 4 at 0x00000047dfa0 (gluster+0x00000047dfa0) Change-Id: Ie85a8a80a2c5b82252c0c1d45e68ebe9938da2eb Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru> Fixes: #1311
* Indicate timezone offsets in timestampsCsaba Henk2020-06-151-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Logs and other output carrying timestamps will have now timezone offsets indicated, eg.: [2020-03-12 07:01:05.584482 +0000] I [MSGID: 106143] [glusterd-pmap.c:388:pmap_registry_remove] 0-pmap: removing brick (null) on port 49153 To this end, - gf_time_fmt() now inserts timezone offset via %z strftime(3) template. - A new utility function has been added, gf_time_fmt_tv(), that takes a struct timeval pointer (*tv) instead of a time_t value to specify the time. If tv->tv_usec is negative, gf_time_fmt_tv(... tv ...) is equivalent to gf_time_fmt(... tv->tv_sec ...) Otherwise it also inserts tv->tv_usec to the formatted string. - Building timestamps of usec precision has been converted to gf_time_fmt_tv, which is necessary because the method of appending a period and the usec value to the end of the timestamp does not work if the timestamp has zone offset, but it's also beneficial in terms of eliminating repetition. - The buffer passed to gf_time_fmt/gf_time_fmt_tv has been unified to be of GF_TIMESTR_SIZE size (256). We need slightly larger buffer space to accommodate the zone offset and it's preferable to use a buffer which is undisputedly large enough. This change does *not* do the following: - Retaining a method of timestamp creation without timezone offset. As to my understanding we don't need such backward compatibility as the code just emits timestamps to logs and other diagnostic texts, and doesn't do any later processing on them that would rely on their format. An exception to this, ie. a case where timestamp is built for internal use, is graph.c:fill_uuid(). As far as I can see, what matters in that case is the uniqueness of the produced string, not the format. - Implementing a single-token (space free) timestamp format. While some timestamp formats used to be single-token, now all of them will include a space preceding the offset indicator. Again, I did not see a use case where this could be significant in terms of representation. - Moving the codebase to a single unified timestamp format and dropping the fmt argument of gf_time_fmt/gf_time_fmt_tv. While the gf_timefmt_FT format is almost ubiquitous, there are a few cases where different formats are used. I'm not convinced there is any reason to not use gf_timefmt_FT in those cases too, but I did not want to make a decision in this regard. Change-Id: I0af73ab5d490cca7ed8d07a2ce7ac22a6df2920a Updates: #837 Signed-off-by: Csaba Henk <csaba@redhat.com>
* cli: fix several signed integer overflows and format specifiersDmitry Antipov2020-06-101-3/+6
| | | | | | | | | | | | | | | Initially found with GCC UBsan: cli/src/cli-rpc-ops.c:5347:73: runtime error: left shift of 1 by 31 places cannot be represented in type 'int' cli/src/cli-rpc-ops.c:5355:74: runtime error: left shift of 1 by 31 places cannot be represented in type 'int' Ditto in cli/src/cli-xml-output.c. Change-Id: I14ed51d06dafe5039f154b0c4edf25a0997d696e Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru> Fixes: #1279
* cli: fix memory leak in gf_cli_gsync_status_output()Dmitry Antipov2020-05-311-8/+0
| | | | | | | | | | | In gf_cli_gsync_status_output(), call to gf_cli_read_status_data() overwrites 'sts_vals' pointers to areas allocated by GF_CALLOC() with pointers to dict data, thus making the allocated areas not accessible. Change-Id: I00c310aec1a1413caf13ade14dc4fed37b51962c Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru> Fixes: #1259
* cluster/afr: Removing unsupported options from code base to improve coveragekarthik-us2020-04-071-12/+4
| | | | | | | | | | | | | | | | Support for gluster volume heal <volname> info healed/heal-failed was removed by commit bb02cfb56ae08f56df4452c2b948fa962ae1212b in release-3.6. cli parser will display the usage message in all the supported versions whenever these clis are run, leading to some dead code in the latest branches. Since support for these clis were removed long back, this should not give any backward compatibility issues as well. Hence removing the dead code from the code base which will lead to better code coverage by the regression runs as well. Updates: #1052 Change-Id: I0c2b061469caf233c06d9699b0d159ce48e240b9 Signed-off-by: karthik-us <ksubrahm@redhat.com>
* cli: display the error while probing the localhostSanju Rakonde2020-03-131-3/+3
| | | | | | | | | | | | | | With bc6e206c6, we regressed in displaying the error message when a user tries to probe localhost. With this change, we display "probe on localhost not needed" message to the user. credits: Sachin Prabhu <sprabhu@redhat.com> fixes: bz#1810042 Change-Id: Ibf82b5a658c371c08290a0b4f655e5ac5f436c06 Signed-off-by: Sanju Rakonde <srakonde@redhat.com>
* cli - removing fetch of unnecessary items.Barak Sason Rofman2020-01-211-66/+1
| | | | | | | | | | Somem methods dict_get...(...) values and then not use them anywhere. Removed found occurrences. fixes: #753 Change-Id: Iaeb8f4cec18f76078f6b2f4e4bd6f9795a3467bc Signed-off-by: Barak Sason Rofman <bsasonro@redhat.com>
* cli - fixing a coverity issueBarak Sason Rofman2020-01-071-1/+1
| | | | | | | | | | Removed unused variable. fixes: CID#1412106 updates: bz#789278 Change-Id: I1d4e1c1625cecf882d51e9cf4f5290383f63d405 Signed-off-by: Barak Sason Rofman <bsasonro@redhat.com>
* cli-rpc-ops.c: cleanupsYaniv Kaul2019-12-191-1396/+967
| | | | | | | | | | | | | | | | | | | | | | | | | | 1. Move functions and structs to static 2. Use dictionary functions with fixed key length. 3. Reduce key length when not needed. 4. Use const char* for some messages. 5. Use fixed strings for some logs which is repeated in the code. 6. Remove redundant checks. Specifically, cli_to_glusterd() does NULL checks already, so no need to do it before calling it. 7. Aligned some messages - not sure why they were cut over several lines, but it made grep on the code harder. 8. Move dictionary fetching of values closer to where they are actually used. Overall, object size is ~4 smaller, hopefully without functional changes. There's more that can be done, but as this is a very long (>10K lines) file, I think it's enough for one change. Specifically, some functions fetch values from the dictionary without using it - this is a bit of a waste. Filed https://github.com/gluster/glusterfs/issues/753 about it. Change-Id: I31f88d94ab25398e00aef2ea84a8c4af9383b75b updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
* cli-*: make some structs static to reduce space consumed.Yaniv Kaul2019-11-261-16/+16
| | | | | | | | | | | | | | | | | | | | | | | There's a small difference when structs are defined static. Whenever possible, define them as such. Specifically, before: text data bss dec hex filename 678 216 0 894 37e ./cli/src/cli-cmd-misc.o 150024 1264 16 151304 24f08 ./cli/src/cli-rpc-ops.o 71980 64 0 72044 1196c ./cli/src/cli-cmd-parser.o 66189 4 16 66209 102a1 ./cli/src/cli-xml-output.o After: text data bss dec hex filename 670 216 0 886 376 ./cli/src/cli-cmd-misc.o 149848 1392 16 151256 24ed8 ./cli/src/cli-rpc-ops.o 70346 1320 0 71666 117f2 ./cli/src/cli-cmd-parser.o 66157 4 16 66177 10281 ./cli/src/cli-xml-output.o Change-Id: I206bd895290595d79fac7b26eee66f4279b50f92 updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
* cli: display detailed rebalance infoSanju Rakonde2019-11-121-7/+14
| | | | | | | | | | | | | | | | | | | | | | | | | Problem: When one of the node is down in cluster, rebalance status is not displaying detailed information. Cause: In glusterd_volume_rebalance_use_rsp_dict() we are aggregating rsp from all the nodes into a dictionary and sending it to cli for printing. While assigning a index to keys we are considering all the peers instead of considering only the peers which are up. Because of which, index is not reaching till 1. while parsing the rsp cli unable to find status-1 key in dictionary and going out without printing any information. Solution: The simplest fix for this without much code change is to continue to look for other keys when status-1 key is not found. fixes: bz#1764119 Change-Id: I0062839933c9706119eb85416256eade97e976dc Signed-off-by: Sanju Rakonde <srakonde@redhat.com>
* Revert "glusterd: (storhaug) remove ganesha (843e1b0)"Jiffin Tony Thottan2019-08-241-0/+82
| | | | | | | | | please note as an additional change, macro GLUSTERD_GET_SNAP_DIR moved from glusterd-store.c to glusterd-snapshot-utils.h Change-Id: I811efefc148453fe32e4f0d322e80455447cec71 updates: #663 Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com>
* Multiple files: get trivial stuff done before lockYaniv Kaul2019-08-011-6/+7
| | | | | | | | | Initialize a dictionary for example seems to be prefectly fine to be done before taking a lock. Change-Id: Ib29516c4efa8f0e2b526d512beab488fcd16d2e7 updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
* cli: Remove Wformat-truncation compiler warningSheetal Pamecha2019-07-021-2/+4
| | | | | | | | | | | | This warning is issued due to unhandled output truncation. As in the code, truncation is expected, we can remove this warning by placing a check on the return value of the function and handling it. In this way, the warning will not be issued. Change-Id: I1820b58fe9a7601961c20944b259df322db35057 updates: bz#1193929 Signed-off-by: Sheetal Pamecha <spamecha@redhat.com>
* glusterd/thin-arbiter: Thin-arbiter integration with GD1Vishal Pandey2019-06-281-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | gluster volume create <VOLNAME> replica 2 thin-arbiter 1 <host1>:<brick1> <host2>:<brick2> <thin-arbiter-host>:<path-to-store-replica-id-file> [force] The changes have been made in a way that the last brick in the bricks list will be treated as the thin-arbiter. GD1 will be manipulated to consider replica count to be as 2 and continue creating the volume like any other replica 2 volume but since thin-arbiter volumes need ta-brick client xlator entries for each subvolume in fuse volfile, volfile generation is modified in a way to inject these entries seperately in the volfile for every subvolume. Few more additions - 1- Save the volinfo with new fields ta_bricks list and thin_arbiter_count. 2- Introduce a new option client.ta-brick-port to add remote-port to ta-brick xlator entry in fuse volfiles. The option can be set using the following CLI syntax - gluster volume set <VOLNAME> client.ta-brick-port <PORTNO.> 3- Volume Info will contain a Thin-Arbiter-path entry to distinguish from other replicate volumes. Change-Id: Ib434e2313b29716f32476c6c211d282c4ef39406 Updates #687 Signed-off-by: Vishal Pandey <vpandey@redhat.com>
* tier/cli: remove tier code to increase code coverage in cliSanju Rakonde2019-04-251-892/+32
| | | | | | Change-Id: I56cc09243dab23b3be86a7faac45001dda77181f updates: bz#1693692 Signed-off-by: Sanju Rakonde <srakonde@redhat.com>
* glusterd: display an error when rebalance start is failedSanju Rakonde2019-04-121-1/+0
| | | | | | | | fixes: bz#1699176 credits: Hari Gowtham <hgowtham@redhat.com> Change-Id: I59134336febf0dc4043483f2f413ac83e3bc79f5 Signed-off-by: Sanju Rakonde <srakonde@redhat.com>
* Multiple files: remove HAVE_BD_XLATOR related code.Yaniv Kaul2019-03-251-35/+0
| | | | | | | | | | | | The BD translator was removed some time ago, (in commit a907e468e724c32b9833ce59806fc215c7122d63). This completes the work. Compile-tested only! updates: bz#1635688 Signed-off-by: Yaniv Kaul <ykaul@redhat.com> Change-Id: I999df52e479a72d3cc9523f22f9056de17eb559c
* inode: fix unused varsAtin Mukherjee2019-03-221-1/+2
| | | | | | | | | Commit 6d6a3b2 introduced some unused vars. This patch defines them within #ifdef DEBUG Fixes: bz#1580315 Change-Id: I8a332b00c3ffb66689b4b6480c490b9436c17d63 Signed-off-by: Atin Mukherjee <amukherj@redhat.com>
* inode: don't dump the whole table to CLIAmar Tumballi2019-03-201-0/+22
| | | | | | | | | | | dumping the whole inode table detail to screen doesn't solve any purpose. We should be getting only toplevel details on CLI, and then if one wants to debug further, then they need to get to 'statedump' to get full details. Fixes: bz#1580315 Change-Id: Iaf3de94602f9c76832c3c918ffe2ad13c0b0e448 Signed-off-by: Amar Tumballi <amarts@redhat.com>
* cli: fix memory leak in cli rpc opsMohit Agrawal2018-12-071-0/+4
| | | | | | | | | | | | | Problem: In some of the cli fops dict_allocate_and_serialize allocate memory for req structure but after submit request it missed to cleanup memory fo req.dict.dict_val Solution: Call GF_FREE for req.dict.dict_val after submit cli request Change-Id: I76c6b3082fa0be21dc595f87701550a318734ea5 updates: bz#1633930 Signed-off-by: Mohit Agrawal <moagrawal@redhat.com>
* libglusterfs: Move devel headers under glusterfs directoryShyamsundarR2018-12-051-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | libglusterfs devel package headers are referenced in code using include semantics for a program, this while it works can be better especially when dealing with out of tree xlator builds or in general out of tree devel package usage. Towards this, the following changes are done, - moved all devel headers under a glusterfs directory - Included these headers using system header notation <> in all code outside of libglusterfs - Included these headers using own program notation "" within libglusterfs This change although big, is just moving around the headers and making it correct when including these headers from other sources. This helps us correctly include libglusterfs includes without namespace conflicts. Change-Id: Id2a98854e671a7ee5d73be44da5ba1a74252423b Updates: bz#1193929 Signed-off-by: ShyamsundarR <srangana@redhat.com>
* cli: fix memory leak in cli/src/cli-rpc-ops.cSunny Kumar2018-12-051-0/+3
| | | | | | | | | | | | This Patch fixes memory leak reported by ASan. Leaks are in gf_cli_status_cbk as a result of allocatating memory using gf_asprintf in loop. SUMMARY: AddressSanitizer: 535 byte(s) leaked in 7 allocation(s). Change-Id: If2fd76c7c1ea6fc44baca295050800074f9d1323 updates: bz#1633930 Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
* cli : Memeory leak fix reported by ASANSunny Kumar2018-12-031-0/+22
| | | | | | | | | | | | | This patch fixes memory leak in cli-rpc-ops.c. Functions: gf_cli_create_volume_cbk, gf_cli_delete_volume_cbk, gf_cli_start_volume_cbk, gf_cli_remove_tier_brick_cbk, gf_cli_list_volume_cbk. updates: bz#1633930 Change-Id: I68a650fb972db18c90e6581a960eae3018f32d40 Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
* cli : Memeory leak fix reported by ASANSunny Kumar2018-12-021-0/+3
| | | | | | | | | | | | This patch fixes memory leak in cli-rpc-ops.c. All leaks are happening in gf_cli_remove_brick_cbk. SUMMARY: AddressSanitizer: 2944 byte(s) leaked in 22 allocation(s). updates: bz#1633930 Change-Id: I1e58d538eb9135f1aadcdb54d10b72f55e8a53d1 Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
* stripe: remove the translator from build and glusterdAmar Tumballi2018-10-311-11/+1
| | | | | | | | | | | | | | | | Based on the proposal to remove few features as they are not actively maintained [1], removing stripe translator from the build. Also make sure there are no regression tests involving stripe translator. [1] https://lists.gluster.org/pipermail/gluster-users/2018-July/034400.html Note that this patch aims at removing the translator from build, and a followup patch is needed to remove the code from repository. Updates: bz#1364707 Change-Id: I235b305338f138e29e9f30cba65bc0dadbebbbd5 Signed-off-by: Amar Tumballi <amarts@redhat.com>
* cli: Fix memory leaks reported by ASANKotresh HR2018-10-121-0/+38
| | | | | | | | | This patch addresses memory leaks other than 'gf_cli_rsp' response structure. Updates: bz#1633930 Change-Id: Idc5940dca623e33bc01004a9324bc435fc60b006 Signed-off-by: Kotresh HR <khiremat@redhat.com>
* cli: Fix memory leaks reported by ASANKotresh HR2018-10-121-64/+52
| | | | | | | | | | 'gf_cli_rsp' structure has 'op_errstr' and 'dict.dict_val' which could get allocated by xdr and should be freed. This patch takes care of all instances of the same. Updates: bz#1633930 Change-Id: I2a5d129ffe85cfca743c89edb45b658f3ce688cb Signed-off-by: Kotresh HR <khiremat@redhat.com>
* cli: memory leak issues reported by asanAmar Tumballi2018-10-091-0/+11
| | | | | | | | | With this fix, a run on 'rpc-coverage.t' passes properly. This should help to get started with other fixes soon! Change-Id: I257ae4e28b9974998a451d3b490cc18c02650ba2 updates: bz#1633930 Signed-off-by: Amar Tumballi <amarts@redhat.com>
* cli: fix glusterd memory leak cause by "gluster v status volume_name"shujun100862018-10-031-0/+1
| | | | | | | | | | | If use this command every some seconds for example 15s to check gluster brick status, the glusterd will use about 1G memory in a year. free the value of rsp in gf_cli_status_cbk. glusterd allocate the value of rsp and send it to cli, but cli do not free the value, that cause glusterd memory leak. fixes: bz#1635480 Change-Id: I3f19cd0d4b791ae1b35f9664b3a668b1579f1178 Signed-off-by: shujun10086 <shujun.huang@nokia-sbell.com>
* cli: handle negative scenariosSanju Rakonde2018-10-011-2/+19
| | | | | | | | | | | When control flow reaches negative case code block, we added "goto out" statement without assigning ret to -1. This patch assigns return value to -1, before going to the lable "out". Change-Id: I6db651a3c9ca285ade9ee1ca23d0abe6b36fda3a updates: bz#1193929 Signed-off-by: Sanju Rakonde <srakonde@redhat.com>
* Quota related files: use dict_{setn|getn|deln|get_int32n|set_int32n|set_strn}Yaniv Kaul2018-09-261-2/+4
| | | | | | | | | | | | | | In a previous patch (https://review.gluster.org/20769) we've added the key length to be passed to dict_* funcs, to remove the need to strlen() it. This patch moves some code to use it. Please review carefully. Compile-tested only! updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com> Change-Id: If4f425a9827be7c36ccfbb9761006ae824a818c6
* Land part 2 of clang-format changesGluster Ant2018-09-121-10048/+10014
| | | | | Change-Id: Ia84cc24c8924e6d22d02ac15f611c10e26db99b4 Signed-off-by: Nigel Babu <nigelb@redhat.com>
* multiple files: calloc -> mallocYaniv Kaul2018-09-041-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | xlators/cluster/stripe/src/stripe-helpers.c: Move to GF_MALLOC() instead of GF_CALLOC() when possible xlators/cluster/dht/src/tier.c: Move to GF_MALLOC() instead of GF_CALLOC() when possible xlators/cluster/dht/src/dht-layout.c: Move to GF_MALLOC() instead of GF_CALLOC() when possible xlators/cluster/dht/src/dht-helper.c: Move to GF_MALLOC() instead of GF_CALLOC() when possible xlators/cluster/dht/src/dht-common.c: Move to GF_MALLOC() instead of GF_CALLOC() when possible xlators/cluster/afr/src/afr.c: Move to GF_MALLOC() instead of GF_CALLOC() when possible xlators/cluster/afr/src/afr-inode-read.c: Move to GF_MALLOC() instead of GF_CALLOC() when possible tests/bugs/replicate/bug-1250170-fsync.c: Move to GF_MALLOC() instead of GF_CALLOC() when possible tests/basic/gfapi/gfapi-async-calls-test.c: Move to GF_MALLOC() instead of GF_CALLOC() when possible tests/basic/ec/ec-fast-fgetxattr.c: Move to GF_MALLOC() instead of GF_CALLOC() when possible rpc/xdr/src/glusterfs3.h: Move to GF_MALLOC() instead of GF_CALLOC() when possible rpc/rpc-transport/socket/src/socket.c: Move to GF_MALLOC() instead of GF_CALLOC() when possible rpc/rpc-lib/src/rpc-clnt.c: Move to GF_MALLOC() instead of GF_CALLOC() when possible extras/geo-rep/gsync-sync-gfid.c: Move to GF_MALLOC() instead of GF_CALLOC() when possible cli/src/cli-xml-output.c: Move to GF_MALLOC() instead of GF_CALLOC() when possible cli/src/cli-rpc-ops.c: Move to GF_MALLOC() instead of GF_CALLOC() when possible cli/src/cli-cmd-volume.c: Move to GF_MALLOC() instead of GF_CALLOC() when possible cli/src/cli-cmd-system.c: Move to GF_MALLOC() instead of GF_CALLOC() when possible cli/src/cli-cmd-snapshot.c: Move to GF_MALLOC() instead of GF_CALLOC() when possible cli/src/cli-cmd-peer.c: Move to GF_MALLOC() instead of GF_CALLOC() when possible cli/src/cli-cmd-global.c: Move to GF_MALLOC() instead of GF_CALLOC() when possible It doesn't make sense to calloc (allocate and clear) memory when the code right away fills that memory with data. It may be optimized by the compiler, or have a microscopic performance improvement. In some cases, also changed allocation size to be sizeof some struct or type instead of a pointer - easier to read. In some cases, removed redundant strlen() calls by saving the result into a variable. 1. Only done for the straightforward cases. There's room for improvement. 2. Please review carefully, especially for string allocation, with the terminating NULL string. Only compile-tested! updates: bz#1193929 Original-Author: Yaniv Kaul <ykaul@redhat.com> Signed-off-by: Yaniv Kaul <ykaul@redhat.com> Signed-off-by: Amar Tumballi <amarts@redhat.com> Change-Id: I16274dca4078a1d06ae09a0daf027d734b631ac2
* {cli-cmd-parser|cli-rpc-ops||cli-xml-output}.c: strncpy()->sprintf(), reduce ↵Yaniv Kaul2018-08-241-4/+4
| | | | | | | | | | | | | | | | | | | | | | strlen()'s strncpy may not be very efficient for short strings copied into a large buffer: If the length of src is less than n, strncpy() writes additional null bytes to dest to ensure that a total of n bytes are written. Instead, use snprintf(). Also: - save the result of strlen() and re-use it when possible. - move from GF_CALLOC() to GF_MALLOC() for the strings. - move from strlen to sizeof() for const strings. Compile-tested only! Change-Id: I3cf49c5401ee100a5db6a4954c3d699ec1814c17 updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
* All: remove memset() before sprintf()Yaniv Kaul2018-08-141-177/+24
| | | | | | | | | | | | It's not needed. There's a good chance the compiler is smart enough to remove it anyway, but it can't hurt - I hope. Compile-tested only! Change-Id: Id7c054e146ba630227affa591007803f3046416b updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
* All: run codespell on the code and fix issues.Yaniv Kaul2018-07-221-2/+2
| | | | | | | | | | | | Please review, it's not always just the comments that were fixed. I've had to revert of course all calls to creat() that were changed to create() ... Only compile-tested! Change-Id: I7d02e82d9766e272a7fd9cc68e51901d69e5aab5 updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
* Fix compile warningsXavi Hernandez2018-07-101-5/+5
| | | | | | | | | | | This patch fixes compile warnings that appear with newer compilers. The solution applied is only to remove the warnings, but it doesn't always solve the problem in the best way. It assumes that the problem will never happen, as the previous code assumed. Change-Id: I6e8470d6c2e2dbd3bd7d324b5fd2f92ffdc3d6ec updates: bz#1193929 Signed-off-by: Xavi Hernandez <xhernandez@redhat.com>
* glusterd: glusterd is releasing the locks before timeoutSanju Rakonde2018-05-281-0/+22
| | | | | | | | | | | | | | | | | | | Problem: We introduced lock timer in mgmt v3, which will realease the lock after 3 minutes from command execution. Some commands related to heal/profile will take more time to execute. For these comands timeout is set to 10 minutes. As the lock timer is set to 3 minutes glusterd is releasing the lock after 3 minutes. That means locks are released before the command is completed its execution. Solution: Pass a timeout parameter from cli to glusterd, when there is a change in default timeout value(i.e, default timeout value can be changed through command line or for the commands related to profile/heal we will change the default timeout value to 10 minutes.) glusterd will set the lock timer timeout according to the timeout value passed. Change-Id: I7b7a9a4f95ed44aca39ef9d9907f546bca99c69d fixes: bz#1577731 Signed-off-by: Sanju Rakonde <srakonde@redhat.com>
* cli/snapshot: ignore errors for snapshot status for ALL/VOLThomas Hindoe Paaboel Andersen2018-05-041-1/+1
| | | | | | | | | | | | | | | | | Currently errors are reported for snapshot status of type ALL and VOL. The intention was to ignore those, but the code gets it wrong. The original condition for ignoring ALL/VOL was removed in Bug 1096610 Change-Id Ifc0ac31d2a9f91e136e87f3b51a629df7dba94e8 And the current logic introduced in Bug 789278 Change-Id I985cea1ef787d239b2632d5a7f467070846f92e4 Change-Id: Ic02ea98fb23b1149264e91b41f2fc2ca916d405f Fixes: bz#1574259 Signed-off-by: Thomas Hindoe Paaboel Andersen <phomes@gmail.com>
* bitrot : improved cli report after bitrot operatoinSunny Kumar2018-02-011-0/+57
| | | | | | | | | | Improved cli report post bitrot opertaion as previously it was showing output "volume bitrot: success" for all the sucessfull bitrot operations (enable, disable or scrub options). Change-Id: I0857e99f3956221a51cfd1b29a90e1038b90570f BUG: 1539166 Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
* cli: Fix coverity errors for cli-rpc-ops.cKaushal M2017-11-211-34/+106
| | | | | | | | | | | | | Fixes issues 147, 168, 169, 219, 715, 718, 766, 768, 772, 774, 776, 782, 790 from the report at [1]. Also, fixed some other possible static checker errors as well. [1]: https://download.gluster.org/pub/gluster/glusterfs/static-analysis/master/glusterfs-coverity/2017-10-30-9aa574a5/html/ BUG: 789278 Change-Id: I985cea1ef787d239b2632d5a7f467070846f92e4 Signed-off-by: Kaushal M <kaushal@redhat.com>
* cli: correct rebalance status elapsed checkN Balachandran2017-11-071-1/+5
| | | | | | | | | Check that elapsed time has crossed 10 mins for at least one rebalance process before displaying the estimates. Change-Id: Ib357a6f0d0125a178e94ede1e31514fdc6ce3593 BUG: 1479528 Signed-off-by: N Balachandran <nbalacha@redhat.com>
* geo-rep/scheduler: Add validation for session existenceKotresh HR2017-10-061-1/+1
| | | | | | | | | Added validation to check for session existence to give out proper error message out. Change-Id: I13c5f6ef29c1395cff092a14e1bd2c197a39f058 BUG: 1499159 Signed-off-by: Kotresh HR <khiremat@redhat.com>
* cli/afr: gluster volume heal info "healed" command output is not appropriateMohit Agrawal2017-10-041-6/+7
| | | | | | | | | | | | | | | | | | | | | | | | Problem: "gluster volume heal info [healed] [heal-failed]" command output on terminal is not appropriate in case of down any volume. Solution: To make message more appropriate change the condition in function "gd_syncop_mgmt_brick_op". Test : To verify the fix followed below procedure 1) Create 2*3 distribute replicate volume 2) set self-heal daemon off 3) kill two bricks (3, 6) 4) create some file on mount point 5) bring brick 3,6 up 6) kill other two brick (2 and 4) 7) make self heal daemon on 8) run "gluster v heal <vol-name>" Note: After apply the patch options (healed | heal-failed) will deprecate from command line. BUG: 1388509 Change-Id: I229c320c9caeb2525c76b78b44a53a64b088545a Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
* cli: fix Coverity warning DEADCODE in gf_cli_attach_tier()Mohammed Azhar Padariyakam2017-09-291-3/+0
| | | | | | | | | | | | | | | Issue : At condition "ret", the value of "ret" must be equal to 0. The condition "ret" cannot be true since the value is always 0. Hence, the execution cannot reach the statement "goto out" Solution : The never-true if-condition and its body has to be removed Fix : The always false if-condition and the dead code under this if-condition was removed. Change-Id: I5c038b8ec9abf9b2f06dcfd981904b9dca1a0094 BUG: 789278 Signed-off-by: Mohammed Azhar Padariyakam <mpadariy@redhat.com>
* heal: New feature heal info summary to list the status of brick and count of ↵Mohamed Ashiq Liyazudeen2017-09-151-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | entries to be healed Command output: Brick 192.168.2.8:/brick/1 Status: Connected Total Number of entries: 363 Number of entries in heal pending: 362 Number of entries in split-brain: 0 Number of entries possibly healing: 1 <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <cliOutput> <healInfo> <bricks> <brick hostUuid="9105dd4b-eca8-4fdb-85b2-b81cdf77eda3"> <name>192.168.2.8:/brick/1</name> <status>Connected</status> <totalNumberOfEntries>363</numberOfEntries> <numberOfEntriesInHealPending>362</numberOfEntriesInHealPending> <numberOfEntriesInSplitBrain>0</numberOfEntriesInSplitBrain> <numberOfEntriesPossiblyHealing>1</numberOfEntriesPossiblyHealing> </brick> </bricks> </healInfo> <opRet>0</opRet> <opErrno>0</opErrno> <opErrstr/> </cliOutput> Change-Id: I40cb6f77a14131c9e41b292f4901b41a228863d7 BUG: 1261463 Signed-off-by: Mohamed Ashiq Liyazudeen <mliyazud@redhat.com> Reviewed-on: https://review.gluster.org/12154 Smoke: Gluster Build System <jenkins@build.gluster.org> Tested-by: Karthik U S <ksubrahm@redhat.com> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Ravishankar N <ravishankar@redhat.com> Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
* Command to identify client processhari gowtham2017-09-061-0/+139
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | command: gluster volume status <volname/all> client-list output: Client connections for volume v1 Name count ----- ------ fuse 2 tierd 1 total clients for volume v1 : 3 ----------------------------------------------------------------- Client connections for volume v2 Name count ----- ------ tierd 1 fuse.gsync 1 total clients for volume v2 : 2 ----------------------------------------------------------------- Updates: #178 Change-Id: I0ff2579d6adf57cc0d3bd0161a2ec6ac6c4747c0 Signed-off-by: hari gowtham <hgowtham@redhat.com> Reviewed-on: https://review.gluster.org/18095 Smoke: Gluster Build System <jenkins@build.gluster.org> Tested-by: hari gowtham <hari.gowtham005@gmail.com> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
* glusterd: Add geo-replication session details to get-state outputSamikshan Bairagya2017-08-041-33/+0
| | | | | | | | | | | | | | | This commit adds support to the get-state CLI to capture details on geo-replication session as obtained in `gluster volume geo-replication status detail` in its output. Fixes: #291 Change-Id: I2fbcba70bfdaf439522637234805545194777ed4 Signed-off-by: Samikshan Bairagya <samikshan@gmail.com> Reviewed-on: https://review.gluster.org/17941 Smoke: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Shubhendu Tripathi <shtripat@redhat.com> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Atin Mukherjee <amukherj@redhat.com>