Re: [zfs-discuss] ZFS snapshot used space question
On Thu, Aug 30, 2012 at 1:11 PM, Timothy Coalson tsc...@mst.edu wrote: Is there a way to get the total amount of data referenced by a snapshot that isn't referenced by a specified snapshot/filesystem? I think this is what is really desired in order to locate snapshots with offending space usage. Try zfs destroy -nv pool/fs@snapA%snapC (on Illumos-based systems). This will tell you how much space would be reclaimed if you were to destroy a range of snapshots. --matt ___ zfs-discuss mailing list zfs-discuss@opensolaris.org http://mail.opensolaris.org/mailman/listinfo/zfs-discuss
Re: [zfs-discuss] ZFS snapshot used space question
Is there a way to get the total amount of data referenced by a snapshot that isn't referenced by a specified snapshot/filesystem? I think this is what is really desired in order to locate snapshots with offending space usage. The written and written@ attributes seem to only do the reverse. I think you can back calculate it from the snapshot and filesystem referenced sizes, and the written@snap property of the filesystem, but that isn't particularly convenient to do (looks like zfs get -Hp ... makes it possible to hack a script together for, though). This is what I was hoping to get as well, but I am not sure it's really possible. Even if you try to calculate the referenced space + displayed used space and compare against the active filesystem that doesn't really tell you much because the data on the active filesystem might not be as static as you want. For example: If it references 10G and the active filesystem shows 10G used, you might expect that the snapshot isn't using any space. However, the 10G it referenced might have been deleted and the 10G in the active filesystem might be new data and that means your snap could be 10G. But if 9G of that was on another snapshot, you would have something like this: rootpool/export/home@snap.0- 1G- - - - rootpool/export/home@snap.1- 27K - - - - rootpool/export/home@snap.2- 0 - - - - And the referenced would look something like: rootpool/export/home@snap.00 - 10G - rootpool/export/home@snap.10 - 9G- rootpool/export/home@snap.10 - 10G- And the current filesystem would be: rootpool/export/home 40G 20G 10G 10G 0 0 Then imagine that across more than three snapshots. I can't wrap my head around logic that would work there. I would love if someone could figure out a good way though... - Chad ___ zfs-discuss mailing list zfs-discuss@opensolaris.org http://mail.opensolaris.org/mailman/listinfo/zfs-discuss
Re: [zfs-discuss] ZFS snapshot used space question
I went ahead and hacked this script together, so let me elaborate. First, though, a teaser: $ ./snapspace.sh mainpool/storage SNAPSHOTOLDREFS UNIQUE UNIQUE% zfs-auto-snap_monthly-2011-11-14-18h59 34.67G 11.0G 31% zfs-auto-snap_monthly-2011-12-14-18h59 33.41G 8.95G 26% zfs-auto-snap_monthly-2012-02-09-16h05 123.75G 70.3G 56% ... OLDREFS is how much of the referenced space of the snapshot is not referenced by the current filesystem. UNIQUE is the amount that is referenced by that snapshot and nothing else (the used property), and finally I thought it would be nice to have the unique amount as a percentage of OLDREFS. So, the heart of the script is this: ... fullref=`zfs get -Hp referenced $1 | awk '{print $3}'` for snap in `zfs list -Hd 1 -t snapshot -o name $1 | cut -f2- -d@` do snapref=`zfs get -Hp referenced $1@$snap | awk '{print $3}'` snapwritten=`zfs get -Hp written@$snap $1 | awk '{print $3}'` olddata=$((snapref + snapwritten - fullref)) ... Everything else is sanity checking and display formatting. So, it adds the snapshot referenced data, and the written@snap value of the filesystem (Richard, thanks again for pointing this out), which would be the size of the current filesystem if nothing was deleted/overwritten (which are equivalent due to copy on write), and subtracts the actual size of the current filesystem, obtaining the amount of data deleted/overwritten since the snapshot was taken (or to put it another way, all the data in that snapshot that isn't in the current filesystem). Since this relies on the written@ property, I think it will only work on illumos-based distros, based on what Richard said (apologies to everyone that doesn't use an illumos kernel, if so). Also, since the values are retrieved with separate commands, if the filesystem is being written to, the numbers may become strange, but probably only for the most recent snapshots. Attaching the full script (renamed to .txt because the listserv hates scripts) for all who are interested. Tim On Fri, Aug 31, 2012 at 8:04 AM, Truhn, Chad chad.tr...@bowheadsupport.comwrote: Is there a way to get the total amount of data referenced by a snapshot that isn't referenced by a specified snapshot/filesystem? I think this is what is really desired in order to locate snapshots with offending space usage. The written and written@ attributes seem to only do the reverse. I think you can back calculate it from the snapshot and filesystem referenced sizes, and the written@snap property of the filesystem, but that isn't particularly convenient to do (looks like zfs get -Hp ... makes it possible to hack a script together for, though). This is what I was hoping to get as well, but I am not sure it's really possible. Even if you try to calculate the referenced space + displayed used space and compare against the active filesystem that doesn't really tell you much because the data on the active filesystem might not be as static as you want. For example: If it references 10G and the active filesystem shows 10G used, you might expect that the snapshot isn't using any space. However, the 10G it referenced might have been deleted and the 10G in the active filesystem might be new data and that means your snap could be 10G. But if 9G of that was on another snapshot, you would have something like this: rootpool/export/home@snap.0- 1G- - - - rootpool/export/home@snap.1- 27K - - - - rootpool/export/home@snap.2- 0 - - - - And the referenced would look something like: rootpool/export/home@snap.00 - 10G - rootpool/export/home@snap.10 - 9G- rootpool/export/home@snap.10 - 10G- And the current filesystem would be: rootpool/export/home 40G 20G 10G 10G 0 0 Then imagine that across more than three snapshots. I can't wrap my head around logic that would work there. I would love if someone could figure out a good way though... - Chad #!/bin/bash if (($# 1)) then echo usage: $0 filesystem exit 1 fi if [[ $1 == *@* || $1 == /* ]] then echo Snapshots and paths are not supported echo usage: $0 filesystem exit 1 fi echo SNAPSHOTOLDREFS \tUNIQUE\tUNIQUE% fullref=`zfs get -Hp referenced $1 | awk '{print $3}'` for snap in `zfs list -Hd 1 -t snapshot -o name $1 | cut -f2- -d@` do snapref=`zfs get -Hp referenced $1@$snap | awk '{print $3}'` snapwritten=`zfs get -Hp written@$snap $1 | awk '{print $3}'` olddata=$((snapref + snapwritten - fullref)) snapused=`zfs get -H used $1@$snap | awk '{print $3}'` snapusedraw=`zfs get -Hp used $1@$snap | awk '{print $3}'`
Re: [zfs-discuss] ZFS snapshot used space question
On Wed, Aug 29, 2012 at 8:58 PM, Timothy Coalson tsc...@mst.edu wrote: As I understand it, the used space of a snapshot does not include anything that is in more than one snapshot. True. It shows the amount that would be freed if you destroyed the snapshot right away. Data held onto by more than one snapshot cannot be removed when you destroy just one of them, obviously. The act of destroying a snapshot will likely change the USED value of the neighbouring snapshots though. Yup, this is the same thing I came up with as well. Though I am a bit disappointed in the results at least things make sense again. Thank you all for your help! ___ zfs-discuss mailing list zfs-discuss@opensolaris.org http://mail.opensolaris.org/mailman/listinfo/zfs-discuss
Re: [zfs-discuss] ZFS snapshot used space question
For illumos-based distributions, there is a written and written@ property that shows the amount of data writtent to each snapshot. This helps to clear the confusion over the way the used property is accounted. https://www.illumos.org/issues/1645 -- richard On Aug 29, 2012, at 11:12 AM, Truhn, Chad chad.tr...@bowheadsupport.com wrote: All, I apologize in advance for what appears to be a question asked quite often, but I am not sure I have ever seen an answer that explains it. This may also be a bit long-winded so I apologize for that as well. I would like to know how much unique space each individual snapshot is using. I have a ZFS filesystem that shows: $zfs list -o space rootpool/export/home NAME AVAIL USED USEDSNAP USEDDS USEDREFRESERV USEDCHILD rootpool/export/home 5.81G 14.4G 8.81G5.54G 0 0 So reading this I see that I have a total of 14.4G of space used by this data set. Currently 5.54 is active data that is available on the normal filesystem and 8.81G used in snapshots. 8.81G + 5.54G = 14.4G (roughly). I 100% agree with these numbers and the world makes sense. This is also backed up by: $zfs get usedbysnapshots rootpool/export/home NAME PROPERTYVALUE SOURCE rootpool/export/home usedbysnapshots 8.81G - Now if I wanted to see how much space any individual snapshot is currently using I would like to think that this would show me: $zfs list -ro space rootpool/export/home NAME AVAIL USED USEDSNAP USEDDS USEDREFRESERV USEDCHILD rootpool/export/home 5.81G 14.4G 8.81G 5.54G 0 0 rootpool/export/home@week3 -202M - - - - rootpool/export/home@week2 -104M - - - - rootpool/export/home@7daysago-1.37M - - - - rootpool/export/home@6daysago-1.20M - - - - rootpool/export/home@5daysago-1020K - - - - rootpool/export/home@4daysago-342K - - - - rootpool/export/home@3daysago-1.28M - - - - rootpool/export/home@week1 -0- - - - rootpool/export/home@2daysago-0- - - - rootpool/export/home@yesterday - 360K - - - - rootpool/export/home@today-1.26M - - - - So normal logic would tell me if USEDSNAP is 8.81G and is composed of 11 snapshots, I would add up the size of each of those snapshots and that would roughly equal 8.81G. So time to break out the calculator: 202M + 104M + 1.37M + 1.20M + 1020K + 342K + 1.28M +0 +0 + 360K + 1.26M equals... ~312M! That is nowhere near 8.81G. I would accept it even if it was within 15%, but it's not even close. That definitely not metadata or ZFS overhead or anything. I understand that snapshots are just the delta between the time when the snapshot was taken and the current active filesystem and are truly just references to a block on disk rather than a copy. I also understand how two (or more) snapshots can reference the same block on a disk but yet there is still only that one block used. If I delete a recent snapshot I may not save as much space as advertised because some may be inherited by a parent snapshot. But that inheritance is not creating duplicate used space on disk so it doesn't justify the huge difference in sizes. But even with this logic in place there is currently 8.81G of blocks referred to by snapshots which are not currently on the active filesystem and I don't believe anyone can argue with that. Can something show me how much space a single snapshot has reserved? I searched through some of the archives and found this thread (http://mail.opensolaris.org/pipermail/zfs-discuss/2012-August/052163.html) from early this month and I feel as if I have the same problem as the OP, but hopefully attacking it with a little more background. I am not arguing with discrepancies between df/du and zfs output and I have read the Oracle documentation about it but haven't found what I feel like should be a simple answer. I currently have a ticket open with Oracle, but I am getting answers to all kinds of questions except for the question I am asking so I am hoping someone out there might be able to help me. I am a little concerned I am going
Re: [zfs-discuss] ZFS snapshot used space question
Is there a way to get the total amount of data referenced by a snapshot that isn't referenced by a specified snapshot/filesystem? I think this is what is really desired in order to locate snapshots with offending space usage. The written and written@ attributes seem to only do the reverse. I think you can back calculate it from the snapshot and filesystem referenced sizes, and the written@snap property of the filesystem, but that isn't particularly convenient to do (looks like zfs get -Hp ... makes it possible to hack a script together for, though). Tim On Thu, Aug 30, 2012 at 11:22 AM, Richard Elling richard.ell...@gmail.comwrote: For illumos-based distributions, there is a written and written@ property that shows the amount of data writtent to each snapshot. This helps to clear the confusion over the way the used property is accounted. https://www.illumos.org/issues/1645 -- richard On Aug 29, 2012, at 11:12 AM, Truhn, Chad chad.tr...@bowheadsupport.com wrote: All, I apologize in advance for what appears to be a question asked quite often, but I am not sure I have ever seen an answer that explains it. This may also be a bit long-winded so I apologize for that as well. I would like to know how much unique space each individual snapshot is using. I have a ZFS filesystem that shows: $zfs list -o space rootpool/export/home NAME AVAIL USED USEDSNAP USEDDS USEDREFRESERV USEDCHILD rootpool/export/home 5.81G 14.4G 8.81G5.54G 0 0 So reading this I see that I have a total of 14.4G of space used by this data set. Currently 5.54 is active data that is available on the normal filesystem and 8.81G used in snapshots. 8.81G + 5.54G = 14.4G (roughly). I 100% agree with these numbers and the world makes sense. This is also backed up by: $zfs get usedbysnapshots rootpool/export/home NAME PROPERTYVALUE SOURCE rootpool/export/home usedbysnapshots 8.81G - Now if I wanted to see how much space any individual snapshot is currently using I would like to think that this would show me: $zfs list -ro space rootpool/export/home NAME AVAIL USED USEDSNAP USEDDS USEDREFRESERV USEDCHILD rootpool/export/home 5.81G 14.4G 8.81G 5.54G 0 0 rootpool/export/home@week3 -202M - - - - rootpool/export/home@week2 -104M - - - - rootpool/export/home@7daysago-1.37M - - - - rootpool/export/home@6daysago-1.20M - - - - rootpool/export/home@5daysago-1020K - - - - rootpool/export/home@4daysago-342K - - - - rootpool/export/home@3daysago-1.28M - - - - rootpool/export/home@week1 -0- - - - rootpool/export/home@2daysago-0- - - - rootpool/export/home@yesterday - 360K - - - - rootpool/export/home@today-1.26M - - - - So normal logic would tell me if USEDSNAP is 8.81G and is composed of 11 snapshots, I would add up the size of each of those snapshots and that would roughly equal 8.81G. So time to break out the calculator: 202M + 104M + 1.37M + 1.20M + 1020K + 342K + 1.28M +0 +0 + 360K + 1.26M equals... ~312M! That is nowhere near 8.81G. I would accept it even if it was within 15%, but it's not even close. That definitely not metadata or ZFS overhead or anything. I understand that snapshots are just the delta between the time when the snapshot was taken and the current active filesystem and are truly just references to a block on disk rather than a copy. I also understand how two (or more) snapshots can reference the same block on a disk but yet there is still only that one block used. If I delete a recent snapshot I may not save as much space as advertised because some may be inherited by a parent snapshot. But that inheritance is not creating duplicate used space on disk so it doesn't justify the huge difference in sizes. But even with this logic in place there is currently 8.81G of blocks referred to by snapshots which are not currently on the active filesystem and I don't believe anyone can argue with that. Can something show me how much space a single snapshot has reserved? I searched through some of the archives and found this thread (
[zfs-discuss] ZFS snapshot used space question
All, I apologize in advance for what appears to be a question asked quite often, but I am not sure I have ever seen an answer that explains it. This may also be a bit long-winded so I apologize for that as well. I would like to know how much unique space each individual snapshot is using. I have a ZFS filesystem that shows: $zfs list -o space rootpool/export/home NAME AVAIL USED USEDSNAP USEDDS USEDREFRESERV USEDCHILD rootpool/export/home 5.81G 14.4G 8.81G5.54G 0 0 So reading this I see that I have a total of 14.4G of space used by this data set. Currently 5.54 is active data that is available on the normal filesystem and 8.81G used in snapshots. 8.81G + 5.54G = 14.4G (roughly). I 100% agree with these numbers and the world makes sense. This is also backed up by: $zfs get usedbysnapshots rootpool/export/home NAME PROPERTYVALUE SOURCE rootpool/export/home usedbysnapshots 8.81G - Now if I wanted to see how much space any individual snapshot is currently using I would like to think that this would show me: $zfs list -ro space rootpool/export/home NAME AVAIL USED USEDSNAP USEDDS USEDREFRESERV USEDCHILD rootpool/export/home 5.81G 14.4G 8.81G 5.54G 0 0 rootpool/export/home@week3 -202M - - - - rootpool/export/home@week2 -104M - - - - rootpool/export/home@7daysago-1.37M - - - - rootpool/export/home@6daysago-1.20M - - - - rootpool/export/home@5daysago-1020K - - - - rootpool/export/home@4daysago-342K - - - - rootpool/export/home@3daysago-1.28M - - - - rootpool/export/home@week1 -0- - - - rootpool/export/home@2daysago-0- - - - rootpool/export/home@yesterday - 360K - - - - rootpool/export/home@today-1.26M - - - - So normal logic would tell me if USEDSNAP is 8.81G and is composed of 11 snapshots, I would add up the size of each of those snapshots and that would roughly equal 8.81G. So time to break out the calculator: 202M + 104M + 1.37M + 1.20M + 1020K + 342K + 1.28M +0 +0 + 360K + 1.26M equals... ~312M! That is nowhere near 8.81G. I would accept it even if it was within 15%, but it's not even close. That definitely not metadata or ZFS overhead or anything. I understand that snapshots are just the delta between the time when the snapshot was taken and the current active filesystem and are truly just references to a block on disk rather than a copy. I also understand how two (or more) snapshots can reference the same block on a disk but yet there is still only that one block used. If I delete a recent snapshot I may not save as much space as advertised because some may be inherited by a parent snapshot. But that inheritance is not creating duplicate used space on disk so it doesn't justify the huge difference in sizes. But even with this logic in place there is currently 8.81G of blocks referred to by snapshots which are not currently on the active filesystem and I don't believe anyone can argue with that. Can something show me how much space a single snapshot has reserved? I searched through some of the archives and found this thread (http://mail.opensolaris.org/pipermail/zfs-discuss/2012-August/052163.html) from early this month and I feel as if I have the same problem as the OP, but hopefully attacking it with a little more background. I am not arguing with discrepancies between df/du and zfs output and I have read the Oracle documentation about it but haven't found what I feel like should be a simple answer. I currently have a ticket open with Oracle, but I am getting answers to all kinds of questions except for the question I am asking so I am hoping someone out there might be able to help me. I am a little concerned I am going to find out that there is no real way to show it and that makes for one sad SysAdmin. Thanks, Chad ___ zfs-discuss mailing list zfs-discuss@opensolaris.org http://mail.opensolaris.org/mailman/listinfo/zfs-discuss
Re: [zfs-discuss] ZFS snapshot used space question
As I understand it, the used space of a snapshot does not include anything that is in more than one snapshot. There is a bit of a hack, using the verbose and dry run options of zfs send, that will tell you how much data must be transferred to replicate each snapshot incrementally, which should help clear things up. Try (with elevated privileges): zfs send -nvR rootpool/export/home@today You might also look at the REFER column in zfs list -r -t snapshot rootpool/export/home, which tells you how much data was referenced by the filesystem when the snapshot was taken. However, this could be uninformative if the majority of the snapshot data is rewritten files rather than new files. Tim On Wed, Aug 29, 2012 at 1:12 PM, Truhn, Chad chad.tr...@bowheadsupport.comwrote: All, I apologize in advance for what appears to be a question asked quite often, but I am not sure I have ever seen an answer that explains it. This may also be a bit long-winded so I apologize for that as well. I would like to know how much unique space each individual snapshot is using. I have a ZFS filesystem that shows: $zfs list -o space rootpool/export/home NAME AVAIL USED USEDSNAP USEDDS USEDREFRESERV USEDCHILD rootpool/export/home 5.81G 14.4G 8.81G5.54G 0 0 So reading this I see that I have a total of 14.4G of space used by this data set. Currently 5.54 is active data that is available on the normal filesystem and 8.81G used in snapshots. 8.81G + 5.54G = 14.4G (roughly). I 100% agree with these numbers and the world makes sense. This is also backed up by: $zfs get usedbysnapshots rootpool/export/home NAME PROPERTYVALUE SOURCE rootpool/export/home usedbysnapshots 8.81G - Now if I wanted to see how much space any individual snapshot is currently using I would like to think that this would show me: $zfs list -ro space rootpool/export/home NAME AVAIL USED USEDSNAP USEDDS USEDREFRESERV USEDCHILD rootpool/export/home 5.81G 14.4G 8.81G 5.54G 0 0 rootpool/export/home@week3 -202M - - - - rootpool/export/home@week2 -104M - - - - rootpool/export/home@7daysago-1.37M - - - - rootpool/export/home@6daysago-1.20M - - - - rootpool/export/home@5daysago-1020K - - - - rootpool/export/home@4daysago-342K - - - - rootpool/export/home@3daysago-1.28M - - - - rootpool/export/home@week1 -0- - - - rootpool/export/home@2daysago-0- - - - rootpool/export/home@yesterday - 360K - - - - rootpool/export/home@today-1.26M - - - - So normal logic would tell me if USEDSNAP is 8.81G and is composed of 11 snapshots, I would add up the size of each of those snapshots and that would roughly equal 8.81G. So time to break out the calculator: 202M + 104M + 1.37M + 1.20M + 1020K + 342K + 1.28M +0 +0 + 360K + 1.26M equals... ~312M! That is nowhere near 8.81G. I would accept it even if it was within 15%, but it's not even close. That definitely not metadata or ZFS overhead or anything. I understand that snapshots are just the delta between the time when the snapshot was taken and the current active filesystem and are truly just references to a block on disk rather than a copy. I also understand how two (or more) snapshots can reference the same block on a disk but yet there is still only that one block used. If I delete a recent snapshot I may not save as much space as advertised because some may be inherited by a parent snapshot. But that inheritance is not creating duplicate used space on disk so it doesn't justify the huge difference in sizes. But even with this logic in place there is currently 8.81G of blocks referred to by snapshots which are not currently on the active filesystem and I don't believe anyone can argue with that. Can something show me how much space a single snapshot has reserved? I searched through some of the archives and found this thread ( http://mail.opensolaris.org/pipermail/zfs-discuss/2012-August/052163.html) from early this month and I feel as if I have the same problem as the OP, but hopefully attacking it with a little more background. I am not arguing with discrepancies between df/du and zfs output and I have read the
Re: [zfs-discuss] ZFS snapshot used space question
On Wed, Aug 29, 2012 at 8:58 PM, Timothy Coalson tsc...@mst.edu wrote: As I understand it, the used space of a snapshot does not include anything that is in more than one snapshot. True. It shows the amount that would be freed if you destroyed the snapshot right away. Data held onto by more than one snapshot cannot be removed when you destroy just one of them, obviously. The act of destroying a snapshot will likely change the USED value of the neighbouring snapshots though. ___ zfs-discuss mailing list zfs-discuss@opensolaris.org http://mail.opensolaris.org/mailman/listinfo/zfs-discuss