mount: Verify mount failure in mount.glusterfs wrapper.

The result of mount command execution is not checked properly, thus
no proper message given for the end user. This patch fix the same.

Cherry picked from commit 76b72680017c836eff8805ea0339f7827ba3e561:
> Bug Id: 1128165
> Change-Id: I3882e34e840ed15b5ce48ed5e1ad51208e2be913
> Signed-off-by: Humble Chirammal <hchiramm@redhat.com>
> Reviewed-on: http://review.gluster.org/8438
> Tested-by: Gluster Build System <jenkins@build.gluster.com>
> Reviewed-by: Niels de Vos <ndevos@redhat.com>

BUG: 1173513
Change-Id: I3882e34e840ed15b5ce48ed5e1ad51208e2be913
Signed-off-by: Niels de Vos <ndevos@redhat.com>
Reviewed-on: http://review.gluster.org/9270
Reviewed-by: Humble Devassy Chirammal <humble.devassy@gmail.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Raghavendra Bhat <raghavendra@redhat.com>
Tested-by: Raghavendra Bhat <raghavendra@redhat.com>
build: FreeBSD 11-Current causes libtool to fail with '-shared'

Thanks for Markiyan Kushnir <markiyan.kushnir@gmail.com> for
reporting this

Change-Id: Ia0272e51be4ddede1e6bc188dfb892979626a7cd
BUG: 1171524
Signed-off-by: Harshavardhana <harsha@harshavardhana.net>
Reviewed-on: http://review.gluster.org/9252
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Niels de Vos <ndevos@redhat.com>
Reviewed-by: Raghavendra Bhat <raghavendra@redhat.com>
Tested-by: Raghavendra Bhat <raghavendra@redhat.com>
Stop logrotate from complaining about missing files.

Previously logrotate reported errors for files missing in
"/var/log/glusterfs/geo-replication-slaves/*/*.log". Fixed by reordering
directives in the example config.

Change-Id: I7cdb9e0d82f08aa27d5e26664660204fdeb8e98e
BUG: 1165133
Signed-off-by: Jan-Hendrik Zab <zab@l3s.de>
Reviewed-on: http://review.gluster.org/9239
Reviewed-by: Lalatendu Mohanty <lmohanty@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Raghavendra Bhat <raghavendra@redhat.com>
Tested-by: Raghavendra Bhat <raghavendra@redhat.com>
ec: Change license

This is a backport of http://review.gluster.org/9201/

Change-Id: Iae90ade2421898417b53dec0417a610cf306c44b
BUG: 1170515
Signed-off-by: Xavier Hernandez <xhernandez@datalab.es>
Reviewed-on: http://review.gluster.org/9233
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Reviewed-by: Raghavendra Bhat <raghavendra@redhat.com>
Tested-by: Raghavendra Bhat <raghavendra@redhat.com>
ec: Fix return errors when not enough bricks

Changes introduced by this patch:

* Fix an incorrect error propagation when the state of the life
  cycle of a fop returns an error.

* Fix incorrect unlocking of failed locks.

* Return ENOTCONN if there aren't enough bricks online.

* In readdir(p) check that the fd has been successfully open by
  a previous opendir.

This is a backport of http://review.gluster.org/9098/

Change-Id: Ib44f25a1297849ebcbab839332f3b6359f275ebe
BUG: 1161066
Signed-off-by: Xavier Hernandez <xhernandez@datalab.es>
Reviewed-on: http://review.gluster.org/9107
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Dan Lambright <dlambrig@redhat.com>
Reviewed-by: Raghavendra Bhat <raghavendra@redhat.com>
Tested-by: Raghavendra Bhat <raghavendra@redhat.com>
glupy: build fix if python and glusterfs prefix differ

If python is installed in ${pythonprefix} and glusterfs
in ${glusterfsprefix}, we have the following values:
${PYTHON}-config --prefix   => ${pythonprefix}
$libdir                     => ${glusterfsprefix}/lib

Using LDFLAGS="-L`${PYTHON}-config --prefix`/$libdir" we lookf for
python libraries in ${pythonprefix}/${glusterfsprefix}/lib while
we should be looking for ${pythonprefix}/lib

Replacing $libdir by lib breaks bug 1159248, so let us look in both
${pythonprefix}/lib and ${pythonprefix}/$libdir

Backport of: I2fef1b795235d1543a0e5ac619c6c2d59127fb66

