Enable aux-gfid-mount option on non Linux systems

The aux-gfid-mount works on non Linux systems, and it is required
to pass tests/basic/gfid-access.t

BUG: 764655
Change-Id: Ic6c8ef425e091440a139bbd25fadbf4f82e378cb
Signed-off-by: Emmanuel Dreyfus <manu@netbsd.org>
Reviewed-on: http://review.gluster.org/8446
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Humble Devassy Chirammal <humble.devassy@gmail.com>
Reviewed-by: Harshavardhana <harsha@harshavardhana.net>
Tested-by: Harshavardhana <harsha@harshavardhana.net>
Regression test portability: mkdir

mkdir -v (verbose) is not portable, just remove it.

BUG: 764655
Change-Id: If344792caf977698abe0bf497d9083bc9333df55
Signed-off-by: Emmanuel Dreyfus <manu@netbsd.org>
Reviewed-on: http://review.gluster.org/8463
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Harshavardhana <harsha@harshavardhana.net>
Tested-by: Harshavardhana <harsha@harshavardhana.net>
Regression test portability: stat

Linux uses stat -c, stat --printf= or stat --printf
NetBSD uses stat -f with different format strings. This change set
changes all stat usage to stat -c and introduce a shell stat()
fonction to perform the format string translation.

BUG: 764655
Change-Id: I024fca7c1b736b053f5888cbf21da0a72489ef63
Signed-off-by: Emmanuel Dreyfus <manu@netbsd.org>
Reviewed-on: http://review.gluster.org/8424
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Harshavardhana <harsha@harshavardhana.net>
Tested-by: Harshavardhana <harsha@harshavardhana.net>
cluster/dht: Fix dht_access treating directory like files

When the cluster topology changes due to add-brick, all sub
volumes of DHT will not contain the directories till a rebalance
is completed. Till the rebalance is run, if a caller bypasses
lookup and calls access due to saved/cached inode information
(like NFS server does) then, dht_access misreads the error
(ESTALE/ENOENT) from the new subvolumes and incorrectly tries
to handle the inode as a file. This results in the directories
in memory state in DHT to be corrupted and not heal even post
a rebalance.

This commit fixes the problem in dht_access thereby preventing
DHT from misrepresenting a directory as a file in the case
presented above.

Change-Id: Idcdaa3837db71c8fe0a40ec0084a6c3dbe27e772
BUG: 1125824
Signed-off-by: Shyam <srangana@redhat.com>
Reviewed-on: http://review.gluster.org/8462
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
NFS: stripe-xlator should pass EOF at end of READDIR

NFS READDIR replies are made of a header, a sequence of
entries, and a EOF flag. When GlusterFS's NFS server is
used along with stripe xlator, it fails to set the EOF
flag, which violates NFS RFC and confuses some clients.

The bug is caused because nfs xlator sets EOF if it gets
op_errno set to ENOENT. That value is produced in storage
xlator and propagated through server, client, and other
xlators until stripe xlator handles it. stripe only passed
op_errno if op_ret < 0, which is not the case here. This
change set adds a special case for that situation to fix
the problem.

Change-Id: Ie6db94b0515292387cfb04c1e4a9363f34fcd19a
BUG: 1130969
Reported-by: Emmanuel Dreyfus <manu@netbsd.org>
Signed-off-by: Niels de Vos <ndevos@redhat.com>
Reviewed-on: http://review.gluster.org/8493
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Santosh Pradhan <spradhan@redhat.com>
Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
Reviewed-by: Emmanuel Dreyfus <manu@netbsd.org>
Tested-by: Emmanuel Dreyfus <manu@netbsd.org>
geo-rep: Fixing issue with xsync upper limit

While identifying the file/dir to sync, xtime of the file was compared
with xsync_upper_limit as `xtime < xsync_upper_limit` After the sync,
xtime of parent directory is updated as stime. With the upper limit
condition, stime is updated as MIN(xtime_parent, xsync_upper_limit)

With this files will get missed if `xtime_of_file == xsync_upper_limit`

With this patch xtime_of_file is compared as
xtime_of_file <= xsync_upper_limit

BUG: 1128093
Change-Id: I5022ce67ba503ed4621531a649a16fc06b2229d9
Signed-off-by: Aravinda VK <avishwan@redhat.com>
Reviewed-on: http://review.gluster.org/8439
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Kotresh HR <khiremat@redhat.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
who-wrote-glusterfs: use the set $GITDM_REPO variable

