Bug#246111: new version of xfs_freeze.diff

David Everly David Everly <deckrider@gmail.com>, 246111@bugs.debian.org
Fri, 29 Apr 2005 11:37:44 -0600


--0lnxQi9hkpPO77W3
Content-Type: multipart/mixed; boundary="8GpibOaaTibBMecb"
Content-Disposition: inline


--8GpibOaaTibBMecb
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

tags 239111 + patch
tags 246111 + patch
tags 243835 + patch
thanks

I'm attaching a new version of xfs_freeze.diff which can replace the
current one in the sarge version of grub (debian/patches).

For xfs, in theory it is only needed to run 'xfs_freeze -f' followed
immediately by 'xfs_freeze -u'.  This is because xfs_freeze is not
supposed to return until disk I/O is complete.  However, this is
currently not the case with kernel-image-2.6.8-2-686 2.6.8-13:

   http://bugs.debian.org/306966

So this patch defaults to a 20 second sleep (which is what consistently
works on my systems), but has a new option (--sync-sleep) to customize
the sleep time.

In any case, the existing approach which tries to freeze, run a grub
shell, and then unfreeze really needs to be corrected, since it will
ALWAYS hang a system that is a single XFS partition for everything.

--=20
Encrypted Mail Preferred:
    Key ID:  8527B9AF
    Key Fingerprint:  E1B6 40B6 B73F 695E 0D3B  644E 6427 DD74 8527 B9AF
    Information:  http://www.gnupg.org/
                                                                           =
    =20
ASCII ribbon campaign:
()  against HTML email
/\  against Microsoft attachments
    Information:  http://www.expita.com/nomime.html

--8GpibOaaTibBMecb
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="xfs_freeze.diff"
Content-Transfer-Encoding: quoted-printable

--- svn.old/util/grub-install.in	2005-04-25 11:47:21.000000000 -0600
+++ svn/util/grub-install.in	2005-04-29 10:01:11.978324529 -0600
@@ -40,6 +40,7 @@
 no_floppy=3D
 force_lba=3D
 recheck=3Dno
+sync_sleep=3D20
 debug=3Dno
=20
 # look for secure tempfile creation wrappers on this platform
@@ -70,6 +71,8 @@
   --force-lba             force GRUB to use LBA mode even for a buggy
                           BIOS
   --recheck               probe a device map even if it already exists
+  --sync-sleep            number of seconds to sleep while trying to
+                          sync XFS
=20
 INSTALL_DEVICE can be a GRUB device name or a system device filename.
=20
@@ -81,6 +84,20 @@
 EOF
 }
=20
+# Usage: xfs_hack
+# Routine to flush xfs filesystem log (sync doesn't do this)
+# sleep is needed to give time for the log to be flushed
+xfs_hack () {
+    sync
+    if which xfs_freeze >/dev/null ; then
+        echo "Trying to sync filesystem, do not interrupt until complete."
+        xfs_freeze -f ${grubdir} 2>/dev/null
+	sleep $sync_sleep
+	xfs_freeze -u ${grubdir} 2>/dev/null
+        echo "Trying to sync filesystem is complete."
+    fi
+}
+
 # Usage: convert os_device
 # Convert an OS device to the corresponding GRUB drive.
 # This part is OS-specific.
@@ -247,6 +264,8 @@
 	force_lba=3D"--force-lba" ;;
     --recheck)
 	recheck=3Dyes ;;
+    --sync-sleep=3D*)
+	sync_sleep=3D`echo "$option" | sed 's/--sync-sleep=3D//'` ;;
     # This is an undocumented feature...
     --debug)
 	debug=3Dyes ;;
@@ -336,6 +355,7 @@
     # Create a safe temporary file.
     test -n "$mklog" && log_file=3D`$mklog`
=20
+    xfs_hack
     $grub_shell --batch $no_floppy --device-map=3D$device_map <<EOF >$log_=
file
 quit
 EOF
@@ -414,6 +434,7 @@
     ${pkglibdir}/stage1 ${pkglibdir}/stage2 ${pkglibdir}/*stage1_5; do
     cp -f $file ${grubdir} || exit 1
 done
+xfs_hack
=20
 # Make a default file.
 ${grub_set_default} --root-directory=3D${rootdir} default
@@ -451,6 +472,7 @@
 test -n "$mklog" && log_file=3D`$mklog`
=20
 # Now perform the installation.
+xfs_hack
 $grub_shell --batch $no_floppy --device-map=3D$device_map <<EOF >$log_file
 root $root_drive
 setup $force_lba --stage2=3D$grubdir/stage2 --prefix=3D$grub_prefix $insta=
ll_drive

--8GpibOaaTibBMecb--

--0lnxQi9hkpPO77W3
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)

iD8DBQFCcnDnZCfddIUnua8RAi5lAJ9bRbreY9ASZSbdEQiRtJ2faipySwCeM/OH
WaR9m9jM0xmTjpkxdPTfgrg=
=/wLt
-----END PGP SIGNATURE-----

--0lnxQi9hkpPO77W3--