894 Commits

Author SHA1 Message Date
Aravinda VK
cbb52082da geo-rep: IPv6 support
`address_family=inet6` needs to be added while mounting master and
slave volumes in gverify script.

New option introduced to gluster cli(`--inet6`) which will be used
internally by geo-rep while calling `gluster volume info
--remote-host=<ipv6>`.

Backport of https://review.gluster.org/22363

Fixes: bz#1695436
Change-Id: I1e0d42cae07158df043e64a2f991882d8c897837
Signed-off-by: Aravinda VK <avishwan@redhat.com>
(cherry picked from commit 240e1d6821fbb779c3dd73f6f0225d755a5b7cc6)
2019-04-17 13:58:46 +00:00
Milind Changire
4cb1d6d94a socket: socket event handlers now return void
Problem:
Returning any value from socket event handlers to the event sub-system
doesn't make sense since event sub-system cannot handle socket
sub-system errors.

Solution:
Change return type of all socket event handlers to 'void'

mainline:
> Change-Id: I70dc2c57f12b7ea2fae41120f71aa0d7fe0b2b6f
> Fixes: bz#1651246
> Signed-off-by: Milind Changire <mchangir@redhat.com>
> Reviewed-on: https://review.gluster.org/c/glusterfs/+/22221

Change-Id: I70dc2c57f12b7ea2fae41120f71aa0d7fe0b2b6f
Fixes: bz#1683900
Signed-off-by: Milind Changire <mchangir@redhat.com>
(cherry picked from commit 776ba851c6ee6c265253d44cf1d6e4e3d4a21772)
2019-03-02 11:54:24 +00:00
Rinku Kothiya
f87a3e8403 cli: Added the group option for volume set
gluster volume set <VOLUME> group <GROUP> is used for setting multiple
pre-defined volume options, but this was undocumented. This patch doc-
ments this feature.

fixes: bz#1243991

Change-Id: Id346cf2537f85179caff32479f09555ce2e72e76
Signed-off-by: Rinku Kothiya <rkothiya@redhat.com>
2019-02-04 12:56:00 +00:00
Rinku Kothiya
55b40dfbb2 cli: Added a welcome and help message
When gluster command is fired without any arguments it just shows the
prompt, so added a welcome message and info to get help.

fixes: bz#1535528

Change-Id: I627b66b67443716e9270025c1e47b98b6facba13
Signed-off-by: Rinku Kothiya <rkothiya@redhat.com>
2019-01-21 03:23:23 +00:00
Rinku Kothiya
0687b0beb5 core: Feature added to accept CidrIp in auth.allow
Added functionality to gluster volume set auth.allow command to
accept CIDR IP addresses. Modified few functions to isolate cidr
feature so that it prevents other gluster commands such as peer
probe to use cidr format ip. The functions are modified in such
a way that they have an option to enable accepting of cidr
format for other gluster commands if required in furture.

updates: bz#1138841

Change-Id: Ie6734002a7078f1820e5df42d404411cce945e8b
Credits: Mohit Agrawal
Signed-off-by: Rinku Kothiya <rkothiya@redhat.com>
2019-01-18 17:13:13 +00:00
Yaniv Kaul
3ce7b5dbf0 libglusterfs/src/mem-types.h: remove unused common enums from mem-types.h
They were not used at all, just taking space.
I've also marked all those that are not common really, but used
in just one place - they probably should move there (in follow-up
patches)

As a test, I've removed from the stripe xlator unused private
enums and moved one that was in the common list, but only
used in the stripe code, to be a private enum.

Compile-tested only!

updates: bz#1193929
Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
Change-Id: I1158dc1d259f1fd3f69904336c46c9d83cea799f
2018-12-30 11:59:27 +00:00
Sunny Kumar
c3d23b06ce cli: fix memory leak
This patch fixes memory leak in cli/src/cli.c.

