472 Commits

Author SHA1 Message Date
Yaniv Kaul
c7d1aee76d Multiple files: reduce work while under lock.
Mostly, unlock before logging.
In some cases, moved different code that was not needed
to be under lock (for example, taking time, or malloc'ing)
to be executed before taking the lock.

Note: logging might be slightly less accurate in order, since it may
not be done now under the lock, so order of logs is racy. I think
it's a reasonable compromise.

Compile-tested only!
updates: bz#1193929
Signed-off-by: Yaniv Kaul <ykaul@redhat.com>

Change-Id: I2438710016afc9f4f62a176ef1a0d3ed793b4f89
2019-01-29 09:27:22 +00:00
Mohit Agrawal
04f84756e1 core: heketi-cli is throwing error "target is busy"
Problem: At the time of deleting block hosting volume
         through heketi-cli , it is throwing an error "target is busy".
         cli is throwing an error because brick is not detached successfully
         and brick is not detached due to race condition to cleanp xprt
         associated with detached brick

Solution: To avoid xprt specifc race condition introduce an atomic flag
          on rpc_transport

Change-Id: Id4ff1fe8375a63be71fb3343f455190a1b8bb6d4
fixes: bz#1668190
Signed-off-by: Mohit Agrawal <moagrawal@redhat.com>
2019-01-24 06:54:41 +00:00
Milind Changire
b6c417785e rpc: use address-family option from vol file
This patch helps enable IPv6 connections in the cluster.
The default address-family is IPv4 without using this option explicitly.

When address-family is set to "inet6" in the /etc/glusterfs/glusterd.vol
file, the mount command-line also needs to have
-o xlator-option="transport.address-family=inet6" added to it.

This option also gets added to the brick command-line.
Snapshot and gfapi use-cases should also use this option to pass in the
inet6 address-family.

Change-Id: I97db91021af27bacb6d7578e33ea4817f66d7270
fixes: bz#1635863
Signed-off-by: Milind Changire <mchangir@redhat.com>
2019-01-22 13:47:19 +00:00
Kinglong Mee
8b4822d457 rpc-clnt: reduce transport connect log for EINPROGRESS
quotad and ganesha.nfsd prints many logs as,

[rpc-clnt.c:1739:rpc_clnt_submit ] 0-<VOLUME_NAME>-quota: error returned while attempting to connect to host: (null), port 0

Change-Id: Ic0c815400619e4a87a772a51b19822920228c1ef
Updates: bz#1596787
Signed-off-by: Kinglong Mee <mijinlong@open-fs.com>
2019-01-07 03:19:34 +00:00
Pranith Kumar K
4a15ea1fd3 rpcsvc: Don't expect dictionary values to be available
When reconfigure happens, string values from one dictionary
are directly set in another dictionary. This can lead to
invalid memory when the first dictionary is freed up.
So do dict_set_dynstr_with_alloc instead of dict_set_str

updates bz#1650403
Change-Id: Id53236467521cfdeb07e7178d87ba6cf88d17003
Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
2019-01-07 03:17:49 +00:00
Sheetal Pamecha
8d38c5b733 rpc/rpc-lib: fix coverity issue
Defect: Code can never be reached because of the
condition queue_index > 1024 cannot be true.

CID: 1398471 Logically dead code
updates: bz#789278

Change-Id: I367cda7e734f6d774900a58d8664cffcab69126f
Signed-off-by: Sheetal Pamecha <sheetal.pamecha08@gmail.com>
2018-12-28 10:40:49 +00:00
Sunny Kumar
de1fb17ac3 rpc : fix coverity in rpc/rpc-lib/src/rpcsvc.c
This patch fixes newly introduced coverity.

CID: 1398472: Dereference before null check.
updates: bz#789278

Change-Id: Ie9b13084097de8f24b138acd7608c3e15b3bba9c
Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
2018-12-28 10:31:53 +00:00
Mohit Agrawal
0c7425d431 rpc: Use adaptive mutex in rpcsvc_program_register
Adaptive mutexes are used to protect critical/shared data items that
are held for short periods.It provides a balance between spin locks
and traditional mutex.We have observed after use adaptive mutex in
rpcsvc_program_register got some improvement.

Change-Id: I7905744b32516ac4e4ca3c83c2e8e5e306093add
fixes: bz#1660701
2018-12-20 16:44:26 +00:00
ShyamsundarR
bfe2b5e153 clang: Fix various missing checks for empty list
When using list_for_each_entry(_safe) functions, care needs
to be taken that the list passed in are not empty, as these
functions are not empty list safe.

clag scan reported various points where this this pattern
could be caught, and this patch fixes the same.

Additionally the following changes are present in this patch,
- Added an explicit op_ret setting in error case in the
macro MAKE_INODE_HANDLE to address another clang issue reported
- Minor refactoring of some functions in quota code, to address
possible allocation failures in certain functions (which in turn
cause possible empty lists to be passed around)

Change-Id: I1e761a8d218708f714effb56fa643df2a3ea2cc7
Updates: bz#1622665
Signed-off-by: ShyamsundarR <srangana@redhat.com>
2018-12-14 04:33:15 +00:00
Mohit Agrawal
607bbd935f rpc: Resolve memory leak in mgmt_pmap_signout_cbk
Problem: At the time of submit signout request to mgmt
         rpc_clnt_mgmt_pmap_signout create a frame but in cbk
         frame is not destroyed

Solution: cleanup frame in mgmt_pmap_signout_cbk to avoid leak

Change-Id: I9961cacb2e02c8023c4c99e22e299b8729c2b09f
fixes: bz#1658045
Signed-off-by: Mohit Agrawal <moagrawal@redhat.com>
2018-12-12 22:58:49 +00:00
Raghavendra Bhat
7dadea15c5 copy_file_range support in GlusterFS
* libglusterfs changes to add new fop

    * Fuse changes:
      - Changes in fuse bridge xlator to receive and send responses

    * posix changes to perform the op on the backend filesystem

    * protocol and rpc changes for sending and receiving the fop

    * gfapi changes for performing the fop

    * tools: glfs-copy-file-range tool for testing copy_file_range fop

      - Although, copy_file_range support has been added to the upstream
	    fuse kernel module, no release has been made yet of a kernel
        which contains the support. It is expected to come in the
        upcoming release of linux-4.20

        So, as of now, executing copy_file_range fop on a fused based
        filesystem results in fuse kernel module sending read on the
	    source fd and write on the destination fd.

	    Therefore a small gfapi based tool has been written to be able
        test the copy_file_range fop. This tool is similar (in functionality)
	    to the example program given in copy_file_range man page.

	    So, running regular copy_file_range on a fuse mount point and
	    running gfapi based glfs-copy-file-range tool gives some idea about
	    how fast, the copy_file_range (or reflink) can be.

	    On the local machine this was the result obtained.

	    mount -t glusterfs workstation:new /mnt/glusterfs
	    [root@workstation ~]# cd /mnt/glusterfs/
	    [root@workstation glusterfs]# ls
	    file
	    [root@workstation glusterfs]# cd
	    [root@workstation ~]# time /tmp/a.out /mnt/glusterfs/file /mnt/glusterfs/new
	    real  0m6.495s
	    user  0m0.000s
	    sys   0m1.439s
	    [root@workstation ~]# time glfs-copy-file-range $(hostname) new /tmp/glfs.log /file /rrr
	    OPEN_SRC: opening /file is success
	    OPEN_DST: opening /rrr is success
	    FSTAT_SRC: fstat on /rrr is success
	    copy_file_range successful

        real  0m0.309s
        user  0m0.039s
        sys   0m0.017s

        This tool needs following arguments
         1) hostname
         2) volume name
         3) log file path
         4) source file path (relative to the gluster volume root)
         5) destination file path (relative to the gluster volume root)

        "glfs-copy-file-range <hostname> <volume> <log file path> <source> <destination>"

      - Added a testcase as well to run glfs-copy-file-range tool

    * io-stats changes to capture the fop for profiling

    * NOTE:

      - Added conditional check to see whether the copy_file_range syscall
        is available or not. If not, then return ENOSYS.

      - Added conditional check for kernel minor version in fuse_kernel.h
        and fuse-bridge while referring to copy_file_range. And the kernel
        minor version is kept as it is. i.e. 24. Increment it in future
        when there is a kernel release which contains the support for
        copy_file_range fop in fuse kernel module.

    * The document which contains a writeup on this enhancement can be found at
      https://docs.google.com/document/d/1BSILbXr_knynNwxSyyu503JoTz5QFM_4suNIh2WwrSc/edit

