[OracleOSS] [TitleIndex] [WordIndex]

OCFS2/Reflink-Illustrated

REFLINK ILLUSTRATED

This page illustrates the use of reflink to both explain the feature and to show the usage of some utilities that are required to create and monitor reflinks. These utilities are available for download.

Let us start by noting the available space in the volume. It shows 47GB free.

# df -h .
Filesystem            Size  Used Avail Use% Mounted on
/dev/sdd1              50G  3.3G   47G   7% /ocfs2

Now let us create a 5GB file.

# dd if=/dev/zero of=myfile bs=1M count=5000

As expected, the available space drops by 5GB.

# df -h .
Filesystem            Size  Used Avail Use% Mounted on
/dev/sdd1              50G  8.2G   42G  17% /ocfs2

Let us use the shared-filefrag utility to note all the extents in the file along with the physical block locations and length of each extent.

# shared-filefrag -v myfile
Filesystem type is: 7461636f
File size of myfile is 5242880000 (1280000 blocks, blocksize 4096)
 ext logical physical expected length flags
   0       0  1280257             256 
   1     256  1257985  1280512  20480 
   2   20736  1280513  1278464   8192 
   3   28928   870913  1288704  30720 
   4   59648   903169   901632  30720 
   5   90368   935425   933888  30720 
   6  121088   967681   966144  30720 
   7  151808   999937   998400  30720 
   8  182528  1064449  1030656  30720 
   9  213248  1096705  1095168  30720 
  10  243968  1128961  1127424  30720 
  11  274688  1161217  1159680  30720 
  12  305408  1193473  1191936  30720 
  13  336128  1225729  1224192  30720 
  14  366848  1290241  1256448  30720 
  15  397568  1322497  1320960  30720 
  16  428288  1354753  1353216  30720 
  17  459008  1387009  1385472  30720 
  18  489728  1419265  1417728  30720 
  19  520448  1451521  1449984  30720 
  20  551168  1483777  1482240  30720 
  21  581888  1516033  1514496  30720 
  22  612608  1548289  1546752  30720 
  23  643328  1580545  1579008  30720 
  24  674048  1612801  1611264  30720 
  25  704768  1645057  1643520  30720 
  26  735488  1677313  1675776  30720 
  27  766208  1709569  1708032  30720 
  28  796928  1741825  1740288  30720 
  29  827648  1774081  1772544  30720 
  30  858368  1806337  1804800  30720 
  31  889088  1838593  1837056  30720 
  32  919808  1870849  1869312  30720 
  33  950528  1903105  1901568  30720 
  34  981248  1935361  1933824  30720 
  35 1011968  1967617  1966080  30720 
  36 1042688  1999873  1998336  30720 
  37 1073408  2032129  2030592  30720 
  38 1104128  2064385  2062848  30720 
  39 1134848  2096641  2095104  30720 
  40 1165568  2128897  2127360  30720 
  41 1196288  2161153  2159616  30720 
  42 1227008  2193409  2191872  30720 
  43 1257728  2225665  2224128  22272 eof
myfile: 44 extents found

Let us now create 4 reflinks of the same file.

# reflink myfile myfile-ref1
# reflink myfile myfile-ref2
# reflink myfile myfile-ref3
# reflink myfile myfile-ref4

The directory listing shows us 5 files of 5GB each.

# ls -l
total 25600000
-rw-r--r-- 1 root root 5242880000 Sep 23 12:48 myfile
-rw-r--r-- 1 root root 5242880000 Sep 23 12:57 myfile-ref1
-rw-r--r-- 1 root root 5242880000 Sep 23 12:57 myfile-ref2
-rw-r--r-- 1 root root 5242880000 Sep 23 12:57 myfile-ref3
-rw-r--r-- 1 root root 5242880000 Sep 23 12:57 myfile-ref4

However, df shows no decrease in available space. It still shows 42 GB free.

# df -h .
Filesystem            Size  Used Avail Use% Mounted on
/dev/sdd1              50G  8.2G   42G  17% /ocfs2

The shared-filefrag utility shows the same extent layout as before with the exception that all the extents are flagged shared.

# shared-filefrag -v myfile
Filesystem type is: 7461636f
File size of myfile is 5242880000 (1280000 blocks, blocksize 4096)
 ext logical physical expected length flags
   0       0  1280257             256 shared
   1     256  1257985  1280512  20480 shared
   2   20736  1280513  1278464   8192 shared
   3   28928   870913  1288704  30720 shared
   4   59648   903169   901632  30720 shared
   5   90368   935425   933888  30720 shared
   6  121088   967681   966144  30720 shared
   7  151808   999937   998400  30720 shared
   8  182528  1064449  1030656  30720 shared
   9  213248  1096705  1095168  30720 shared
  10  243968  1128961  1127424  30720 shared
  11  274688  1161217  1159680  30720 shared
  12  305408  1193473  1191936  30720 shared
  13  336128  1225729  1224192  30720 shared
  14  366848  1290241  1256448  30720 shared
  15  397568  1322497  1320960  30720 shared
  16  428288  1354753  1353216  30720 shared
  17  459008  1387009  1385472  30720 shared
  18  489728  1419265  1417728  30720 shared
  19  520448  1451521  1449984  30720 shared
  20  551168  1483777  1482240  30720 shared
  21  581888  1516033  1514496  30720 shared
  22  612608  1548289  1546752  30720 shared
  23  643328  1580545  1579008  30720 shared
  24  674048  1612801  1611264  30720 shared
  25  704768  1645057  1643520  30720 shared
  26  735488  1677313  1675776  30720 shared
  27  766208  1709569  1708032  30720 shared
  28  796928  1741825  1740288  30720 shared
  29  827648  1774081  1772544  30720 shared
  30  858368  1806337  1804800  30720 shared
  31  889088  1838593  1837056  30720 shared
  32  919808  1870849  1869312  30720 shared
  33  950528  1903105  1901568  30720 shared
  34  981248  1935361  1933824  30720 shared
  35 1011968  1967617  1966080  30720 shared
  36 1042688  1999873  1998336  30720 shared
  37 1073408  2032129  2030592  30720 shared
  38 1104128  2064385  2062848  30720 shared
  39 1134848  2096641  2095104  30720 shared
  40 1165568  2128897  2127360  30720 shared
  41 1196288  2161153  2159616  30720 shared
  42 1227008  2193409  2191872  30720 shared
  43 1257728  2225665  2224128  22272 shared,eof
