Understanding ZFS Snapshots - why will it utilize space ?


 
Thread Tools Search this Thread
Operating Systems Solaris Understanding ZFS Snapshots - why will it utilize space ?
# 1  
Old 02-20-2018
Understanding ZFS Snapshots - why will it utilize space ?

Hi all,

I am moving to Solaris11 and is trying to understand how ZFS snapshot works.

Chances upon this Oracle Blog and can't wrap my head around it.
https://blogs.oracle.com/solaris/understanding-the-space-used-by-zfs-v2

Hope gurus here can shed some light .

=======

Here it goes,

I understand snapshot works on copy on write mechanism, so if there isn't any changes, there wouldn't be extra space taken.

q1) Why is it that when file1 is deleted, both snap1 and snap2 isn't utilizing any space ?

Code:
bleonard@os200906:~# rm /tank/file1
bleonard@os200906:~# zpool scrub tank
bleonard@os200906:~# zfs list -t all -r tank
NAME         USED  AVAIL  REFER  MOUNTPOINT
tank         200M   784M   100M  /tank
tank@snap1    17K      -   100M  -
tank@snap2    17K      -   200M  -

Yet when using zfs list as below, it is showing that 100M is use by snapshot
(USEDSNAP - 100M)

Code:
 
 bleonard@os200906:~# zfs list -t all -o space -r tank
NAME        AVAIL   USED  USEDSNAP  USEDDS  USEDREFRESERV  USEDCHILD
tank         784M   200M      100M    100M              0       154K

So when file1 is deleted, snap1 and snap2 is not utilizing any space but 100M is used by snapshots ?...

==============

q2) However, when snap1 is deleted, snap2 will show that it is using 100M of space.. why so ?

Code:
 
 bleonard@os200906:~# zfs destroy tank@snap1
bleonard@os200906:~# zfs list -t all -r tank
NAME         USED  AVAIL  REFER  MOUNTPOINT
tank         200M   784M   100M  /tank
tank@snap2   100M      -   200M  -

SmilieSmilieSmilie
I am sure I am looking at this the wrong way...

Regards,
Noob
# 2  
Old 02-20-2018
After the deletion of file1 USEDSNAP is telling you that there are pointers to 100MB of data.
In that time, 2 references exist in point in time for 100M of data.
snap1 - file1
snap2 - file1, file2

USED space in zpool has not changed after the deletion of file1.

Now, tank@snap1 is destroyed.
zfs list is telling you if you destroy the renaming snapshot (snap2), you will reclaim 100M of space as free space.
Since snap2 contains both files (one being 'live' one, other being referenced to) it is using 100M of space in zpool.

During the practice on the blog USEDSNAP column will always be 100M, after first snapshot creation, deletion of file1, second snapshot creation, first snapshot destroy.
This is not displayed clearly on the blog entry.

A good tehnical read Is it magic? | Oracle Matthew Ahrens' Blog

Hope that helps
Regards
Peasant.
This User Gave Thanks to Peasant For This Post:
# 3  
Old 02-21-2018
Hi Peasant,

Thanks for your reply.
Can I look at it this way ->

1) When file1 is deleted, there is actually no change done; just that snap1 and snap2 will still need to refer to this deleted file; hence USED for snap1 and snap2 remain the same, and USSSNAP will reflect 100M (because that the filesize of file1)

2) when snap1 is deleted, the only snap that still needs to refer to "deleted file1" is snap2. hence, snap2 is "holding on/USED" to 100M of the zpool and if snap2 is deleted, file1's space is 100% freed

am I right ?
# 4  
Old 02-21-2018
In a nutshell yes.
It is confusing a bit from user perspective,zfs used/usedsnap etc.

I would recommend reading about snapshots and COW in general.
Any tech that uses those, basically works on same principle.

Range is from filesystems (zfs,brtfs etc.) to enterprise storage systems with proprietary HW/SW.
Everything works the same way more or less.

Lets say blocks need to be modified due to write request.

Instead of overwriting blocks, zfs will write a change a new blocks, while old blocks will still contain old data, and that data will remain on disk until needed and is considered free.

This is what enables snapshots,clones, rollback etc. which is fundamental design of zfs filesystem/volume manager.

If there is a snapshot (pointers to old blocks at the time snapshot is taken), those will not be considered free but will remain unchanged (read the blog i posted, it is extremely good).
This is what enables snapshots,clones, rollback etc.

ZFS is a great and fairly complex product code wise with a lot of time and effort put into it.

One can only put a hat down to those SUN engineers behind it.
Those guys were ahead of their time.

Also, i must apologize upfront for information given in this post due to minor alcohol intoxication Smilie
This happens you know, when you are in automation business.
As a folks say here
'An idle mind is a devils workshop' Smilie

Regards
Peasant.
This User Gave Thanks to Peasant For This Post:
# 5  
Old 02-23-2018
Quote:
Originally Posted by Peasant
Also, i must apologize upfront for information given in this post due to minor alcohol intoxication Smilie
Yes. I do believe that you are intoxicated to have apologize for this amazing reply.

SmilieSmilieSmilie

Thanks pal!
Login or Register to Ask a Question

Previous Thread | Next Thread

3 More Discussions You Might Find Interesting

1. Solaris

Permissions to run ZFS Snapshots

Hi, I work as an Oracle Technical consultant (mainly DBA related), and I have used ZFS snapshots on previous projects which has helped me a great deal. I often take snapshots before doing some dev work, and then I can roll it back if I want to start again, or if it goes pear shaped!! I have... (4 Replies)
Discussion started by: AndyG
4 Replies

2. Solaris

Recommended Patch Cluster Using ZFS Snapshots

I have a question regarding installing recommended patch clusters via ZFS snapshots. Someone wrote a pretty good blog about it here: Initial Program Load: Live Upgrade to install the recommended patch cluster on a ZFS snapshot The person's article is similar to what I've done in the past. ... (0 Replies)
Discussion started by: christr
0 Replies

3. Solaris

How to utilize the 2nd hard disk space in x86 solaris 5.10

I have 2 hard disks ,one hard disk(40gb) completely for windows Os,and the other(120gb) for solaris Os. In the second hard disk.I have utilised around 10gb for the solaris installation and also partitioned with the available 10gb space for the solaris x86 OS. Now i need to utilise the... (8 Replies)
Discussion started by: jayaprakash
8 Replies
Login or Register to Ask a Question