From: David Matlack <dmatlack@google.com>
To: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: linux-kselftest@vger.kernel.org, rppt@kernel.org,
shuah@kernel.org, akpm@linux-foundation.org, linux-mm@kvack.org,
vipinsh@google.com, linux-kernel@vger.kernel.org,
kexec@lists.infradead.org, pratyush@kernel.org, graf@amazon.com
Subject: Re: [PATCH v1 0/7] liveupdate: tmpfs preservation and early freeze
Date: Thu, 15 Oct 2026 21:53:27 +0000 [thread overview]
Message-ID: <atFLV3tT0s3y6zMp@google.com> (raw)
In-Reply-To: <atE53vmlDeA4cWD2@google.com>
On 2026-10-15 04:38 PM, Pasha Tatashin wrote:
> What if instead of retrieve-into an existing file FD, userspace passes
> a dir_fd on the target tmpfs mount where the file should be restored?
This is good. This eliminates the pinning race and also eliminates the
checks v1 had to do on the userspace-provided file.
> During preserve we can record the file's basename if the file was linked
> (or mark that it was unlinked). On retrieve, creates a brand-new file in
> dir_fd (e.g. starts as an unlinked O_TMPFILE on that tmpfs superblock),
> populates all the folios and metadata while the file is still unreachable
> by anyone else, links it into dir_fd under the preserved name at the end
> (or leaves it unlinked if the original file was unlinked), and returns
> the FD of the new file to userspace.
I don't think the name should be in the ABI though:
- Userspace already has to know what each token is, so it knows the
name. And a basename isn't enough anyway, since userspace still has
to supply the directory.
- "The name" isn't well defined. A file can have several hard links,
and it can be renamed or unlinked between preserve and freeze.
- Linking in the kernel needs a policy for collisions, and linking at
finish() can fail (or find the name taken) at a point where there's
no good way to report it.
- The name isn't the only thing needed to create the file properly.
There's also the mode, the owner (fsuid/fsgid, setgid directories,
idmapped mounts), default ACLs and LSM labels, the access mode of the
fd, and whether the file may be linked at all. If we record those in
the ABI it grows a lot.
What if we model the retrieve args on open() directly? RETRIEVE_FD
behaves like openat(dirfd, ".", O_TMPFILE | flags, mode), then fills the
file, then returns the fd:
struct liveupdate_memfd_retrieve_arg {
__u32 size;
__s32 dirfd;
__aligned_u64 flags; /* subset of O_*, ORed with O_TMPFILE */
__aligned_u64 mode;
};
In the kernel this is file_open_root(&dir_path, ".", O_TMPFILE | flags,
mode), which goes through the same path as open().
Userspace links the file into place with linkat() whenever it wants, the
usual O_TMPFILE way, or passes O_EXCL to make it unlinkable. Then
there's no name in the ABI or the uAPI, no linking in the kernel,
unlinked files are just files userspace never links, and "don't link it
until it's fully populated" comes for free.
One quirk: open() rejects O_TMPFILE without write access. With LUO
holding the file until finish, that brings back the -ETXTBSY problem for
restored binaries. vfs_tmpfile() itself doesn't need write access, and
neither does filling the file, so I think we can allow an O_RDONLY |
O_TMPFILE here.
> I would like file type to stay exactly the same, I really don't want to
> play the game where LUO can magically change file from one type to
> another even if from Linux internal implementation they share a lot of
> code, they are still a different file types from the user perspective.
Ok, I don't feel that strongly. We should just do it based on the
superblock rather than i_nlink, so that O_TMPFILE and unlinked tmpfs
files stay on a user mount.
prev parent reply other threads:[~2026-10-15 21:53 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-15 9:38 [PATCH v1 0/7] liveupdate: tmpfs preservation and early freeze Pasha Tatashin
2026-10-15 9:38 ` [PATCH v1 1/7] liveupdate: Add LIVEUPDATE_SESSION_FREEZE ioctl to freeze sessions early Pasha Tatashin
2026-10-15 9:47 ` sashiko-bot
2026-10-15 9:38 ` [PATCH v1 2/7] selftests: liveupdate: Add tests for LIVEUPDATE_SESSION_FREEZE Pasha Tatashin
2026-10-15 9:45 ` sashiko-bot
2026-10-15 9:38 ` [PATCH v1 3/7] liveupdate: Pass user argument to file preserve and retrieve Pasha Tatashin
2026-10-15 9:49 ` sashiko-bot
2026-10-15 9:38 ` [PATCH v1 4/7] selftests: liveupdate: Add tests for preserve and retrieve user argument Pasha Tatashin
2026-10-15 9:45 ` sashiko-bot
2026-10-15 9:38 ` [PATCH v1 5/7] liveupdate: Allow file handlers to mark retrieve failures as retryable Pasha Tatashin
2026-10-15 9:46 ` sashiko-bot
2026-10-15 9:38 ` [PATCH v1 6/7] mm/memfd_luo: Support tmpfs preservation and retrieval Pasha Tatashin
2026-10-15 9:54 ` sashiko-bot
2026-10-15 9:38 ` [PATCH v1 7/7] selftests: liveupdate: Add test coverage for " Pasha Tatashin
2026-10-15 9:47 ` sashiko-bot
2026-10-15 17:48 ` [PATCH v1 0/7] liveupdate: tmpfs preservation and early freeze David Matlack
2026-10-15 18:23 ` Pasha Tatashin
2026-10-15 18:54 ` David Matlack
2026-10-15 20:38 ` Pasha Tatashin
2026-10-15 21:53 ` David Matlack [this message]
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=atFLV3tT0s3y6zMp@google.com \
--to=dmatlack@google.com \
--cc=akpm@linux-foundation.org \
--cc=graf@amazon.com \
--cc=kexec@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=pasha.tatashin@soleen.com \
--cc=pratyush@kernel.org \
--cc=rppt@kernel.org \
--cc=shuah@kernel.org \
--cc=vipinsh@google.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.