cluster/afr: Assign gfid path if path is NULL in lookup

Change-Id: I45be4ea7f04ee79b67a83134fe8ebd18067a707f
BUG: 820355
Signed-off-by: Pranith Kumar K <pranithk@gluster.com>
Reviewed-on: http://review.gluster.com/3373
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Amar Tumballi <amarts@redhat.com>
Reviewed-by: Raghavendra Bhat <raghavendrabhat@gluster.com>
Reviewed-by: Vijay Bellur <vijay@gluster.com>
locks: Fixed opt arg parsing in clear-locks

Change-Id: I470fd21d5d53e3c6f0bd2a4f84c6327532e18559
BUG: 823151
Signed-off-by: Krishnan Parthasarathi <kp@gluster.com>
Reviewed-on: http://review.gluster.com/3391
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vijay@gluster.com>
performance/md-cache: use mdc_fsetattr_cbk as the callback if setattr is on a fd

Change-Id: I114a16055540e0cd3317b83b329600251ffe03c3
BUG: 823886
Signed-off-by: Raghavendra Bhat <raghavendrabhat@gluster.com>
Reviewed-on: http://review.gluster.com/3386
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Amar Tumballi <amarts@redhat.com>
Reviewed-by: Anand Avati <avati@redhat.com>
common-utils: Simplified mkdir_p interface and put it to use.

- Simplified mkdir_p interface.
- Removed mkdir_if_missing from codebase
- Modified glusterd consumers of mkdir_if_missing to use mkdir_p
  with allow_symlinks=_gf_true. This implicitly assumes that glusterd
  is in 'control' of the brick path and glusterd's working dir in the sense
  that the symlinks (if any) in any of the above mentioned paths are under
  the 'storage administrator's control.

Change-Id: I7383ad5cff11b123e1e0d2fe6da0c81e03c52ed2
BUG: 823132
Signed-off-by: Krishnan Parthasarathi <kp@gluster.com>
Reviewed-on: http://review.gluster.com/3378
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
fuse, glusterfsd: mount logic fixes

Commit 7d0397c2 introduced two issues:

 i) broke the libfuse derived mount logic (details below)
ii) in case of a daemonized glusterfs client is ran as daemon, parent
    process can return earlier than the mount is in place, which breaks
    agents that programmatically do a gluster mount via a direct call to
    glusterfs (ie. not via mount(8)).

This patch fixes these issues by a refactor that merges the approaches
sported by commits

  7d0397c2 fuse: allow requests during mount (needed for SELinux labels)
  c5d781e0 upon daemonizing, wait on mtab update to terminate in parent

Original daemonized libfuse event flow is as follows:

  try:
    fd = open("/dev/fuse")
    mount("-oopts,fd=%s" % fd ...)
    mount(8) -f    # manipulate mtab
  except:
    sp = socketpair()
    env _FUSE_COMMFD=sp fusermount -oopts
    fd = receive_fd(sp)

  where fusermount(1) does:
    fd = open("/dev/fuse")
    mount("-oopts,fd=%d" % fd ...)
    sp = atoi(getenv("_FUSE_COMMFD"))
    send_fd(sp, fd)

  daemonize(
    # in child
    fuse_loop(fd)
  )
  # in parent
  exit()

