Like archival, restoration can also be triggered in one of two ways. The most common method is for a user's access of a file to trigger the restore, which is performed by the dmfsd daemon. Another method is the use of the frestore(8) program, which performs the restoration directly.
In either case, the restore agent opens the file, using either the fhopen(2) or open(2) system calls, with the O_ALT_IO flag set. This flag requires root privileges, and will permit the process to access the underlying file directly, rather than being blocked when accessing a non-resident portion.
The next step is for the restoration process to set the DM_RIP (Restore In Progress) flag using the DMFS_SETRIP fcntl(2). As with the DMFS_SETAIP fcntl(2), this will only succeed if no other process is restoring the file.
Then the restore agent reads in the relevant virtual volumes, and writes the non-resident portions of the file to disk. As the file descriptor was opened with the O_ALT_IO flag set, the write(2) calls will not be blocked and will restore the file on the underlying file store.
At various points through the restore, the restore agent may perform a DMFS_SETBBOUND fcntl(2). This operation takes an off_t argument and adjusts the byte barrier to this new value. Typically, as the file is restored, this operation is used to move the byte barrier, permitting blocked reads to complete as the file is restored.
The final step for restoration is for the restore agent to perform the DMFS_FINISHARC fcntl(2) and then close the file. This fcntl(2) call will set a flag such that when the file descriptor is closed, the file is marked fully resident and all processes waiting for the restoration to complete will be unblocked.
Finishing the restore is done as a two-step process to better support executing non-resident files. Any process attempting to execute the file will be blocked until after the close operation of the restore agent is completed, ensuring that the file will not be noted as being opened for write while attempting to execute it.