BUG: 1138897
Change-Id: I29b9f121e1cdc546ca8551ff48cc99f1c71a0ea6
Signed-off-by: Emmanuel Dreyfus <manu@netbsd.org>
Reviewed-on: http://review.gluster.org/9214
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Reviewed-by: Raghavendra Bhat <raghavendra@redhat.com>
Tested-by: Raghavendra Bhat <raghavendra@redhat.com>
mgmt/glusterd: Out of bounds access to fs_info struct

Change-Id: Ibc75713d35c9cbafd493c8cf6b5294eaf29f05d4
BUG: 1163920
Signed-off-by: Petr Medonos <petr.medonos@etnetera.cz>
Reviewed-on: http://review.gluster.org/9126
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Posix: Brick failure detection fix for ext4 filesystem

Issue: stat() on XFS has a check for the filesystem status but
ext4 does not.

Fix: Replacing stat() call with open, write and read  to a new file under the
"brick/.glusterfs" directory. This change will work for xfs, ext4 and other
fileystems.

Change-Id: Id03c4bc07df4ee22916a293442bd74819b051839
BUG: 1158037
"Signed-off-by: Lalatendu Mohanty <lmohanty@redhat.com>"
"Reviewed-on: http://review.gluster.org/8213"
(cherry picked from commit a7ef6eea4d43afdba9d0453c095e71e6bf22cdb7)
Signed-off-by: Lalatendu Mohanty <lmohanty@redhat.com>
Reviewed-on: http://review.gluster.org/8988
Reviewed-by: Niels de Vos <ndevos@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Raghavendra Bhat <raghavendra@redhat.com>
Tested-by: Raghavendra Bhat <raghavendra@redhat.com>
USS : Decide the log entry based on the type of graph.

Problem : When a lookup is issued, and if the entry is not found
then snapview-client will log failure stating that
"Lookup on normal graph failed with error Stale file handle"
irrespective of type of graph it received call back from.

Solution : Introduced a check to find out the graph from which
the snapview-client received call-back.

> Change-Id: Iadd5b525c394be3675d40231711058e1cf1396cd
> BUG: 1146479
> Signed-off-by: Sachin Pandit <spandit@redhat.com>
> Reviewed-on: http://review.gluster.org/8851
> Reviewed-by: Raghavendra Bhat <raghavendra@redhat.com>
> Tested-by: Gluster Build System <jenkins@build.gluster.com>
> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
> Signed-off-by: Raghavendra Bhat <raghavendra@redhat.com>

Change-Id: I6971d3e2a44db14431205b4c14cffd86a79de51f
BUG: 1174639
Signed-off-by: Raghavendra Bhat <raghavendra@redhat.com>
Reviewed-on: http://review.gluster.org/9281
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Sachin Pandit <spandit@redhat.com>
Allow gluster to be used with linux automounter

Added (ignored) -n option to mount.glusterfs command

Cherry picked from commit f8496dab2f6111bdc5ced0881d15061160b76e52:
> Change-Id: I9209da215d38507cd9d01b1e9af4aecff4414f83
> BUG: 1123004
> Signed-off-by: Anders Blomdell <anders.blomdell@control.lth.se>
> Reviewed-on: http://review.gluster.org/8373
> Reviewed-by: Harshavardhana <harsha@harshavardhana.net>
> Tested-by: Gluster Build System <jenkins@build.gluster.com>
> Reviewed-by: Humble Devassy Chirammal <humble.devassy@gmail.com>
> Reviewed-by: Vijay Bellur <vbellur@redhat.com>

BUG: 1171259
Change-Id: I9209da215d38507cd9d01b1e9af4aecff4414f83
Signed-off-by: Niels de Vos <ndevos@redhat.com>
Reviewed-on: http://review.gluster.org/9279
Reviewed-by: Anders Blomdell <anders.blomdell@control.lth.se>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
Reviewed-by: Harshavardhana <harsha@harshavardhana.net>
Tested-by: Harshavardhana <harsha@harshavardhana.net>
uss/gluster: Fix typo error in the description for USS under "gluster volume set help"

gluster volume set help for uss shows "User Servicable Snapshots"
whereas it should be "User Serviceable Snapshots"

