Distributed Replicated Block Device (DRBD) development
 help / color / mirror / Atom feed
* [Drbd-dev] missing shift in snapshot-resync-target-lvm.sh
@ 2010-02-11 22:46 Nathan Faber
  2010-02-12 10:43 ` Lars Ellenberg
  0 siblings, 1 reply; 2+ messages in thread
From: Nathan Faber @ 2010-02-11 22:46 UTC (permalink / raw)
  To: drbd-dev

[-- Attachment #1: Type: text/plain, Size: 410 bytes --]

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"

[-- Attachment #2: Type: text/html, Size: 1225 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Drbd-dev] missing shift in snapshot-resync-target-lvm.sh
  2010-02-11 22:46 [Drbd-dev] missing shift in snapshot-resync-target-lvm.sh Nathan Faber
@ 2010-02-12 10:43 ` Lars Ellenberg
  0 siblings, 0 replies; 2+ messages in thread
From: Lars Ellenberg @ 2010-02-12 10:43 UTC (permalink / raw)
  To: drbd-dev

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.

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-02-12 10:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-11 22:46 [Drbd-dev] missing shift in snapshot-resync-target-lvm.sh Nathan Faber
2010-02-12 10:43 ` Lars Ellenberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox