summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt
Commit message (Collapse)AuthorAgeFilesLines
* glusterd : fix some coverity issues in glusterd-store.cSunny Kumar2018-09-051-3/+35
| | | | | | | | This patch fixes CID 1382346, 1274190 and 1382403. Change-Id: I1968e686587719e74bd70fa1542c20bccc04a7f9 updates: bz#789278 Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
* glusterd: Fix Buffer size issuesSanju Rakonde2018-09-041-6/+9
| | | | | | | | This patch fixes buffer size issue 1138522. Change-Id: Ia12fc8f34f75704f8ed3efae2022c4fd67a8c76c updates: bz#789278 Signed-off-by: Sanju Rakonde <srakonde@redhat.com>
* {dht-rebalance|glusterd-geo-rep|glusterd-utils|nfs|bd}.c: no dict_del before ↵Yaniv Kaul2018-09-042-5/+0
| | | | | | | | | | | | dict_set There is no need to remove an item before re-setting it. Compile-tested only! Change-Id: I2869aec9ebf474859127b8b38d284246e6097e84 updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
* Multiple files: calloc -> mallocYaniv Kaul2018-09-047-19/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | xlators/storage/posix/src/posix-inode-fd-ops.c: xlators/storage/posix/src/posix-helpers.c: xlators/storage/bd/src/bd.c: xlators/protocol/client/src/client-lk.c: xlators/performance/quick-read/src/quick-read.c: xlators/performance/io-cache/src/page.c xlators/nfs/server/src/nfs3-helpers.c xlators/nfs/server/src/nfs-fops.c xlators/nfs/server/src/mount3udp_svc.c xlators/nfs/server/src/mount3.c xlators/mount/fuse/src/fuse-helpers.c xlators/mount/fuse/src/fuse-bridge.c xlators/mgmt/glusterd/src/glusterd-utils.c xlators/mgmt/glusterd/src/glusterd-syncop.h xlators/mgmt/glusterd/src/glusterd-snapshot.c xlators/mgmt/glusterd/src/glusterd-rpc-ops.c xlators/mgmt/glusterd/src/glusterd-replace-brick.c xlators/mgmt/glusterd/src/glusterd-op-sm.c xlators/mgmt/glusterd/src/glusterd-mgmt.c xlators/meta/src/subvolumes-dir.c xlators/meta/src/graph-dir.c xlators/features/trash/src/trash.c xlators/features/shard/src/shard.h xlators/features/shard/src/shard.c xlators/features/marker/src/marker-quota.c xlators/features/locks/src/common.c xlators/features/leases/src/leases-internal.c xlators/features/gfid-access/src/gfid-access.c xlators/features/cloudsync/src/cloudsync-plugins/src/cloudsyncs3/src/libcloudsyncs3.c xlators/features/bit-rot/src/bitd/bit-rot.c xlators/features/bit-rot/src/bitd/bit-rot-scrub.c bxlators/encryption/crypt/src/metadata.c xlators/encryption/crypt/src/crypt.c xlators/performance/md-cache/src/md-cache.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! .. and allocate memory as much as needed. xlators/nfs/server/src/mount3.c : Don't blindly allocate PATH_MAX, but strlen() the string and allocate appropriately. Also, align error messges. updates: bz#1193929 Original-Author: Yaniv Kaul <ykaul@redhat.com> Signed-off-by: Yaniv Kaul <ykaul@redhat.com> Signed-off-by: Yaniv Kaul <ykaul@redhat.com> Change-Id: Ibda6f33dd180b7f7694f20a12af1e9576fe197f5
* geo-rep : fix coverity issues in glusterd-geo-rep.cSunny Kumar2018-09-041-3/+40
| | | | | | | | | | | | | | This patch fixes RESOURCE_LEAK at line number 1344, 2088, 4819, 1347, 2092, 1608, 1612, 2284, 3837. It also fixes FORWARD_NULL at line number 2955. CID : 1175012, 1175014, 1210989, 1223042, 1223043, 1382381, 1382429, 1389120, 1389474, 1390452, 1356512. Change-Id: I7de239944eb61073d208ecf3899999a1ea0c8e43 updates: bz#789278 Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
* glusterd: fail volume stop operation if brick detach failsAtin Mukherjee2018-09-041-8/+22
| | | | | | | | | | | | | | While sending a detach request for a brick in brick multiplexing mode, in any situation if the brick isn't connected, glusterd will fail to detach the brick but due to the missing error code handling, glusterd will mark the volume as stopped. Fix is to handle the return code of send_attach_req in glusterd_volume_stop_glusterfs () Change-Id: I886202969c96eec3620f74cd7027652d6287f4be Fixes: bz#1624440 Signed-off-by: Atin Mukherjee <amukherj@redhat.com>
* xlators: move from strlen() to sizeof()Yaniv Kaul2018-08-314-17/+17
| | | | | | | | | | | | | | | | | | xlators/features/index/src/index.c xlators/features/shard/src/shard.c xlators/features/upcall/src/upcall-internal.c xlators/mgmt/glusterd/src/glusterd-bitrot.c xlators/mgmt/glusterd/src/glusterd-locks.c xlators/mgmt/glusterd/src/glusterd-mountbroker.c xlators/mgmt/glusterd/src/glusterd-op-sm.c For const strings, just do compile time size calc instead of runtime. Compile-tested only! Change-Id: I995b2b89f14454b3855a4cd0ca90b3f01d5e080f updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
* glusterd : fix some coverity issues in glusterd-syncop.cSunny Kumar2018-08-301-3/+5
| | | | | | | | This patch fixes CID 1382344, 1124655 and 1325537. Change-Id: I2412d6b88483e32a5de1baebb3823a985b2dcfb0 updates: bz#789278 Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
* multiple files: remove unndeeded memset()Yaniv Kaul2018-08-292-8/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a squash of multiple commits: contrib/fuse-lib/misc.c: remove unneeded memset() All flock variables are properly set, no need to memset it. Only compile-tested! Signed-off-by: Yaniv Kaul <ykaul@redhat.com> Change-Id: I8e0512c5a88daadb0e587f545fdb9b32ca8858a2 libglusterfs/src/{client_t|fd|inode|stack}.c: remove some memset() I don't think there's a need for any of them. Only compile-tested! Signed-off-by: Yaniv Kaul <ykaul@redhat.com> Change-Id: I2be9ccc3a5cb5da51a92af73488cdabd1c527f59 libglusterfs/src/xlator.c: remove unneeded memset() All xl->mem_acct members are properly set, no need to memset it. Only compile-tested! Signed-off-by: Yaniv Kaul <ykaul@redhat.com> Change-Id: I7f264cd47e7a06255a3f3943c583de77ae8e3147 xlators/cluster/afr/src/afr-self-heal-common.c: remove unneeded memset() Since we are going over the whole array anyway, initialize it properly, to either 1 or 0. Only compile-tested! Signed-off-by: Yaniv Kaul <ykaul@redhat.com> Change-Id: Ied4210388976b6a7a2e91cc3de334534d6fef201 xlators/cluster/dht/src/dht-common.c: remove unneeded memset() Since we are going over the whole array anyway it is initialized properly. Only compile-tested! Signed-off-by: Yaniv Kaul <ykaul@redhat.com> Change-Id: Idc436d2bd0563b6582908d7cbebf9dbc66a42c9a xlators/cluster/ec/src/ec-helpers.c: remove unneeded memset() Since we are going over the whole array anyway it is initialized properly. Only compile-tested! Signed-off-by: Yaniv Kaul <ykaul@redhat.com> Change-Id: I81bf971f7fcecb4599e807d37f426f55711978fa xlators/mgmt/glusterd/src/glusterd-volgen.c: remove some memset() I don't think there's a need for any of them. Only compile-tested! Signed-off-by: Yaniv Kaul <ykaul@redhat.com> Change-Id: I476ea59ba53546b5153c269692cd5383da81ce2d xlators/mgmt/glusterd/src/glusterd-geo-rep.c: read() in 4K blocks The current 1K seems small. 4K is usually better (in Linux). Also remove a memset() that I don't think is needed between reads. Only compile-tested! Signed-off-by: Yaniv Kaul <ykaul@redhat.com> Change-Id: I5fb7950c92d282948376db14919ad12e589eac2b xlators/storage/posix/src/posix-{gfid-path|inode-fd-ops}.c: remove memset() before sys_*xattr() functions. I don't see a reason to memset the array sent to the functions sys_llistxattr(), sys_lgetxattr(), sys_lgetxattr(), sys_flistxattr(), sys_fgetxattr(). (Note: it's unclear to me why we are calling sys_*txattr() functions with XATTR_VAL_BUF_SIZE-1 size instead of XATTR_VAL_BUF_SIZE ). Only compile-tested! Change-Id: Ief2103b56ba6c71e40ed343a93684eef6b771346 updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
* glusterd: Fix coverity issuesSanju Rakonde2018-08-292-3/+2
| | | | | | | | | | | This patch fixes CID's 1395250, 1395252 1395250 - Unintialized variable 1395252 - Out of bounds access updates: bz#789278 Change-Id: Icf646364b14d48fa2bd82ea78ca5cdb5c684355f Signed-off-by: Sanju Rakonde <srakonde@redhat.com>
* snapshot : fixed coverity issue in glusterd-snapshot.cSunny Kumar2018-08-291-78/+88
| | | | | | | | This patch fixes CID 1395253 and indentation. Change-Id: Iffcd992d3d49765c7e47b864724f83c7c5d57579 updates: bz#789278 Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
* snapshot : fix few coverity issues in glusterd-snapshot-utils.cSunny Kumar2018-08-281-2/+3
| | | | | | | | This patch fixes CID 1210987 and 1351650. Change-Id: Ic85bc6048651146a79fe68add19dcc095738a517 updates: bz#789278 Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
* glusterd: glusterd_brick_start shouldn't cleanup pidfile if only_connect is trueMohit Agrawal2018-08-271-4/+4
| | | | | | | | | | | | Problem: Sometime glusterd cleanup pidfile even brick is started and cli shows volume status "N/A" Solution: Update the condition in glusterd_brick_start to avoid pidfile cleanup in case if only_connect flag is true Fixes: bz#1622422 Change-Id: I8decb34597126b848e3a44d957e138833dd97350 Signed-off-by: Mohit Agrawal <moagrawal@redhat.com>
* mgmt/glusterd: Coverity fixes in glusterd-utils.cVijay Bellur2018-08-271-3/+19
| | | | | | | | | | | | | | | Addresses the following CIDs: 1388821: Unchecked return value from sys_lremovexattr() in glusterd_check_and_set_brick_xattr() 1370957: Unused return value in glusterd_volume_tier_use_rsp_dict() 1370950: Memory leak in glusterd_get_global_options_for_all_vols() 1370946: Redundant gf_strdup() leading to a memory leak in glusterd_get_global_options_for_all_vols() Change-Id: I2ab58207bc43b40f004ee18463430a141126bf94 Updates: bz#789278 Signed-off-by: Vijay Bellur <vbellur@redhat.com>
* mgmt/glusterd: Fix resource leak & unused value issues in glusterd-volume-ops.cVijay Bellur2018-08-231-0/+5
| | | | | | | | Addresses CID: 1274132, 1325534 Change-Id: I176612ef5baf5618d543838a5f32db7dcd7002c3 updates: bz#789278 Signed-off-by: Vijay Bellur <vbellur@redhat.com>
* glusterd: glusterd_brick_start shouldn't try to bring up brick if ↵Atin Mukherjee2018-08-231-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | only_connect is true With the latest refactoring in glusterd_brick_start () function in case we run into a situation where is_gf_service_running () return a valid pid which is running but doesn't belong to a gluster process, even in case of only_connect flag passed as gf_true we'd end up trying to start a brick which would cause a deadlock in brick multiplexing as both glusterd_restart_bricks () and glusterd_do_volume_quorum_action () would cause context switching with each other for the same brick. The following bt shows the same: (gdb) t a a bt Thread 8 (Thread 0x7fcced48a700 (LWP 11959)): srch_vol=srch_vol@entry=0xbe0410, comp_vol=comp_vol@entry=0xc03680, brickinfo=brickinfo@entry=0xc14ef0) at glusterd-utils.c:5834 brickinfo=0xc14ef0, volinfo=0xc03680, conf=<optimized out>) at glusterd-utils.c:5902 brickinfo=brickinfo@entry=0xc14ef0, wait=wait@entry=_gf_false, only_connect=only_connect@entry=_gf_true) at glusterd-utils.c:6251 volinfo=0xc03680, meets_quorum=_gf_true) at glusterd-server-quorum.c:402 at glusterd-server-quorum.c:443 iov=iov@entry=0x7fcce0004040, count=count@entry=1, myframe=myframe@entry=0x7fcce00023a0) at glusterd-rpc-ops.c:542 iov=0x7fcce0004040, count=1, myframe=0x7fcce00023a0, fn=0x7fccf12403d0 <__glusterd_friend_add_cbk>) at glusterd-rpc-ops.c:223 ---Type <return> to continue, or q <return> to quit--- at rpc-transport.c:538 Thread 7 (Thread 0x7fccedc8b700 (LWP 11958)): Thread 6 (Thread 0x7fccf1d67700 (LWP 11877)): brickinfo=brickinfo@entry=0xc14ef0) at glusterd-utils.c:5834 at glusterd-utils.c:6251 Thread 5 (Thread 0x7fccf2568700 (LWP 11876)): Thread 4 (Thread 0x7fccf2d69700 (LWP 11875)): Thread 3 (Thread 0x7fccf356a700 (LWP 11874)): Thread 2 (Thread 0x7fccf3d6b700 (LWP 11873)): ---Type <return> to continue, or q <return> to quit--- Thread 1 (Thread 0x7fccf68a8780 (LWP 11872)): Fix: The solution is to ensure we don't restart bricks if only_connect is true and just ensure that the brick is attempted to be connected. Test: Simulated a code change to ensure gf_is_service_running () always return to true to hit the scenario. Change-Id: Iec184e6c9e8aabef931d310f931f4d7a580f0f48 Fixes: bz#1620544 Signed-off-by: Atin Mukherjee <amukherj@redhat.com>
* xlators/mgmt/glusterd/src/glusterd-utils.c : re-scope message variableYaniv Kaul2018-08-231-1/+1
| | | | | | | | | | The the error message variable changed in scope - defined in a smaller scope. Compile-tested only! Change-Id: I16dda11c30099b0e448b8e44a300f153727ce8da updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
* xlators/mgmt/glusterd/src/glusterd-volume-ops.c : reduce size of message ↵Yaniv Kaul2018-08-231-3/+3
| | | | | | | | | | | | | variable Size of error message variable reduced from 2048 bytes to 64 bytes or 128 bytes. Compile-tested only! Change-Id: I393ba03969a6e71ccb0ce382d0e0546192897312 updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
* xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c : declare err_str as ↵Yaniv Kaul2018-08-231-15/+5
| | | | | | | | | | | | const char declare err_str as const char and intialize it at the time of declaration. Compile-tested only! Change-Id: If07e1130e819ce042905a2d0be650cd7afc2b558 updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
* xlators/mgmt/glusterd/src/glusterd-replace-brick.c : reduce size of message ↵Yaniv Kaul2018-08-231-1/+1
| | | | | | | | | | | | variable Size of error message variable reduced from 2048 bytes to 256 bytes. Compile-tested only! Change-Id: Ifc0f6af2256bcbec77102767ba651d5d55f8c906 updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
* xlators/mgmt/glusterd/src/glusterd-volgen.c : reduce size of message variableYaniv Kaul2018-08-231-1/+1
| | | | | | | | | | Size of error message variable reduced from 4096 bytes to 128 bytes. Compile-tested only! Change-Id: I08c87502be791e68ab767ed96657ac89ee77fae0 updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
* mgmt/glusterd: Fix memory leaks in glusterd-handler.cVijay Bellur2018-08-231-1/+2
| | | | | | | | | | | | Addresses the following CIDs: 1370941: Unconditional memory leak in glusterd_print_snapinfo_by_vol() 1370943: Memory leak when opendir fails for output directory in glusterd_get_state() Change-Id: I9536841629e1ffe1fed79a8e57d266a0e953e5af updates: bz#789278 Signed-off-by: Vijay Bellur <vbellur@redhat.com>
* xlators/mgmt/glusterd/src/glusterd-rpc-ops.c : re-scope message variableYaniv Kaul2018-08-231-2/+2
| | | | | | | | | | | The error and/or message variable was changed in scope: defined in a smaller scope. Compile-tested only! Change-Id: I5e46a1992ad35a996aa8ee58da28606ac018ab8e updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
* xlators/mgmt/glusterd/src/glusterd-handshake.c : reduce size or re-scope ↵Yaniv Kaul2018-08-231-2/+2
| | | | | | | | | | | | | | | message variable The the error and/or message variable was either: - Reduced in size - from 2048 bytes to 64 bytes, for example. or - Changed in scope - defined in a smaller scope. Compile-tested only! Change-Id: I9c609415667844ee034b7eb2b67bdbc19d38819d updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
* xlators/mgmt/glusterd/src/glusterd-handler.c : reduce size or re-scope ↵Yaniv Kaul2018-08-231-23/+19
| | | | | | | | | | | | | | | message variable The the error and/or message variable was either: - Reduced in size - from 2048 bytes to 64 bytes, for example. or - Changed in scope - defined in a smaller scope. Compile-tested only! Change-Id: Iebb92a56d9d0ca53c80d75866bcb7848e08cf6b2 updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
* xlators/mgmt/glusterd/src/glusterd-geo-rep.c : reduce size of message variableYaniv Kaul2018-08-231-3/+3
| | | | | | | | | | Size of error message variable reduced from 2048 bytes to 64 bytes. Compile-tested only! Change-Id: I65abd9c4f23a64ac9cda5373aff4119458addbc8 updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
* xlators/mgmt/glusterd/src/glusterd-brick-ops.c : reduce size or re-scope ↵Yaniv Kaul2018-08-231-4/+3
| | | | | | | | | | | | | | | message variable The the error and/or message variable was either: - Reduced in size - from 2048 bytes to 64 bytes, for example. or - Changed in scope - defined in a smaller scope. Compile-tested only! Change-Id: Ib74e5f8f4c2978f670d4708e9382e97edf5df0a7 updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
* xlators/mgmt/glusterd/src/glusterd-bitrot.c : reduce size of message variableYaniv Kaul2018-08-231-1/+1
| | | | | | | | | | Size of error message variable reduced from 2048 bytes to 256 bytes. Compile-tested only! Change-Id: Ib536451d9b562f932132b99c4eff21fc4f2775bc updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
* mgmt/glusterd: Fix resource leaks in glusterd-handshake.cVijay Bellur2018-08-231-4/+16
| | | | | | | | | | | | | Addresses the following CIDs: 1124768: fd leak in __server_getspec() if spec_fd happens to be 0 1202400: Memory leak in get_snap_volname_and_volinfo() 1214622: Memory leak in glusterd_create_missed_snap() 1214623: Memory leak in an error path of __server_get_volume_info() Change-Id: I33910b4125d25205e76e0d13cf0256d47bd8fc3c updates: bz#789278 Signed-off-by: Vijay Bellur <vbellur@redhat.com>
* mgmt/glusterd: Fix memory leaks in glusterd-op-sm.cVijay Bellur2018-08-231-13/+5
| | | | | | | | | | | | | | | | | | | | | Addresses the following CIDs: - 1124704: Removed an unessential variable that caused a memory leak in glusterd_op_set_volume(). Nuked an unnecessary log message upon error as well since failure logging is being done in the caller - 1124772: Memory leak in an error path of glusterd_op_ac_send_brick_op() - 1175021: Removed an unessential variable that caused a memory leak in glusterd_op_build_payload() Also addressed a memory leak in an error path of glusterd_dict_set_volid() Change-Id: I060effbbcebe9d58b91f606175080ede517ba239 updates: bz#789278 Signed-off-by: Vijay Bellur <vbellur@redhat.com>
* snapshot : fix snapshot status failure due to symlink problemSunny Kumar2018-08-231-1/+9
| | | | | | | | | | | | | | | | | | | | | | | Problems : 1. Snapshot status for individual snapshots were failing after OS upgrade from RHEL6 to RHEL7. 2. Post upgrade snapshot creation of cloned volume was failing. Root Cause : When OS upgrade is from RHEL6 to RHEL7 there is difference in symlink (/var/run) between these two versions. Basically when (/var/run) is symlinked to /run, mount command resolves path and mounts it. But at the same time call to those functions fails who depends on absolute path. (like strcmp in glusterd_get_mnt_entry_info) Solution : Resolve the input path to absolute path before calling these functions. Test : Tested on same setup where issue was reported. After this patch snapshot issues are completely resolved. Change-Id: I5ba57998cea614c6072709f52f42a57562018844 fixes: bz#1619843 Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
* coverity: Multiple coverity fixes for issues with HIGH severityShyamsundarR2018-08-221-25/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | glfs-fops.c 1391414 Uninitialized pointer read List head needed initialization glusterfsd-mgmt.c graph.c 1382431 Buffer not null terminated 1382417 Dereference before null check 1382347 Buffer not null terminated Cleaned usage of volfile_checksum member of gf_volfile_t struct across the code base. glusterd-tier.c 1382426 Resource leak 1370955 Dereference before null check The function fixed needs more work, but with tier almost being deprecated, addressed some parts of the reported coverity issues as appropriate. Tested using the following test cases: ./tests/basic/tier/new-tier-cmds.t ./tests/basic/tier/tier.t ./tests/basic/tier/bug-1214222-directories_missing_after_attach_tier.t ./tests/basic/tier/tier_lookup_heal.t ./tests/basic/tier/tier-heald.t ./tests/basic/tier/tier-snapshot.t ./tests/features/glfs-lease.t Change-Id: I396f1c34bb112bb22d2745ed279e1a4850cac4af Updates: bz#789278 Signed-off-by: ShyamsundarR <srangana@redhat.com>
* glusterd: fix gcc warningsRavishankar N2018-08-213-187/+187
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ...and also changed char array initialization to from {0,} to "". gcc version 8.1.1 20180712 (Red Hat 8.1.1-5) (GCC) on Fedora 28. Sample warnings: glusterd-utils.c:7234:41: warning: ‘.hostname’ directive output may be truncated writing 9 bytes into a region of size between 1 and 1024 [-Wformat-truncation=] snprintf (key, sizeof (key), "%s.hostname", base_key); ^~~~~~~~~ glusterd-utils.c:7234:9: note: ‘snprintf’ output between 10 and 1033 bytes into a destination of size 1024 snprintf (key, sizeof (key), "%s.hostname", base_key); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ glusterd-snapshot.c:3090:65: warning: ‘/’ directive output may be truncated writing 1 byte into a region of size between 0 and 4095 [-Wformat-truncation=] snprintf (snap_path, sizeof (snap_path) - 1, "%s/%s", ^ glusterd-snapshot.c:3090:17: note: ‘snprintf’ output between 2 and 4351 bytes into a destination of size 4095 snprintf (snap_path, sizeof (snap_path) - 1, "%s/%s", ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ snap_mount_dir, snap_vol->snapshot->snapname); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ glusterd-statedump.c:28:45: warning: ‘%s’ directive output may be truncated writing up to 4095 bytes into a region of size 144 [-Wformat-truncation=] snprintf (subkey, sizeof (subkey), "%s%d", key, index); ^~ ~~~ glusterd-statedump.c:28:9: note: ‘snprintf’ output between 2 and 4107 bytes into a destination of size 144 snprintf (subkey, sizeof (subkey), "%s%d", key, index); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ updates: bz#1193929 Change-Id: Ic721f27b28d1221c124b570e81c55528f5b7f3cd Signed-off-by: Ravishankar N <ravishankar@redhat.com>
* glusterd: fix some coverity issuesBhumika Goyal2018-08-209-17/+21
| | | | | | | | | | | Fixes CID: 1241481 1241482 1274079 1274118 1274121 1274131 1274198 1274214 1274220 1274224 1394663 1394641 382454 1382453 1382449 1288095 Link: https://scan6.coverity.com/reports.htm#v42388/p10714/fileInstanceId=84772667&defectInstanceId=25770661&mergedDefectId=744716 Change-Id: Idaf434186231c8b0fff4b27c57fa23636a89c8a7 updates: bz#789278 Signed-off-by: Bhumika Goyal <bgoyal@redhat.com>
* snapshot/handshake: store description after strdupMohammed Rafi KC2018-08-201-3/+14
| | | | | | | | | | | | | | | problem: During a handshake, when we import a friend data snap description variable was just referenced to dictionary value. Solution: snap description should have a separate memory allocated through gf_strdup Change-Id: I94da0c57919e1228919231d1563a001362b100b8 fixes: bz#1618004 Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com>
* snapshot:Fix wrong dictionary key in snapshot cleanup codeMohammed Rafi KC2018-08-201-1/+2
| | | | | | | | | | | Snapshot was designed to support multiple volume snapshot, hence the volume name keys are labelled with volume count. So the volume key should have a volume count appended with key Change-Id: I044d73fc86db0e662dc914669aecfb82a6476fb5 fixes: bz#1618004 Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com>
* mgmt/glusterd: Code cleanup in glusterd-volgen.cVijay Bellur2018-08-191-20/+17
| | | | | | | | | | | | | | | This patch does the following: 1. Addresses CID: 1124815,124816,1124833,1291724,1325535,1325536,1357858 - by adding some null checks - by handling return values from functions - by using an appropriate buffer length in strncpy 2. Cleans up some commented code Change-Id: I5a7079f34e3e460d5a6267734c3bc84bf4ad72f5 updates: bz#789278 Signed-off-by: Vijay Bellur <vbellur@redhat.com>
* snapshot:Fail snapshot creation if an empty description providedMohammed Rafi KC2018-08-191-0/+10
| | | | | | | | | | Snapshot description should have a valid string. Creating a snapshot with null value will cause reading from info file to fail with a null exception Change-Id: I9f84154b8e3e7ffefa5438807b3bb9b4e0d964ca updates: bz#1618004 Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com>
* glusterd: coverity defects fix introduced by commit 1f3bfe7Atin Mukherjee2018-08-172-2/+2
| | | | | | | | | | | | | Commit 1f3bfe7 stripped down the total size of certain path related variables in glusterd_brickinfo_t which considered couple of new coverity defects. Fix the following: CID : 1394969 Destination buffer too small CID : 1394968 Out-of-bounds access Change-Id: Ibc30eac4680cc6c83bd89d248f1435cb6a3d1b75 updates: bz#789278 Signed-off-by: Atin Mukherjee <amukherj@redhat.com>
* glusterd: ignore importing volume which is undergoing a delete operationAtin Mukherjee2018-08-165-6/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem explanation: Assuming in a 3 nodes cluster, if N1 originates a delete operation and while N1's commit phase completes, either glusterd service of N2 or N3 gets disconnected from N1 (before completing the commit phase), N1 will attempt to end up importing the volume which is in-flight for a delete in other nodes as a fresh resulting into an incorrect configuration state. Fix: Mark a volume as stage deleted once a volume delete operation passes it's staging phase and reset this flag during unlock phase. Now during this intermediate phase if the same volume gets imported to other peers, it shouldn't considered to be recreated. An automated .t is quite tough to implement with the current infra. Test Case: 1. Keep creating and deleting volumes in a loop on a 3 node cluster 2. Simulate n/w failure between the peers (ifdown followed by ifup) 3. Check if output of 'gluster v list | wc -l' is same across all 3 nodes during 1 & 2. Change-Id: Ifdd5dc39699120258d7fdd42fe2deb9de25c6246 Fixes: bz#1605077 Signed-off-by: Atin Mukherjee <amukherj@redhat.com>
* build: use standard PKG_CHECK_MODULES for libxml2 availabilityNiels de Vos2018-08-161-2/+2
| | | | | | | | | | | | | In case the development parts of libxml2 are not installed, it was required to re-run ./autogen.sh to cleanup the cached values for the check. This is not nice towards users. By using the standard PKG_CHECK_MODULES for libxml-2.0 the results of the check are not cached and will be probed again when running ./configure. Change-Id: I3c4586e5555a521be5d4fb61bdb873ae0317311a Fixes: bz#1599219 Reported-by: Sachidananda Urs <surs@redhat.com> Signed-off-by: Niels de Vos <ndevos@redhat.com>
* mountbroker : fix coverity issue in glusterd-mountbroker.cSunny Kumar2018-08-151-1/+4
| | | | | | | | | Fixes CID : 1124789 updates: bz#789278 Change-Id: I61c70f05e6377d7ddc8961556274714dd356a117 Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
* glusterd: fix gcc7 warningsAmar Tumballi2018-08-142-22/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | [sh]$ gcc --version gcc (GCC) 7.3.1 20180303 (Red Hat 7.3.1-5) Warnings were of the type below: xlators/mgmt/glusterd/src/glusterd-store.c:3285:33: warning: ‘/options’ directive output may be truncated writing 8 bytes into a region of size between 1 and 4096 [-Wformat-truncation=] snprintf (path, len, "%s/options", conf->workdir); ^~~~~~~~ xlators/mgmt/glusterd/src/glusterd-store.c:1280:39: warning: ‘/snaps/’ directive output may be truncated writing 7 bytes into a region of size between 1 and 4096 [-Wformat-truncation=] snprintf (snap_fpath, len, "%s/snaps/%s/%s", priv->workdir, ^~~~~~~ * Also changed some places where there was issues with key size * Made sure all the 'char buf[SOMESIZE] = {0,};' are changed to 'char buf[SOMESIZE] = "";` - In the files I changed * Also edited coding standard to reflect that. updates: bz#1193929 Change-Id: I04c652624ac63199cea2077e46b3a5def37c3689 Signed-off-by: Amar Tumballi <amarts@redhat.com>
* mgmt/glusterd: Fix possible use after free in glusterd_op_ac_commit_op()Vijay Bellur2018-08-141-1/+3
| | | | | | | | Fixes CID 1391418 Change-Id: I60ce6cd3b2528369f4dc1be81c0c15a1a806982a updates: bz#789278 Signed-off-by: Vijay Bellur <vbellur@redhat.com>
* mgmt/glusterd: Fix buffer length to prevent a memory overrunVijay Bellur2018-08-141-2/+2
| | | | | | | | Fixes CID 1394647, 1394658 Change-Id: I30cf6e793919a08e0a3fe10622351b8316d7767c updates: bz#789278 Signed-off-by: Vijay Bellur <vbellur@redhat.com>
* glusterd: remove the unused databuf in rebalance structureAmar Tumballi2018-08-141-1/+0
| | | | | | | | | While it is a one line fix, it allows a significant unwanted memory being allocated for defrag structure. Updates: bz#1193929 Change-Id: Idda70d1d3dc0e7be56c35e872aa6edfaf752290d Signed-off-by: Amar Tumballi <amarts@redhat.com>
* mgmt/glusterd: Fix a memory leak in volgenVijay Bellur2018-08-141-0/+1
| | | | | | | | Fixes CID 1325557 Change-Id: I5e33ae19ddf4c44a49a2b3b3dea0c739bc96d3a7 updates: bz#789278 Signed-off-by: Vijay Bellur <vbellur@redhat.com>
* All: remove memset() before sprintf()Yaniv Kaul2018-08-1412-351/+61
| | | | | | | | | | | | 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>
* glusterd: compare friend data within mutexAtin Mukherjee2018-08-133-41/+48
| | | | | | | | | | | | | | | | | | | | | | | During friend handshake if the glusterd receives more than one friend updates, it might very well become possible that two threads would end up working on two different volinfo references and glusterd might end up updating the store with a old volinfo reference. While debugging glusterd crash from validating-server-quorum.t test file from the line-coverage regression the same was observed. Solution is to run glusterd_compare_friend_data under a mutex. Test: As the crash was more visible in the line-coverage run (given lcov does some instrumentation and exposes the races), 6 manual lcov runs were triggered starting from https://build.gluster.org/job/line-coverage/443 to https://build.gluster.org/job/line-coverage/449/ and no crash was observed from validating-server-quorum.t Change-Id: I86fce473a76fd24742d51bf17a685d28b90a8941 Fixes: bz#1603063 Signed-off-by: Atin Mukherjee <amukherj@redhat.com>
* glusterd: Compare volume_id before start/attach a brickMohit Agrawal2018-08-101-20/+27
| | | | | | | | | | | | | | Problem: After reboot a node brick is not coming up because fsid comparison is failed before start a brick Solution: Instead of comparing fsid compare volume_id to resolve the same because fsid is changed after reboot a node but volume_id persist as a xattr on brick_root path at the time of creating a volume. Change-Id: Ic289aab1b4ebfd83bbcae8438fee26ae61a0fff4 fixes: bz#1612418 Signed-off-by: Mohit Agrawal <moagrawal@redhat.com>