> Change-Id: I3cc8b3ea2cb6d209e1a12678eb7d0e68f4160d99
> BUG: 1160236
> Signed-off-by: vmallika <vmallika@redhat.com>
> Reviewed-on: http://review.gluster.org/9041
> Reviewed-by: Raghavendra Bhat <raghavendra@redhat.com>
> Tested-by: Gluster Build System <jenkins@build.gluster.com>
> Reviewed-by: Rajesh Joseph <rjoseph@redhat.com>
> Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com>
> Tested-by: Krishnan Parthasarathi <kparthas@redhat.com>
> Signed-off-by: Raghavendra Bhat <raghavendra@redhat.com>

Change-Id: Id2de0e353d3307023da9239f6dee8b59e8eb0d8f
BUG: 1175645
Reviewed-on: http://review.gluster.org/9295
Reviewed-by: Sachin Pandit <spandit@redhat.com>
Reviewed-by: Humble Devassy Chirammal <humble.devassy@gmail.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Raghavendra Bhat <raghavendra@redhat.com>
Tested-by: Raghavendra Bhat <raghavendra@redhat.com>
ec: Fix incorrect value of EC_MAX_NODES

EC_MAX_NODES was incorrectly calculated. Now the value if computed
as the minimum between the theoretical maximum and the limit imposed
by the Galois Field.

This is a backport of http://review.gluster.org/9193/

Change-Id: I75a8345147f344f051923d66be2c10d405370c7b
BUG: 1170959
Signed-off-by: Xavier Hernandez <xhernandez@datalab.es>
Reviewed-on: http://review.gluster.org/9245
Reviewed-by: Dan Lambright <dlambrig@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Raghavendra Bhat <raghavendra@redhat.com>
Tested-by: Raghavendra Bhat <raghavendra@redhat.com>
ec: Remove O_APPEND from flags on create and open.

Allowing O_APPEND flag to pass through to the brick files
corrupts fragment contents because writes are not stored on
the desired place.

Write fop has been modified so that it uses current file
size as its write offset. This guarantees that all writes,
even those comming from different file descriptors and
clients, will write to the end of the file.

This is backport of http://review.gluster.org/9079/

Change-Id: I9f721f12217a98231fe52e344166d1c94172c272
BUG: 1161885
Signed-off-by: Xavier Hernandez <xhernandez@datalab.es>
Reviewed-on: http://review.gluster.org/9080
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Dan Lambright <dlambrig@redhat.com>
Reviewed-by: Raghavendra Bhat <raghavendra@redhat.com>
Tested-by: Raghavendra Bhat <raghavendra@redhat.com>
glusterd/snapshot: mount snapshot volume with read-only option

Snapshot volumes are readonly. If you mount the volume to the client it
doesn't allow writes, but its attributes are rw which contradicts the
functionality.

mount script should set read-only attributes for snapshot volumes.

> Change-Id: I056253abd8dfe7b2b43a064fbdbd9c16b8eca679
> BUG: 1132946
> Signed-off-by: vmallika <vmallika@redhat.com>
> Reviewed-on: http://review.gluster.org/8518
> Tested-by: Gluster Build System <jenkins@build.gluster.com>
> Reviewed-by: Avra Sengupta <asengupt@redhat.com>
> Reviewed-by: Rajesh Joseph <rjoseph@redhat.com>
> Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com>
> Tested-by: Krishnan Parthasarathi <kparthas@redhat.com>
> Signed-off-by: Raghavendra Bhat <raghavendra@redhat.com>

Change-Id: Ida7340ea18a558cd15f25f2787a9794e287b17bd
BUG: 1175694
Reviewed-on: http://review.gluster.org/9296
Reviewed-by: Vijaikumar Mallikarjuna <vmallika@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Raghavendra Bhat <raghavendra@redhat.com>
Tested-by: Raghavendra Bhat <raghavendra@redhat.com>
glusterd/snapshot: Snapshot should be deactivated when it is created.

By default snapshot should be deactivated and this should be a
configurable option.

This behaviour can be configured by the command below:
gluster snapshot config activate-on-create <enable|disable>

Change-Id: I1911595c32beed43bb2fca4bf99f0d264b422513
BUG: 1170921
Signed-off-by: vmallika <vmallika@redhat.com>
Reviewed-on: http://review.gluster.org/8985
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Avra Sengupta <asengupt@redhat.com>
Reviewed-by: Rajesh Joseph <rjoseph@redhat.com>
Reviewed-by: Kaushal M <kaushal@redhat.com>
Signed-off-by: Sachin Pandit <spandit@redhat.com>
Reviewed-on: http://review.gluster.org/9241
Reviewed-by: Raghavendra Bhat <raghavendra@redhat.com>
USS : Display only the activated snapshots.

