Distributed Replicated Block Device (DRBD) development
 help / color / mirror / Atom feed
From: Lars Ellenberg <lars.ellenberg@linbit.com>
To: drbd-dev@lists.linbit.com
Subject: Re: [Drbd-dev] missing shift in snapshot-resync-target-lvm.sh
Date: Fri, 12 Feb 2010 11:43:37 +0100	[thread overview]
Message-ID: <20100212104337.GA12119@soda.linbit> (raw)
In-Reply-To: <785112911002111446i1010e429kf36ae7dcecacaeb3@mail.gmail.com>

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.

      reply	other threads:[~2010-02-12 10:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100212104337.GA12119@soda.linbit \
    --to=lars.ellenberg@linbit.com \
    --cc=drbd-dev@lists.linbit.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox