core: remove unused code

BUG: 764890
Change-Id: Ia8bcaa7a4daeb706bcb0bba24b2e634e9ca20d49
Signed-off-by: Amar Tumballi <amarts@redhat.com>
Reviewed-on: http://review.gluster.com/3657
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
rpc: add extra arguments to _callback's actor function

Need to differentiate the callback functions based on which
rpc-clnt the callback is received. without it, all callback
actor handling will be like global.

BUG: 839345
Change-Id: Ide024f5585eab3c5fe6c3b33250772fb6e8ad655
Signed-off-by: Amar Tumballi <amarts@redhat.com>
Reviewed-on: http://review.gluster.com/3656
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
xlator options: remove overwritten data-self-heal initializer

In the struct volume_options, the "data-self-heal"
.default_value = "" setting appeared before a setting of
.default_value = "on".  Remove the former.

Change-Id: Ieddcc18f61581f9448d806cd8bf8eefaaf0118b9
BUG: 789278
Signed-off-by: Jim Meyering <meyering@redhat.com>
Reviewed-on: http://review.gluster.com/3589
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
nfs-common: don't let 0-length path cause buf[-1] access

Change-Id: I5f0e93448a954aff1ff08a0980fb9bfd60e63988
BUG: 789278
Signed-off-by: Jim Meyering <meyering@redhat.com>
Reviewed-on: http://review.gluster.com/3594
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
glusterd: avoid buffer overrun for over-long volname

