* XFS directory entries sort order
@ 2008-06-10 9:45 dizzy
2008-06-10 17:20 ` Andi Kleen
0 siblings, 1 reply; 5+ messages in thread
From: dizzy @ 2008-06-10 9:45 UTC (permalink / raw)
To: xfs
Hello
Can someone tell me (in English or C :) ) the algorithm of the sorting order
of the entries in an XFS directory as I would get them with a readdir() (or
shell "find" command)?
I am trying to figure it out by reading linux/fs/xfs/xfs_dir2*.c code but I
don't seem to be doing much progress and I was hoping maybe someone that
knows these details can help.
Thank you!
--
Mihai RUSU Email: dizzy@roedu.net
"Linux is obsolete" -- AST
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: XFS directory entries sort order
2008-06-10 9:45 XFS directory entries sort order dizzy
@ 2008-06-10 17:20 ` Andi Kleen
2008-06-10 23:53 ` Barry Naujok
0 siblings, 1 reply; 5+ messages in thread
From: Andi Kleen @ 2008-06-10 17:20 UTC (permalink / raw)
To: dizzy; +Cc: xfs
dizzy <dizzy@roedu.net> writes:
> Can someone tell me (in English or C :) ) the algorithm of the sorting order
> of the entries in an XFS directory as I would get them with a readdir() (or
> shell "find" command)?
>
> I am trying to figure it out by reading linux/fs/xfs/xfs_dir2*.c code but I
> don't seem to be doing much progress and I was hoping maybe someone that
> knows these details can help.
I believe it computes a hash over the name and then sorts by the hash
numerical value. At least the b*tree large directories do, small inline
directories might be different (XFS uses different algorithms for
different directory sizes)
The hash function is in xfs_da_btree.c:xfs_da_hashname()
With the recent case insensitive support there are also differences
on the file systems which have that enabled.
Also better don't rely on it never changing.
-Andi
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: XFS directory entries sort order
2008-06-10 17:20 ` Andi Kleen
@ 2008-06-10 23:53 ` Barry Naujok
2008-06-10 23:58 ` Andi Kleen
0 siblings, 1 reply; 5+ messages in thread
From: Barry Naujok @ 2008-06-10 23:53 UTC (permalink / raw)
To: Andi Kleen, dizzy; +Cc: xfs
On Wed, 11 Jun 2008 03:20:00 +1000, Andi Kleen <andi@firstfloor.org> wrote:
> dizzy <dizzy@roedu.net> writes:
>
>> Can someone tell me (in English or C :) ) the algorithm of the sorting
>> order
>> of the entries in an XFS directory as I would get them with a readdir()
>> (or
>> shell "find" command)?
>>
>> I am trying to figure it out by reading linux/fs/xfs/xfs_dir2*.c code
>> but I
>> don't seem to be doing much progress and I was hoping maybe someone that
>> knows these details can help.
>
> I believe it computes a hash over the name and then sorts by the hash
> numerical value. At least the b*tree large directories do, small inline
> directories might be different (XFS uses different algorithms for
> different directory sizes)
readdir order is not dependant on the hashes. The order depends on the
order of files being created, unlinked and the length of the filenames
being unlinked/created.
> The hash function is in xfs_da_btree.c:xfs_da_hashname()
>
> With the recent case insensitive support there are also differences
> on the file systems which have that enabled.
>
> Also better don't rely on it never changing.
Yes :)
Barry.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: XFS directory entries sort order
2008-06-10 23:53 ` Barry Naujok
@ 2008-06-10 23:58 ` Andi Kleen
2008-06-11 0:04 ` Barry Naujok
0 siblings, 1 reply; 5+ messages in thread
From: Andi Kleen @ 2008-06-10 23:58 UTC (permalink / raw)
To: Barry Naujok; +Cc: dizzy, xfs
> readdir order is not dependant on the hashes. The order depends on the
> order of files being created, unlinked and the length of the filenames
> being unlinked/created.
Thanks for the correction. It's a long time that I read that source
so it probably got confused with some other fs.
-Andi
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: XFS directory entries sort order
2008-06-10 23:58 ` Andi Kleen
@ 2008-06-11 0:04 ` Barry Naujok
0 siblings, 0 replies; 5+ messages in thread
From: Barry Naujok @ 2008-06-11 0:04 UTC (permalink / raw)
To: Andi Kleen; +Cc: dizzy, xfs
On Wed, 11 Jun 2008 09:58:57 +1000, Andi Kleen <andi@firstfloor.org> wrote:
>
>> readdir order is not dependant on the hashes. The order depends on the
>> order of files being created, unlinked and the length of the filenames
>> being unlinked/created.
>
> Thanks for the correction. It's a long time that I read that source
> so it probably got confused with some other fs.
If I read the code correctly, in node-form directories, it will try and
use the same data block that other names with the same hash are located in.
Barry.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-06-11 0:04 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-10 9:45 XFS directory entries sort order dizzy
2008-06-10 17:20 ` Andi Kleen
2008-06-10 23:53 ` Barry Naujok
2008-06-10 23:58 ` Andi Kleen
2008-06-11 0:04 ` Barry Naujok
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox