From: Christoph Hellwig <hch@infradead.org>
To: Chuck Lever <chuck.lever@oracle.com>
Cc: "Darrick J. Wong" <djwong@kernel.org>,
Sun Yongjian <sunyongjian1@huawei.com>,
linux-fsdevel@vger.kernel.org, yangerkun@huawei.com
Subject: Re: [PATCH] Revert "libfs: Use d_children list to iterate simple_offset directories"
Date: Wed, 12 Mar 2025 08:47:50 -0700 [thread overview]
Message-ID: <Z9GspnEyvYzrJGWt@infradead.org> (raw)
In-Reply-To: <d0dc742a-7373-4e1e-9af4-d7414b1d3f4e@oracle.com>
On Tue, Mar 11, 2025 at 03:39:32PM -0400, Chuck Lever wrote:
> It's not possible to guarantee that the next entry will have a higher
> offset value.
>
> Suppose the "New offset" value wraps. So the current directory entry
> will have a offset that is close to U32_MAX, but the next created
> directory entry will have an offset close to zero. In fact, new entries
> will have a smaller offset value than "current" for quite some time.
In fact even for on-disk file systems (including XFS) it often has a
lower value - most file systems try to fill holes in the d_off space
created by previously deleted entries. The big exception is btrfs,
which just uses a monotonically increasing 64-bit counter (which can
create problems fairly quickly on 32-bit systems, as the seekdir/telldir
cookie is a long and not a off_t and thus 32-bit on all 32-bit systems).
> The offset is a cookie, not a numeric value. It is simply something that
> says "please start here when iteration continues".
Yes. This then places into the next mine field about reporting
entries added between getdents iterations. Which can cause all kinds
of issues when done wrong especially for rename()d entries.
> Think of it as a
> hash -- it looks like a hexadecimal number, but has no other intrisic
> meaning. (In fact, I think some Linux file systems do use a hash here
> rather than a scalar integer).
A hash is actually kinda dangerous because it can trivially place
multiple values at the same offset with hash collision. And given
the hashes use for directories it isn't that hard to introduce them
intentionally for many file systems.
next prev parent reply other threads:[~2025-03-12 15:47 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-26 14:29 [PATCH] Revert "libfs: Use d_children list to iterate simple_offset directories" Greg Kroah-Hartman
2025-02-26 15:57 ` Chuck Lever
2025-02-26 16:21 ` Greg Kroah-Hartman
2025-02-26 16:28 ` Chuck Lever
2025-02-26 19:13 ` Greg Kroah-Hartman
2025-02-26 20:33 ` Chuck Lever
2025-03-10 16:29 ` Greg Kroah-Hartman
2025-03-10 17:30 ` Chuck Lever
2025-03-11 13:55 ` Sun Yongjian
2025-03-11 15:23 ` Chuck Lever
2025-03-11 18:11 ` Darrick J. Wong
2025-03-11 18:25 ` Chuck Lever
2025-03-11 18:52 ` Darrick J. Wong
2025-03-11 19:39 ` Chuck Lever
2025-03-11 21:47 ` Kent Overstreet
2025-03-12 15:39 ` Christoph Hellwig
2025-03-12 15:47 ` Christoph Hellwig [this message]
2025-03-13 13:45 ` Chuck Lever
2025-03-18 11:38 ` Sun Yongjian
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=Z9GspnEyvYzrJGWt@infradead.org \
--to=hch@infradead.org \
--cc=chuck.lever@oracle.com \
--cc=djwong@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=sunyongjian1@huawei.com \
--cc=yangerkun@huawei.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