Change-Id: I4956c4180b34d4a9e3e6e60eeafba8cb2031896e
updates: bz#1633930
Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
2018-12-26 02:17:59 +00:00
Sheetal Pamecha
2421453bf3 cli: variable-length array declaration clang fix
Problem: Declared variable-length array can have zero size

Added a goto statement to address this issue.

Updates: bz#1622665

Change-Id: Ibf80643490367a5f7e50f66f87e4296380be45de
Signed-off-by: Sheetal Pamecha <sheetal.pamecha08@gmail.com>
2018-12-14 04:38:23 +00:00
Sunny Kumar
74c72d0dd9 cli : fix memory leak in cli-cmd-volume.c
This patch fixes ememory leak reported by ASan.

Tracebacks:
Direct leak of 84 byte(s) in 1 object(s) allocated from:
    #0 0x7f71ea107848 in __interceptor_malloc (/lib64/libasan.so.5+0xef848)
    #1 0x7f71e9e2ac49 in __gf_malloc ./libglusterfs/src/mem-pool.c:136
    #2 0x7f71e9e2b4bb in gf_vasprintf ./libglusterfs/src/mem-pool.c:236
    #3 0x7f71e9e2b68a in gf_asprintf ./libglusterfs/src/mem-pool.c:256
    #4 0x41e8ec in cli_cmd_bitrot_cbk ./cli/src/cli-cmd-volume.c:1847
    #5 0x410b39 in cli_cmd_process ./cli/src/cli-cmd.c:137
    #6 0x40fe9d in cli_batch ./cli/src/input.c:29
    #7 0x7f71e989558d in start_thread (/lib64/libpthread.so.0+0x858d)

updates: bz#1633930
Change-Id: I8977e45add742e67047291f398f0ee79eb09afe4
Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
2018-12-10 05:46:00 +00:00
Mohit Agrawal
f168db1da7 cli: fix memory leak in cli rpc ops
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>
2018-12-07 03:48:21 +00:00
Rinku Kothiya
4bdabc49d0 cli: fix a memory leak reported by ASan.
Fixed a leak in cli_cmd_volume_remove_brick_cbk.
SUMMARY: AddressSanitizer: 1152 byte(s) leaked in 8 allocation(s)

updates: bz#1633930

Credits: Mohit Agrawal
Change-Id: Idb59c3880329fde59c415c84d7f0bb09ae879a1a
Signed-off-by: Rinku Kothiya <rkothiya@redhat.com>
2018-12-06 17:37:04 +05:30
Kotresh HR
36e1175df6 cli: Fix mem-leaks reported by ASAN
Tracebacks:

Direct leak of 96 byte(s) in 1 object(s) allocated from:
 #0 0x7f3acf9eac48 in malloc (/lib64/libasan.so.5+0xeec48)
 #1 0x7f3acf510949 in __gf_malloc ./libglusterfs/src/mem-pool.c:136
 #2 0x7f3acf5111bb in gf_vasprintf ./libglusterfs/src/mem-pool.c:236
 #3 0x7f3acf51138a in gf_asprintf ./libglusterfs/src/mem-pool.c:256
 #4 0x421611 in cli_cmd_volume_set_cbk ./cli/src/cli-cmd-volume.c:868
 #5 0x410599 in cli_cmd_process ./cli/src/cli-cmd.c:135
 #6 0x40f90d in cli_batch ./cli/src/input.c:29
 #7 0x7f3acd78c593 in start_thread pthread_create.c:463

Direct leak of 73 byte(s) in 1 object(s) allocated from:
 #0 0x7f3acf9eac48 in malloc (/lib64/libasan.so.5+0xeec48)
 #1 0x7f3acf510949 in __gf_malloc ./libglusterfs/src/mem-pool.c:136
 #2 0x421519 in gf_strndup ../../libglusterfs/src/mem-pool.h:167
 #3 0x421519 in gf_strdup ../../libglusterfs/src/mem-pool.h:184
 #4 0x421519 in cli_cmd_volume_set_cbk cli/src/cli-cmd-volume.c:859
 #5 0x410599 in cli_cmd_process cli/src/cli-cmd.c:135
 #6 0x40f90d in cli_batch cli/src/input.c:29
 #7 0x7f3acd78c593 in start_thread pthread_create.c:463

