geo-rep / gsyncd.c: fix coverity fix

gsyncd wrapper was segfaulting as coverity fix freed
up pointer at wrong place (after it was reused)

Instead of the apporach of the original coverity fix
that added elaborate control flow to hunt down potential
leaks, here we move the code over to static allocations
in place of (the not really necessary) dynamic ones.

Change-Id: Ida3855ff4a4f4371b350d27f858f129ceed51785
BUG: 789278
Signed-off-by: Csaba Henk <csaba@redhat.com>
Reviewed-on: http://review.gluster.com/3345
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vijay@gluster.com>
protocol/client: Concatinate the graph uuid along with process uuid in
setlk_version.

Change-Id: Idec06c5ef1d440864e465f008a38c86395b52aba
BUG: 820831
Signed-off-by: Mohammed Junaid <junaid@redhat.com>
Reviewed-on: http://review.gluster.com/3314
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vijay@gluster.com>
init.d: stop only 'glusterd' process on '/etc/init.d/glusterd stop'

earlier it used to stop even brick processes and gluster NFS server
process, which is not a expected behavior for command
'/etc/init.d/glusterd stop'

Change-Id: Ibc092cdf2693b3b2ae491d32ce3f0113854149c8
Signed-off-by: Amar Tumballi <amarts@redhat.com>
BUG: 796998
Reviewed-on: http://review.gluster.com/2919
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Jeff Darcy <jdarcy@redhat.com>
Reviewed-by: Anand Avati <avati@redhat.com>
features/locks: insert_and_merge should not operate on blocked locks

Change-Id: I9417fe28d6c2907b8160cd70c2d2c755731bbe67
BUG: 810502
Signed-off-by: Pranith Kumar K <pranithk@gluster.com>
Reviewed-on: http://review.gluster.com/3365
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
features/locks: Don't delete blocked locks in pl_flush

Change-Id: I442e8d866df317b901f24cf447412179bb61a01c
BUG: 810502
Signed-off-by: Pranith Kumar K <pranithk@gluster.com>
Reviewed-on: http://review.gluster.com/3366
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
stat(1) portability fix

stat(1) flag to specify format is not portable. This change works that
around and makes the script a bit more readable: ${getinode} instead of
stat -c %i

BUG: 764655
Change-Id: Iae3c40b03118078530c29d14d5f7180c36361c16
Signed-off-by: Emmanuel Dreyfus <manu@netbsd.org>
Reviewed-on: http://review.gluster.com/3362
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Amar Tumballi <amarts@redhat.com>
Reviewed-by: Anand Avati <avati@redhat.com>
Library search order fix

Set LD_LIBRARY_PATH before starting glusterfs. This avoids loading
xlator from another glusterfs version if there are diffeent builds
installed on the system (e.g.: in /usr, /usr/local, /opt, /usr/pkg...)

BUG: 764655
Change-Id: I13bf0bea043351498b4bc885c5ac45b108229a0a
Signed-off-by: Emmanuel Dreyfus <manu@netbsd.org>
Reviewed-on: http://review.gluster.com/3361
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Amar Tumballi <amarts@redhat.com>
Reviewed-by: Anand Avati <avati@redhat.com>
Provide missing basename_r and dirname_r

Some systems (e.g.: NetBSD) do not have thread-safe basename(3) and
dirname(3). This is fine with OpenGroup's Single Unix Specification
which allows these functions to use static storage. Unfortunately,
glusterfs uses them a lot and assume thread-safety.

This patch brings FreeBSD's thread-safe basename_r(3) and dirname_r(3)
in the contrib directory, and tweaks the build process so that
NetBSD builds use them instead of libc basename(3) and dirname(3)

BUG: 764655
Change-Id: Ic9a159fffdc7bacc9408f8e90854e4c2db81930c
Signed-off-by: Emmanuel Dreyfus <manu@netbsd.org>
Reviewed-on: http://review.gluster.com/3320
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
Reviewed-by: Anand Avati <avati@redhat.com>
cli: validate quota enable/disable arguments properly

Change-Id: I175cfd418fae52f3e82402c989b9f5da15058146
BUG: 807667
Signed-off-by: Raghavendra Bhat <raghavendrabhat@gluster.com>
Reviewed-on: http://review.gluster.com/3363
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Amar Tumballi <amarts@redhat.com>
Reviewed-by: Anand Avati <avati@redhat.com>
glusterfs/rebalance: Register cbk for glusterfs_rebalance_event_notify

In case of n/w failures, cbk needs to be passed to
mgmt_submit_request.

Change-Id: I519720dbdde4c8d46381144403751bf7ed6d3a51
BUG: 822086
Signed-off-by: shishir gowda <shishirng@gluster.com>
Reviewed-on: http://review.gluster.com/3359
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Amar Tumballi <amarts@redhat.com>
Reviewed-by: Krishnan Parthasarathi <kp@gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
Self-heald: Enable configuring of heal poll timeout

Change-Id: I631e5bf4b3615b553b72e7ac7f490714b3b995f9
BUG: 821395
Signed-off-by: Pranith Kumar K <pranithk@gluster.com>
Reviewed-on: http://review.gluster.com/3329
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
features/quota: get the top xlator from the active graph outside the list

In quota reconfigure we were getting the top of the active graph within the
list which contains the limits set on the volume. Suppose the list is empty,
then the code inside the list traversal loop is not executed, and thus top
will be NULL which might lead to segfault when accessed later.

