glusterd: Give up biglock during rpc conn cleanup

glusterd could deadlock after a peer-detach command as follows,

1) glusterd_friend_cleanup function 'flushes' out messages in the rpc
layer's queue, that haven't received a response. At this point, glusterd
has already acquired the big lock.

2) The side-effect of flushing out the messages is that the
corresponding call backs are called.

Call backs themselves are executed after acquiring the big lock. This
results in the big lock being acquired in a nested manner (in the same
thread),  which causes
a deadlock.

This can also happen during brick/NFS/SHD disconnect in volume-stop.

Change-Id: Iab3aad143cd8ebbab53ea0b69687f0e7627dc8a9
BUG: 965533
Signed-off-by: Krishnan Parthasarathi <kparthas@redhat.com>
Reviewed-on: http://review.gluster.org/5084
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
rpm: automatically load the fuse module on EL5

The fuse module needs to be loaded before /dev/fuse can be used. On
RHEL6 and Fedora the module is loaded on demand. RHEL5 needs to load the
module manually.

This change add a script under /etc/sysconfig/modules/ that loads the
fuse module on boot and packages it in the EL5 version of
glusterfs-fuse.

One of the features of GlusterFS is to not depend on additional fuse
userspace. The conditional requires on /usr/bin/fusermount is not
needed, this command is never called in the current version (even though
is it referenced in the sources).

BUG: 947830
Change-Id: I166327b8f2dff2c150368bdf5ea917af259186b2
Signed-off-by: Niels de Vos <ndevos@redhat.com>
Reviewed-on: http://review.gluster.org/5102
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
performance/write-behind: Enable write-behind when strict_O_DIRECT is not set.

When open() with O_DIRECT happens, write-behind was being disabled for the
fd irrespective of strict_O_DIRECT option. This commit disables write-behind
only when strict_O_DIRECT is enabled.

Change-Id: Ieef180e52910c3bf64d46b26b0e5dc3b8542f6d2
BUG: 923556
Signed-off-by: Vijay Bellur <vbellur@redhat.com>
Reviewed-on: http://review.gluster.org/4697
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Jeff Darcy <jdarcy@redhat.com>
Reviewed-on: http://review.gluster.org/5108
Reviewed-by: Anand Avati <avati@redhat.com>
glusterd: Backport of vme table changes from master

This patch backports the following changes from the master branch

99fe09f glusterd: Moved the volume entry table to a separate file.
e306d08 glusterd: Changing the volume entry table's representation.
eac54f6 glusterd: Added option description, and validation function fields.
bcb4235 glusterd: Added validation function for performance cache max and min size.
8897d08 glusterd: Added validation function for quota-timeout.
4579609 glusterd: Added validation function for stripe-block-size.
6788bad glusterd: Fix some options in vme table
549231d glusterd: Added the validation function for subvols-per-directory
9636e63 glusterd: Added description for nfs.transport-type option in volume set help.

Change-Id: I4a64ad94f17df4b45a3a32262a83e2c35fb5f7da
BUG: 907311
Signed-off-by: Kaushal M <kaushal@redhat.com>
Reviewed-on: http://review.gluster.org/4956
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
glusterd: Introduce volume op-versions

This is a backport of change
        9153855 glusterd: Introduce volume op-versions
from master.

Each volume is now associated with two op-versions,
 * op_version - the op-version of the highest op-versioned feature enabled
 * client_op_version - the op-version of the highest op-versioned feature
   enabled which affects the clients only.

These two op-versions are generated dynamically and kept updated during
runtime. Glusterd now uses the respective volumes' client-op-version during
getspec requests.

To achieve the above a new field in the vme table is introduced,
client_option, this boolean field tells if the option is a client side
option.

BUG: 907311
Change-Id: I59af02644a714e1c54fc89f1ead5aa551bba7ee7
Signed-off-by: Kaushal M <kaushal@redhat.com>
Reviewed-on: http://review.gluster.org/4957
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
glusterd: Set op-version on startup based on install status

This is a backport of change
        fa227c0 glusterd: Set op-version on startup based on install status
from master.

If the current installation of glusterfs doesn't have a stored
op-version and is,
a. a fresh install, then set op-version to maximum
b. an upgrade from release which didn't have op-version support, set it
to minimum.

The install status is detected using the peer-uuid.
If both peer-uuid and op-version are not present in the store, the
installation is fresh.
If peer-uuid is present, but op-version is absent in the store, the
installation has been upgraded from a version which didn't support
op-versions.

By setting the initial op-version as above, we can ensure that
a. features are not enabled accidentally during upgrades
b. a fresh install starts with all possible features enabled.

BUG: 954256
Change-Id: I5cdd0c63fd16ecfa2fede99684da6fd6167823a8
Signed-off-by: Kaushal M <kaushal@redhat.com>
Reviewed-on: http://review.gluster.org/5001
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
glusterd-volgen: Enable open-behind based on op-version

Backport of patch on master branch, under review at
        http://review.gluster.org/4866

This patch enables the open-behind by default only when the op-version
allows it. Also the volume op-version calculations take account of this
enablement.

BUG: 954256
Change-Id: Ie739bc23ba90ec2f009feecef28187912a37487c
Signed-off-by: Kaushal M <kaushal@redhat.com>
Reviewed-on: http://review.gluster.org/5095
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
glusterd-volgen: Improve volume op-versions calculation

Backport of patch on master branch, under review at
        http://review.gluster.org/4952

