gfapi: optimistic resolution with ESTALE detection

Enhance the path resolver to be optimistic. Instead of performing
a wasteful ->lookup() fop for every component in every API call,
build in speculation logic to consider the previous resolution
result temporarily, and if it results in ESTALE either later in
the path resolution or in the FOP, then retry resolution with
->lookup() at every level and retry the FOP.

This is the same optimistic resolution/retry logic Linux kernel
resolver is proposing to use.

Change-Id: Iecbc25248754caf0915cd7205910563ff88ce5e7
BUG: 953694
Signed-off-by: Anand Avati <avati@redhat.com>
Reviewed-on: http://review.gluster.org/4928
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
md-cache: support negative xattr entries

Add support for negative xattr caching. For this, we need
to fetch xattrs in every opportunity (including readdirplus)
in order to treat missing key in cached dict as negative entry.

This is crucial to detect missing ACL xattrs in Samba workload.

Change-Id: I918a2ef4ab804724256f7546b15e808332ed518d
BUG: 953694
Signed-off-by: Anand Avati <avati@redhat.com>
Reviewed-on: http://review.gluster.org/4929
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
syncop: copy inode pointer in readdirplus

Change-Id: I9ab2b8ac2da9fe13f56b8b08f715a0b603ece0cb
BUG: 953694
Signed-off-by: Anand Avati <avati@redhat.com>
Reviewed-on: http://review.gluster.org/4930
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
gfapi: link inodes in relevant entry FOPs

Do not let inode linking to happen only in lookup(). While
that works, it is inefficient.

Change-Id: I51bbfb6255ec4324ab17ff00566375f49d120c06
BUG: 953694
Signed-off-by: Anand Avati <avati@redhat.com>
Reviewed-on: http://review.gluster.org/4931
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
dht,posix: support for case discovery

This is support for discovering a filename in a given directory
which has a case insensitive match of a given name. It is implemented
as a virtual extended attribute on the directory where the required
filename is specified in the key.

E.g:

  sh# getfattr -e "text" -n user.glusterfs.get_real_filename:FiLe-B /mnt/samba/patchy
  getfattr: Removing leading '/' from absolute path names
  # file: mnt/samba/patchy
  user.glusterfs.get_real_filename:FiLe-B="file-b"

In reality, there can be multiple "answers" as the backend filesystem is
case sensitive and there can be multiple files which can strcasecamp()
successfully. In this case we pick the first matched file from the first
responding server.

If a matching file does not exist, we return ENOENT (and NOT ENODATA).
This way the caller can differentiate between "unsupported" glusterfs
API and file not existing.

This API is used by Samba VFS to perform efficient discovery of the real
filename without doing a full scan at the Samba level.

Change-Id: I53054c4067cba69e585fd0bbce004495bc6e39e8
BUG: 953694
Signed-off-by: Anand Avati <avati@redhat.com>
Reviewed-on: http://review.gluster.org/4941
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
gfapi: provide stable st_dev in stat structure

Samba depends on st_dev being unique and stable for different
filesystems (it uses st_dev+st_ino as key to store metadata of
a file).

Change-Id: Ia022fabadfb5ef3fc9724c1b1ca86f1a20f98af9
BUG: 953694
Signed-off-by: Anand Avati <avati@redhat.com>
Reviewed-on: http://review.gluster.org/5045
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
pkg-config: present API version and not package version

This way PKG_MODULE() autoconf test checks for required API
rather than release version (e.g required API could be in all
all of 3.4.5, 3.5.1, 3.6.4 etc.)

With the first "release" of gfapi, the current version (4) will
be frozen.

Version 3 is sufficient for QEMU's requirement. Version 4 is
necessary for Samba VFS

Change-Id: Iada3a4c88b9c67413dcd57004fd8a62926a21b42
BUG: 953694
Signed-off-by: Anand Avati <avati@redhat.com>
Reviewed-on: http://review.gluster.org/4932
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
gfapi: ignore NULL and -1 parameters in glfs_set_logging()

Permit changing either logfile or level by specifying the other
as -1 or NULL respectively.

Change-Id: I7df05db7b613c57e0106a5cce846ae26d2a160d4
BUG: 953694
Signed-off-by: Anand Avati <avati@redhat.com>
Reviewed-on: http://review.gluster.org/5085
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
extras: prevent "glusterd dead but subsys locked"

Commit b5bf14a6 added support for a file under /var/lock/subsys,
Hoewever, killproc does remove the $PIDFILE which cases subsequent
checks on its existence to fail. When glusterd was stopped successfully,
the $PIDFILE has been removed already, there is no need to try to remove
is again.

Upon executing '/sbin/service glusterd status', the message 'glusterd
dead but subsys locked' would be returned because the file under
/var/lock/subsys was not removed.

Bug: 960476
Change-Id: I781fe463e3c5472e42d668155cee4f63d349a568
Reported-by: Satheesaran Sundaramoorthi <sasundar@redhat.com>
Signed-off-by: Niels de Vos <ndevos@redhat.com>
Reviewed-on: http://review.gluster.org/5074
Reviewed-by: Jeff Darcy <jdarcy@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
glusterd: Allow volume start force to succeed if brick directories are recreated

Change-Id: I4fc3c5c829adca256bb131f4a2722abc95741158
BUG: 963665
Signed-off-by: Krutika Dhananjay <kdhananj@redhat.com>
Reviewed-on: http://review.gluster.org/5020
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Amar Tumballi <amarts@redhat.com>
Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>