Change-Id: I280069c814dd21ce6ec3be00a884fc24ab692367
updates: #536
Signed-off-by: Raghavendra Bhat <raghavendra@redhat.com>
2018-12-12 15:56:55 +00:00
ShyamsundarR
20ef211cfa libglusterfs: Move devel headers under glusterfs directory
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>
2018-12-05 21:47:04 +00:00
Xie Changlong
ad446dabb8 protocol/server: support server.all-squash
We still use gnfs on our side, so do a little work to support
server.all-squash. Just like server.root-squash, it's also a
volume wide option. Also see bz#1285126

$ gluster volume set <VOLNAME> server.all-squash on

Note: If you enable server.root-squash and server.all-squash
at the same time, only server.all-squash works. Please refer
to following table

+---------------+-----------------+---------------------------+
|               |all_squash       | no_all_squash             |
+-------------------------------------------------------------+
|               |                 |anonuid/anongid for root   |
|root_squash    |anonuid/anongid  |useruid/usergid for no-root|
+-------------------------------------------------------------+
|no_root_squash |anonuid/anongid  |useruid/usergid            |
+-------------------------------------------------------------+

Updates bz#1285126
Signed-off-by: Xie Changlong <xiechanglong@cmss.chinamobile.com>
Signed-off-by: Xue Chuanyu <xuechuanyu@cmss.chinamobile.com>
Change-Id: Iea043318fe6e9a75fa92b396737985062a26b47e
2018-12-05 21:45:49 +00:00
Raghavendra Bhat
9fc6cf898b rpc: check if fini is there before calling it
The rpc_transport_t structure is allocated and filled in the
rpc_transport_load function. If filling the fileds of the rpc
structure fails, then in the failure handling the structure is
freed by rpc_transport_cleanup. There, it unconditionally calls
fini. But, if the failure handling was invoked because of any
failure in between the allocation of rpc_transport_t and filling
the transport->fini (including the failure to fill fini ()), then
rpc_transport_cleanup can lead to a segfault.

