]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
- create /etc/ctdb/taken_ips and /etc/ctdb/changed_ips analog to the
authorRonnie Sahlberg <sahlberg@ronnie>
Fri, 1 Jun 2007 03:14:05 +0000 (13:14 +1000)
committerRonnie Sahlberg <sahlberg@ronnie>
Fri, 1 Jun 2007 03:14:05 +0000 (13:14 +1000)
existing /etc/ctdb/released_ips

- only call the statd-callout script if the ips have changed  and call
it with a "notify" argument.    we need to restart nfslock service in
both cases

- change statd-callout to explicitely restart the lock manager and statd
when "notify" is called.   copy the state directory for each held ip
from shared storage to /tmp then use sm-notify to send notifications to
all monitored clients

(This used to be ctdb commit 800f15a27af885a3f83430d3bc411cc72ac40e86)

ctdb/tools/events
ctdb/tools/statd-callout

index f2508eafe74a86edc32b636752de49886ba0faa8..da61b8b8e8c3d7f4fb8120f586c195c542db2d7a 100755 (executable)
@@ -41,6 +41,9 @@ case $cmd in
                 echo "Failed to add $ip/$maskbits on dev $iface"
                 exit 1
        }
+       echo $ip >> /etc/ctdb/taken_ips
+       echo $ip >> /etc/ctdb/changed_ips
+
        # if we have a local arp entry for this IP then remove it
        /sbin/arp -d $ip 2> /dev/null
 
@@ -65,19 +68,27 @@ case $cmd in
        # if we have a local arp entry for this IP then remove it
        /sbin/arp -d $ip 2> /dev/null
        echo $ip >> /etc/ctdb/released_ips
+       echo $ip >> /etc/ctdb/changed_ips
        /bin/rm -f /etc/ctdb/ip.$ip
        exit 0
        ;;
 
      recovered)
-        # restart any services as necessary, like NFS
-       # 
-       [ -x /etc/ctdb/statd-callout ] && /etc/ctdb/statd-callout copy
+       # if we have taken or released any ips we must send out
+       # statd notifications to recover lost nfs locks
+       [ -x /etc/ctdb/statd-callout ] && [ -x /etc/ctdb/changed_ips ] && {
+               /etc/ctdb/statd-callout notify &
+       } >/dev/null 2>&1
+
+        # restart NFS to ensure that all TCP connections to the released ip
+       # are closed
        [ -f /etc/ctdb/released_ips ] && {
                ( /sbin/service nfs status > /dev/null 2>&1 && 
                       /sbin/service nfs restart > /dev/null 2>&1 ) &
        } > /dev/null 2>&1
+       /bin/rm -f /etc/ctdb/changed_ips
        /bin/rm -f /etc/ctdb/released_ips
+       /bin/rm -f /etc/ctdb/taken_ips
        exit 0
        ;;
 
index 5d2959aeeea315e341d0f7a43950a283b8b72027..12ecf388aadd7cbd76e6c4d187d6ce4d6c225fd6 100755 (executable)
@@ -22,23 +22,23 @@ case "$1" in
            /bin/rm -f $STATD_SHARED_DIRECTORY/$ip/$2
        done
        ;;
-  copy)
-       restart_needed=0
+  notify)
+       # restart the local lock manager and statd
+       /sbin/service nfslock stop > /dev/null 2>&1 
+       /sbin/service nfslock start > /dev/null 2>&1 
+       # send out notifications to any additional ips we now serve
         for f in `/bin/ls /etc/ctdb/ip.*`; do
            fname=`/bin/basename $f`
            ip=`echo $fname | cut -d. -f2-`
            [ -d $STATD_SHARED_DIRECTORY/$ip ] && {
-               /bin/mv $STATD_SHARED_DIRECTORY/$ip $STATD_SHARED_DIRECTORY/$ip.$$
-               /bin/cp -a $STATD_SHARED_DIRECTORY/$ip.$$/. /var/lib/nfs/statd/sm/
-               /bin/rm -rf $STATD_SHARED_DIRECTORY/$ip.$$
-               restart_needed=1
+               # we must copy to a different directory since rpc.statd gets
+               # "upset" if sm-notify touches the files.
+               /bin/rm -rf /tmp/statd/$ip
+               /bin/mkdir -p /tmp/statd/$ip
+               /bin/cp -apr $STATD_SHARED_DIRECTORY/$ip/* /tmp/statd/$ip
+               /usr/sbin/sm-notify -P /tmp/statd/$ip -v $ip -n
            }
        done
-       # restart lockd if necessary
-       [ $restart_needed -eq 1 ] && {
-               ( /sbin/service nfslock status > /dev/null 2>&1 && 
-                      /sbin/service nfslock restart > /dev/null 2>&1 ) &
-       } > /dev/null 2>&1
        ;;
 esac