>>>>> "n" == none <[EMAIL PROTECTED]> writes:
n> snapshots referring to old data which has been deleted from n> the current filesystem and I'd like to find out which n> snapshots refer to how much data Imagine you have a filesystem containing ten 1MB files, zfs create root/export/home/carton/t cd t n=0; while [ $n -lt 10 ]; do mkfile 1m $n; n=$(( $n + 1 )); done and you change nothing on the filesystem except to slowly delete one file at a time. After you delete each of them, you take another snapshot. n=0; while [ $n -lt 10 ]; do zfs snapshot root/export/home/carton/[EMAIL PROTECTED]; rm $n; n=$(( $n + 1 )); done When they're all gone, you stop. Now you want to know, destroying which snapshot can save you space. If you think about how you got the filesystem to this state, the ideal answer is, only deleting the oldest snapshot will save space. Deleting any middle snapshot saves no space. Here's what 'zfs list' says: bash-3.2# zfs list -r root/export/home/carton/t NAME USED AVAIL REFER MOUNTPOINT root/export/home/carton/t 10.2M 26.6G 18K /export/home/carton/t root/export/home/carton/[EMAIL PROTECTED] 1.02M - 10.0M - root/export/home/carton/[EMAIL PROTECTED] 18K - 9.04M - root/export/home/carton/[EMAIL PROTECTED] 18K - 8.04M - root/export/home/carton/[EMAIL PROTECTED] 18K - 7.03M - root/export/home/carton/[EMAIL PROTECTED] 17K - 6.03M - root/export/home/carton/[EMAIL PROTECTED] 17K - 5.03M - root/export/home/carton/[EMAIL PROTECTED] 17K - 4.03M - root/export/home/carton/[EMAIL PROTECTED] 17K - 3.02M - root/export/home/carton/[EMAIL PROTECTED] 17K - 2.02M - root/export/home/carton/[EMAIL PROTECTED] 17K - 1.02M - now, uselessly destroy a middle snapshot: bash-3.2# zfs destroy root/export/home/carton/[EMAIL PROTECTED] bash-3.2# zfs list -r root/export/home/carton/t NAME USED AVAIL REFER MOUNTPOINT root/export/home/carton/t 10.2M 26.6G 18K /export/home/carton/t root/export/home/carton/[EMAIL PROTECTED] 1.02M - 10.0M - root/export/home/carton/[EMAIL PROTECTED] 18K - 9.04M - root/export/home/carton/[EMAIL PROTECTED] 18K - 8.04M - root/export/home/carton/[EMAIL PROTECTED] 17K - 6.03M - root/export/home/carton/[EMAIL PROTECTED] 17K - 5.03M - root/export/home/carton/[EMAIL PROTECTED] 17K - 4.03M - root/export/home/carton/[EMAIL PROTECTED] 17K - 3.02M - root/export/home/carton/[EMAIL PROTECTED] 17K - 2.02M - root/export/home/carton/[EMAIL PROTECTED] 17K - 1.02M - still using 10MB. but if you destroy the oldest snapshot: bash-3.2# zfs destroy root/export/home/carton/[EMAIL PROTECTED] bash-3.2# zfs list -r root/export/home/carton/t NAME USED AVAIL REFER MOUNTPOINT root/export/home/carton/t 9.17M 26.6G 18K /export/home/carton/t root/export/home/carton/[EMAIL PROTECTED] 1.02M - 9.04M - root/export/home/carton/[EMAIL PROTECTED] 18K - 8.04M - root/export/home/carton/[EMAIL PROTECTED] 17K - 6.03M - root/export/home/carton/[EMAIL PROTECTED] 17K - 5.03M - root/export/home/carton/[EMAIL PROTECTED] 17K - 4.03M - root/export/home/carton/[EMAIL PROTECTED] 17K - 3.02M - root/export/home/carton/[EMAIL PROTECTED] 17K - 2.02M - root/export/home/carton/[EMAIL PROTECTED] 17K - 1.02M - space is freed. However, there are other cases where deleting a middle snapshot will save space: bash-3.2# mkfile 1m 0 bash-3.2# zfs snapshot root/export/home/carton/[EMAIL PROTECTED] bash-3.2# mkfile 1m 1 bash-3.2# zfs snapshot root/export/home/carton/[EMAIL PROTECTED] bash-3.2# rm 1 bash-3.2# zfs snapshot root/export/home/carton/[EMAIL PROTECTED] bash-3.2# rm 0 bash-3.2# zfs list -r root/export/home/carton/t NAME USED AVAIL REFER MOUNTPOINT root/export/home/carton/t 2.07M 26.6G 18K /export/home/carton/t root/export/home/carton/[EMAIL PROTECTED] 17K - 1.02M - root/export/home/carton/[EMAIL PROTECTED] 1.02M - 2.02M - root/export/home/carton/[EMAIL PROTECTED] 17K - 1.02M - bash-3.2# zfs destroy root/export/home/carton/[EMAIL PROTECTED] bash-3.2# zfs list -r root/export/home/carton/t NAME USED AVAIL REFER MOUNTPOINT root/export/home/carton/t 1.05M 26.6G 18K /export/home/carton/t root/export/home/carton/[EMAIL PROTECTED] 17K - 1.02M - root/export/home/carton/[EMAIL PROTECTED] 17K - 1.02M - To me, it looks as though the USED column tells you ``how much space would be freed if I destroyed the thing on this row,'' and the REFER column tells you ``about what would 'du -s' report if I ran it on the root of this dataset.'' The answer to your question is then to look at the USED column, but with one caveat: after you delete something, the USED column will reshuffle, so it's useful for deciding the next single thing you want to destroy, not for choosing a set of things for a multiple-thing destruction-plan. In the first example, USED couldn't tell you before you've destroyed anything that ``deleting snapshots @0 - @4 will save 5MB,'' but the column will keep guiding you to the oldest snapshot as the next helpful one to destroy. Obviously I can't prove that the columns always behave this way, but they behaved consistently and reasonably in these two simple tests. Also I did not look at changes in pool-wide free space. I trusted the USED column of 't'.
pgph98lyNyrVn.pgp
Description: PGP signature
_______________________________________________ zfs-discuss mailing list zfs-discuss@opensolaris.org http://mail.opensolaris.org/mailman/listinfo/zfs-discuss