Change-Id: I8be9b84cd6b19933c559c9736198a6e440373f68
fixes: bz#1654917
Signed-off-by: Raghavendra Bhat <raghavendra@redhat.com>
2018-12-04 02:27:03 +00:00
Mohit Agrawal
46c15ea8fa server: Resolve memory leak path in server_init
Problem: 1) server_init does not cleanup allocate resources
            while it is failed before return error
         2) dict leak at the time of graph destroying

Solution: 1) free resources in case of server_init is failed
          2) Take dict_ref of graph xlator before destroying
             the graph to avoid leak

Change-Id: I9e31e156b9ed6bebe622745a8be0e470774e3d15
fixes: bz#1654917
Signed-off-by: Mohit Agrawal <moagrawal@redhat.com>
2018-12-03 11:34:35 +00:00
Yaniv Kaul
b56bf714c1 rpc *.h fles: align structs
Make an effort to slightly better align the structures.

Change-Id: I6f80a451f2ffbf15adfb986cedc24c2799787b49
updates: bz#1193929
Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
2018-12-03 05:53:34 +00:00
Raghavendra Gowdappa
95e380eca1 rpcsvc: provide each request handler thread its own queue
A single global per program queue is contended by all request handler
threads and event threads. This can lead to high contention. So,
reduce the contention by providing each request handler thread its own
private queue.

Thanks to "Manoj Pillai"<mpillai@redhat.com> for the idea of pairing a
single queue with a fixed request-handler-thread and event-thread,
which brought down the performance regression due to overhead of
queuing significantly.

Thanks to "Xavi Hernandez"<xhernandez@redhat.com> for discussion on
how to communicate the event-thread death to request-handler-thread.

Thanks to "Karan Sandha"<ksandha@redhat.com> for voluntarily running
the perf benchmarks to qualify that performance regression introduced
by ping-timer-fixes is fixed with this patch and patiently running
many iterations of regression tests while RCAing the issue.

Thanks to "Milind Changire"<mchangir@redhat.com> for patiently running
the many iterations of perf benchmarking tests while RCAing the
regression caused by ping-timer-expiry fixes.