Volume op-versions calculations now take into account if an option,
 a. enables/disables an xlator, or
 b. is a boolean option.

This prevents op-versions from being updated when a feature is disabled.

BUG: 954256
Change-Id: Ic68032b9e55a3f0191f8fc3ecd6b5ced385ad943
Signed-off-by: Kaushal M <kaushal@redhat.com>
Reviewed-on: http://review.gluster.org/5094
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
cluster/afr: Avoid order mismatch in blocking entrylks

Problem:
When taking blocking entrylks, afr orders the entrylks based on
uuid_compare of gfids of parent dirs, if they are equal then it orders
them based on the basenames. While this approach works fine, the
implementation assumes loc->gfids to be populated at the time of
the comparison, but loc may have gfid in loc->inode->gfid instead
of loc->gfid which was leading to order mismatches and dead-locks.

Fix:
Implemented loc_gfid which gives gfid by checking both loc->gfid,
loc->inode->gfid. Used this for ordering the blocking entrylks.

Change-Id: I2743fcaff3d670fbeb6b8e0a496f106a3585dde1
BUG: 965987
Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
Reviewed-on: http://review.gluster.org/5063
Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
gfapi: support for chdir() and family

Add support for chdir, fchdir, getcwd, realpath equivalents in
GFAPI. These are required for the Samba VFS plugin.

Change-Id: I91d2db9146994403c98961c489c7640c51d5add2
BUG: 953694
Signed-off-by: Anand Avati <avati@redhat.com>
Reviewed-on: http://review.gluster.org/5151
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
gfapi: handle root (/) resolution gracefully for realpath()

Resolving path of / is crucial for realpath() to work properly.

Change-Id: I8a1b482beba37f01afbd20446d9e6f6125f2ec34
BUG: 953694
Signed-off-by: Anand Avati <avati@redhat.com>
Reviewed-on: http://review.gluster.org/5152
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
syncop: set credentials of running process in @frame

Inherit the pid/euid/egid/groups of the running process in the
frame. Do this only in cases where a loaded frame was not
presented to the synctask.

This behavior is required for Samba VFS.

Change-Id: Ib181c90f47c6741197b9ce9f67a19e2914b647d2
BUG: 953694
Signed-off-by: Anand Avati <avati@redhat.com>
Reviewed-on: http://review.gluster.org/5153
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
gfapi: implement readdirplus_r support

This call is used by Samba VFS.

Change-Id: Ib371502ad5a71b3b0e993f6b30e3dfb1f839c020
BUG: 953694
Signed-off-by: Anand Avati <avati@redhat.com>
Reviewed-on: http://review.gluster.org/5154
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
gfapi: POSIX locking support

Change-Id: I37d9e1fb4a715094876be6af3856c1b4cf398021
BUG: 953694
Signed-off-by: Anand Avati <avati@redhat.com>
Reviewed-on: http://review.gluster.org/5155
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
posix-acl: fetch ACLs in readdirplus

Not fetching ACLs in readdirplus can potentially result in spurious
wrong ACL decisions (which magically go away on a lookup() which
populates the ACLs)

Change-Id: Ided38b4d868fab482b477ce51b4878289ef9eed0
BUG: 953694
Signed-off-by: Anand Avati <avati@redhat.com>
Reviewed-on: http://review.gluster.org/5156
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
gfapi: add new API glfs_set_xlator_option()

This is the equivalent of specifying --xlator-option command line
argument to glusterfsd.

Change-Id: I1171dd518a85db4bd456fa0790f450e889a956cd
BUG: 953694
Signed-off-by: Anand Avati <avati@redhat.com>
Reviewed-on: http://review.gluster.org/5157
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
quick-read: prune cache on write/[f]truncate

Cache needs to be pruned on write and [f]truncate. The lack of this
is causing Samba ping-pong test to return wierd 'data increment' values
during startup.

Change-Id: I9cd6a839bcd02de738d78638211b78f382f58e0a
BUG: 953694
Signed-off-by: Anand Avati <avati@redhat.com>
Reviewed-on: http://review.gluster.org/5158
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
gfapi: optimistic resolution with ESTALE detection

Enhance the path resolver to be optimistic. Instead of performing
a wasteful ->lookup() fop for every component in every API call,
build in speculation logic to consider the previous resolution
result temporarily, and if it results in ESTALE either later in
the path resolution or in the FOP, then retry resolution with
->lookup() at every level and retry the FOP.

This is the same optimistic resolution/retry logic Linux kernel
resolver is proposing to use.

Change-Id: Iecbc25248754caf0915cd7205910563ff88ce5e7
BUG: 953694
Signed-off-by: Anand Avati <avati@redhat.com>
Reviewed-on: http://review.gluster.org/5159
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
md-cache: support negative xattr entries

Add support for negative xattr caching. For this, we need
to fetch xattrs in every opportunity (including readdirplus)
in order to treat missing key in cached dict as negative entry.

This is crucial to detect missing ACL xattrs in Samba workload.

Change-Id: I918a2ef4ab804724256f7546b15e808332ed518d
BUG: 953694
Signed-off-by: Anand Avati <avati@redhat.com>
Reviewed-on: http://review.gluster.org/5160
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
syncop: copy inode pointer in readdirplus

Change-Id: I9ab2b8ac2da9fe13f56b8b08f715a0b603ece0cb
BUG: 953694
Signed-off-by: Anand Avati <avati@redhat.com>
Reviewed-on: http://review.gluster.org/5161
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>