[in glusterd_store_is_valid_brickpath]
When strlen(volname) is no smaller than sizeof(volinfo->volname),
volinfo->volname would end up not being NUL-terminated.
Then, a use of that buffer that expects it to be NUL-terminated
(i.e., glusterd_store_brickinfopath_set's GLUSTERD_GET_BRICK_DIR)
will access beyond the end of the buffer.
Instead, diagnose the too-long volume name and fail.

Change-Id: I655d8638547bf342d33280c14ff1edacc3cdeb5a
BUG: 789278
Signed-off-by: Jim Meyering <meyering@redhat.com>
Reviewed-on: http://review.gluster.com/3591
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
gsyncd: don't let a bogus config file make us read/write buf[-1]

Change-Id: Ic55c28c572c1878f8a223ae2fd25d301a7ef0c12
BUG: 789278
Signed-off-by: Jim Meyering <meyering@redhat.com>
Reviewed-on: http://review.gluster.com/3596
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
read_conf: don't let a corrupt config file cause invalid line[-1] reference

Change-Id: Ifbc698768d9418a54c1501efa335edd4048cfd41
BUG: 789278
Signed-off-by: Jim Meyering <meyering@redhat.com>
Reviewed-on: http://review.gluster.com/3603
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
cli: print_brick_status: don't smash stack

For bricklen > 110 (i.e., 2 * fieldlen), the if-clause
would be executed 2 or more times, making strncpy write
past the end of "buf", clobbering the stack.  Rewrite,
removing unnecessary use of strncpy, strlen and decl/use
of the temporary buffer, and instead, specifying precision
via a printf-style format directive.

Coverity identified the static buffer overrun.

Change-Id: I176386e752c397dea22265de9f3c6eb631334f4f
BUG: 789278
Signed-off-by: Jim Meyering <meyering@redhat.com>
Reviewed-on: http://review.gluster.com/3646
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
cli: cli_cmd_get_confirmation: don't reference answer[-1] for NUL input

Change-Id: I83baa54fc5392e92a6a451c549d356ff1ffc92cb
BUG: 789278
Signed-off-by: Jim Meyering <meyering@redhat.com>
Reviewed-on: http://review.gluster.com/3606
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
glusterfsd: don't ignore tmpfile write failure (2x)

In both glusterfs_volfile_reconfigure and mgmt_getspec_cbk,
we fwrite to a temporary file, fflush the stream, and then
rewind and read from it.  However, if either the fwrite or
fflush were to fail, we would have ignored a write failure
and would then read and process corrupt or incomplete input.
In each case, add a test of ferror so that we don't ignore
the write failure.

Found by inspection.

Change-Id: I8e84deb7d020a907870c9da2dde5c7371ce6ddb7
BUG: 789278
Signed-off-by: Jim Meyering <meyering@redhat.com>
Reviewed-on: http://review.gluster.com/3648
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
core: check for pre-allocated blocks in backend fs, fix it.

There is a possibility that the backend FS (like XFS) can
allocate blocks beyond EOF for better performance reasons, which
results in 'st_blocks' with higher values than what is consumed by
the file descriptor. This would break few logic inside GlusterFS,
like quota behavior etc, thus we need the exact number of blocks
which are consumed by the file to the higher layers inside GlusterFS.

Currently, this logic won't work for sparse files (ie, file with holes)

Change-Id: Ied216733a8862e84f7da8386ae0a144f3f5cd5f2
BUG: 817343
Signed-off-by: Amar Tumballi <amarts@redhat.com>
Reviewed-on: http://review.gluster.com/3631
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Jeff Darcy <jdarcy@redhat.com>
Reviewed-by: Raghavendra Bhat <raghavendra@redhat.com>
Reviewed-by: Anand Avati <avati@redhat.com>
storage/posix: handle getxattr failures gracefully

Use proper variable types for getting return value of getxattr calls,
which otherwise can lead to segfaulting of processes or page allocation
failures in the kernel.

Change-Id: I62ab5d6c378447090c19846f03298c3afc8863ba
BUG: 838195
Signed-off-by: Raghavendra Bhat <raghavendra@redhat.com>
Reviewed-on: http://review.gluster.com/3640
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Niels de Vos <ndevos@redhat.com>
Reviewed-by: Anand Avati <avati@redhat.com>
extras: add clear_xattrs.sh to the glusterfs-server sub-package

Change-Id: Iba695a6d19389fbc1776da5e939d67318916aadf
BUG: 812214
Signed-off-by: Niels de Vos <ndevos@redhat.com>
Reviewed-on: http://review.gluster.com/3644
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
geo-rep: don't let unexpected status provoke undefined behavior

glusterd_gsync_read_frm_status reads what is expected to be a NUL-
terminated status string from the specified file, but makes two
mistakes when trying to do the favor of trimming trailing spaces.
Do not let a leading NUL byte of status cause us to read buf[-1]
and possibly to clear that and any preceding "trailing" spaces.
Do not let a blen-byte input (with no NUL byte) cause our use of
strlen to access beyond the end of non-NUL-terminated buffer.

I looked at this code because coverity reported that it was
assuming a read-provided buffer to be NUL-terminated.

Change-Id: I140be0948e31196e5be08766d4e6400bf6f4dfa1
BUG: 789278
Signed-off-by: Jim Meyering <meyering@redhat.com>
Reviewed-on: http://review.gluster.com/3647
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
calls to dict_allocate_and_serialize() are not 64-bit clean

All calls to dict_allocate_and_serialize() pass the address of a 32-bit
type, but must cast it to the 64-bit pointer type (size_t *).

This happens to work on LE machines, but even if it's apparently benign,
it's still a bug. On BE machines it is not benign.

GF_PROTOCOL_DICT_SERIALIZE() hacks around it by creating a size_t temp
var, but that's, well, a hack, IMO when you consider that all the callers
are actually passing &<u_int>; the param should just be a u_int * and
eliminate the buggy casts and the temp var in the macro.

Nobody apparently uses the Fedora/EPEL PPC RPMs, but they might. People
are trying to build gluster.org bits on SPARC and tripping over this.

Change-Id: I92ea139f9e3e91ddbbb32a51b96fa582a9515626
Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
BUG: 838928
Reviewed-on: http://review.gluster.com/3642
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
extras: install clear_xattrs.sh

The script was not installed by default, this breaks building the RPM
packages since Change-Id Iba695a6d19389fbc1776da5e939d67318916aadf.

Change-Id: I4fb982cb5217dc7b3ec3c7a664dd3997a2e05170
BUG: 812214
Signed-off-by: Niels de Vos <ndevos@redhat.com>
Reviewed-on: http://review.gluster.com/3659
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
rpc: variable name changes

's/3_1/3_3/g' in case of glusterfs protocol
's/3_1_/_/g' in case of CLI and mgmt protocol

Change-Id: I6e6510d02c05f68f290c52ed284c04576326e12c
Signed-off-by: Amar Tumballi <amarts@redhat.com>
BUG: 764890
Reviewed-on: http://review.gluster.com/3632
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Jeff Darcy <jdarcy@redhat.com>
Reviewed-by: Anand Avati <avati@redhat.com>
core: remove the unused files - round 2

BUG: 764890
Change-Id: I3eb626eeaa2a09f0e248444f560c2a0eaf46c642
Signed-off-by: Amar Tumballi <amarts@redhat.com>
Reviewed-on: http://review.gluster.com/3660
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
protocol/server: return 'xdata' even in case of error

helps to better utilize dict for more clarity on
errors, if required.

Change-Id: I3ff90e16be946e5f60974d4bde68a729d596c9de
Signed-off-by: Amar Tumballi <amarts@redhat.com>
BUG: 826982
Reviewed-on: http://review.gluster.com/3633
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Jeff Darcy <jdarcy@redhat.com>
Reviewed-by: Anand Avati <avati@redhat.com>
fuse/md-cache: add support for the 'fopen-keep-cache' mount option

fopen-keep-cache disables unconditional page-cache invalidations
on file open in fuse (via FOPEN_KEEP_CACHE) and replaces that
behavior with detection of remote changes and explicit
invalidations from mount/fuse. This option improves local caching
through the page cache and native client.

This change defines a new 'invalidate' translator callback to
identify when an inode's cache mapping has been determined to be
invalid. md-cache implements the policy to detect and invoke
inode invalidations. fuse-bridge and io-cache implement
invalidate handlers to invalidate the respective caches (page
cache in the case of fuse).

BUG: 833564
Change-Id: I99818da5777eaf06276c1c0b194669f5bab92d48
Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-on: http://review.gluster.com/3584
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>