Lou Gosselin:
> So if file "xyz" is locked and belongs to the union, I can just scan 
> each branch in order until I find either "xyz" or ".wh.xyz".
> Then I know with certainty that this file lock is keeping this branch busy?

Generally yes. And it is better to find ".wh..wh.opq" too.
There are some complicated cases in real world.
For instance,
- the file "xyz" exists only on the lower readonly branch.
- processA
  open("xyz") for read;
  sleep(long time);
  read(from "xyz");
- processB
  open("xyz");
  write(to "xyz");
- processB writes to "xyz" while processA is sleeping, then the file
  will be copied-up.
- when processA wakes up, it will notice the file is copied-up and read
  from the upper writable branch, the copied-up one.
- if you run "remount,del:/the/lower/branch" after the file is copied-up
  but processA is still sleeping, then remount will return EBUSY. and if
  you look for "xyz", you will find the file exists on two branches.

Until processA reads from "xyz", it refers to the file on the lower
branch which keeps the lower branch busy even the file exists on the
upper branch too.

Also there are cases other than open.
When "dirA" exists on the lower branch only, if you run "cd /aufs/dirA"
or set inotify to "/aufs/dirA", then you will not able to delete the
lower branch. But if "dirA" exists on the upper branch too, then you
will able to delete it.


> If everything in aufs is immediately applied to the branch (no caching 
> within aufs), then I guess this algorithm can work.
>
> Perhaps I assumed wrongly that aufs kept unwritten branch state internally.

Aufs has no such write-cache because the branch filesystem has generally.
And your example "tail -f union/branch1_file" doesn't write to the
file. :-)


J. R. Okajima

------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share 
of $1 Million in cash or HP Products. Visit us here for more details:
http://ad.doubleclick.net/clk;226879339;13503038;l?
http://clk.atdmt.com/CRS/go/247765532/direct/01/

Reply via email to