As of 013850c9 (instead of adopting FUSE's 47e61004¹), we went for async
mtab manipulation, and as of c5d781e0, still wanted keep that in sync
with termination of daemon parent, so we changed it to:

  try:
    fd = open("/dev/fuse")
    mount("-oopts,fd=%s" % fd ...)
    pid = fork(
      # in child
      mount(8) -f
    )
  except:
    sp = socketpair()
    env _FUSE_COMMFD=sp fusermount -oopts
    fd = receive_fd(sp)

  daemonize(
    fuse_loop(fd)
  )
  waitpid(pid)
  exit()

(Note the new approch came only to direct [privileged] mount, so fusermount
based mounting was already partially broken.)

As of 7d0397c2, with the purpose of facilitating async mount, the event flow
was practically reduced to:

  fd = open("/dev/fuse")
  fork(
    mount("-oopts,fd=%s" % fd ...)
    fork(
      mount(8) -n
    )
  )

  daemonize(
    fuse_loop(fd)
  )
  exit()

Thus fusermount based mounting become defunct; however, the dead
code was still kept around. So, we should either drop it or fix
it. Also, the mtab manipulator is forked into yet another child
with no purpose, while syncing with it in daemon parent is broken.
mount(2) is neither synced with parent.

Now we are coming to the following scheme:

  fd = open("/dev/fuse")
  pid = fork(
    try:
      mount("-oopts,fd=%s" % fd ...)
      mount(8) -n
    except:
      env _FUSE_DEVFD=fd fusermount -oopts
  )

  where fusermount(1) does:
    fd = getenv("_FUSE_DEVFD")
    mount("-oopts,fd=%s" % fd ...)

  daemonize(
    fuse_loop(fd)
  )
  waitpid(pid)
  exit()

Nb.:

- We can't help losing compatibility with upstream fusermount,
  as it sends back the fd only when mount(2) is completed,
  thus defeating the async mount approach. The
  'getenv("_FUSE_DEVFD")' mechanism is specfic to glusterfs'
  fusermount (at the moment -- sure we can talk about it with
  upstream)

- fusermount opens /dev/fuse at same privilege level as of
  original process², so we can bravely go on with doing the open
  unconditionally in original process

- Original mounting code actually tries to mount through
  fusermount _twice_: if first attempt fails, then, assuming
  subtype support is missing in kernel, it tries again subtype
  stripped. However, this is redundant, as fusermount internally
  also performs the subtype check³. Therefore we simplified the
  logic to have just a single fusermount call.

- we revert the changes to mount.glusterfs as of 7d0397c2, as
  now there is no issue with glusterfs to work around in that scope

¹ http://fuse.git.sourceforge.net/git/gitweb.cgi?p=fuse/fuse;a=blobdiff;f=ChangeLog;h=47e61004;hb=4c3d9b19;hpb=e61b775a
² http://fuse.git.sourceforge.net/git/gitweb.cgi?p=fuse/fuse;a=blob;f=util/fusermount.c;h=b2e87d95#l1023
³ http://fuse.git.sourceforge.net/git/gitweb.cgi?p=fuse/fuse;a=blob;f=util/fusermount.c;h=b2e87d95#l839

Change-Id: I0c4ab70e0c5ad7b27337228749b266bcd0ba941d
BUG: 811217
Signed-off-by: Csaba Henk <csaba@redhat.com>
Reviewed-on: http://review.gluster.com/3341
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Jeff Darcy <jdarcy@redhat.com>
Reviewed-by: Anand Avati <avati@redhat.com>
fuse: reorganize mounting code

Macro-driven conditional compilation was a chaos.

New scheme is:

contrib/fuse-lib/mount-common.c:
  libfuse routines used both by glusterfs and fusermount
contrib/fuse-lib/mount.c:
  libfuse-derived but customized mounting code for glusterfs
contrib/fuse-util/mount_util.c:
  libfuse routines used only by fusermount

Change-Id: I3e0ba7f74e36556b78244cd7676eb4d379939602
BUG: 762389
Signed-off-by: Csaba Henk <csaba@redhat.com>
Reviewed-on: http://review.gluster.com/3342
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
fuse: sync with upstream

Cherry-picked following commits from
git://fuse.git.sourceforge.net/gitroot/fuse/fuse
form 555d6b50..acc5c79d interval:

  commit 1193a39c0869a3608f22472735bcffdcccb6b2a5
  Author: Reuben Hawkins <reubenhwk@gmail.com>

      cleaning up warnings

  commit dba9185999dfa35161d4c810735df0ab3fde5104
  Author: Laszlo Papp <ext-laszlo.papp@nokia.com>

      Check the 'mtablock' for negative value

  commit e63a9d8ee6529c9d15a87745276f45c9bdad3961
  Author: Miklos Szeredi <miklos@szeredi.hu>

      fusermount: clean up do_mount() function

  commit 81fee822a098a3e26969401fc486f136465f96f0
  Author: Laszlo Papp <ext-laszlo.papp@nokia.com>

      Eliminate the unused value

  commit 60eb44ee5eb2756465610b215968f176f4aaac6e
  Author: Laszlo Papp <ext-laszlo.papp@nokia.com>

      Fix resource leaks in fusermount

  commit d6bec4020fddd4dd67248789a1af600580f2cbda
  Author: Miklos Szeredi <mszeredi@suse.cz>

      In case of failure to add to /etc/mtab don't umount.

  commit 1e7607ff89c65b005f69e27aeb1649d624099873
  Author: Miklos Szeredi <mszeredi@suse.cz>

      fusermount: chdir to / before performing mount/umount

  commit 2fcbc2a5a94983813c533c015134c6974f8ee636
  Author: Miklos Szeredi <miklos@szeredi.hu>

      fusermount: don't save/restore cwd

  commit bd99f9cf24e16643752b02fb4fa7b48f2124ab4e
  Author: Miklos Szeredi <miklos@szeredi.hu>

      Fix check for read-only fs in mtab update

Nb.:
- not picked changes that implement and enforce mount/umount
  mechanisms based on newer util-linux features (umount --fake
  and --no-canonicalize)
- not picked fusermount "auto-unmount" feature

Change-Id: Ib9498516184336e77ec047e5414125332d0a4292
BUG: 762389
Signed-off-by: Csaba Henk <csaba@redhat.com>
Reviewed-on: http://review.gluster.com/3343
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
Thou shalt not free(3) memory dirname(3) returned

On Linux basename() and dirname() return a pointer within the string
passed as argument. On BSD flavors, basename() and dirname() return
static storage, or pthread specific storage. Both behaviour are
compliant, but calling free on the result in the second case is a bug.

BUG: 764655
Change-Id: Ic82414aff1f8db2a7544b16315761ce1c05276c4
Signed-off-by: Emmanuel Dreyfus <manu@netbsd.org>
Reviewed-on: http://review.gluster.com/3377
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Pranith Kumar Karampuri <pranithk@gluster.com>
protocol: handle proper vector size for writev()/readv()

* fixes the offset handling issue when 'xdata' is sent in writev/readv fop
  at the transport layer itself.
* client_writev() was not sending xdata on wire, fixed

Change-Id: Ib5ced64c84d415f07032662017979c65d9a1a128
Signed-off-by: Amar Tumballi <amarts@redhat.com>
BUG: 808078
Reviewed-on: http://review.gluster.com/3182
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Jeff Darcy <jdarcy@redhat.com>
Tested-by: Jeff Darcy <jdarcy@redhat.com>
Reviewed-by: Anand Avati <avati@redhat.com>
nfs/nlm: nlm-unlock call should reply success in case it is not able to find the lock in the list.

Change-Id: I84b298702c445320082ef03de90c924931f1a1e1
BUG: 822384
Signed-off-by: Krishna Srinivas <ksriniva@redhat.com>
Reviewed-on: http://review.gluster.com/3368
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
geo-rep / gsyncd: fix cleanup of temporary mounts

[This is a "forward port" of fafd5c17, http://review.gluster.com/2908]

The "finally" clause that was meant to cleanup after the
temp mount has not covered the case of getting signalled
(eg. by monitor, upon worker timing out).

So here we "outsource" the cleanup to an ephemeral child process.
Child calls setsid(2) so it won't be bothered by internal process
management. We use a pipe in between worker and the cleanup child;
when child sees the worker end getting closed, it performs the cleanup.
Worker end can get closed either because worker closes it (normal case),
or because worker has terminated (faulty case) -- thus as bonus, we get
a nice uniform handling with no need to differentiate between normal and
faulty cases.

The faulty case that was seen IRL -- ie., users of maintainance mounts
hang in chdir(2) to mount point -- can be simulated for testing purposes
by applying the following patch:

  diff --git a/xlators/mount/fuse/src/fuse-bridge.c b/xlators/mount/fuse/src/fuse-bridge.c
  index acd3c68..1ce5dc1 100644
  --- a/xlators/mount/fuse/src/fuse-bridge.c
  +++ b/xlators/mount/fuse/src/fuse-bridge.c
  @@ -2918,7 +2918,7 @@ fuse_init (xlator_t *this, fuse_in_header_t *finh, void *msg)
           if (fini->minor < 9)
                   *priv->msg0_len_p = sizeof(*finh) + FUSE_COMPAT_WRITE_IN_SIZE;
   #endif
  -        ret = send_fuse_obj (this, finh, &fino);
  +        ret = priv->client_pid_set ? 0 : send_fuse_obj (this, finh, &fino);
           if (ret == 0)
                   gf_log ("glusterfs-fuse", GF_LOG_INFO,
                           "FUSE inited with protocol versions:"

Change-Id: I14bad56a60a7fa82d0104fa4b9a20f4e42a7186f
BUG: 786291
Signed-off-by: Csaba Henk <csaba@redhat.com>
Reviewed-on: http://review.gluster.com/3259
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Jeff Darcy <jdarcy@redhat.com>
Reviewed-by: Anand Avati <avati@redhat.com>
nlm: do not use killall command to kill rpc.statd

killall command will kill the rpc.statd process only in normal mode.
If the process is running in valgrind mode, then killall is not able
to kill rpc.statd and several instances of rpc.statd will be running
for every restart of the nfs server (graph changes etc).

So to avoid that get the pid of rpc.statd using /var/run/rpc.statd.pid
and send SIGKILL signal to that pid to accomplish what killall command
was doing.

Change-Id: I2509bf918ddd0dcdd9a4562ee23f13488c7a5979
BUG: 815756
Signed-off-by: Raghavendra Bhat <raghavendrabhat@gluster.com>
Reviewed-on: http://review.gluster.com/3225
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Amar Tumballi <amarts@redhat.com>
Reviewed-by: Anand Avati <avati@redhat.com>
cli,glusterd,debug/io-stats: Clear top stats

Introduces a cli command to clear "volume top" stats. The syntax for clearing
stats is
 # gluster volume top <VOLNAME> clear [nfs]

This patch also fixes io-stats xlator, to create ios_stat struct for open fop as
well, along with create and mkdir fops. This allows stats to be recorded for
files that exist already after clearing stats or restarting brick process, which
would not occur otherwise.

Change-Id: I1b87e192025be7bb8a51eaff3d09c747d05d7def
BUG: 771709
Signed-off-by: Kaushal M <kaushal@redhat.com>
Reviewed-on: http://review.gluster.com/3334
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Amar Tumballi <amarts@redhat.com>
Reviewed-by: Anand Avati <avati@redhat.com>
swift: Passing account name in container_update.

This patch also contains fixes to bugs
  * 811501
  * 812498
  * 821310

Also, removed the default set of users in the proxy-server.conf file.

Change-Id: Ief83905d10ff7bf7c43685ada4d7f05959cee9d1
BUG: 821310
Signed-off-by: Mohammed Junaid <junaid@redhat.com>
Reviewed-on: http://review.gluster.com/3390
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vijay@gluster.com>
cluster/afr: Unlock higher entry locks in rename entrylk failure.

BUG: 823255
Change-Id: Ic6ad33518ea42c9518a21381518bd4f4afdd87cb
Signed-off-by: Pranith Kumar K <pranithk@gluster.com>
Reviewed-on: http://review.gluster.com/3382
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
core: canonicalize paths

canonicalize paths during add-brick, creation of volume,
setting nfs.export-dir in volgen

BUG: 789870
Change-Id: I1d3788ac850359b0def0457113831e825a475d58
Signed-off-by: Rajesh Amaravathi <rajesh@redhat.com>
Reviewed-on: http://review.gluster.com/3315
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
Fix volume create

Improve Krishnan Parthasarathi's patch, which fixed situation where
a brick mount point did not had EA enabled. This fixes an incorrect
assumption that dirname(3) returns the same address it was given as
argument. GNU dirname(3) does it, BSD dirname(3) does not.

Also makes the code a bit easier to read.

Change-Id: I031fda5b9359a64eefb2279e640e73a416e58d90
BUG: 812214
Signed-off-by: Emmanuel Dreyfus <manu@netbsd.org>
Reviewed-on: http://review.gluster.com/3380
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Jeff Darcy <jdarcy@redhat.com>
Reviewed-by: Anand Avati <avati@redhat.com>
mount.glusterfs: use proper format specifer for getting the inode number and
                 device type for the mount point

Change-Id: I3ca46cce61a08c8636ee9fc031a37a0a4bcb728e
BUG: 764655
Signed-off-by: Raghavendra Bhat <raghavendrabhat@gluster.com>
Reviewed-on: http://review.gluster.com/3410
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
protocol/client: do not print the null gfid when symlink fails

Change-Id: I1a2748768bc30a00c4f7b2e2fda1d282bc581658
BUG: 823880
Signed-off-by: Raghavendra Bhat <raghavendrabhat@gluster.com>
Reviewed-on: http://review.gluster.com/3411
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
distribute: use global synctask 'env' instead of local

creating a local synctask_env can lead to creating of many more
syncop threads than required. The current syncop logic can handle
the scale-up/scale-down of threads depending on the load. Hence,
its neater to use global synctask env.

Change-Id: Id46f963a0190c0154513317ae03323db155ac15a
Signed-off-by: Amar Tumballi <amarts@redhat.com>
BUG: 823774
Reviewed-on: http://review.gluster.com/3412
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>