summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/common-utils.c
Commit message (Collapse)AuthorAgeFilesLines
* libglusterfs: fix dict leakRavishankar N2020-09-041-8/+22
| | | | | | | | | | | | | | Problem: gf_rev_dns_lookup_cached() allocated struct dnscache->dict if it was null but the freeing was left to the caller. Fix: Moved dict allocation and freeing into corresponding init and fini routines so that its easier for the caller to avoid such leaks. Updates: #1000 Change-Id: I90d6a6f85ca2dd4fe0ab461177aaa9ac9c1fbcf9 Signed-off-by: Ravishankar N <ravishankar@redhat.com>
* Remove need for /proc on FreeBSDDaniel Morante2020-08-201-0/+9
| | | | | Change-Id: Ieebd9a54307813954011ac8833824831dce6da10 Fixes: #1376
* Use sysctl for get_mem_size() on FreeBSDDaniel Morante2020-08-191-1/+1
| | | | | Change-Id: Iab2600260707af02e2b8da9e489cbb12b9fc14a6 Fixes: #1376
* libglusterfs: add library wrapper for time()Dmitry Antipov2020-08-171-3/+3
| | | | | | | | | Add thin convenient library wrapper gf_time(), adjust related users and comments as well. Change-Id: If8969af2f45ee69c30c3406bce5baa8305fb7f80 Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru> Updates: #1002
* glusterfs: infinite loop in common-utils.cSaju-Mohammed2020-08-071-16/+9
| | | | | | | | | | | | | | | | | Issue: function - gf_rev_dns_lookup_cache having an infinite loop when gf_dnscache_entry_init() returns NULL. Also when ip address is coming in as NULL. Fix: Code change has been done to handle the loop. Also minor CLINT warnings removed for common-utils.c Added review comment changes. Code changes for #790 Change-Id: I24446dc64c0409009e91e0bf57a699c85337c578 Fixes: #790 Signed-off-by: msaju <sajmoham@redhat.com>
* dht - fixing xattr inconsistencyBarak Sason Rofman2020-07-221-0/+16
| | | | | | | | | | | | | | | | | The scenario of setting an xattr to a dir, killing one of the bricks, removing the xattr, bringing back the brick results in xattr inconsistency - The downed brick will still have the xattr, but the rest won't. This patch add a mechanism that will remove the extra xattrs during lookup. This patch is a modification to a previous patch based on comments that were made after merge: https://review.gluster.org/#/c/glusterfs/+/24613/ fixes: #1324 Change-Id: Ifec0b7aea6cd40daa8b0319b881191cf83e031d1 Signed-off-by: Barak Sason Rofman <bsasonro@redhat.com>
* libglusterfs, glusterd: tweak directory scanningDmitry Antipov2020-07-071-4/+3
| | | | | | | | | 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
* storage/posix, libglusterfs: library function to sync filesystemDmitry Antipov2020-06-221-0/+20
| | | | | | | | Convert an ad-hoc hack to a regular library function gf_syncfs(). Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru> Change-Id: I3ed93e9f28f22c273df1466ba4a458eacb8df395 Fixes: #1329
* Indicate timezone offsets in timestampsCsaba Henk2020-06-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Logs and other output carrying timestamps will have now timezone offsets indicated, eg.: [2020-03-12 07:01:05.584482 +0000] I [MSGID: 106143] [glusterd-pmap.c:388:pmap_registry_remove] 0-pmap: removing brick (null) on port 49153 To this end, - gf_time_fmt() now inserts timezone offset via %z strftime(3) template. - A new utility function has been added, gf_time_fmt_tv(), that takes a struct timeval pointer (*tv) instead of a time_t value to specify the time. If tv->tv_usec is negative, gf_time_fmt_tv(... tv ...) is equivalent to gf_time_fmt(... tv->tv_sec ...) Otherwise it also inserts tv->tv_usec to the formatted string. - Building timestamps of usec precision has been converted to gf_time_fmt_tv, which is necessary because the method of appending a period and the usec value to the end of the timestamp does not work if the timestamp has zone offset, but it's also beneficial in terms of eliminating repetition. - The buffer passed to gf_time_fmt/gf_time_fmt_tv has been unified to be of GF_TIMESTR_SIZE size (256). We need slightly larger buffer space to accommodate the zone offset and it's preferable to use a buffer which is undisputedly large enough. This change does *not* do the following: - Retaining a method of timestamp creation without timezone offset. As to my understanding we don't need such backward compatibility as the code just emits timestamps to logs and other diagnostic texts, and doesn't do any later processing on them that would rely on their format. An exception to this, ie. a case where timestamp is built for internal use, is graph.c:fill_uuid(). As far as I can see, what matters in that case is the uniqueness of the produced string, not the format. - Implementing a single-token (space free) timestamp format. While some timestamp formats used to be single-token, now all of them will include a space preceding the offset indicator. Again, I did not see a use case where this could be significant in terms of representation. - Moving the codebase to a single unified timestamp format and dropping the fmt argument of gf_time_fmt/gf_time_fmt_tv. While the gf_timefmt_FT format is almost ubiquitous, there are a few cases where different formats are used. I'm not convinced there is any reason to not use gf_timefmt_FT in those cases too, but I did not want to make a decision in this regard. Change-Id: I0af73ab5d490cca7ed8d07a2ce7ac22a6df2920a Updates: #837 Signed-off-by: Csaba Henk <csaba@redhat.com>
* libglusterfs/common-utils: structure loggingyatipadia2020-02-041-121/+92
| | | | | | | | changes all the gf_msg() to gf_smgs() Change-Id: I3524bbd8f8070df2f2c888ea9b0fb7db1ee44453 Updates: #657 Signed-off-by: yatipadia <ypadia@redhat.com>
* common-utils.c: add gf_strn2boolean() functionYaniv Kaul2019-11-271-0/+68
| | | | | | | | | | | | | | | | | | | | | The function takes a string and its length and based on it returns if it's a boolean. It's identical in functionality to gf_string2boolean only with far less string comparisons since it takes into account the length of the string. dict_get_str_boolean() has been converted to use it. Other cases of gf_string2boolean() across the code base can be converted as well, but more importantly, they should be converted from dict_get_str() and then calling to gf_string2boolean to simply call dict_get_str_boolean(), which would take care of this for them. This is therefore a first step in the conversion. Change-Id: I9ee93abfc676f6e123a3919d8df8c25e8848b799 updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
* posix-helpers.c (and others): minor changes to posix_xattr_fill()Yaniv Kaul2019-11-061-2/+2
| | | | | | | | | | | | | | | | posix_xattr_fill() is called from several POSIX functions. Made minor changes to it and the functions called from it: 1. Dict functions to use known lengths (dict_getn() instead of dict_get(), etc.) 2. Re-ordered some static char[] arrays, to account (hopefully) to the frequency of the xattrs usage (based on grep in the code...) 3. Before strcmp(), check if the strings lengths match. 4. Removed some dead code. Hopefully, no functional changes. Change-Id: I510c0d2785e54ffe0f82c4c449782f2302d63a32 updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
* libglusterfs: remove dependency of rpcAmar Tumballi2019-08-161-68/+0
| | | | | | | | | | | | | | | | | | Goal: 'libglusterfs' files shouldn't have any dependency outside of the tree, specially the header files, shouldn't have '#include' from outside the tree. Fixes: * Had to introduce libglusterd so, methods and structures required for only mgmt/glusterd, and cli/ are separated from 'libglusterfs/' * Remove rpc/xdr/gen from build, which was used mainly so dependency for libglusterfs could be properly satisfied. * Move rpcsvc_auth_data to client_t.h, so all dependencies could be handled. Updates: bz#1636297 Change-Id: I0e80243a5a3f4615e6fac6e1b947ad08a9363fce Signed-off-by: Amar Tumballi <amarts@redhat.com>
* backup-volfile-server: ignore duplicate entriesAmar Tumballi2019-07-231-2/+4
| | | | | | | | | | Erroring out for duplicate entries for backup_volfile_servers would cause failures for some script. This option is harmless if it is duplicate, we just need to ignore this. Fixes: bz#1730953 Change-Id: I950064501a7bb61b90e99f2c079564f9c923d4c1 Signed-off-by: Amar Tumballi <amarts@redhat.com>
* Replace usleep() with nanosleep()Vijay Bellur2019-07-111-0/+18
| | | | | | | | | | | | | | | | | | | As usleep has been obsoleted, changed all invocations of usleep to nanosleep. From man 3 usleep: "4.3BSD, POSIX.1-2001. POSIX.1-2001 declares this function obsolete; use nanosleep(2) instead. POSIX.1-2008 removes the specification of usleep()." Added a helper function gf_nanosleep() to have a single place for handling edge cases that might arise from the conversion of usleep to nanosleep and allow the sleep to resume with right remaining value upon being interrupted. Fixes: bz#1721686 Change-Id: Ia39ab82c9e0f4669d2c00d4cdf25e38d94ef9f62 Signed-off-by: Vijay Bellur <vbellur@redhat.com>
* multiple files: another attempt to remove includesYaniv Kaul2019-06-141-3/+0
| | | | | | | | | | | | | | | | | | There are many include statements that are not needed. A previous more ambitious attempt failed because of *BSD plafrom (see https://review.gluster.org/#/c/glusterfs/+/21929/ ) Now trying a more conservative reduction. It does not solve all circular deps that we have, but it does reduce some of them. There is just too much to handle reasonably (dht-common.h includes dht-lock.h which includes dht-common.h ...), but it does reduce the overall number of lines of include we need to look at in the future to understand and fix the mess later one. Change-Id: I550cd001bdefb8be0fe67632f783c0ef6bee3f9f updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
* core: only log seek errors if SEEK_HOLE/SEEK_DATA is availableNiels de Vos2019-04-111-0/+4
| | | | | | | | | | | | | | | | | | | On RHEL-6 there is no support for SEEK_HOLE/SEEK_DATA and this causes the POSIX xlator to return errno=EINVAL. Because of this, the rpc-server xlator will log all 'failed' seek attempts. When applications call seek() often, the brick logs can grow very quickly and fill up the disks. Messages that get logged are like [server-rpc-fops.c:2091:server_seek_cbk] 0-vol01-server: 4947: SEEK-2 (53920aee-062c-4598-aa50-2b4d7821b204), client: worker.example.com-7808-2019/02/08-18:04:57:903430-vol01-client-0-0-0, error-xlator: vol01-posix [Invalid argument] The problem can be reproduced by running a Gluster Server on RHEL-6, with a client running on RHEL-7. The client should execute an application that calls lseek() with SEEK_HOLE/SEEK_DATA. Change-Id: I7b6c16f8e0ba1a183e845cfdb8d5a3f8caeab138 Fixes: bz#1697316 Signed-off-by: Niels de Vos <ndevos@redhat.com>
* glusterfsd: Multiple shd processes are spawned on brick_mux environmentMohit Agrawal2019-03-121-1/+2
| | | | | | | | | | | | | | | | | | | Problem: Multiple shd processes are spawned while starting volumes in the loop on brick_mux environment.glusterd spawn a process based on a pidfile and shd daemon is taking some time to update pid in pidfile due to that glusterd is not able to get shd pid Solution: Commit cd249f4cb783f8d79e79468c455732669e835a4f changed the code to update pidfile in parent for any gluster daemon after getting the status of forking child in parent.To resolve the same correct the condition update pidfile in parent only for glusterd and for rest of the daemon pidfile is updated in child Change-Id: Ifd14797fa949562594a285ec82d58384ad717e81 fixes: bz#1684404 Signed-off-by: Mohit Agrawal <moagrawal@redhat.com>
* glusterd: change the op-versionSanju Rakonde2019-03-111-1/+1
| | | | | | | | | | as commit 073444 is backported to release-5.4 branch, op-version for this change should 5.4 instead of 6. fixes: bz#1685120 Change-Id: Id504b9a1446125cea7c6a32117ccc44f28e73aa7 Signed-off-by: Sanju Rakonde <srakonde@redhat.com>
* core: make compute_cksum function op_version compatibleSanju Rakonde2019-03-071-5/+10
| | | | | | | | | | | | | | | Problem: commit 5a152a changed the mechansim of computing the checksum. In heterogeneous cluster, peers are running into rejected state because we have different cksum computation mechansims in upgraded and non-upgraded nodes. Solution: add a check for op-version so that all the nodes in the cluster follow the same mechanism for computing the cksum. Change-Id: I1508f000e8c9895588b6011b8b6cc0eda7102193 fixes: bz#1685120 Signed-off-by: Sanju Rakonde <srakonde@redhat.com>
* glusterd: manage upgrade to current masterAmar Tumballi2019-02-041-5/+5
| | | | | | | | | | | | | | | | | | | | | | 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>
* core: make gf_thread_create() easier to useXavi Hernandez2019-02-011-30/+80
| | | | | | | | | | | | | | This patch creates a specific function to set the thread name using a string format and a variable argument list, like printf(). This function is used to set the thread name from gf_thread_create(), which now accepts a variable argument list to create the full name. It's not necessary anymore to use a local array to build the name of the thread. This is done automatically. Change-Id: Idd8d01fd462c227359b96e98699f8c6d962dc17c Updates: bz#1193929 Signed-off-by: Xavi Hernandez <xhernandez@redhat.com>
* afr/self-heal:Fix wrong type checkingRavishankar N2019-01-241-0/+23
| | | | | | | | | | gf_dirent struct has d_type variable which should check with DT_DIR istead of IA_IFDIR or IA_IFDIR has to compare with entry->d_stat.ia_type Change-Id: Idf1059ce2a590734bc5b6adaad73604d9a708804 updates: bz#1653359 Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com>
* rpc: use address-family option from vol fileMilind Changire2019-01-221-2/+15
| | | | | | | | | | | | | | | | | This patch helps enable IPv6 connections in the cluster. The default address-family is IPv4 without using this option explicitly. When address-family is set to "inet6" in the /etc/glusterfs/glusterd.vol file, the mount command-line also needs to have -o xlator-option="transport.address-family=inet6" added to it. This option also gets added to the brick command-line. Snapshot and gfapi use-cases should also use this option to pass in the inet6 address-family. Change-Id: I97db91021af27bacb6d7578e33ea4817f66d7270 fixes: bz#1635863 Signed-off-by: Milind Changire <mchangir@redhat.com>
* core: Feature added to accept CidrIp in auth.allowRinku Kothiya2019-01-181-2/+32
| | | | | | | | | | | | | | | Added functionality to gluster volume set auth.allow command to accept CIDR IP addresses. Modified few functions to isolate cidr feature so that it prevents other gluster commands such as peer probe to use cidr format ip. The functions are modified in such a way that they have an option to enable accepting of cidr format for other gluster commands if required in furture. updates: bz#1138841 Change-Id: Ie6734002a7078f1820e5df42d404411cce945e8b Credits: Mohit Agrawal Signed-off-by: Rinku Kothiya <rkothiya@redhat.com>
* fix 32-bit-build-smoke warningsIraj Jamali2019-01-111-1/+1
| | | | | | | fixes: bz#1622665 Change-Id: I777d67b1b62c284c62a02277238ad7538eef001e Signed-off-by: Iraj Jamali <ijamali@redhat.com>
* libglusterfs/common-utils.c: Fix buffer size for checksum computationVarsha Rao2019-01-111-2/+2
| | | | | | | | | | | | | | Problem: When quorum count option is updated, the change is not reflected in the nfs-server.vol file. This is because in get_checksum_for_file(), when the last part of the file read has size less than buffer size, the read buffer stores old data value along with correct data value. Solution: Pass the bytes read instead of fixed buffer size, for calculating checksum. Change-Id: I4b641607c8a262961b3f3da0028a54e08c3f8589 fixes: bz#1657744 Signed-off-by: Varsha Rao <varao@redhat.com>
* all: handle USE_AFTER_FREE warningsAmar Tumballi2018-12-201-3/+7
| | | | | | | | | | | | | | | | | | | * we shouldn't be using 'local' after DHT_STACK_UNWIND() as it frees the content of local. Add a 'goto out' or similar logic to handle the situation. * fix possible overlook of unref(dict), instead of unref(xdata). * make coverity happy by re-ordering unref in meta-defaults. * gfid-access: re-order dictionary allocation so we don't have to do a extra unref. * other obvious errors reported. updates: bz#789278 Change-Id: If05961ee946b0c4868df19861d7e4a927a2a2489 Signed-off-by: Amar Tumballi <amarts@redhat.com>
* core: move invalid port logs to DEBUG log levelMilind Changire2018-12-121-1/+1
| | | | | | | | | Stop spamming "invalid port" logs in case sysadmin has reserved a large number of ports. Change-Id: I244ef7693560cc404b36cadc6b05d92ec0e908d3 fixes: bz#1656517 Signed-off-by: Milind Changire <mchangir@redhat.com>
* libglusterfs: Move devel headers under glusterfs directoryShyamsundarR2018-12-051-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* Coverity fix for calling risky function - fscanfPoornima G2018-11-241-1/+1
| | | | | | | | | | | | | | | fscanf with %s reads a word, there is no restriction on the length of that word, and the caller is required to pass a sufficiently large buffer for storing thw word. If the input word exceeds the buffer size, it will cause buffer overflow. To fix this, use fscanf with width parameter. Width specifies the maximum number of characters to be read in the current reading operation. Change-Id: If250abf5eb637b9fc2a79047e3599f83254cd4e5 updates: bz#1193929 Signed-off-by: Poornima G <pgurusid@redhat.com>
* core: fix strncpy warningsKaleb S. KEITHLE2018-11-151-1/+1
| | | | | | | | | | | | | | | | | | | Since gcc-8.2.x (fedora-28 or so) gcc has been emitting warnings about buggy use of strncpy. e.g. warning: ‘strncpy’ output truncated before terminating nul copying as many bytes from a string as its length and warning: ‘strncpy’ specified bound depends on the length of the source argument Since we're copying string fragments and explicitly null terminating use memcpy to silence the warning Change-Id: I413d84b5f4157f15c99e9af3e154ce594d5bcdc1 updates: bz#1193929 Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
* core: Portmap entries showing stale brick entries when bricks are downMohit Agrawal2018-11-121-1/+4
| | | | | | | | | | | | | | | | Problem: pmap is showing stale brick entries after down the brick because of glusterd_brick_rpc_notify call gf_is_service_running before call pmap_registry_remove to ensure about brick instance. Solutiom: 1) Change the condition in gf_is_pid_running to ensure about process existence, use open instead of access to achieve the same 2) Call search_brick_path_from_proc in __glusterd_brick_rpc_notify along with gf_is_service_running Change-Id: Ia663ac61c01fdee6c12f47c0300cdf93f19b6a19 fixes: bz#1646892 Signed-off-by: Mohit Agrawal <moagrawal@redhat.com>
* libglusterfs multiple files: remove dead initilizationYaniv Kaul2018-11-111-4/+0
| | | | | | | | | | | | | Per newer GCC releases and clang-scan, some trivial dead initialization (values that were set but were never read) were removed. Compile-tested only! updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com> Change-Id: Ia9959b2ff87d2e9cb46864e68ffe7dccb984db34
* all: fix warnings on non 64-bits architecturesXavi Hernandez2018-10-101-16/+0
| | | | | | | | | | 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>
* Land part 2 of clang-format changesGluster Ant2018-09-121-3513/+3540
| | | | | Change-Id: Ia84cc24c8924e6d22d02ac15f611c10e26db99b4 Signed-off-by: Nigel Babu <nigelb@redhat.com>
* features/uss: Use xxh64 to generate gfid instead of md5sumRaghavendra Manjunath2018-09-051-0/+170
| | | | | | | | | | | | | | | | * This is to ensure FIPS support * Also changed the signature of svs_uuid_generate to get xlator argument * Added xxh64 wrapper functions in common-utils to generate gfid using xxh64 - Those wrapper functions can be used by other xlators as well to generate gfids using xxh64. But as of now snapview-server is going to be the only consumer. Change-Id: Ide66573125dd74122430cccc4c4dc2a376d642a2 Updates: #230 Signed-off-by: Raghavendra Manjunath <raghavendra@redhat.com> Signed-off-by: Raghavendra Bhat <raghavendra@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/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
* 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
* libglusterfs/src/common-utils.c: strncpy -> sprintf, remove dead code.Yaniv Kaul2018-08-201-120/+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>
* contrib: Remove gf_mkostemp copied from GLibCShyamsundarR2018-08-161-4/+12
| | | | | | | | | | | | | | | | | | 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-161-7/+8
| | | | | | | | | | | | | | | | | | | | | | 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: run codespell on the code and fix issues.Yaniv Kaul2018-07-221-3/+3
| | | | | | | | | | | | 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-161-2/+1
| | | | | | | | | | | | | | | 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>
* Fix compile warningsXavi Hernandez2018-07-101-2/+3
| | | | | | | | | | | 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>
* 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>
* core: FreeBSD has pthread_set_name_np() (versus pthread_setname_np())Kaleb S. KEITHLEY2018-05-091-2/+8
| | | | | | | | | | And has had it since at least FreeBSD 9.0 Reported-by: Roman Serbski <mefystofel@gmail.com> Change-Id: I52cfde7f2f7a82d0e66465ac392ed7e201e1653b updates: bz#1193929 Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
* gfapi : RECALL_LEASE implementationSoumya Koduri2018-05-041-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Right now there are two types of upcalls * poll method * registering callback But callback can be registered per fs and same callback fn shall be used for any lease recall with object handle as argument as done for cache invalidation. TODO: RECALL LEASE for each glfd (for future reference) (may be needed fo Samba as they do not deal with object handles. In case of RECALL_LEASE, we could associate separate cbk function for each glfd either by - extending pub_glfs_lease to accept new args (recall_cbk_fn, cookie) - or by defining new API "glfs_register_recall_cbk_fn (glfd, recall_cbk_fn, cookie) . In such cases, flag it and instead of calling below upcall functions, define a new one to go through the glfd list and invoke each of theirs recall_cbk_fn. Plus added following as well * passed lease id to dict in required arguments * added flag check in pub_glfs_open Updates: #350 Change-Id: I07a971f0f26ec6aae0b9f9a5613504317dee153b Signed-off-by: Soumya Koduri <skoduri@redhat.com> Signed-off-by: Poornima G <pgurusid@redhat.com> Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com>