public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2 ./WHATS_NEW scripts/fsadm.sh tools/lvresize.c
@ 2008-02-06 12:45 zkabelac
  0 siblings, 0 replies; 2+ messages in thread
From: zkabelac @ 2008-02-06 12:45 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2008-02-06 12:45:32

Modified files:
	.              : WHATS_NEW 
	scripts        : fsadm.sh 
	tools          : lvresize.c 

Log message:
	Fix lvresize to support /dev/mapper prefix in the lvname
	Fix unfilled paramater passed to fsadm from lvresize
	Update fsadm to call lvresize if the partition size differs (with option -l)
	Fix fsadm to support vg/lv name (like the rest of lv-tools)

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.788&r2=1.789
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/scripts/fsadm.sh.diff?cvsroot=lvm2&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvresize.c.diff?cvsroot=lvm2&r1=1.92&r2=1.93

--- LVM2/WHATS_NEW	2008/02/05 09:38:04	1.788
+++ LVM2/WHATS_NEW	2008/02/06 12:45:32	1.789
@@ -2,6 +2,10 @@
 ===================================
   Update usage message for clvmd.
   Fix clvmd man page printing <br>, clarified debug options.
+  Fix lvresize to support /dev/mapper prefix in the lvname
+  Fix unfilled paramater passed to fsadm from lvresize
+  Update fsadm to call lvresize if the partition size differs (with option -l)
+  Fix fsadm to support vg/lv name (like the rest of lv-tools)
 
 Version 2.02.33 - 31st January 2008
 ===================================
--- LVM2/scripts/fsadm.sh	2008/01/08 16:45:43	1.4
+++ LVM2/scripts/fsadm.sh	2008/02/06 12:45:32	1.5
@@ -47,11 +47,14 @@
 FSCK=fsck
 XFS_CHECK=xfs_check
 
+LVRESIZE=lvresize
+
 YES=
 DRY=0
-VERB=0
+VERB=
 FORCE=
 EXTOFF=0
+DO_LVRESIZE=0
 FSTYPE=unknown
 VOLUME=unknown
 TEMPDIR="${TMPDIR:-/tmp}/${TOOL}_${RANDOM}$$/m"
@@ -78,6 +81,7 @@
 	echo "    -e | --ext-offline  unmount filesystem before Ext2/3 resize"
 	echo "    -f | --force        Bypass sanity checks"
 	echo "    -n | --dry-run      Print commands without running them"
+	echo "    -l | --lvresize     Resize given device (if it is LVM device)"
 	echo "    -y | --yes          Answer \"yes\" at any prompts"
 	echo
 	echo "  new_size - Absolute number of filesystem blocks to be in the filesystem,"
@@ -88,7 +92,7 @@
 }
 
 verbose() {
-	test "$VERB" -eq 1 && echo "$TOOL: $@" || true
+	test -n "$VERB" && echo "$TOOL: $@" || true
 }
 
 error() {
@@ -115,7 +119,12 @@
 	fi
 	IFS=$IFS_OLD
 	trap 2
-	exit $1
+
+	# start LVRESIZE with the filesystem modification flag
+	# and allow recursive call of fsadm
+	unset FSADM_RUNNING
+	test "$DO_LVRESIZE" -eq 2 && exec $LVRESIZE $VERB -r -L$(( $NEWSIZE / 1048576 )) $VOLUME
+	exit ${1:-0}
 }
 
 # convert parameter from Exa/Peta/Tera/Giga/Mega/Kilo/Bytes and blocks
@@ -133,12 +142,19 @@
 	esac
 	#NEWBLOCKCOUNT=$(round_block_size $NEWSIZE $2)
 	NEWBLOCKCOUNT=$(( $NEWSIZE / $2 ))