Change-Id: I578c3fc67713f4234bd3abbec5d3fbba19059ea5
Fixes: bz#1644629
Signed-off-by: Raghavendra Gowdappa <rgowdapp@redhat.com>
2018-11-29 01:19:12 +00:00
Kaleb S. KEITHLE
4a4ba1f2eb core: fix strncpy warnings
Since gcc-8.2.x (fedora-28 or so) gcc has been emitting warnings
about buggy use of strncpy.

Most uses that gcc warns about in our sources are exactly backwards;
the 'limit' or len is the strlen/size of the _source param_, giving
exactly zero protection against overruns. (Which was, after all, one
of the points of using strncpy in the first place.)

IOW, many warnings are about uses that look approximately like this:
    ...
    char dest[8];
    char src[] = "this is a string longer than eight chars";
    ...
    strncpy (dest, src, sizeof(src)); /* boom */
    ...

The len/limit should be sizeof(dest).

Note: the above example has a definite over-run. In our source the
overrun is typically only theoretical (but possibly exploitable.)

Also strncpy doesn't null-terminate on truncation; snprintf does; prefer
snprintf over strncpy.

Mildly surprising that coverity doesn't warn/isn't warning about this.

Change-Id: I022d5c6346a751e181ad44d9a099531c1172626e
updates: bz#1193929
Signed-off-by: Kaleb S. KEITHLE <kkeithle@redhat.com>
2018-11-15 05:06:59 +00:00
Yaniv Kaul
8a5adc8116 rpc/rpc-lib/src/rpc-clnt.c: unlock sooner, if we fail to connect.
Previously, we did not go to unlock the mutex if we failed
to connect. This patch fixes it.

Compile-tested only!

updates: bz#1193929
Signed-off-by: Yaniv Kaul <ykaul@redhat.com>

Change-Id: I0fcca066a2601dba6bc3e9eb8b3c9fc757ffe4db
2018-11-15 05:04:13 +00:00
Yaniv Kaul
e134ef2493 rpc-clnt*: several code changes to reduce conn lock times
Assorted code refactoring to reduce lock contention.
Also, took the opportunity to reorder structs more properly.
Removed dead code.

Hopefully, no functional changes.
Compile-tested only!

updates: bz#1193929
Signed-off-by: Yaniv Kaul <ykaul@redhat.com>

Change-Id: I5de6124ad071fd5e2c31832364d602b5f6d6fe28
2018-11-12 03:25:02 +00:00
Amar Tumballi
74e8328d3f all: fix the format string exceptions
Currently, there are possibilities in few places, where a user-controlled
(like filename, program parameter etc) string can be passed as 'fmt' for
printf(), which can lead to segfault, if the user's string contains '%s',
'%d' in it.

While fixing it, makes sense to make the explicit check for such issues
across the codebase, by making the format call properly.

Fixes: CVE-2018-14661

Fixes: bz#1644763
Change-Id: Ib547293f2d9eb618594cbff0df3b9c800e88bde4
Signed-off-by: Amar Tumballi <amarts@redhat.com>
2018-11-05 18:50:59 +00:00
Harpreet Lalwani
874ce6ef6e rpc/rpc-lib: Uninitialized argument value of a function
trav->saved_at.tv_sec is not initialized.

Calling "list_empty" function before initializing "trav".

Updates: bz#1622665

Change-Id: Ib5c2703a07a9c56ccd115001aca500f7a23c4a2e
Signed-off-by: Harpreet Lalwani <hlalwani@redhat.com>
2018-10-23 08:03:54 +00:00
Kinglong Mee
4756e27bbc rpc: failed requests immediately if rpc connection is down
In the case glfs_fini is ongoing, some cache xlators like readdir-ahead,
continues to submit requests. Current rpc submit code ignores
connection status and queues these internally generated requests. These
requests then got cleaned up after inode table has been destroyed,
causing crash.

Change-Id: Ife6b17d8592a054f7a7f310c79d07af005087017
updates: bz#1626313
Signed-off-by: Zhang Huan <zhanghuan@open-fs.com>
2018-09-27 03:03:53 +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
Sanju Rakonde
8612a1ca19 glusterd: Fix Buffer size issues
This patch fixes buffer size issue 1138522.

