summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-store.c
Commit message (Collapse)AuthorAgeFilesLines
* libglusterfs, glusterd: tweak directory scanningDmitry Antipov2020-07-071-23/+18
| | | | | | | | | Replace an over-engineered GF_SKIP_IRRELEVANT_ENTRIES() with inline function gf_irrelevant_entry(), adjust related users. Change-Id: I6f66c460f22a82dd9ebeeedc2c55fdbc10f4eec5 Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru> Fixes: #1350
* glusterd: fix memory leak in glusterd_store_retrieve_bricks()Dmitry Antipov2020-06-051-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Found with GCC's address sanitizer: ==67190==ERROR: LeakSanitizer: detected memory leaks Direct leak of 24624 byte(s) in 6 object(s) allocated from: #0 0x7f62535c0837 in __interceptor_calloc (/usr/lib64/libasan.so.6+0xb0837) #1 0x7f62532a1690 in __gf_default_calloc glusterfs/mem-pool.h:122 #2 0x7f62532a20ca in __gf_calloc /path/to/glusterfs/libglusterfs/src/mem-pool.c:144 #3 0x7f62532c8128 in gf_store_iter_new /path/to/glusterfs/libglusterfs/src/store.c:511 #4 0x7f623e2f9ed7 in glusterd_store_retrieve_bricks /path/to/glusterfs/xlators/mgmt/glusterd/src/glusterd-store.c:2389 Direct leak of 8208 byte(s) in 2 object(s) allocated from: #0 0x7f62535c0837 in __interceptor_calloc (/usr/lib64/libasan.so.6+0xb0837) #1 0x7f62532a1690 in __gf_default_calloc glusterfs/mem-pool.h:122 #2 0x7f62532a20ca in __gf_calloc /path/to/glusterfs/libglusterfs/src/mem-pool.c:144 #3 0x7f62532c8128 in gf_store_iter_new /path/to/glusterfs/libglusterfs/src/store.c:511 #4 0x7f623e2f9cf0 in glusterd_store_retrieve_bricks /path/to/glusterfs/xlators/mgmt/glusterd/src/glusterd-store.c:2363 #5 0x7fff5cb70bcf ([stack]+0x15bcf) #6 0x7f623e309113 in glusterd_store_retrieve_volumes /path/to/glusterfs/xlators/mgmt/glusterd/src/glusterd-store.c:3505 #7 0xfffeb96e61d (<unknown module>) #8 0x7f623e4586d7 (/usr/lib64/glusterfs/9dev/xlator/mgmt/glusterd.so+0x2f86d7) Change-Id: I9b2a543dc095f4fa739cd664fd4d608bf8c87d60 Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru> Fixes: #1263
* multiple xlators: reduce key lengthYaniv Kaul2020-01-141-4/+3
| | | | | | | | | | | | | | | In many cases, we were freely allocating long keys with no need. Smaller char arrays are just fine almost anywhere, so just went ahead and looked where they we can use smaller ones. In some cases, annotated the functions as static and the prefixes passed as const as it was easier to read and understand. Where relevant, converted the dict functions to use known key length. Change-Id: I882ab33ea20d90b63278336cd1370c09ffdab7f2 updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
* glusterd-store: fix Coverity CID 1407767Xie Changlong2019-12-041-0/+2
| | | | | | | | To avoid memory leak. updates: bz#789278 Change-Id: I321c65a66c9ac372d059aa3ca89a989c6089979e Signed-off-by: Xie Changlong <xiechanglong@cmss.chinamobile.com>
* store.c/glusterd-store.c: remove sys_stat callsYaniv Kaul2019-11-271-3/+2
| | | | | | | | | | | | | | | Instead of querying for the file size and allocating a char array according to its size, let's just use a fixed size. Those calls are not really needed, and are either expensive or cached anyway. Since we do dynamic allocation/free, let's just use a fixed array instead. I'll see if there are other sys_stat() calls that are not really useful and try to eliminate them in separate patches. Change-Id: I76b40e78a52ab38f613fc0cdef4be60e6253bf20 updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
* glusterd: display correct rebalance data size after glusterd restartSanju Rakonde2019-10-181-5/+5
| | | | | | | | | | | | | | | | | | | Problem: After completion of rebalance, if glusterd is restarted, rebalance status displays wrong rebalance data size in its output. Cause: While glusterd restoring the information from /var/lib/glusterd/ into its memory, glusterd fetches rebalance_data from /var/lib/glusterd/vols/volname/node_state.info. This value is converted into an integer using atoi(), which is returning incorrect value for larger values. Solution: use sscanf() instead of atoi() to convert string to integer(in this case it is unsigned long) fixes: bz#1762438 Change-Id: Icbdb096919612b4a1d6fb0e315f09d38900abf4e Signed-off-by: Sanju Rakonde <srakonde@redhat.com>
* glusterd-store.c: remove of dead codeYaniv Kaul2019-09-051-130/+0
| | | | | | | | These functions do not seem to be in use. Change-Id: Ie76baf2a9727b9ba0e66f234226b1e62788245f2 updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
* Revert "glusterd: (storhaug) remove ganesha (843e1b0)"Jiffin Tony Thottan2019-08-241-10/+0
| | | | | | | | | 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>
* glusterd: write voldir once in glusterd-store and don't attempt again.Yaniv Kaul2019-07-291-29/+16
| | | | | | | | | | | | | | | | | | glusterd_store_brickinfos() is calling per each brick the function glusterd_store_brickinfo(). In it, we call: ret = glusterd_store_create_brick_dir(volinfo); However, volinfo is the same for all those bricks - no need to again and again call it (which tries to mkdir that dir). We can do it once above the loops in glusterd_store_brickinfos() While at, combine two similar functions that write additional dirs. Change-Id: I5858cf7783f088ea13a8fa20115118efa816f4cb updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
* core: use more restrictive mode while creating the directoriesSanju Rakonde2019-07-231-3/+3
| | | | | | | fixes: bz#1724024 Change-Id: I539fb7248b2cfc037ec29f1413ea648f9ec21ef2 Signed-off-by: Sanju Rakonde <srakonde@redhat.com>
* glusterd: don't log a warning message for tier-enabled keySanju Rakonde2019-07-041-2/+5
| | | | | | | | | | | | | We are logging a warning message saying unknown-key for tier-enabled kay. although the tier xlator is deprecated, this key is left behind for handling the peer rejection issues in a heterogeneous cluster. We need not to log if this key is not found/recognised. updates: bz#1193929 Change-Id: Ia68661898a618f99a240ca8d8a124ff6a65ebe9d Signed-off-by: Sanju Rakonde <srakonde@redhat.com>
* glusterd/thin-arbiter: Thin-arbiter integration with GD1Vishal Pandey2019-06-281-9/+227
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* glusterd.h: remove unneeded macros or move them to their users.Yaniv Kaul2019-06-251-0/+27
| | | | | | | | | | Some macros were not used, so removed. Some macros were quite local, so moved to the respective users. Some macros simplified (removed an allocation here and there) Change-Id: Ifaf1aff15a78f105b1549ab8053378933b35df43 updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
* glusterd-volgen.c: remove BD xlator from the graphYaniv Kaul2019-06-181-13/+0
| | | | | | | | | | | | | The BD xlator was removed some time ago. Remove it from the graph. We can also remove the caps settings - only the BD xlator was using it. Lastly, remove the caps (which only BD was using) and the document describing the translator. Change-Id: Id0adcb2952f4832a5dc6301e726874522e07935d updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
* glusterd/tier: gluster upgrade broken because of tierhari gowtham2019-06-031-0/+9
| | | | | | | | | | | | | | | | | | | | Problem: While tier code was removed, the is_tier_enabled related to tier wasn't handled for upgrade. As this option was missing in the info file, the checksum mismatch issue happens during upgrade. This results in the peer rejections happening. Fix: use the op_version check and note down the is_tier_enabled always. This way it will be dummy key, but the future upgrades will work fine. NOTE: Just having the key from 3.10 to 7 will cause issues when upgraded from 5 to 8 or any such upgrade which skips the version where we handle it. Change-Id: I9951e2b74f16e58e884e746c34dcf53e559c7143 fixes: bz#1714973 Signed-off-by: hari gowtham <hgowtham@redhat.com>
* glusterd/tier: remove tier related code from glusterdHari Gowtham2019-05-271-210/+1
| | | | | | | | | | | | | The handler functions are pointed to dummy functions. The switch case handling for tier also have been moved to point default case to avoid issues, if reintroduced. The tier changes in DHT still remain as such. updates: bz#1693692 Change-Id: I80d80c9a3eb862b4440a36b31ae82b2e9d92e4dc Signed-off-by: Hari Gowtham <hgowtham@redhat.com>
* glusterd/store: store all key-values in one shotYaniv Kaul2019-05-081-320/+290
| | | | | | | | | | | | Instead of saving each key-value separately, which is slow ( especially as we fflush() after each!), store them all as one string and write all together. Implements https://github.com/gluster/glusterfs/issues/629 Change-Id: Ie77a272446b0b6785584b710a4fdd9c613dd9578 updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat,.com>
* glusterd: coverity fixAtin Mukherjee2019-05-061-2/+14
| | | | | | | | CID: 1382403 (CHECKED_RETURN) Updates: bz#789278 Change-Id: I4c57b93fd3d14c524ff8519ed876f029834de306 Signed-off-by: Atin Mukherjee <amukherj@redhat.com>
* glusterd: Fix coverity defects & put coverity annotationsAtin Mukherjee2019-05-021-4/+0
| | | | | | | | | | | Along with fixing few defect, put the required annotations for the defects which are marked ignore/false positive/intentional as per the coverity defect sheet. This should avoid the per component graph showing many defects as open in the coverity glusterfs web page. Updates: bz#789278 Change-Id: I19461dc3603a3bd8f88866a1ab3db43d783af8e4 Signed-off-by: Atin Mukherjee <amukherj@redhat.com>
* glusterd: improve loggingAtin Mukherjee2019-02-081-1/+3
| | | | | | | | | glusterd_resolve_all_bricks failure log should highlight the brick identifier. Updates: bz#1193929 Change-Id: I035b4650ef6a14bb1e1221d3bad1c40f9d43dbdd Signed-off-by: Atin Mukherjee <amukherj@redhat.com>
* glusterd: get-state command should not fail if any brick is gone badv7devSanju Rakonde2019-02-051-1/+2
| | | | | | | | | | | | | | | | | | | | | | Problem: get-state command will error out, if any of the underlying brick(s) of volume(s) in the cluster go bad. It is expected that get-state command should not error out, but should generate an output successfully. Solution: In glusterd_get_state(), a statfs call is made on the brick path for every bricks of the volumes to calculate the total and free memory available. If any of statfs call fails on any brick, we should not error out and should report total memory and free memory of that brick as 0. This patch also handles a statfs failure scenario in glusterd_store_retrieve_bricks(). fixes: bz#1672205 Change-Id: Ia9e8a1d8843b65949d72fd6809bd21d39b31ad83 Signed-off-by: Sanju Rakonde <srakonde@redhat.com>
* glusterd: manage upgrade to current masterAmar Tumballi2019-02-041-8/+7
| | | | | | | | | | | | | | | | | | | | | | Scenarios tested: * Upgrade the node when there are stripe / tiering and regular type of volumes are present. - All volumes are started fine (as the change was not on brick volfile) - For tier, the functionality may not even work, as changetimerecorder is not present. - 'gluster volume info' properly shows as 'NOT SUPPORTED' for stripe and tier type of volume. * Upgrade in a rolling upgrade scenario, where an old version is able to connect to higher master. - on a normal volume, if the volfile-server was new, the newer client volfiles needed to have utime xlator conditionally. - with this one change, all other changes seem to work fine. Change-Id: Ib2d3b69dafa02b2c695a735b13c1aa70aba07cb8 updates: bz#1635688 Signed-off-by: Amar Tumballi <amarts@redhat.com>
* libglusterfs: Move devel headers under glusterfs directoryShyamsundarR2018-12-051-14/+14
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* glusterd: glusterd to regenerate volfiles when GD_OP_VERSION_MAX changesAtin Mukherjee2018-12-051-7/+125
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While glusterd has an infra to allow post install of spec to bring it up in the interim upgrade mode to allow all the volfiles to be regenerated with the latest executable, in container world the same methodology is not followed as container image always point to the specific gluster rpm and gluster rpm doesn't go through an upgrade process. This fix does the following: 1. If glusterd.upgrade file doesn't exist, regenerate the volfiles 2. If maximum-operating-version read from glusterd.upgrade doesn't match with GD_OP_VERSION_MAX, glusterd detects it to be a version where new options are introduced and regenerate the volfiles. Tests done: 1. Bring up glusterd, check if glusterd.upgrade file has been created with GD_OP_VERSION_MAX value. 2. Post 1, restart glusterd and check glusterd hasn't regenerated the volfiles as there's is no change in the GD_OP_VERSION_MAX vs the op_version read from the file. 3. Bump up the GD_OP_VERSION_MAX in the code by 1 and post compilation restart glusterd where the volfiles should be again regenerated. Note: The old way of having volfiles regenerated during an rpm upgrade is kept as it is for now but eventually this can be sunset later. Change-Id: I75b49a1601c71e99f6a6bc360dd12dd03a96414b Fixes: bz#1651463 Signed-off-by: Atin Mukherjee <amukherj@redhat.com>
* glusterd: perform rcu_read_lock/unlock() under cleanup_lock mutexSanju Rakonde2018-12-031-2/+2
| | | | | | | | | | | | | | Problem: glusterd should not try to acquire locks on any resources, when it already received a SIGTERM and cleanup is started. Otherwise we might hit segfault, since the thread which is going through cleanup path will be freeing up the resouces and some other thread might be trying to acquire locks on freed resources. Solution: perform rcu_read_lock/unlock() under cleanup_lock mutex. fixes: bz#1654270 Change-Id: I87a97cfe4f272f74f246d688660934638911ce54 Signed-off-by: Sanju Rakonde <srakonde@redhat.com>
* glusterd: perform store operation in cleanup lockAtin Mukherjee2018-11-271-0/+8
| | | | | | | | | All glusterd store operation and cleanup thread should work under a critical section to avoid any partial store write. Change-Id: I4f12e738f597a1f925c87ea2f42565dcf9ecdb9d Fixes: bz#1652430 Signed-off-by: Atin Mukherjee <amukherj@redhat.com>
* glusterd : fix high sev coverity issueSunny Kumar2018-11-271-3/+2
| | | | | | | | This patch fixes CID : 1174824 : RESOURCE_LEAK Change-Id: I59d2d6ebc1fa3d7ebe0b97c7dbe3c5539128522a updates: bz#789278 Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
* core: fix strncpy warningsKaleb S. KEITHLE2018-11-151-3/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since gcc-8.2.x (fedora-28 or so) gcc has been emitting warnings about buggy use of strncpy. Most uses that gcc warns about in our sources are exactly backwards; the 'limit' or len is the strlen/size of the _source param_, giving exactly zero protection against overruns. (Which was, after all, one of the points of using strncpy in the first place.) IOW, many warnings are about uses that look approximately like this: ... char dest[8]; char src[] = "this is a string longer than eight chars"; ... strncpy (dest, src, sizeof(src)); /* boom */ ... The len/limit should be sizeof(dest). Note: the above example has a definite over-run. In our source the overrun is typically only theoretical (but possibly exploitable.) Also strncpy doesn't null-terminate on truncation; snprintf does; prefer snprintf over strncpy. Mildly surprising that coverity doesn't warn/isn't warning about this. Change-Id: I022d5c6346a751e181ad44d9a099531c1172626e updates: bz#1193929 Signed-off-by: Kaleb S. KEITHLE <kkeithle@redhat.com>
* glusterd : fix high sev coverity issueSunny Kumar2018-11-051-1/+4
| | | | | | | | | This patch fixes CID : 1174824 : RESOURCE_LEAK updates: bz#789278 Change-Id: I2a4f8b508995de112fa16e1094e44ecd4b625312 Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
* glusterd : fix high coverity issues glusterd-store.cSunny Kumar2018-11-021-31/+43
| | | | | | | | | | | This patch fixes CID 1224305, 1202395, 1202394, 1174824, 1174825, 1174826 and 1202397. All issues are of RESOURCE_LEAK type. Change-Id: Ie9944d5bdd0bd2788afdb1b6bb329aa3c44b90d0 updates: bz#789278 Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
* stripe: remove the translator from build and glusterdAmar Tumballi2018-10-311-11/+0
| | | | | | | | | | | | | | | | 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>
* all: fix warnings on non 64-bits architecturesXavi Hernandez2018-10-101-1/+1
| | | | | | | | | | When compiling in other architectures there appear many warnings. Some of them are actual problems that prevent gluster to work correctly on those architectures. Change-Id: Icdc7107a2bc2da662903c51910beddb84bdf03c0 fixes: bz#1632717 Signed-off-by: Xavi Hernandez <xhernandez@redhat.com>
* glusterd: make sure that brickinfo->uuid is not nullSanju Rakonde2018-09-261-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: After an upgrade from the version where shared-brick-count option is not present to a version which introduced this option causes issue at the mount point i.e, size of the volume at mount point will be reduced by shared-brick-count value times. Cause: shared-brick-count is equal to the number of bricks that are sharing the file system. gd_set_shared_brick_count() calculates the shared-brick-count value based on uuid of the node and fsid of the brick. https://review.gluster.org/#/c/glusterfs/+/19484 handles setting of fsid properly during an upgrade path. This patch assumed that when the code path is reached, brickinfo->uuid is non-null. But brickinfo->uuid is null for all the bricks, as the uuid is null https://review.gluster.org/#/c/glusterfs/+/19484 couldn't reached the code path to set the fsid for bricks. So, we had fsid as 0 for all bricks, which resulted in gd_set_shared_brick_count() to calculate shared-brick-count in a wrong way. i.e, the logic written in gd_set_shared_brick_count() didn't work as expected since fsid is 0. Solution: Before control reaches the code path written by https://review.gluster.org/#/c/glusterfs/+/19484, adding a check for whether brickinfo->uuid is null and if brickinfo->uuid is having null value, calling glusterd_resolve_brick will set the brickinfo->uuid to a proper value. When we have proper uuid, fsid for the bricks will be set properly and shared-brick-count value will be caluculated correctly. Please take a look at the bug https://bugzilla.redhat.com/show_bug.cgi?id=1632889 for complete RCA Steps followed to test the fix: 1. Created a 2 node cluster, the cluster is running with binary which doesn't have shared-brick-count option 2. Created a 2x(2+1) volume and started it 3. Mouted the volume, checked size of volume using df 4. Upgrade to a version where shared-brick-count is introduced (upgraded the nodes one by one i.e, stop the glusterd, upgrade the node and start the glusterd). 5. after upgrading both the nodes, bumped up the cluster.op-version 6. At mount point, df shows the correct size for volume. fixes: bz#1632889 Change-Id: Ib9f078aafb15e899a01086eae113270657ea916b Signed-off-by: Sanju Rakonde <srakonde@redhat.com>
* glusterd: fix coverity issuesSanju Rakonde2018-09-251-18/+4
| | | | | | | | | | | | | | | This patch addreeses CID 1124812, 11248123, 1124833, and 1351706 1. We have a null check after GF_ASSERT. GF_ASSERT does a null check and fails if it is null. So removing the redundant null checks. 2. Added a log message to avoid unused value coverity issue Change-Id: Ib0d6dad8f40474afc8e5e60a531d37247cc8a081 updates: bz#789278 Signed-off-by: Sanju Rakonde <srakonde@redhat.com>
* glusterd: acquire lock to update volinfo structureSanju Rakonde2018-09-181-31/+34
| | | | | | | | | | | | | | | | | | Problem: With commit cb0339f92, we are using a separate syntask for restart_bricks. There can be a situation where two threads are accessing the same volinfo structure at the same time and updating volinfo structure. This can lead volinfo to have inconsistent values and assertion failures because of unexpected values. Solution: While updating the volinfo structure, acquire a store_volinfo_lock, and release the lock only when the thread completed its critical section part. Fixes: bz#1627610 Signed-off-by: Sanju Rakonde <srakonde@redhat.com> Change-Id: I545e4e2368e3285d8f7aa28081ff4448abb72f5d
* glusterd : fix coverity issue in glusterd-store.cSunny Kumar2018-09-171-1/+6
| | | | | | | | This patch fixes CID 1124356: Unchecked return value (CHECKED_RETURN) updates: bz#789278 Change-Id: I81f4637f19b81f820a2deb70cc7f84b79fe70236 Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
* Land part 2 of clang-format changesGluster Ant2018-09-121-4215/+4170
| | | | | Change-Id: Ia84cc24c8924e6d22d02ac15f611c10e26db99b4 Signed-off-by: Nigel Babu <nigelb@redhat.com>
* multiple xlators (mgmt): strncpy()->sprintf(), reduce strlen()'sYaniv Kaul2018-09-071-89/+174
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | xlators/mgmt/glusterd/src/glusterd-geo-rep.c xlators/mgmt/glusterd/src/glusterd-handshake.c xlators/mgmt/glusterd/src/glusterd-sm.c xlators/mgmt/glusterd/src/glusterd-store.c xlators/mgmt/glusterd/src/glusterd-utils.c xlators/mgmt/glusterd/src/glusterd-volgen.c xlators/mgmt/glusterd/src/glusterd-volume-ops.c xlators/mgmt/glusterd/src/glusterd.c 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(). Try to ensure output is not truncated. Also: - save the result of strlen() and re-use it when possible. - move from strlen to SLEN (sizeof() ) for const strings. Compile-tested only! Change-Id: Ib5d001857236f43e41c4a51b5f48e1a33110aaeb updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
* 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 some coverity issuesBhumika Goyal2018-08-201-10/+3
| | | | | | | | | | | 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>
* glusterd: coverity defects fix introduced by commit 1f3bfe7Atin Mukherjee2018-08-171-1/+1
| | | | | | | | | | | | | 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>
* All: remove memset() before sprintf()Yaniv Kaul2018-08-141-5/+0
| | | | | | | | | | | | 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: Coverity issues with type FORWARD_NULLSanju Rakonde2018-07-241-1/+2
| | | | | | | | | | | This patch fixes coverity issues 102, 103, 112 and 119 from [1] [1] https://download.gluster.org/pub/gluster/glusterfs/static-analysis/master/glusterfs-coverity/2018-07-23-5fa004f3/html/ Updates: bz#789278 Change-Id: I99762eb0bcbd974a5250434777db63520f2ce2e6 Signed-off-by: Sanju Rakonde <srakonde@redhat.com>
* glusterd-store: fix coverity warningYaniv Kaul2018-07-171-15/+8
| | | | | | | | | The same variable 'len' was used both in the macros and the functions. (Introduced as part of commit 6dc5dfef819cad69d6d4b4c1c305efa74236ad84 ?) Change-Id: If434999d6470067f8a1e501c8e132561e8cd81ef updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
* Fix compile warningsXavi Hernandez2018-07-101-61/+169
| | | | | | | | | | | 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: fix tier-enabled flag op-version checkAtin Mukherjee2018-02-131-2/+2
| | | | | | | | | | tier-enabled flag in volinfo structure was introduced in 3.10, however while writing this value to the glusterd store was done with a wrong op-version check which results into volume checksum failure during upgrades. Change-Id: I4330d0c4594eee19cba42e2cdf49a63f106627d4 BUG: 1544600 Signed-off-by: Atin Mukherjee <amukherj@redhat.com>
* glusterd/store: handle the case of fsid being set to 0Amar Tumballi2018-02-051-0/+19
| | | | | | | | | | | | | Generally this would happen when a system gets upgraded from an version which doesn't have fsid details, to a version with fsid values. Without this change, after upgrade, people would see reduced 'df ' output, causing lot of confusions. Debugging Credits: Nithya B <nbalacha@redhat.com> Change-Id: Id718127ddfb69553b32770b25021290bd0e7c49a BUG: 1517260 Signed-off-by: Amar Tumballi <amarts@redhat.com>
* glusterd: checked_return coverity fixKartik_Burmee2017-11-151-1/+1
| | | | | | | | | | | | function: glusterd_store_retrieve_options issue: Calling "gf_store_iter_destroy" without checking return value fix: typecasted the return value of the function to void Change-Id: I6dc4f4308b1eca8d6ee85834a1530ff356c73898 BUG: 789278 Signed-off-by: Kartik_Burmee <kburmee@redhat.com>
* Coverity Issue: PW.INCLUDE_RECURSION in several filesGirjesh Rajoria2017-11-091-1/+0
| | | | | | | | | | | | | | Coverity ID: 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 423, 424, 425, 426, 427, 428, 429, 436, 437, 438, 439, 440, 441, 442, 443 Issue: Event include_recursion Removed redundant, recursive includes from the files. Change-Id: I920776b1fa089a2d4917ca722d0075a9239911a7 BUG: 789278 Signed-off-by: Girjesh Rajoria <grajoria@redhat.com>
* snapshot: Issue with other processes accessing the mounted brickSunny Kumar2017-10-231-10/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Added code for unmount of activated snapshot brick during snapshot deactivation process which make sense as mount point for deactivated bricks should not exist. Removed code for mounting newly created snapshot, as newly created snapshots should not mount until it is activated. Added code for mount point creation and snapshot mount during snapshot activation. Added validation during glusterd init for mounting only those snapshot whose status is either STARTED or RESTORED. During snapshot restore, mount point for stopped snap should exist as it is required to set extended attribute. During handshake, after getting updates from friend mount point for activated snapshot should exist and should not for deactivated snapshot. While getting snap status we should show relevent information for deactivated snapshots, after this pathch 'gluster snap status' command will show output like- Snap Name : snap1 Snap UUID : snap-uuid Brick Path : server1:/run/gluster/snaps/snap-vol-name/brick Volume Group : N/A (Deactivated Snapshot) Brick Running : No Brick PID : N/A Data Percentage : N/A LV Size : N/A Fixes: #276 Change-Id: I65783488e35fac43632615ce1b8ff7b8e84834dc BUG: 1482023 Signed-off-by: Sunny Kumar <sunkumar@redhat.com>