+
+	if [ $DO_LVRESIZE -eq 1 ]; then
+		# start lvresize, but first cleanup mounted dirs
+		DO_LVRESIZE=2
+		cleanup 0
+	fi
 }
 
 # detect filesystem on the given device
 # dereference device name if it is symbolic link
 detect_fs() {
-	VOLUME=$($READLINK -e -n "$1") || error "Cannot get readlink $1"
+        VOLUME=${1#/dev/}
+	VOLUME=$($READLINK -e -n "/dev/$VOLUME") || error "Cannot get readlink $1"
 	# use /dev/null as cache file to be sure about the result
 	FSTYPE=$($BLKID -c /dev/null -o value -s TYPE "$VOLUME") || error "Cannot get FSTYPE of \"$VOLUME\""
 	verbose "\"$FSTYPE\" filesystem found on \"$VOLUME\""
@@ -291,11 +307,12 @@
 # Resize filesystem
 ####################
 resize() {
+	NEWSIZE=$2
 	detect_fs "$1"
 	detect_device_size
 	verbose "Device \"$VOLUME\" has $DEVSIZE bytes"
 	# if the size parameter is missing use device size
-	NEWSIZE=$2
+	#if [ -n "$NEWSIZE" -a $NEWSIZE <
 	test -z "$NEWSIZE" && NEWSIZE=${DEVSIZE}b
 	trap cleanup 2
 	#IFS=$'\n'  # don't use bash-ism ??
@@ -306,7 +323,7 @@
 	  "xfs") resize_xfs $NEWSIZE ;;
 	  *) error "Filesystem \"$FSTYPE\" on device \"$VOLUME\" is not supported by this tool" ;;
 	esac || error "Resize $FSTYPE failed"
-	cleanup
+	cleanup 0
 }
 
 ###################
@@ -325,11 +342,15 @@
 # - parsing parameters
 #############################
 
+# test if we are not invoked recursively
+test -n "$FSADM_RUNNING" && exit 0
+
 # test some prerequisities
 test -n "$TUNE_EXT" -a -n "$RESIZE_EXT" -a -n "$TUNE_REISER" -a -n "$RESIZE_REISER" \
   -a -n "$TUNE_XFS" -a -n "$RESIZE_XFS" -a -n "$MOUNT" -a -n "$UMOUNT" -a -n "$MKDIR" \
   -a -n "$RMDIR" -a -n "$BLOCKDEV" -a -n "$BLKID" -a -n "$GREP" -a -n "$READLINK" \
-  -a -n "$FSCK" -a -n "$XFS_CHECK" || error "Required command definitions in the script are missing!"
+  -a -n "$FSCK" -a -n "$XFS_CHECK" -a -n "LVRESIZE" \
+  || error "Required command definitions in the script are missing!"
 $($READLINK -e -n / >/dev/null 2>&1) || error "$READLINK does not support options -e -n"
 TEST64BIT=$(( 1000 * 1000000000000 ))
 test $TEST64BIT -eq 1000000000000000 || error "Shell does not handle 64bit arithmetic"
@@ -344,11 +365,12 @@
 do
 	case "$1" in
 	 "-h"|"--help") tool_usage ;;
-	 "-v"|"--verbose") VERB=1 ;;
+	 "-v"|"--verbose") VERB="-v" ;;
 	 "-n"|"--dry-run") DRY=1 ;;
 	 "-f"|"--force") FORCE="-f" ;;
 	 "-e"|"--ext-offline") EXTOFF=1 ;;
 	 "-y"|"--yes") YES="-y" ;;
+	 "-l"|"--lvresize") DO_LVRESIZE=1 ;;
 	 "check") shift; CHECK=$1 ;;
 	 "resize") shift; RESIZE=$1; shift; NEWSIZE=$1 ;;
 	 *) error "Wrong argument \"$1\". (see: $TOOL --help)"
@@ -359,6 +381,7 @@
 if [ -n "$CHECK" ]; then
 	check "$CHECK"
 elif [ -n "$RESIZE" ]; then
+	export FSADM_RUNNING="fsadm"
 	resize "$RESIZE" "$NEWSIZE"
 else
 	error "Missing command. (see: $TOOL --help)"
