logging: use duplicate stderr, instead of re-opening

The special filename "-" is supposed to log to stderr. Instead of
trying to explictly open "/dev/stderr" again (which may not be possible
as permissions might have changed by then), dup the stderr and use
the copy.

It is not a good idea to use @stderr global variable directly, as
ctx->log.logfile is fclose()d in glfs_fini() (was fixed in
http://review.gluster.org/6452)

Cherry picked from commit 15ea78fffd63756fecf2f15887d3cad6a13d2a34:
> BUG: 1088589
> Signed-off-by: Anand Avati <avati@redhat.com>
> Reviewed-on: http://review.gluster.org/7607
> Tested-by: Gluster Build System <jenkins@build.gluster.com>
> Reviewed-by: Vijay Bellur <vbellur@redhat.com>

Change-Id: Ia6c538fe363905588dcf4fc4783804073956a586
BUG: 1103413
Signed-off-by: Niels de Vos <ndevos@redhat.com>
Reviewed-on: http://review.gluster.org/7938
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Harshavardhana <harsha@harshavardhana.net>
NetBSD build fixes for release-3.5

1) Make sure __THROW is definedThis is a backport of I6e7cb1eb59b84988e155e9a8b696e842b7ff8f7f

2) include <rpc/xdr.h> before <rpc/auth.h> so that XDR is defined
This was fixed in master within I20193d3f8904388e47344e523b3787dbeab044acbut weonly pull up

3) NetBSD's gettext is in libintl, hence search it at configure time
This is a backport of I651a74fe49c3f087fe135dab3453fd5b18b4268a

4) include <sys/wait.h> to have WEXITSTATUS defined
This problem does not exist in master as WEXITSTATUS is not used

5) Do not define popcountl() on NetBSD as it is in <strings.h>
This is a backport of I4428a88b1e0d7c5f6740022861ffe230dbbd84bd

BUG: 764655
Change-Id: Ieea5a2a627e2b7930525d6c525f1602073574a97
Signed-off-by: Emmanuel Dreyfus <manu@netbsd.org>
Reviewed-on: http://review.gluster.org/7925
Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
Reviewed-by: Niels de Vos <ndevos@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
glusterd: On gaining quorum spawn_daemons in new thread

  Backport of http://review.gluster.org/7703 from master

During startup, if a glusterd has peers, it waits till quorum is
obtained to spawn bricks and other services. If peers are not present,
the daemons are started during glusterd' startup itself.

The spawning of daemons as a quorum action was done without using a
seperate thread, unlike the spawn on startup. Since, quotad was launched
using the blocking runner_run api, this leads to the thread being
blocked. The calling thread is almost always the epoll thread and this
leads to a deadlock. The runner_run call blocks the epoll thread waiting
for quotad to start, as a result glusterd cannot serve any requests. But
the startup of quotad is blocked as it cannot fetch the volfile from
glusterd.

The fix for this is to launch the spawn daemons task in a seperate
thread. This will free up the epoll thread and prevents the above
deadlock from happening.

BUG: 1105188
Change-Id: Idad1e96fbe1411dfd4b1a542fb5fa115673636c0
Signed-off-by: Kaushal M <kaushal@redhat.com>
Reviewed-on: http://review.gluster.org/7995
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Niels de Vos <ndevos@redhat.com>
features/gfid-access: calloc gfid and set in xdata

Backport of http://review.gluster.org/#/c/7978/

Problem: the gfid passed to ga_fill_tmp_loc() was a stack variable which
the function set in the xdata dictionary. Accessing it in a later point
in time gave unexpected values.

This was easy to hit when AFR was involved like so:
ga_mknod()--->xxx-->afr_mknod():
In afr_mknod transaction, once the stack-winds for the lock-phase are sent,
the gfid in xdata becomes out of scope. When we send the actual op i.e.
afr_mknod_wind(), the gfid in xdata is stale, causing posix to set junk
gfids on the files.

Fix:
calloc the gfid and set it in the dict.

Thanks to Pranith for the RCA!

Change-Id: Ief2080836dc2923dec4be44dda4f6211430e535e
BUG: 1104959
Signed-off-by: Ravishankar N <ravishankar@redhat.com>
Reviewed-on: http://review.gluster.org/7985
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Niels de Vos <ndevos@redhat.com>
glusterd: Better op-version values and ranges

Till now, the op-version was an incrementing integer that was
incremented by 1 for every Y release (when using the X.Y.Z release
numbering). This is not flexible enough to handle backports of features
into Z releases.

Going forward, from the upcoming 3.6.0 and 3.5.1 releases, the
op-versions will be multi-digit integer values composed of the version
numbers, instead of a simple incrementing integer. An X.Y.Z release will
have XYZ as its op-version. Y and Z will always be 2 digits wide and
will be padded with 0 if required. This way of bumping op-versions
allows for gaps in between the subsequent Y releases. These gaps will
allow backporting features from new Y releases into old Z releases.

Change-Id: Ib6a09989f03521146e299ec0588fe36273191e47
Depends-on: http://review.gluster.org/7963
BUG: 1096425
Signed-off-by: Niels de Vos <ndevos@redhat.com>
Reviewed-on: http://review.gluster.org/8010
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
gNFS: Make NFS DRC off by default

DRC in NFS causes memory bloat and there are known memory corruptions.
It would be good to disable drc by default till the feature is stable.

Cherry picked from 4215d071cec4fc8a62ca4fd6212d83f931838829:
> Change-Id: I93db6ef5298672c56fb117370bb582a5e5550b17
> BUG: 1105524
> Original-patch-by: Santosh Kumar Pradhan <spradhan@redhat.com>
> Signed-off-by: Niels de Vos <ndevos@redhat.com>
> Reviewed-on: http://review.gluster.org/8004
> Tested-by: Gluster Build System <jenkins@build.gluster.com>
> Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com>
> Reviewed-by: Santosh Pradhan <spradhan@redhat.com>
> Reviewed-by: Vijay Bellur <vbellur@redhat.com>

Change-Id: I93db6ef5298672c56fb117370bb582a5e5550b17
BUG: 1105524
Signed-off-by: Niels de Vos <ndevos@redhat.com>
Reviewed-on: http://review.gluster.org/8013
Reviewed-by: Santosh Pradhan <spradhan@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
features/gfid-access: Fix memory leaks.

Change-Id: I90f6cdb1c8c4face1bb72a9cc77818d308389e45
BUG: 1104919
Signed-off-by: Raghavendra G <rgowdapp@redhat.com>
Reviewed-on: http://review.gluster.org/7983
Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Niels de Vos <ndevos@redhat.com>
afr-v1 documentation.

        Backport of http://review.gluster.org/6574

BUG: 1086781
Change-Id: I3a7e0cf3eeedce5b3859a46f2a6a7de4ae62bed4
Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
Reviewed-on: http://review.gluster.org/8038
Reviewed-by: Krutika Dhananjay <kdhananj@redhat.com>
Reviewed-by: Niels de Vos <ndevos@redhat.com>
Tested-by: Niels de Vos <ndevos@redhat.com>
protocol/server: send ENOENT instead of ESTALE for older clients

Modify protocol/server and storage/posix to send ENOENT to older clients
instead of ESTALE

http://goo.gl/t83hmL

Change-Id: Ie63e91e73e33769ce9dc3d964938cfd6eb4c4be5
BUG: 1109832
Signed-off-by: Ravishankar N <ravishankar@redhat.com>
Reviewed-on: http://review.gluster.org/8080
Reviewed-by: Raghavendra Bhat <raghavendra@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>