1
0
mirror of https://github.com/gluster/glusterfs.git synced 2026-02-05 15:48:40 +01:00

408 Commits

Author SHA1 Message Date
Môshe van der Sterre
eb4b2cb003 gfapi: Move the SECURE_ACCESS_FILE check out of glfs_mgmt_init
glfs_mgmt_init is only called for glfs_set_volfile_server, but
secure_mgmt is also required to use glfs_set_volfile with SSL.

fixes: #829
Change-Id: Ibc769fe634d805e085232f85ce6e1c48bf4acc66
2020-09-29 14:32:59 +00:00
Xavi Hernandez
9310e319da gfapi: Check the fd argument before accessing it
Some public GFAPI functions did access the fd object without verifying
that it wasn't NULL, causing crashes in some cases.

This patch returns an error code in case it's NULL.

Updates: #1009
Change-Id: I8cadde87ae8d542e0af9b55aa866fe763f97d4fb
Signed-off-by: Xavi Hernandez <xhernandez@redhat.com>
2020-09-25 04:00:15 +00:00
Kaleb S. KEITHLEY
bc09af7737 api: libgfapi symbol versions break LTO in Fedora rawhide/f33
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>
2020-07-03 17:25:43 +00:00
Pranith Kumar K
af89d9e623 cluster/afr: Delay post-op for fsync
Problem:
AFR doesn't delay post-op for fsync fop. For fsync heavy workloads
this leads to un-necessary fxattrop/finodelk for every fsync leading
to bad performance.

Fix:
Have delayed post-op for fsync. Add special flag in xdata to indicate
that afr shouldn't delay post-op in cases where either the
process will terminate or graph-switch would happen. Otherwise it leads
to un-necessary heals when the graph-switch/process-termination
happens before delayed-post-op completes.

Fixes: #1253
Change-Id: I531940d13269a111c49e0510d49514dc169f4577
Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
2020-06-08 13:49:12 +00:00
Xavi Hernandez
3da22f8cb0 syncop: improve scaling and implement more tools
The current scaling of the syncop thread pool is not working properly
and can leave some tasks in the run queue more time than necessary
when the maximum number of threads is not reached.

This patch provides a better scaling condition to react faster to
pending work.

Condition variables and sleep in the context of a synctask have also
been implemented. Their purpose is to replace regular condition
variables and sleeps that block synctask threads and prevent other
tasks to be executed.

The new features have been applied to several places in glusterd.

Change-Id: Ic50b7c73c104f9e41f08101a357d30b95efccfbf
Fixes: #1116
Signed-off-by: Xavi Hernandez <xhernandez@redhat.com>
2020-05-13 16:17:35 +00:00
Soumya Koduri
55914f968d gfapi: Suspend synctasks instead of blocking them
There are certain conditions which blocks the current
execution thread (like waiting on mutex lock or condition
variable or I/O response). In such cases, if it is a
synctask thread, we should suspend the task instead
of blocking it (like done in SYNCOP using synctask_yield)

This is to avoid deadlock like the one mentioned below -

1) synctaskA sets fs->migration_in_progress to 1 and
   does I/O (LOOKUP)
2) Other synctask threads wait for fs->migration_in_progress
  to be reset to 0 by synctaskA and hence blocked
3) but synctaskA cannot resume as all synctask threads are blocked
   on (2).

Note: this same approach is already used by few other components
like syncbarrier etc.

Change-Id: If90f870d663bb242c702a5b86ac52eeda67c6f0d
Fixes: #1146
Signed-off-by: Soumya Koduri <skoduri@redhat.com>
2020-04-07 11:48:42 +00:00
Sunny Kumar
34347876bb libgfapi: fix resource leak
This patch fixes resource leak in glfs-fops.c.
CID : 1403873 : Resource leak

updates: bz#789278

Change-Id: I589d4d65d2b074801f7b4b0afd7dc4607d79420e
Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
2020-02-03 06:12:15 +00:00
Yaniv Kaul
9969d1dc2a multiple xlators: reduce key length
In many cases, we were freely allocating long keys with no need.
Smaller char arrays are just fine almost anywhere, so just went ahead
and looked where they we can use smaller ones.

