cluster/afr: Return EIO if read-child < 0 in inode-read fops

Change-Id: I8fb2369caffae8f295774b8b12a086c66ec714c7
BUG: 800884
Signed-off-by: Pranith Kumar K <pranithk@gluster.com>
Reviewed-on: http://review.gluster.com/3332
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Jeff Darcy <jdarcy@redhat.com>
Reviewed-by: Anand Avati <avati@redhat.com>
glusterd: Fixed glusterd_brick_create_path algo.

- check if any prefix of the brick path has "trusted.gfid"
  or "trusted.glusterfs.volume-id" set.
- set trusted.glusterfs.volume-id on the bricks as soon as
  its induction into the volume is settled. Earlier, the setting of
  "volume-id" used to happen during the first run of the brick process,
  leaving of window for bricks part of one volume to be (ab)used by another
  volume inadvertently.
- removed creation of brick directory (if missing), during start volume force.
  This is to avoid directory creation as part 'force'ful starting of volume
  and leave the responsibility with the user, who understands the
  'availability' of the export directory (brick) better.

Change-Id: I4237ec4ea7a4e38a7501027e7de7112edd67de8c
BUG: 812214
Signed-off-by: Krishnan Parthasarathi <kp@gluster.com>
Reviewed-on: http://review.gluster.com/3280
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vijay@gluster.com>
cluster/replicate: check for 'loc->path' before dereferencing it

Change-Id: I4dada6fd509aa289e97fdb0b50b28300a15e6a0e
Signed-off-by: Amar Tumballi <amarts@redhat.com>
BUG: 820355
Reviewed-on: http://review.gluster.com/3325
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
client/protocol : Changes in client3_1_getxattr()

Copy args->loc to local->loc in client3_1_getxattr(). This prevents logs with
"(null) (--)" in client3_1_getxattr_cbk().
Also save args->name in local->name and print it in the log as well.

Change-Id: I1bfd00c6bbbe9f617744af7acd2f07ceafaadb3a
BUG: 812199
Signed-off-by: Kaushal M <kaushal@redhat.com>
Reviewed-on: http://review.gluster.com/3336
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Amar Tumballi <amarts@redhat.com>
Reviewed-by: Anand Avati <avati@redhat.com>
Self-heald: Print the time stamp of the event-history

Change-Id: I45767e26288ef6de6446ddf2ea82ed31e128d227
BUG: 796579
Signed-off-by: Pranith Kumar K <pranithk@gluster.com>
Reviewed-on: http://review.gluster.com/3277
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vijay@gluster.com>
nfs/nlm: procedures for PC clients

*  This change introduces four NLMv4 procedures:

   NM_LOCK, SHARE, UNSHARE and FREE_ALL.

   These are used by PC clients (windows/dos) to control access
   to files.

   1. NM_LOCK: this lock is not monitored by statd.

   2. SHARE: A share reservation is a lock on the whole file
      that is taken whenever a file is opened on windows clients.
      This has ACCESS (N, R, W, RW) and DENY MODE (N, R, W, RW).
        ACCESS:    mode of access requested by the client;
        DENY MODE: what the requesting client wants to
                   deny other clients.

   3. UNSHARE: remove a share reservation obtained by SHARE.
      Called while closing a file.

   4. FREE_ALL: remove all share reservations and locks,
      both monitored and unmonitored, of the calling client.

*  lock and nm_lock use a common function with only
   a flag conveying whether or not to monitor a lock.

*  NOTES:
   1. SHARE reservations are not STACK_WIND'd to subsequent xlators.
      These are maintained in-memory in the nfs xlator.

   2. Consequently, for SHARE reservations to work effectively,
      all PC clients  *must* mount from the same gNfs server.
      Not doing so will result in different servers maintaining
      separate SHARE reservations which will not be enforced
      for obvious reasons.

Change-Id: Id4f22670a94ed58691a6a7f4c80aa8c11421a277
BUG: 800287
Signed-off-by: Rajesh Amaravathi <rajesh@redhat.com>
Reviewed-on: http://review.gluster.com/3212
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Krishna Srinivas <krishna@gluster.com>
libglusterfs/fd: while dumping the fd_ctx use fd->xl_count

While dumping the fd_ctx when statedump is issued fd->xl_count should be
used to determine the number of xlators instead of using latest graph's count,
since while creating the fd only those many slots would have been allocated
as the number of xlators in the graph at that instant. Then the graph would have
changed, thus the xl count.

All the above things should happen before any operation is done on fd, otherwise
fd_ctx_set will allocate the extra slots for the new xlators present in the
graph.

Also added the program which can be used to reproduce the bug.

Change-Id: I11fe75d71ef5d37e29e2958d53752aa31098c313
BUG: 820887
Signed-off-by: Raghavendra Bhat <raghavendrabhat@gluster.com>
Reviewed-on: http://review.gluster.com/3335
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vijay@gluster.com>
protocol/client: check if the name is NULL before duping it

Change-Id: I1cefc34af6fae2e71b05179824963e06361c35a2
BUG: 822385
Signed-off-by: Raghavendra Bhat <raghavendrabhat@gluster.com>
Reviewed-on: http://review.gluster.com/3353
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Amar Tumballi <amarts@redhat.com>
Tested-by: Anand Avati <avati@redhat.com>
Fixed a memory leak in stripe translator.

When iobuf is created it has reference count = 1.
After iobref_add (local->iobref, iobuf); reference count becomes 2.
After iobref_unref(local->iobref); it becomes 1 and never becomes 0.
So iobuf never deletes and this causes a memory leak.

I emulated it, creating files on brick manually.
After 5 mins of:
while true; do dd if=file of=/dev/zero bs=16384; done
top showed me this:
4618 root      20   0 1721m 1.5g 1868 S  0.0 16.2   5:41.77 glusterfs

