public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Andi Kleen <andi@firstfloor.org>
To: dizzy <dizzy@roedu.net>
Cc: xfs@oss.sgi.com
Subject: Re: XFS directory entries sort order
Date: Tue, 10 Jun 2008 19:20:00 +0200	[thread overview]
Message-ID: <87prqpp5q7.fsf@basil.nowhere.org> (raw)
In-Reply-To: <200806101245.09950.dizzy@roedu.net> (dizzy@roedu.net's message of "Tue, 10 Jun 2008 12:45:09 +0300")

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

  reply	other threads:[~2008-06-10 17:19 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-10  9:45 XFS directory entries sort order dizzy
2008-06-10 17:20 ` Andi Kleen [this message]
2008-06-10 23:53   ` Barry Naujok
2008-06-10 23:58     ` Andi Kleen
2008-06-11  0:04       ` Barry Naujok

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87prqpp5q7.fsf@basil.nowhere.org \
    --to=andi@firstfloor.org \
    --cc=dizzy@roedu.net \
    --cc=xfs@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox