scripts: CTDB lockvol ping-timeout should be 10secs

Users often forget to update the ping-timeout, perhaps
we should take care of this automatically

Change-Id: I6d14df8aa52665847233cb1760dfd54f41baadec
BUG: 1091600
Signed-off-by: Harshavardhana <harsha@harshavardhana.net>
Reviewed-on: http://review.gluster.org/7569
Reviewed-by: Raghavendra Talur <rtalur@redhat.com>
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>
glusterd: avoid repetitive logging of disconnect messages

NFS/SHD process disconnecting from glusterd, when the respective service
are down, would lead to repeated logging of disconnect related messages,
owing to the rpc reconnect logic in glusterfs(d). This patch addresses
that by logging the disconnect only on the first disconnect event.

Change-Id: I4008d2436721f4ba093270df4ccb3fc885f22ca0
Signed-off-by: Krishnan Parthasarathi <kparthas@redhat.com>
Reviewed-on: http://review.gluster.org/7468
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
glusterd/snapshot: Move read-only xlator to client graph

read-only xlator is moved from server graph to client graph
so that AFR & DHT healing can take place at server

Change-Id: I140ec962330c59d3b44f9bc8084a1544a1fd6c54
BUG: 1061685
Signed-off-by: Rajesh Joseph <rjoseph@redhat.com>
Reviewed-on: http://review.gluster.org/7582
Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Reviewed-by: Sachin Pandit <spandit@redhat.com>
Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
glusterd/snapshot: Activation and De-activation of snapshot

Previously, snapshots by default were activated on creation and there was
no option to activate or deactivate them on demand.

This will allow the user to activate and deactivate on demand.
The CLI goes as follows

1) Activate the snap using a command "gluster snapshot activate <snapname> [force]"
2) Deactivate the snap using a command "gluster snapshot deactivate <snapname>"

Note: Even now the snapshot will be activated during creation.

Change-Id: I0946d800780f26c63fa1fcaf29aabc900140448f
BUG: 1061685
Signed-off-by: Joseph Fernandes <josferna@redhat.com>
Reviewed-on: http://review.gluster.org/7476
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijaikumar Mallikarjuna <vmallika@redhat.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
glusterd: Differentiate rebalance status and remove-brick status messages

previously when user triggred 'gluster volume remove-brick VOLNAME
BRICK start' then command' gluster volume rebalance <volname> status'
showing output even user has not triggred "rebalance start" and when
user triggred 'gluster volume rebalance <volname> start' then command
'gluster volume remove-brick VOLNAME BRICK status' showing output even
user has not run rebalance start and remove brick start.

regression test failed in previous patch. file test/dht.rc and
test/bug/bug-973073 edited to avoid regression test failure.

now with this fix it will differentiate rebalance and remove-brick
status messages.

Signed-off-by: ggarg <ggarg@redhat.com>

Change-Id: I7f92ad247863b9f5fbc0887cc2ead07754bcfb4f
BUG: 1089668
Reviewed-on: http://review.gluster.org/7517
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
Reviewed-by: Humble Devassy Chirammal <humble.devassy@gmail.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
storage/posix: do not dereference gfid symlinks before posix_handle_mkdir_hashes()

Whenever a new directory is created, its corresponding gfid file must
also be created. This was done first calling MAKE_HANDLE_PATH() to get
the path of the gfid file, then calling posix_handle_mkdir_hashes() to
create the parent directories of the gfid, and finally creating the
soft-link.

In normal circumstances, the gfid we want to create won't exist and
MAKE_HANDLE_PATH() will return a simple path to the new gfid. However if
the volume is damaged and a self-heal is running, it is possible that we
try to create an already existing gfid. In this case, MAKE_HANDLE_PATH()
will return a path to the directory instead of the path to the gfid.

To solve this problem, every time a path to a gfid is needed, a call to
MAKE_HANDLE_ABSPATH() is made instead of the call to MAKE_HANDLE_PATH().

Change-Id: Ic319cc38c170434db8e86e2f89f0b8c28c0d611a
BUG: 859581
Signed-off-by: Xavier Hernandez <xhernandez@datalab.es>
Reviewed-on: http://review.gluster.org/5075
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
extras/hookscripts: Remove %P from smb share path value.

We had added %P in the value for path in smb share definitions to
avoid ctdb errors. However, %P does not work well for windows
clients and they fail to access the share.

Solution for the original problem:
The error messages were being generated by a monitoring script that ctdb
runs. The script reads the path value from testparm and tests if it exists
in the local machine. This particular check does not hold valid for
virtual file system backends like gluster. There is no harm in asking
ctdb to not to check the existence of such backend and can be done by
setting the following config in ctdb.conf:

CTDB_SAMBA_SKIP_SHARE_CHECK=YES.

Change-Id: I91627c8a279126a5cc24c6347847f9bfbad53dd5
BUG: 1068776
Signed-off-by: Raghavendra Talur <rtalur@redhat.com>
Reviewed-on: http://review.gluster.org/7598
Reviewed-by: Jose A. Rivera <jarrpa@redhat.com>
Reviewed-by: Poornima G <pgurusid@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Harshavardhana <harsha@harshavardhana.net>
glusterd/snapshot: Restore cleanup

If restores fails for some reason then we should revert
the restore operation. To do so we take the backup of
vols folder before doing a restore and if the restore
fails then we revert the changes done.

Change-Id: I97f72aec3a34fc122bf137beb336e94db3a04dff
BUG: 1061685
Signed-off-by: Rajesh Joseph <rjoseph@redhat.com>
Reviewed-on: http://review.gluster.org/7548
Reviewed-by: Santosh Pradhan <spradhan@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
cli/hooks : Add volume set options to enable/disable nfs-ganesha support.

1. gluster volume set nfs-ganesha.enable ON/OFF
If the option is set to ON, the volume field in the nfs-ganesha configuartion file is
edited. Gluster-nfs is disabled on that volume and the volume is exported using
nfs-ganesha.

2.gluster volume set nfs-ganesha.host IP
This is used to provide the IP of the nfs-ganesha host.

Note : nfs-ganesha.host MUST be set before using nfs-ganesha.enable ON

The switch from gluster-nfs to nfs-ganesha is mostly done by the hook-scripts
in the post phase of the 'set' option. As a result, gluster volume reset does not
function as it is expected to. By default, nfs-ganesha will be set to off but the
process  will not be killed.

Hence, a few changes have to be made post 'reset' option as well. Those changes
also have been added.

Change-Id: I7fdc14ee49d1724af96eda33c6a3ec08b1020788
BUG: 1092283
Signed-off-by: Meghana <mmadhusu@redhat.com>
Reviewed-on: http://review.gluster.org/7321
Reviewed-by: Raghavendra Talur <rtalur@redhat.com>
Reviewed-by: Santosh Pradhan <spradhan@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
barrier : barrier O_SYNC write incorrect flag check

barrier_writev function was doing the following check to determine whether its a
O_SYNC write or not:
        if (!(flags & O_SYNC))
The problem here is this flag is not fd's flag and gfapi write does not copy
open call fd's flag into write flag because of which O_SYNC writes were not
getting barriered even if barrier was enabled.

The check has been modified as:
        if (!(fd->flags & (O_SYNC | O_DSYNC)))

Change-Id: I07b23852d150b81c7317100ca6d22d082ad897cd
BUG: 1090488
Signed-off-by: Atin Mukherjee <amukherj@redhat.com>
Reviewed-on: http://review.gluster.org/7549
Reviewed-by: Varun Shastry <vshastry@redhat.com>
Reviewed-by: Santosh Pradhan <spradhan@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
barrier : fsync call over NFS should be barriered when barrier is enabled

barrier_fsync was not getting hit when fsync call is issued from the
application over NFS mount.
Investigation reveals that NFS doesn't send an explicit fsync call to the
glusterfs server, however NFS converts it with a stable write with O_DSYNC
flag, so for a fsync call over NFS mount point, barrier feature always
needs to check for writev and its correspoding flags. So to meet all the
coditions of write with O_SYNC and fsync getting blocked when barrier is
enabled the check has been modified with following:

      if (!((flags | fd->flags) & (O_SYNC | O_DSYNC)))

Point to be noted here is we need to check both fd's flag and the explicit
flag  as for NFS write fd->flags is 0.

Bug ID : 1091902
Change-Id: Ifd5377fca2cc93bb72158dd525b2aab8b4164ca8
Signed-off-by: Atin Mukherjee <amukherj@redhat.com>
Reviewed-on: http://review.gluster.org/7633
Reviewed-by: Santosh Pradhan <spradhan@redhat.com>
Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
mgmt/glusterd: handle postvalidate carefully when prevalidate fails

* Also changed the order of peers retrieval and snapshot retrieval
  upon glusterd start, so that the snapshot bricks can be properly
  resolved while cleaning up the snapshots.

