From: Christoph Hellwig <hch@infradead.org>
To: NeilBrown <neil@brown.name>
Cc: Christoph Hellwig <hch@infradead.org>,
Matthew Wilcox <willy@infradead.org>,
fstests@vger.kernel.org, linux-fsdevel@vger.kernel.org,
Chuck Lever <cel@kernel.org>,
linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] fstests: generic: Add test of seek in directories
Date: Tue, 1 Sep 2026 02:18:32 -0700 [thread overview]
Message-ID: <apaYaEx6hlyRbe4c@infradead.org> (raw)
In-Reply-To: <178822473504.3510150.6373190942920919075@noble.neil.brown.name>
On Tue, Sep 01, 2026 at 11:05:35AM +1000, NeilBrown wrote:
> > > I think a strong argument for Linux needing something is that NFS needs
> > > working directory offsets to be able to support READDIR, because there
> > > is no "OPEN" request for directories.
> >
> > I don't think anyone disputes the need for stable directory offsets,
> > and we should (*knock on wood*) have implementation of native
> > file systems that fail this.
>
> "should not" ??
Yes.
> > What the test tries to force is a specific behavior for rename onto
> > existing file names, replacing the original file name entry with
> > a new one of the same name. The test expects that to reuse the
> > previous d_off, which is not required by any real or de facto standard.
>
> That's debatable. The documents that I have found don't mention rename.
> Does that mean anything goes, or do that mean it doesn't get an
> exemption from the general rule that all names must be listed?
The Posix definition of rename is very explicit that the old directory
entry shall be removed:
Otherwise, if the directory entry named by new exists, it shall be
removed and old renamed to new. In this case, a directory entry named
new shall remain visible to other threads throughout the renaming
operation and refer either to the file referred to by new or old
before the operation began.
So the previous directory entry for "new" shall be removed. If a
file system reuses the same d_off for the renamed file, it just created
a new entry that happens to instantly reuse the d_off in the same atomic
operation.
> I think a fix to make it work over NFS would be to report the entries in
> reverse order - most recently added to least recently added. This would
> effectively encode the timestamp (last_index) in the seek cookie instead
> of in btrfs_file_private.
> Changing how the seek-cookie is interpreted could cause a hiccup
> for an NFS client which was in the middle of a READDIR when a server
> we reboot to a new verion of btrfs, but that is likely not significant.
>
> Note that
> https://pubs.opengroup.org/onlinepubs/9799919799/functions/posix_getdents.html
>
> uses the word "incremented" in
>
> the directory entry immediately following the last entry whose
> information was returned
>
> but I don't think anyone seems interested in that detail.
I would suggest to ignore posix_getdents or the whole Issue 8 base spec,
as unlike previous versions I did not try to document and norm existing
behavior, but instead comes up with it's own things. If we need a
justification we should look at historic Linux and Unix behaviors and
older Posix specs that haven't drifted away from the purpose as much
as the current one.
next prev parent reply other threads:[~2026-09-01 9:18 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
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 [this message]
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=apaYaEx6hlyRbe4c@infradead.org \
--to=hch@infradead.org \
--cc=cel@kernel.org \
--cc=fstests@vger.kernel.org \
--cc=linux-btrfs@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