myfile: 44 extents found

The md5sum utility confirms that the data in the files are identical.

# md5sum myfile*
f0c4910bd1b40aecaad309d2a8999e66  myfile
f0c4910bd1b40aecaad309d2a8999e66  myfile-ref1
f0c4910bd1b40aecaad309d2a8999e66  myfile-ref2
f0c4910bd1b40aecaad309d2a8999e66  myfile-ref3
f0c4910bd1b40aecaad309d2a8999e66  myfile-ref4

The shared-du utility shows us a total usage of 25000 MB but a footprint of 5000 MB. That is expected as all files share the same set of extents on disk. (The number in parenthesis is the total shared extents for that file.)

# shared-du -m -c --shared-size myfile*
5000    (5000)  myfile
5000    (5000)  myfile-ref1
5000    (5000)  myfile-ref2
5000    (5000)  myfile-ref3
5000    (5000)  myfile-ref4
25000   total
5000    footprint

Now let us overwrite the first 2GB in the original file.

# dd if=/dev/urandom of=myfile bs=1M count=2000 conv=notrunc

The directory listing does not change other than the mtime of the original file.

# ls -l
total 25600000
-rw-r--r-- 1 root root 5242880000 Sep 23 13:16 myfile
-rw-r--r-- 1 root root 5242880000 Sep 23 12:57 myfile-ref1
-rw-r--r-- 1 root root 5242880000 Sep 23 12:57 myfile-ref2
-rw-r--r-- 1 root root 5242880000 Sep 23 12:57 myfile-ref3
-rw-r--r-- 1 root root 5242880000 Sep 23 12:57 myfile-ref4

But the available space drops 2GB to 40GB.

# df -h .
Filesystem            Size  Used Avail Use% Mounted on
/dev/sdd1              50G   11G   40G  21% /ocfs2

The md5sum utility shows that the file written to after the reflink has changed. The data in the other files remains unchanged.

# md5sum myfile*
2c7ed599daf24fbce0960c516d0e8bba  myfile
f0c4910bd1b40aecaad309d2a8999e66  myfile-ref1
f0c4910bd1b40aecaad309d2a8999e66  myfile-ref2
f0c4910bd1b40aecaad309d2a8999e66  myfile-ref3
f0c4910bd1b40aecaad309d2a8999e66  myfile-ref4

Th shared-du utility shows us that the footprint has increased by 2GB.

# shared-du -m -c --shared-size myfile*
5000    (3000)  myfile
5000    (5000)  myfile-ref1
5000    (5000)  myfile-ref2
5000    (5000)  myfile-ref3
5000    (5000)  myfile-ref4
25000   total
7000    footprint

Finally the shared-filefrag utility that shows us different extents in the overwritten areas of the file.

# shared-filefrag -v myfile
Filesystem type is: 7461636f
File size of myfile is 5242880000 (1280000 blocks, blocksize 4096)
 ext logical physical expected length flags
   0       0  2247937            8448 
   1    8448  2257921  2256384  30720 
   2   39168  2290177  2288640  30720 
   3   69888  2322433  2320896  30720 
   4  100608  2354689  2353152  30720 
   5  131328  2386945  2385408  30720 
   6  162048  2419201  2417664  30720 
   7  192768  2451457  2449920  30720 
   8  223488  2483713  2482176  30720 
   9  254208  2515969  2514432  30720 
  10  284928  2548225  2546688  30720 
  11  315648  2580481  2578944  30720 
  12  346368  2612737  2611200  30720 
  13  377088  2644993  2643456  30720 
  14  407808  2677249  2675712  30720 
  15  438528  2709505  2707968  30720 
  16  469248  2741761  2740224  30720 
  17  499968  2774017  2772480  12032 
  18  512000  1441537  2786048   8448 shared
  19  520448  1451521  1449984  30720 shared
  20  551168  1483777  1482240  30720 shared
  21  581888  1516033  1514496  30720 shared
  22  612608  1548289  1546752  30720 shared
  23  643328  1580545  1579008  30720 shared
  24  674048  1612801  1611264  30720 shared
  25  704768  1645057  1643520  30720 shared
  26  735488  1677313  1675776  30720 shared
  27  766208  1709569  1708032  30720 shared
  28  796928  1741825  1740288  30720 shared
  29  827648  1774081  1772544  30720 shared
  30  858368  1806337  1804800  30720 shared
  31  889088  1838593  1837056  30720 shared
  32  919808  1870849  1869312  30720 shared
  33  950528  1903105  1901568  30720 shared
  34  981248  1935361  1933824  30720 shared
  35 1011968  1967617  1966080  30720 shared
  36 1042688  1999873  1998336  30720 shared
  37 1073408  2032129  2030592  30720 shared
  38 1104128  2064385  2062848  30720 shared
  39 1134848  2096641  2095104  30720 shared
  40 1165568  2128897  2127360  30720 shared
  41 1196288  2161153  2159616  30720 shared
  42 1227008  2193409  2191872  30720 shared
  43 1257728  2225665  2224128  22272 shared,eof
myfile: 44 extents found


2011-12-23 01:01