summaryrefslogtreecommitdiffstats
path: root/libglusterfs
Commit message (Collapse)AuthorAgeFilesLines
* Various files: strncpy()->sprintf(), reduce strlen()'sYaniv Kaul2018-08-313-39/+47
| | | | | | | | | | | | | | | | | | | | 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(). Check for truncated output where applicable. 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: I54e80d4f4a80e98d3775e376efe05c51af0b29eb updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
* libglusterfs : fix coverity issues in common-utils.cSunny Kumar2018-08-311-6/+18
| | | | | | | | Fixes CID 1351691, 1351678, 1274192, 1274117, 1124845. Change-Id: I65805524de85fb2186260288641390458a719499 updates: bz#789278 Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
* libglusterfs/src/dict.c: fix to handle key=NULL.Yaniv Kaul2018-08-311-10/+31
| | | | | | | | | | | We don't want to strlen NULL strings. Compile-tested only! updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com> Change-Id: Id795998693ba410dbd80df962d48956a9e4164c4
* clang-scan: fix multiple issuesAmar Tumballi2018-08-311-0/+25
| | | | | | | | | | | * Buffer overflow issue in glusterfsd * Null argument passed to function expecting non-null (event-epoll) * Make sure the op_ret value is set in macro (posix) Updates: bz#1622665 Change-Id: I32b378fc40a5e3ee800c0dfbc13335d44c9db9ac Signed-off-by: Amar Tumballi <amarts@redhat.com>
* libglusterfs/gfdb_data_store: handle a range-overflow conditionAmar Tumballi2018-08-311-0/+8
| | | | | | | | | | | | As the value read from the file is not checked for the range, and the same value is directly used to allocate, and read further values, it can cause major issues. CID: 1351699 updates: bz#789278 Change-Id: I7ff4c1791343861ebf98d1c615b52af54cb2485e Signed-off-by: Amar Tumballi <amarts@redhat.com>
* libglusterfs/src/dict.c: allocate memory accurately.Yaniv Kaul2018-08-301-23/+8
| | | | | | | | | | | | | | | | | | I suspect we've allocated and then set to '\0' an additional byte for no reason: gf_asprintf() allocates enough inc. the terminating null; data->len took that additional byte into account; memcpy() it back took care of that terminating null byte as well. Also, unrelated, implemented str_to_data() via strn_to_data(). Compile-tested only! updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com> Change-Id: I32c90e12974f51a0fbc0cfaebf9bd0fd722adc11
* multiple files: remove unndeeded memset()Yaniv Kaul2018-08-295-12/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* multiple files: move from strlen() to sizeof()Yaniv Kaul2018-08-294-12/+10
| | | | | | | | | | | | | | | {glusterfsd|glusterfsd-mgmt|quota-common-utils|xlator|tier|stripe}.c tools/setgfid2path/src/main.c xlators/cluster/afr/src/afr-inode-read.c {glusterfs-acl|glusterfs}.h For const strings, just do compile time size calc instead of runtime. Compile-tested only! Change-Id: I303684b1ff29b05c10126fb1057f507e404ced07 updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
* libglusterfs : fix coverity in store.cSunny Kumar2018-08-281-1/+1
| | | | | | | | This patch fixes CID 1395103 and 1395102. Change-Id: I8c9fad85f254a55697b0bad185dcdd02be64f682 updates: bz#789278 Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
* libglusterfs/src/dict.{c,h}: Introduce dict_setn, dict_addn, dict_addn and ↵Yaniv Kaul2018-08-273-8/+152
| | | | | | | | | | | | | | | | | | | | | | others. They all take as a parameter the key length, instead of strlen() it. In most cases, we know the key length, we just never bothered to save and pass it along. (We most likely sprintf'ed it earlier and the return value could have been used). A more interesting addition is dict_set_nstrn() [horrible name. Ideas are welcome]. It accepts both the string length and the key length and avoids strlen() both. Some of it can be calculated on compile-time, btw. For example: dict_set_str (dict, "key", "all"); Should become: dict_set_nstrn (dict, "key", sizeof ("key"), "all", sizeof ("all")); Compile-tested only! Change-Id: Ic2667f445f6c2e22e279505f5ad435788b4b668c updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
* libglusterfs/src/dict.c: perform hash calc not under lock.Yaniv Kaul2018-08-271-12/+26
| | | | | | | | | | | If possible, perform the key hash calculation not under the dictionary lock. Compile-tested only! Change-Id: I88b6ed4eff6660d8334bc08ca4eebf61960e3ca1 updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
* dict.c: fix indentionYaniv Kaul2018-08-271-1/+1
| | | | | | | | updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com> Change-Id: I3f210ae236f778fd0e8e7a17d01da21f65cb4e4b
* dict.c: do not strlen if not needed.Yaniv Kaul2018-08-271-61/+51
| | | | | | | | | | | | Use the output of sprintf(). Also, constify and initialize parameters properly. Only compile-tested! Change-Id: I33870afbe14bc1292fb08115e878d48c00a43bee updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
* 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>