Single snapshots do weird things?
Since my last message to the list, when I found I was using an old version of the driver(4.0.2), I've done a completly new install of the kernel.org 2.4.21 sources, and the device-mapper.1.00.05 and LVM2.2.00.06 tarballs. This is still on Debian unstable, but no Debian lvm packages or kernel patches are installed this time.
I've patched the kernel with the device-mapper and VFS patch, compiled and installed both tarballs, and can insmod the dm-mod with no errors.
Now, when I copy 2Mb onto the filesystem and create an 8Mb snapshot, it's immediately flagged INACTIVE, "Allocated to snapshot" is 100% and is not mountable.
I'm using a 256k PE size and a 512Mb LV on a 10Gb disk.
Here's the sequence of commands, with output omitted where the command works normally.
lvm:~# pvcreate /dev/hdb lvm:~# vgcreate -s 256k vg0 /dev/hdb lvm:~# vgdisplay vg0 --- Volume group --- VG Name vg0 System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 1 VG Access read/write VG Status resizable MAX LV 256 Cur LV 0 Open LV 0 Max PV 256 Cur PV 1 Act PV 1 VG Size 9.54 GB PE Size 256.00 KB Total PE 39092 Alloc PE / Size 0 / 0 Free PE / Size 39092 / 9.54 GB VG UUID w7c4AZ-nmm5-BI4q-#OAm-yvSc-E0eh-#dRhSk
lvm:~# lvcreate -L 512m -n lv0 vg0 lvm:~# lvdisplay /dev/vg0/lv0 --- Logical volume --- LV Name /dev/vg0/lv0 VG Name vg0 LV UUID fAfvNg-fBhr-DCWS-Gwm6-RWfX-hHpz-EPi7zn LV Write Access read/write LV Status available # open 0 LV Size 512.00 MB Current LE 2048 Segments 1 Allocation next free (default) Read ahead sectors 0 Block device 254:0
lvm:~# mke2fs /dev/vg0/lv0
lvm:~# mount /dev/vg0/lv0 fs
lvm:~# df -k fs
/dev/vg0/lv0 507748 13 481521 1% /root/fs
lvm:~# cp -R /usr/src/device-mapper.1.00.05* fs
lvm:~# sync
lvm:~# df -k fs
/dev/vg0/lv0 507748 2028 479506 1% /root/fs
lvm:~# lvcreate -s -L 8m -p r -n snap0 -d -v /dev/vg0/lv0
Setting chunksize to 16 sectors.
Finding volume group "vg0"
Creating logical volume snap0
Archiving volume group "vg0" metadata.
Creating volume group backup "/etc/lvm/backup/vg0"
Found volume group "vg0"
Loading vg0-snap0
Found volume group "vg0"
Zeroing start of logical volume "snap0"
Found volume group "vg0"
Removing vg0-snap0
Found volume group "vg0"
Found volume group "vg0"
Found volume group "vg0"
Loading vg0-lv0-real
Loading vg0-snap0-cow
Loading vg0-snap0
Loading vg0-lv0
Creating volume group backup "/etc/lvm/backup/vg0"
Logical volume "snap0" created
lvm:~# lvdisplay /dev/vg0/snap0
--- Logical volume ---
LV Name /dev/vg0/snap0
VG Name vg0
LV UUID WL5TXy-gE0H-jQu!-BJod-XPmk-WnFL-VVgLus
LV Write Access read only
LV snapshot status INACTIVE destination for /dev/vg0/lv0
LV Status available
# open 0
LV Size 512.00 MB
Current LE 2048
Segments 1
Snapshot chunk size 8.00 KB
Allocated to snapshot 100.00%
Allocation next free (default)
Read ahead sectors 0
Block device 254:4lvm:~# mount -t ext2 /dev/vg0/snap0 snap/
mount: block device /dev/vg0/snap0 is write-protected, mounting read-only
mount: wrong fs type, bad option, bad superblock on /dev/vg0/snap0,
or too many mounted file systemsMy syslog now shows
device-mapper: 4.0.4-ioctl (2003-08-30) initialised: [email protected]
device-mapper: snapshot is marked invalid
EXT2-fs: unable to read superblock
Here's some version numbers:
lvm:~# lvm version LVM version: 2.00.06 (2003-08-20) Library version: 1.00.05-ioctl-cvs (2003-09-01) Driver version: 4.0.4
lvm:~# uname -a Linux lvm 2.4.21-dm #1 Fri Sep 12 12:52:48 EST 2003 i686 GNU/Linux
lvm:~# gcc -v Reading specs from /usr/lib/gcc-lib/i386-linux/2.95.4/specs gcc version 2.95.4 20011002 (Debian prerelease)
lvm:/usr/src# lsmod Module Size Used by Not tainted dm-mod 40364 7 3c59x 25096 1 af_packet 11976 1 rtc 6236 0 (autoclean) unix 14020 4 (autoclean)
Thanks, glen.
Quoted 3 lines · Glen Harris
Now, when I copy 2Mb onto the filesystem and create an 8Mb snapshot, it's immediately flagged INACTIVE, "Allocated to snapshot" is 100% and is not mountable.
Thanks for those diagnostics: I'll look into this further tomorrow.
Stick to using read/write snapshots for now. With read-only ones, it seems the COW device is incorrectly getting set read-only.
# dmsetup info vg0-snap0-cow Name: vg0-snap0-cow State: ACTIVE (READ-ONLY)
Alasdair
Signature · 1 line
[email protected]
Ich bin vom 15.09.2003 bis einschliesslich 17.11.2003 im Urlaub und nicht erreichbar. Bitte wenden Sie sich in dieser Zeit an meinen Kollegen Jens Jordan, [email protected].
Mit freundlichem Gruss,
Stephan Budach
I am out of office from Sep.,15th until Nov.,17th 2003. In the meantime, please contact Jens Jordan, [email protected]
Yours sincerely,
Stephan Budach
Hey, that fixed it! I've created 5 snapshots with copying/deleting files in between, and they've all worked!
Well, except for one. I copied a file and took a snapshot and the file wasn't in the snapshot. Running sync and making another snapshot *did* have the file, though.
Is it mandatory to sync the filesystem before taking a snapshot?
Quoted 2 lines · Alasdair G Kergon
Stick to using read/write snapshots for now. With read-only ones, it seems the COW device is incorrectly getting set read-only.
Signature · 13 lines
| Nine megs for the secretaries fair, | One disk to rule them all, | | Seven megs for the hackers scarce, | One disk to bind them, | | Five megs for the grads in smoky lairs, | One disk to hold the files | | Three megs for system source; | And in the darkness grind 'em. | ----------------------------------------------------------------------------- | Glen Harris | [email protected] | 07 47500893 | http://www.gbrmpa.gov.au | ----------------------------------------------------------------------------- ============================================================================= If you have received this transmission in error please notify us immediately by return email and delete all copies. Any unauthorised use, disclosure or distribution of this email is prohibited. =============================================================================
Quoted 1 line · Glen Harris
Is it mandatory to sync the filesystem before taking a snapshot?
If you want the snapshot to be consistent: that's what the VFS lock patch attempts to do automatically whenever you take a snapshot: presumably you haven't applied that patch?
Alasdair
Signature · 1 line
[email protected]
Quoted 10 lines · Alasdair G Kergon
Quoted 1 line · Glen Harris
Is it mandatory to sync the filesystem before taking a snapshot?
If you want the snapshot to be consistent: that's what the VFS lock patch attempts to do automatically whenever you take a snapshot: presumably you haven't applied that patch?
Alasdair
Yes, I applied linux-2.4.21-VFS-lock.patch as well as the devmapper patch. The behaviour is reproducable, I just did it again:
lvm:~# mount /dev/vg0/lv0 fs [Several files/dirs exist, but not device-mapper.1.00.05.tgz]
lvm:~# lvcreate -s -L 8m --n snap0 /dev/vg0/lv0 lvm:~# mount /dev/vg0/snap0 snap/0 [Not there yet!]
lvm:~# cp /usr/src/device-mapper.1.00.05.tgz fs lvm:~# lvcreate -s -L 8m --n snap1 /dev/vg0/lv0 lvm:~# mount /dev/vg0/snap1 snap/1 [Does *not* exist in the mounted snapshot filesystem]
lvm:~# sync lvm:~# lvcreate -s -L 8m --n snap2 /dev/vg0/lv0 lvm:~# mount /dev/vg0/snap2 snap/2 [Ahhh! Now it exists in *this* mounted snapshot filesystem!]
Oh, and after the file appears in the final snapshot, it doesn't magically appear in the previous one.
glen.
Signature · 13 lines
| Nine megs for the secretaries fair, | One disk to rule them all, | | Seven megs for the hackers scarce, | One disk to bind them, | | Five megs for the grads in smoky lairs, | One disk to hold the files | | Three megs for system source; | And in the darkness grind 'em. | ----------------------------------------------------------------------------- | Glen Harris | [email protected] | 07 47500893 | http://www.gbrmpa.gov.au | ----------------------------------------------------------------------------- ============================================================================= If you have received this transmission in error please notify us immediately by return email and delete all copies. Any unauthorised use, disclosure or distribution of this email is prohibited. =============================================================================
Quoted 2 lines · Glen Harris
Hey, that fixed it! I've created 5 snapshots with copying/deleting files in between, and they've all worked!
I've put a new tarball up on the ftp site containing a fix for the read-only snapshot problem together with some other minor fixes.
ftp://ftp.sistina.com/pub/LVM2/tools/LVM2.2.00.07.tgz
Alasdair
Signature · 1 line
[email protected]