Change-Id: I3312751c1e3178672360a678fe15b1f7f1054b22
updates: bz#1633930
Signed-off-by: Kotresh HR <khiremat@redhat.com>
2018-12-06 10:27:37 +00:00
Rinku Kothiya
7ea5f438f6 cli: memory leak issue reported by asan
This patch fixes dict leak in cli_cmd_volume_stop_cbk.
SUMMARY: AddressSanitizer: 640 byte(s) leaked in 4 allocation(s)

Credits: Mohit Agrawal
Change-Id: If14983b8588e68d16d6bbb04b87e2f06fb97023d
fixes: bz#1633930
Signed-off-by: Rinku Kothiya <rkothiya@redhat.com>
2018-12-05 22:17:58 +00:00
ShyamsundarR
20ef211cfa libglusterfs: Move devel headers under glusterfs directory
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>
2018-12-05 21:47:04 +00:00
Sunny Kumar
7f7716f819 cli: fix memory leak in cli/src/cli-rpc-ops.c
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>
2018-12-05 21:37:31 +00:00
Harpreet kaur
afc3006b46 cli: memory leak issue reported by asan
This patch fixes Indirect leaks in cli-cmd-volume.c
Leaks are happening in cli_cmd_quota_cbk and
cli_cmd_quota_handle_list_all.
SUMMARY: AddressSanitizer: 1152 byte(s) leaked in 8 allocation(s)

Updates: bz#1633930

Change-Id: Ia6c0306e88bd81f74d1220303ead8095fbcf5623
Signed-off-by: Harpreet kaur <hlalwani@redhat.com>
2018-12-05 21:34:56 +00:00
Sunny Kumar
f479f46189 cli: fix memory leak in cli-cmd-system.c
This patch fixes memory leak reported by ASan.

SUMMARY: AddressSanitizer: 384 byte(s) leaked in 2 allocation(s).

updates: bz#1633930
Change-Id: I93ebddcfeea3d51547e00775db2c9d99f5dfafea
Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
2018-12-05 03:49:14 +00:00
Harpreet Kaur Lalwani
8e8f4bf3fa cli: "usage()" and "--help" for gluster cli
Added a usage message which will be shown when a user enters an 
"unrecognized word" or an "unrecognized command" on the cli.
Also added a "--help" option for gluster cli.

fixes: bz#1535495

Change-Id: Ibcfb3d1c84daa1054e09c5cdfa6a5dab19f534a6
Signed-off-by: Harpreet Kaur Lalwani <hlalwani@redhat.com>
2018-12-04 09:28:11 +00:00
Sunny Kumar
220722b426 cli : Memeory leak fix reported by ASAN
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>
2018-12-03 15:57:38 +00:00
Harpreet Lalwani
7c0cb6eebd cli: memory leak issue reported by asan
This patch fixes Indirect leaks in tests/bugs/heal-symlinks.t.
Leaks are happening in cli_cmd_volume_heal_cbk.
SUMMARY: AddressSanitizer: 640 byte(s) leaked in 4 allocation(s).

Updates: bz#1633930

Change-Id: I970b4229630fdaf01aec66581c1287beef7560a3
Signed-off-by: Harpreet Lalwani <hlalwani@redhat.com>
2018-12-03 05:48:28 +00:00
Sunny Kumar
0566ecc878 cli : Memeory leak fix reported by ASAN
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>
2018-12-02 07:23:37 +00:00
Raghavendra Gowdappa
95e380eca1 rpcsvc: provide each request handler thread its own queue
A single global per program queue is contended by all request handler
threads and event threads. This can lead to high contention. So,
reduce the contention by providing each request handler thread its own
private queue.

Thanks to "Manoj Pillai"<mpillai@redhat.com> for the idea of pairing a
single queue with a fixed request-handler-thread and event-thread,
which brought down the performance regression due to overhead of
queuing significantly.

