socket: don't send notification 'up' on socket_writev failure

Change-Id: If4e4b95fe025a412f25313d83c780046dfec5116
Signed-off-by: Krishnan Parthasarathi <kparthas@redhat.com>
Reviewed-on: http://review.gluster.org/6716
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
geo-rep/gfid-access: Fix errno for non-existent GFID.

Because of http://review.gluster.org/#/c/6318/ patch,
ESTALE is returned for a lookukp on non-existent GFID.
But ENOENT is more appropriate when lookup happens
through virtual .gfid directory on aux-gfid-mount
point. This is avoids confusion for the consumers
of gfid-access-translator like geo-rep which expects
ENOENT.

Change-Id: I4add2edf5958bb59ce55d02726e6b3e801b101bb
BUG: 1069191
Signed-off-by: Kotresh H R <khiremat@redhat.com>
Reviewed-on: http://review.gluster.org/7154
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
Reviewed-by: Venky Shankar <vshankar@redhat.com>
Reviewed-by: Anand Avati <avati@redhat.com>
write-behind: track filesize when doing extending writes

A program that calls mmap() on a newly created sparse file, may receive
a SIGBUS signal. If SIGBUS is not handled, a segmentation fault will
occur and the program will exit.

A bug in the write-behind translator can cause the creation of a sparse
file created with open(), seek(), write() to be cached. The last write()
may not be sent to the server, until write-behind deems this necessary.

* open(.., O_TRUNC, ...)/creat() the file, it is 0 bytes big
* seek() into the file, use offset 31
* write() 1 byte to the file
* the range from byte 0-30 are unwritten so called 'sparse'

The following illustration tries to capture this:

    Legend:
    [ = start of file
    _ = unallocated/unwritten bytes
    # = allocated bytes in the file
    ] = end of file

    [_______________#]
     |              |
     '- byte 0      '- byte 31

Without this change, reading from byte 0-30 will return an error, and
reading the same area through an mmap()'d pointer will trigger a SIGBUS.
Reading from this range did not trigger the outstanding write() to be
flushed. The brick that receives the read() (translated over the network
from mmap()) does not know that the file has been extended, and returns
-EINVAL. This error gets transported back from the brick to the
glusterfs-fuse client, and translated by the Linux kernel/VFS into
SIGBUS triggered by mmap().

In order to solve this, a new attribute to the wb_inode structure is
introduced; the current size of the file. All FOPs that can modify the
size, are expected to update wb_inode->size. This makes it possible for
extending writes with an offset bigger than EOF to mark the unwritten
area as modified/pending.

Change-Id: If5ba6646732e6be26568541ea9b12852a5d0b988
BUG: 1058663
Signed-off-by: Niels de Vos <ndevos@redhat.com>
Reviewed-on: http://review.gluster.org/6835
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
Reviewed-by: Anand Avati <avati@redhat.com>
Added test case for crypt translator

Change-Id: I7a28a1285c19c3279c2f71e9d9914cf14c761858
BUG: 1030058
Signed-off-by: Edward Shishkin <edward@redhat.com>
Reviewed-on: http://review.gluster.org/6504
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
build: Add missing rpmbuild/BUILD dir for CentOS 5.x

The rpmbuild/BUILD directory isn't created automatically
by the build system on CentOS 5.x. This 1-line patch
adds its creation to the build process.

BUG: 1071504
Change-Id: I90ad70608776cb491f2ba92fb7d6044cff4defcc
Signed-off-by: Justin Clift <justin@gluster.org>
Reviewed-on: http://review.gluster.org/7175
Reviewed-by: Niels de Vos <ndevos@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
cli:  Rectify grammar in the "Usage" of "rebalance" command

Problem: Currently Usage of rebalance command is : " Usage: volume rebalance
<VOLNAME> [fix-layout] {start|stop|status} [force] "

1) "force" option can be only used with "start" .

2) "fix-layout" option can be only used with "start"

But the current usage says "fix-layout" operation can be stopped and can get the
status of "fix-layout" operation and also "stop" ,"status" operation can be used
with "force" option which is not correct.

