From: "Theodore Ts'o" <tytso@mit.edu>
To: Dave Chinner <david@fromorbit.com>
Cc: Mateusz Guzik <mjguzik@gmail.com>,
Florian Weimer <fweimer@redhat.com>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-api@vger.kernel.org, Dave Chinner <dchinner@redhat.com>
Subject: Re: Testing if two open descriptors refer to the same inode
Date: Tue, 30 Jul 2024 00:19:33 -0400 [thread overview]
Message-ID: <20240730041933.GC719392@mit.edu> (raw)
In-Reply-To: <ZqhQnWQSweXgffdD@dread.disaster.area>
On Tue, Jul 30, 2024 at 12:31:57PM +1000, Dave Chinner wrote:
> I don't think you can make such a simplistic delineation, because
> there's more than one issue at play here.
>
> There are at least two different "is this inode identical"
> use cases that {st_dev,st_ino} is being used for.
>
> The first, as Florian described, is to determine if two open fds
> refer to the same inode for collision avoidance.
>
> This works on traditional filesystems like ext4 and XFS, but isn't
> reliable on filesystems with integrated snapshot/subvolume
> functionality.
That's fair, but the first is the problem I think is more important,
because there are existing programs which are depending on
st_dev/st_ino as being a reliable way of detecting uniqueness --- and
if this breas, file data may get corrpted, or the dyanmic linker will
assume that two unrelated shared libraries are actually the same, with
hilarity then ensuing --- because an interface which is guaranteed by
decade of Unix history, and POSIX, is broken by some Linux file
systems.
> The second is that {dev,ino} is being used to disambiguate paths
> that point to hardlinked inodes for the purposes of identifying
> and optimising access and replication of shared (i.e. non-unique)
> file data.
>
> This works on traditional filesystems like ext4, but fails badly on
> filesystem that support FICLONERANGE (XFS, btrfs, NFS, CIFS,
> bcachefs, etc) because cloned files have unique inodes but
> non-unique data.
That's a problem, yes --- but it's a previously unsolved problem, and
the failure will cause inefficiency, but it doesn't actually cause
data corruption.
It's also a very hard problem, especially if we're considering the
full, general FICLONERANGE interface, where an arbitrary subset of
blocks at one offset, might be cloned at a completely different offset
in a different file, and where a single file might have cloned ranges
from a dozens of other files. How this information would be
communicated to userspace, so they could copy a directory hierarchy
without an increased expansion is a hard problem.
Given that we have a simple solution (filehandles) to fix a problem
where false positives causes lost data or core dumps, let's solve the
simple problem and try to get it standardized acrossed operating
systems beyond Linux, and in parallel, we can try to figure out a much
more complicated interface to solve this other problem.
- Ted
next prev parent reply other threads:[~2024-07-30 4:19 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-29 6:55 Testing if two open descriptors refer to the same inode Florian Weimer
2024-07-29 9:09 ` Aleksa Sarai
2024-07-29 9:29 ` Florian Weimer
2024-07-29 10:18 ` Mateusz Guzik
2024-07-29 10:40 ` Florian Weimer
2024-07-29 10:50 ` Mateusz Guzik
2024-07-29 10:56 ` Mateusz Guzik
2024-07-29 10:57 ` Florian Weimer
2024-07-29 11:06 ` Mateusz Guzik
2024-07-29 11:36 ` Florian Weimer
2024-07-29 12:00 ` Mateusz Guzik
2024-07-29 11:40 ` Aleksa Sarai
2024-07-31 18:07 ` David Sterba
2024-07-29 11:47 ` Aleksa Sarai
2024-07-29 12:12 ` Mateusz Guzik
2024-07-29 23:19 ` Dave Chinner
2024-07-29 23:08 ` Dave Chinner
2024-07-29 12:26 ` Christian Brauner
2024-07-29 13:36 ` Theodore Ts'o
2024-07-30 2:31 ` Dave Chinner
2024-07-30 4:19 ` Theodore Ts'o [this message]
2024-07-30 15:38 ` Christoph Hellwig
2024-07-29 15:24 ` Jeff Layton
2024-07-29 15:39 ` Florian Weimer
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=20240730041933.GC719392@mit.edu \
--to=tytso@mit.edu \
--cc=david@fromorbit.com \
--cc=dchinner@redhat.com \
--cc=fweimer@redhat.com \
--cc=linux-api@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mjguzik@gmail.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;
as well as URLs for NNTP newsgroup(s).