Instead of displaying all the snapshots in the uss world,
it is better if we display only the activated snapshots.

Change-Id: I70d3ec212b62ec15956ae3e826bc4201d8dedd17
BUG: 1170548
Signed-off-by: Sachin Pandit <spandit@redhat.com>
Reviewed-on: http://review.gluster.org/8958
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Avra Sengupta <asengupt@redhat.com>
Reviewed-by: Rajesh Joseph <rjoseph@redhat.com>
Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com>
Tested-by: Krishnan Parthasarathi <kparthas@redhat.com>
Signed-off-by: Sachin Pandit <spandit@redhat.com>
Reviewed-on: http://review.gluster.org/9242
Reviewed-by: Vijaikumar Mallikarjuna <vmallika@redhat.com>
Reviewed-by: Raghavendra Bhat <raghavendra@redhat.com>
uss/gluster: Move all uss related logs into subfolder.

For USS we have 1 snapd log per volume and as many snap logs for volume.
For example if there are 4 volumes having 256 snaps each and USS is
enabled than total number of logs under /var/log/glusterfs for USS would
be 1028 logs.

Total logs = (4(snapd per volume) + 4(volumes)*256(snaps)) = 1028

Hence, it makes sense to move into into sub-folder structure like

/var/log/glusterfs/snaps/<vol-name>/<snapd + snaps logs>

Change-Id: I29262e6458c3906916923cd67d1145d6ae10bec3
BUG: 1175728
Signed-off-by: vmallika <vmallika@redhat.com>
Reviewed-on: http://review.gluster.org/9050
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Rajesh Joseph <rjoseph@redhat.com>
Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com>
Tested-by: Krishnan Parthasarathi <kparthas@redhat.com>
Signed-off-by: Sachin Pandit <spandit@redhat.com>
Reviewed-on: http://review.gluster.org/9298
Reviewed-by: Raghavendra Bhat <raghavendra@redhat.com>
posix: Fix buffer overrun in _handle_list_xattr()

In _handle_list_xattr() we test remaining_size > 0 to check that
we do not overrun the buffer, but since that variable was unsigned
(size_t), the condition would let us go beyond end of buffer if
remaining_size became negative.

This could happen if attribute list grew between the first
sys_llistxattr() call that gets the size and the second sys_llistxattr()
call that get the data. We fix the problem by making remaining_size
signed (ssize_t). This also matches sys_llistxattr() return type.

While there, we use the size returned by the second sys_llistxattr()
call to parse the buffser, as it may also be smaller than the size
obtained from first call, if attribute list shrank.

This fixes a spurious crash in tests/basic/afr/resolve.t

backport of: Ifc5884dd0f39a50bf88aa51fefca8e2fa22ea913

BUG: 1138897
Change-Id: I37d4816b9cb246e34c92994cb969dc2be80be20d
Signed-off-by: Emmanuel Dreyfus <manu@netbsd.org>
Reviewed-on: http://review.gluster.org/9215
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Raghavendra Bhat <raghavendra@redhat.com>
telldir()/seekdir() portability fixes

POSIX says that an offset obtained from telldir() can only be used
on the same DIR *. Linux is abls to reuse the offset accross
closedir()/opendir() for a given directory, but this is not portable
and such a behavior should be fixed.

An incomplete fix for the posix xlator was merged in
http://review.gluster.org/8933
This change set completes it.

- Perform the same fix index xlator.
- Use appropriate casts and variable types so that 32 bit signed
  offsets obtained by telldir() do not get clobbered when copied into
  64 bit signed types.
- modify afr-self-heald.c so that it does not use anonymous fd,
  since this will cause closedir()/opendir() between each
  syncop_readdir(). On failure we fallback to anonymous fs
  only for Linux so that we can cope with updated client vs not
  updated brick.
- Avoid sending an EINVAL when the client request for the EOF offset.
  Here we fix an error in previous fix for posix xlator: since we
  fill each directory entry with the offset of the next entry, we
  must consider as EOF the offset of the last entry, and not the
  value of telldir() after we read it.

This is a backport of I59fb7f06a872c4f98987105792d648141c258c6a

BUG: 1138897
Change-Id: I1e9f3e4a7d780b98adf6d9f197ee2198d43ef94d
Signed-off-by: Emmanuel Dreyfus <manu@netbsd.org>
Reviewed-on: http://review.gluster.org/9084
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Raghavendra Bhat <raghavendra@redhat.com>