Change-Id: I1648d69256490878339294537e17300399ddbf2c
BUG: 822827
Signed-off-by: Raghavendra Bhat <raghavendrabhat@gluster.com>
Reviewed-on: http://review.gluster.com/3364
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Amar Tumballi <amarts@redhat.com>
Reviewed-by: Anand Avati <avati@redhat.com>
glusterd, cli: Enable errstr for peer probe

Presently glusterd only returns an errno to cli for peer probe command. This
patch allows glusterd to return an errstr as well to cli. An op_errstr member
has been added to gf1_cli_probe_rsp and gd1_mgmt_probe_rsp structs to allow
this.
In case of an error, cli will display the errstr if it was set. If errstr is not
set cli will display the error message based on errno.
Also, to allow for return of errstr in cases such as handshake failure, an
errstr member has been added to the glusterd_peerctx_t struct.

Change-Id: Iece2b44a7181555e960d9fe4517ec6cda4cdb385
BUG: 816840
Signed-off-by: Kaushal M <kaushal@redhat.com>
Reviewed-on: http://review.gluster.com/3262
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Amar Tumballi <amarts@redhat.com>
Reviewed-by: Anand Avati <avati@redhat.com>
glusterd,cli: Enable errstr for peer detach

This patch adds an op_errstr member to the gf1_cli_deprobe_rsp structure to
enable return of an errstr to cli.

Change-Id: I0cbb6805b05d7cc0603c13d1c1550bb2bd062a7a
BUG: 816840
Signed-off-by: Kaushal M <kaushal@redhat.com>
Reviewed-on: http://review.gluster.com/3307
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Amar Tumballi <amarts@redhat.com>
Reviewed-by: Anand Avati <avati@redhat.com>
cluster/afr: Determining sources should do both fxattrop, fstat

Change-Id: Ifab37db2af8d489cd516e992b7423c765dcabc4f
BUG: 765587
Signed-off-by: Pranith Kumar K <pranithk@gluster.com>
Reviewed-on: http://review.gluster.com/3088
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
cluster/afr: Mark zero size file as sink in absense of xattrs.

Change-Id: I4500f39a49ee16e6e88451dcf147d9f49b1d749e
BUG: 765587
Signed-off-by: Pranith Kumar K <pranithk@gluster.com>
Reviewed-on: http://review.gluster.com/3089
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Jeff Darcy <jdarcy@redhat.com>
Reviewed-by: Anand Avati <avati@redhat.com>
cluster/afr: Handle files w.o. xattrs and size mismatch.

Change-Id: Ia27ee996bed8f5915c154718bf6e859b6a2fc335
BUG: 765587
Signed-off-by: Pranith Kumar K <pranithk@gluster.com>
Reviewed-on: http://review.gluster.com/3090
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Jeff Darcy <jdarcy@redhat.com>
Reviewed-by: Anand Avati <avati@redhat.com>
cluster/afr: Perform conservative merge on dir with xattr split-brain

Change-Id: I96d59ad239c2c5efee14dd4b01a10a3f565d491e
BUG: 765587
Signed-off-by: Pranith Kumar K <pranithk@gluster.com>
Reviewed-on: http://review.gluster.com/3091
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Jeff Darcy <jdarcy@redhat.com>
Reviewed-by: Anand Avati <avati@redhat.com>
cluster/afr: Enforce order in pre/post op

The xattrop order in pre/post op on all the subvols
is client-0, client-1... client-n where n is (replica-count - 1).
This order can lead to invalid split-brains if the brick
dies in the middle of xattrops.

Example: transaction completed pre-op, so on all the subvolumes
xattrs have '1' changelog. Now post-op is sent to both the subvols.
On subvol-0 change-log of client-0 is decremented to 0, before
decrementing change-log of client-1 to 0 the brick dies.
This change-log status on subvol-0 gives the meaning that a
change is done on subvol-0 successfully but on subvol-1 it failed.
Which is not what happened.
Changes done when the subvol-0 was down will lead to pending
change-log on subvol-1 for subvol-0. Which is correct.
When the subvol-0 is brought back up, the change-log will be in
split-brain state even when it is not a legitimate split-brain.

If the brick dies in the middle of xattrops it should remain fool.
Pre-op should perform xattrop of the local change-log first and
post-op should perform xattrop of the local change-log last.
In case of optimistic changelogs txn_changelog should be done
last on local if it succeeds, first if it fails.

Change-Id: Ib6eeb20cdc49b0b1fd2f454f25a9c8e08388c6e7
BUG: 765194
Signed-off-by: Pranith Kumar K <pranithk@gluster.com>
Reviewed-on: http://review.gluster.com/3226
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
storage/posix,fuse-bridge: fill the d_type attribute in READDIRP replies

d_type should contain the type of the the dir-entry (man 3 readdir).
Currently the d_type is always set to DT_UNKNOWN (0). The POSIX standard
readdir() returns a 'struct dirent' on both Linux and NetBSD with the
d_type attribute.

Commit bb315cb180c3547218b5ed581d38e76aec74cf94 removed setting d_type
in xlators/mount/fuse/src/fuse-bridge.c. This was using
d_type_from_stat(). The stat() seems to have been removed for
performance reasons. Instead of removing d_type completely,
dirent->d_type could have been used. Therefore the fuse-brige can now
add "fde->type = entry->d_type" back into fuse_readdir_cbk() without
causing the previous performance impact.

Change-Id: I4514bbc0acceb33d09c3cf50bda51e34d953efca
BUG: 817785
Signed-off-by: Niels de Vos <ndevos@redhat.com>
Reviewed-on: http://review.gluster.com/3256
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
Reviewed-by: Anand Avati <avati@redhat.com>