[Top] [All Lists]

Re: XFS directory entries sort order

To: dizzy <dizzy@xxxxxxxxx>
Subject: Re: XFS directory entries sort order
From: Andi Kleen <andi@xxxxxxxxxxxxxx>
Date: Tue, 10 Jun 2008 19:20:00 +0200
Cc: xfs@xxxxxxxxxxx
In-reply-to: <200806101245.09950.dizzy@xxxxxxxxx> (dizzy@xxxxxxxxx's message of "Tue, 10 Jun 2008 12:45:09 +0300")
References: <200806101245.09950.dizzy@xxxxxxxxx>
Sender: xfs-bounce@xxxxxxxxxxx
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (gnu/linux)
dizzy <dizzy@xxxxxxxxx> 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.


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