21ab4e
From ad1155ea55a042bec47f43973399d0742263c54f Mon Sep 17 00:00:00 2001
21ab4e
From: Jiffin Tony Thottan <jthottan@redhat.com>
21ab4e
Date: Fri, 30 Jun 2017 17:11:46 +0530
21ab4e
Subject: [PATCH 566/566] systemd/glusterfssharedstorage : remove dependency
21ab4e
 for var-run-gluster-shared_storage
21ab4e
21ab4e
Currently the script used by glusterfssharedstorage have dependency over
21ab4e
var-run-gluster-shared_storage. But this service will be present only if
21ab4e
node has rebooted. Also in reboot scenario , there is a chance that this
21ab4e
service can be executed before creating var-run-gluster-shared_storage.
21ab4e
In that case glusterfssharedstorage will get succeed even without mounting
21ab4e
the shared storage
21ab4e
21ab4e
Also the type of glusterfssharedstorage changed to "forking" so that it can
21ab4e
be active(instead of dead) after the successful start.
21ab4e
21ab4e
Upstream reference
21ab4e
>Change-Id: I1c02cc64946e534d845aa7ec7b72644bbe4d26f9
21ab4e
>BUG: 1452527
21ab4e
>Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com>
21ab4e
>https://review.gluster.org/#/c/17658/
21ab4e
21ab4e
Change-Id: I1c02cc64946e534d845aa7ec7b72644bbe4d26f9
21ab4e
BUG: 1335090
21ab4e
Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com>
21ab4e
Reviewed-on: https://code.engineering.redhat.com/gerrit/112440
21ab4e
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
21ab4e
---
21ab4e
 extras/mount-shared-storage.sh                   | 43 ++++++++++++------------
21ab4e
 extras/systemd/glusterfssharedstorage.service.in |  1 +
21ab4e
 2 files changed, 22 insertions(+), 22 deletions(-)
21ab4e
21ab4e
diff --git a/extras/mount-shared-storage.sh b/extras/mount-shared-storage.sh
21ab4e
index 038a59a..3645a0f 100755
21ab4e
--- a/extras/mount-shared-storage.sh
21ab4e
+++ b/extras/mount-shared-storage.sh
21ab4e
@@ -4,34 +4,33 @@
21ab4e
 #try to mount the shared storage if it fails
21ab4e
 #TODO : Do it for other glusterfs clients in /etc/fstab
21ab4e
 
21ab4e
-ms="var-run-gluster-shared_storage.mount"
21ab4e
 volume="gluster_shared_storage"
21ab4e
-failed=$(systemctl --failed | grep -c $ms)
21ab4e
-if [ $failed -eq 1 ]
21ab4e
+mp="/var/run/gluster/shared_storage"
21ab4e
+#check if there is fstab entry for shared storage
21ab4e
+gfc=$(sed -e 's/#.$//' 
21ab4e
+if [ $gfc -eq 0 ]
21ab4e
 then
21ab4e
-        if systemctl restart $ms
21ab4e
-        then
21ab4e
-                #Restart worked just wait for sometime to make it reflect
21ab4e
-                sleep 5
21ab4e
-        else
21ab4e
-                #Restart failed, no point in further continuing
21ab4e
-                exit 1
21ab4e
-        fi
21ab4e
+	exit 0
21ab4e
 fi
21ab4e
 
21ab4e
-# If we've reached this point, there wasn't a failed mountpoint
21ab4e
-# BUT we need to check for whether this haven't been called before the attempts
21ab4e
-# to the filesystem mounts, thus we need to check whether there is a glusterfs
21ab4e
-# in fstab and aren't mountedmount
21ab4e
+#check whether shared storage is mounted
21ab4e
+#if it is mounted then mount has inode value 1
21ab4e
+inode=$(ls -id $mp | awk '{print $1}')
21ab4e
 
21ab4e
-#In the logs I've seen ~4-5secs between the initial mount/start and the unmount
21ab4e
+if [ $inode -eq 1 ]
21ab4e
+then
21ab4e
+	exit 0
21ab4e
+fi
21ab4e
 
21ab4e
-gfc=$(sed -e 's/#.$//' 
21ab4e
-gfm=$(grep -i $volume /proc/mounts | wc -l)
21ab4e
+mount -t glusterfs localhost:/$volume $mp
21ab4e
+#wait for few seconds
21ab4e
+sleep 5
21ab4e
 
21ab4e
-if [ $gfm -lt $gfc ]
21ab4e
+#recheck mount got succeed
21ab4e
+inode=$(ls -id $mp | awk '{print $1}')
21ab4e
+if [ $inode -eq 1 ]
21ab4e
 then
21ab4e
-        exit 1
21ab4e
+	exit 0
21ab4e
+else
21ab4e
+	exit 1
21ab4e
 fi
21ab4e
-
21ab4e
-exit 0
21ab4e
diff --git a/extras/systemd/glusterfssharedstorage.service.in b/extras/systemd/glusterfssharedstorage.service.in
21ab4e
index 3bceba8..723ff49 100644
21ab4e
--- a/extras/systemd/glusterfssharedstorage.service.in
21ab4e
+++ b/extras/systemd/glusterfssharedstorage.service.in
21ab4e
@@ -3,6 +3,7 @@ Description=Mount glusterfs sharedstorage
21ab4e
 Requires=glusterd.service remote-fs-pre.target local-fs.target
21ab4e
 
21ab4e
 [Service]
21ab4e
+Type=forking
21ab4e
 ExecStart=@GLUSTERFS_LIBEXECDIR@/mount-shared-storage.sh
21ab4e
 Restart=on-failure
21ab4e
 RestartSec=3
21ab4e
-- 
21ab4e
1.8.3.1
21ab4e