In some cases, annotated the functions as static and the prefixes
passed as const as it was easier to read and understand.

Where relevant, converted the dict functions to use known key length.

Change-Id: I882ab33ea20d90b63278336cd1370c09ffdab7f2
updates: bz#1193929
Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
2020-01-14 17:11:22 +00:00
yatipadia
830a3dc464 api-glfs-fops: structure logging
Convert gf_msg() to gf_smsg()

Change-Id: Iceb40d60a75106c7b4b0a2487b611f7376bccc46
Updates: #657
Signed-off-by: yatipadia <ypadia@redhat.com>
2020-01-14 17:05:10 +00:00
Niklas Hambüchen
4702232a1f api: Fix documentation path in README
Ref: #84
Updates: bz#1193929
Change-Id: If346dbe421d3e301ae035165b2e01ee0a7176d36
Signed-off-by: Amar Tumballi <amarts@gmail.com>
2019-11-13 12:22:23 +05:30
Yaniv Kaul
f737a745b5 rpc: align structs
squash tens of warnings on padding of structs in afr structures.
The warnings were found by manually added '-Wpadded' to the GCC
command line.

Also made relevant structs and definitions static, where it
was applicable.

Change-Id: Ib71a7e9c6179378f072d796d11172d086c343e53
updates: bz#1193929
Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
2019-10-17 06:34:27 +00:00
Purna Pavan Chandra Aekkaladevi
7464ece4b9 libgfapi : Dereference after null check - coverity fix
This patch fixes coverity issue with CID 1405581

A pointer 'volname' is being deferenced (by passing it as an argument to strncmp), even when it points to NULL, leading to segmentation fault.

fix : Adding a NULL check condition beforehand and returning NULL

Change-Id: I18685fa1cb251253996051b83b6790a5d5f0aff9
Updates: bz#789278
Signed-off-by: Purna Pavan Chandra Aekkaladevi <paekkala@redhat.com>
2019-09-30 17:30:22 +00:00
Soumya Koduri
257bb3d16b gfapi: Update the version of 'glfs_h_creat_open'
Change-Id: I43eaa53a7b8d876640d225e011b56192bba57eed
Fixes: bz#1753569
Signed-off-by: Soumya Koduri <skoduri@redhat.com>
2019-09-27 19:36:05 +05:30
Soumya Koduri
41a0f2aa75 gfapi: 'glfs_h_creat_open' - new API to create handle and open fd
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>
2019-09-25 10:47:36 +00:00
Sheetal Pamecha
61d438e738 libgfapi: return correct errno on invalid volume name
glfs_init when called with volume name prefixed by '/'
sets errno to 0. Setting errno to EINVAL to resolve the issue.
Also volname is a parameter to glfs_new.
Thus, validating volname in glfs_new itself and
returning EINVAL from that function

fixes: bz#1507896

Change-Id: I0d4d2423e26cc07644d50ec8cce788ecc639203d
Signed-off-by: Sheetal Pamecha <spamecha@redhat.com>
2019-09-12 08:02:34 +00:00
Barak Sason
72fe2bd9ae api: fixing a coverity issue
Added a null pointer check to avoid seg-fault

CID:1403874
Updates: bz#789278

Change-Id: Ia8ff992c9f06d79647089f296afe77519fb5af2a
Signed-off-by: Barak Sason <bsasonro@redhat.com>
2019-08-20 16:42:06 +00:00
Amar Tumballi
82ebdab276 gfapi: provide version for statedump path
Updates: bz#1689097
Change-Id: I2e3c2a3aef17fda67d04fa9e604ea3f8335a2b0b
Signed-off-by: Amar Tumballi <amarts@redhat.com>
2019-08-13 05:58:58 +00:00
Soumya Koduri
756f903e2a gfapi: Fix deadlock while processing upcall
As mentioned in bug1733166, there could be potential deadlock
while processing upcalls depending on how each xlator choose
to act on it. The right way of fixing such issues
is to change rpc callback communication process.
- https://github.com/gluster/glusterfs/issues/697

Till then, making changes in gfapi layer to avoid any I/O
processing.