1.5 gb of memory has leaked.

For what this if for? Can it be true in the normal conditions?
if ((local->replies[i].op_ret < local->replies[i].requested_size) &&
    (local->stbuf_size > (local->offset + op_ret))) {
May be delete it entirely?

Change-Id: I17c115ab566e5bba662dd809e0c747db3c0310c8
BUG: 822378
Signed-off-by: Alexander Bersenev <bay@hackerdom.ru>
Reviewed-on: http://review.gluster.com/3340
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Anand Avati <avati@redhat.com>
geo-rep / gsyncd.c: fix coverity fix

gsyncd wrapper was segfaulting as coverity fix freed
up pointer at wrong place (after it was reused)

Instead of the apporach of the original coverity fix
that added elaborate control flow to hunt down potential
leaks, here we move the code over to static allocations
in place of (the not really necessary) dynamic ones.

Change-Id: Ida3855ff4a4f4371b350d27f858f129ceed51785
BUG: 789278
Signed-off-by: Csaba Henk <csaba@redhat.com>
Reviewed-on: http://review.gluster.com/3345
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vijay@gluster.com>
protocol/client: Concatinate the graph uuid along with process uuid in
setlk_version.

Change-Id: Idec06c5ef1d440864e465f008a38c86395b52aba
BUG: 820831
Signed-off-by: Mohammed Junaid <junaid@redhat.com>
Reviewed-on: http://review.gluster.com/3314
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vijay@gluster.com>
init.d: stop only 'glusterd' process on '/etc/init.d/glusterd stop'

earlier it used to stop even brick processes and gluster NFS server
process, which is not a expected behavior for command
'/etc/init.d/glusterd stop'

Change-Id: Ibc092cdf2693b3b2ae491d32ce3f0113854149c8
Signed-off-by: Amar Tumballi <amarts@redhat.com>
BUG: 796998
Reviewed-on: http://review.gluster.com/2919
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Jeff Darcy <jdarcy@redhat.com>
Reviewed-by: Anand Avati <avati@redhat.com>
features/locks: insert_and_merge should not operate on blocked locks

Change-Id: I9417fe28d6c2907b8160cd70c2d2c755731bbe67
BUG: 810502
Signed-off-by: Pranith Kumar K <pranithk@gluster.com>
Reviewed-on: http://review.gluster.com/3365
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
features/locks: Don't delete blocked locks in pl_flush

Change-Id: I442e8d866df317b901f24cf447412179bb61a01c
BUG: 810502
Signed-off-by: Pranith Kumar K <pranithk@gluster.com>
Reviewed-on: http://review.gluster.com/3366
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
stat(1) portability fix

stat(1) flag to specify format is not portable. This change works that
around and makes the script a bit more readable: ${getinode} instead of
stat -c %i

BUG: 764655
Change-Id: Iae3c40b03118078530c29d14d5f7180c36361c16
Signed-off-by: Emmanuel Dreyfus <manu@netbsd.org>
Reviewed-on: http://review.gluster.com/3362
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Amar Tumballi <amarts@redhat.com>
Reviewed-by: Anand Avati <avati@redhat.com>
Library search order fix

Set LD_LIBRARY_PATH before starting glusterfs. This avoids loading
xlator from another glusterfs version if there are diffeent builds
installed on the system (e.g.: in /usr, /usr/local, /opt, /usr/pkg...)

BUG: 764655
Change-Id: I13bf0bea043351498b4bc885c5ac45b108229a0a
Signed-off-by: Emmanuel Dreyfus <manu@netbsd.org>
Reviewed-on: http://review.gluster.com/3361
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Amar Tumballi <amarts@redhat.com>
Reviewed-by: Anand Avati <avati@redhat.com>
Provide missing basename_r and dirname_r

Some systems (e.g.: NetBSD) do not have thread-safe basename(3) and
dirname(3). This is fine with OpenGroup's Single Unix Specification
which allows these functions to use static storage. Unfortunately,
glusterfs uses them a lot and assume thread-safety.

This patch brings FreeBSD's thread-safe basename_r(3) and dirname_r(3)
in the contrib directory, and tweaks the build process so that
NetBSD builds use them instead of libc basename(3) and dirname(3)

BUG: 764655
Change-Id: Ic9a159fffdc7bacc9408f8e90854e4c2db81930c
Signed-off-by: Emmanuel Dreyfus <manu@netbsd.org>
Reviewed-on: http://review.gluster.com/3320
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
Reviewed-by: Anand Avati <avati@redhat.com>
cli: validate quota enable/disable arguments properly

Change-Id: I175cfd418fae52f3e82402c989b9f5da15058146
BUG: 807667
Signed-off-by: Raghavendra Bhat <raghavendrabhat@gluster.com>
Reviewed-on: http://review.gluster.com/3363
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Amar Tumballi <amarts@redhat.com>
Reviewed-by: Anand Avati <avati@redhat.com>
glusterfs/rebalance: Register cbk for glusterfs_rebalance_event_notify

In case of n/w failures, cbk needs to be passed to
mgmt_submit_request.

Change-Id: I519720dbdde4c8d46381144403751bf7ed6d3a51
BUG: 822086
Signed-off-by: shishir gowda <shishirng@gluster.com>
Reviewed-on: http://review.gluster.com/3359
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Amar Tumballi <amarts@redhat.com>
Reviewed-by: Krishnan Parthasarathi <kp@gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
Self-heald: Enable configuring of heal poll timeout

Change-Id: I631e5bf4b3615b553b72e7ac7f490714b3b995f9
BUG: 821395
Signed-off-by: Pranith Kumar K <pranithk@gluster.com>
Reviewed-on: http://review.gluster.com/3329
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>