Change-Id: Ic119f83fff3930e164f3c81df1c9b60d5eb2d99f
BUG: 1131272
Signed-off-by: Patrick Uiterwijk <puiterwijk@redhat.com>
Reviewed-on: http://review.gluster.org/8495
Reviewed-by: Humble Devassy Chirammal <humble.devassy@gmail.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>
client: Add ping-timeout to statedump

The ping timeout value of a client xlator can be seen by,

># cat $META/graphs/active/vol-client-0/private |grep ping_timeout
ping_timeout = 42

where $META is /<fuse-mountpt>/.meta

Change-Id: I4f68f184fc3f30871269a23fc4a82a1378396058
Signed-off-by: Krishnan Parthasarathi <kparthas@redhat.com>
Reviewed-on: http://review.gluster.org/8321
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Regression test portability: mount

Address various portability-related problems related to mount
- In order to address the non-portability of NFS mount options,
  use the mount_nfs shell function everywhere, and use it to
  translate options.
- Make sure NFS mounts are unmounted before shutting down the
  daemons in order to avoid deadlock. The change is done in every
  test that did not unmounted NFS mounts at the end of the script,
  and in global cleanup function as well. The force_umount shell
  function from volume.rc was duplicated as umount_nfs in nfs.rc
  so that we do not have to add an include on volume.rc for all
  NFS tests that do not need it.
- The FUSE mount type on NetBSD is puffs|perfuse|fuse.glusterfs
  instead of just fuse.glusterfs, make the regexp configurable
  in include.rc
- Finding wether the mount is RO or RW in mount output needs
  a system-dependent command configurable in include.rc
- mount options in /proc/mounts may be limited to "rw", adjust
  the regexp for this case where there is no comma

And while there change rm into rm -f in tests/basic/mount.t
for removal opearation that should fail, since rm may ask
for confirmation

Change-Id: I1fb708486ec350b2885e2404879561c1020fa8fd
BUG: 1129939
Signed-off-by: Emmanuel Dreyfus <manu@netbsd.org>
Reviewed-on: http://review.gluster.org/8494
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Harshavardhana <harsha@harshavardhana.net>
Tested-by: Harshavardhana <harsha@harshavardhana.net>
Regression test portability: 127.0.0.0/8

On Linux, the host answers any address in  127.0.0.0/8
On NetBSD, any address must be configured with ifconfig lo0 alias before
it can be used.

BUG: 1129939
Change-Id: Ia628716c104d955817a95e0c5e04ead924bb4847
Signed-off-by: Emmanuel Dreyfus <manu@netbsd.org>
Reviewed-on: http://review.gluster.org/8483
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Harshavardhana <harsha@harshavardhana.net>
Tested-by: Harshavardhana <harsha@harshavardhana.net>
Regression test portability: dd

Use dd msgfmt=quiet also in truncate replacement

BUG: 764655
Change-Id: I5ad022c1dc65ecc98996ccbe8a3d0e9de162aa1a
Signed-off-by: Emmanuel Dreyfus <manu@netbsd.org>
Reviewed-on: http://review.gluster.org/8464
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Harshavardhana <harsha@harshavardhana.net>
Tested-by: Harshavardhana <harsha@harshavardhana.net>
Regression test portability: sha1sum

Provide a shell function for sha1sum if missing

BUG: 764655
Change-Id: I8b232af8aab7f95ba7c7ad83e37a111d562201a5
Signed-off-by: Emmanuel Dreyfus <manu@netbsd.org>
Reviewed-on: http://review.gluster.org/8450
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Harshavardhana <harsha@harshavardhana.net>
Tested-by: Harshavardhana <harsha@harshavardhana.net>
Regression test portability: mktemp

Linux mktemp accepts to run without a template, NetBSD mandates it. Since
the template option has the same syntax, add it everywhere. While there,
also do this in scripts outside of regression testing.

BUG: 764655
Change-Id: I3ec140afbc9009257c81a56d77afcc21fef74cc4
Signed-off-by: Emmanuel Dreyfus <manu@netbsd.org>
Reviewed-on: http://review.gluster.org/8432
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Harshavardhana <harsha@harshavardhana.net>
Tested-by: Harshavardhana <harsha@harshavardhana.net>
geo-rep/glusterd: API to check active geo-rep session for the volume

Requirement:
Snapshot needs an API to fail the CLI if any geo-rep session is active
for that volume.

Solution:
A function "gd_vol_is_geo_rep_active" is provided to check if any
geo-rep session is active for that volume. An in memory dict called
'gsync_running_slaves' is maintained in 'volinfo' structure to keep
track of active geo-rep session for the volume. The key
'slavenode::slavevol' with value 'running' is added whenever geo-rep
is started/resumed into the dict and the same is removed if
stopped/paused. So the 'count' in dict is used to decide whether the
geo-rep is active or not for that volume.