Change-Id: I2079e95339e5d761d5060707f4555cfacab95c83
fixes: bz#1733166
Signed-off-by: Soumya Koduri <skoduri@redhat.com>
2019-08-02 14:12:41 +00:00
Amar Tumballi
7124fc6d01 gfapi: increase function-coverage
* Add few more mgmt functions to the coverage
* While testing mgmt function, found an issue, where if the
  'glfs_set_volfile_server()' is not called before calling
  'glfs_unset_volfile_server()', unset would cause a crash.
  Null check of few variables fixes the issue, which is handled
  in this patch itself.
* Added a test for volfile API

Updates: bz#1693692
Change-Id: Iba151f8da1b64107e2f436ddbfef9da45b1c1588
Signed-off-by: Amar Tumballi <amarts@redhat.com>
2019-07-31 00:53:11 +00:00
Xiubo Li
799edc73c3 event: rename event_XXX with gf_ prefixed
I hit one crash issue when using the libgfapi.

In the libgfapi it will call glfs_poller() --> event_dispatch()
in file api/src/glfs.c:721, and the event_dispatch() is defined
by libgluster locally, the problem is the name of event_dispatch()
is the extremly the same with the one from libevent package form
the OS.

For example, if a executable program Foo, which will also use and
link the libevent and the libgfapi at the same time, I can hit the
crash, like:

kernel: glfs_glfspoll[68486]: segfault at 1c0 ip 00007fef006fd2b8 sp
00007feeeaffce30 error 4 in libevent-2.0.so.5.1.9[7fef006ed000+46000]

The link for Foo is:
lib_foo_LADD = -levent $(GFAPI_LIBS)
It will crash.

This is because the glfs_poller() is calling the event_dispatch() from
the libevent, not the libglsuter.

The gfapi link info :
GFAPI_LIBS = -lacl -lgfapi -lglusterfs -lgfrpc -lgfxdr -luuid

If I link Foo like:
lib_foo_LADD = $(GFAPI_LIBS) -levent
It will works well without any problem.

And if Foo call one private lib, such as handler_glfs.so, and the
handler_glfs.so will link the GFAPI_LIBS directly, while the Foo won't
and it will dlopen(handler_glfs.so), then the crash will be hit everytime.

The link info will be:
foo_LADD = -levent
libhandler_glfs_LIBADD = $(GFAPI_LIBS)

I can avoid the crash temporarily by linking the GFAPI_LIBS in Foo too like:
foo_LADD = $(GFAPI_LIBS) -levent
libhandler_glfs_LIBADD = $(GFAPI_LIBS)

But this is ugly since the Foo won't use any APIs from the GFAPI_LIBS.

And in some cases when the --as-needed link option is added(on many dists
it is added as default), then the crash is back again, the above workaround
won't work.

Fixes: #699

Change-Id: I38f0200b941bd1cff4bf3066fca2fc1f9a5263aa
Signed-off-by: Xiubo Li <xiubli@redhat.com>
2019-07-29 04:43:56 +00:00
Yaniv Kaul
7162c8ad9d cli: defer create_frame() (and dict creation) to later stages.
Where possible, defer create_frame() - whenever possible, after
command line verification, for example.

Change-Id: Id6606e90e7ea6190f30b225c4733b229c519bb2f
updates: bz#1193929
Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
2019-07-16 13:34:56 +00:00
Vijay Bellur
3c1efa0c92 Replace usleep() with nanosleep()
As usleep has been obsoleted, changed all invocations of usleep
to nanosleep. From man 3 usleep:

"4.3BSD, POSIX.1-2001.  POSIX.1-2001 declares this function
 obsolete; use nanosleep(2) instead. POSIX.1-2008 removes the
 specification of usleep()."

Added a helper function gf_nanosleep() to have a single place
for handling edge cases that might arise from the conversion of
usleep to nanosleep and allow the sleep to resume with right
remaining value upon being interrupted.

Fixes: bz#1721686

Change-Id: Ia39ab82c9e0f4669d2c00d4cdf25e38d94ef9f62
Signed-off-by: Vijay Bellur <vbellur@redhat.com>
2019-07-11 10:37:52 +00:00
Kinglong Mee
40c18b189f gfapi: set right pargfid according to parent's inode
EC updates parent's inode from loc, when pargfid is not the parent's inode's,
a warnning message is print, and an error is returned to up xlator.

