glusterfsd: fix small memory leaks in glusterfsd-mgmt.c

E.g. In glusterfs_volfile_fetch(), req.xdata.xdata_val is allocated
in dict_allocate_and_serialize() but not freed after mgmt_submit_request().

A survey of dict_allocate_and_serialize/_submit_request in
glusterfsd-mgmt.c shows no consistent pattern of freeing the xdata_val
and also the dict, which is a little disturbing. (Yes, clearly not
every place this occurs needs to be freed the same way.)

Change-Id: I8f31179ae12c05c9b5406d8e9e28110fcbfac1c7
BUG: 1036102
Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
Reviewed-on: http://review.gluster.org/6381
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
cluster/dht: handle NULL check before strlen/strcmp in fgetxattr

@key can legally be NULL. Handle that case without crashing.

Change-Id: Iaae293caa7eeb24afc9cd2580799173e2ce00911
BUG: 1036879
Signed-off-by: Anand Avati <avati@redhat.com>
Reviewed-on: http://review.gluster.org/6402
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
protocol/client: handle network disconnect/reconnect properly

if client/server state versions match, we still need to notify
parent xlators of reconnection (CHILD_UP) because they were
notified of CHILD_DOWN at the time of disconnection.

Change-Id: I36c4bde6d8c3db9cb0c48eeb10663b56897c932e
BUG: 1037267
Signed-off-by: Anand Avati <avati@redhat.com>
Reviewed-on: http://review.gluster.org/6397
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com>
glusterd: submit RPC requests without holding big lock

If the endpoint of an RPC is not connected, the callback is called
synchronously within rpc_clnt_submit(). Since callbacks typically
hold the big lock, give up the big lock before calling rpc_clnt_submit
and acquire it freshly after the call.

Change-Id: Id89d8dd86c1a4012739ef4af7ea0935492b1a02b
BUG: 1037849
Signed-off-by: Anand Avati <avati@redhat.com>
Reviewed-on: http://review.gluster.org/6414
Tested-by: Gluster Build System <jenkins@build.gluster.com>
cluster/afr: handle NULL check before strlen/strcmp in fgetxattr

xattr name can legally be NULL. Handle that case without crashing.

Change-Id: Ie214cb05ccd52565dc247a9234ad83ae799d3866
BUG: 1036879
Signed-off-by: Anand Avati <avati@redhat.com>
Reviewed-on: http://review.gluster.org/6420
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
gfapi: backport handles to 3.4 for nfs-ganesha

nfs-ganesha-2.0 will ship shortly. It depends on the gfapi handle support,
which won't otherwise be released until 3.5 sometime in 2014.

Change-Id: I104d6fb275bb2c710790340fdc7d998446403026
Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
Reviewed-on: http://review.gluster.org/6394
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
distribute: Rebalance should provide even disk space distribution

Earlier disk space check had an issue which didn't
provide the needed functionality to avoid migration
when the destination had lesser available space,
scenario we need to avoid is stated below :

During rebalance `migrate-data` - Destination subvol experiences
a `reduction` in 'blocks' of free space, at the same time source
subvol gains certain 'blocks' of free space. A valid check is
necessary here to avoid errorneous move to destination where
the space could be scantily available.

This patch provides a proper fix in place by subtracting
necessary file blocks from destination and adding those blocks
to source.

backporting fix http://review.gluster.org/5961

BUG: 982919
Original-author: Harshavardhana <harsha@harshavardhana.net>
Signed-off-by: shishir gowda <gowda.shishir@gmail.com>

Change-Id: If5808eaa89e66d7bcaeee7268fe3fe5b1b56f51d
Signed-off-by: shishir gowda <gowda.shishir@gmail.com>
Reviewed-on: http://review.gluster.org/6461
Reviewed-by: Harshavardhana <harsha@harshavardhana.net>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
cluster/dht: set layout in inode ctx even if linkfile fails

Creating linkfile could have failed, but we dont care about linkfile
for setting layout in the inode ctx (could be EEXIST etc.)

So ignore @inode in cbk and pick it up from local->loc.inode

Backporting  http://review.gluster.org/6319
BUG: 1032859

Change-Id: Ic95e303a4c060900d041820d4faa68d1c4685b6a
Original-author: Anand Avati <avati@redhat.com>
Signed-off-by: shishir gowda <gowda.shishir@gmail.com>
Reviewed-on: http://review.gluster.org/6470
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
cluster/dht: Do migration inprog/complete check only if ENOENT

Additionally, update op_errno to the lasted failure. If failures
found in complete_check, error returned would be EUCLEAN instead
of the right failure (in this case ENOENT)

Change-Id: Ib813867f4b817af651627b9ea07b0b09fa2b26ce
BUG: 966852
Original-author: shishir gowda <sgowda@redhat.com>
Signed-off-by: Anand Avati <avati@redhat.com>
Reviewed-on: http://review.gluster.org/6495
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
cluster/dht: Del GF_READDIR_SKIP_DIRS key from dict for first_up

