diff options
author | Jeff Darcy <jdarcy@redhat.com> | 2012-04-23 11:51:22 -0400 |
---|---|---|
committer | Anand Avati <avati@redhat.com> | 2012-04-23 14:37:24 -0700 |
commit | 7d0397c2144810c8a396e00187a6617873c94002 (patch) | |
tree | 8b9739cd2fda0237be2cbfc68de0eeb0760cd52a /xlators/mount/fuse/utils | |
parent | eb9003cdca755980da9ed5a3a3fb0fc52c750131 (diff) |
fuse: allow requests during mount (needed for SELinux labels)
Change-Id: Ia1af402897e6a7290acf79617c34fdc804751729
BUG: 811217
Signed-off-by: Jeff Darcy <jdarcy@redhat.com>
Reviewed-on: http://review.gluster.com/3199
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'xlators/mount/fuse/utils')
-rwxr-xr-x | xlators/mount/fuse/utils/mount.glusterfs.in | 55 |
1 files changed, 42 insertions, 13 deletions
diff --git a/xlators/mount/fuse/utils/mount.glusterfs.in b/xlators/mount/fuse/utils/mount.glusterfs.in index 073c3609abf..aef0939db62 100755 --- a/xlators/mount/fuse/utils/mount.glusterfs.in +++ b/xlators/mount/fuse/utils/mount.glusterfs.in @@ -34,6 +34,36 @@ _init () UPDATEDBCONF=/etc/updatedb.conf } +# Mount happens asynchronously, so the command status alone will never be +# sufficient. Instead, we have to wait for multiple events representing +# different possible outcomes. +wait_for () +{ + local daemon_pid=$1 + local mount_point=$2 + + waited=0 + while true; do + kill -s 0 $daemon_pid + if [ $? != 0 ]; then + echo "Gluster client daemon exited unexpectedly." + umount $mount_point &> /dev/null + exit 1 + fi + inode=$(stat -c %i $mount_point 2>/dev/null); + if [ "$inode" = "1" ]; then + break + fi + if [ $waited -ge 10 ]; then + break + fi + sleep 1 + waited=$((waited+1)) + done + + echo "$inode" +} + start_glusterfs () { if [ -n "$log_level_str" ]; then @@ -121,34 +151,33 @@ start_glusterfs () cmd_line=$(echo "$cmd_line --volfile=$volfile_loc"); fi - cmd_line=$(echo "$cmd_line $mount_point"); - err=0; - $cmd_line; - - - inode=$(stat -c %i $mount_point 2>/dev/null); + cmd_line=$(echo "$cmd_line $mount_point") + err=0 + $cmd_line + daemon_pid=$$ + # Wait for the inode to change *or* for the daemon to exit (indicating a + # problem with the mount). + inode=$(wait_for $daemon_pid $mount_point) # this is required if the stat returns error if [ -z "$inode" ]; then - inode="0"; + inode="0" fi # retry the failover - # if [ $? != "0" ]; then # <--- TODO: Once glusterfs returns proper error code, change it. if [ $inode -ne 1 ]; then - err=1; if [ -n "$cmd_line1" ]; then cmd_line1=$(echo "$cmd_line1 $mount_point"); - $cmd_line1; - err=0; + $cmd_line1 + daemon_pid=$$ - inode=$(stat -c %i $mount_point 2>/dev/null); + inode=$(wait_for $daemon_pid $mount_point) # this is required if the stat returns error if [ -z "$inode" ]; then inode="0"; fi if [ $inode -ne 1 ]; then - err=1; + err=1 fi fi fi |