349 Commits

Author SHA1 Message Date
ShyamsundarR
b4504eadd8 gfapi: Cleanup alias file
2 extra symbols were in the alias file, that are not exported
this is cleaned up with this patch.

Change-Id: I1ab54b9fb6b0d455884fbbfd89820c60bb861e6f
Updates: bz#1193929
Signed-off-by: ShyamsundarR <srangana@redhat.com>
2018-09-17 03:32:36 +00:00
Gluster Ant
e16868dede Land part 2 of clang-format changes
Change-Id: Ia84cc24c8924e6d22d02ac15f611c10e26db99b4
Signed-off-by: Nigel Babu <nigelb@redhat.com>
2018-09-12 17:52:45 +05:30
Gluster Ant
45a71c0548 Land clang-format changes
Change-Id: I6f5d8140a06f3c1b2d196849299f8d483028d33b
2018-09-12 17:22:48 +05:30
Kaleb S. KEITHLEY
af0d5a9b53 core: python3
see https://review.gluster.org/#/c/19788/,
    https://review.gluster.org/#/c/19871/,
    https://review.gluster.org/#/c/19952/,
    https://review.gluster.org/#/c/20104/,
    https://review.gluster.org/#/c/20162/,
    https://review.gluster.org/#/c/20185/,
    https://review.gluster.org/#/c/20207/,
    https://review.gluster.org/#/c/20227/,
    https://review.gluster.org/#/c/20307/,
    https://review.gluster.org/#/c/20320/,
    https://review.gluster.org/#/c/20332/,
    https://review.gluster.org/#/c/20364/,
    https://review.gluster.org/#/c/20441/, and
    https://review.gluster.org/#/c/20484

shebangs changed from /usr/bin/python2 to /usr/bin/python3.
(Reminder, various distribution packaging guidelines require use
of explicit python version and don't allow '#!/usr/bin/env python',
regardless of how handy that idiom may be.)

glusterfs.spec(.in) package python{2,3}-gluster and python2 or
python3 dependencies as appropriate.

configure(.ac):
+ test for and use python2 or python3 as appropriate. If build
  machine has python2 and python3, use python3. Override by
  setting PYTHON=/usr/bin/python2 when running configure.
+ PYTHONDEV_CPPFLAGS from python[23]-config --includes is a
  better match to the original python sysconfig.get_python_inc().
  All those other extraneous flags breaks the build.
+ Only change the shebangs once. Changing them over and over
  again, e.g., during a `make glusterrpms` in extras/LinuxRPM
  just sends make (is it really make that's looping?) into an
  infinite loop. If you figure out why, let me know.
+ Oldest python2 is python2.6 on CentOS 6 and Debian 8 (Jessie).
  Everything else has 2.7 or 3.x
+ logic from https://review.gluster.org/c/glusterfs/+/21050, which
  needs to be removed/merged after that patch is merged.

Builds on CentOS 6, CentOS 7, Fedora 28, Fedora rawhide, and the
mysterious RHEL > 7.

Change-Id: Idae21d3b6f58b32372e1daa0d234e491e563198f
updates: #411
Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
2018-09-03 09:14:44 +00:00
Niels de Vos
44e40404ed build: add --enable-asan configure options
Introduce a `./configure --enable-asan` to build with
`-fsanitize=address -fno-omit-frame-pointer` options. This uses the
libasan.so shared library, so that needs to be available.

While running builds with the ASAN options, several linker issues
surfaced and these have been addressed with this change as well.
Building with --enable-asan has been tested on Fedora 28.

Change-Id: I428a9da70dd8f7d0056cfbe5c398619a571469b2
Updates: #492
Signed-off-by: Niels de Vos <ndevos@redhat.com>
2018-08-30 05:41:26 +00:00
Yaniv Kaul
036327d9e9 glfs-fops.c, glfs.c: strncpy() -> sprintf(), reduce strlen()'s
strncpy may not be very efficient for short strings copied into
a large buffer: If the length of src is less than n,
strncpy() writes additional null bytes to dest to ensure
that a total of n bytes are written.

Instead, use snprintf().

Also, save the result of strlen() and re-use it when possible.

Compile-tested only!

Change-Id: I4ecfb359cf0efaafeab245a8138f526b21613231
updates: bz#1193929
Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
2018-08-24 16:26:36 +00:00
ShyamsundarR
faf736cb30 coverity: Multiple coverity fixes for issues with HIGH severity
glfs-fops.c
1391414 Uninitialized pointer read
List head needed initialization

glusterfsd-mgmt.c
graph.c
1382431 Buffer not null terminated
1382417 Dereference before null check
1382347 Buffer not null terminated
Cleaned usage of volfile_checksum member of gf_volfile_t struct
across the code base.

glusterd-tier.c
1382426 Resource leak
1370955 Dereference before null check
The function fixed needs more work, but with tier almost being
deprecated, addressed some parts of the reported coverity issues
as appropriate.

Tested using the following test cases:
./tests/basic/tier/new-tier-cmds.t
./tests/basic/tier/tier.t
./tests/basic/tier/bug-1214222-directories_missing_after_attach_tier.t
./tests/basic/tier/tier_lookup_heal.t
./tests/basic/tier/tier-heald.t
./tests/basic/tier/tier-snapshot.t
./tests/features/glfs-lease.t

Change-Id: I396f1c34bb112bb22d2745ed279e1a4850cac4af
Updates: bz#789278
Signed-off-by: ShyamsundarR <srangana@redhat.com>
2018-08-22 18:13:12 +00:00
Yaniv Kaul
ec8174353a api/src/glfs.c: move to GF_MALLOC() instead of GF_CALLOC()
It doesn't make sense to calloc (allocate and clear) memory
when the code right away fills that memory with data.
It may be optimized by the compiler, or have a microscopic
performance improvement.

Please review carefully, especially for string allocation, with the
terminating NULL string.

Only compile-tested!

Change-Id: Ieeb86ff5d99176250f57c0a28c215c709b83fc80
updates: bz#1193929
Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
2018-08-22 08:56:46 +00:00
Kinglong Mee
da7c26ff1b gfapi: Use inode_forget in case of unlink/rename objects
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>
2018-08-21 04:49:46 +00:00
Jiffin Tony Thottan
febee007bb gfapi : Handle the path == "" glfs_resolve_at
Currently there is no check for path = "" in glfs_resolve_at.
So if application sends an empty path, then the function resolves
into the parent inode which is incorrect. Plus modified possible
of "path" with "origpath" in the same function.

Change-Id: Ie5ff9ce4b771607b7dbb3fe00704fe670421792a
fixes: bz#1610236
Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com>
2018-08-13 11:44:55 +00:00
ShyamsundarR
60f1aeb08d coverity: Fix remaining SECURE_TEMP issues reported
Two pending SECURE_TEMP issues still exist in the coverity
reports, these are fixed by this patch.

In both instances (where functions actually seem to be
duplicates of each other) the need was for a FILE * and
not an fd. Applied the same pattern in both places as in
other parts of the code where mkstemp was used and later
a FILE * was created from the resulting fd for use.

Coverity report: https://download.gluster.org/pub/gluster/
  glusterfs/static-analysis/master/glusterfs-coverity/
  2018-07-30-4d3c62e7/html/

Issues numbered: 382, 383 (named SECURE_TEMP)

Further added tmpfile to the blacklist, so that future code
changes do not add the same, into symbol-check.sh.

Also corrected shellcheck errors in symbol-check.sh as a
result of updating the same.

Updates: bz#789278

Change-Id: I1d572a16ca5b5df2f597aeaa5f454fad34c8296e
Signed-off-by: ShyamsundarR <srangana@redhat.com>
2018-08-03 08:37:15 +00:00
Zhang Huan
75300258c4 libgfapi: fix memory leak on old volume files
Fix missing free of fs->oldvolfile. This patch uses standard
calloc/realloc to allocate memory for vol file. As by the time fs struct
is destroyed, the THIS->ctx is already gone, that causes invalid memory
access.

Change-Id: I72ae19c76eb16e61f077714f7e52405fee721997
fixes: bz#1607689
Signed-off-by: Zhang Huan <zhanghuan@open-fs.com>
2018-07-28 07:21:12 +00:00
Zhang Huan
a6b5ec5cb5 libgfapi: add missing unref of mgmt client in glfs_fini
Change-Id: I89cdf14cb9d822eaf7c01cf0b0220b423eb5b705
fixes: bz#1607689
Signed-off-by: Zhang Huan <zhanghuan@open-fs.com>
2018-07-28 07:21:12 +00:00
Niels de Vos
35cfc01fa2 build: rename event.h to gf-event.h
Newer FreeBSD versions (noticed with 10.3-RELEASE) provide a event.h
file that on occasion gets included instead of the libglusterfs file.
When this happens, 'struct event_pool' will not be defined and building
will fail with errors like:

    autoscale-threads.c:18:55: error: incomplete definition of type 'struct event_pool'
            int                      thread_count   = pool->eventthreadcount;
                                                      ~~~~^
    autoscale-threads.c:17:16: note: forward declaration of 'struct event_pool'
            struct event_pool       *pool           = ctx->event_pool;
                   ^

This problem is caused by 'pkg-config --cflags uuid' that adds
/usr/local/include to the GF_CPPFLAGS. The use of libuuid is preferred
so that the contrib/uuid/ directory can be removed.

By renaming event.h to gf-event.h there is no conflict between the
different event.h files anymore and compiling on FreeBSD works without
issues.

Change-Id: Ie69f6b8a4f8f8e9630d39a86693eb74674f0f763
Updates: bz#1607319
Signed-off-by: Niels de Vos <ndevos@redhat.com>
2018-07-27 17:37:32 +00:00
Yaniv Kaul
621138ce76 All: run codespell on the code and fix issues.
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>
2018-07-22 14:40:16 +00:00
Jiffin Tony Thottan
2a3090028a gfapi : Coverity Fixes
*** CID 1391419:  Control flow issues  (DEADCODE)
glusterfs/api/src/glfs-fops.c: 5224 in glfs_recall_lease_upcall()

*** CID 1391414:  Memory - illegal accesses  (UNINIT)
glusterfs/glusterfs/api/src/glfs-fops.c: 5137 in glfs_recall_lease_fd()

Fixes: #789278
Change-Id: Ie16103e7e321724d3cf1bdcb815c2e2467b9a366
Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com>
2018-06-14 14:50:16 +00:00
Kaleb S. KEITHLEY
e86c58b473 api: cleanup headers
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>
2018-06-11 13:10:42 +00:00
Raghavendra G
3894f4262d rpc/clnt: Don't let consumers manage "connected" state
The state management of "connected" in rpc is ad-hoc as far as the
responsibility goes. Note that there is nothing wrong with
functionality itself. rpc layer manages this state in disconnect
codepath and has exposed an api to manage this one from
consumers. Note that rpc layer never sets "connected" to true by
itself, which forces the consumers to use this api to get a working
rpc connection. The situation is best captured from a comment in code
from Jeff Darcy in glusterfsd/src/gf-attach.c:

-/*
- * In a sane world, the generic RPC layer would be capable of tracking
- * connection status by itself, with no help from us.  It might invoke our
- * callback if we had registered one, but only to provide information.  Sadly,
- * we don't live in that world.  Instead, the callback *must* exist and *must*
- * call rpc_clnt_{set,unset}_connected, because that's the only way those
- * fields get set (with RPC both above and below us on the stack).  If we don't
- * do that, then rpc_clnt_submit doesn't think we're connected even when we
- * are.  It calls the socket code to reconnect, but the socket code tracks this
- * stuff in a sane way so it knows we're connected and returns EINPROGRESS.
- * Then we're stuck, connected but unable to use the connection.  To make it
- * work, we define and register this trivial callback.
- */

Also, consumers of rpc know about state of connection only through the
notifications sent by rpc-clnt. So, consumers don't have any extra
information to manage the state and hence letting them manage the
state is counter intuitive. This patch cleans that up and instead
moves the responsibility of state management of rpc layer into
itself.

Change-Id: I31e641a60795fc480ca753917f4b2579f1e05094
Signed-off-by: Raghavendra G <rgowdapp@redhat.com>
Fixes: bz#1585585
2018-06-04 12:57:42 +05:30
Kaleb S. KEITHLEY
202d27c530 core/various: python3 compat, prepare for python2 -> python3
see https://review.gluster.org/#/c/19788/ and
    https://review.gluster.org/#/c/19871/

Selected small fixes from 2to3 utility. Specifically apply, basestring,
funcattrs, idioms, numliterals, set_literal, types, urllib, zip

Note: these 2to3 fixes report no changes are necessary: exec, execfile,
exitfunc, filter, getcwdu, intern, itertools, metaclass, methodattrs, ne,
next, nonzero, operator, paren, raw_input, reduce, reload, renames, repr,
standarderror, sys_exc, throw, tuple_params, xreadlines.

Any 2to3 fixes not in the above two lists have more extensive changes
which will follow in separate patches.

most unicode changes suggested by 2to3 will need to be applied at the
same time as changing the shebangs from python2 to python3. Prashanth
notes that unicode strings in py2 need 'u' prefix; unicode strings in
py3 3.0, 3.1, and 3.2 a 'u' prefix will throw an error, but in py3 3.3+
it is legal (or just ignored). All Linux dists we care about have 3.3
or later so we can leave 'u' prefixes on unicode strings.

Change-Id: I49bba2f328b0ee24b9a8115a7183be979981563e
updates: #411
Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
2018-05-30 03:37:46 +00:00
Kotresh HR
3d38e4e47f libgfapi: Fix lookup on root
Lookup on root was sending "/" as the path.
This will break the basename calculation in
loc_copy and hence lookup on root was failing
if the loc_copy was involved in the stack.

With ctime, a first lookup on root initiates
a metadata self heal because of ctime xattr
not being same on all afr subvolumes. This
results in loc_copy and hence the failure
of lookup.

Fix would be to send path with "." for the root.

fixes: bz#1582516
Change-Id: Iafe4b99f249a4f5034ad34c1d30590de0e35aa0d
Signed-off-by: Kotresh HR <khiremat@redhat.com>
2018-05-28 04:57:22 +00:00
Kaleb S. KEITHLEY
dcccfeb887 api: missing __THROW on pub function decls
missing __THROW on pub function decls needed for C++

Change-Id: Ia0ff09d311741e4cdc8ef171e07bbd56c24b9260
updates: bz#1193929
Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
2018-05-25 08:18:50 +00:00
Susant Palai
fc17daf2e6 core: make glfs_iobuf_copy() consumable for general purpose.
Currently plugins for cloudsync will be using it to write back data
downloaded from remote store/cloud.

Change-Id: I59f10bebed21b19568c94cbf29e3d536d5570749
Updates: #387
Signed-off-by: Susant Palai <spalai@redhat.com>
2018-05-24 09:32:09 +00:00
Kaleb S. KEITHLEY
b4ce5e090d gfapi: various broken symbol versions
lots of breakage in symbol versions:
  symbols added in 4.1 incorrectly, and
  symbols added in 4.1 but labeled 4.0.0, and
  symbols added in 3.13 incorrectly

Not noticed until someone tried to build 3.13.2 on FreeBSD 11.1,
despite the fact that we build on FreeBSD 10.3 IIRC, somehow the
3.13 errors aren't a build error there.

Note: in rereading the Ulrich Drepper write-up I noticed that when
a symbol version is changed, you are supposed to leave the old
symbol in its original section in addition to adding it to its new
section. Adding back those symbols to their original sections.

Reported-by: Roman Serbski <mefystofel@gmail.com>

Change-Id: I9a883546d08e0847f7228d8ea5943bc54275b319
fixes: bz#1575716
Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
2018-05-10 11:15:18 -04:00
Thomas Hindoe Paaboel Andersen
a6490fe021 gfapi: acutally avoid recall callback when closed
Due to missing curly braces we end up calling the callback
function even when state is GLFD_CLOSE. This patch adds the
curly braces so both the log and actual callback is skipped.

  Introduced in 19568 in commit b04066721bf4a240f61b83bd87bbb27437c5fe4f

Change-Id: I0b15cfe222841cfcb12f17723284acb3838d64d7
fixes: bz#1575294
Signed-off-by: Thomas Hindoe Paaboel Andersen <phomes@gmail.com>
2018-05-06 11:24:34 +00:00
Soumya Koduri
b04066721b gfapi : RECALL_LEASE implementation
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>
2018-05-04 17:12:19 +00:00
Kaleb S. KEITHLEY
4e7b423d3c core/various: python3 compat, prepare for python2 -> python3
see https://review.gluster.org/#/c/19788/

use print fn from __future__

Change-Id: If5075d8d9ca9641058fbc71df8a52aa35804cda4
updates: #411
Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
2018-05-02 11:28:46 +00:00
Kaleb S. KEITHLEY
29024cfdd5 core/build/various: python3 compat, prepare for python2 -> python3
Note 1) we're not supposed to be using #!/usr/bin/env python, see
https://fedoraproject.org/wiki/Packaging:Guidelines?rd=Packaging/Guidelines#Shebang_lines