[ec-helpers.c:400:ec_loc_gfid_check] 0-openfs1-disperse-0: Mismatching GFID's in loc

Change-Id: Ie8036be91f039083a1e3fe17ec235a222df84b97
fixes: bz#1723280
Signed-off-by: Kinglong Mee <mijinlong@horiscale.com>
2019-06-25 16:30:00 +00:00
Amar Tumballi
836c7ec096 glfs: add syscall.h after header cleanup
in one of the recent patches, we cleaned-up the unneccesary header
file includes. In the order of merging the patches, there cropped
up an compile error.

updates: bz#1193929
Change-Id: I2ad52aa918f9c698d5273bb293838de6dd50ac31
Signed-off-by: Amar Tumballi <amarts@redhat.com>
2019-06-14 22:38:12 +05:30
Yaniv Kaul
0a6fe8551a multiple files: another attempt to remove includes
There are many include statements that are not needed.
A previous more ambitious attempt failed because of *BSD plafrom
(see https://review.gluster.org/#/c/glusterfs/+/21929/ )

Now trying a more conservative reduction.
It does not solve all circular deps that we have, but it
does reduce some of them. There is just too much to handle
reasonably (dht-common.h includes dht-lock.h which includes
dht-common.h ...), but it does reduce the overall number of lines
of include we need to look at in the future to understand and fix
the mess later one.

Change-Id: I550cd001bdefb8be0fe67632f783c0ef6bee3f9f
updates: bz#1193929
Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
2019-06-14 16:50:32 +00:00
Amar Tumballi
6eaa561526 gfapi: provide an api for setting statedump path
Currently for an application using glfsapi to use glusterfs, when a
statedump is taken, it uses /var/run/gluster dir to dump info.

There can be concerns as this directory may be owned by some other
user, and hence it may fail taking statedump. Such applications
should have an option to use different path.

This patch provides an API to do so.

Updates: bz#1689097
Change-Id: I8918e002bc823d83614c972b6c738baa04681b23
Signed-off-by: Amar Tumballi <amarts@redhat.com>
2019-06-14 05:25:14 +00:00
Soumya Koduri
bc6fd4cfa6 gfapi: fix incorrect initialization of upcall syncop arguments
While sending upcall notifications via synctasks, the argument used to
carry relevant data for these tasks is not initialized properly. This patch
is to fix the same.

Change-Id: I9fa8f841e71d3c37d3819fbd430382928c07176c
fixes: bz#1718316
Signed-off-by: Soumya Koduri <skoduri@redhat.com>
2019-06-14 04:21:35 +00:00
Amar Tumballi
e7aeab3063 across: clang-scan: fix NULL dereferencing warnings
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>
2019-06-04 10:30:29 +00:00
Sheetal Pamecha
1587a6730e api/glfsxmp.c: minor fixes
* add more fops: f{get,set,list,remove}xattr(), access(), fstat(), fsetattr(),
getxattr(), lgetxattr(), llistxattr(), lsetxattr(), fgetxattr()
* handle some error cases (like volume not found)

Updates: #655
Change-Id: I3334bdf3090eafd83a54e1be12036ea01b181089
Signed-off-by: Amar Tumballi <amarts@redhat.com>
Signed-off-by: Sheetal Pamecha <spamecha@redhat.com>
2019-05-26 14:15:10 +00:00
Xavi Hernandez
d8eadde7d4 core: avoid dynamic TLS allocation when possible
Some interdependencies between logging and memory management functions
make it impossible to use the logging framework before initializing
memory subsystem because they both depend on Thread Local Storage
allocated through pthread_key_create() during initialization.

This causes a crash when we try to log something very early in the
initialization phase.

To prevent this, several dynamically allocated TLS structures have
been replaced by static TLS reserved at compile time using '__thread'
keyword. This also reduces the number of error sources, making
initialization simpler.

Updates: bz#1193929
Change-Id: I8ea2e072411e30790d50084b6b7e909c7bb01d50
Signed-off-by: Xavi Hernandez <xhernandez@redhat.com>
2019-04-24 03:26:48 +00:00
Soumya Koduri
4a03a71c61 gfapi: Unblock epoll thread for upcall processing
With commit#ad35193,we have made changes to offload
processing upcall notifications to synctask so as not
to block epoll threads. However seems like the issue wasnt
fully addressed.

In "glfs_cbk_upcall_data" -> "synctask_new1" after creating synctask
if there is no callback defined, the thread waits on synctask_join
till the syncfn is finished. So that way even with those changes,
epoll threads are blocked till the upcalls are processed.

Hence the right fix now is to define a callback function for that
synctask "glfs_cbk_upcall_syncop" so as to unblock epoll/notify threads
completely and the upcall processing can happen in parallel by synctask
threads.

Change-Id: I4d8645e3588fab2c3ca534e0112773aaab68a5dd
fixes: bz#1693575
Signed-off-by: Soumya Koduri <skoduri@redhat.com>
2019-03-29 07:24:27 +00:00
Ravishankar N
08d502c3b0 gfapi: add function to set client-pid
This api offers the ability to set the pid of a client to a particular
value, identical to how gluster fuse clients provide the --client-pid
option. This is an internal API to be used by gluster processes only. See
https://lists.gluster.org/pipermail/gluster-devel/2019-March/055925.html
for more details. Currently glfsheal is the only proposed consumer.

updates: bz#1689250
Change-Id: I0620be2127d79d69cdd57cffb29bba44e6e5da1f
Signed-off-by: Ravishankar N <ravishankar@redhat.com>
2019-03-26 15:25:07 +00:00
Mohammed Rafi KC
f2f07591b2 rpc/transport: Missing a ref on dict while creating transport object
while creating rpc_tranpsort object, we store a dictionary without
taking a ref on dict but it does an unref during the cleaning of the
transport object.

So the rpc layer expect the caller to take a ref on the dictionary
before passing dict to rpc layer. This leads to a lot of confusion
across the code base and leads to ref leaks.

Semantically, this is not correct. It is the rpc layer responsibility
to take a ref when storing it, and free during the cleanup.

I'm listing down the total issues or leaks across the code base because
of this confusion. These issues are currently present in the upstream
master.

1) changelog_rpc_client_init

