Oracle 11.4 got two new functions called reflink and reflinkat. It's seems to be a rather small change, but it has quite some importance. The man page explains:

The  reflink()  function  creates the file named by path2 with the contents of the file named by path1. The reflink() function does not  read or  write  the  underlying  data blocks. The path1 argument points to a path name naming an existing file. The path2 argument points to a  path name naming the new directory entry to be created

This creates a copy of the file without actually reading and writing it. However both files are independent afterwards. You can write into a file without changing this copy. So it's not just a symbolic link or something like that. Think of it like a ZFS snapshot, just file level. Important to know: It only works this way when both files are in the same ZFS pool.

Okay, how do you use this function? Well, you don't have to write your own application, easiest way is to use cp -z. At first i try a normal copy. It's the second run.

root@batou:/testpool/limited# time cp testfile testfile2

real    0m2,362s
user    0m0,003s
sys     0m1,295s

Now we add the -z option.

root@batou:/testpool/limited# time cp -z testfile testfile3

real    0m6,386s
user    0m0,001s
sys     0m0,221s
What .. it takes longer? Fast copy? Well, this command does a lot in the background in order to enable future speedups. Because when you try it a second time, the number looks differently.

root@batou:/testpool/limited# time cp -z testfile testfile4

real    0m0,098s
user    0m0,001s
sys     0m0,020s

Significantly faster. So ... where you can use this feature. It's not for copying a file a single time, as the first copy is slower. However if you copy large VMs contained in your deployment process quite often , this is an extremely fast way to clone you environments, saving disk space and compute/io resources on the way. Another example would be coping large database files for example to create developer environments.

Do you want to learn more?

docs.oracle.com - reflink (3c)

1 Comment

Linear

  • Paul Zuchowski  
    It's true Joerg. Since reflink works by incrementing the dedup table (DDT) entry reference counts, it must first check if the source blocks are in the DDT by looking at a bit in the blkptr. If not in DDT, the block is copied normally plus the DDT entries are created. Subsequent copies are able to use the dedup functionality to speed up the copy as you learned. Large block sizes are better since each block is visited.

Add Comment

Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
Standard emoticons like :-) and ;-) are converted to images.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA