glusterd: fix memory corruption when probe fails

Change-Id: If161e9bebfd518b355aaf37af7805e804772dc2d
BUG: 893851
Signed-off-by: Jeff Darcy <jdarcy@redhat.com>
Reviewed-on: http://review.gluster.org/4372
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com>
tests: make EXPECT_WITHIN also fail on command failure

Change-Id: I051bbe2344f19e647826ee177932ae8b95747ebd
BUG: 764966
Signed-off-by: Kaushal M <kaushal@redhat.com>
Reviewed-on: http://review.gluster.org/4334
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Changes to support automake-1.13

automake-1.13 obsoletes some macros that were being used. This patch replaces
these macros.

Change-Id: I2a24a923f284e9b54fb57ccc27eb0b5ad8dd6050
BUG: 892882
Signed-off-by: Kaushal M <kaushal@redhat.com>
Reviewed-on: http://review.gluster.org/4368
Tested-by: Niels de Vos <ndevos@redhat.com>
Reviewed-by: Niels de Vos <ndevos@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
extras: Changed the exit status in start function to 0.

Problem:
We were returning "1" when "glusterd start" was being called with service
already running. As per
http://refspecs.linuxbase.org/LSB_4.1.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html
we should consider it to be a success case and return 0.

Fix:
Just changed the return status from 1 to 0.

Change-Id: I8d6d2014f0c32ba53834503e721e2a71df7330a8
BUG: 845653
Signed-off-by: Raghavendra Talur <rtalur@redhat.com>
Reviewed-on: http://review.gluster.org/4348
Reviewed-by: Niels de Vos <ndevos@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
socket: Don't log readv failures if read-fail-log is false

Change-Id: I6903d62cbc7107eb8498bcd81d07667b36890a02
BUG: 764888
Signed-off-by: Krishnan Parthasarathi <kparthas@redhat.com>
Reviewed-on: http://review.gluster.org/4377
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
protocol/server: do server_connection_put only if bound_xl is NULL

If getting bound_xl fails, then while putting the connection back we
should also check for bound_xl pointer for NULL apart from the op_ret
and the connection object. We were checking just op_ret and conn pointer
till now and if the mount from a machine is not allowed as auth.allow
did not permit it, then also we were destroying the connection object.

Change-Id: Iac43e8dc078d905edafb44d6670f88989a8f82a3
BUG: 881062
Signed-off-by: Raghavendra Bhat <raghavendra@redhat.com>
Reviewed-on: http://review.gluster.org/4373
Reviewed-by: Amar Tumballi <amarts@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Fix format security errors with hardening build flags

These problems were found while building with the hardening options used
by Debian. In order to prevent introducing new unsafe constructs, the
options -Wformat" and -Werror=format-security are addeded to the CFLAGS
by configure.ac if the compiler supports them.

Also, a small spelling fix in posix-aio.c is included.

Change-Id: I1034311644fa3c21bc5a7b842c41a3ca79108b3f
BUG: 887278
Original-author: Patrick Matthäi <pmatthaei@debian.org>
Signed-off-by: Niels de Vos <ndevos@redhat.com>
Reviewed-on: http://review.gluster.org/4311
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
Reviewed-by: Anand Avati <avati@redhat.com>
glusterd: Don't persist enable-pump in volinfo->dict

- enable-pump option in the pump xlator is set during a replace-brick
  session. This was persisted in the volinfo->dict for volume file
  generation.
  It has two 'harmful' side-effects,
  a) It would lead to volinfo cksum divergence among peers in
     cluster (for the same version no.) during a replace-brick session.

  b) "enable-pump" key would appear in "gluster volume info VOLNAME".
     This key is used internally in volume file generation code to
     optionally load the pump xlator in the source brick. It is _not_
     an volume option.

Change-Id: I37a8e7186e2985d187e4a166a599cf69145a90f9
BUG: 886000
Signed-off-by: Krishnan Parthasarathi <kparthas@redhat.com>
Reviewed-on: http://review.gluster.org/4367
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
replicate: don't clear changelog for un-healed replicas

Change-Id: Iebfa6770a688e89c051666b46977862188061738
BUG: 802417
Signed-off-by: Jeff Darcy <jdarcy@redhat.com>
Reviewed-on: http://review.gluster.org/4034
Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
cluster/afr: Pre-op should be undone for non-piggyback post-op

Problem:
When fop fails post-op is always performed
over the network irrespective of whether pre-op is piggybacked
or not. Decrementing Pre-op-done count even for the piggybacked
ones is wrong.
I have added an assert for pre_op_done to be non-zero and when
dd of=a if=/dev/urandom bs=5M count=1000 is executed and a brick
is taken down, the mount is crashing.

Fix:
Decrement pre-op-done count only when the post-op is not
piggybacked.

Change-Id: Ie837251a43bfb437f0fada191302eeee60be1601
BUG: 863939
Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
Reviewed-on: http://review.gluster.org/4310
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
cli: output xml in pretty format

Gluster cli now prints XML outputs in 'pretty' format. This solves the problem
of empty elements occuring as two tags instead of being collapsed into one.

Change-Id: Iab7aeadcff29c18ae388b58e446a16e937ac09ed
BUG: 849293
Signed-off-by: Kaushal M <kaushal@redhat.com>
Reviewed-on: http://review.gluster.org/4355
Reviewed-by: Krutika Dhananjay <kdhananj@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
object-storage: add UFO unit tests

Run the UFO unit tests following the main GlusterFS unit tests. The
UFO unit tests run under the Nose unit test running harness, requiring
the python-nose package to be installed. These unit tests run fast
enough that we could even consider running them on a commit hook run
by rfc.sh.

