summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src
Commit message (Collapse)AuthorAgeFilesLines
* rpcsvc: Add latency tracking for rpc programsPranith Kumar K2020-09-0710-67/+115
| | | | | | | | | | Added latency tracking of rpc-handling code. With this change we should be able to monitor the amount of time rpc-handling code is consuming for each of the rpc call. fixes: #1466 Change-Id: I04fc7f3b12bfa5053c0fc36885f271cb78f581cd Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
* glusterfsd, libglusterfs, rpc: prefer libglusterfs time APIDmitry Antipov2020-09-071-1/+2
| | | | | | | | Use timespec_now_realtime() rather than clock_gettime(). Change-Id: I8fa00b7c0f7b388305c7d19574be3b409db68558 Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru> Updates: #1002
* build: extend --enable-valgrind to support Memcheck and DRDDmitry Antipov2020-09-053-4/+11
| | | | | | | | | Extend '-enable-valgrind' to '--enable=valgrind[=memcheck,drd]' to enable Memcheck or DRD Valgrind tool, respectively. Change-Id: I80d13d72ba9756e0cbcdbeb6766b5c98e3e8c002 Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru> Updates: #1002
* libglusterfs: fix dict leakRavishankar N2020-09-043-8/+25
| | | | | | | | | | | | | | 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>
* Events: Fixing coverity issues.Srijan Sivakumar2020-09-031-3/+5
| | | | | | | | | | Fixing resource leak reported by coverity scan. CID: 1431237 Change-Id: I2bed106b3dc4296c50d80542ee678d32c6928c25 Updates: #1060 Signed-off-by: Srijan Sivakumar <ssivakum@redhat.com>
* fuse: fetch arbitrary number of groups from /proc/[pid]/statusCsaba Henk2020-08-211-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | Glusterfs so far constrained itself with an arbitrary limit (32) for the number of groups read from /proc/[pid]/status (this was the number of groups shown there prior to Linux commit v3.7-9553-g8d238027b87e (v3.8-rc1~74^2~59); since this commit, all groups are shown). With this change we'll read groups up to the number Glusterfs supports in general (64k). Note: the actual number of groups that are made use of in a regular Glusterfs setup shall still be capped at ~93 due to limitations of the RPC transport. To be able to handle more groups than that, brick side gid resolution (server.manage-gids option) can be used along with NIS, LDAP or other such networked directory service (see https://github.com/gluster/glusterdocs/blob/5ba15a2/docs/Administrator%20Guide/Handling-of-users-with-many-groups.md#limit-in-the-glusterfs-protocol ). Also adding some diagnostic messages to frame_fill_groups(). Change-Id: I271f3dc3e6d3c44d6d989c7a2073ea5f16c26ee0 fixes: #1075 Signed-off-by: Csaba Henk <csaba@redhat.com>
* libglusterfs: add functions to calculate time differenceDmitry Antipov2020-08-212-2/+33
| | | | | | | | | | Add gf_tvdiff() and gf_tsdiff() to calculate the difference between 'struct timeval' and 'struct timespec' values, use them where appropriate. Change-Id: I172be06ee84e99a1da76847c15e5ea3fbc059338 Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru> Updates: #1002
* posix: Implement a janitor thread to close fdMohit Agrawal2020-08-201-0/+7
| | | | | | | | | | | | | | Problem: In the commit fb20713b380e1df8d7f9e9df96563be2f9144fd6 we use syntask to close fd but we have found the patch is reducing the performance Solution: Use janitor thread to close fd's and save the pfd ctx into ctx janitor list and also save the posix_xlator into pfd object to avoid the race condition during cleanup in brick_mux environment Change-Id: Ifb3d18a854b267333a3a9e39845bfefb83fbc092 Fixes: #1396 Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
* dict: Remove redundant checksSheetal Pamecha2020-08-202-41/+30
| | | | | | fixes: #1428 Change-Id: I0cb1c42d620ac1aeab8da25a2e1d7835219d2e4a Signed-off-by: Sheetal Pamecha <spamecha@redhat.com>
* Remove need for /proc on FreeBSDDaniel Morante2020-08-204-1/+41
| | | | | Change-Id: Ieebd9a54307813954011ac8833824831dce6da10 Fixes: #1376
* libglusterfs: cleanup --disable-mempoolDmitry Antipov2020-08-193-121/+130
| | | | | | | | | Use trivial no-op mempool if configured with --disable-mempool. Cleanup OLD_MEM_POOLS leftovers, adjust related statedumps. Change-Id: Ibaa90e538a34f6dcd216e45c05dd32d955b151f6 Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru> Fixes: #1359
* Events: Socket creation after getaddrinfo and IPv4 and IPv6 packet capturesrijan-sivakumar2020-08-191-8/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Issue: Currently, the socket creation is done prior to getaddrinfo function being invoked. This can cause mismatch in the protocol and address families of the created socket and the result of the getaddrinfo api. Also, the glustereventsd UDP server by default only captures IPv4 packets hence IPv6 packets are not even captured. Code Changes: 1. Modified the socket creation in such a way that the parameters taken in are dependent upon the result of the getaddrinfo function. 2. Created a subclass for adding address family in glustereventsd.py for both AF_INET and AF_INET6. 3. Modified addresses in the eventsapiconf.py.in Reasoning behind the approach: 1. If we are using getaddrinfo function then socket creation should happen only after we check if we received back valid addresses. Hence socket creation should come after the call to getaddrinfo 2. The listening server which pushes the events to the webhook has to listen for both IPv4 and IPv6 messages as we would not be sure as to what address family is picked in _gf_event. Fixes: #1377 Change-Id: I568dcd1a977c8832f0fef981e1f81cac7043c760 Signed-off-by: srijan-sivakumar <ssivakum@redhat.com>
* Use sysctl for get_mem_size() on FreeBSDDaniel Morante2020-08-191-1/+1
| | | | | Change-Id: Iab2600260707af02e2b8da9e489cbb12b9fc14a6 Fixes: #1376
* Add missing links to userspace RCUDaniel Morante2020-08-191-1/+2
| | | | | Change-Id: I77519eb5ffb6a4a1f51f8c60f3fdd0eb0576c4ee Fixes: #1376
* BSD: extattr_set_link and extattr_set_fd return bytes written not 0Daniel Morante2020-08-191-2/+2
| | | | | Change-Id: I120006dab4e199ad3d3f4a5ebc9c352f3c49ea7d Fixes: #1376
* glusterd: memory deallocated twicenik-redhat2020-08-182-7/+7
| | | | | | | | | | | | | | | | | | | | | Issue: If the the pointer tmptier is destroyed in the function code it still it checks for the same in the out label. And tries to destroy the same pointer again. Fix: So, instead of passing the ptr by value, if we pass it by reference then, on making the ptr in the function the value will persist, in the calling function and next time when the gf_store_iter_destory() is called it won't try to free the ptr again. CID: 1430122 Updates: #1060 Change-Id: I019cea8e301c7cc87be792c03b58722fc96f04ef Signed-off-by: nik-redhat <nladha@redhat.com>
* libglusterfs: add library wrapper for time()Dmitry Antipov2020-08-176-8/+15
| | | | | | | | | 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
* libglusterfs: annotate synctasks with ThreadSanitizer APIDmitry Antipov2020-08-112-0/+55
| | | | | | | | | | If --enable-tsan is specified and API headers are detected, annotate synctask context initialization and context switch with ThreadSanitizer API. Change-Id: I7ac4085d7ed055448f1fc80df7d59905d129f186 Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru> Fixes: #1400
* 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>
* dict: optimize dict_serialized_length_lk functionMohit Agrawal2020-07-312-39/+12
| | | | | | | | | | | | To return the length of searlized dictionary the function iterates full dictionary and access every key value member of the dictionary.Instead of iterating full dictionary introduce a variable totkvlen at dictionary to save the key value length at the time of storing key/value pair in the dictionary. Change-Id: Ie8cfdea1cc335bce51f59179281df3c89afab68b Fixes: #1395 Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
* statedump: Dump xlator-name for mem-pool objectPranith Kumar K2020-07-293-0/+3
| | | | | | Fixes: #1399 Change-Id: I11cf75a0ea9a16724f36f73feb1c90dabed25c4b Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
* libglusterfs/xlator: undefined symbol xlator_apinik-redhat2020-07-271-12/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | Issue: On executiing the command gluster vol set help, an error comes up in glusterd logs stating `undefined symbol: xlator_api`. This issue is seen for the rpc-transport/socket.so file. Fix: The symbol `xlator_api` is not found in rpc-transport/socket.so file as it is not a xlator but a shared object for transport. In the `xlator.c` file, there is a function `xlator_volopt_dynload`, which looks for the default values of the options available in gluster, which is stored inside the respective xlator files for different voltypes. In each of these files the `options` object is present which contains the default values, which is therefore referenced from the `options` data member of `xlator_api` object in case of xlators.But, since `rpc-transport/socket.so` is not an xlator we don't have the `xlator_api` object present to point to that object. So, in case of `rpc-transport/socket.so` type we are accesing the `options` object directly from the `xlator_volopt_dynload` function to fetch the default values for the available options. Fixes: #827 Change-Id: I3b2b0c1f2a11896be250aaca1a33a65b044991d5 Signed-off-by: nik-redhat <nladha@redhat.com>
* dht - fixing xattr inconsistencyBarak Sason Rofman2020-07-223-0/+23
| | | | | | | | | | | | | | | | | 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>
* glusterfs.h: add IS_ERROR() and IS_SUCCESS() macroAmar Tumballi2020-07-211-1/+4
| | | | | | | | | | These macros helps to clearly identify all negetive checks are 'errors', and all 0 and above are success. With this clasification, we can add more error codes to the process / method / function. Updates: #280 Change-Id: I0ebc5c4ad41eb78e4f2c1b98648986be62e7b521 Signed-off-by: Amar Tumballi <amar@kadalu.io>
* libglusterfs: fix warnings issued with gcc-10 -Wtype-limitsDmitry Antipov2020-07-191-65/+94
| | | | | | | | | | | | | dict.c:1129:16: warning: comparison is always false due to limited range of data type [-Wtype-limits] dict.c:1129:38: warning: comparison is always false due to limited range of data type [-Wtype-limits] dict.c:1151:16: warning: comparison is always false due to limited range of data type [-Wtype-limits] dict.c:1151:39: warning: comparison is always false due to limited range of data type [-Wtype-limits] Improve error checking and unify to common style as well. Change-Id: Ia4f890bfaaf4e29c8514ee7e4d824d69020b9332 Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru> Updates: #1002
* glusterd - fixing coverity issuesBarak Sason Rofman2020-07-091-0/+2
| | | | | | | | | Fixing double free issues Change-Id: Ie56753196335080f32f061329644ac462998ada2 CID: 1430112, 1430122 updates: #1202 Signed-off-by: Barak Sason Rofman <bsasonro@redhat.com>
* libglusterfs, glusterd: tweak directory scanningDmitry Antipov2020-07-072-16/+12
| | | | | | | | | 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
* build: improve support for sanitizersDmitry Antipov2020-07-061-1/+1
| | | | | | | | Fix --enable-asan and --enable-tsan, add --enable-ubsan. Change-Id: Ifb3c44107ecaee4cad4bc88dd81c49c6cd691764 Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru> Fixes: #1320
* Issue with gf_fill_iatt_for_direntSoumya Koduri2020-07-031-1/+1
| | | | | | | | | | | | In "gf_fill_iatt_for_dirent()", while calculating inode_path for loc, the inode should be of parent's. Instead it is loc.inode which results in error and eventually lookup/readdirp fails. This patch fixes the same. Change-Id: Ied086234a4634e8cb13520521ac547c87b3c76b5 Fixes: #1351 Signed-off-by: Soumya Koduri <skoduri@redhat.com>
* storage/posix, libglusterfs: library function to sync filesystemDmitry Antipov2020-06-223-0/+24
| | | | | | | | 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
* rpc: fix undefined behaviour in __builtin_ctzDmitry Antipov2020-06-172-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | Found with GCC UBsan: rpcsvc.c:102:36: runtime error: passing zero to ctz(), which is not a valid argument #0 0x7fcd1ff6faa4 in rpcsvc_get_free_queue_index /path/to/glusterfs/rpc/rpc-lib/src/rpcsvc.c:102 #1 0x7fcd1ff81e12 in rpcsvc_handle_rpc_call /path/to/glusterfs/rpc/rpc-lib/src/rpcsvc.c:837 #2 0x7fcd1ff833ad in rpcsvc_notify /path/to/glusterfs/rpc/rpc-lib/src/rpcsvc.c:1000 #3 0x7fcd1ff8829d in rpc_transport_notify /path/to/glusterfs/rpc/rpc-lib/src/rpc-transport.c:520 #4 0x7fcd0dd72f16 in socket_event_poll_in_async /path/to/glusterfs/rpc/rpc-transport/socket/src/socket.c:2502 #5 0x7fcd0dd8986a in gf_async ../../../../libglusterfs/src/glusterfs/async.h:189 #6 0x7fcd0dd8986a in socket_event_poll_in /path/to/glusterfs/rpc/rpc-transport/socket/src/socket.c:2543 #7 0x7fcd0dd8986a in socket_event_handler /path/to/glusterfs/rpc/rpc-transport/socket/src/socket.c:2934 #8 0x7fcd0dd8986a in socket_event_handler /path/to/glusterfs/rpc/rpc-transport/socket/src/socket.c:2854 #9 0x7fcd2048aff7 in event_dispatch_epoll_handler /path/to/glusterfs/libglusterfs/src/event-epoll.c:640 #10 0x7fcd2048aff7 in event_dispatch_epoll_worker /path/to/glusterfs/libglusterfs/src/event-epoll.c:751 ... Fix, simplify, and prefer 'unsigned long' as underlying bitmap type. Change-Id: If3f24dfe7bef8bc7a11a679366e219a73caeb9e4 Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru> Fixes: #1283
* Indicate timezone offsets in timestampsCsaba Henk2020-06-156-94/+97
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: fix use-after-destroy mutex errorDmitry Antipov2020-06-111-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | Found with GCC ThreadSanitizer: WARNING: ThreadSanitizer: use of an invalid mutex (e.g. uninitialized or destroyed) (pid=188590) #0 pthread_mutex_lock <null> (libtsan.so.0+0x528ac) #1 client_ctx_del /path/to/glusterfs/libglusterfs/src/client_t.c:535 (libglusterfs.so.0+0xc681a) #2 client_destroy_cbk /path/to/glusterfs/xlators/protocol/server/src/server.c:944 (server.so+0xaf6e) #3 gf_client_destroy_recursive /path/to/glusterfs/libglusterfs/src/client_t.c:295 (libglusterfs.so.0+0xc5058) #4 client_destroy /path/to/glusterfs/libglusterfs/src/client_t.c:330 (libglusterfs.so.0+0xc60e4) ... Location is heap block of size 272 at 0x7b440001a180 allocated by thread T7: #0 calloc <null> (libtsan.so.0+0x3075a) #1 __gf_calloc /path/to/glusterfs/libglusterfs/src/mem-pool.c:151 (libglusterfs.so.0+0x6e42b) #2 gf_client_get /path/to/glusterfs/libglusterfs/src/client_t.c:155 (libglusterfs.so.0+0xc571a) ... The problem is that client_destroy() may call client_ctx_del() (which attempts to lock 'sratch_ctx.lock') via recursive deletion from gf_client_destroy_recursive(), so destroying mutex before entering recursive deletion is an error. It should be destroyed later - just before the client context is freed. Change-Id: I730a628714d2b404e3f019ae552403da16b51b68 Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru> Fixes: #1285
* libglusterfs: drop useless 'const' on function return typeDmitry Antipov2020-06-091-1/+1
| | | | | | | | | Using 'const' qualifier on function return type makes no effect in ISO C, as reported with -Wignored-qualifiers of gcc-10 and clang-10. Change-Id: I83de7ab4c8255284683bb462cd9f584ebf0f983b Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru> Fixes: #1249
* open-behind: rewrite of internal logicXavi Hernandez2020-06-044-0/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There was a critical flaw in the previous implementation of open-behind. When an open is done in the background, it's necessary to take a reference on the fd_t object because once we "fake" the open answer, the fd could be destroyed. However as long as there's a reference, the release function won't be called. So, if the application closes the file descriptor without having actually opened it, there will always remain at least 1 reference, causing a leak. To avoid this problem, the previous implementation didn't take a reference on the fd_t, so there were races where the fd could be destroyed while it was still in use. To fix this, I've implemented a new xlator cbk that gets called from fuse when the application closes a file descriptor. The whole logic of handling background opens have been simplified and it's more efficient now. Only if the fop needs to be delayed until an open completes, a stub is created. Otherwise no memory allocations are needed. Correctly handling the close request while the open is still pending has added a bit of complexity, but overall normal operation is simpler. Change-Id: I6376a5491368e0e1c283cc452849032636261592 Fixes: #1225 Signed-off-by: Xavi Hernandez <xhernandez@redhat.com>
* syncop: improve scaling and implement more toolsXavi Hernandez2020-05-133-75/+291
| | | | | | | | | | | | | | | | | | | | The current scaling of the syncop thread pool is not working properly and can leave some tasks in the run queue more time than necessary when the maximum number of threads is not reached. This patch provides a better scaling condition to react faster to pending work. Condition variables and sleep in the context of a synctask have also been implemented. Their purpose is to replace regular condition variables and sleeps that block synctask threads and prevent other tasks to be executed. The new features have been applied to several places in glusterd. Change-Id: Ic50b7c73c104f9e41f08101a357d30b95efccfbf Fixes: #1116 Signed-off-by: Xavi Hernandez <xhernandez@redhat.com>
* posix - fix seek functionalityBarak Sason Rofman2020-05-071-5/+6
| | | | | | | | | A wrong pointer check causes the offset returned by seek to be always wrong fixes: #1228 Change-Id: Iac4c6a163175617ac4f14544fc6b7c6fb4041cd6 Signed-off-by: Barak Sason Rofman <bsasonro@redhat.com>
* tests: skip tests on absence of reflink in xfsPranith Kumar K2020-05-061-1/+2
| | | | | | Fixes: #1223 Change-Id: I36cb72d920ffd77405051546615c5262c392daef Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
* core, cli, quota: cleanup malloc debugging and statsDmitry Antipov2020-05-041-2/+2
| | | | | | | | | | | | 1. Since mcheck()/mprobe() etc. features are no longer used, mcheck.h isn't required to be included. 2. Since mallinfo() is used to obtain malloc statistics, it should be detected instead of malloc_stats(). Change-Id: I54c7d2ee568e06ab29938efc01d1a2153c5bd5db Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru> Fixes: #1172
* core: Updated the GD_OP_VERSIONRinku Kothiya2020-04-291-1/+3
| | | | | | | fixes: #1204 Change-Id: Ied5d4d553771ff315ed3f1a7229f96733fe7ed00 Signed-off-by: Rinku Kothiya <rkothiya@redhat.com>
* Posix: Optimize posix code to improve file creationMohit Agrawal2020-04-063-0/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | Problem: Before executing a fop in POSIX xlator it builds an internal path based on GFID.To validate the path it call's (l)stat system call and while .glusterfs is heavily loaded kernel takes time to lookup inode and due to that performance drops Solution: In this patch we followed two ways to improve the performance. 1) Keep open fd specific to first level directory(gfid[0]) in .glusterfs, it would force to kernel keep the inodes from all those files in cache. In case of memory pressure kernel won't uncache first level inodes. We need to open 256 fd's per brick to access the entry faster. 2) Use at based call's to access relative path to reduce path based lookup time. Note: To verify the patch we have executed kernel untar 100 times on 6 different clients after enabling metadata group-cache and some other option.We were getting more than 20 percent improvement in kenel untar after applying the patch. Credits: Xavi Hernandez <xhernandez@redhat.com> Change-Id: I1643e6b01ed669b2bb148d02f4e6a8e08da45343 updates: #891 Signed-off-by: Mohit Agrawal <moagrawal@redhat.com>
* core[brick_mux]: brick crashed when creating and deleting volumes over timeMohit Agrawal2020-03-271-8/+26
| | | | | | | | | | | | | | | | | Problem: In brick_mux environment, while volumes are created/stopped in a loop after running a long time the main brick is crashed.The brick is crashed because the main brick process was not cleaned up memory for all objects at the time of detaching a volume. Below are the objects that are missed at the time of detaching a volume 1) xlator object for a brick graph 2) local_pool for posix_lock xlator 3) rpc object cleanup at quota xlator 4) inode leak at brick xlator Solution: To avoid the crash resolve all leak at the time of detaching a brick Change-Id: Ibb6e46c5fba22b9441a88cbaf6b3278823235913 updates: #977 Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
* Posix: Use simple approach to close fdMohit Agrawal2020-03-202-11/+2
| | | | | | | | | | | | | | | Problem: posix_release(dir) functions add the fd's into a ctx->janitor_fds and janitor thread closes the fd's.In brick_mux environment it is difficult to handle race condition in janitor threads because brick spawns a single janitor thread for all bricks. Solution: Use synctask to execute posix_release(dir) functions instead of using background a thread to close fds. Credits: Pranith Karampuri <pkarampu@redhat.com> Change-Id: Iffb031f0695a7da83d5a2f6bac8863dad225317e Fixes: bz#1811631 Signed-off-by: Mohit Agrawal <moagrawal@redhat.com>
* utime: resolve an issue of permission denied logsAmar Tumballi2020-03-131-1/+2
| | | | | | | | | | | | In case where uid is not set to be 0, there are possible errors from acl xlator. So, set `uid = 0;` with pid indicating this is set from UTIME activity. The message "E [MSGID: 148002] [utime.c:146:gf_utime_set_mdata_setxattr_cbk] 0-dev_SNIP_data-utime: dict set of key for set-ctime-mdata failed [Permission denied]" repeated 2 times between [2019-12-19 21:27:55.042634] and [2019-12-19 21:27:55.047887] Change-Id: Ieadf329835a40a13ac0bf908dac776e66954466c Fixes: #832 Signed-off-by: Amar Tumballi <amar@kadalu.io>
* Segmentation fault occurs during truncatekinsu2020-02-241-0/+8
| | | | | | | | | | | | | | | | | | | | Problem: Segmentation fault occurs when bricks are nearly full 100% and in parallel truncate of a file is attempted (No space left on device). Prerequicite is that performance xlators are activated (read-ahead, write-behind etc) while stack unwind of the frames following an error responce from brick (No space left on device) frame->local includes a memory location that is not allocated via mem_get but via calloc. The destroyed frame is always ra_truncate_cbk winded from ra_ftruncate and the inode ptr is copied to the frame local in the wb_ftruncate. Fix: extra check is added for the pool ptr Change-Id: Ic5d3bd0ab7011e40b2811c6dece063b256e4d9d1 Fixes: bz#1797882 Signed-off-by: kinsu <vpolakis@gmail.com>
* core: Prevent crash on process terminationXavi Hernandez2020-02-191-19/+11
| | | | | | | | | | | | | | | A previous patch (ce61da816a) has fixed a use-after-free issue, but it doesn't work well when the final cleanup is done at process termination because gluster doesn't stop other threads before calling exit(). For this reason, the final cleanup is removed to avoid the crash, at least until the termination sequence properly stops all gluster threads before exiting the program. Change-Id: Id7cfb4407fcf208e28f03a7c3cdc3ef9c1f3bf9b Fixes: bz#1801684 Signed-off-by: Xavi Hernandez <xhernandez@redhat.com>
* core: fix memory pool management racesXavi Hernandez2020-02-185-106/+146
| | | | | | | | | | | | | | | | | | | | | | Objects allocated from a per-thread memory pool keep a reference to it to be able to return the object to the pool when not used anymore. The object holding this reference can have a long life cycle that could survive a glfs_fini() call. This means that it's unsafe to destroy memory pools from glfs_fini(). Another side effect of destroying memory pools from glfs_fini() is that the TLS variable that points to one of those pools cannot be reset for all alive threads. This means that any attempt to allocate memory from those threads will access already free'd memory, which is very dangerous. To fix these issues, mem_pools_fini() doesn't destroy pool lists anymore. Only at process termination the pools are destroyed. Change-Id: Ib189a5510ab6bdac78983c6c65a022e9634b0965 Fixes: bz#1801684 Signed-off-by: Xavi Hernandez <xhernandez@redhat.com>
* libglusterfs-xlator: structure loggingyatipadia2020-02-144-135/+141
| | | | | | | | convert all gf_msg() to gf_smsg() Change-Id: Id542e05faadb8041b472a2298c71fe62730e65fc Updates: #657 Signed-off-by: yatipadia <ypadia@redhat.com>
* volgen: make thin-arbiter name unique in 'pending-xattr' optionAmar Tumballi2020-02-121-0/+1
| | | | | | | | | | Thin-arbiter module makes use of 'pending-xattr' name for the translator as the filename which gets created in thin-arbiter node. By making this unique, we can host single thin-arbiter node for multiple clusters. Updates: #763 Change-Id: Ib3c732e7e04e6dba229e71ae3e64f1f3cb6d794d Signed-off-by: Amar Tumballi <amar@kadalu.io>
* libglusterfs-options: structure loggingyatipadia2020-02-093-82/+100
| | | | | | | | convert all gf_msg() to gf_smsg() Change-Id: I8f1ff462b9c8012ed676c51450930a65ac403bf3 Updates: #657 Signed-off-by: yatipadia <ypadia@redhat.com>