The read-only tree never changes - it holds references to the disk blocks belonging to the original files as they were at the time the snapshot was created. Its disk blocks (and the files’ disk blocks) are duplicated using copy-on-write as necessary. ![]() One of them remains writable, while the other is marked read-only.Īfterward, when files are created, deleted and modified, the volume’s writable directory (the active one) is modified as normal. You end up with two directory trees, containing the same files and pointing to the same disk blocks. Instead of performing the above “fast copy” operation on a single file, it is performed on the entire volume’s directory structure. In addition to speeding up file-copy operations, it also saves space on your storage device, because it’s not keeping two copies of data for content that is known to be identical.Ī snapshot is basically an extension of this concept. Later on, if you modify the file, the system allocates new storage for those blocks that have changed, but everything unchanged remains shared with the original. Instead, it creates a new file that uses all of the original file’s disk blocks for storage. This is because it’s not actually copying all the data to a new set of disk blocks. As you may have noticed, duplicating a file in APFS using the Finder completes almost instantly, regardless of it’s size. One of the most obvious is APFS’s ability to perform quick copies of files. These technologies (reference counting and copy-on-write) allow an operating system to do many useful things. When a disk block is shared by multiple files and one tries to write to the block, it is duplicated (and the file’s internal data updated to reflect that it is now using a different block) before the write operation. This is used in conjunction with “ copy-on-write” technology. There is a per-block reference count stored, so that when files are deleted, the block isn’t freed until all of the files using the block have been deleted. The general idea is that, when using a snapshot-capable file system, each disk block can belong to multiple files. ![]() Here’s a white paper that, in part, explains their implementation. The earliest example I’m personally familiar with was developed by NetApp for their file server appliances. Various kinds of network servers have been using them for decades. Snapshots are nothing new to the industry.
0 Comments
Leave a Reply. |