[Drbd-dev] missing shift in snapshot-resync-target-lvm.sh

Lars Ellenberg lars.ellenberg at linbit.com
Fri Feb 12 11:43:37 CET 2010


On Thu, Feb 11, 2010 at 05:46:30PM -0500, Nathan Faber wrote:
> Hi,
> 
> In 8.3.7 and in 8.3 git the shift on the percent arg is off by one and
> causes an infinite loop on before-resync-target execution.
> 
> --- snapshot-resync-target-lvm-orig.sh 2010-02-03 18:54:27.000000000 -0500
> +++ snapshot-resync-target-lvm.sh 2010-02-11 17:34:46.000000000 -0500
> @@ -44,7 +44,7 @@
>   case $1 in
>   -p|--percent)
>   SNAP_PERC="$2"
> - shift
> + shift 2
>   ;;
>   -a|--additional)
>   SNAP_ADDITIONAL="$2"

Right...
can you try this patch instead:

diff --git a/scripts/snapshot-resync-target-lvm.sh b/scripts/snapshot-resync-target-lvm.sh
index 8457e18..1971ae9 100755
--- a/scripts/snapshot-resync-target-lvm.sh
+++ b/scripts/snapshot-resync-target-lvm.sh
@@ -39,38 +39,39 @@ BE_VERBOSE=0
 SNAP_NAME=${BACKING_BDEV##*/}-before-resync
 DEFAULTFILE="/etc/default/drbd-snapshot"
 
+if [ -f $DEFAULTFILE ]; then
+	. $DEFAULTFILE
+fi
+
+## command line parameters override default file
+
 eval set -- "$TEMP"
 while true; do
 	case $1 in
-		-p|--percent)
-			SNAP_PERC="$2"
-			shift
-			;;
-		-a|--additional)
-			SNAP_ADDITIONAL="$2"
-			shift 2
-			;;
-		-n|--disconnect-on-error)
-			DISCONNECT_ON_ERROR=1
-			shift
-			;;
-		-v|--verbose)
-			BE_VERBOSE=1
-			shift
-			;;
-		--)
-			shift
-			break
-			;;
+	-p|--percent)
+		SNAP_PERC="$2"
+		shift
+		;;
+	-a|--additional)
+		SNAP_ADDITIONAL="$2"
+		shift
+		;;
+	-n|--disconnect-on-error)
+		DISCONNECT_ON_ERROR=1
+		;;
+	-v|--verbose)
+		BE_VERBOSE=1
+		;;
+	--)
+		break
+		;;
 	esac
+	shift
 done
+shift # the -- 
 
 LVC_OPTIONS="$@"
 
-if [ -f $DEFAULTFILE ]; then
-	. $DEFAULTFILE
-fi
-
 if [[ $0 == *unsnapshot* ]]; then
 	[ $BE_VERBOSE = 1 ] && set -x
 	VG_PATH=${BACKING_BDEV%/*}
@@ -80,8 +81,8 @@ else
 	(
 		set -e
 		[ $BE_VERBOSE = 1 ] && set -x
-		DRBD_DEV=$(drbdadm sh-dev $DRBD_RESOURCE)
-		DRBD_MINOR=${DRBD_DEV##/dev/drbd}
+		# it may even be a stacked resource :-/
+		DRBD_MINOR=$(drbdadm sh-minor $DRBD_RESOURCE || drbdadm -S sh-minor $DRBD_RESOURCE)
 		OUT_OF_SYNC=$(sed -ne "/^ *$DRBD_MINOR:/ "'{
 				n;
 				s/^.* oos:\([0-9]*\).*$/\1/;


-- 
: Lars Ellenberg
: LINBIT | Your Way to High Availability
: DRBD/HA support and consulting http://www.linbit.com

DRBD® and LINBIT® are registered trademarks of LINBIT, Austria.


More information about the drbd-dev mailing list