Solved How ZFS take snapshot?

Hi,
I am trying to understand the impact of ZFS snapshot in the system...

Is it rigth to think that ZFS takes server data at the block level, bypassing the file system, and reading data directly from the disk volume?
 
No, it does not bypass the filesystem. What happens is that ZFS creates an "image" of the snapshotted dataset that is done on the block storage level (which is still of higher level than raw storage on disks) of the dataset. This "image" uses copy-on-write mechanism which means that at the creation of the snapshot it takes almost no extra space. When the live dataset starts to diverge from the snapshot the blocks that have changes on them will be stored separately, blocks that have no changes will be still stored only once.
 
It's fairly basic, just imagine a file, when this file is written to disk the filesystem keeps track of the blocks that are used. Within the filesystem the "file" is a list of block numbers
Code:
file -> block 1, block 2, block 3

When you write new data to file traditional filesystems simply overwrite the existing blocks. ZFS however is a so-called Copy-On-Write filesystem. Instead of overwriting the existing blocks it creates new ones and (if nothing else references those blocks) frees the 'old' blocks.

Code:
file -> block 4, block 5, block 6

What a snapshot basically does is collect a list of blocks, so it remembers file has blocks 1, 2 and 3 in use. When you write to the file again it'll have block 4, 5 and 6 in use. The snapshot however still 'remembers' the old list of blocks 1, 2 and 3. Just a neat "side-effect" of a CoW filesystem :D
 
Back
Top