Freezing filesystems...
by Darryl L. Pierce
(forwarded from someone else regarding filesystem quiescing)
This LWN article actually summarizes the situation nicely on Linux:
http://lwn.net/Articles/287435/
Here is the final commit as it went into the kernel (in 2009):
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit...
The API is present in Fedora 13 and RHEL 6, and is backported to (at
least) RHEL 5.5 -- I didn't look at earlier versions of RHEL 5. Here
is the RHEL 6 feature request:
https://bugzilla.redhat.com/show_bug.cgi?id=236564
You can call the ioctls directly, but also very recent versions of
util-linux-ng have a utility called /sbin/fsfreeze which exposes this
functionality at the command line. This is in Fedora Rawhide, but not
in RHEL 6 AFAICT.
Only some filesystem types support freezing. On Linux they are:
ext3, ext4, reiserfs, jfs, xfs.
If you want to play with freezing filesystems without destroying
anything, I recommend virt-rescue! You will need a recent version
(Rawhide basically):
$ cd /tmp
$ rm -f test.img
$ truncate -s 1G test.img
$ virt-rescue test.img
[...]
Within virt-rescue I used /sbin/fdisk to create this layout:
><rescue> /sbin/fdisk -l /dev/vda
Disk /dev/vda: 1073 MB, 1073741824 bytes
16 heads, 63 sectors/track, 2080 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x622e09f1
Device Boot Start End Blocks Id System
/dev/vda1 1 500 251968+ 83 Linux
/dev/vda2 501 1000 252000 83 Linux
/dev/vda3 1001 2080 544320 83 Linux
I then placed ext4 filesystems on each partition, and mounted them:
><rescue> mkfs.ext4 /dev/vda1
><rescue> mkfs.ext4 /dev/vda2
><rescue> mkfs.ext4 /dev/vda3
><rescue> mkdir /sysroot/1
><rescue> mkdir /sysroot/2
><rescue> mkdir /sysroot/3
><rescue> mount /dev/vda1 /sysroot/1
><rescue> mount /dev/vda2 /sysroot/2
><rescue> mount /dev/vda3 /sysroot/3
Notice that unfrozen filesystems are not consistent:
><rescue> file -s /dev/vda1
/dev/vda1: Linux rev 1.0 ext4 filesystem data (needs journal recovery) (extents) (huge files)
But when you freeze them, they are marked as consistent in the
superblock (as if they were unmounted):
><rescue> /sbin/fsfreeze -f /sysroot/1
><rescue> file -s /dev/vda1
/dev/vda1: Linux rev 1.0 ext4 filesystem data (extents) (huge files)
and then if you unfreeze them they become inconsistent again:
><rescue> /sbin/fsfreeze -u /sysroot/1
><rescue> file -s /dev/vda1
/dev/vda1: Linux rev 1.0 ext4 filesystem data (needs journal recovery) (extents) (huge files)
The situation on Windows is reasonably advanced. They support
application level quiescing, called "Volume Shadow Copy Service",
summarised in the documents below. It all looks phenomenally complex
to me:
http://msdn.microsoft.com/en-us/library/bb968832(VS.85).aspx
http://technet.microsoft.com/en-us/library/ee923636(WS.10).aspx
I cannot see a way to quiesce a plan NTFS block device from within
Windows, although I'm sure it must exist. Maybe we can ask the guys
in Israel if they know about this?
--
Darryl L. Pierce, Sr. Software Engineer @ Red Hat, Inc.
Delivering value year after year.
Red Hat ranks #1 in value among software vendors.
http://www.redhat.com/promo/vendor/
13 years, 11 months
Supercedes previous patch...
by Darryl L. Pierce
The patch sent yesterday was the wrong one. It didn't contain the
refactored code and C APIs that replaced the C++ class Host.
13 years, 11 months
Replaced previous patch...
by Darryl L. Pierce
The previous patch was rather mangled after merging with a current patch,
so I refactored things. This patch replaces the previously submitted one.
13 years, 11 months