The branch, master has been updated
       via  d967789 ctdb-scripts: Fix CTDB_DBDIR=tmpfs support
      from  3968e33 ctdb: Remove unused ctdb_set_process_name

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit d9677894b7aa2248e1884ab9e21667879bf1e3c4
Author: Martin Schwenke <mar...@meltin.net>
Date:   Tue Nov 17 14:57:44 2015 +1100

    ctdb-scripts: Fix CTDB_DBDIR=tmpfs support
    
    Various scripts (including debug_locks.sh, 00.ctdb, 05.system) need
    CTDB_DBDIR to point to the right place... but it doesn't.
    
    Move the rewriting of CTDB_DBDIR to loadconfig() so that it happens
    for all scripts.  Have this code set internal variable
    CTDB_DBDIR_TMPFS_OPTIONS so that ctdbd_wrapper can do the mount.
    
    This loses the generality that was present in dbdir_tmpfs_start() but
    it wasn't being used anyway.  If it is needed in the future then it
    will be in the git history.
    
    Signed-off-by: Martin Schwenke <mar...@meltin.net>
    Reviewed-by: Amitay Isaacs <ami...@gmail.com>
    
    Autobuild-User(master): Amitay Isaacs <ami...@samba.org>
    Autobuild-Date(master): Wed Nov 18 11:51:54 CET 2015 on sn-devel-104

-----------------------------------------------------------------------

Summary of changes:
 ctdb/config/ctdbd_wrapper | 79 ++++++++++++++++-------------------------------
 ctdb/config/functions     | 25 +++++++++++++++
 2 files changed, 52 insertions(+), 52 deletions(-)


Changeset truncated at 500 lines:

diff --git a/ctdb/config/ctdbd_wrapper b/ctdb/config/ctdbd_wrapper
index 71c7b25..be251e6 100755
--- a/ctdb/config/ctdbd_wrapper
+++ b/ctdb/config/ctdbd_wrapper
@@ -25,7 +25,6 @@ loadconfig "ctdb"
 [ -n "$CTDB_SOCKET" ] && export CTDB_SOCKET
 
 ctdbd="${CTDBD:-/usr/local/sbin/ctdbd}"
-ctdb_rundir="/usr/local/var/run/ctdb"
 
 ############################################################
 
@@ -80,61 +79,37 @@ ctdbd_is_running ()
 
 ############################################################
 
-# Mount given database directories on tmpfs
+# If necessary, mount volatile database directory on tmpfs
 dbdir_tmpfs_start ()
 {
-    for _var ; do
-       # $_var is the name of the configuration varable, so get the
-       # value
-       eval _val="\$${_var}"
-
-       case "$_val" in
-           tmpfs|tmpfs:*)
-               _opts_defaults="mode=700"
-               # Get any extra options specified after colon
-               if [ "$_val" = "tmpfs" ] ; then
-                   _opts=""
-               else
-                   _opts="${_val#tmpfs:}"
-               fi
-               # It is OK to repeat options - last value wins
-               _opts_all="${_opts_defaults}${_opts:+,}${_opts}"
-
-               # Last component of mountpoint is variable name
-               _mnt="${ctdb_rundir}/${_var}"
-               mkdir -p "$_mnt" || exit $?
-
-               # If already mounted then remount, otherwise mount
-               if findmnt -t tmpfs "$_mnt" >/dev/null ; then
-                   mount -t tmpfs -o "remount,$_opts_all" none "$_mnt" || \
-                       exit $?
-               else
-                   mount -t tmpfs -o "$_opts_all" none "$_mnt" || exit $?
-               fi
-
-               # Replace specified value with mountpoint, to be
-               # passed to ctdbd
-               eval "${_var}=${_mnt}"
-               ;;
-       esac
-    done
+    if [ -z "$CTDB_DBDIR_TMPFS_OPTIONS" ] ; then
+       return
+    fi
+
+    # Shortcut for readability
+    _opts="$CTDB_DBDIR_TMPFS_OPTIONS"
+
+    mkdir -p "$CTDB_DBDIR" || exit $?
+
+    # If already mounted then remount, otherwise mount
+    if findmnt -t tmpfs "$CTDB_DBDIR" >/dev/null ; then
+       mount -t tmpfs -o "remount,$_opts" none "$CTDB_DBDIR" || \
+           exit $?
+    else
+       mount -t tmpfs -o "$_opts" none "$CTDB_DBDIR" || exit $?
+    fi
 }
 
-# Unmount database tmpfs directories on exit
+# If necessary, unmount volatile database tmpfs directory on exit
 dbdir_tmpfs_stop ()
 {
-    for _var ; do
-       eval _val="\$${_var}"
-
-       case "$_val" in
-           tmpfs|tmpfs:*)
-               _mnt="${ctdb_rundir}/${_var}"
-               if [ -d "$_mnt" ] && findmnt -t tmpfs "$_mnt" >/dev/null ; then
-                   umount "$_mnt"
-               fi
-               ;;
-       esac
-    done
+    if [ -z "$CTDB_DBDIR_TMPFS_OPTIONS" ] ; then
+       return
+    fi
+
+    if [ -d "$CTDB_DBDIR" ] && findmnt -t tmpfs "$CTDB_DBDIR" >/dev/null ; then
+       umount "$CTDB_DBDIR"
+    fi
 }
 
 build_ctdb_options ()
@@ -223,7 +198,7 @@ start()
     # there may still be other processes around, so do some cleanup.
     kill_ctdbd "$_session"
 
-    dbdir_tmpfs_start CTDB_DBDIR
+    dbdir_tmpfs_start
 
     build_ctdb_options
 
@@ -334,7 +309,7 @@ stop()
        fi
     fi
 
-    dbdir_tmpfs_stop CTDB_DBDIR
+    dbdir_tmpfs_stop
 
     return 0
 }
diff --git a/ctdb/config/functions b/ctdb/config/functions
index 49bed98..eef8f7e 100755
--- a/ctdb/config/functions
+++ b/ctdb/config/functions
@@ -8,6 +8,7 @@ if [ -z "$CTDB_BASE" ] ; then
 fi
 
 CTDB_VARDIR="/usr/local/var/lib/ctdb"
+ctdb_rundir="/usr/local/var/run/ctdb"
 
 # Only (and always) override these variables in test code
 
@@ -21,6 +22,29 @@ fi
 
 #######################################
 # pull in a system config file, if any
+
+rewrite_ctdb_options ()
+{
+    case "$CTDB_DBDIR" in
+       tmpfs|tmpfs:*)
+           _opts_defaults="mode=700"
+           # Get any extra options specified after colon
+           if [ "$CTDB_DBDIR" = "tmpfs" ] ; then
+               _opts=""
+           else
+               _opts="${CTDB_DBDIR#tmpfs:}"
+           fi
+           # This is an internal variable, only used by ctdbd_wrapper.
+           # It is OK to repeat mount options - last value wins
+           CTDB_DBDIR_TMPFS_OPTIONS="${_opts_defaults}${_opts:+,}${_opts}"
+
+           CTDB_DBDIR="${ctdb_rundir}/CTDB_DBDIR"
+           ;;
+       *)
+           CTDB_DBDIR_TMPFS_OPTIONS=""
+    esac
+}
+
 _loadconfig() {
 
     if [ -z "$1" ] ; then
@@ -52,6 +76,7 @@ _loadconfig() {
        if [ -r "$_config" ] ; then
            . "$_config"
        fi
+       rewrite_ctdb_options
     fi
 }
 


-- 
Samba Shared Repository

Reply via email to