7f4c2a
From c8d348dd59e729b8f59bd87149aa52cc16159279 Mon Sep 17 00:00:00 2001
7f4c2a
From: Meghana M <mmadhusu@redhat.com>
7f4c2a
Date: Tue, 30 Jun 2015 23:47:39 +0530
7f4c2a
Subject: [PATCH 199/200] NFS-Ganesha : Unexport fails after S31ganesha-start script is run
7f4c2a
7f4c2a
The dbus-send script extracts the export ID from the export config file.
7f4c2a
It expects the export ID to be written in a particular format. The post-phase
7f4c2a
hook-script created the export file in a different format,and the dbus-send
7f4c2a
never gets the correct export ID because of this.
7f4c2a
Fixing the issue by replacing the write_conf function in the
7f4c2a
S31ganesha-start hook-script.Also, NFS-Ganesha service stops when dbus signal is sent more
7f4c2a
than once on the same export. Consecutive start/stop operations creates problems.
7f4c2a
Fixing all the issues at once.
7f4c2a
7f4c2a
This is a backport of the fix upstream,
7f4c2a
http://review.gluster.org/#/c/11477/
7f4c2a
7f4c2a
Change-Id: I3a80a8454f781896e85b8be7d9c3d979968afcf6
7f4c2a
BUG: 1237053
7f4c2a
Signed-off-by: Meghana Madhusudhan <mmadhusu@redhat.com>
7f4c2a
Reviewed-on: https://code.engineering.redhat.com/gerrit/52233
7f4c2a
Reviewed-by: Niels de Vos <ndevos@redhat.com>
7f4c2a
Reviewed-by: Kaleb Keithley <kkeithle@redhat.com>
7f4c2a
Tested-by: Kaleb Keithley <kkeithle@redhat.com>
7f4c2a
---
7f4c2a
 extras/ganesha/scripts/create-export-ganesha.sh    |    3 +-
7f4c2a
 extras/hook-scripts/start/post/S31ganesha-start.sh |   46 +++++++++++--------
7f4c2a
 2 files changed, 28 insertions(+), 21 deletions(-)
7f4c2a
7f4c2a
diff --git a/extras/ganesha/scripts/create-export-ganesha.sh b/extras/ganesha/scripts/create-export-ganesha.sh
7f4c2a
index 9762c0d..668f357 100755
7f4c2a
--- a/extras/ganesha/scripts/create-export-ganesha.sh
7f4c2a
+++ b/extras/ganesha/scripts/create-export-ganesha.sh
7f4c2a
@@ -32,8 +32,7 @@ function write_conf()
7f4c2a
 {
7f4c2a
 echo -e "# WARNING : Using Gluster CLI will overwrite manual
7f4c2a
 # changes made to this file. To avoid it, edit the
7f4c2a
-# file, copy it over to all the NFS-Ganesha nodes
7f4c2a
-# and run ganesha-ha.sh --refresh-config."
7f4c2a
+# file and run ganesha-ha.sh --refresh-config."
7f4c2a
 
7f4c2a
 echo "EXPORT{"
7f4c2a
 echo "      Export_Id = 2;"
7f4c2a
diff --git a/extras/hook-scripts/start/post/S31ganesha-start.sh b/extras/hook-scripts/start/post/S31ganesha-start.sh
7f4c2a
index f1ca72b..a657b00 100755
7f4c2a
--- a/extras/hook-scripts/start/post/S31ganesha-start.sh
7f4c2a
+++ b/extras/hook-scripts/start/post/S31ganesha-start.sh
7f4c2a
@@ -37,24 +37,27 @@ function parse_args ()
7f4c2a
 #This function generates a new export entry as export.volume_name.conf
7f4c2a
 function write_conf()
7f4c2a
 {
7f4c2a
-        echo "EXPORT{
7f4c2a
-        "
7f4c2a
-        echo "Export_Id = ;"
7f4c2a
-        echo "Path=\"/$1\";"
7f4c2a
-        echo "FSAL {
7f4c2a
-        "
7f4c2a
-        echo "name = "GLUSTER";"
7f4c2a
-        echo "hostname="localhost";"
7f4c2a
-        echo  "volume=\"$1\";"
7f4c2a
-        echo "}"
7f4c2a
-        echo "Access_type = RW;"
7f4c2a
-        echo "Squash = No_root_squash;"
7f4c2a
-        echo "Disable_ACL = TRUE;"
7f4c2a
-        echo "Pseudo=\"/$1\";"
7f4c2a
-        echo "Protocols = \"3\",\"4\" ;"
7f4c2a
-        echo "Transports = \"UDP\",\"TCP\" ;"
7f4c2a
-        echo "SecType = \"sys\";"
7f4c2a
-        echo "}"
7f4c2a
+echo -e "# WARNING : Using Gluster CLI will overwrite manual
7f4c2a
+# changes made to this file. To avoid it, edit the
7f4c2a
+# file, copy it over to all the NFS-Ganesha nodes
7f4c2a
+# and run ganesha-ha.sh --refresh-config."
7f4c2a
+
7f4c2a
+echo "EXPORT{"
7f4c2a
+echo "      Export_Id = 2;"
7f4c2a
+echo "      Path = \"/$VOL\";"
7f4c2a
+echo "      FSAL {"
7f4c2a
+echo "           name = \"GLUSTER\";"
7f4c2a
+echo "           hostname=\"localhost\";"
7f4c2a
+echo "           volume=\"$VOL\";"
7f4c2a
+echo "           }"
7f4c2a
+echo "      Access_type = RW;"
7f4c2a
+echo "      Disable_ACL = true;"
7f4c2a
+echo "      Squash=\"No_root_squash\";"
7f4c2a
+echo "      Pseudo=\"/$VOL\";"
7f4c2a
+echo "      Protocols = \"3\", \"4\" ;"
7f4c2a
+echo "      Transports = \"UDP\",\"TCP\";"
7f4c2a
+echo "      SecType = \"sys\";"
7f4c2a
+echo "}"
7f4c2a
 }
7f4c2a
 
7f4c2a
 #This function keeps track of export IDs and increments it with every new entry
7f4c2a
@@ -101,9 +104,14 @@ function start_ganesha()
7f4c2a
 }
7f4c2a
 
7f4c2a
         parse_args $@
7f4c2a
+        is_exported="no"
7f4c2a
+        if showmount -e localhost | cut -d "" -f1 | grep -q "/$VOL[[:space:]]"
7f4c2a
+        then
7f4c2a
+              is_exported="yes"
7f4c2a
+        fi
7f4c2a
         ganesha_value=$(grep $ganesha_key  $GLUSTERD_WORKDIR/vols/$VOL/info |\
7f4c2a
                         cut -d"=" -f2)
7f4c2a
-        if [ "$ganesha_value" = "on" ]
7f4c2a
+        if [ "$ganesha_value" = "on" -a "$is_exported" = "no" ]
7f4c2a
         then
7f4c2a
                 write_conf $VOL > $GANESHA_DIR/exports/export.$VOL.conf
7f4c2a
                 start_ganesha $VOL
7f4c2a
-- 
7f4c2a
1.7.1
7f4c2a