summaryrefslogtreecommitdiffstats
path: root/libglusterfs
Commit message (Collapse)AuthorAgeFilesLines
* multiple files: move from strlen() to sizeof()Yaniv Kaul2018-08-251-0/+3
| | | | | | | | | | | | {ec-heal|ec-combine|ec-helpers|ec-inode-read}.c For const strings, just do compile time size calc instead of runtime. Compile-tested only! Change-Id: If92ba0a7a20f64b898d01c6e3b6708190ca93e04 updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
* libglusterfs/src/iobuf.c: remove memset(), CALLOC -> MALLOCYaniv Kaul2018-08-241-6/+1
| | | | | | | | | | | | I'm not sure I see the need for those memset(), I've removed them. There's at least one easy to convert CALLOC to MALLOC - converted. Only compile-tested! updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com> Change-Id: Ia019775ad5255190f5d02d948ea27db7f563387d
* coverity: Multiple coverity fixes for issues with HIGH severityShyamsundarR2018-08-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* libglusterfs/src/common-utils.c: Move to GF_MALLOC() instead of GF_CALLOC() ↵Yaniv Kaul2018-08-221-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | 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: I579f5b405bf410aac5ab0452231124d354f94ed1
* xlators/playground: fix the template files with latest requirementsAmar Tumballi2018-08-221-0/+1
| | | | | | | | | | | | | | | * Make use of xlator_api * Make use of gf_msg() * Make use of mem-pool * Add a sample metrics dump function * Provide an dummy option, which can be initialized, and reconfigured * Add a test case to make sure template xlator is built and used with default fops * Make a change in rpc-coverage to run without lock tests. Updates: bz#1193929 Change-Id: I377dd67b656f440f9bc7c0098e21c0c1934e9096 Signed-off-by: Amar Tumballi <amarts@redhat.com>
* libglusterfs/src/graph.c: Move to GF_MALLOC() instead of GF_CALLOC() when ↵Yaniv Kaul2018-08-221-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | 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: Icd990423a5e6048e76922668aab67422f4bc1867
* dict.c: align dictionary structuresYaniv Kaul2018-08-221-5/+5
| | | | | | Change-Id: Ib7250b3ff11a7ab98b578c0663dc1817624b8df1 updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
* libglusterfs/src/quota-common-utils.c:move to GF_MALLOC() instead of ↵Yaniv Kaul2018-08-221-1/+1
| | | | | | | | | | | | | | | | | | GF_CALLOC() when 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. Please review carefully, especially for string allocation, with the terminating NULL string. Only compile-tested! Change-Id: Ie2a634d768904636160582189a5f0390668b37bb updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
* libglusterfs/src/rbthash.c: Move to GF_MALLOC() instead of GF_CALLOC() when ↵Yaniv Kaul2018-08-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | 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: Ied400a500e36373d725f9480c5ebbe0a851f7c40
* libglusterfs/src/dict.c: Move to GF_MALLOC() instead of GF_CALLOC() when ↵Yaniv Kaul2018-08-221-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | 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: Iea9098b9ec0a82a866fbc5836514b1b317daefa1
* libglusterfs/src/client_t.c: Move to GF_MALLOC() instead of GF_CALLOC() when ↵Yaniv Kaul2018-08-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | 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: I58d2604ef684f94ea782fdbb1b1462fc7be53a9e
* Fix physical memory detection on NetBSDEmmanuel Dreyfus2018-08-211-1/+11
| | | | | | | | | | | | | | | | NetBSD has two sysctl for physical memory detection: hw.physmem and hw.physmem64. Only the later is 64-bit proof, and it has been available for years. That fix is important because it cause recent glusterfs to refuse mounting fileystems when there is too much RAM, with an error loading the quick-read xlator [quick-read.c:838:check_cache_size_ok] 0-gfs-quick-read: Cache size 134217728 is greater than the max size of 0 Change-Id: I957a1ff1d7018fe2f9d47384a28708e6cbdf710a Signed-off-by: Emmanuel Dreyfus <manu@netbsd.org> Fixes: bz#1619475
* Revert "performance/write-behind: better invalidation in readdirp"Raghavendra G2018-08-212-8/+1
| | | | | | | | | | | This reverts commit 4d3c62e71f3250f10aa0344085a5ec2d45458d5c. Traversing all children of a directory in wb_readdirp caused significant performance regression. Hence reverting this patch Change-Id: I6c3b6cee2dd2aca41d49fe55ecdc6262e7cc5f34 updates: bz#1512691 Signed-off-by: Raghavendra G <rgowdapp@redhat.com>
* dict.c: ensure hash is done in the right place.Yaniv Kaul2018-08-201-29/+32
| | | | | | | | | The hash should be done outside of locks, whenever is possible. Change-Id: I4f8f7455702e0489a57105cf79668c7fca90e1c0 updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
* libglusterfs/src/common-utils.c: strncpy -> sprintf, remove dead code.Yaniv Kaul2018-08-202-124/+5
| | | | | | | | | | | | | | | | | | | | | | strncpy may not be very efficient for sort 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, do a quick calc to see how much we really need and use snprintf() to copy as much. Also, move from CALLOC to MALLOC, as we are writing to this newly allocated memory right away and add terminating null. Lastly, removed some dead code. I did the same optimization as above to it, only to find out no one is using it. Compile-tested only! Change-Id: Ib91b9a73c3d74c511fd067446b1bf6c2e1802687 updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
* libguestfs/src/mem-pool.h: switch from calloc() to malloc()Yaniv Kaul2018-08-201-14/+5
| | | | | | | | | | | If we are going to overwrite that allocated memory, why bother zero'ing it? Only compile-tested! updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com> Change-Id: I9c9d2d8d5ab3e706c747feb1920ecd417807f7fd
* coverity: libglusterfs issuesAmar Tumballi2018-08-199-10/+33
| | | | | | | | | CID: 1391415, 1274122, 1274201, 1382408, 1382437, 1389436 1288798, 1288106, 1288110 updates: bz#789278 Change-Id: I48c7a50f22f5f4580310040c66463d9f7dd26204 Signed-off-by: Amar Tumballi <amarts@redhat.com>
* dict.c: copy-pasta fix (dict -> data)Yaniv Kaul2018-08-191-2/+2
| | | | | | Change-Id: Ifda14a1cc01e0fa99ff20d710eccb43296e22955 updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
* performance/readdir-ahead: keep stats of cached dentries in sync with ↵Krutika Dhananjay2018-08-181-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | modifications PROBLEM: Stats of dentries that are readdirp'd ahead can become stale due to fops like writes, truncate etc that modify the file pointed by dentries. When a readdir is finally wound at offset corresponding to these entries, the iatts that are returned to the application come from readdir-ahead's cache, which are stale by now. This problem gets further aggravated when caching translators/modules cache and continue to serve this stale information. FIX: * Store the iatt in context of the inode pointed by dentry. * Whenever the inode pointed by dentry undergoes modification, in cbk of modification fop, update the iatt stored in inode-ctx to reflect the modification. * When serving a readdirp response from application, update iatts of dentries with the iatts stored in the context of inodes pointed by these dentries. * Some fops don't have valid iatts in their responses. For eg., write response whose data is still cached in write-behind will have zeroed out stat. In this case keep only ia_type and ia_gfid and reset rest of the iatt members to zero. - fuse-bridge in this case just sends "entry" information back to kernel and attr is not sent. - gfapi sets entry->inode to NULL and zeroes out the entire stat * There is one tiny race between the entry creation and a readdirp on its parent dir, which could cause the inode-ctx setting and inode ctx reading to happen on two different inode objects. To prevent this, when entry->inode doesn't eqaul to linked_inode, - fuse-bridge is made to send only "entry" information without attributes - gfapi sets entry->inode to NULL and zeroes out the entire stat. Change-Id: Ia27ff49a61922e88c73a1547ad8aacc9968a69df BUG: 1390050 Updates: bz#1390050 Signed-off-by: Krutika Dhananjay <kdhananj@redhat.com> Signed-off-by: Raghavendra G <rgowdapp@redhat.com>
* statedump : fix coverity issuesSunny Kumar2018-08-171-2/+2
| | | | | | | | | | | Comparing an array to null is not useful, the test will always evaluate as true. Fixes CID 1325566 and 1389371. updates: bz#789278 Change-Id: Id51f84cc62767a432de1d12851ae2669c1596a94 Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
* libglusterfs: FORWARD_NULL coverity fixSunil Kumar Acharya2018-08-162-1/+7
| | | | | | | | | | | Fixing FORWARD_NULL coverify errors in libglusterfs. CID: 1391407, 1391410 BUG: 789278 Change-Id: I3d20523005e4418759c8a72620edff7c977d2d00 updates: bz#789278 Signed-off-by: Sunil Kumar Acharya <sheggodu@redhat.com>
* contrib: Remove gf_mkostemp copied from GLibCShyamsundarR2018-08-163-7/+13
| | | | | | | | | | | | | | | | | | gf_mkostemp is borrowed from GLibC a long time back, we now have mkostemp or mkstemp alternatives with all distributions and versions that we care for. As a result removing this from the contrib directory and modifying the one instance that is still using the same. This is part of code cleanup as we cleaned up coverity SECUR_TEMP errors. Updates: bz#1193929 Change-Id: I1ad7863043cdb0845c53748f5a0522e767079130 Signed-off-by: ShyamsundarR <srangana@redhat.com>
* contrib/xxhash: update to latest xxHash (0.6.5)Yaniv Kaul2018-08-163-9/+11
| | | | | | | | | | | | | | | | | | | | | | Update to latest xxHash, which is supposed to faster with small keys. Specifically, updated to 3064d42e7d74b0921bdd1818395d9cb37bb8976a, which is a bit higher than 0.6.5. Compiled hopefully with namespace (XXH_NAMESPACE=GF_), which allows to use XXH() funcs with no fear they'll 'leak' from our library. Only compile tested! xxhsum is modified to display messages which was conflicting with regression tests (TAP harness). So modified the gfid2path_fuse.t and gfid2path_nfs.t to adhere to that. updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com> Change-Id: I35cea5cc93f338c1023ac2c9bc6d7d13225a967b
* All: remove memset() before sprintf()Yaniv Kaul2018-08-145-56/+1
| | | | | | | | | | | | 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>
* libglusterfs: Fix a resource leak in graph.cVijay Bellur2018-08-131-0/+1
| | | | | | | | Fixes CID 1382367 Change-Id: I02678fc71716ab0046ea2ef437c6594a8a34a4fc updates: bz#789278 Signed-off-by: Vijay Bellur <vbellur@redhat.com>
* core: Update condition in get_xlator_by_name_or_typeMohit Agrawal2018-08-101-1/+1
| | | | | | | | | | | | | | | | Problem: Sometimes client connection is failed after throwing error "cleanup flag is set for xlator Try again later". The situation comes only after get a detach request but the brick stack is not completely detached and at the same time the client initiates a connection with brick Solution: To resolve the same check cleanup_starting flag in get xlator_by_name_or_type, this function call by server_setvolume to attach a client with brick. Change-Id: I3720e42642fe495dd05211e2ed2cb976db9e231b fixes: bz#1614124 Signed-off-by: Mohit Agrawal <moagrawal@redhat.com>
* Revert "performance/readdir-ahead: Invalidate cached dentries if they're ↵Raghavendra G2018-08-031-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | modified while in cache" This reverts commit 7131de81f72dda0ef685ed60d0887c6e14289b8c. With the latest master, I created a single brick volume and some files inside it. [root@rhgs313-6 ~]# umount -f /mnt/fuse1; mount -t glusterfs -s 192.168.122.6:/thunder /mnt/fuse1; ls -l /mnt/fuse1/; echo "Trying again"; ls -l /mnt/fuse1 umount: /mnt/fuse1: not mounted total 0 ----------. 0 root root 0 Jan 1 1970 file-1 ----------. 0 root root 0 Jan 1 1970 file-2 ----------. 0 root root 0 Jan 1 1970 file-3 ----------. 0 root root 0 Jan 1 1970 file-4 ----------. 0 root root 0 Jan 1 1970 file-5 d---------. 0 root root 0 Jan 1 1970 subdir Trying again total 3 -rw-r--r--. 1 root root 33 Aug 3 14:06 file-1 -rw-r--r--. 1 root root 33 Aug 3 14:06 file-2 -rw-r--r--. 1 root root 33 Aug 3 14:06 file-3 -rw-r--r--. 1 root root 33 Aug 3 14:06 file-4 -rw-r--r--. 1 root root 33 Aug 3 14:06 file-5 d---------. 0 root root 0 Jan 1 1970 subdir [root@rhgs313-6 ~]# Conversation can be followed on gluster-devel on thread with subj: tests/bugs/distribute/bug-1122443.t - spurious failure. git-bisected pointed this patch as culprit. Change-Id: I1eb46f6c196f44fde8ce991840a0e724e6f50862 Signed-off-by: Raghavendra G <rgowdapp@redhat.com> Updates: bz#1390050
* performance/write-behind: better invalidation in readdirpRaghavendra G2018-07-282-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | Current invalidation of stats in wb_readdirp_cbk is prone to races. As the deleted comment explains, <snip> We cannot guarantee integrity of entry->d_stat as there are cached writes. The stat is most likely stale as it doesn't account the cached writes. However, checking for non-empty liability list here is not a fool-proof solution as there can be races like, 1. readdirp is successful on posix 2. sync of cached write is successful on posix 3. write-behind received sync response and removed the request from liability queue 4. readdirp response is processed at write-behind. In the above scenario, stat for the file is sent back in readdirp response but it is stale. </snip> Change-Id: I6ce170985cc6ce3df2382ec038dd5415beefded5 Signed-off-by: Raghavendra G <rgowdapp@redhat.com> Updates: bz#1512691
* performance/readdir-ahead: Invalidate cached dentries if they're modified ↵Krutika Dhananjay2018-07-281-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | while in cache PROBLEM: Entries that are readdirp'd ahead can undergo modification in terms of writes, truncates which could modify their iatts. When a readdir is finally wound at offset corresponding to these entries, the iatts that are returned to the application come from readdir-ahead's cache, which are stale by now. This problem gets further aggravated when caching translators/modules cache and continue to serve this stale information. FIX: Whenever a dentry undergoes modification, in the cbk of the modification fop, a "dirty" flag (default 0) is set in its inode ctx. When it's time for readdir-ahead to serve these entries, it will read the inode ctx and check if the entry is "dirty", and if it is, set the entry's attrs to all zeroes, as an indicator to fuse, md-cache etc not to cache these attributes. Also there is one tiny race between the entry creation and a readdirp on its parent dir, which could cause the inode-ctx setting and inode ctx reading to happen on two different inode objects. To prevent this, fuse-bridge is made to drop entries for which dentry->inode is not the same as linked inode, in readdirp cbk. Change-Id: If7396507632b5268442ca580473d5155fee9cbef BUG: 1390050 Updates: bz#1390050 Signed-off-by: Krutika Dhananjay <kdhananj@redhat.com> Signed-off-by: Raghavendra G <rgowdapp@redhat.com>
* build: remove uuid from contrib/Niels de Vos2018-07-272-15/+4
| | | | | | | | | | | | | | Bundling libuuid is not needed anymore, all current distributions provide it now. Some OS's provide their own uuid_*() functions in libc. These may not be fully compatible with libuuid.so found on Linux systems. In that case, either e2fsprogs-libuuid can be installed, or support for the native uuid_*() functions can be added to libglusterfs/src/compat-uuid.h. Change-Id: Icfa48caea81307a3bca549364969c2038911942b Fixes: bz#1607319 Signed-off-by: Niels de Vos <ndevos@redhat.com>
* build: rename event.h to gf-event.hNiels de Vos2018-07-275-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | Newer FreeBSD versions (noticed with 10.3-RELEASE) provide a event.h file that on occasion gets included instead of the libglusterfs file. When this happens, 'struct event_pool' will not be defined and building will fail with errors like: autoscale-threads.c:18:55: error: incomplete definition of type 'struct event_pool' int thread_count = pool->eventthreadcount; ~~~~^ autoscale-threads.c:17:16: note: forward declaration of 'struct event_pool' struct event_pool *pool = ctx->event_pool; ^ This problem is caused by 'pkg-config --cflags uuid' that adds /usr/local/include to the GF_CPPFLAGS. The use of libuuid is preferred so that the contrib/uuid/ directory can be removed. By renaming event.h to gf-event.h there is no conflict between the different event.h files anymore and compiling on FreeBSD works without issues. Change-Id: Ie69f6b8a4f8f8e9630d39a86693eb74674f0f763 Updates: bz#1607319 Signed-off-by: Niels de Vos <ndevos@redhat.com>
* stack: Reduce stack usage for local variables to store tmpfile namesShyamsundarR2018-07-271-2/+1
| | | | | | | | | | This patch moves stack based PATH_MAX allocations for tmpfile names, to heap allocated names instead. Reducing the impact on stack space used and accruing benefits thereof. Change-Id: I646d9cb091018de6768b3523902788fa2ba14d96 Updates: bz#1193929 Signed-off-by: ShyamsundarR <srangana@redhat.com>
* coverity: Ignore most of SECURE_TEMP issuesShyamsundarR2018-07-273-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | mkstemp as per the Linux man page, uses 0600 as the permission bits when creating the file. This is hence safe and a Coverity warning that should be ignored. Further, we are mostly a multi-threaded program in all our daemons and cannot set and unset umask at will in a multi-threaded program, to address the coverity issue. This change attempts to nudge coverity to ignore this warning, using the pattern, /* coverity[EVENT_TAG_NAME] ... */ <line of code that has the issue> This commit is an experiment, if post merge the next coverity report ignores these errors, the above pattern (as found using an internet search) works and can be applied to certain other warnings as well. Change-Id: I73a184ce1a54dd9e66542952b1190a74438c826a Updates: bz#789278 Signed-off-by: ShyamsundarR <srangana@redhat.com>
* core (named threads): flood of -Wformat-truncation warnings with gcc-7.1Kaleb S. KEITHLEY2018-07-233-7/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | Starting in Fedora 26 which has gcc-7.1.x, -Wformat-trunction is enabled with -Wformat, resulting in a flood of new warnings. This many warnings is a concern because it makes it hard(er) to see other warnings that should be addressed. An example is at https://kojipkgs.fedoraproject.org//packages/glusterfs/3.12.0/1.fc28/data/logs/x86_64/build.log For more info see https://review.gluster.org/#/c/18267/ I can't find much (or good) documentation on the heuristics the compiler uses for this warning. In the case of printing integer types it appears it looks at the available space in the destination and the range of values for the variable and/or its type. To address the specific question about why 0x3ff versus 0xfff to mask the value, either would suffice to hint to the compiler that the printed value will fit in three characters. But the loop is from 0...1023 (or 0...0x3ff if you prefer) so I chose that as a more "accurate" mask to use as it exactly matches the range of values of the loop. Fixes: bz#1492847 Change-Id: I6e309ba42159841131d8241bfc0566ef09e00aa9
* All: run codespell on the code and fix issues.Yaniv Kaul2018-07-2229-104/+104
| | | | | | | | | | | | 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>
* logging: check for fmts not being NULLAmar Tumballi2018-07-162-7/+10
| | | | | | | | | | | | | | | this fix is just a review of possible SIGSEGV issues in line 714 as per crash report at the bug: ``` 08:35:25 Program terminated with signal 11, Segmentation fault. 08:35:25 #0 0x00007f4ebb491c5c in gf_time_fmt (dst=0x7f4eb1ff9a90 "", sz_dst=256, utime=1531470915, fmt=0) at /home/jenkins/root/workspace/centos7-regression/libglusterfs/src/common-utils.h:714 ``` fixes: bz#1600878 Change-Id: I160c391f8ac1a3456e59103d293b24e0e3fae718 Signed-off-by: Amar Tumballi <amarts@redhat.com>
* md-cache: Do not invalidate cache post set/remove xattrPoornima G2018-07-114-2/+79
| | | | | | | | | | | | | | | Since setxattr and removexattr fops cbk do not carry poststat, the stat cache was being invalidated in setxatr/remoxattr cbk. Hence the further lookup wouldn't be served from cache. To prevent this invalidation, md-cache is modified to get the poststat in set/removexattr_cbk in dict. Co-authored with Xavi Hernandez. Change-Id: I6b946be2d20b807e2578825743c25ba5927a60b4 fixes: bz#1586018 Signed-off-by: Xavi Hernandez <xhernandez@redhat.com> Signed-off-by: Poornima G <pgurusid@redhat.com>
* Fix compile warningsXavi Hernandez2018-07-103-13/+24
| | | | | | | | | | | 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>
* posix: Do not log ENXIO errors for seek fopXavi Hernandez2018-07-101-0/+6
| | | | | | | | | | | | | When lseek is used with SEEK_DATA and SEEK_HOLE, it's expected that the last operation fails with ENXIO when offset is beyond the end of file. In this case it doesn't make sense to report this as an error log message. This patch reports ENXIO failure messages for seek fops in debug level instead of error level. Change-Id: I62a4f61f99b0e4d7ea6a2cdcd40afe15072794ac fixes: bz#1598926 Signed-off-by: Xavi Hernandez <xhernandez@redhat.com>
* core/various: python3 compat, prepare for python2 -> python3Kaleb S. KEITHLEY2018-07-092-110/+109
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | see https://review.gluster.org/#/c/19788/, https://review.gluster.org/#/c/19871/, https://review.gluster.org/#/c/19952/, https://review.gluster.org/#/c/20104/, https://review.gluster.org/#/c/20162/, https://review.gluster.org/#/c/20185/, https://review.gluster.org/#/c/20207/, https://review.gluster.org/#/c/20227/, https://review.gluster.org/#/c/20307/, https://review.gluster.org/#/c/20320/, https://review.gluster.org/#/c/20332/, and https://review.gluster.org/#/c/20364/ Fixes glupy.py python2isms, iteritems -> items, and some overlooked print() in georep/peer_mountbroker.in Note: Fedora packaging guidelines and SUSE rpmlint require explicit shebangs; popular practices like #!/usr/bin/env python and #!/usr/bin/python are not allowed; they must be #!/usr/bin/python2 or #!/usr/bin/python3 Note: Selected small fixes from 2to3 utility. Specifically apply, basestring, funcattrs, has_key, idioms, map, numliterals, raise, set_literal, types, urllib, and zip have already been applied. Also version agnostic imports for urllib, cpickle, socketserver, _thread, queue, etc., suggested by Aravinda in https://review.gluster.org/#/c/19767/1 Note: these 2to3 fixes report no changes are necessary: asserts, buffer, exec, execfile, exitfunc, filter, getcwdu, imports2, input, intern, itertools, metaclass, methodattrs, ne, next, nonzero, operator, paren, raw_input, reduce, reload, renames, repr, standarderror, sys_exc, throw, tuple_params, xreadlines. Change-Id: Idda031c1ec975417c79323aea33e7b694e752b2a updates: #411 Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
* stack.h: fix the pass_through logicAmar Tumballi2018-07-031-10/+15
| | | | | | | | | | | | while fixing the coverity issues, we made a minor mistake in the pass through logic in STACK_WIND macro. Also, with this patch, made the code common to reduce possible future errors creeping in due to missing one place update. updates: bz#1193929 Change-Id: I6fcfd156d63b0a7e6208819872e565eacf774150 Signed-off-by: Amar Tumballi <amarts@redhat.com>
* core/various: python3 compat, prepare for python2 -> python3Kaleb S. KEITHLEY2018-06-232-21/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | see https://review.gluster.org/#/c/19788/, https://review.gluster.org/#/c/19871/, https://review.gluster.org/#/c/19952/, https://review.gluster.org/#/c/20104/, https://review.gluster.org/#/c/20162/, https://review.gluster.org/#/c/20185/, https://review.gluster.org/#/c/20207/, https://review.gluster.org/#/c/20227/, https://review.gluster.org/#/c/20307/, https://review.gluster.org/#/c/20320/, and https://review.gluster.org/#/c/20332/ This patch fixes the remaining comma white space (ws_comma) as suggested by the 2to3 utility. (Earlier attempts to fix all ws_comma in one patch did not pass centos regression, hence multiple patches to identify the change that causes the failure.) Note: Fedora packaging guidelines and SUSE rpmlint require explicit shebangs; popular practices like #!/usr/bin/env python and #!/usr/bin/python are not allowed; they must be #!/usr/bin/python2 or #!/usr/bin/python3 Note: Selected small fixes from 2to3 utility. Specifically apply, basestring, funcattrs, has_key, idioms, map, numliterals, raise, set_literal, types, urllib, and zip have already been applied. Also version agnostic imports for urllib, cpickle, socketserver, _thread, queue, etc., suggested by Aravinda in https://review.gluster.org/#/c/19767/1 Note: these 2to3 fixes report no changes are necessary: asserts, buffer, exec, execfile, exitfunc, filter, getcwdu, imports2, input, intern, itertools, metaclass, methodattrs, ne, next, nonzero, operator, paren, raw_input, reduce, reload, renames, repr, standarderror, sys_exc, throw, tuple_params, xreadlines. Change-Id: If5aca67084a7b1c06966fed35fb35e8bb2f7d67c updates: #411 Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
* glusterd: Fix for shd not coming upSanju Rakonde2018-06-131-3/+0
| | | | | | | | | | | | | | Problem: After creating and starting n(n is large) distribute-replicated volumes using a script, if we create and start (n+1)th distribute-replicate volume manually self heal daemon is down. Solution: In glusterd_proc_stop after giving SIGTERM signal if the process is still running, we are giving a SIGKILL. As SIGKILL will not perform any cleanup process, we need to remove the pidfile. Fixes: bz#1589253 Change-Id: I7c114334eec74c8d0f21b3e45cf7db6b8ef28af1 Signed-off-by: Sanju Rakonde <srakonde@redhat.com>
* features/shard: Introducing ".shard/.remove_me" for atomic shard deletion ↵Krutika Dhananjay2018-06-131-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | (part 1) PROBLEM: Shards are deleted synchronously when a sharded file is unlinked or when a sharded file participating as the dst in a rename() is going to be replaced. The problem with this approach is it makes the operation really slow, sometimes causing the application to time out, especially with large files. SOLUTION: To make this operation atomic, we introduce a ".remove_me" directory. Now renames and unlinks will simply involve two steps: 1. creating an empty file under .remove_me named after the gfid of the file participating in unlink/rename 2. carrying out the actual rename/unlink A synctask is created (more on that in part 2) to scan this directory after every unlink/rename operation (or upon a volume mount) and clean up all shards associated with it. All of this happens in the background. The task takes care to delete the shards associated with the gfid in .remove_me only if this gfid doesn't exist in backend, ensuring that the file was successfully renamed/unlinked and its shards can be discarded now safely. Change-Id: Ia1d238b721a3e99f951a73abbe199e4245f51a3a updates: bz#1568521 Signed-off-by: Krutika Dhananjay <kdhananj@redhat.com>
* core/various: python3 compat, prepare for python2 -> python3Kaleb S. KEITHLEY2018-06-071-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | see https://review.gluster.org/#/c/19788/, https://review.gluster.org/#/c/19871/, https://review.gluster.org/#/c/19952/, and https://review.gluster.org/#/c/20104/ https://review.gluster.org/#/c/20162/ This patch changes uses of map() and raise(), and a few cases of print() that were overlooked in the prior patch that fixed print. Note: Fedora packaging guidelines require explicit shebangs, so popular practices like #!/usr/bin/env python and #!/usr/bin/python are not allowed; they must be #!/usr/bin/python2 or #!/usr/bin/python3 Note: Selected small fixes from 2to3 utility. Specifically apply, basestring, funcattrs, idioms, numliterals, set_literal, types, urllib, zip, map, and raise have already been applied. Also version agnostic imports for urllib, cpickle, socketserver, _thread, queue, etc., suggested by Aravinda in https://review.gluster.org/#/c/19767/1 Note: these 2to3 fixes report no changes are necessary: asserts, buffer, exec, execfile, exitfunc, filter, getcwdu, intern, itertools, metaclass, methodattrs, ne, next, nonzero, operator, paren, raw_input, reduce, reload, renames, repr, standarderror, sys_exc, throw, tuple_params, xreadlines. Change-Id: Id62ea491e4ab5dd390075c5c6d9d889cf6f9da27 updates: #411 Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
* call-stub: Add a missing breakVijay Bellur2018-06-011-0/+1
| | | | | | | updates: bz#789278 Change-Id: Id411e69505209c08f33bb77948ee81936dfaef79 Signed-off-by: Vijay Bellur <vbellur@redhat.com>
* core/various: python3 compat, prepare for python2 -> python3Kaleb S. KEITHLEY2018-05-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | see https://review.gluster.org/#/c/19788/ and https://review.gluster.org/#/c/19871/ Selected small fixes from 2to3 utility. Specifically apply, basestring, funcattrs, idioms, numliterals, set_literal, types, urllib, zip Note: these 2to3 fixes report no changes are necessary: exec, execfile, exitfunc, filter, getcwdu, intern, itertools, metaclass, methodattrs, ne, next, nonzero, operator, paren, raw_input, reduce, reload, renames, repr, standarderror, sys_exc, throw, tuple_params, xreadlines. Any 2to3 fixes not in the above two lists have more extensive changes which will follow in separate patches. most unicode changes suggested by 2to3 will need to be applied at the same time as changing the shebangs from python2 to python3. Prashanth notes that unicode strings in py2 need 'u' prefix; unicode strings in py3 3.0, 3.1, and 3.2 a 'u' prefix will throw an error, but in py3 3.3+ it is legal (or just ignored). All Linux dists we care about have 3.3 or later so we can leave 'u' prefixes on unicode strings. Change-Id: I49bba2f328b0ee24b9a8115a7183be979981563e updates: #411 Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
* Core: The lock contention on gf_client_dump_inodes_to_dicthari gowtham2018-05-301-1/+1
| | | | | | | | | | | | | | Problem: For a distributed replicated volume, in the inode status command the lock on gf_client_dump_inodes_to_dict is held by the first brickop. while this is being processed, if the second brickop comes. It fails to get the lock and the whole brick op fails. Fix: Instead of using a TRY_LOCK which errors out if the lock is busy, Use LOCK which will wait till the lock is acquired. Change-Id: I768a0a1b60f28c4f7f94549e18ee3765b69cc528 fixes: bz#1579769 Signed-off-by: hari gowtham <hgowtham@redhat.com>
* rpc: conditionally cleanup event slotMilind Changire2018-05-291-0/+8
| | | | | | | | | | | | | | | Problem: socket_server_event_handler() may call rpc_transport_unref() for a socket which may fail registration with the event sub-system. This causes an assert to fail in event_unregister_epoll_common() Solution: Conditionally cleanup event slot only if slot index >= 0 Change-Id: I6ca7c133712e894adc335c7763879691b7e4b213 fixes: bz#1582704 BUG: 1582704 Signed-off-by: Milind Changire <mchangir@redhat.com>
* core: make glfs_iobuf_copy() consumable for general purpose.Susant Palai2018-05-244-0/+52
| | | | | | | | | Currently plugins for cloudsync will be using it to write back data downloaded from remote store/cloud. Change-Id: I59f10bebed21b19568c94cbf29e3d536d5570749 Updates: #387 Signed-off-by: Susant Palai <spalai@redhat.com>