Note that they are not functional tests, as they don't require a real
Gluster file system to run.

Change-Id: I55972890c24be16fc588a6950cb6bfd539287bbe
Signed-off-by: Peter Portante <peter.portante@redhat.com>
Reviewed-on: http://review.gluster.org/4333
Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
Reviewed-by: Anand Avati <avati@redhat.com>
Tested-by: Anand Avati <avati@redhat.com>
cluster/dht: update ctx-time only if we receive the new iatt

1. Used local->postparent(contains merged iatt of all succesful calls) instead
of postparent for dht ctx time update.

2. dht_inode_ctx_time_update avoided in case of opret -1.

Change-Id: Ie04a7842a41c241f911b6a3f76267b996d27fb43
BUG: 881013
Signed-off-by: Varun Shastry <vshastry@redhat.com>
Reviewed-on: http://review.gluster.org/4338
Reviewed-by: Shishir Gowda <sgowda@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
afr: replace afr_more_important_error with afr_most_important_error

afr_more_important_error() is written to return whether a new errno
should override an existing errno for high-level operations that
could span multiple sub-operations. It specifically prioritizes
ESTALE over EIO over ENOENT, and otherwise defaults to the latest
error passed having priority.

This change preserves current behavior, but rewrites the logic to
return the higher priority error of the existing and new errno. The
purpose of the change is to make the logic a bit more clear and set
the stage for future changes to make the logic flexible based on
context.

BUG: 892730
Change-Id: Id1aa48855dfb0507abc9d1ef22f2259b30472576
Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-on: http://review.gluster.org/4375
Reviewed-by: Jeff Darcy <jdarcy@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
tests: Fix tests for bug 857330

Changed some tests to use EXPECT, which I should have done originally, instead
of using TEST. With recent changes to the EXPECT primitive we get more info for
failures, which hopefully will make debugging of the intermittent failures of
these tests easier.

Change-Id: If763dcfb7e370a3f360277c3c183b950aede5685
BUG: 857330
Signed-off-by: Kaushal M <kaushal@redhat.com>
Reviewed-on: http://review.gluster.org/4390
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
debug/trace: save the recent fops received in the event-history

* Make use of event-history in debug/trace xlator to dump the recent fops,
when statedump is given. trace xlator saves the fop it received along
with the time in the event-history and upon statedump signal, dumps its
history. The size of the event-history can be given as a xlator option.

* Make changes in trace to take logging into log-file or logging to
history as an option. By default both are off.

Change-Id: I12baee5805c6efb55735cead4e2093fb94d7a6a0
BUG: 797171
Signed-off-by: Raghavendra Bhat <raghavendra@redhat.com>
Reviewed-on: http://review.gluster.org/4088
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
nlm: use virtual ip of server to connect to client

In cases where the servers use virtual ip's, this commit
makes sure we use them and not the physical ip.

This change also refactors code around nlm4_establish_callback
by sending granted msg only after a connection establishment,
and removing the separate thread creation.

Change-Id: I087362c547a25aa52ef7fc6653845a3863466ee6
BUG: 888283
Signed-off-by: Rajesh Amaravathi <rajesh@redhat.com>
Reviewed-on: http://review.gluster.org/4326
Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
afr: conditionally prioritize EIO errors over ENOENT

The most important errno logic historically only prioritized ESTALE
over ENOENT. Commit c8c0942d added EIO prioritization over ENOENT
to ensure that split-brain was reported when it occurs in
conjunction with bricks missing the file entry. The unintended side
effect of this change is that (non split-brain) EIO errors reported
from the bricks themselves are now reported to the client when the
expectation is that afr should squash said errors in favor of
marking the file inconsistent.

The high-level problem is that EIO is overloaded with different
meanings from different contexts. This commit adds an eio parameter
to the errno priority logic to conditionally flag when EIO is of
higher priority and should be propagated to the client.

BUG: 892730
Change-Id: Ib692a8a1f1737ef190d57894f392ec53ffb33aab
Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-on: http://review.gluster.org/4376
Reviewed-by: Jeff Darcy <jdarcy@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
glusterd: replace obsolete /usr/local reference for remote ssh/gsyncd

See https://bugzilla.redhat.com/show_bug.cgi?id=895656
    https://bugzilla.redhat.com/show_bug.cgi?id=764679 (GLUSTER-2947)
    https://bugzilla.redhat.com/show_bug.cgi?id=764623 (GLUSTER-2891)

The comments in the bzs are a bit obtuse and/or vague. As near as I
can make out we had, for a while, a "convenience symlink" to or from
/usr/local/libexec/gsyncd, which no longer exists.

And, lacking any comments in the code, I gather this is some sort of
fallback or failsafe logic: if the first, normal attempt to invoke gsyncd
fails then an attempt is made to ssh to the box and invoke it.

In any event, there's nothing in /usr/local/... so it's unquestionably
wrong to try to invoke anything there.

BUG: 895656
Change-Id: I3b7ac7a049b91ce101b930599294830147cc60ad
Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
Reviewed-on: http://review.gluster.org/4392
Reviewed-by: Niels de Vos <ndevos@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Joe Julian <joe.julian.prime@gmail.com>
Reviewed-by: Anand Avati <avati@redhat.com>
cluster/afr: Fail readv on data-split-brain

Problem:
Afr prevents opens on a file in split-brian but the
fd that is already open still has the capability to perform
both reads and writes to the file.

Fix:
Fail readvs on a file with EIO.

Change-Id: I8e07f24c36fab800499b36ab374f984b743332cd
BUG: 873962
Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
Reviewed-on: http://review.gluster.org/4199
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Jeff Darcy <jdarcy@redhat.com>
Reviewed-by: Anand Avati <avati@redhat.com>