overlayfs,workdir的作用

OverlayFS has a workdir option, beside two other directories lowerdir and upperdir, which needs to be an empty directory.

Unfortunately the kernel documentation of overlayfs does not talk much about the purpose of this option.

The "workdir" needs to be an empty directory on the same filesystem as upperdir.

For readonly overlays the workdir might be ommittet among the upperdir. This give me the clue that it has to do with writing the merged files.

Please explain what's happening in the workdir when files are written or changed in the merged directory. Why is the writable upperdir not enough?

 

82711 gold badge77 silver badges1919 bronze badges

  • My guess: When a lower file is to be modified, it is copied (a non-atomic operation) to workdir and then atomically moved into the right place in upper. Thus, other processes will either open the (complete) lower file or (after the switch) the complete upper file, never a halfway-done file. – Marcel Waldvogel Mar 8 at 14:33

 

The workdir option is required, and used to prepare files before they are switched to the overlay destination in an atomic action (the workdir needs to be on the same filesystem as the upperdir).

Source: http://windsock.io/the-overlay-filesystem/

I would hazard a guess that "the overlay destination" means upperdir.

So... certain files (maybe "whiteout" files?) are non-atomically created and configured in workdirand then atomically moved into upperdir.

你可能感兴趣的:(Linux,linux,overlay)