Change-Id: Ia12fc8f34f75704f8ed3efae2022c4fd67a8c76c
updates: bz#789278
Signed-off-by: Sanju Rakonde <srakonde@redhat.com>
2018-09-04 14:01:59 +00:00
Yaniv Kaul
5276e8f27e multiple files: calloc -> malloc
xlators/cluster/stripe/src/stripe-helpers.c: Move to GF_MALLOC() instead of GF_CALLOC() when possible

xlators/cluster/dht/src/tier.c: Move to GF_MALLOC() instead of GF_CALLOC() when possible
xlators/cluster/dht/src/dht-layout.c: Move to GF_MALLOC() instead of GF_CALLOC() when possible
xlators/cluster/dht/src/dht-helper.c: Move to GF_MALLOC() instead of GF_CALLOC() when possible
xlators/cluster/dht/src/dht-common.c: Move to GF_MALLOC() instead of GF_CALLOC() when possible
xlators/cluster/afr/src/afr.c: Move to GF_MALLOC() instead of GF_CALLOC() when possible
xlators/cluster/afr/src/afr-inode-read.c: Move to GF_MALLOC() instead of GF_CALLOC() when possible
tests/bugs/replicate/bug-1250170-fsync.c: Move to GF_MALLOC() instead of GF_CALLOC() when possible
tests/basic/gfapi/gfapi-async-calls-test.c: Move to GF_MALLOC() instead of GF_CALLOC() when possible
tests/basic/ec/ec-fast-fgetxattr.c: Move to GF_MALLOC() instead of GF_CALLOC() when possible
rpc/xdr/src/glusterfs3.h: Move to GF_MALLOC() instead of GF_CALLOC() when possible
rpc/rpc-transport/socket/src/socket.c: Move to GF_MALLOC() instead of GF_CALLOC() when possible
rpc/rpc-lib/src/rpc-clnt.c: Move to GF_MALLOC() instead of GF_CALLOC() when possible
extras/geo-rep/gsync-sync-gfid.c: Move to GF_MALLOC() instead of GF_CALLOC() when possible
cli/src/cli-xml-output.c: Move to GF_MALLOC() instead of GF_CALLOC() when possible
cli/src/cli-rpc-ops.c: Move to GF_MALLOC() instead of GF_CALLOC() when possible
cli/src/cli-cmd-volume.c: Move to GF_MALLOC() instead of GF_CALLOC() when possible
cli/src/cli-cmd-system.c: Move to GF_MALLOC() instead of GF_CALLOC() when possible
cli/src/cli-cmd-snapshot.c: Move to GF_MALLOC() instead of GF_CALLOC() when possible
cli/src/cli-cmd-peer.c: Move to GF_MALLOC() instead of GF_CALLOC() when possible
cli/src/cli-cmd-global.c: Move to GF_MALLOC() instead of GF_CALLOC() when possible

It doesn't make sense to calloc (allocate and clear) memory
when the code right away fills that memory with data.
It may be optimized by the compiler, or have a microscopic
performance improvement.

In some cases, also changed allocation size to be sizeof some
struct or type instead of a pointer - easier to read.
In some cases, removed redundant strlen() calls by saving the result
into a variable.

1. Only done for the straightforward cases. There's room for improvement.
2. Please review carefully, especially for string allocation, with the
terminating NULL string.

Only compile-tested!

updates: bz#1193929
Original-Author: Yaniv Kaul <ykaul@redhat.com>
Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
Signed-off-by: Amar Tumballi <amarts@redhat.com>

Change-Id: I16274dca4078a1d06ae09a0daf027d734b631ac2
2018-09-04 05:09:09 +00:00
Yaniv Kaul
052849983e Various files: 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(). Check for truncated output
where applicable.

Also:
- save the result of strlen() and re-use it when possible.
- move from strlen to SLEN (sizeof() ) for const strings.

Compile-tested only!

Change-Id: I54e80d4f4a80e98d3775e376efe05c51af0b29eb
updates: bz#1193929
Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
2018-08-31 13:13:43 +00:00
Milind Changire
459ea3e781 rpc: log fuse unique ID along with gluster XID
for better traceability between fuse requests and gluster requests a
mapping needs to be established in the logs between the two IDs