Thanks to "Xavi Hernandez"<xhernandez@redhat.com> for discussion on
how to communicate the event-thread death to request-handler-thread.

Thanks to "Karan Sandha"<ksandha@redhat.com> for voluntarily running
the perf benchmarks to qualify that performance regression introduced
by ping-timer-fixes is fixed with this patch and patiently running
many iterations of regression tests while RCAing the issue.

Thanks to "Milind Changire"<mchangir@redhat.com> for patiently running
the many iterations of perf benchmarking tests while RCAing the
regression caused by ping-timer-expiry fixes.

Change-Id: I578c3fc67713f4234bd3abbec5d3fbba19059ea5
Fixes: bz#1644629
Signed-off-by: Raghavendra Gowdappa <rgowdapp@redhat.com>
2018-11-29 01:19:12 +00:00
Shwetha K Acharya
0a3540293b geo-rep: Geo-rep help text issue
Modified Geo-rep help text for better sanity.

Change-Id: I48f4d0fd60c1ffcde753b37416e0c73afd0b5702
fixes: bz#1652887
Signed-off-by: Shwetha K Acharya <sacharya@redhat.com>
2018-11-27 14:01:51 +00:00
Ravishankar N
fc9889d037 glfsheal: add a '--nolog' flag
....and if set, change the log level to GF_LOG_NONE. This is useful for
monitoring applications which invoke the heal info set of commands once
every minute, leading to un-necessary glfsheal* logs in
/var/log/glusterfs/. For example, we can now run

`gluster volume heal <VOLNAME> info --nolog`
`gluster volume heal <VOLNAME> info split-brain --nolog` etc.

The default log level is still retained at GF_LOG_INFO.

The patch also changes glfsheal internally to accept '--xml' instead of 'xml'.
Note: The --nolog flag is *not* displayed in the help anywhere, for the
sake of consistency in how the other flags are not displayed anywhere in
the help.

fixes: bz#1643519
Change-Id: Ia08b6aa6e4a0548379db7e313dd4411ebc66f206
Signed-off-by: Ravishankar N <ravishankar@redhat.com>
2018-11-26 08:36:13 +00:00
Shwetha Acharya
429843eb9e geo-rep: validate the config checkpoint date format
Added a strlen check to ensure that the format is (Y-m-d H:M:S).

Change-Id: I8844aaa33418d43ffe2320c4a05eb1eddd306903
updates: bz#1651584
Signed-off-by: Shwetha Acharya <sacharya@gmail.com>
2018-11-22 04:58:05 +00:00
Sunny Kumar
5af9799ab7 cli : fix coverity issue in cli-xml-output.c
This patch fixes 1124659, 1241480 and 1274196.

Change-Id: Ib89f53b8e34fcc47184d08ad57f2ee32fd00d78c
updates: bz#789278
Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
2018-11-18 16:50:57 +00:00
Ravishankar N
db28fc7a35 cli: avoid unnecessary strtail for geo rep config.
Found while looking at this function for another patch.

Compile Tested Only!

Updates bz#1193929
Change-Id: I46a9e95bf4d6609bc122edf86418659369258abe
Signed-off-by: Ravishankar N <ravishankar@redhat.com>
2018-11-11 15:45:38 +00:00
Atin Mukherjee
185106a574 cli: add a warning/confirmation message in peer detach code path
On a multi node cluster if one of the node is detached which had active
clients mounted through the same server address, this can cause all the
clients to loose any volfile changes. This is due to the lack of infra
in glusterd to let client know the list of IPs and attempt to connect to
other active nodes as failback. Such framework does exist in GD2 but not
in GD1.

This patch ensures to take a preventive measure to have a warning
message thrown to user to ensure all such connected clients are
remounted through a different IP.