2) quota_enforcer_init

3) rpcsvc_create_listeners : when there are two transport, like tcp,rdma.

4) quotad_aggregator_init

5) glusterd: init

6) nfs3_init_state

7) server: init

8) client:init

This patch does the cleanup according to the semantics.

Change-Id: I46373af9630373eb375ee6de0e6f2bbe2a677425
updates: bz#1659708
Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com>
2019-03-20 13:24:44 +00:00
Arjun Sharma
2e9d3ab12d Updating the glfs_setattr and glfs_fsetattr public APIs to use glfs_stat
Change-Id: I0e86c8222c88b4c71087ec287ba81f8353d70822
updates: #389
Signed-off-by: Arjun <arjsharm@redhat.com>
2019-02-27 13:12:49 +00:00
ShyamsundarR
ddcb3c7438 api: Update all future API versions to rel-6
As release 6 is branched, all future APIs now become 6.0

This change implements the same.

Change-Id: I6db368b4dc8585278ec11d4a411adcd04635de53
Updates: bz#1193929
Signed-off-by: ShyamsundarR <srangana@redhat.com>
2019-02-07 12:21:43 +00:00
Kaleb S. KEITHLEY
4aee035cd2 api: bad GFAPI_4.1.6 block
missing global: line, tabs not spaces

Change-Id: Icdbc23b4e4cd608da1d764e81757201c4b1269a6
updates: bz#1193929
Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
2019-01-30 07:01:09 +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
Arjun
213f31bf9e gfapi : making glfs_setattr/glfs_fsetattr as public
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>
2019-01-16 06:24:45 +00:00
Mohit Agrawal
211521f039 core: Resolve dict_leak at the time of destroying graph
Problem: In gluster code some of the places it call's get_new_dict
         to create a dictionary without taking reference so at the time
         of dict_unref it has become a leak

Solution: To resolve the same call dict_new instead of get_new_dict

