inode: include dentry cycle checks for all existing inodes

inode_link() has the responsibility of maintaining the DAGness of
the dentry tree, and prevent cyclic loops from forming. To do this
the technique used is to perform cyclic check only while linking
inodes which already were linked in the inode table (i.e linking
a new_inode() can never form a loop).

While this was how it was supposed to be all along, the @old_inode
variable was missed out to get updated if the given inode to inode_link
itself was already linked (i.e, the code was only handling a complex
case when the given new inode had a gfid which already existed)

Without this patch, it is possible to call inode_link in a specific
way which results in dentry loops.

Change-Id: I4c87fa2d63f11e31c73d8b847e56962f6c983880
BUG: 1158226
Signed-off-by: Anand Avati <avati@redhat.com>
Reviewed-on: http://review.gluster.org/8995
Reviewed-by: Harshavardhana <harsha@harshavardhana.net>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Tested-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
feature/changelog: Fix changelog missing SETATTR entries.

Problem: Valid SETATTR entries are missing in changelog when more
         than one metadata operation happen on same inode within
         changelog roll-over time.

Cause: Metadata entries with fop num being GF_FOP_NULL are logged
       in changelog which is of no use. Since slice version
       checking is done for metadata entries to avoid logging of
       subsequent entries of same inode falling into same
       changelog, if the entry with GF_FOP_NULL is logged first,
       subsequent valid ones will be missed.

Solution: Have a boundary condition to log only those fops whose fop
          number falls between GF_FOP_NULL and GF_FOP_MAXVALUE.

Change-Id: Iff585ea573ac5e521a361541c6646225943f0b2d
BUG: 1104954
Signed-off-by: Kotresh HR <khiremat@redhat.com>
Reviewed-on: http://review.gluster.org/8964
Reviewed-by: Aravinda VK <avishwan@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Venky Shankar <vshankar@redhat.com>
Tested-by: Venky Shankar <vshankar@redhat.com>
Avoid spurious EINVAL in posix_readdir()

On non Linux systems, we check that seekdir() succeeds and we return
EINVAL if it does not. We need this to avoid infinite loops if some
other component in GlusterFS makes an invalid seekdir() usage. This
was introduced in this change: http://review.gluster.org/#/c/8760/

But seekdir() also fails when using the offset returned for the
last entry, and this is expected behavior. As a result, the seekdir()
test produces a spurious EINVAL when reaching end of directory. That
error is not propagated to calling process, but it may harm internal
GlusterFS processing. At least it produce a spurious error message
in brick's log.

We fix the problem by remembering the last entry offset in fd private
data. When a new posix_readdir() invocation requests that offset,
we avoid returning EINVAL.

BUG: 1129939
Change-Id: I4e67a2ea46538aae63eea663dd4aa33b16ad24c7
Signed-off-by: Emmanuel Dreyfus <manu@netbsd.org>
Reviewed-on: http://review.gluster.org/8926
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Raghavendra Bhat <raghavendra@redhat.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
CLI: Show warning message only for remove-brick commit

Earlier warning message for checking the removed-bricks for
any unmigrated files was thrown both for remove-brick commit
and force.

With this change the warning message will be shown only for
remove-brick commit.

Change-Id: Ib1fa47d831d5189088c77c5cf709a25ff36d7379
BUG: 1157974
Signed-off-by: Susant Palai <spalai@redhat.com>
Reviewed-on: http://review.gluster.org/8983
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com>
Reviewed-by: Kaushal M <kaushal@redhat.com>
logrotate: gluster logrotate config should not be global

Issue : Previously glusterfs logrotate config file pollutes
global config. So moved the directives inside the curly braces,
 so they don't pollute the global config state.

Change-Id: I8836893dfcdf457d9c5d766612d687bfce64e2ae
BUG: 1126802
Signed-off-by: Lalatendu Mohanty <lmohanty@redhat.com>
Reviewed-on: http://review.gluster.org/8994
Reviewed-by: Niels de Vos <ndevos@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Regression test portability: self-heald.t

