97 Commits

Author SHA1 Message Date
Jeff Darcy
1fbffa0aa4 api: add glfs_get_volfile
From the API-header description:

> Sometimes it's useful e.g. for scripts to see the volfile, so that
> they can parse it and find subvolumes to do things like split-brain
> resolution or custom layouts.  The API here was specifically intended
> to make access e.g. from Python as simple as possible.
>
> Note that the volume must be started (not necessarily mounted) for
> this to work.

Change-Id: If3f55ee9611cdf4b77aa53659f0af0d21957817d
Signed-off-by: Jeff Darcy <jdarcy@redhat.com>
Reviewed-on: http://review.gluster.org/7183
Reviewed-by: Anand Avati <avati@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
2014-03-05 21:29:42 -08:00
Poornima G
ff0cd7c4e3 libgfapi: In glfs_resolve_at(), do not override the previous return value.
Overriding ret to contain glfs_loc_touchup()s' return value implies that
if glfs_loc_touchup() is successful, glfs_resolve_at() is also successful
which is not necessarily true. This was causing glfs_resolve_at() to
succeed even if it couldn't resolve, thus create and other fops would
fail. Hence overriding ret only if glfs_loc_touchup() fails.

Change-Id: I0804afbd120b3798abe07e870bfc40bf162bc289
BUG: 1066837
Signed-off-by: Poornima G <pgurusid@redhat.com>
Reviewed-on: http://review.gluster.org/7125
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
2014-02-19 17:09:30 -08:00
Jose A. Rivera
5f0a857c70 libgfapi: Add proper NULL checks
Two spots check for NULL after the pointer in question has already been
dereferenced. Checked for NULL (and set errno when needed) at appripriate
spots, added a few NULL checks further up the stack, and some whitespace
cleanup.

BUG: 789278
CID: 1124800
CID: 1124805

Change-Id: I1dd4ad3f285cca36f4e3f739288f154ec120aebb
Signed-off-by: Jose A. Rivera <jarrpa@redhat.com>
Reviewed-on: http://review.gluster.org/6908
Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
2014-02-14 07:10:59 -08:00
Anand Avati
0cab34b3a5 core: add @xdata parameter to syncop_[f]removexattr()
To be used in afr metadata self-heal

Change-Id: I8dac4b19d61e331702427eeb5b606aab3d20b328
BUG: 1021686
Signed-off-by: Anand Avati <avati@redhat.com>
Reviewed-on: http://review.gluster.org/6941
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Raghavendra Bhat <raghavendra@redhat.com>
2014-02-13 11:17:05 -08:00
Jose A. Rivera
ff28179310 libgfapi: Don't ignore return value of glfs_loc_touchup()
BUG: 789278
CID: 1124353

Change-Id: I7d2958cbc98faf45d723f17868c515762c50c618
Signed-off-by: Jose A. Rivera <jarrpa@redhat.com>
Reviewed-on: http://review.gluster.org/6931
Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
2014-02-08 11:21:52 -08:00
Jose A. Rivera
c0ac212223 libgfapi: Remove useless call to lstat
There's no need to lstat cmd_args->volfile, since we already
check to see if fopen fails. The error message was largely the
same.

BUG: 789278
CID: 1124869

Change-Id: I10827154b32c72d2e4a1ab0d3c1e464f8af6ffee
Signed-off-by: Jose A. Rivera <jarrpa@redhat.com>
Reviewed-on: http://review.gluster.org/6783
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
2014-01-24 23:46:48 -08:00
Jose A. Rivera
8814fdafab libgfapi: Fix pointer dereference before NULL check
ctx is not checked for NULL before it is dereferenced, though the
check in "err" seems to suggest we should guard against it.

BUG: 789278
CID: 1124827

Change-Id: I6ed0b42992af5f370cce9aa2feb56811cdd54b42
Signed-off-by: Jose A. Rivera <jarrpa@redhat.com>
Reviewed-on: http://review.gluster.org/6782
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
2014-01-24 23:46:35 -08:00
Jose A. Rivera
bb63256b7e libgfapi: Fix pointer dereference before NULL check
Call to dict_keys_join dereferences xattr before it is checked
for NULL. Restructured the function to check for NULL earlier and
call dict_unref only when needed.

BUG: 789278
CID: 1124826

Change-Id: I732fa304ad6f3b921c589832d13f73bbd36f589c
Signed-off-by: Jose A. Rivera <jarrpa@redhat.com>
Reviewed-on: http://review.gluster.org/6763
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
2014-01-24 01:41:59 -08:00
Pranith Kumar K
8d55c25f15 syncop: Change return value of syncop
Problem:
We found a day-1 bug when syncop_xxx() infra is used inside a synctask with
compilation optimization (CFLAGS -O2).

Detailed explanation of the Root cause:
We found the bug in 'gf_defrag_migrate_data' in rebalance operation:

Lets look at interesting parts of the function:

int
gf_defrag_migrate_data (xlator_t *this, gf_defrag_info_t *defrag, loc_t *loc,
                        dict_t *migrate_data)
{
.....
code section - [ Loop ]
        while ((ret = syncop_readdirp (this, fd, 131072, offset, NULL,
                                       &entries)) != 0) {
.....
code section - [ ERRNO-1 ] (errno of readdirp is stored in readdir_operrno by a
thread)
                /* Need to keep track of ENOENT errno, that means, there is no
                   need to send more readdirp() */
                readdir_operrno = errno;
.....
code section - [ SYNCOP-1 ] (syncop_getxattr is called by a thread)
                        ret = syncop_getxattr (this, &entry_loc, &dict,
                                               GF_XATTR_LINKINFO_KEY);
code section - [ ERRNO-2]   (checking for failures of syncop_getxattr(). This
may not always be executed in same thread which executed [SYNCOP-1])
                        if (ret < 0) {
                                if (errno != ENODATA) {
                                        loglevel = GF_LOG_ERROR;
                                        defrag->total_failures += 1;
.....
}

the function above could be executed by thread(t1) till [SYNCOP-1] and code
from [ERRNO-2] can be executed by a different thread(t2) because of the way
syncop-infra schedules the tasks.

when the code is compiled with -O2 optimization this is the assembly code that
is generated:
 [ERRNO-1]
1165                        readdir_operrno = errno; <<---- errno gets expanded
as *(__errno_location())
   0x00007fd149d48b60 <+496>:        callq  0x7fd149d410c0 <address@hidden>
   0x00007fd149d48b72 <+514>:        mov    %rax,0x50(%rsp) <<------ Address
returned by __errno_location() is stored in a special location in stack for
later use.
   0x00007fd149d48b77 <+519>:        mov    (%rax),%eax
   0x00007fd149d48b79 <+521>:        mov    %eax,0x78(%rsp)
....
 [ERRNO-2]
1281                                        if (errno != ENODATA) {
   0x00007fd149d492ae <+2366>:        mov    0x50(%rsp),%rax <<-----  Because
it already stored the address returned by __errno_location(), it just
dereferences the address to get the errno value. BUT THIS CODE NEED NOT BE
EXECUTED BY SAME THREAD!!!
   0x00007fd149d492b3 <+2371>:        mov    $0x9,%ebp
   0x00007fd149d492b8 <+2376>:        mov    (%rax),%edi
   0x00007fd149d492ba <+2378>:        cmp    $0x3d,%edi

The problem is that __errno_location() value of t1 and t2 are different. So
[ERRNO-2] ends up reading errno of t1 instead of errno of t2 even though t2 is
executing [ERRNO-2] code section.

When code is compiled without any optimization for [ERRNO-2]:
1281                                        if (errno != ENODATA) {
   0x00007fd58e7a326f <+2237>:        callq  0x7fd58e797300
<address@hidden><<--- As it is calling __errno_location() again it gets the
location from t2 so it works as intended.
   0x00007fd58e7a3274 <+2242>:        mov    (%rax),%eax
   0x00007fd58e7a3276 <+2244>:        cmp    $0x3d,%eax
   0x00007fd58e7a3279 <+2247>:        je     0x7fd58e7a32a1
<gf_defrag_migrate_data+2287>

Fix:
Make syncop_xxx() return (-errno) value as the return value in
case of errors and all the functions which make syncop_xxx() will need to use
(-ret) to figure out the reason for failure in case of syncop_xxx() failures.

Change-Id: I314d20dabe55d3e62ff66f3b4adb1cac2eaebb57
BUG: 1040356
Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
Reviewed-on: http://review.gluster.org/6475
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
2014-01-19 23:05:15 -08:00
Harshavardhana
c2b09dc87e build: Start using library versioning for various libraries
According to libtool three individual numbers stand for
CURRENT:REVISION:AGE, or C:R:A for short. The libtool
script typically tacks these three numbers onto the end
of the name of the .so file it creates. The formula for
calculating the file numbers on Linux and Solaris is

   /path/to/library/<library_name>.(C - A).(A).(R)

As you release new versions of your library, you will
update the library's C:R:A. Although the rules for changing
these version numbers can quickly become confusing, a few
simple tips should help keep you on track. The libtool
documentation goes into greater depth.

In essence, every time you make a change to the library and
release it, the C:R:A should change. A new library should start
with 0:0:0. Each time you change the public interface
(i.e., your installed header files), you should increment the
CURRENT number. This is called your interface number. The main
use of this interface number is to tag successive revisions
of your API.

The AGE number is how many consecutive versions of the API the
current implementation supports. Thus if the CURRENT library
API is the sixth published version of the interface and it is
also binary compatible with the fourth and fifth versions
(i.e., the last two), the C:R:A might be 6:0:2. When you break
binary compatibility, you need to set AGE to 0 and of course
increment CURRENT.

The REVISION marks a change in the source code of the library
that doesn't affect the interface-for example, a minor bug fix.
Anytime you increment CURRENT, you should set REVISION back to 0.

Change-Id: Id72e74c1642c804fea6f93ec109135c7c16f1810
BUG: 862082
Signed-off-by: Harshavardhana <harsha@harshavardhana.net>
Reviewed-on: http://review.gluster.org/5645
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Niels de Vos <ndevos@redhat.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
2014-01-18 08:51:14 -08:00
Lalatendu Mohanty
c9008fe6a1 libgfapi: Fixing possible dereferencing of null pointer "glfd"
Fix: Putting a check so that pointer derefrence does not happen
when "gfld" is null

Change-Id: I281b10be445bbeec3a2728fc139d5ac94372e5b6
BUG: 789278
Signed-off-by: Lalatendu Mohanty <lmohanty@redhat.com>
Reviewed-on: http://review.gluster.org/6697
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
2014-01-16 00:58:49 -08:00
Lalatendu Mohanty
f9162911e8 libgfapi : Fixing some NULL pointer dereferencing issues.
1. Fixing dereferencing null pointer "gio"
2. Checking "frame" before calling STACK_DESTROY (frame->root)

Change-Id: If2ce8804a8e9f3f99f71a8c0d13900afb5635072
Signed-off-by: Lalatendu Mohanty <lmohanty@redhat.com>
Reviewed-on: http://review.gluster.org/6313
Reviewed-by: Santosh Pradhan <spradhan@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com>
Reviewed-by: Raghavendra Talur <rtalur@redhat.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
2014-01-09 22:45:05 -08:00
Poornima G
0d7279d32d gfapi: Closed the logfile fd and initialize to NULL in glfs_fini
Currently if logfile is closed and other threads call gf_log
after glfs_fini() is executed, it may lead to memory corruption.
Adding gf_log_fini() which closes the logfile and initializes
the logfile to NULL, thus any further logging happens to stderr.
Also added gf_log_globals_fini() which should be filled in the
future to release all the logging resources.

Change-Id: I879163e1a3636e65300d166f782517ee773cab65
BUG: 1030228
Signed-off-by: Poornima G <pgurusid@redhat.com>
Reviewed-on: http://review.gluster.org/6552
Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
2013-12-26 03:16:30 -08:00
Kaleb S. KEITHLEY
1731253487 gfapi: add __THROW [(__attribute) ((__nothrow__))] to fn decls for C++ users.
Off hand I don't know of anything written in C++ that is or could be a user
of gfapi.

Never the less, it's possible that one could exist, or be written, and
marking the library entry points is a) friendly, b) possibly allows the
C++ compiler to generate better code, and c) is a good practice when
writing APIs that might be consumed by C++ applications. Considering we
already take the first step and use __BEGIN_DECLS/__END_DECLS to be C++
friendly, we should take the extra step

Change-Id: Ib319ecaa452a46f258a9c6e8c7221454d2fefd0f
Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
Reviewed-on: http://review.gluster.org/6393
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
2013-12-03 10:01:59 -08:00
Anand Avati
544dee895a syncops: expose @flags in syncop_rmdir()
Change-Id: I9b73c1db728e4cb3948fc118cceb292b21d48b96
BUG: 1021686
Signed-off-by: Anand Avati <avati@redhat.com>
Reviewed-on: http://review.gluster.org/6112
Reviewed-by: Amar Tumballi <amarts@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
2013-11-21 13:08:32 -08:00
Bharata B Rao
884a668a9c zerofill: Change the type of len argument of glfs_zerofill() to off_t
glfs_zerofill() can be potentially called to zero-out entire file and
hence allow for bigger value of length parameter.

Change-Id: I75f1d11af298915049a3f3a7cb3890a2d72fca63
BUG: 1028673
Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
Reviewed-on: http://review.gluster.org/6266
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: M. Mohan Kumar <mohan@in.ibm.com>
Tested-by: M. Mohan Kumar <mohan@in.ibm.com>
Reviewed-by: Anand Avati <avati@redhat.com>
2013-11-14 23:29:48 -08:00
Poornima
2990befa4c gfapi: Closed the logfile fd in glfs_fini
The logfile fd is not closed even after calling glfs_fini,
hence in smb mount if connection to glusterfs volume fails
at a point after the log file was opened, the fd would remain
open until the process dies.

This patch closes the logfile fd in glfs_fini.

Change-Id: I608bfac9c6833b42750b0383ad26fd33ee378ee1
BUG: 1030228
Signed-off-by: Poornima <pgurusid@redhat.com>
Reviewed-on: http://review.gluster.org/6263
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
2013-11-14 10:39:55 -08:00
Anand Avati
c1109ed6c6 gfapi: introduce glfs_readdir() and glfs_readdirplus() APIs
Change-Id: I6b233bf647585675f233898351bf593f251716cc
BUG: 839950
Signed-off-by: Anand Avati <avati@redhat.com>
Reviewed-on: http://review.gluster.org/6201
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Raghavendra Talur <rtalur@redhat.com>
2013-11-13 10:48:18 -08:00
M. Mohan Kumar
c8fef37c5d glusterfs: zerofill support
Add support for a new ZEROFILL fop. Zerofill writes zeroes to a file in
the specified range. This fop will be useful when a whole file needs to
be initialized with zero (could be useful for zero filled VM disk image
provisioning or  during scrubbing of VM disk images).

Client/application can issue this FOP for zeroing out. Gluster server
will zero out required range of bytes ie server offloaded zeroing. In
the absence of this fop,  client/application has to repetitively issue
write (zero) fop to the server, which is very inefficient method because
of the overheads involved in RPC calls  and acknowledgements.

WRITESAME is a  SCSI T10 command that takes a block of data as input and
writes the same data to other blocks and this write is handled
completely within the storage and hence is known as offload . Linux ,now
has support for SCSI WRITESAME command which is exposed to the user in
the form of BLKZEROOUT ioctl.  BD Xlator can exploit BLKZEROOUT ioctl to
implement this fop. Thus zeroing out operations can be completely
offloaded to the storage device , making it highly efficient.

The fop takes two arguments offset and size. It zeroes out 'size' number
of bytes in an opened file starting from 'offset' position.

This patch adds zerofill support to the following areas:
	- libglusterfs
	- io-stats
	- performance/md-cache,open-behind
	- quota
	- cluster/afr,dht,stripe
	- rpc/xdr
	- protocol/client,server
	- io-threads
	- marker
	- storage/posix
	- libgfapi

Client applications can exloit this fop by using glfs_zerofill introduced in
libgfapi.FUSE support to this fop has not been added as there is no system call
for this fop.

Changes from previous version 3:
* Removed redundant memory failure log messages

Changes from previous version 2:
* Rebased and fixed build error

Changes from previous version 1:
* Rebased for latest master

TODO :
     * Add zerofill support to trace xlator
     * Expose zerofill capability as part of gluster volume info

Here is a performance comparison of server offloaded zeofill vs zeroing
out using repeated writes.

[root@llmvm02 remote]# time ./offloaded aakash-test log 20

real	3m34.155s
user	0m0.018s
sys	0m0.040s
[root@llmvm02 remote]# time ./manually aakash-test log 20

real	4m23.043s
user	0m2.197s
sys	0m14.457s
[root@llmvm02 remote]# time ./offloaded aakash-test log 25;

real	4m28.363s
user	0m0.021s
sys	0m0.025s
[root@llmvm02 remote]# time ./manually aakash-test log 25

real	5m34.278s
user	0m2.957s
sys	0m18.808s

The argument log is a file which we want to set for logging purpose and
the third argument is size in GB .

As we can see there is a performance improvement of around 20% with this
fop.

Change-Id: I081159f5f7edde0ddb78169fb4c21c776ec91a18
BUG: 1028673
Signed-off-by: Aakash Lal Das <aakash@linux.vnet.ibm.com>
Signed-off-by: M. Mohan Kumar <mohan@in.ibm.com>
Reviewed-on: http://review.gluster.org/5327
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
2013-11-10 21:25:49 -08:00
Anand Avati
c80794079a gfapi: remove unnecessary call to glfs_resolve_base()
Calling glfs_resolve_base() on the root inode for every resolver
invocation is unnecessary and wasteful.

Here are the results from running a test program which performs
path based operations (creates and deletes 1000 files):

Without patch:
[root@blackbox ~]# sync
[root@blackbox ~]# time ./a.out 1

real    0m4.314s
user    0m1.923s
sys     0m1.144s
[root@blackbox ~]# sync
[root@blackbox ~]# time ./a.out 1

real    0m4.383s
user    0m1.940s
sys     0m1.177s
[root@blackbox ~]# sync
[root@blackbox ~]# time ./a.out 1

real    0m4.339s
user    0m1.863s
sys     0m1.129s

With patch:

[root@blackbox ~]# sync
[root@blackbox ~]# time ./a.out 1

real    0m3.005s
user    0m1.162s
sys     0m0.816s
[root@blackbox ~]# sync
[root@blackbox ~]# time ./a.out 1

real    0m3.188s
user    0m1.222s
sys     0m0.867s
[root@blackbox ~]# sync
[root@blackbox ~]# time ./a.out 1

real    0m2.999s
user    0m1.131s
sys     0m0.832s

Change-Id: Id160a24f44b4dccfcfce99a6f69ddb8938523cd5
BUG: 953694
Signed-off-by: Anand Avati <avati@redhat.com>
Reviewed-on: http://review.gluster.org/6131
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Raghavendra Talur <rtalur@redhat.com>
Reviewed-by: Raghavendra Bhat <raghavendra@redhat.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
2013-11-07 23:55:59 -08:00
Lalatendu Mohanty
f42a764924 libgfapi: fixing tabs in glfsxmp.c with whitespace
Just replacing tabs with whitespace. No code changes present
in this patch

Change-Id: Ic3f64f5a52b0ab5e5c9fe9f45113901dec751e68
Signed-off-by: Lalatendu Mohanty <lmohanty@redhat.com>
Reviewed-on: http://review.gluster.org/6148
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com>
Reviewed-by: Santosh Pradhan <spradhan@redhat.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
2013-10-27 22:50:11 -07:00
Krutika Dhananjay
93c49c6e8c gfapi: fix mem-types initialisation
... and also fill the body of mem_acct_init().

Change-Id: I457d0629c20f999dd2f50e710c75b1c7575b6c19
BUG: 1021904
Signed-off-by: Krutika Dhananjay <kdhananj@redhat.com>
Reviewed-on: http://review.gluster.org/6134
Reviewed-by: Amar Tumballi <amarts@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
2013-10-24 13:56:13 -07:00
Anand Avati
7ebcf96c94 gfapi: wake migration waiters after migration
Wake call threads which are waiting on migration to complete with
a cond_broadcast. Else if any call which arrives right when migration
is attempted will end up hanging indefinitely.

Change-Id: I7df5298f93998d9a54fb12c16654e62333018ece
BUG: 953694
Signed-off-by: Anand Avati <avati@redhat.com>
Reviewed-on: http://review.gluster.org/6111
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Raghavendra Bhat <raghavendra@redhat.com>
Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com>
2013-10-22 09:33:39 -07:00
Krishnan Parthasarathi
dfa08fe058 gfapi: fix return value of glfs_fini
Change-Id: I5b90c7602334226a978bbdae2f9516e8701b403f
BUG: 1004519
Signed-off-by: Krishnan Parthasarathi <kparthas@redhat.com>
Reviewed-on: http://review.gluster.org/6092
Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
2013-10-17 12:49:28 -07:00
Lalatendu Mohanty
656db3a8e0 libgfapi: Fix to compilation failure/warnings for examples/glfsxmp.c
The comilation of glfsxmp.c i.e. "make glfsxmp" was failing
with "undefined reference to `clock_gettime'" error.

Fixed all compilation warnings for unused variables and
wrong formart specifier in printf e.g. : "format ‘%d’ expects
argument of type ‘int’, but argument 3 has type ‘__syscall_slong_t’
[-Wformat]"

Also added the compilation steps for glfsxmp.c in the
README file

Change-Id: I399ec7c9ad7b6412463c89099d63922caef6749e
Signed-off-by: Lalatendu Mohanty <lmohanty@redhat.com>
Reviewed-on: http://review.gluster.org/6085
Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com>
Reviewed-by: Santosh Pradhan <spradhan@redhat.com>
Tested-by: Shyamsundar Ranganathan <srangana@redhat.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
2013-10-16 00:55:50 -07:00
R.Shyamsundar
d573f170cf gfapi: object handle based API extensions
There is an ongoing effort to integrate NFS Ganesha (
https://github.com/nfs-ganesha/nfs-ganesha/wiki ) with GlusterFS as one of
the file system back ends.

Towards this we need extensions to gfapi that can handle object based
operations. Meaning, instead of using full paths or relative paths from
cwd, it is required that we can work with APIs, like the *at POSIX
variants, to be able to create, lookup, open etc. files and directories.
Hence the objects are the files or directories themselves and we give out
handles to these objects that can be used for further operations.

This code drop is an initial implementation of the proposed APIs.

The new APIs are implemented as glfs_h_XXX variants in the file
glfs-handleops.c to mirror glfs-fops.c style. The code leverages holding
onto inode references and doling these out as opaque/cookie type objects to
the callers, to enable them to be used as handles in other operations.

An fd based approach was considered, but due to the extra footprint that
the fd structure and its counterparts would incur, this was dropped to take
the approach of holding inode references themselves.

Tested by extending glfsxmp.c to invoke and exercise the added APIs, and
further tested with a reference integration of the same as an FSAL with NFS
Ganesha.

Change-Id: I23629c99e905b54070fa2e6565147812e5f3fa5d
BUG: 1016000
Signed-off-by: R.Shyamsundar <srangana@redhat.com>
Reviewed-on: http://review.gluster.org/5936
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
2013-10-11 12:16:46 -07:00
Poornima
d3558ae5c4 gfapi: Fix iobuf leaks in gfapi
In glfs_readv, if syncop_readv() fails with return value <= 0
the iobref was not being unrefd which would cause iobuf leaks.

Change-Id: I9850ae149e53cf75ba26f8b5f4c5446cce4b5991
BUG: 1018176
Signed-off-by: Poornima <pgurusid@redhat.com>
Reviewed-on: http://review.gluster.org/6074
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
2013-10-11 12:05:55 -07:00
Raghavendra Bhat
dcfe4ab475 glusterfsd, libgfapi: destroy the temporary graphs constructed for comparison
* The new and the oldgraphs which have been constructed whenever there is
  a volfile change (either reconfigure of the existing graph or creating
  a new graph) for comparison should be freed. Otherwise frequent graph
  changes will lead to huge memory leak

Change-Id: I4faddb1aa9393b34cd2de6732e537a60f600026a
BUG: 948178
Signed-off-by: Raghavendra Bhat <raghavendra@redhat.com>
Reviewed-on: http://review.gluster.org/5388
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
2013-10-03 21:32:43 -07:00
Niels de Vos
c499ef86a2 gfapi.py: support dynamic loading of versioned libraries
Currently gfapi.py only loads libraries by filename ending in ".so".  On
an installed system without development packages, the <lib>.so filenames
are not available. ctypes.util.find_library() can be used to detect the
files dynamically.

In addition to this, also fixing some minor indention errors and package
the library into the Python site-packages path. Python applications and
libraries can now access libgfapi through 'from glusterfs import gfapi'.

Change-Id: I71e38dabd3ade5dcf24813bf2fc25cda91b571c6
BUG: 1005146
Signed-off-by: Niels de Vos <ndevos@redhat.com>
Reviewed-on: http://review.gluster.org/5835
Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
2013-10-02 13:04:03 -07:00
Anand Avati
84fa8af38d core: block unused signals in created threads
Block all signal except those which are set for explicit handling
in glusterfs_signals_setup(). Since thread spawning code in
libglusterfs and xlators can get called from application threads
when used through libgfapi, it is necessary to do this blocking.

Change-Id: Ia320f80521a83d2edcda50b9ad414583a0175281
BUG: 1011662
Signed-off-by: Anand Avati <avati@redhat.com>
Reviewed-on: http://review.gluster.org/5995
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Amar Tumballi <amarts@redhat.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
2013-09-25 01:33:16 -07:00
Vijay Bellur
aa971f439d logging: Expose set_log_file_path() in libglusterfs.
This patch also changes the behavior of glfs_set_logging().
If logfile argument is not provided to glfs_set_logging(),
libgfapi uses set_log_file_path() to create a logfile.

Change-Id: I49ec66c7f16f5604ff2f7cf7b365b08a05b5460d
BUG: 764890
Signed-off-by: Vijay Bellur <vbellur@redhat.com>
Reviewed-on: http://review.gluster.org/5910
Reviewed-by: Anand Avati <avati@redhat.com>
Tested-by: Anand Avati <avati@redhat.com>
2013-09-24 12:00:54 -07:00
Anand Avati
d7f7510f21 gfapi: implement a minimial glfs_fini()
At the very least, we should PARENT_DOWN on the currently active
graph and disconnect ourselves from glusterd.

Further cleanups underway.

Change-Id: I9276686a84b0975b5ce272b4cbec1b80920d5c5c
BUG: 1004519
Signed-off-by: Anand Avati <avati@redhat.com>
Reviewed-on: http://review.gluster.org/5788
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Raghavendra Bhat <raghavendra@redhat.com>
Reviewed-by: Amar Tumballi <amarts@redhat.com>
2013-09-17 11:42:12 -07:00
Anand Avati
8eb3898578 gfapi: use native STACK_WIND for read _async() calls
There is little value in using synctask wrappers for async IO
requests, as STACK_WIND is asynchronous by nature already.

Skip going through synctask for read/write async calls.

Change-Id: Ifde331d7c97e0f33426da6ef4377c5ba70dddc06
BUG: 1009134
Signed-off-by: Anand Avati <avati@redhat.com>
Reviewed-on: http://review.gluster.org/5897
2013-09-17 11:41:42 -07:00
Poornima
1955f7dc84 gfapi: store the open/create flags in fd_t object
The flags passed on to open and create calls were not being saved
in the fd_t object, hence the fd migration was failing.

Change-Id: I486bb818477fe4c393d64a711534a082162a0e53
BUG: 1005159
Signed-off-by: Poornima <pgurusid@redhat.com>
Reviewed-on: http://review.gluster.org/5837
Reviewed-by: Amar Tumballi <amarts@redhat.com>
Reviewed-by: Raghavendra Bhat <raghavendra@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
2013-09-06 15:56:57 -07:00
Anand Avati
2a1f445d30 gfapi: apply an upper bound on nested symlink resolution
In case of nested symlink resolution, implement an upper
bound on the number of such nested levels the resolver will
descend. This limit is arbitrary, and set to 2048 nested
levels.

Change-Id: I264e5bd60d317eda97f4e6f49bd5d8694f8664a9
BUG: 1004100
Signed-off-by: Anand Avati <avati@redhat.com>
Reviewed-on: http://review.gluster.org/5768
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Raghavendra Talur <rtalur@redhat.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
2013-09-05 05:26:30 -07:00
Anand Avati
4b317e64ca glusterfs, gfapi: fix symbol clash
The callback structures in both protocol/client and glusterfsd,
gfapi used the same name for the actor table - gluster_cbk_actors.

CBKs are required only for the management connection, and the
actors of protocol/client are NOP functions. This supposed-to-be
NOP function dispatch tabble is actually ending up pointing to
the actor table of glusterfsd or gfapi.

These functions, even though set wrongly, are not even expected
to be called through the protocol/client callback path. Glusterd
however sends the FETCHSPEC (and other) notify callbacks to *all*
connected clients unconditionally, and there is a small period
of time when protocol/client is connected to glusterd for
PORTMAP query. If the FETCHSPEC callback notify is issued in
this window of time, we end up calling the wrong actor in the
client side resulting in a crash.

Change-Id: I605ff7df64c7faf4607369bbf275aedec28e1778
BUG: 1004091
Signed-off-by: Anand Avati <avati@redhat.com>
Reviewed-on: http://review.gluster.org/5767
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Amar Tumballi <amarts@redhat.com>
2013-09-05 05:24:42 -07:00
Raghavendra Talur
479087c1e6 api: Add null check for active_subvol in glfs_close.
Problem:
In glfs_close, NULL value returned by glfs_active_subvol was not
being checked and was causing a crash.

Change-Id: I6eefa60e7b07dee251b98932b1d08a5c2981d3d7
BUG: 1002511
Signed-off-by: Raghavendra Talur <rtalur@redhat.com>
Reviewed-on: http://review.gluster.org/5733
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
2013-08-29 14:11:50 -07:00
Raghavendra Talur
2ec4b22bb0 api: Fill loc.path and loc.gfid before syncop_open.
syncop_open was crashing because of NULL dereference.
This fixes that.

Change-Id: I4bc48fac2a6c0b15c806cbbb4ae45c67891ab7ed
BUG: 1002577
Signed-off-by: Raghavendra Talur <rtalur@redhat.com>
Reviewed-on: http://review.gluster.org/5734
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
2013-08-29 13:52:28 -07:00
Anand Avati
bbcdbd8c36 synctask: minor enhancements
- Enhance syncenv_new() to accept scaling parameters of syncproc.
  Previously the scaling parameters were hardcoded and decided at
  compile time.

- New API synctask_create() which returns the created synctask. This
  is similar to synctask_new which only returned the status of whether
  a synctask could be created or not.

  The meaning of NULL cbk in synctask_create() means the task is
  "joinable". Until synctask_join() is called on such a synctask,
  the task is not reaped and resources are not destroyed. The
  task would be in a zombie state after synctask_fn returns and
  before synctask_join() is called.

Change-Id: I368ec9037de9510d2ba951f0aad86aaf18d9a6b6
BUG: 986775
Signed-off-by: Anand Avati <avati@redhat.com>
Reviewed-on: http://review.gluster.org/5365
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
2013-08-28 15:52:24 -07:00
Vijay Bellur
cd25375415 api: Set errno before invoking glfs_init_done()
Change-Id: I3f4d3cfaf7078e126881111eb840d854b0b6466d
BUG: 860212
Signed-off-by: Vijay Bellur <vbellur@redhat.com>
Reviewed-on: http://review.gluster.org/5704
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
2013-08-25 13:03:24 -07:00
Anand Avati
d3bbbbb158 gfapi: Add description of glfs_io_cbk function as a comment
No code change, just add a comment describing the callback function
type.

Change-Id: I3a5c5b3d3fe042b4f535963dd477806832c15704
BUG: 839950
Signed-off-by: Anand Avati <avati@redhat.com>
Reviewed-on: http://review.gluster.org/5696
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Tested-by: Vijay Bellur <vbellur@redhat.com>
2013-08-23 03:37:23 -07:00
Anand Avati
a78f7dcddb libgfapi : Fix for hardlink creation on SMB mount
Previously the inode of the hard link was left uninitialised hence
glfs_loc_link() used to fail with invalid parameter.Since inode is
same for both the files in hard link creation,   updated the inode
field of hard link to be same as that of the original file.

Original-author: susant palai <spalai@redhat.com>
Change-Id: Ifd6439867d982524a7b48bf3f6add6e844b3c4c1
BUG: 996063
Signed-off-by: Anand Avati <avati@redhat.com>
Reviewed-on: http://review.gluster.org/5576
Tested-by: susant palai <spalai@redhat.com>
Reviewed-by: Raghavendra Talur <rtalur@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
2013-08-13 08:59:52 -07:00
Bala.FA
4e63eafaed log: set ident to openlog
at syslog side, log message is identified by its properties like
programname, pid, etc.  brick/mount processes need to be identified
uniquely as they are different process of gluterfsd/glusterfs.  At
rsyslog side, log separated by programname/app-name with pid works but
bit hard to identify them in long run which process is for what
brick/mount.

This patch fixes by setting identity string at openlog() which sets
programname/app-name as similar to old style log file prefixed by
gluster, glusterd, glusterfs or glusterfsd

Change-Id: Ia05068943fa67ae1663aaded1444cf84ea648db8
BUG: 928648
Signed-off-by: Bala.FA <barumuga@redhat.com>
Reviewed-on: http://review.gluster.org/5541
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
2013-08-13 07:07:43 -07:00
Tiziano Müller
16061c0d0f Fix broken parallel install
There is an automake bug when using _LTLIBRARIES, breaking parallel
`make install` (see http://debbugs.gnu.org/cgi/bugreport.cgi?bug=7328)

Change-Id: I06aea1dc4c3e6cb0ae9aee5a04dd61881c8b6a7e
BUG: 981888
Signed-off-by: Tiziano Müller <tiziano.mueller@stepping-stone.ch>
Reviewed-on: http://review.gluster.org/5448
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
2013-07-31 19:32:19 -07:00
Anand Avati
dfedfec359 gfapi: perform open() on pre-existing inode in glfs_creat()
Performing syncop_create() on a pre-existing file can result
in opening the linkfile if DHT has a linkfile for the file.
This is because dht_create() will perform the op on the
hashed_subvol() and overwrite the layout in dht_create_cbk.

Change-Id: I7a0db56921ec9fc3e278e0418db3b967f81e5598
BUG: 990410
Signed-off-by: Anand Avati <avati@redhat.com>
Reviewed-on: http://review.gluster.org/5447
Reviewed-by: Raghavendra Talur <rtalur@redhat.com>
Tested-by: Raghavendra Talur <rtalur@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
2013-07-31 13:29:35 -07:00
Anand Avati
21d032bf05 gfapi: fix glfs_readlink()
glfs_readlink() is supposed to memcpy the buffer pointer
returned by syncop_readlink(). Fix it.

Change-Id: I5936b07abbd93cf02b354233dc60f6623e30a38b
BUG: 953694
Signed-off-by: Anand Avati <avati@redhat.com>
Reviewed-on: http://review.gluster.org/5439
Reviewed-by: Amar Tumballi <amarts@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Raghavendra Talur <rtalur@redhat.com>
2013-07-31 06:23:37 -07:00
Vijay Bellur
0bbdfa3d40 api: Avoid a NULL deref in glfs_open().
Change-Id: I23e9fabcb8a430bcd44595ca31460c54d7bd4a39
BUG: 953694
Signed-off-by: Vijay Bellur <vbellur@redhat.com>
Reviewed-on: http://review.gluster.org/5426
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
2013-07-30 19:50:50 -07:00
Anand Avati
aa70c0bba0 gfapi: handle failures in graph switches
A graph switch failure can potentially result in NULL returned
for glfs_active_subvol(). Handle this gracefully in glfs_subvol_done()

Change-Id: I6adbd878c354b9ed2314fc71cea4671792efa0a4
BUG: 953694
Signed-off-by: Anand Avati <avati@redhat.com>
Reviewed-on: http://review.gluster.org/5407
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
2013-07-28 08:20:20 -07:00
Raghavendra Talur
da50f61174 gfapi: fix for not able to rename folders
If oldname is being renamed to newname, we need to
check for type of newname only if newname exists.

Change-Id: I068a283f9ffe67fcd5e8754d6bf052a2339efbf2
BUG: 953694
Signed-off-by: Raghavendra Talur <rtalur@redhat.com>
Reviewed-on: http://review.gluster.org/5333
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
2013-07-16 15:58:48 -07:00
Anand Avati
d7e80787fc gfapi: fix read past EOF in glfs_preadv()
When syncop_preadv() returns 0, we are returning @size as-is
(without modifying user passed buffer). This results in
junk data being read when read offset is at or beyond EOF.

Change-Id: I8aa9c957359f9a52833b944b452f501b6f5538d3
BUG: 953694
Signed-off-by: Anand Avati <avati@redhat.com>
Reviewed-on: http://review.gluster.org/5236
Reviewed-by: Raghavendra Talur <rtalur@redhat.com>
Reviewed-by: José Rivera <jrivera@redhat.com>
Tested-by: José Rivera <jrivera@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
2013-06-20 01:45:50 -07:00