Note 2) we're also not supposed to be using "!/usr/bin/python,
see https://fedoraproject.org/wiki/Changes/Avoid_usr_bin_python_in_RPM_Build#Quick_Opt-Out

The previous patch (https://review.gluster.org/19767) tried to do too
much in one patch, so it was abandoned.

This patch does two things:
1) minor cleanup of configure(.ac) to explicitly use python2
2) change all the shebang lines to #!/usr/bin/python2 and add them
where they were missing based on warnings emitted during rpmbuild.

In a follow-up patch python2 will eventually be changed to python3.

Before that python2-isms (e.g. print, string.join(), etc.) need to be
converted to python3. Some of those can be rewritten in version agnostic
python. E.g. print statements become print() with "from __future_ import
print_function". The python 2to3 utility will be used for some of those.
Also Aravinda has given guidance in the comments to the first patch for
changes.

updates: #411
Change-Id: I471730962b2526022115a1fc33629fb078b74338
Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
2018-04-12 11:04:27 +00:00
Kaleb S. KEITHLEY
87c51a17a4 gfapi: fix a couple of minor issues
duplicatation of exported functions in gfapi.map. Only the newest one
is needed. Both the legacy and current symbols are exported.

glfs_io_cbk34 typedef should not be in a public header file. The old
application was compiled with the original glfs_io_cbk. Outside of
libgfapi, nothing now uses/needs this old typedef, move it into the
C file that needs it.

