[OpenAFS] order of directory entries re: creat() vs readdir()

Todd M. Lewis Todd M. Lewis" <utoddl@email.unc.edu
Tue, 01 Sep 2009 22:25:59 -0400


We have a process that may run on any number of clients and at various
times, the result of each run is to drop a small file into a common
directory. These files represent queued work requests that get done in
batches about once per hour by another process running on a single
server. That process deletes the files it has processed.

The clients include a time stamp in the file names. However, because of
client clock skew (which was more of an issue many years ago when this
was set up), rather than sorting the files by time stamp, the server
process uses other heuristics to determine the order in which to process
requests based on the nature of the requests themselves -- creates,
mods, deletes, etc. falling into a hierarchy that almost always does the
Right Thing. The preferred order would be the actual order the files
were created in.

My question then is about the order of entries as files are created in
AFS directories. It occurs to me that even though the clients' clocks
may be out of sync, the files' actual creation order may be reflected in
the order directory entries are returned from readdir() since that
happens on the server. A few tests seem to show that this is the case,
but... are there any guarantees about the order directory entries are
created and returned from readdir(), all else being equal (by which I
mean, starting from an empty directory)? If not guarantees, how about in
terms of emergent properties due to current implementation? That's
subject to change of course, but these aren't life or death critical
operations and they are already questionably ordered in some
circumstances with our current scheme. So, would this be a reasonable
way to improve our processing order? Obviously we'd need to pay
attention to how we deleted these files to reduce create/delete ordering
issues.

Thoughts? Comments?
--
Todd_Lewis@unc.edu