Change-Id: I120704e4412a9cadb8d90a9b7969f2b4a1196bc5
BUG: 1061685
Signed-off-by: Raghavendra Bhat <raghavendra@redhat.com>
Reviewed-on: http://review.gluster.org/7494
Reviewed-by: Kaushal M <kaushal@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
glusterd : Volname, brickpath & volfpath length validation

While creating a volume and adding a brick validation for _POSIX_PATH_MAX is
done on absolute pathname instead of relative pathname due to which a brickpath
having less than _POSIX_PATH_MAX may also fail the validation if the directory
length is greater than (_POSIX_PATH_MAX -strlen(brickpath/volume name).

Also this fix addresses one cli response message correction which says the
volume file is too long instead of brick path is too long (when brickpath
length validation doesn't fail and vol file length validation fails.)

It is also important to note that with the current design of volfile naming, it
can not be guranteed that volname and brickpath can have max of _POSIX_PATH_MAX
characters.

Change-Id: I1283d1f9dea96ae797620002c8723719f26a866d
BUG: 1085330
Signed-off-by: Atin Mukherjee <amukherj@redhat.com>
Reviewed-on: http://review.gluster.org/7420
Reviewed-by: Niels de Vos <ndevos@redhat.com>
Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
protocol/server: Validate outstanding-rpc-limit

server.outstanding-rpc-limit by passes validation enforcement of gluster
as protocol/server ignores any keys starting with rpc (rpc* wildcard).
Which also causes a side effect, i.e. help text gets displayed as NULL.

Change-Id: I925e028529d671e1e29a0c7ff7e625fdb49a1be4
BUG: 1091364
Signed-off-by: Santosh Kumar Pradhan <spradhan@redhat.com>
Reviewed-on: http://review.gluster.org/7562
Reviewed-by: Poornima G <pgurusid@redhat.com>
Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
glusterd: Allow symlink parent for snap_mount_folder

If '/var' is a symlink which is on OSX, 'glusterd'
initialization fails which is not necessary fix it.

Change-Id: I83adc16cfc0e0deaa18acf74ba99299ba4a21d60
BUG: 1061685
Signed-off-by: Harshavardhana <harsha@harshavardhana.net>
Reviewed-on: http://review.gluster.org/7558
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
glusterd/snapshot: umount2 on OSX/NetBSD is unmount

Change-Id: I8de4d47bb2a54b915243ea029cce2585fba34876
BUG: 1089172
Signed-off-by: Harshavardhana <harsha@harshavardhana.net>
Reviewed-on: http://review.gluster.org/7651
Reviewed-by: Justin Clift <justin@gluster.org>
Tested-by: Justin Clift <justin@gluster.org>
Reviewed-by: Anand Avati <avati@redhat.com>
changelog: in C99 `inline` shouldn't be part of function definition

- C99 standard dictates that `inline` should be used only to hint
  function implementation not as a definition
          - http://clang.llvm.org/compatibility.html#inline
  This also leads to run time issues as 'undefined symbols'

- Remember to use adding explicit headers when using an external
  function

Change-Id: I66a9030da7ac38ded6e0b6a977182be977382fa2
BUG: 1089172
Signed-off-by: Harshavardhana <harsha@harshavardhana.net>
Reviewed-on: http://review.gluster.org/7655
Reviewed-by: Anand Avati <avati@redhat.com>
Tested-by: Anand Avati <avati@redhat.com>
glusterfs.spec: Add missing files in %files section

Thanks to Niels for all the help in finding RCA.

Change-Id: I5678c53a5c04de18ccd676fbaf5bf8b0c77c9c14
BUG: 1080970
Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
Reviewed-on: http://review.gluster.org/7645
Reviewed-by: Niels de Vos <ndevos@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
mgmt/gluster: Use fsync instead of O_SYNC

Glusterd uses O_SYNC to write to temp file then performs renames
to the actual file and performs fsync on parent directory. Until
this rename happens syncing writes to the file can be deferred.
In this patch O_SYNC open of temp file is removed and fsync of the
fd before rename is done.

Change-Id: Ie7da161b0daec845c7dcfab4154cc45c2f49d825
BUG: 908277
Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
Reviewed-on: http://review.gluster.org/7370
Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com>
Reviewed-by: Raghavendra Bhat <raghavendra@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
statedump: strfd based APIs

Expose strfd based APIs for extracing various types of xlator
state information.

Change-Id: Ibbb6594b6fb31206bc6a1b1ea6514ed41889583b
BUG: 1089216
Signed-off-by: Anand Avati <avati@redhat.com>
Reviewed-on: http://review.gluster.org/7540
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Harshavardhana <harsha@harshavardhana.net>