Change-Id: I48e6c64c124f5803c8f09c78df0e14dc2b6a348a
BUG: 1071411
Signed-off-by: Susant Palai <spalai@redhat.com>
Reviewed-on: http://review.gluster.org/7172
Reviewed-by: Anand Avati <avati@redhat.com>
Tested-by: Anand Avati <avati@redhat.com>
Reduce logging caused by non-existing extended attributes

This changes the following log messages from INFO (default value) to
DEBUG. We do not really care if someone tries to read extended
attributes that do not exist.

    [2013-12-09 12:19:05.924497] E [posix.c:3539:posix_fgetxattr] 0-dis-rep-posix: fgetxattr failed on key system.posix_acl_access (No data available)
    [2013-12-09 12:19:05.924545] I [server-rpc-fops.c:863:server_fgetxattr_cbk] 0-dis-rep-server: 13074: FGETXATTR 1 (b8381953-ffa5-40fa-90dd-ae122335cc4b) (system.posix_acl_access) ==> (No data available)

Change-Id: Idbbeb026f81e67025a2b36d7bfeb125ad2a1f61b
BUG: 1027174
Signed-off-by: Niels de Vos <ndevos@redhat.com>
Reviewed-on: http://review.gluster.org/7171
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Harshavardhana <harsha@harshavardhana.net>
Reviewed-by: Anand Avati <avati@redhat.com>
libglusterfs/inode: Fix NULL dereferences.

There could be scenarios where the inode_ctx_get() can
be called to only check if the context exists, in such
cases the buffer for the context might not have been passed.
Hence fix inode_ctx_get() to not crash, when the buffer
is not passed.

Change-Id: I607d86eb401ccab0e5cd75f6f977c454994ec063
BUG: 789278
Signed-off-by: Poornima G <pgurusid@redhat.com>
Reviewed-on: http://review.gluster.org/7167
Reviewed-by: Santosh Pradhan <spradhan@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
rpc: transport may be destroyed while rpc isn't

rpc_clnt object is destroyed after the corresponding transport object is
destroyed. But rpc_clnt_reconnect, a timer driven function, refers to
the transport object beyond its 'life'. Instead, using the embedded
connection object prevents use after free problem wrt transport object.

Also, access transport object under conn->lock.

Change-Id: Iae28e8a657d02689963c510114ad7cb7e6764e62
BUG: 962619
Signed-off-by: Krishnan Parthasarathi <kparthas@redhat.com>
Reviewed-on: http://review.gluster.org/6751
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
api: add glfs_get_volfile

From the API-header description:

> Sometimes it's useful e.g. for scripts to see the volfile, so that
> they can parse it and find subvolumes to do things like split-brain
> resolution or custom layouts.  The API here was specifically intended
> to make access e.g. from Python as simple as possible.
>
> Note that the volume must be started (not necessarily mounted) for
> this to work.

Change-Id: If3f55ee9611cdf4b77aa53659f0af0d21957817d
Signed-off-by: Jeff Darcy <jdarcy@redhat.com>
Reviewed-on: http://review.gluster.org/7183
Reviewed-by: Anand Avati <avati@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
cli: Changed log rotate command format to common format.

Problem:
The syntax of log rotate was
volume log rotate <volname> [<brick>]
All other commands are of the form:
volume <verb|noun> <volname> [<actions>|options]

Solution:
Changed log rotate command usage to common format.
Old syntax is also supported, it will be deprecated
in next release.

Change-Id: Ia6f6665185a1549c6f79ca763599b446f29e2c78
BUG: 844187
Signed-off-by: Raghavendra Talur <rtalur@redhat.com>
Reviewed-on: http://review.gluster.org/4594
Reviewed-by: Kaushal M <kaushal@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
build: GlusterFS Unit Test Framework

This patch will allow for developers to create unit tests for
their code.  Documentation has been added to the patch and
is available here:

doc/hacker-guide/en-US/markdown/unittest.md

Also, unit tests are run when RPM is created.