Similarly glfs_realpath34() decl should not be in glfs.h. Period. Old
applications were compiled with the then glfs_realpath() decl and
linked with glfs_realpath@@GFAPI_3_4.0. New applications should only
call glfs_realpath() and it will be linked to the new/current
glfs_realpath().

Change-Id: Icd5b0c9e9b68f0c133f14447b09ace35f33dbab2
fixes: bz#1564235
Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
2018-04-05 15:09:33 -04:00
Niklas Hambüchen
0056feaa21 python: Remove all uses of find_library. Fixes #1450593
`find_library()` doesn't consider LD_LIBRARY_PATH on Python < 3.6.

Change-Id: Iee26085cb5d14061001f19f032c2664d69a378a8
BUG: 1450593
Signed-off-by: Niklas Hambüchen <mail@nh2.me>
2018-03-24 05:10:31 +00:00
Mohit Agrawal
cf06dd5440 glusterd: TLS verification fails while using intermediate CA
Problem: TLS verification fails while using intermediate CA
         if mgmt SSL is enabled.

Solution: There are two main issue of TLS verification failing
          1) not calling ssl_api to set cert_depth
          2) The current code does not allow to set certificate depth
             while MGMT SSL is enabled.
          After apply this patch to set certificate depth user
          need to set parameter option transport.socket.ssl-cert-depth <depth>
          in /var/lib/glusterd/secure_acccess instead to set in
          /etc/glusterfs/glusterd.vol. At the time of set secure_mgmt in ctx
          we will check the value of cert-depth and save the value of cert-depth
          in ctx.If user does not provide any value in cert-depth in that case
          it will consider default value is 1