updates bz#1650403
Change-Id: I3ccbbf5af07079a4fa09aad2cd0458c8625b2f06
Signed-off-by: Mohit Agrawal <moagrawal@redhat.com>
2019-01-14 04:01:54 +00:00
ShyamsundarR
1a3c2a48e7 gfapi: update returned/callback pre/post attributes to glfs_stat
Change-Id: Ie0fe971e694101aa011d66aa496d0644669c2c5a
Updates: #389
Signed-off-by: Kinglong Mee <mijinlong@open-fs.com>
Signed-off-by: ShyamsundarR <srangana@redhat.com>
2019-01-07 14:43:27 +00:00
ShyamsundarR
c31f1c232a gfapi: new api glfs_statx as linux's statx
Change-Id: I44dd6ceef0954ae7fc13f920e84d81bbd3f6a774
Updates: #389
Signed-off-by: Kinglong Mee <mijinlong@open-fs.com>
Signed-off-by: ShyamsundarR <srangana@redhat.com>
2019-01-07 14:43:27 +00:00
Kinglong Mee
f99f51ca87 glfs-fops.c: fix the bad string length for snprintf
Snprintf reserves one byte for the ending '\0'.
A NAME_MAX bytes d_name is truncated to NAME_MAX - 1 bytes.

Change-Id: Ic884d18cee24360e55ddb896dc587b0b74ef97fe
updates: bz#1193929
Signed-off-by: Kinglong Mee <mijinlong@open-fs.com>
2019-01-07 09:20:21 +00:00
Soumya Koduri
d9a8ccd354 gfapi: nit cleanup related to releasing fs->mutex lock
This is follow-up patch to the comment received for
 - https://review.gluster.org/#/c/glusterfs/+/21882

We need not hold the fs->mutex lock to log error message.

Change-Id: I29d2ea2e6cfecc3dd94982bd48f4bc9f11cc3aac
fixes: bz#1660577
Signed-off-by: Soumya Koduri <skoduri@redhat.com>
2018-12-31 16:10:04 +00:00
Sunny Kumar
1ea203d6b6 libgfapi : fix coverity issue
This patch fixes coverity issue in api/src/glfs-fops.c.

CID: 1389247, 1389296, 1389369, 1389392.
All coverity defects are of type Mixing enum types (MIXED_ENUMS).

updates: bz#789278

Change-Id: I007bb317ed5f0b8ddaf94a93b3a4d02b1e74cb8d
Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
2018-12-31 06:51:07 +00:00
Soumya Koduri
8fe3c6107a gfapi: Access fs->oldvolfile under mutex lock
In some cases (for eg., when there are multiple
RPC_CLNT_CONNECT notifications), multiple threads may fetch
volfile and try to update it in 'fs' object simultaneously.
Hence protect those variables' access under fs->mutex lock.

Change-Id: Idaee9548560db32d83f4c04ebb1f375fee7864a9
fixes: bz#1660577
Signed-off-by: Soumya Koduri <skoduri@redhat.com>
2018-12-25 17:36:01 +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
Amar Tumballi
af7e957b49 xlator: make 'xlator_api' mandatory
* Remove the options to load old symbol.
* keep only 'xlator_api' symbol from being exported using xlator.sym
* add xlator_api to all the xlators where its missing

NOTE: This covers all the xlators which has at least a test case
to validate its loading. If there is a translator, which doesn't
have any test, then we should probably remove that from codebase.

fixes: #164
Change-Id: Ibcdc8c9844cda6b4463d907a15813745d14c1ebb
Signed-off-by: Amar Tumballi <amarts@redhat.com>
2018-12-13 14:41:50 +05:30
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
Soumya Koduri
ad35193718 gfapi: Offload callback notifications to synctask
Upcall notifications are received from server via epoll
and same thread is used to forward these notifications
to the application. This may lead to deadlock and hang
in the following scenario.

Consider if as part of handling these callbacks,
application has to do some operations which involve
sending I/Os to gfapi stack which inturn have to wait for
epoll threads to receive repsonse. Thus this may lead to
deadlock if all the epoll threads are waiting to complete
these callback notifications.

To address it, instead of using epoll thread itself,
make use of synctask to send those notificaitons to the
application.

Change-Id: If614e0d09246e4279b9d1f40d883a32a39c8fd90
updates: bz#1648768
Signed-off-by: Soumya Koduri <skoduri@redhat.com>
2018-11-26 04:20:05 +00:00