From: Stewart Smith <stewart@flamingspork.com>
To: Theodore Ts'o <tytso@mit.edu>, Radek Pazdera <rpazdera@redhat.com>
Cc: linux-ext4@vger.kernel.org, "Lukáš Czerner" <lczerner@redhat.com>
Subject: Re: [RFC] Optimizing readdir()
Date: Mon, 14 Jan 2013 17:09:26 +1100 [thread overview]
Message-ID: <87wqvge1nt.fsf@flamingspork.com> (raw)
In-Reply-To: <20130114045152.GF29329@thunk.org>
[-- Attachment #1: Type: text/plain, Size: 1066 bytes --]
Theodore Ts'o <tytso@mit.edu> writes:
> I wonder if the better approach is to just simply have some
> easy-to-use library routines that do a readdir/sort in userspace. The
> spd_readdir does basically this, and as we can see it's good enough
> for most purposes. The problem is danger when using this in threaded
> programs, or if you have programs doing really strange things with
> telldir/seekdir, etc.
>
> But it wouldn't be that hard to write a generic library function which
> if it were used for find, ls, tar, and a few other key programs, would
> solve the problem for most use cases.
Many times I've used scandir(3) to do this.
(copying out of notmuch/notmuch-new.c):
static int
dirent_sort_inode (const struct dirent **a, const struct dirent **b)
{
return ((*a)->d_ino < (*b)->d_ino) ? -1 : 1;
}
(as then doing stat() on each file is *much* faster in inode order)
glibc provides alphasort() (POSIX.1-2008) and versionsort() (GNU
extension), it'd probably be great if it also provided inodesort()
--
Stewart Smith
[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]
next prev parent reply other threads:[~2013-01-14 6:16 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-13 15:22 [RFC] Optimizing readdir() Radek Pazdera
2013-01-14 4:51 ` Theodore Ts'o
2013-01-14 6:09 ` Stewart Smith [this message]
2013-01-15 7:21 ` Radek Pazdera
2013-01-15 22:44 ` Andreas Dilger
2013-01-17 15:53 ` Radek Pazdera
2013-01-29 16:38 ` Radek Pazdera
2013-01-30 11:34 ` Lukáš Czerner
2013-02-02 19:45 ` Andreas Dilger
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=87wqvge1nt.fsf@flamingspork.com \
--to=stewart@flamingspork.com \
--cc=lczerner@redhat.com \
--cc=linux-ext4@vger.kernel.org \
--cc=rpazdera@redhat.com \
--cc=tytso@mit.edu \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.