BUG: 1623408
Change-Id: I0ef82fe69c1ad7d0ce9e3ac4f35cd82aa6e9bca9
fixes: bz#1623408
Signed-off-by: Milind Changire <mchangir@redhat.com>
2018-08-30 13:03:40 +00:00
Yaniv Kaul
cd95c072f4 rpc/rpc-lib/src/rpc-clnt-ping.c:move to GF_MALLOC() instead of GF_CALLOC() when
It doesn't make sense to calloc (allocate and clear) memory
when the code right away fills that memory with data.
It may be optimized by the compiler, or have a microscopic
performance improvement.

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

Only compile-tested!

Change-Id: Ifb30412ddf1bfa509f52e0454454929b266e5658
updates: bz#1193929
Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
2018-08-23 09:29:02 +00:00
Vijay Bellur
e7afbfb1cf mgmt/glusterd: Code cleanup in glusterd-volgen.c
This patch does the following:

1. Addresses CID: 1124815,124816,1124833,1291724,1325535,1325536,1357858
  - by adding some null checks
  - by handling return values from functions
  - by using an appropriate buffer length in strncpy

2. Cleans up some commented code

Change-Id: I5a7079f34e3e460d5a6267734c3bc84bf4ad72f5
updates: bz#789278
Signed-off-by: Vijay Bellur <vbellur@redhat.com>
2018-08-19 13:25:58 +00:00
Zhang Huan
2e0744570f rpc: fix return value in rpc destroy
Change-Id: I73a113e2d40f508fd53b273a990a2371692c87bf
fixes: bz#1607689
Signed-off-by: Zhang Huan <zhanghuan@open-fs.com>
2018-07-28 07:21:12 +00:00
Zhang Huan
e7c87f757c rpc: add missing free of rpc->dnscache
Change-Id: I3fa97b99bf23459cf548205d75d2cc7936b2310e
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
Mohit Agrawal
abd7b13932 rpc: rpc_clnt_connection_cleanup is crashed due to double free
Problem: gfapi client is getting crashed in rpc_clnt_connection_cleanup
         at the time of destroying saved_frames

Solution: gfapi client is getting crashed because saved_frame ptr is
          already freed in rpc_clnt_destroy.To avoid the same update
          code in rpc_clnt_destroy

Change-Id: Id8cce102b49f26cfd86ef88257032ed98f43192b
fixes: bz#1607783
Signed-off-by: Mohit Agrawal <moagrawal@redhat.com>
2018-07-25 09:54:06 +05:30
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
Mohit Agrawal
e31c7a7c0c changelog: fix br-state-check.t crash for brick_mux
Problem: br-state-check.t is getting crash

Solution: Check condition in rpcsvc_request_create
          before allocate memory from rxpool

BUG: 1597776
Change-Id: I4fde1ade6073f603c32453f1840395db9a9155b7
fixes: bz#1597776
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
2018-07-11 03:11:45 +00:00
Xavi Hernandez
6dc5dfef81 Fix compile warnings
This patch fixes compile warnings that appear with newer compilers. The
solution applied is only to remove the warnings, but it doesn't always
solve the problem in the best way. It assumes that the problem will never
happen, as the previous code assumed.

Change-Id: I6e8470d6c2e2dbd3bd7d324b5fd2f92ffdc3d6ec
updates: bz#1193929
Signed-off-by: Xavi Hernandez <xhernandez@redhat.com>
2018-07-10 16:28:24 +02: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
Kotresh HR
2d5b179d1a rpc: Don't reset auth_value in disconnect
The auth_value was being reset to AUTH_GLUSTERFS_v2
during rpc disconnect. It shoud not be reset. The
disconnect during portmap request can race with
handshake. If handshake happens first and
disconnect later, auth_value would set to default
value and it never sets back to actual auth_value

fixes: bz#1579276
Change-Id: Ib46c9e01a97f6defb3fd1e0423fdb4b899b4a361
Signed-off-by: Kotresh HR <khiremat@redhat.com>
2018-05-24 05:26:14 +00:00
Shreyas Siravara
20fb08d525 rpc: update tirpc registration to "force" unregister old mapping before re-registering
> Reviewed-on: https://review.gluster.org/16849
> Reviewed-by: Shreyas Siravara <sshreyas@fb.com>

Change-Id: I05ed6b7c715a71e5819fbe8116e7c3146010f836
BUG: 1521030
Signed-off-by: Kevin Vigor <kvigor@fb.com>
Signed-off-by: Amar Tumballi <amarts@redhat.com>
2018-03-28 07:38:59 +00:00
Zhang Huan
3b578daaec rpc: simplify parameters when a saved frame is forced to unwind
When a saved frame is to be forced unwind, there is no need to pass an
empty iovector without any data pointed to.