BUG: 1555154
Change-Id: I89e9a9e1026e37efb5c20f9ec62b1989ef644f35
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
2018-03-19 19:00:03 +00:00
Prashanth Pai
664b946496 Fetch backup volfile servers from glusterd2
Clients will request for a list of volfile servers from glusterd2 by
setting a (optional) flag in GETSPEC RPC call. glusterd2 will check for
the presence of this flag and accordingly return a list of glusterd2
servers in GETSPEC RPC reply. Currently, this list of servers returned
only contains servers which have bricks belonging to the volume.

See:
https://github.com/gluster/glusterd2/issues/382
https://github.com/gluster/glusterfs/issues/351

Updates #351
Change-Id: I0eee3d0bf25a87627e562380ef73063926a16b81
Signed-off-by: Prashanth Pai <ppai@redhat.com>
2018-02-16 16:16:25 +00:00
Kinglong Mee
384562b294 gfapi: return pre/post attributes at callback for glfs api
Updates: #389
Change-Id: Ic71632722effe4b8855d5de3e65688efd9afe1e3
Signed-off-by: Kinglong Mee <mijinlong@open-fs.com>
2018-02-12 21:34:46 +00:00
Kinglong Mee
248152767b gfapi: return pre/post attributes from glfs_ftruncate
Updates: #389
Change-Id: I8faea0828921fb17f05f7321c3cb01747373f21e
Signed-off-by: Kinglong Mee <mijinlong@open-fs.com>
2018-02-12 21:34:46 +00:00
Kinglong Mee
09943beb49 gfapi: return pre/post attributes from glfs_fsync/fdatasync
Updates: #389
Change-Id: I4153df72d5eeecefa7579170899db4c340128bea
Signed-off-by: Kinglong Mee <mijinlong@open-fs.com>
2018-02-12 21:34:46 +00:00
Kinglong Mee
d01f7244e9 gfapi: return pre/post attributes from glfs_pread/pwrite
As nfs-ganesha, a wcc data contains pre/post attributes is return
in read/write rpc reply. nfs-ganesha get those attributes by
two getattr between the real read/write right now.