Change-Id: I740b01868abbd75bf0a609cfaf00114d4d78aa96
Fixes: bz#1647074
Signed-off-by: Atin Mukherjee <amukherj@redhat.com>
2018-11-09 07:18:25 +00:00
Amar Tumballi
74e8328d3f all: fix the format string exceptions
Currently, there are possibilities in few places, where a user-controlled
(like filename, program parameter etc) string can be passed as 'fmt' for
printf(), which can lead to segfault, if the user's string contains '%s',
'%d' in it.

While fixing it, makes sense to make the explicit check for such issues
across the codebase, by making the format call properly.

Fixes: CVE-2018-14661

Fixes: bz#1644763
Change-Id: Ib547293f2d9eb618594cbff0df3b9c800e88bde4
Signed-off-by: Amar Tumballi <amarts@redhat.com>
2018-11-05 18:50:59 +00:00
Amar Tumballi
7331395513 stripe: remove the translator from build and glusterd
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>
2018-10-31 02:24:49 +00:00
Sunil Kumar Acharya
e15a5a5cc6 cluster/ec : Prevent volume create without redundant brick
Problem:
EC volumes can be created without any redundant brick.

Solution:
Updated the conditional check to avoid volume create without
redundant brick.

fixes: bz#1642448
Change-Id: I0cb334b1b9378d67fcb8abf793dbe312c3179c0b
Signed-off-by: Sunil Kumar Acharya <sheggodu@redhat.com>
2018-10-24 18:45:50 +05:30
Sanju Rakonde
1be6703b10 glusterd: set integer instead of string
dict_get_str_boolean expects a integer, so we need
to set all the boolean variables as integers to
avoid log messages like below:

[2018-09-10 03:55:19.236387] I [dict.c:2838:dict_get_str_boolean] (-->/usr/local/lib/libgfrpc.so.0(rpc_clnt_reconnect+0xc2) [0x7ff7a83d0452] -->/usr/local/lib/glusterfs/4.2dev/rpc-transport/socket.so(+0x65b0) [0x7ff7a06cf5b0] -->/usr/local/lib/libglusterfs.so.0(dict_get_str_boolean+0xcf) [0x7ff7a85fc58f] ) 0-dict: key transport.socket.ignore-enoent, integer type asked, has string type [Invalid argument]

This patch addresses all such instances in glusterd.

Change-Id: I7e1979fcf381363943f4d09b94c3901c403727da
updates: bz#1193929
Signed-off-by: Sanju Rakonde <srakonde@redhat.com>
2018-10-24 06:02:07 +00:00
Kotresh HR
68299b2443 cli: Fix heap-buffer-overflow issue reported by ASAN
GF_MALLOC was being used to allocate memory which is
not initialized. strcat is used on it which could
result in buffer overflow if it contains garbage before
'\0'. So changed it to GF_CALLOC.

Traceback:

==23427==ERROR: AddressSanitizer: heap-buffer-overflow ...
WRITE of size 5 at 0x6080000083fe thread T3
 #0 0x7fb60966991c in __interceptor_strcat ...
 #1 0x48adc0 in config_parse ...
 #2 0x48cde8 in cli_cmd_gsync_set_parse ...
...

Updates: bz#1633930
Change-Id: I3710f011d8139984b1898265d84d150c9bdc962b
Signed-off-by: Kotresh HR <khiremat@redhat.com>
2018-10-24 05:06:18 +00:00
Kotresh HR
ac074e0343 cli: Fix memory leaks reported by ASAN
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>
2018-10-12 15:38:36 +00:00
Kotresh HR
16704e575c cli: Fix memory leaks reported by ASAN
'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>
2018-10-12 05:40:13 +00:00
Amar Tumballi
3fa73bfdb5 cli: memory leak issues reported by asan
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>
2018-10-09 19:17:21 +00:00
Sanju Rakonde
31b6308c64 cli: Resource leak coverity fix
This patch fixes CID 1175017.