Fix portability problems in updated self-heald.t:
- Use the k suffit in dd(1) bs argument instead of less portable M and K
- Error message for disconnected bricks in NetBSD is "Socket is not connected"
- On touch d/a while bricks are down, NetBSD updates d ctime/mtime even
  on bricks where a is not present, resulting in a different to-be-healed
  count than on Linux. We now tes both values. If NetBSD behavior is a bug,
  it is not in the heal process and should be tested somewhere else.

This also requires fixes in heal process: http://review.gluster.org/8936

BUG: 1129939
Change-Id: Ibda1902a8fd64aa7cc5202744adca825e6b251c9
Signed-off-by: Emmanuel Dreyfus <manu@netbsd.org>
Reviewed-on: http://review.gluster.org/8968
Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Fixed missing / in replace-brick pause example

BUG: 1155421
Change-Id: I079f738e8381bada4595d3600921a39581edaea7
Signed-off-by: Joe Julian <me@joejulian.name>
Reviewed-on: http://review.gluster.org/8963
Reviewed-by: Humble Devassy Chirammal <humble.devassy@gmail.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
doc: Introduction to meta xlator.

... in the form of examples. This is by no means exhaustive.  Meta
xlator is not as well known as it should be for its own good.  This
patch is to get the ball rolling.

Change-Id: I5898c37aa15706e886af68f19caac48c175df90b
BUG: 1144282
Signed-off-by: Krishnan Parthasarathi <kparthas@redhat.com>
Reviewed-on: http://review.gluster.org/8410
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Humble Devassy Chirammal <humble.devassy@gmail.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
doc: iobuf and iobref documentation.

Change-Id: Ib6d8121a968e8160c587a8553b7333262bb44975
BUG: 1118309
Signed-off-by: Poornima G <pgurusid@redhat.com>
Reviewed-on: http://review.gluster.org/8818
Reviewed-by: Prashanth Pai <ppai@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Humble Devassy Chirammal <humble.devassy@gmail.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
glusterd: Store rebalance state on all peers

The rebalance state was being saved only on the peers participating in
the rebalance on a rebalance start. This change makes sure all nodes
save the rebalance state.

Change-Id: I436e5c34bcfb88f7da7378cec807328ce32397bc
BUG: 1157979
Signed-off-by: Kaushal M <kaushal@redhat.com>
Reviewed-on: http://review.gluster.org/8998
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com>
Tested-by: Krishnan Parthasarathi <kparthas@redhat.com>
Regression test portability: useradd/userdell

Adjust useradd/userdel flags for NetBSD. Similar work will have to be
done for other non Linux systems

BUG: 1129939
Change-Id: I2a30819a4915d04473f0ef0c0c063de6015212a1
Signed-off-by: Emmanuel Dreyfus <manu@netbsd.org>
Reviewed-on: http://review.gluster.org/8895
Reviewed-by: Xavier Hernandez <xhernandez@datalab.es>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
Regression test portability: loopback devices

Introduce functions to deal with loopback devices setup, mount
and umount.

Remove test for xfsprogs for non Linux systems, as loopback devices
can be populated with other filesystems (e.g.: FFS for NetBSD)

While there, remove mount.nfs test for non Linux systems. At least
NetBSD has it in base system as mount_nfs.

BUG: 1129939
Change-Id: I816b36e1d3e6933f92acf19d9be8eeaaa333356e
Signed-off-by: Emmanuel Dreyfus <manu@netbsd.org>
Reviewed-on: http://review.gluster.org/8914
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Lazy umount emulation: deal with stopped volumes

On non Linux systems, lazy umount is emulated using contrib/umountd.
It first check that the path given to unmount exists, but it should
not give up on ENOTCONN as it is what happens when a volume is mounted
but stopped.

This lets NetBSD pass tests/bugs/bug-1049323.t