Change-Id: I6e858fb38644326e22239b83272b15db656035e5
BUG: 1523122
Signed-off-by: Zhang Huan <zhanghuan@open-fs.com>
2018-03-28 07:38:10 +00:00
Zhang Huan
f7d6d8579c rpc: fix incorrect return value when xdr decode fails
xdr_replymsg is called to decode reply message, and it returns failure
if the message is corrupted. However, retrieving return value from
the global errno is 0 even xdr_replymsg fails.

Fix this issue by simply returning a negative value if call to
xdr_replymsg fails.

Change-Id: I2b9a1dc97652fbb6cf6568ea617f120713784a55
BUG: 1523122
Signed-off-by: Zhang Huan <zhanghuan@open-fs.com>
2018-03-28 07:37:34 +00:00
Sven Fischer
de52876407 cleanup: xlator_t structure's 'client_latency' variable is not used
- Removed unused struct member and its one time usage.
  - cleaned up wrong white space

member 'client_latency' was not used otherwise since it was added by

commit 07cc8679cdf3b29680f4f105d0222da168d8bfc1
Author: Kevin Vigor <kvigor@fb.com>
Date:   Tue Mar 21 08:23:25 2017 -0700

    Halo Replication feature for AFR translator

Change-Id: Ibb0ea828d4090bbe8897f6af326b317884162a00
BUG: 1495153
Signed-off-by: Sven Fischer <sven@fischer-abc.de>
2018-03-19 03:30:31 +00:00
Kaleb S. KEITHLEY
2bb17551a5 build: address linkage issues
We have the following undefined symbol error from protocol/server.so:

  glusterfs_mgmt_pmap_signout
  glusterfs_autoscale_threads

See https://review.gluster.org/19225 (bz#1532238)
and https://review.gluster.org/19657 (bz#1550895)

(why are there two different bzs for the same bug?)

IMO this is a cleaner solution. I.e. moving the above two functions
to libgfrpc (.../rpc/rpc-lib/...)

I would also, for (foolish) consistency sake, like to see
glusterfs_mgmt_pmap_signin() moved from glusterfsd to libgfrpc as
well.

This works on f28/rawhide, with its new, more restrictive run-time
link semantics. The smoke and regression tests on earlier fedora and
centos will confirm that it works on those platforms too.

Change-Id: I9cfbd1cc15e7ebd9fc31b56ac791287fa2c584de
BUG: 1550895
Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
2018-03-05 09:25:17 -05:00
Milind Changire
7d641313f4 rpcsvc: scale rpcsvc_request_handler threads
Scale rpcsvc_request_handler threads to match the scaling of event
handler threads.

Please refer to https://bugzilla.redhat.com/show_bug.cgi?id=1467614#c51
for a discussion about why we need multi-threaded rpcsvc request
handlers.

Change-Id: Ib6838fb8b928e15602a3d36fd66b7ba08999430b
Signed-off-by: Milind Changire <mchangir@redhat.com>
2018-02-26 15:14:38 +05:30
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
Sheena Artrip
7a4ca270af rpc: Adds rpcbind6 programs to libgfrpc symbols
Building with --with-default-ipv6 causes shared
components of gluster calling the rpcbind6 functions
to fail. Adding the symbols in the list is all that is
necessary. Building without ipv6 keeps the same behavior.

No test cases as this is a build-specific fix.

Change-Id: I248d3291bf17326b07d152d9b79cdcfaf9068f0d
BUG: 1544961
Signed-off-by: Sheena Artrip <sheenobu@fb.com>
2018-02-13 15:05:04 -08:00
Amar Tumballi
d663b9a323 protocol: utilize the version 4 xdr
updates #384

Change-Id: Id80bf470988dbecc69779de9eb64088559cb1f6a
Signed-off-by: Amar Tumballi <amarts@redhat.com>
2018-02-01 11:40:24 +00:00
Poornima G
542af5714d protocol: Implement put fop
Updates #353
Change-Id: I755b9208690be76935d763688fa414521eba3a40
Signed-off-by: Poornima G <pgurusid@redhat.com>
2018-01-31 09:13:58 +00:00