From: Nikita Danilov <nikita@clusterfs.com>
To: Anton Altaparmakov <aia21@cam.ac.uk>
Cc: J?rn Engel <joern@wohnheim.fh-wedel.de>,
Jan Blunck <jblunck@suse.de>,
miklos@szeredi.hu, aaranya@cs.sunysb.edu,
linux-fsdevel@vger.kernel.org
Subject: Re: Expected getdents behaviour
Date: Fri, 16 Sep 2005 11:50:20 +0400 [thread overview]
Message-ID: <17194.31036.70042.635177@gargle.gargle.HOWL> (raw)
In-Reply-To: <Pine.LNX.4.60.0509152201520.21782@hermes-1.csi.cam.ac.uk>
Anton Altaparmakov writes:
[...]
>
> I don't know how your hash works but on ntfs this does not work like that.
> There is no parameter which would be able to tell you where you are in the
> b tree, unless you take a reference on an entry so it cannot be removed
> (rename==remove btw) but how does the reference get released later?
Reiser4 has exactly the same problem, and this is how it was solved (not
for the weak of heart):
- offset of a directory entry is its ordinal number within a
directory. I.e., first name in the directory has offset 0, second---1,
etc.;
- struct file for directory remembers "current readdir position" which
is a pair (ordinal-number-of-entry, key-of-entry-in-the--tree);
- on seekdir(dir, pos) (== lseek(dir, pos)), pos is the ordinal number
of the target entry, and comparing it with the current readdir position
we know how many entries to rewind to the left or to the right to reach
the target. This can be done in any reasonable *-tree (for suitable
values of *);
- now the fun (or horror) part: above rewinding does not work correctly
when entries were added or removed between current position and the
target entry. To work about this, all directory modifications are
monitored and current position is adjusted accordingly: when new
directory entry is created, its key is compared against key in the
current readdir position. If entry's key is smaller, then entry is
added "before" current position and current position's
ordinal-number-of-entry is incremented. Similarly for entry removal;
- this of course is still fragile and can be broken, but that's enough
for most cases (rm -r and friends work, for example);
- additional complexities due to non-unique keys in the tree and NFS
(where we don't have persistent struct file for a directory) are left
as an exercise for a reader.
Nikita.
next prev parent reply other threads:[~2005-09-16 7:50 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-09-15 13:57 Expected getdents behaviour Akshat Aranya
2005-09-15 14:03 ` Peter Staubach
2005-09-15 14:07 ` Anton Altaparmakov
2005-09-15 14:12 ` Anton Altaparmakov
2005-09-15 14:45 ` Miklos Szeredi
2005-09-15 15:17 ` Anton Altaparmakov
2005-09-15 16:41 ` Jan Blunck
2005-09-15 17:46 ` Jörn Engel
2005-09-15 18:19 ` Theodore Ts'o
2005-09-15 21:04 ` Anton Altaparmakov
2005-09-16 7:50 ` Nikita Danilov [this message]
2005-09-15 21:47 ` Jörn Engel
2005-09-16 7:29 ` Nikita Danilov
2005-09-16 11:58 ` Theodore Ts'o
2005-09-15 21:00 ` Anton Altaparmakov
2005-09-15 21:15 ` Charles P. Wright
2005-09-15 21:19 ` Anton Altaparmakov
2005-09-15 20:28 ` Anton Altaparmakov
2005-09-15 16:51 ` Miklos Szeredi
2005-09-15 21:17 ` Anton Altaparmakov
2005-09-15 15:51 ` Theodore Ts'o
2005-09-15 16:52 ` Bryan Henderson
2005-09-15 16:57 ` Jeremy Allison
2005-09-15 20:51 ` Anton Altaparmakov
2005-09-15 20:50 ` Anton Altaparmakov
2005-09-15 23:41 ` Bryan Henderson
2005-09-15 20:25 ` Anton Altaparmakov
2005-09-16 3:39 ` Theodore Ts'o
2005-09-16 11:57 ` Dave Kleikamp
2005-09-15 18:08 ` Nikita Danilov
2005-09-16 11:23 ` Miklos Szeredi
2005-09-16 1:28 ` tridge
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=17194.31036.70042.635177@gargle.gargle.HOWL \
--to=nikita@clusterfs.com \
--cc=aaranya@cs.sunysb.edu \
--cc=aia21@cam.ac.uk \
--cc=jblunck@suse.de \
--cc=joern@wohnheim.fh-wedel.de \
--cc=linux-fsdevel@vger.kernel.org \
--cc=miklos@szeredi.hu \
/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;
as well as URLs for NNTP newsgroup(s).