From: "Theodore Tso" <tytso@mit.edu>
To: NeilBrown <neil@brown.name>
Cc: Matthew Wilcox <willy@infradead.org>,
fstests@vger.kernel.org, linux-fsdevel@vger.kernel.org,
Chuck Lever <cel@kernel.org>
Subject: Re: [PATCH] fstests: generic: Add test of seek in directories
Date: Fri, 28 Aug 2026 10:55:16 -0400 [thread overview]
Message-ID: <apGfAFkNdD5mrASi@mit.edu> (raw)
In-Reply-To: <178791556100.3510150.18132687067056760170@noble.neil.brown.name>
The key requirements come from readdir() and seekdir(). To quote from
readdir() specification:
If a file is removed from or added to the directory after the most
recent call to opendir() or rewinddir(), whether a subsequent call
to readdir() returns an entry for that file is unspecified.
And then from seekdir():
The seekdir() function shall set the position of the next readdir()
operation on the directory stream specified by dirp to the position
specified by loc. The value of loc should have been returned from
an earlier call to telldir(). The new position reverts to the one
associated with the directory stream when telldir() was performed.
If the value of loc was not obtained from an earlier call to
telldir(), or if a call to rewinddir() occurred between the call to
telldir() and the call to seekdir(), the results of subsequent
calls to readdir() are unspecified.
Telldir() is specified to return a "cookie". It does not have to be a
offset, and the DIR * returned by opendir() and consumed by
readdir() does not have to be backed by a file descriptor.
Historically, jfs implemented an whole an extra on-disk btree in order
to implement the insane POSIX seekdir()/telldir() semantics. (Meaning
every single directory insert or deletion required at least one extra
disk seek.) Ext4 returns directory entries in a very sub-optimal hash
tree order, requiring lots of extra disk seeks, in order to provide
this guarantee. This is also something that historically has been
enforced by Posix Compliance Test Suites (PCTS) for those people who
believed that Posix compliance was relevant.
And, yes we also go through all of this pain and performance hit not
just because of Posix compliance, but also because NFS requires it.
Personally, supporting NFS is *way* more important than Posix
compliance, but people of good will can have different priorities. :-)
For this reason, I would support having a test to provide the
gaurantee needed for Posix and NFS compatibility. Not for Posix's
sake, but for NFS's.
Cheers,
- Ted
next prev parent reply other threads:[~2026-08-28 14:56 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-27 23:36 fstests: Verify behaviour of "seek" in a directory NeilBrown
2026-08-27 23:36 ` [PATCH] fstests: generic: Add test of seek in directories NeilBrown
2026-08-28 4:13 ` Matthew Wilcox
2026-08-28 11:12 ` NeilBrown
2026-08-28 14:55 ` Theodore Tso [this message]
2026-08-30 22:22 ` NeilBrown
2026-08-31 1:37 ` Theodore Tso
2026-08-31 13:16 ` Christoph Hellwig
2026-09-01 1:05 ` NeilBrown
2026-09-01 9:18 ` Christoph Hellwig
2026-08-30 23:13 ` Chuck Lever
2026-08-31 12:59 ` Christoph Hellwig
2026-08-31 22:47 ` NeilBrown
2026-09-01 9:09 ` Christoph Hellwig
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=apGfAFkNdD5mrASi@mit.edu \
--to=tytso@mit.edu \
--cc=cel@kernel.org \
--cc=fstests@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=neil@brown.name \
--cc=willy@infradead.org \
/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