--- LVM2/tools/lvresize.c	2008/01/30 14:00:02	1.92
+++ LVM2/tools/lvresize.c	2008/02/06 12:45:32	1.93
@@ -166,6 +166,7 @@
 {
 	const char *cmd_name;
 	char *st;
+	unsigned dev_dir_found = 0;
 
 	lp->sign = SIGN_NONE;
 	lp->resize = LV_ANY;
@@ -228,11 +229,12 @@
 	argv++;
 	argc--;
 
-	if (!(lp->vg_name = extract_vgname(cmd, lp->lv_name))) {
+	if (!(lp->lv_name = skip_dev_dir(cmd, lp->lv_name, &dev_dir_found))
+	    || (!(lp->vg_name = extract_vgname(cmd, lp->lv_name)))) {
 		log_error("Please provide a volume group name");
 		return 0;
 	}
-	
+
 	if (!validate_name(lp->vg_name)) {
 		log_error("Volume group name %s has invalid characters",
 			  lp->vg_name);
@@ -267,7 +269,6 @@
 	uint32_t sz, str;
 	struct list *pvh = NULL;
 	char size_buf[SIZE_BUF];
-	char lv_path[PATH_MAX];
 
 	/* does LV exist? */
 	if (!(lvl = find_lv_in_vg(vg, lp->lv_name))) {
@@ -622,6 +623,14 @@
 	log_print("Logical volume %s successfully resized", lp->lv_name);
 
 	if (lp->resizefs && (lp->resize == LV_EXTEND)) {
+		char lv_path[PATH_MAX];
+
+		if (dm_snprintf(lv_path, PATH_MAX, "%s%s/%s", cmd->dev_dir,
+				lp->vg_name, lp->lv_name) < 0) {
+			log_error("Couldn't create LV path for %s",
+				  lp->lv_name);
+			return ECMD_FAILED;
+		}
 		if (!exec_cmd("fsadm", "resize", lv_path, size_buf)) {
 			stack;
 			return ECMD_FAILED;


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

* LVM2 ./WHATS_NEW scripts/fsadm.sh tools/lvresize.c
@ 2008-04-29 15:25 zkabelac
  0 siblings, 0 replies; 2+ messages in thread
From: zkabelac @ 2008-04-29 15:25 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2008-04-29 15:25:28

Modified files:
	.              : WHATS_NEW 
	scripts        : fsadm.sh 
	tools          : lvresize.c 

Log message:
	fixing fsadm usage with older blockdev,blkid,readline tools
	fixing lvresize extension code path where size was not set for fsadm

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.863&r2=1.864
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/scripts/fsadm.sh.diff?cvsroot=lvm2&r1=1.5&r2=1.6
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvresize.c.diff?cvsroot=lvm2&r1=1.96&r2=1.97

--- LVM2/WHATS_NEW	2008/04/29 08:55:19	1.863
+++ LVM2/WHATS_NEW	2008/04/29 15:25:25	1.864
@@ -11,6 +11,8 @@
   Fix metadata corruption writing lvm1-formatted metadata with snapshots.
   Add --prefixes to reporting tools for field name prefix output format.
   Fix lvconvert -m0 allocatable space check.
+  Fix fsadm.sh to work with older blockdev,blkid,readlink
+  Fix lvresize - extension was not passing new size to fsadm
 
 Version 2.02.35 - 15th April 2008
 =================================
--- LVM2/scripts/fsadm.sh	2008/02/06 12:45:32	1.5
+++ LVM2/scripts/fsadm.sh	2008/04/29 15:25:27	1.6
@@ -43,7 +43,9 @@
 BLOCKDEV=blockdev
 BLKID=blkid
 GREP=grep
+CUT=cut
 READLINK=readlink
+READLINK_E="-e"
 FSCK=fsck
 XFS_CHECK=xfs_check
 
@@ -154,9 +156,10 @@
 # dereference device name if it is symbolic link
 detect_fs() {
         VOLUME=${1#/dev/}
-	VOLUME=$($READLINK -e -n "/dev/$VOLUME") || error "Cannot get readlink $1"
+	VOLUME=$($READLINK $READLINK_E -n "/dev/$VOLUME") || error "Cannot get readlink $1"
 	# use /dev/null as cache file to be sure about the result
-	FSTYPE=$($BLKID -c /dev/null -o value -s TYPE "$VOLUME") || error "Cannot get FSTYPE of \"$VOLUME\""
+	# use 'cut' to be compatible with older version of blkid that does not provide option '-o value'
+	FSTYPE=$($BLKID -c /dev/null -s TYPE "$VOLUME" | cut -d \" -f 2) || error "Cannot get FSTYPE of \"$VOLUME\""
 	verbose "\"$FSTYPE\" filesystem found on \"$VOLUME\""
 }
 
@@ -171,7 +174,15 @@
 
 # get the full size of device in bytes
 detect_device_size() {
-	DEVSIZE=$($BLOCKDEV --getsize64 "$VOLUME") || error "Cannot read device \"$VOLUME\""
+	# check if blockdev supports getsize64
+	$BLOCKDEV 2>&1 | $GREP getsize64 >/dev/null 
+	if test $? -eq 0; then 
+		DEVSIZE=$($BLOCKDEV --getsize64 "$VOLUME") || error "Cannot read size of device \"$VOLUME\""
+	else
+		DEVSIZE=$($BLOCKDEV --getsize "$VOLUME") || error "Cannot read size of device \"$VOLUME\""
+		SSSIZE=$($BLOCKDEV --getss "$VOLUME") || error "Cannot block size read device \"$VOLUME\""
+		DEVSIZE=$(($DEVSIZE * $SSSIZE))
+	fi
 }
 
 # round up $1 / $2
@@ -349,9 +360,10 @@
 test -n "$TUNE_EXT" -a -n "$RESIZE_EXT" -a -n "$TUNE_REISER" -a -n "$RESIZE_REISER" \
   -a -n "$TUNE_XFS" -a -n "$RESIZE_XFS" -a -n "$MOUNT" -a -n "$UMOUNT" -a -n "$MKDIR" \
   -a -n "$RMDIR" -a -n "$BLOCKDEV" -a -n "$BLKID" -a -n "$GREP" -a -n "$READLINK" \
-  -a -n "$FSCK" -a -n "$XFS_CHECK" -a -n "LVRESIZE" \
+  -a -n "$FSCK" -a -n "$XFS_CHECK" -a -n "LVRESIZE" -a -n "$CUT" \
   || error "Required command definitions in the script are missing!"
-$($READLINK -e -n / >/dev/null 2>&1) || error "$READLINK does not support options -e -n"
+
+$($READLINK -e -n / >/dev/null 2>&1) || READLINK_E="-f"
 TEST64BIT=$(( 1000 * 1000000000000 ))
 test $TEST64BIT -eq 1000000000000000 || error "Shell does not handle 64bit arithmetic"
 $(echo Y | $GREP Y >/dev/null) || error "Grep does not work properly"
--- LVM2/tools/lvresize.c	2008/04/10 19:59:43	1.96
+++ LVM2/tools/lvresize.c	2008/04/29 15:25:28	1.97
@@ -630,6 +630,11 @@
 				  lp->lv_name);
 			return ECMD_FAILED;
 		}
+		if (dm_snprintf(size_buf, SIZE_BUF, "%" PRIu64,
+				(uint64_t) lp->extents * vg->extent_size / 2) < 0) {
+		    log_error("Couldn't generate new LV size string");
+		    return ECMD_FAILED;
+		}
 		if (!exec_cmd("fsadm", "resize", lv_path, size_buf)) {
 			stack;
 			return ECMD_FAILED;


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

end of thread, other threads:[~2008-04-29 15:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-06 12:45 LVM2 ./WHATS_NEW scripts/fsadm.sh tools/lvresize.c zkabelac
2008-04-29 15:25 zkabelac

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).