summaryrefslogtreecommitdiffstats
path: root/api/src/glfs-handleops.c
Commit message (Collapse)AuthorAgeFilesLines
* api: libgfapi symbol versions break LTO in Fedora rawhide/f33Kaleb S. KEITHLEY2020-07-031-64/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The way symbol versions are implemented is incompatible with gcc-10 and LTO. Fedora provenpackager Jeff Law (law [at] redhat.com) writes in the Fedora dist-git glusterfs.spec: This package uses top level ASM constructs which are incompatible with LTO. Top level ASMs are often used to implement symbol versioning. gcc-10 introduces a new mechanism for symbol versioning which works with LTO. Converting packages to use that mechanism instead of toplevel ASMs is recommended. In particular, note that the version of gluster in Fedora rawhide/f33 is glusterfs-8.0RC0. Once this fix is merged it will be necessary to backport it to the release-8 branch. At the time that gfapi symbol versions were first implemented we copied the GNU libc (glibc) symbol version implementation following Uli Drepper's symbol versioning HOWTO. Now gcc-10 has a symver attribute that can be used instead. (Maybe it has been there all along?) Both the original implemenation and this implemenation yield the same symbol versions. This can be seen by running `nm -D --with-symbol-versions libgfapi.so` on the libgfapi.so built before and after applying this fix. Change-Id: I05fda580afacfff1bfc07be810dd1afc08a92fb8 Fixes: #1352 Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
* api-glfs-fops: structure loggingyatipadia2020-01-141-20/+18
| | | | | | | | Convert gf_msg() to gf_smsg() Change-Id: Iceb40d60a75106c7b4b0a2487b611f7376bccc46 Updates: #657 Signed-off-by: yatipadia <ypadia@redhat.com>
* gfapi: Update the version of 'glfs_h_creat_open'Soumya Koduri2019-09-271-1/+1
| | | | | | Change-Id: I43eaa53a7b8d876640d225e011b56192bba57eed Fixes: bz#1753569 Signed-off-by: Soumya Koduri <skoduri@redhat.com>
* gfapi: 'glfs_h_creat_open' - new API to create handle and open fdSoumya Koduri2019-09-251-0/+135
| | | | | | | | | | | | | | | | | Right now we have two separate APIs, one - 'glfs_h_creat_handle' to create handle & another - 'glfs_h_open' to create a glfd to return to application Having two separate routines can result in access errors while trying to create and write into a read-only file. Since a fd is opened even during file/directory creation, introducing a new API to make these two operations atomic i.e, which can create both handle & fd and pass them to application Change-Id: Ibf513fcfcdad175f4d7eb6fa7a61b8feec6d33b5 Fixes: bz#1753569 Signed-off-by: Soumya Koduri <skoduri@redhat.com>
* across: clang-scan: fix NULL dereferencing warningsAmar Tumballi2019-06-041-1/+1
| | | | | | | | | All these checks are done after analyzing clang-scan report produced by the CI job @ https://build.gluster.org/job/clang-scan updates: bz#1622665 Change-Id: I590305af4ceb779be952974b2a36066ffc4865ca Signed-off-by: Amar Tumballi <amarts@redhat.com>
* gfapi : making glfs_setattr/glfs_fsetattr as publicArjun2019-01-161-1/+1
| | | | | | | | | | Initially glfs_fsetattr and glfs_setattr, both functions accepted iatt as arguements but now they accept stat and later in the function the stat is being converted to iatt so that it can be passed to syncop_fsetattr/syncop_setattr. Change-Id: I41a9e0124785a32ca19ef4d492c5ed5002e66ede updates: #389 Signed-off-by: Arjun Sharma <arjsharm@redhat.com>
* libglusterfs: Move devel headers under glusterfs directoryShyamsundarR2018-12-051-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* gfapi: Send fop_attr dict as part of syncop_openSoumya Koduri2018-11-171-1/+1
| | | | | | | | | | Leaseid (stored in thread locals) is sent to server via xdata. This dict variable is set but not passed as argument in glfs_h_open(). Fixed the same. Change-Id: Idd2f8a0ec184b4b6b1ad1e6e5d75df551c36a96d updates: bz#1648768 Signed-off-by: Soumya Koduri <skoduri@redhat.com>
* Land part 2 of clang-format changesGluster Ant2018-09-121-1914/+1933
| | | | | Change-Id: Ia84cc24c8924e6d22d02ac15f611c10e26db99b4 Signed-off-by: Nigel Babu <nigelb@redhat.com>
* gfapi: Use inode_forget in case of unlink/rename objectsKinglong Mee2018-08-211-1/+6
| | | | | | | | | After unlink/rename, the nonexistent inode should be remove from inode table, that's better than put to lru list. Change-Id: I5a40df188f3f42a2c864cfb4404b22b288fdcc12 fixes: bz#1612750 Signed-off-by: Kinglong Mee <mijinlong@open-fs.com>
* All: run codespell on the code and fix issues.Yaniv Kaul2018-07-221-4/+4
| | | | | | | | | | | | 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>
* api: cleanup headersKaleb S. KEITHLEY2018-06-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | fix inconsistent use in headers of: struct glfs and glfs_t struct glfs_fd and glfs_fd_t struct glfs_object and glfs_object_t add typedefs to headers for various struct glfs_foos, and use them, e.g.: struct glfs_upcall and glfs_upcall_t fix inconsistent type naming for 'enum glfs_lock_mode_t'. (All other enum decls are 'enum glfs_foo' not 'enum_glfs_foo_t'), and add typedefs for all enums, and use them. style, replace tabs with spaces and follow return value style, i.e.: int pub_glfs_foo() instead of: int pub_glfs_foo() Update copyright dates, substantial new work has been done since 2012 Change-Id: I0a9654486ea132efde7977b655799fb37887b1d5 Updates: bz#1193929 Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
* gfapi : RECALL_LEASE implementationSoumya Koduri2018-05-041-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* libgfapi: skip nameless lookup if stat is NULLKinglong Mee2018-02-081-2/+3
| | | | | Change-Id: If0ad17be2f7d7f88df25966aaf67af963ff4fc41 Signed-off-by: Kinglong Mee <mijinlong@open-fs.com>
* gfapi : New APIs have been added to use lease feature in glusterSoumya Koduri2018-01-261-6/+62
| | | | | | | | | | | Following APIs glfs_h_lease(), glfs_lease() added, so that gfapi applications can set and get lease which enables more efficient client side caching. Updates: #350 Change-Id: Iede85be9af1d4df969b890d0937ed0afa4ca6596 Signed-off-by: Poornima G <pgurusid@redhat.com> Signed-off-by: Soumya Koduri <skoduri@redhat.com> Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com>
* core: fix some of the dict_{get,set} with proper APIsAmar Tumballi2018-01-171-4/+4
| | | | | | | updates #220 Change-Id: I6e25dbb69b2c7021e00073e8f025d212db7de0be Signed-off-by: Amar Tumballi <amarts@redhat.com>
* gfapi: avoid nameless lookup when inode_find successKinglong Mee2017-11-281-2/+22
| | | | | | | | Ganesha calls pub_glfs_h_create_from_handle always with stat != NULL, for inode_find success, a nameless lookup seems unnecessary. Change-Id: I1242deefe8ff4af15a98cc3af7824233e24d62ad Signed-off-by: Kinglong Mee <mijinlong@open-fs.com>
* gfapi: Register/Unregister Upcall events' callbackSoumya Koduri2017-10-311-1/+1
| | | | | | | | | | | | | | | | | Polling continuously for upcall events is not optimal. Hence new APIs have been added to allow applications to register and unregister upcall events it is interested in along with callback function to be invoked in case of any such upcalls sent by backend server. @TODO: Make changes in upcall xlator so that events are sent to only those clients which either registered callbacks or started polling. Shall be addressed in separate patch. Updates: #315 Change-Id: I40473fd5cf689172ff2d7bb2869756b7fd5bc761 Signed-off-by: Soumya Koduri <skoduri@redhat.com>
* gfapi: adds a glfs_mem_header for exported memoryKinglong Mee2017-09-011-3/+12
| | | | | | | | | | | | | | | | | | glfs_free releases different types of data depends on memory type. Drop the depends of memory type of memory accounting, new macro GLFS_CALLOC/GLFS_MALLOC/GLFS_REALLOC/GLFS_FREE are added to support assign release function dynamically, it adds a separate memory header named glfs_mem_header for gfapi. Updates: #312 Change-Id: Ie608e5227cbaa05d3f4681a515e83a50d5b17c3f Signed-off-by: Kinglong Mee <mijinlong@open-fs.com> Reviewed-on: https://review.gluster.org/18092 Smoke: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Niels de Vos <ndevos@redhat.com> Tested-by: Niels de Vos <ndevos@redhat.com> Reviewed-by: Jeff Darcy <jeff@pl.atyp.us> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
* gfapi: Duplicate the buffer sent in setxattr callsPoornima G2017-08-071-1/+7
| | | | | | | | | | | | | | | | | | | | | Issue: The caller of glfs_setxattr sends a buffer to set as the value. We create a dict in which the pointer to the value is set. Underlying layers like md-cache take a ref on this dict to store the value for a longer time. But the moment setxattr is complete, the caller of glfs_setxattr can free the value memory. Solution: memcpy the setxattr value to the gluster buffer. Change-Id: I58753fe702e8b7d0f6c4f058714c65d0ad5d7a0a BUG: 1477488 Signed-off-by: Poornima G <pgurusid@redhat.com> Reviewed-on: https://review.gluster.org/17967 Reviewed-by: soumya k <skoduri@redhat.com> Smoke: Gluster Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Jeff Darcy <jeff@pl.atyp.us>
* gfapi: Fix few severe coverity issuesSoumya Koduri2017-05-051-0/+1
| | | | | | | | | | | | | | | From https://download.gluster.org/pub/gluster/glusterfs/static-analysis/master/glusterfs-coverity/2017-05-03-6484558c/html/ fixes coverity#189, 248, 250, 488, 546 Change-Id: I7c4aa5bf6c367344602748dfd736de27f341cca2 BUG: 789278 Signed-off-by: Soumya Koduri <skoduri@redhat.com> Reviewed-on: https://review.gluster.org/17161 Smoke: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Niels de Vos <ndevos@redhat.com> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: Amar Tumballi <amarts@redhat.com> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
* gfapi/handleops: Introducing glfs_xreaddirplus_r() fop for handleopsSoumya Koduri2017-05-021-0/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Its known that readdirplus operation fetches stat as well for each of the dirents. But often applications may need extra information, like for eg., NFS-Ganesha which operates on handles needs handles for each of those dirents returned. So this would require extra calls to the backend, in this case LOOKUP (which is very expensive operation) resulting in very low readdir performance. To address that introducing this new API using which applications can make request for any extra information to be returned as part of readdirplus response. Currently this new api returns stat and handles as demanded by application. The synopsis of the API is noted in glfs.h. @todo: * Enhance test script using this new API Below were the perf results on single brick volume with and without these changes - Dataset used - 10*100 directories and each directory containing 100 empty files. I used NFS-Ganesha application to test these changes - >for i in {1..5}; do systemctl restart nfs-ganesha; sleep 10; mount -t nfs -o vers=4 localhost:/brick_vol /mnt; cd /mnt; echo "ITERATION$i"; date; find . > tmp-nfs.log; date; cd /; umount /mnt; sleep 2; done; Without these changes - ITERATION1 Mon Mar 20 17:22:26 IST 2017 Mon Mar 20 17:23:18 IST 2017 ITERATION2 Mon Mar 20 17:23:39 IST 2017 Mon Mar 20 17:24:28 IST 2017 ITERATION3 Mon Mar 20 17:24:49 IST 2017 Mon Mar 20 17:25:36 IST 2017 ITERATION4 Mon Mar 20 17:30:57 IST 2017 Mon Mar 20 17:31:37 IST 2017 ITERATION5 Mon Mar 20 17:31:57 IST 2017 Mon Mar 20 17:32:40 IST 2017 [root@dhcp35-197 /]# On an average ~46.2 sec With these changes applied - ITERATION1 Mon Mar 20 17:35:03 IST 2017 Mon Mar 20 17:35:15 IST 2017 ITERATION2 Mon Mar 20 17:35:36 IST 2017 Mon Mar 20 17:35:46 IST 2017 ITERATION3 Mon Mar 20 17:36:06 IST 2017 Mon Mar 20 17:36:17 IST 2017 ITERATION4 Mon Mar 20 17:41:38 IST 2017 Mon Mar 20 17:41:49 IST 2017 ITERATION5 Mon Mar 20 17:42:10 IST 2017 Mon Mar 20 17:42:20 IST 2017 On an average ~10.8 sec Updates #174 BUG: 1442950 Change-Id: I0f74f74dc62085ca4c4a23c38e3edc84bd850876 Signed-off-by: Soumya Koduri <skoduri@redhat.com> Reviewed-on: https://review.gluster.org/15663 Smoke: Gluster Build System <jenkins@build.gluster.org> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: Niels de Vos <ndevos@redhat.com> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
* api: fix bad release of dict causes memory leakKinglong Mee2017-04-251-2/+4
| | | | | | | | | | | | | Change-Id: Ic7169fd05aff7bf46108e8ac7b1f29688a7f2358 Signed-off-by: Kinglong Mee <mijinlong@open-fs.com> Reviewed-on: https://review.gluster.org/17092 Tested-by: Poornima G <pgurusid@redhat.com> Reviewed-by: Poornima G <pgurusid@redhat.com> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Prashanth Pai <ppai@redhat.com> Smoke: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Amar Tumballi <amarts@redhat.com>
* gfapi: redesign the public interface for upcall consumersNiels de Vos2016-09-281-60/+166
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The glfs_callback_arg and glfs_callback_inode_arg were allocated by gfapi, and expected to be free()'d by the application. However it is not reasonable to expect that applications use the same memory allocator to as the compiled libgfapi.so. For instance, it is possible that gfapi uses glibc malloc/free, and an application like NFS-Ganesha the versions from jemalloc. Mismatching of the malloc() and free() functions causes segmentation faults at best. In order to prevent problems like this in the future, the API for applications that consume upcalls has been remodeled. Any of the structures that gfapi allocates, should be free'd with glfs_free(). The members of the structures can not be accessed directly anymore, each has its own function to access now. Correcting the naming of the functions, structures and constants is a continuation of commit 2775dc64101ed37c8d9809bf9852dbf0746ee2b6. These new improvements not only have correct prefixes for the functions and structures, the naming also reflects more to the upcall framework and does not use "callback" anymore. Change-Id: I2b8bd5a0a82036d2abea1a217f5e5975a1d4fe93 BUG: 1344714 Signed-off-by: Niels de Vos <ndevos@redhat.com> Reviewed-on: http://review.gluster.org/14701 Smoke: Gluster Build System <jenkins@build.gluster.org> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com> Reviewed-by: soumya k <skoduri@redhat.com> Reviewed-by: jiffin tony Thottan <jthottan@redhat.com>
* gfapi: do not cache upcalls if the application is not interestedNiels de Vos2016-08-251-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When the volume option 'features.cache-invalidation' is enabled, upcall events are sent from the brick process to the client. Even if the client is not interested in upcall events itself, md-cache or other xlators may benefit from them. By adding a new 'cache_upcalls' boolean in the 'struct glfs', we can enable the caching of upcalls when the application called glfs_h_poll_upcall(). NFS-Ganesha sets up a thread for handling upcalls in the initialization phase, and calls glfs_h_poll_upcall() before any NFS-client accesses the NFS-export. In the future there will be a more flexible registration API for enabling certain kind of upcall events. Until that is available, this should work just fine. Verificatio of this change is not trivial within our current regression test framework. The bug report contains a description on how to reliably reproduce the problem with the glusterfs-coreutils. Change-Id: I818595c92db50e6e48f7bfe287ee05103a4a30a2 BUG: 1368842 Signed-off-by: Niels de Vos <ndevos@redhat.com> Reviewed-on: http://review.gluster.org/15191 Smoke: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Poornima G <pgurusid@redhat.com> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: soumya k <skoduri@redhat.com> Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
* gfapi/upcall: Fix a ref leakSoumya Koduri2016-07-241-0/+4
| | | | | | | | | | | | | | | | inode_find (used to create the handle) takes a reference of the inode. This needs to be un'refernced to avoid leak. Change-Id: I22f03577a8f1d9608cfc62d57202cfc4c2ba12b3 BUG: 1358608 Signed-off-by: Soumya Koduri <skoduri@redhat.com> Reviewed-on: http://review.gluster.org/14984 Reviewed-by: jiffin tony Thottan <jthottan@redhat.com> Smoke: Gluster Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Jeff Darcy <jdarcy@redhat.com> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> Tested-by: Gluster Build System <jenkins@build.gluster.org>
* glfs/upcall: entries should be removed under mutex lockSoumya Koduri2016-07-221-1/+1
| | | | | | | | | | | | | | | | | | | | During poll, upcall entries should be removed from the upcall_list only under upcall_list_mutex lock. Otherwise it could result in the list corruption if there are entries being added during poll resulting in memory leak. Also addressed a probable leak during any failures with upcall entry addition. Change-Id: I468183f961eb6faed9a0a1bcb783705f711641fc BUG: 1358608 Signed-off-by: Soumya Koduri <skoduri@redhat.com> Reviewed-on: http://review.gluster.org/14972 Smoke: Gluster Build System <jenkins@build.gluster.org> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Jeff Darcy <jdarcy@redhat.com>
* gfapi/handleops: Avoid using glfd during createSoumya Koduri2016-06-281-23/+9
| | | | | | | | | | | | | | | | | To avoid leaking glfd while creating a file using handleops and since application shall not be interested in it, use the 'fd' object directly which can be un'refed post create. Change-Id: I119874ffb63fb4aa18f846ba1fdbe77874b66a54 BUG: 1339553 Signed-off-by: Soumya Koduri <skoduri@redhat.com> Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com> Reviewed-on: http://review.gluster.org/14532 NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: Niels de Vos <ndevos@redhat.com> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Tested-by: Gluster Build System <jenkins@build.gluster.org> Smoke: Gluster Build System <jenkins@build.gluster.org>
* libgfapi/upcall : prepend "glfs_" to callback_arg, callback_inode_argJiffin Tony Thottan2016-06-101-6/+6
| | | | | | | | | | | | Change-Id: I371525775db4f6a4d69beb94baaa53d17b16fb41 BUG: 1344714 Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com> Reviewed-on: http://review.gluster.org/14702 CentOS-regression: Gluster Build System <jenkins@build.gluster.com> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: Jeff Darcy <jdarcy@redhat.com> Tested-by: Jeff Darcy <jdarcy@redhat.com> Smoke: Gluster Build System <jenkins@build.gluster.com>
* gfapi/upcall : remove unused variable ret in glfs_h_find_handleJiffin Tony Thottan2016-05-311-2/+0
| | | | | | | | | | | | | | | | | | The variable ret is declared in glfs_h_find_handle(), but never used. So while compiling following warning message will be printed. glfs-handleops.c: In function ‘glfs_h_find_handle’: glfs-handleops.c:1813:29: warning: variable ‘ret’ set but not used [-Wunused-but-set-variable] int ret = -1; ^ Change-Id: I599b7a4e87184aacd6c937e946defd4e270509c4 BUG: 1341007 Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com> Reviewed-on: http://review.gluster.org/14524 Smoke: Gluster Build System <jenkins@build.gluster.com> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Niels de Vos <ndevos@redhat.com>
* gfapi/upcall: Use GF_CALLOC while allocating variablesSoumya Koduri2016-05-241-1/+2
| | | | | | | | | | | | | | | | | In 'glfs_h_poll_cache_invalidation', use GF_CALLOC to allocate 'up_inode_arg' to set memory accounting which is used/referred when freeing the same variable in case of any erros. Change-Id: I365e114fa6d7abb292dacb6fc702128d046df8f8 BUG: 1339214 Signed-off-by: Soumya Koduri <skoduri@redhat.com> Reviewed-on: http://review.gluster.org/14521 Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com> Reviewed-by: jiffin tony Thottan <jthottan@redhat.com> Smoke: Gluster Build System <jenkins@build.gluster.com> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: Niels de Vos <ndevos@redhat.com> CentOS-regression: Gluster Build System <jenkins@build.gluster.com>
* libglusterfs/gfapi: set appropriate errno for inode_link failuresSoumya Koduri2016-05-101-5/+3
| | | | | | | | | | | | | | | | | | We do not seem to be setting errno appropriately in case of inode_link failures. This errno may be used by any application (for eg., nfs-ganesha) to determine the error encountered. This patch addresses the same. Change-Id: I674f747c73369d0597a9c463e6ea4c85b9091355 BUG: 1334621 Signed-off-by: Soumya Koduri <skoduri@redhat.com> Reviewed-on: http://review.gluster.org/14278 Smoke: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Niels de Vos <ndevos@redhat.com> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: jiffin tony Thottan <jthottan@redhat.com> Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com> CentOS-regression: Gluster Build System <jenkins@build.gluster.com>
* gfapi/upcall: Ignore handle create failuresSoumya Koduri2016-05-021-24/+118
| | | | | | | | | | | | | | | | | | | | | | | | | In "glfs_h_poll_cache_invalidation", we need to send upcall only if there is a corresponding inode entry in the gfapi inode table for that handle. That's because the application will have reference to the inode as long as it operates on any handle. That means the only case in which we cannot find inode is when the application has closed the handle (either as part of unlink or for any other purpose). But since it will have no more references and will not be interested in any upcall event for that handle, we can safely ignore such cases. Note: This will affect only that particular applicaiton process/local libgfapi client. Change-Id: I9499cd9c284350d4a271e58f2a0966db65a7a61c BUG: 1331969 Signed-off-by: Soumya Koduri <skoduri@redhat.com> Reviewed-on: http://review.gluster.org/14132 Smoke: Gluster Build System <jenkins@build.gluster.com> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: jiffin tony Thottan <jthottan@redhat.com> CentOS-regression: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
* gfapi: Use inode_forget in case of handle objectsSoumya Koduri2016-02-231-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently with gfapi, even if applications release their reference on paritular inode entries, those entries never get destroyed as they shall always have positive nlookup count unless inode_table exceeds lru limit. Since inodes and their contexts can consume considerable amount of memory, applications may end up consuming lot of memory and may even get OOM killed. To avoid that, have considered below approaches (for handle based access)- a) Do 'inode_lookup' only if the corresponding inode is created for the first time and forget it during close of the handle This shall not work as multiple handle objects can refer to same inode entry and inode_forget from second handle object onwards shall result in assert. b) Do 'inode_lookup' during a handle or fd creation But this approach shall affect the performance of the fops which operate on neither handle nor fd. c) current approach taken- Applications using glfs handle objects hold a reference on corresponding inode entries. Hence it is safe to forget those inodes and make nlookup count to '0' while trying to delete those handle objects. That way the last unref (i.e, from the last handle close) shall result in inode_destroy(). Change-Id: Id2c7ab178894a10c0030c143ba71e7813df8d18c Signed-off-by: Soumya Koduri <skoduri@redhat.com> BUG: 1295107 Reviewed-on: http://review.gluster.org/13096 Reviewed-by: jiffin tony Thottan <jthottan@redhat.com> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: Niels de Vos <ndevos@redhat.com> CentOS-regression: Gluster Build System <jenkins@build.gluster.com> Smoke: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
* gfapi : fixing listxattr call for handle opsJiffin Tony Thottan2016-02-231-11/+15
| | | | | | | | | | | | | | | Currently listxattr is called as part of glfs_h_getxattrs() when NULL is passed to name field, but glfs_h_getxattrs_common() inside it will error out if name is NULL. Therefore listxattr is broken for handle ops. Change-Id: I9ced6e33525e1e1a50298972e4922c954fc2b223 BUG: 1310620 Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com> Reviewed-on: http://review.gluster.org/13482 Reviewed-by: Niels de Vos <ndevos@redhat.com> Smoke: Gluster Build System <jenkins@build.gluster.com> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.com>
* libgfapi: glfd close is not correctly handled for async fopRajesh Joseph2016-02-101-5/+10
| | | | | | | | | | | | | | | | | | | | | | | There is chance that before the async fop is complete client can send a close. libgfapi destroys glfd on close. Therefore it can lead to crash or unexpected behaviour when the pening fop reaches libgfapi layer. Currently we don't provide any api to cancel these outstanding fops neither we check if the glfd is already closed or not. Therefore as a fix provided refcount for glfd. Each fop (sync or async) will take a ref and once the fop is complete it will unref the refcount. We should not call the registered callback function if glfd is already closed. To achieve this we maintain state of glfd so that we can safely take a call if the fd is closed or not. Change-Id: Ibe71b2225312db3f1be66b244fcf8826c70c357d BUG: 1303995 Signed-off-by: Rajesh Joseph <rjoseph@redhat.com> Reviewed-on: http://review.gluster.org/13340 Smoke: Gluster Build System <jenkins@build.gluster.com> CentOS-regression: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
* gfapi: send lookup if inode_ctx is not setMohammed Rafi KC2016-01-131-2/+6
| | | | | | | | | | | | | | | | | | | | | During resolving of an entry or inode, if inode ctx was not set, we will send a lookup to pupulate inode ctx for every xlators This patch also make sure that inode_ctx will be created after every inode_link. We will store inode_ctx value as LOOKUP_NEEDED if the inode is liked via readdirp, in all other case we will store inode_ctx value as LOOKUP_NOT_NEEDED. Change-Id: I3a10c298944200fa3862127187ae8988e582d352 BUG: 1297311 Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com> Reviewed-on: http://review.gluster.org/13226 Reviewed-by: Poornima G <pgurusid@redhat.com> Tested-by: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com> Reviewed-by: Dan Lambright <dlambrig@redhat.com> Tested-by: Dan Lambright <dlambrig@redhat.com>
* Upcall: Read gfid from iatt in case of invalid inodeSoumya Koduri2015-12-011-0/+4
| | | | | | | | | | | | | | | | When any file/dir is looked upon for the first time, inode created shall be invalid till it gets linked to the inode table. In such cases, read the gfid from the iatt structure returned as part of such fops for UPCALL processing. Change-Id: Ie5eb2f3be18c34cf7ef172e126c9db5ef7a8512b BUG: 1283983 Signed-off-by: Soumya Koduri <skoduri@redhat.com> Reviewed-on: http://review.gluster.org/12773 Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com> Tested-by: NetBSD Build System <jenkins@build.gluster.org> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Niels de Vos <ndevos@redhat.com>
* gfapi: xattr key length check to avoid brick crashMilind Changire2015-10-091-0/+20
| | | | | | | | | | | | | | | | | | | Added check to test if xattr key length > max allowed for OS distribution and return: EINVAL if xattr name pointer is NULL or 0 length ENAMETOOLONG if xattr name length > max allowed for distribution Typically the VFS does this in the kernel for us. But since we are bypassing the VFS by providing the libgfapi to talk directly to the brick process, we need to add such checks. Change-Id: I610a8440871200ae4640351902b752777a3ec0c2 BUG: 1263056 Signed-off-by: Milind Changire <mchangir@redhat.com> Reviewed-on: http://review.gluster.org/12207 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Niels de Vos <ndevos@redhat.com> Tested-by: NetBSD Build System <jenkins@build.gluster.org>
* libgfapi : port missing gf_log's to gf_msgManikandan Selvaganesh2015-08-311-4/+4
| | | | | | | | | | | | Change-Id: I0c5320c09b4a5ff1e9df61a86ac7bd47c1bb1bbb BUG: 1252807 Signed-off-by: Manikandan Selvaganesh <mselvaga@redhat.com> Reviewed-on: http://review.gluster.org/11891 Tested-by: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: Raghavendra Talur <rtalur@redhat.com> Reviewed-by: jiffin tony Thottan <jthottan@redhat.com> Reviewed-by: Humble Devassy Chirammal <humble.devassy@gmail.com> Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
* libgfapi: adding 'follow' flag to glfs_h_lookupat()Jiffin Tony Thottan2015-08-241-3/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously glfs_h_lookupat won't follow the symlink, this patch introduces new flag `follow` which will resolve the same. Applications linking against the new library will need to use the new glfs_h_lookupat API call. In order to stay compatible with existing binaries that use the previous glfs_h_lookupat() function, the old symbol needs to stay available. Verification that there are two versions of glfs_h_lookupat: $ objdump -T /usr/lib64/libgfapi.so.0 | grep -w glfs_h_lookupat 0000000000015070 g DF .text 000000000000021e GFAPI_3.7.4 glfs_h_lookupat 0000000000015290 g DF .text 0000000000000008 (GFAPI_3.4.2) glfs_h_lookupat Testing with a binary (based on anonymous_fd_read_write.c from ./tests/) that was linked against the old library: $ objdump -T ./lookupat | grep -w glfs_h_lookupat 0000000000000000 DF *UND* 0000000000000000 GFAPI_3.4.2 glfs_h_lookupat Enable debugging for 'ld.so' so that we can check that the GFAPI_3.4.2 version of the symbol gets loaded: $ export LD_DEBUG_OUTPUT=lookupat.ld.log LD_DEBUG=all $ ./lookupat $ grep -w glfs_h_lookupat lookupat.ld.log.2543 2543: symbol=glfs_h_lookupat; lookup in file=./lookupat [0] 2543: symbol=glfs_h_lookupat; lookup in file=/lib64/libgfapi.so.0 [0] 2543: binding file ./lookupat [0] to /lib64/libgfapi.so.0 [0]: normal symbol `glfs_h_lookupat' [GFAPI_3.4.2] Change-Id: I8bf9b1c19a0585f681bc1a7f84aad1ccd0f75f6a BUG: 1252410 Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com> Signed-off-by: Niels de Vos <ndevos@redhat.com> Reviewed-on: http://review.gluster.org/11883 Reviewed-by: soumya k <skoduri@redhat.com> Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com> Tested-by: NetBSD Build System <jenkins@build.gluster.org>
* syncop: Include iatt to 'syncop_link' argsSoumya Koduri2015-07-101-3/+3
| | | | | | | | | | | | | | Include iatt to 'syncop_link' args to fetch proper attributes of the newly linked inode. Signed-off-by: Soumya Koduri <skoduri@redhat.com> Change-Id: If6b92961bd7a89add3791ed3a9b494087348b492 BUG: 1241788 Reviewed-on: http://review.gluster.org/11611 Tested-by: NetBSD Build System <jenkins@build.gluster.org> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com> Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
* gfapi: Update loc->inode accordingly in 'glfs_loc_link'Soumya Koduri2015-07-091-10/+0
| | | | | | | | | | | | | | | | In case if the inode already exits in the cache, inode_link returns the pointer to the exiting one instead of using loc->inode. This will result in issues if that invalid inodei(loc->inode) is referenced further. Fixed the same. Change-Id: I7d4a06043e4e731c8404532c47d482175dc2c277 BUG: 1240916 Signed-off-by: Soumya Koduri <skoduri@redhat.com> Reviewed-on: http://review.gluster.org/11572 Tested-by: Gluster Build System <jenkins@build.gluster.com> Tested-by: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com> Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com>
* Revert "Upcall/gfapi: Return ENOTSUP when upcall feature is disabled"Niels de Vos2015-06-281-12/+0
| | | | | | | | | | | | | | This reverts commit b68f671b2b8a0aafef8f98145aee7044edaa907d from http://review.gluster.org/11196 . The change depends on modifications to the cluster xlators, but these are still partially under review. Dropping this change now, it causes regression tests to fail. Change-Id: If5ae4a519c9c6312cdb2e2a31acce4b1901f9442 BUG: 1231132 Signed-off-by: Soumya Koduri <skoduri@redhat.com> Signed-off-by: Niels de Vos <ndevos@redhat.com> Reviewed-on: http://review.gluster.org/11452
* gfapi : symlink resolution for glfs_objectJiffin Tony Thottan2015-06-281-2/+23
| | | | | | | | | | | | | | | Generally posix expects symlink should be resolved, before performing an acl related operation. This patch introduces a new api glfs_h_resolve_symlink() which will do the same. Change-Id: Ieee645154455a732edfb2c28834021bab4248810 BUG: 1209735 Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com> Reviewed-on: http://review.gluster.org/11410 Reviewed-by: Niels de Vos <ndevos@redhat.com> Reviewed-by: Raghavendra Talur <rtalur@redhat.com> Tested-by: NetBSD Build System <jenkins@build.gluster.org> Tested-by: Gluster Build System <jenkins@build.gluster.com>
* Upcall/gfapi: Return ENOTSUP when upcall feature is disabledSoumya Koduri2015-06-271-0/+12
| | | | | | | | | | | | | | Changes to detect the list of upcall events enabled using GF_FOP_IPC and return ENOTSUP to applications in case if they poll for any of the events disabled. Change-Id: Icc748054ef903598288119dbe99b1e337174662a BUG: 1231132 Signed-off-by: Niels de Vos <ndevos@redhat.com> Signed-off-by: Soumya Koduri <skoduri@redhat.com> Reviewed-on: http://review.gluster.org/11196 Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com> Tested-by: Kaleb KEITHLEY <kkeithle@redhat.com>
* gfapi: zero size issue in glfs_h_acl_set()Jiffin Tony Thottan2015-05-281-2/+2
| | | | | | | | | | | | | | | | | | | When setting the stringified ACLs in the xattr dict through pub_glfs_h_setxattrs(), the size of the string is always passed as 0. The correct way is to pass the length of the ACL in text form. While verifying this issues, it seems that posix_pacl_set() should return the errno instead of -1. This helps in debugging, otherwise EPERM would always be returned on an error. [ndevos: fix off-by-one strlen() and return errno in posix_pacl_set()] Change-Id: Ia7a7fa1f3a7d615a813c703057dc97b09a0bbb34 BUG: 789278 Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com> Signed-off-by: Niels de Vos <ndevos@redhat.com> Reviewed-on: http://review.gluster.org/10782 Tested-by: NetBSD Build System Tested-by: Gluster Build System <jenkins@build.gluster.com>
* gfapi: fix compile warning in pub_glfs_h_access()Niels de Vos2015-05-091-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While compiling libgfapi, the following warning is reported: Making all in src CC libgfapi_la-glfs-handleops.lo In file included from glfs-handleops.c:12:0: glfs-handleops.c: In function 'pub_glfs_h_access': glfs-internal.h:216:14: warning: 'old_THIS' may be used uninitialized in this function [-Wmaybe-uninitialized] THIS = old_THIS; \ ^ glfs-internal.h:202:36: note: 'old_THIS' was declared here #define DECLARE_OLD_THIS xlator_t *old_THIS = NULL ^ glfs-handleops.c:1159:2: note: in expansion of macro 'DECLARE_OLD_THIS' DECLARE_OLD_THIS; ^ CCLD libgfapi.la CCLD api.la The DECLARE_OLD_THIS macro should be done with the declarations of all the other variables used in this function. Moving the macro further up in the function prevents this warning. Change-Id: I2bedc1aa074893ae3e2c933abc5a167ab5b55f41 BUG: 1210934 Reported-by: Shyamsundar Ranganathan <srangana@redhat.com> Signed-off-by: Niels de Vos <ndevos@redhat.com> Reviewed-on: http://review.gluster.org/10728 Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com> Tested-by: NetBSD Build System Tested-by: Gluster Build System <jenkins@build.gluster.com>
* libgfapi: Store and restore THIS in every API exposed by libgfapiPoornima G2015-05-081-40/+155
| | | | | | | | | | | | | | | | | | | | | | Storing and restoring THIS: When the APIs exposed by libgfapi are called by other xlators like snapview server etc. the THIS value is overwritten to contain the THIS of libgfapi(viz libgfapi master xlator). Hence using 'THIS' in any xlator after calling libgfapi API will lead to issues. One such issue was uncovered in snapview and the patch http://review.gluster.org/#/c/9469/ was sent to workaround this issue. Hence, storing and restoring THIS, at the entry and exit of every API exposed by libgfapi. Change-Id: I6f330dde25e7700fb26339d667a7ccd193ec6ba0 BUG: 1210934 Signed-off-by: Poornima G <pgurusid@redhat.com> Reviewed-on: http://review.gluster.org/9797 Reviewed-by: Raghavendra Talur <rtalur@redhat.com> Reviewed-by: soumya k <skoduri@redhat.com> Reviewed-by: Niels de Vos <ndevos@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com>
* libgfapi : anonymous fd supportJiffin Tony Thottan2015-05-051-0/+48
| | | | | | | | | | | | | | | | Anonymous fd's are floating fd assigned to a glusterfs client without a explicit file open. Here either it will create a new anonymous fd or existing anonymous fd in the client stack for requested file.The anonymous fd's are mainly used for IO's. This patch introduces two api's glfs_h_anonymous_read and glfs_h_anonymous_write which performs read and write respectively Change-Id: Id646f2220e8387b2f8bb244c848dc1db6761444f BUG: 1204651 Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com> Reviewed-by: Niels de Vos <ndevos@redhat.com> Reviewed-on: http://review.gluster.org/9971 Tested-by: Gluster Build System <jenkins@build.gluster.com>