Changes

Jump to navigation Jump to search
2,012 bytes added ,  15:25, 21 August 2014
Added nfs problem
Line 12: Line 12:     
== NFS ==
 
== NFS ==
 +
 +
In Linux files have an attribute called <code>st_nlink</code> -- the amount of names the file has. When a file is removed (which is done with the <code>unlink</code> system call) this counter is decremented and, if it hits zero, the file itself can be removed from disk. Not "is removed", but "can be removed", since the file can be held opened while someone unlinks one. In the latter case the physical removal of the file is delayed till the file is closed.
 +
 +
NFS does special handing in case the nlink value is about to hit zero. The thing is -- if NFS client would send the last unlink request to the server, the latter would just go and kill the file physically, since it doesn't "know" that someone holds this file opened (this information is owned by the client). Instead, client marks the file as "to be deleted on close" and doesn't perform the last nlink decrement immediately. And only when the file is closed and the mentioned flag is seen, the last unlink is sent to the server. And one more thing -- to prevent naming collisions (in simple words -- <code>open()</code> by the old name shouldn't file this old file) NFS also renames the file, giving it a special name ".nfsXXX" where XXX is some unique identifier.
 +
 +
How this affects CRIU? In the article "[[How hard is it to open a file]]?" it's said, that CRIU should be able to dump and restore files, that are unlinked, but opened. Briefly: if a file is such, CRIU cannot just save the file's path, as once dumped tasks are killed, the fill would stop existing. So CRIU takes these files into the images. But on NFS there's no such thing as "unlinked" file -- it prevents the nlink count from dropping to zero. For CRIU all NFS files look as alive ones.
 +
 +
To handle this, CRIU checks that a file it dumps resides on NFS (this is simply by checking the <code>statfs</code>'s <code>fs_type</code> field). If the file is such CRIU then checks its name to be the ".nfsXXX" one. If both checks succeed the file is treated as "opened and unlinked" one.
    
== AUFS ==
 
== AUFS ==
    
[[Category:Under the hood]]
 
[[Category:Under the hood]]

Navigation menu