xfs
[Top] [All Lists]

readdir() ordering guarantees on XFS

To: xfs@xxxxxxxxxxx
Subject: readdir() ordering guarantees on XFS
From: dizzy <dizzy@xxxxxxxxx>
Date: Fri, 6 Jun 2008 16:34:13 +0300
Sender: xfs-bounce@xxxxxxxxxxx
User-agent: KMail/1.9.9
Hello

POSIX leaves unspecified the order of getting the entries with readdir(). This 
is normal since different filesystems may implement their own techniques to 
organize entries in a directory (linear, hash, various search trees, etc).

But if I can makes sure that several Linux machines will have the same FS (ie 
XFS), mount options and same kernels can assume that traversing the same file 
hierarchy structure (that is a file structure with the exact same directories 
and files as names, structure, attributes, except maybe "ctime" which we 
can't really control in Linux) can I expect that traversing using readdir() 
will give me the entries in the exact same order? Or are there any other 
conditions that I have to check for that would guarantee it? (such as, for a 
linear directory aproach one has to have created the directory entries in the 
same order on all the machines to expect same order on readdir()).

Currently, we workaround this issue by reading all the directory entries, 
sorting them and traversing the entries in the sorted order. This however has 
been proven to slow the traversal (depth first traversal) operation about 30% 
than doing it in the order received from readdir() (I even had the test code 
read the whole directory contents, sort them in memory but still have it 
traverse in the order readdir() reported and it is 30% faster than traversing 
in the sorted order).

Any idea?

Thanks!

PS: please Cc: me as I'm not subscribed to the list, thank you

-- 
Mihai RUSU                                      Email: dizzy@xxxxxxxxx
                        "Linux is obsolete" -- AST


<Prev in Thread] Current Thread [Next in Thread>