Also added "this->name" in gf_log in routines which this patch is
touched.

Change-Id: I2b5de7dd686541c6b89c0fd0f7a4dbc92eecfac5
BUG: 1129008
Signed-off-by: Kotresh HR <khiremat@redhat.com>
Reviewed-on: http://review.gluster.org/8459
Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com>
Tested-by: Krishnan Parthasarathi <kparthas@redhat.com>
cluster/afr: Set pending changelog based on filetype for new entries

Change-Id: Ib6eea2dfe43aacf1f3446cc023adecbcf8645d48
BUG: 1132102
Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
Reviewed-on: http://review.gluster.org/8506
Reviewed-by: Anuradha Talur <atalur@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Fix quotad RPC options use-after-free bug in gluster

In cli/src/cli.c:cli_quotad_clnt_rpc_init(), dict_unref (rpc_opts)
causes the options to be freed while code in rpc/rpc-transport/socket
still relies on it. The options are corrupted when memory is reallocated,
which sometimes leads to a crashes on NetBSD when socket_connect()
attempted to read options.

Fix the problem by not doing the dict_unref(). Make sure the rpc_opts
are freed on error, though.

BUG: 1129939
Change-Id: If1d6ea50cc3e1599e9e369863c8db0c0694d3671
Signed-off-by: Emmanuel Dreyfus <manu@netbsd.org>
Reviewed-on: http://review.gluster.org/8502
Reviewed-by: Santosh Pradhan <spradhan@redhat.com>
Reviewed-by: Niels de Vos <ndevos@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com>
Tested-by: Krishnan Parthasarathi <kparthas@redhat.com>
glusterd/snapshot : Fail the snapshot create operation if geo-rep is running.

As one of the recommandations for taking a snapshot is not to have
an active geo-replication session, its better to display an error
saying session is active when snapshot create command is issued.

Change-Id: I94593dbd2659610e033ca316176dda1ac8dc5ce6
BUG: 1129038
Signed-off-by: Sachin Pandit <spandit@redhat.com>
Reviewed-on: http://review.gluster.org/8461
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Rajesh Joseph <rjoseph@redhat.com>
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
Reviewed-by: Vijaikumar Mallikarjuna <vmallika@redhat.com>
Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com>
Tested-by: Krishnan Parthasarathi <kparthas@redhat.com>
client: client3_3_readdir() - initialize ``local`` properly

A crash is observed in the following scenario on OSX

~~~
(gdb) p readdir_rsp_size
$1 = 1552
GLUSTERFS_RPC_REPLY_SIZE == 24
GLUSTERFS_RDMA_MAX_HEADER_SIZE == 228

((1552 + 24 + 228)) == 1804

GLUSTERFS_RDMA_INLINE_THRESHOLD == 2048

if ((readdir_rsp_size +
 GLUSTERFS_RPC_REPLY_SIZE +
 GLUSTERFS_RDMA_MAX_HEADER_SIZE) > GLUSTERFS_RDMA_INLINE_THRESHOLD)
  ----> False
~~~

``local`` is never initialized leads to NULL reference later.

This patch makes sure that local is initialized, correctly as its
done in client3_3_readdirp() call.

Change-Id: I46931fc96900b7740ae71536c954bb9deda5c879
BUG: 1132796
Signed-off-by: Harshavardhana <harsha@harshavardhana.net>
Reviewed-on: http://review.gluster.org/8511
Reviewed-by: Niels de Vos <ndevos@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
Tested-by: Raghavendra G <rgowdapp@redhat.com>
cluster/afr: Perform gfid heal inside locks.

Problem:
Allowing lookup with 'gfid-req' will lead to assigning gfid at posix layer.
When two mounts perform lookup in parallel that can lead to both bricks getting
different gfids leading to gfid-mismatch/EIO for the lookup.

Fix:
Perform gfid heal inside lock.

BUG: 1129529
Change-Id: I20c6c5e25ee27eeb906bff2f4c8ad0da18d00090
Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
Reviewed-on: http://review.gluster.org/8512
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Krutika Dhananjay <kdhananj@redhat.com>
cluster/afr: Perform metadata sync inside metadata locks

Change-Id: Ie55b3d37cacbdad74a3f63c3b0f025b0ffd0104a
BUG: 1132461
Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
Reviewed-on: http://review.gluster.org/8514
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Krutika Dhananjay <kdhananj@redhat.com>