public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
From: zkabelac@sourceware.org
To: lvm-devel@redhat.com, lvm2-cvs@sourceware.org
Subject: LVM2 ./WHATS_NEW scripts/fsadm.sh
Date: Wed, 10 Nov 2010 16:14:00 -0000 [thread overview]
Message-ID: <20101110161405.12477.qmail@sourceware.org> (raw)
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac@sourceware.org 2010-11-10 16:14:03
Modified files:
. : WHATS_NEW
scripts : fsadm.sh
Log message:
fsadm fix for downsize of unmounted fs
Fix for the last commit as $MOUNTED is not only used as bool flag,
but also store mounted location for remount - so parsing output
from mount differently then from /proc/mounts.
Prefix calls of 'tunefs' tools with LANG=C to be sure we always do get
some nonlocalized strings.
Avoid using forced 'resize2fs' for cleanly unmounted filesystems and
run regular fsck -f for this case as required by resize2fs.
'fsadm check' uses date difference for extX filesystems between
the last mount and last check of 'fsck -f' execution and if the mount
was later run 'fsck' with -f so resize2fs is happy and user does not
need to pass '-f' flag.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1794&r2=1.1795
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/scripts/fsadm.sh.diff?cvsroot=lvm2&r1=1.22&r2=1.23
--- LVM2/WHATS_NEW 2010/11/10 10:05:27 1.1794
+++ LVM2/WHATS_NEW 2010/11/10 16:14:02 1.1795
@@ -1,6 +1,7 @@
Version 2.02.77 -
===================================
- Fix regression in detection of mounted filesystem for older systems (2.0.75).
+ Fix fsadm need of using '-f' for downsize of unmounted filesystem.
+ Fix fsadm regression in detection of mounted filesystem for older systems (2.0.75).
Extend cling allocation policy to recognise PV tags (cling_by_tags).
Add allocation/cling_tag_list to lvm.conf.
Regenerate configure with 'autoreconf' for --enable-ocf. (2.02.76)
--- LVM2/scripts/fsadm.sh 2010/11/10 10:03:07 1.22
+++ LVM2/scripts/fsadm.sh 2010/11/10 16:14:03 1.23
@@ -199,14 +199,19 @@
# for empty string try again with real volume name
test -z "$MOUNTED" && MOUNTED=$($GREP ^"$RVOLUME" $PROCMOUNTS)
- # for systems with different device names - check also mount output
- test -z "$MOUNTED" && MOUNTED=$($MOUNT | $GREP ^"$VOLUME")
- test -z "$MOUNTED" && MOUNTED=$($MOUNT | $GREP ^"$RVOLUME")
-
# cut device name prefix and trim everything past mountpoint
# echo translates \040 to spaces
MOUNTED=${MOUNTED#* }
MOUNTED=$(echo -n -e ${MOUNTED%% *})
+
+ # for systems with different device names - check also mount output
+ if test -z "$MOUNTED" ; then
+ MOUNTED=$(LANG=C $MOUNT | $GREP ^"$VOLUME")
+ test -z "$MOUNTED" && MOUNTED=$(LANG=C $MOUNT | $GREP ^"$RVOLUME")
+ MOUNTED=${MOUNTED##* on }
+ MOUNTED=${MOUNTED% type *} # allow type in the mount name
+ fi
+
test -n "$MOUNTED"
}
@@ -271,7 +276,7 @@
####################################
resize_ext() {
verbose "Parsing $TUNE_EXT -l \"$VOLUME\""
- for i in $($TUNE_EXT -l "$VOLUME"); do
+ for i in $(LANG=C $TUNE_EXT -l "$VOLUME"); do
case "$i" in
"Block size"*) BLOCKSIZE=${i##* } ;;
"Block count"*) BLOCKCOUNT=${i##* } ;;
@@ -284,8 +289,13 @@
if [ "$NEWBLOCKCOUNT" -lt "$BLOCKCOUNT" -o "$EXTOFF" -eq 1 ]; then
detect_mounted && verbose "$RESIZE_EXT needs unmounted filesystem" && try_umount
REMOUNT=$MOUNTED
- # CHECKME: after umount resize2fs requires fsck or -f flag.
- FSFORCE="-f"
+ if test -n "$MOUNTED" ; then
+ # Forced fsck -f for umounted extX filesystem.
+ case "$-" in
+ *i*) dry $FSCK $YES -f "$VOLUME" ;;
+ *) dry $FSCK -f -p "$VOLUME" ;;
+ esac
+ fi
fi
verbose "Resizing filesystem on device \"$VOLUME\" to $NEWSIZE bytes ($BLOCKCOUNT -> $NEWBLOCKCOUNT blocks of $BLOCKSIZE bytes)"
@@ -301,7 +311,7 @@
detect_mounted && verbose "ReiserFS resizes only unmounted filesystem" && try_umount
REMOUNT=$MOUNTED
verbose "Parsing $TUNE_REISER \"$VOLUME\""
- for i in $($TUNE_REISER "$VOLUME"); do
+ for i in $(LANG=C $TUNE_REISER "$VOLUME"); do
case "$i" in
"Blocksize"*) BLOCKSIZE=${i##*: } ;;
"Count of blocks"*) BLOCKCOUNT=${i##*: } ;;
@@ -330,7 +340,7 @@
temp_mount || error "Cannot mount Xfs filesystem"
fi
verbose "Parsing $TUNE_XFS \"$MOUNTPOINT\""
- for i in $($TUNE_XFS "$MOUNTPOINT"); do
+ for i in $(LANG=C $TUNE_XFS "$MOUNTPOINT"); do
case "$i" in
"data"*) BLOCKSIZE=${i##*bsize=} ; BLOCKCOUNT=${i##*blocks=} ;;
esac
@@ -370,6 +380,15 @@
cleanup 0
}
+####################################
+# Calclulate diff between two dates
+# LANG=C input is expected the
+# only one supported
+####################################
+diff_dates() {
+ echo $(( $(date -u -d"$1" +%s 2>/dev/null) - $(date -u -d"$2" +%s 2>/dev/null) ))
+}
+
###################
# Check filesystem
###################
@@ -379,6 +398,30 @@
verbose "Skipping filesystem check for device \"$VOLUME\" as the filesystem is mounted on $MOUNTED";
cleanup 3
fi
+
+ case "$FSTYPE" in
+ "ext2"|"ext3"|"ext4")
+ IFS_CHECK=$IFS
+ IFS=$NL
+ for i in $(LANG=C $TUNE_EXT -l "$VOLUME"); do
+ case "$i" in
+ "Last mount"*) LASTMOUNT=${i##*: } ;;
+ "Last checked"*) LASTCHECKED=${i##*: } ;;
+ esac
+ done
+ case "$LASTMOUNT" in
+ *"n/a") ;; # nothing to do - system was not mounted yet
+ *)
+ LASTDIFF=$(diff_dates $LASTMOUNT $LASTCHECKED)
+ if test "$LASTDIFF" -gt 0 ; then
+ verbose "Filesystem has not been checked after the last mount, using fsck -f"
+ FORCE="-f"
+ fi
+ ;;
+ esac
+ IFS=$IFS_CHECK
+ esac
+
case "$FSTYPE" in
"xfs") dry $XFS_CHECK "$VOLUME" ;;
*) # check if executed from interactive shell environment
next reply other threads:[~2010-11-10 16:14 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-10 16:14 zkabelac [this message]
-- strict thread matches above, loose matches on Subject: below --
2012-03-16 12:53 zkabelac
2011-09-19 14:52 zkabelac
2011-09-19 13:51 zkabelac
2011-09-19 13:47 zkabelac
2011-09-19 13:43 zkabelac
2010-11-01 14:08 zkabelac
2010-10-08 15:02 zkabelac
2010-10-08 15:00 zkabelac
2010-10-08 14:55 zkabelac
2010-10-08 14:49 zkabelac
2010-10-08 13:49 zkabelac
2010-10-08 13:47 zkabelac
2010-10-08 12:36 zkabelac
2009-06-09 15:31 zkabelac
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=20101110161405.12477.qmail@sourceware.org \
--to=zkabelac@sourceware.org \
--cc=lvm-devel@redhat.com \
--cc=lvm2-cvs@sourceware.org \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).