But, gluster has return pre/post attributes from glusterfsd,
those attributes are skipped in syncop/gfapi, if gfapi return them,
the upper user (nfs-ganesha) can use them directly without any
duplicate getattr.

Updates: #389
Change-Id: I7b643ae4241cfe2aeb17063de00192d81674024a
Signed-off-by: Kinglong Mee <mijinlong@open-fs.com>
2018-02-12 21:34:46 +00:00
Kinglong Mee
2a004fbcc9 libgfapi: Remove need_lookup from readdirp
The inode_set_need_lookup is removed from fuse_readdirp_cbk at
http://lists.gluster.org/pipermail/gluster-devel/2017-August/053505.html
https://review.gluster.org/#/c/17985/

Remove the same logical from glfd_entry_refresh too.

Change-Id: Ic0d7b59d4d4ed8315bf4c5e87e8e1133bcf95401
Signed-off-by: Kinglong Mee <mijinlong@open-fs.com>
2018-02-08 19:16:41 +00:00
Kinglong Mee
2584ef1b00 libgfapi: skip nameless lookup if stat is NULL
Change-Id: If0ad17be2f7d7f88df25966aaf67af963ff4fc41
Signed-off-by: Kinglong Mee <mijinlong@open-fs.com>
2018-02-08 19:14:45 +00:00
Soumya Koduri
1a519f4bf9 gfapi : New APIs have been added to use lease feature in gluster
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>
2018-01-26 12:33:42 +00:00
Kaleb S. KEITHLEY
3cad44e8a7 build: use libtirpc by default, even if ipv6 is not the default
Another error snuck in with Change-Id I86f847dfd, or more
accurately I think, with Change-Id: Ic47065e9c2...

All libs, not just libgfrpc, need to be linked with libtirpc,
especially on systems that still have xdr functions in (g)libc
where you will get a mixture of calls to libtirpc functions
and glibc functions, with catastrophic results.

BUG: 1536186
Change-Id: I97dc39c7844f44c36fe210aa813480c219e1e415
Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
2018-01-26 10:55:26 +00:00
Anoop C S
ec3df9e65a libgfapi: Add new api for supporting mandatory-locks
The current API for byte-range locks [glfs_posix_lock()] doesn't
allow applications to specify whether it is advisory or mandatory
type locks. This particular change is to introduce an extended
byte-range lock API with an additional argument for including
the byte-range lock mode to be one among advisory(default) or
mandatory. Patch also includes a gfapi test case which make use
of this new api to acquire mandatory locks.

Ref: https://github.com/gluster/glusterfs-specs/blob/master/done/GlusterFS%203.8/Mandatory%20Locks.md

Change-Id: Ia09042c755d891895d96da857321abc4ce03e20c
Updates #393
Signed-off-by: Anoop C S <anoopcs@redhat.com>
2018-01-22 09:54:02 +00:00
Soumya Koduri
9eefff096f gfapi : added glfs_setfsleaseid() for setting lease id
A new function glfs_setfsleaseid() added in gfapi. Currently lock owner
is saved in the thread context. Similarly the leaseid attribute can be
saved using glfs_setfsleaseid().

Updates: #350
Change-Id: I55966cca01d0f2649c32b87bd255568c3ffd1262
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>
2018-01-19 09:27:40 +00:00
Amar Tumballi
9404b0de3f core: fix some of the dict_{get,set} with proper APIs
updates #220

Change-Id: I6e25dbb69b2c7021e00073e8f025d212db7de0be
Signed-off-by: Amar Tumballi <amarts@redhat.com>
2018-01-17 00:00:11 +00:00
Xavier Hernandez
415e0bcc80 all: Simplify component message id's definition
This patch creates a new way of defining message id's that is easier
and less error prone because it doesn't require so many manual changes
each time a new component is defined or a new message created.

Change-Id: I71ba8af9ac068f5add7e74f316a2478bc991c67b
Signed-off-by: Xavier Hernandez <jahernan@redhat.com>
2017-12-14 02:33:51 +00:00
Zhang Huan
4eb49de567 gfapi: fix issue when glfs_set_logging is called concurrently
glfs_set_logging changes THIS->ctx without lock, during initialization
THIS refers to global_xlator. Concurrently changing it could result in
global_xlator.ctx being some fs->ctx. After that fs->ctx is destroyed,
global_xlator.ctx refers to an invalid pointer and that causes crash in
sbusequent access.

Change-Id: I6682173811799bafd525d9ab371874f3803baa0e
BUG: 1521213
Signed-off-by: Zhang Huan <zhanghuan@open-fs.com>
2017-12-06 23:46:03 +00:00
Zhang Huan
28202631fe libglusterfs: specify ctx in gf_log_set_loglevel
specify ctx in gf_log_set_loglevel, instead of getting it from a thread
specific variable.

Change-Id: I498f826e8e32231235a6b0005026a27c327727fd
BUG: 1521213
Signed-off-by: Zhang Huan <zhanghuan@open-fs.com>
2017-12-06 23:45:23 +00:00
Kinglong Mee
718e2f2c6c gfapi: avoid nameless lookup when inode_find success
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>
2017-11-28 22:33:53 +00:00
Girjesh Rajoria
0821a57bd2 Coverity Issue: PW.INCLUDE_RECURSION in several files
Coverity ID: 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417,
418, 419, 423, 424, 425, 426, 427, 428, 429, 436, 437, 438, 439,
440, 441, 442, 443

Issue: Event include_recursion

Removed redundant, recursive includes from the files.

Change-Id: I920776b1fa089a2d4917ca722d0075a9239911a7
BUG: 789278
Signed-off-by: Girjesh Rajoria <grajoria@redhat.com>
2017-11-09 13:21:11 +00:00
Andrea Bolognani
684d62276a *.pc: Fix include path in Cflags
The include path in glusterfs-api.pc looks like

  -I${includedir}/glusterfs

However, client code will include the glusterfs headers using

  #include <glusterfs/api/glfs.h>

rather than

  #include <api/glfs.h>

which makes the "/glusterfs" part entirely unnecessary.

More importantly, on some platforms such as FreeBSD, the header files
for glusterfs will be installed in /usr/local/include, which is *not*
part of the compiler's default include path, so compilation will fail
with something like

  fatal error: 'glusterfs/api/glfs.h' file not found
  #include <glusterfs/api/glfs.h>
           ^~~~~~~~~~~~~~~~~~~~~~

The fix is to simply drop the extra "/glusterfs". The same change
is applied to other *.pc files as well, althought I haven't actually
tested those.

A test program (gfapi-load-volfile) and the glfsxmp example
application were using the wrong include paths, so they had to be
fixed as well.

Change-Id: I9a16de47fee7ab9c12d1cb823bbe061a69352670
BUG: 1508947
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2017-11-08 11:10:44 +00:00
Mohammed Rafi KC
6c8e6d0e97 gfapi: Fix several coverity issues in glfs-fops.c
This patch fixes coverity issues 176

[1] : https://download.gluster.org/pub/gluster/glusterfs/static-analysis/
master/glusterfs-coverity/2017-10-30-9aa574a5/html/

Change-Id: I473323db27218ac784b8eae773a1efe911fcfec0
BUG: 789278
Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com>
2017-11-08 02:10:54 +00:00
Soumya Koduri
c0e77f6439 gfapi: Register/Unregister Upcall events' callback
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>
2017-10-31 07:53:50 +00:00