BUG: 1129939
Change-Id: I3451362453607a0fd82b095a9e5aa6f63bfe869a
Signed-off-by: Emmanuel Dreyfus <manu@netbsd.org>
Reviewed-on: http://review.gluster.org/8991
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Regression test portability: TAP

Even with successful tests on NetBSD, we had a failure message at
the end: "No plan found in TAP output"

This was caused by a white space left padded numerical variable.
Stripping the white spaces fixes the problem.

While there add SKIP_TEST for NetBSD on unspported tests so that
it does not triger a failure.

BUG: 1129939
Change-Id: I8d0bc125c4208974657977568d838ee2dd19783c
Signed-off-by: Emmanuel Dreyfus <manu@netbsd.org>
Reviewed-on: http://review.gluster.org/8981
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Use F_CLOSEM if available

Use F_CLOSEM to close all file descriptors if available.

BUG: 764655
Change-Id: Ib3c682825b89c163ebb152848f2533b3cb62cdce
Signed-off-by: Emmanuel Dreyfus <manu@netbsd.org>
Reviewed-on: http://review.gluster.org/8379
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
Reviewed-by: Humble Devassy Chirammal <humble.devassy@gmail.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
features/snapview-server: verify the fs instance in revalidated lookups as well

Change-Id: Id5f9d5a23eb5932a0a53520b08ffba258952e000
BUG: 1151004
Signed-off-by: Raghavendra Bhat <raghavendra@redhat.com>
Reviewed-on: http://review.gluster.org/8999
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
glusterd: add option support for own-thread

Like enabling SSL, enabling own-thread has to be done separately for
clients and servers.

 * client.own-thread for clients (including internal like self-heal)

 * server.own-thread for servers (including e.g. glusterd)

It's very unlikely that you would ever want to set one without the
other, but they're separate anyway just in case.  Check for "private
polling thread" in the relevant logs to make sure the option took
effect, because otherwise you might not notice any difference besides
inreased performance.  ;)

Change-Id: Ifaee8de52f0b959bcdf7f6b56faeee549ee56604
BUG: 1158648
Signed-off-by: Jeff Darcy <jdarcy@redhat.com>
Reviewed-on: http://review.gluster.org/8931
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com>
Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com>
Tested-by: Krishnan Parthasarathi <kparthas@redhat.com>
gNFS : mount fails if connection to brick(s) is not established yet.

       Connection between gluster-nfs and brick process requires
       time (especially for rdma).During that time when we try to
       mount using nfs ,it will fail saying that volume not found.
       So we need a check using 'is_nfs_export_available'before
       mounting to ensure volume is available.This patch will provide
       the check before nfs mount if it is not given in the test files

Change-Id: I242eb6e3118ebaca1df46314302a203a0c9738a8
BUG: 1158831
Signed-off-by: jiffin tony thottan <jthottan@redhat.com>
Reviewed-on: http://review.gluster.org/9011
Reviewed-by: Meghana M <mmadhusu@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Niels de Vos <ndevos@redhat.com>
Regression test portability: mock

After some attempts at using mock on NetBSD which pulled a lot of
dependencies, it seems that software really assumes the OS is
Linux: chrooted build will fail because of missing Linux files.

As a result, make tests/basic/rpm.t Linux-only, and remove mock
and rpmbuild checks for non Linux systems.

BUG: 1129939
Change-Id: Ica2eb74dd23fbec379a26051a8f61b0dfc07a115
Signed-off-by: Emmanuel Dreyfus <manu@netbsd.org>
Reviewed-on: http://review.gluster.org/8949
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Niels de Vos <ndevos@redhat.com>
cluster/afr: Perform post-op in entry selfheal inside locks

Take entrylks in xlator domain before doing post-op (undo-pending) in
entry self-heal. This is to prevent a parallel name self-heal on
an entry under @fd->inode from reading pending xattrs while it is
being modified by SHD after entry sh below, given that
name self-heal takes locks ONLY in xlator domain and is free to read
pending changelog in the absence of the following locking.

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