Blob Blame History Raw
From c8d348dd59e729b8f59bd87149aa52cc16159279 Mon Sep 17 00:00:00 2001
From: Meghana M <mmadhusu@redhat.com>
Date: Tue, 30 Jun 2015 23:47:39 +0530
Subject: [PATCH 199/200] NFS-Ganesha : Unexport fails after S31ganesha-start script is run

The dbus-send script extracts the export ID from the export config file.
It expects the export ID to be written in a particular format. The post-phase
hook-script created the export file in a different format,and the dbus-send
never gets the correct export ID because of this.
Fixing the issue by replacing the write_conf function in the
S31ganesha-start hook-script.Also, NFS-Ganesha service stops when dbus signal is sent more
than once on the same export. Consecutive start/stop operations creates problems.
Fixing all the issues at once.

This is a backport of the fix upstream,
http://review.gluster.org/#/c/11477/

Change-Id: I3a80a8454f781896e85b8be7d9c3d979968afcf6
BUG: 1237053
Signed-off-by: Meghana Madhusudhan <mmadhusu@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/52233
Reviewed-by: Niels de Vos <ndevos@redhat.com>
Reviewed-by: Kaleb Keithley <kkeithle@redhat.com>
Tested-by: Kaleb Keithley <kkeithle@redhat.com>
---
 extras/ganesha/scripts/create-export-ganesha.sh    |    3 +-
 extras/hook-scripts/start/post/S31ganesha-start.sh |   46 +++++++++++--------
 2 files changed, 28 insertions(+), 21 deletions(-)

diff --git a/extras/ganesha/scripts/create-export-ganesha.sh b/extras/ganesha/scripts/create-export-ganesha.sh
index 9762c0d..668f357 100755
--- a/extras/ganesha/scripts/create-export-ganesha.sh
+++ b/extras/ganesha/scripts/create-export-ganesha.sh
@@ -32,8 +32,7 @@ function write_conf()
 {
 echo -e "# WARNING : Using Gluster CLI will overwrite manual
 # changes made to this file. To avoid it, edit the
-# file, copy it over to all the NFS-Ganesha nodes
-# and run ganesha-ha.sh --refresh-config."
+# file and run ganesha-ha.sh --refresh-config."
 
 echo "EXPORT{"
 echo "      Export_Id = 2;"
diff --git a/extras/hook-scripts/start/post/S31ganesha-start.sh b/extras/hook-scripts/start/post/S31ganesha-start.sh
index f1ca72b..a657b00 100755
--- a/extras/hook-scripts/start/post/S31ganesha-start.sh
+++ b/extras/hook-scripts/start/post/S31ganesha-start.sh
@@ -37,24 +37,27 @@ function parse_args ()
 #This function generates a new export entry as export.volume_name.conf
 function write_conf()
 {
-        echo "EXPORT{
-        "
-        echo "Export_Id = ;"
-        echo "Path=\"/$1\";"
-        echo "FSAL {
-        "
-        echo "name = "GLUSTER";"
-        echo "hostname="localhost";"
-        echo  "volume=\"$1\";"
-        echo "}"
-        echo "Access_type = RW;"
-        echo "Squash = No_root_squash;"
-        echo "Disable_ACL = TRUE;"
-        echo "Pseudo=\"/$1\";"
-        echo "Protocols = \"3\",\"4\" ;"
-        echo "Transports = \"UDP\",\"TCP\" ;"
-        echo "SecType = \"sys\";"
-        echo "}"
+echo -e "# WARNING : Using Gluster CLI will overwrite manual
+# changes made to this file. To avoid it, edit the
+# file, copy it over to all the NFS-Ganesha nodes
+# and run ganesha-ha.sh --refresh-config."
+
+echo "EXPORT{"
+echo "      Export_Id = 2;"
+echo "      Path = \"/$VOL\";"
+echo "      FSAL {"
+echo "           name = \"GLUSTER\";"
+echo "           hostname=\"localhost\";"
+echo "           volume=\"$VOL\";"
+echo "           }"
+echo "      Access_type = RW;"
+echo "      Disable_ACL = true;"
+echo "      Squash=\"No_root_squash\";"
+echo "      Pseudo=\"/$VOL\";"
+echo "      Protocols = \"3\", \"4\" ;"
+echo "      Transports = \"UDP\",\"TCP\";"
+echo "      SecType = \"sys\";"
+echo "}"
 }
 
 #This function keeps track of export IDs and increments it with every new entry
@@ -101,9 +104,14 @@ function start_ganesha()
 }
 
         parse_args $@
+        is_exported="no"
+        if showmount -e localhost | cut -d "" -f1 | grep -q "/$VOL[[:space:]]"
+        then
+              is_exported="yes"
+        fi
         ganesha_value=$(grep $ganesha_key  $GLUSTERD_WORKDIR/vols/$VOL/info |\
                         cut -d"=" -f2)
-        if [ "$ganesha_value" = "on" ]
+        if [ "$ganesha_value" = "on" -a "$is_exported" = "no" ]
         then
                 write_conf $VOL > $GANESHA_DIR/exports/export.$VOL.conf
                 start_ganesha $VOL
-- 
1.7.1