Snapshots are never freed on at least 8.1 and 8.2
Yamagi Burmeister
lists at yamagi.org
Wed Mar 16 08:27:11 UTC 2011
Hello,
I'm not sure if this is a bug or the expected behavior but it seems quit
strange. On at least FreeBSD 8.1 and 8.2 UFS2 snapshots are never freed
while the filesystem is mounted. Therefor you have to remount every 20
snapshots which is quiet a pain when using "dump -L" or similar things
via cron.
Example:
--------
1. Create a new filesystem and copy some data on it:
% mdmfs -s 512M md0 /mnt/
% cp -r /usr/src/sys /mnt/
2. Create 20 snapshots (in tcsh-syntax):
% foreach i ( 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 )
% mksnap_ffs /mnt/ /mnt/.snap/${i}
% end
3. "snapinfo -a" shows 20 snapshots.
% root at saya:pts/3 ~> snapinfo -a
/mnt/.snap/1
/mnt/.snap/2
/mnt/.snap/3
/mnt/.snap/4
/mnt/.snap/5
/mnt/.snap/6
/mnt/.snap/7
/mnt/.snap/8
/mnt/.snap/9
/mnt/.snap/10
/mnt/.snap/11
/mnt/.snap/12
/mnt/.snap/13
/mnt/.snap/14
/mnt/.snap/15
/mnt/.snap/16
/mnt/.snap/17
/mnt/.snap/18
/mnt/.snap/19
/mnt/.snap/20
4. Further snapshots cannot be created since there's a limit of 20
snapshots per filesystem:
% mksnap_ffs /mnt/ /mnt/.snap/21
mksnap_ffs: Cannot create snapshot /mnt/.snap/21: No space left on device
5. Now delete the snapshots:
% rm -Rf /mnt/.snap/*
6. "snapinfo -a" tells us that there are no snapshots in the filesystem:
% snapinfo -a
%
7. But when we want create a new snapshot it fails:
% mksnap_ffs /mnt/ /mnt/.snap/1
mksnap_ffs: Cannot create snapshot /mnt/.snap/1: No space left on device
8. "ffsinfo /dev/md0 | grep snapinum" shows us 20 snapshots!
% ffsinfo /dev/md0 | grep snapinum
snapinum int32_t[ 0] 0x00000004
snapinum int32_t[ 1] 0x00000005
snapinum int32_t[ 2] 0x00000006
snapinum int32_t[ 3] 0x00000007
snapinum int32_t[ 4] 0x00000008
snapinum int32_t[ 5] 0x00000009
snapinum int32_t[ 6] 0x0000000a
snapinum int32_t[ 7] 0x0000000b
snapinum int32_t[ 8] 0x0000000c
snapinum int32_t[ 9] 0x0000000d
snapinum int32_t[10] 0x0000000e
snapinum int32_t[11] 0x0000000f
snapinum int32_t[12] 0x00000010
snapinum int32_t[13] 0x00000011
snapinum int32_t[14] 0x00000012
snapinum int32_t[15] 0x00000013
snapinum int32_t[16] 0x00000014
snapinum int32_t[17] 0x00000015
snapinum int32_t[18] 0x00000016
snapinum int32_t[19] 0x00000017
snapinum int32_t[ 0] 0x00000000
snapinum int32_t[ 0] 0x00000000
snapinum int32_t[ 0] 0x00000000
snapinum int32_t[ 0] 0x00000000
9. Unmounting and remounting the filesystem let the kernel print some
warnings. But afterwards (without fsck) the snapshots are gone and we
can create new ones:
% umount /mnt/
% mount /dev/md0 /mnt/
% dmesg | tail -n 20
ffs_snapshot_mount: non-snapshot inode 4
ffs_snapshot_mount: non-snapshot inode 5
ffs_snapshot_mount: non-snapshot inode 6
ffs_snapshot_mount: non-snapshot inode 7
fs_snapshot_mount: non-snapshot inode 8
ffs_snapshot_mount: non-snapshot inode 9
ffs_snapshot_mount: non-snapshot inode 10
ffs_snapshot_mount: non-snapshot inode 11
ffs_snapshot_mount: non-snapshot inode 12
ffs_snapshot_mount: non-snapshot inode 13
ffs_snapshot_mount: non-snapshot inode 14
fs_snapshot_mount: non-snapshot inode 15
ffs_snapshot_mount: non-snapshot inode 16
ffs_snapshot_mount: non-snapshot inode 17
ffs_snapshot_mount: non-snapshot inode 18
ffs_snapshot_mount: non-snapshot inode 19
ffs_snapshot_mount: non-snapshot inode 20
ffs_snapshot_mount: non-snapshot inode 21
ffs_snapshot_mount: non-snapshot inode 22
ffs_snapshot_mount: non-snapshot inode 23
(This are the inodes shown by the ffsinfo above)
% ffsinfo /dev/md0 | grep snapinum
snapinum int32_t[ 0] 0x00000000
snapinum int32_t[ 0] 0x00000000
napinum int32_t[ 0] 0x00000000
snapinum int32_t[ 0] 0x00000000
snapinum int32_t[ 0] 0x00000000
% mksnap_ffs /mnt/ /mnt/.snap/1
% snapinfo -a
/mnt/.snap/1
Ciao,
Yamagi
More information about the freebsd-fs
mailing list