BUG: 1067059
Change-Id: I95cf8bb0354d4ca4ed4476a0f2385436a17d2369
Signed-off-by: Vijay Bellur <vbellur@redhat.com>
Signed-off-by: Luis Pabon <lpabon@redhat.com>
Reviewed-on: http://review.gluster.org/7145
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Rajesh Joseph <rjoseph@redhat.com>
Reviewed-by: Justin Clift <justin@gluster.org>
Tested-by: Justin Clift <justin@gluster.org>
geo-rep: quick-fix for remote xtime set failed

Remote xtime is required for failover/failback,
this patch is quick fix to avoid the OSError.

Code is masked out, this need to be resolved when
failover/failback is worked on.

Change-Id: If339d88a2ccd8ef18a3b3c015df765c93dcb020c
BUG: 1073844
Signed-off-by: Kotresh H R <khiremat@redhat.com>
Reviewed-on: http://review.gluster.org/7206
Reviewed-by: Aravinda VK <avishwan@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
build: Don't build geo-replication rpms when on EL5

Also fixes a typo bug where geo-replication isn't
being disabled correctly

BUG: 1074045
Change-Id: I28d42637bedcc28d65b6a34ab0183559202c4aed
Signed-off-by: Justin Clift <justin@gluster.org>
Reviewed-on: http://review.gluster.org/7210
Reviewed-by: Joe Julian <joe@julianfamily.org>
Tested-by: Joe Julian <joe@julianfamily.org>
Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Niels de Vos <ndevos@redhat.com>
Reviewed-by: Venky Shankar <vshankar@redhat.com>
glusterd: Fixed typo in console message during volume create

While creating a volume, if the brick is created on the root
partition, then the error statement is thrown.

This error statements was containing two "is" in it.
Removed one of the "is"

Change-Id: I0d83f0feccda34989f7e2b97041d1f15ec9e2f00
BUG: 1065551
Signed-off-by: Satheesaran <satheesaran@gmail.com>
Reviewed-on: http://review.gluster.org/7198
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
glusterd: send/receive volinfo->caps during peer probe.

Problem: volinfo->caps was not sent over to newly probed peers, resulting in a
'Peer Rejected' state due to volinfo checksum mismatch.

Fix: send/receive volinfo capability when peer probing.

Change-Id: I2508d3fc7a6e4aeac9c22dd7fb2d3b362f4c21ff
BUG: 1072720
Signed-off-by: Ravishankar N <ravishankar@redhat.com>
Reviewed-on: http://review.gluster.org/7186
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Kaushal M <kaushal@redhat.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
tests: Add initial sanity checks to the GlusterFS Test Framework

BUG: 1073168
Change-Id: I0b995d94fe83053d3294df1b5fad2eef3b4355d3
Signed-off-by: Justin Clift <justin@gluster.org>
Reviewed-on: http://review.gluster.org/7193
Reviewed-by: Niels de Vos <ndevos@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
hook-scripts: Move smb hooks to right place.

Moved the hook-scripts to dirs corresponding to event.
Also, edited S30samba-set.sh to with changes in
other two hook scripts to bring uniformity.

Change-Id: Ib98c0a18d4bb5d0ba4b881b2e19b40d72580b1c2
BUG: 1073468
Signed-off-by: Raghavendra Talur <rtalur@redhat.com>
Reviewed-on: http://review.gluster.org/7201
Reviewed-by: Poornima G <pgurusid@redhat.com>
Reviewed-by: Bala FA <barumuga@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
scripts: CTDB hooks should add `_netdev` for network mounts

Change-Id: I86ad5e9ed291866a8d478768fb447e269f51c39e
BUG: 1075182
Signed-off-by: Harshavardhana <harsha@harshavardhana.net>
Reviewed-on: http://review.gluster.org/7221
Reviewed-by: Niels de Vos <ndevos@redhat.com>
Reviewed-by: Jose A. Rivera <jarrpa@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
locks: fix unconditional op_ret success of entrylk

Bug introduced in recent refactoring. op_ret of entrylk() was always
getting set to 0 even though second locker wouldn't have gotten a lock.
This was resulting in multiple contenders to get locks granted at the
same time.

Change-Id: I99c187a9285fb80cc500b38f468f2ebda7048cab
Signed-off-by: Anand Avati <avati@redhat.com>
BUG: 849630
Reviewed-on: http://review.gluster.org/7224
Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>