Currently, we sent GF_READDIR_SKIP_DIRS for all subvolumes if
first_subvol != first_up_subvolume.

Also first_up_subvolume can change with-in the life of a call and
cbk. Saving the first_up_subvol in dht_local for checks.

Back porting fix http://review.gluster.org/5577

BUG: 996474
Change-Id: I67b5bbe781e12812557b569b7d0a0beba4224159
Signed-off-by: shishir gowda <gowda.shishir@gmail.com>
Reviewed-on: http://review.gluster.org/6468
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
cluster/dht: Fix anomaly check

We were wrongly detecting holes/overlaps for already accounted
errors. Additionally, sort should also handle zero'ed out layout

Change-Id: Ic3d13e1d735b914f9acc01fe919bc90656baea48
BUG: 1003851
Signed-off-by: shishir gowda <sgowda@redhat.com>
Reviewed-on: http://review.gluster.org/5762
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Amar Tumballi <amarts@redhat.com>
Reviewed-by: Anand Avati <avati@redhat.com>
Reviewed-on: http://review.gluster.org/6469
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
cluster/dht: Ignore decommissioned subvol in overlap optimization

Change-Id: Ib727948c6e21b19fd509f258ff0aea1c5d1a84d1
BUG: 966845
Signed-off-by: shishir gowda <sgowda@redhat.com>
Reviewed-on: http://review.gluster.org/5056
Reviewed-by: Amar Tumballi <amarts@redhat.com>
Reviewed-by: Jeff Darcy <jdarcy@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-on: http://review.gluster.org/6517
Reviewed-by: Shishir Gowda <gowda.shishir@gmail.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
posix: if brick-uid or brick-gid is not specified, do not set

Current code would set owner uid/gid explicitly to 0/0 on start
even if none was specified. Fix it.

Change-Id: I72dec9e79c51bd1eb3af5334c42b7c23b01d0258
BUG: 1040275
Signed-off-by: Anand Avati <avati@redhat.com>
Reviewed-on: http://review.gluster.org/6476
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Tested-by: Lukáš Bezdička <lukas.bezdicka@gooddata.com>
Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Reviewed-on: http://review.gluster.org/6519
Reviewed-by: Lukáš Bezdička <lukas.bezdicka@gooddata.com>
mgmt/glusterd: Fix a memory leak in glusterd_is_local_addr()

Change-Id: Id41d828e1cc56005f5e2a1e75b6d858703dd79c9
BUG: 1032122
Signed-off-by: Vijay Bellur <vbellur@redhat.com>
Reviewed-on: http://review.gluster.org/6518
Reviewed-by: Lukáš Bezdička <lukas.bezdicka@gooddata.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
cli: Throw a warning during creation of rdma volumes.

Change-Id: I75e5383dc7401886c6afe435488de0368050e4e4
BUG: 1017176
Signed-off-by: Vijay Bellur <vbellur@redhat.com>
Reviewed-on: http://review.gluster.org/6558
Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
cli: Throw a warning during replace-brick

Change-Id: Iae59365f09bf64a5927edeeb4c3c052e237eee38
BUG: 1039954
Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
Reviewed-on: http://review.gluster.org/6560
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
tests: Don't use stripe-replicate volume in bug-905864.t

Today, stripe doesn't follow a deterministic order in sending posix
locks to its subvolume. This may lead to dead locks. To avoid
intermittent test failures, we modify bug-905864.t to run on replicate
volume.

Change-Id: I38b72f30bc31576d3ca642f0029cc8749314b1dd
BUG: 905864
Signed-off-by: Krishnan Parthasarathi <kparthas@redhat.com>
Reviewed-on: http://review.gluster.org/5072
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Reviewed-on: http://review.gluster.org/6588
cluster/dht: interim fix for reverting 837422858c

Change-Id: I74818a03f7c5d7891561515af2fa35ea3775255c
BUG: 1032894
Signed-off-by: Vijay Bellur <vbellur@redhat.com>
Reviewed-on: http://review.gluster.org/6582
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Revert "core: fix errno for non-existent GFID"

This reverts commit 837422858c2e4ab447879a4141361fd382645406

Change-Id: I0909f26ce088454bb14b3694b489c672286a4ae6
Reviewed-on: http://review.gluster.org/6575
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
cluster/dht: Ignore ENOENT errors for unlink of linkfiles

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

If unlink of linkfile returns ENOENT, do not fail unlink.
Proceed with unlinking of cached file.

Change-Id: If7cec92b40c39d68dd9c3606c6c2c3a6bd67d27b
BUG: 966848
Signed-off-by: Anand Avati <avati@redhat.com>
Reviewed-on: http://review.gluster.org/6586
Reviewed-by: Harshavardhana <harsha@harshavardhana.net>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>