Change-Id: I4968c35489aeb5bfa0461b2edf2a0d73b7f03c14
updates: bz#789278
Signed-off-by: Sanju Rakonde <srakonde@redhat.com>
2018-10-08 12:30:35 +00:00
Sunny Kumar
c1f0409822 cli : coverity fix in cli-rl.c
This patch fixes CID 1395248.
Issue : Resource leak

updates: bz#789278

Change-Id: I2fd4e36ac2c2a034e56883436abfc5199b095026
Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
2018-10-05 05:07:18 +00:00
shujun10086
04a98cd88e cli: fix glusterd memory leak cause by "gluster v status volume_name"
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>
2018-10-03 09:49:40 +05:30
Sanju Rakonde
f054b51105 cli: handle negative scenarios
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>
2018-10-01 08:02:27 +00:00
Yaniv Kaul
341ba81448 Quota related files: use dict_{setn|getn|deln|get_int32n|set_int32n|set_strn}
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
2018-09-26 04:17:30 +00:00
Gluster Ant
e16868dede Land part 2 of clang-format changes
Change-Id: Ia84cc24c8924e6d22d02ac15f611c10e26db99b4
Signed-off-by: Nigel Babu <nigelb@redhat.com>
2018-09-12 17:52:45 +05:30
Gluster Ant
45a71c0548 Land clang-format changes
Change-Id: I6f5d8140a06f3c1b2d196849299f8d483028d33b
2018-09-12 17:22:48 +05:30
karthik-us
f0bacb2a51 cli: Add warning message while converting to replica 2 configuration
Currently while creating replica 2 volume we display a warning message
of ending up in split-brain. But while converting an existing volume
from other configuration to replica 2 by add-brick or remove-brick
operations we do not show any such messages.
With this fix in add-brick and remove-brick cases also we will display
the same warning message and prompt for confirmation if the configuration
changes to replica 2.

Change-Id: Ifc4ed6994a087d2403894f4e743c4eb41633276b
fixes: bz#1627044
Signed-off-by: karthik-us <ksubrahm@redhat.com>
2018-09-11 02:35:35 +00:00
Yaniv Kaul
2b95d2c0be cli/src/cli-cmd-parser.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
Signed-off-by: Yaniv Kaul <ykaul@redhat.com>

Change-Id: Ic1531afbf614823628cc8d70bae782d4db7ec033
2018-09-05 21:12:08 +05:30
Sunny Kumar
0590678d05 cli : fix coverity issue in cli-cmd-parser.c
This patch fixes 1175017 and 1382401.

This patch fixes resource leak by validating brick_count is valid or
not. If brick_count is not valid we are coming out in "cli_cmd_bricks_parse"
without allocating memory to "brick_str" which is eventually pointed by bricks.

Change-Id: I8ed0f29495379ec49484c5c4069865db3653506f
updates: bz#789278
Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
2018-09-05 04:42:09 +00:00
Yaniv Kaul
5276e8f27e multiple files: calloc -> malloc
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
2018-09-04 05:09:09 +00:00
Sunny Kumar
33f53e88c3 cli : fix coverity issue in cli-cmd-volume.c
This patch fixes 1389756.

Change-Id: I72d4f618368545a5dcee0ca59fe87ba6137ab4a1
updates: bz#789278
Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
2018-08-31 01:24:40 +00:00
Sanju Rakonde
60ef38482c cli: dereferencing null coverity fix
CID: 1124489

https://scan6.coverity.com/reports.htm#v42375/p10714/fileInstanceId=85018660&defectInstanceId=25877775&mergedDefectId=577602

updates: bz#789278
Change-Id: I0ebfbc52ecd5e3b70574df5f286116f872514cc6
Signed-off-by: Sanju Rakonde <srakonde@redhat.com>
2018-08-29 04:45:46 +00:00
Sunny Kumar
57da742b13 cli : fix coverity cli-rl.c
This fixes new coverity issue introduced by commit 5acb74d7da.

Fixes 1395188.

Change-Id: I629e5f214150672e309abb2fc58f55f1f58d8fb7
updates: bz#789278
Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
2018-08-27 02:43:14 +00:00