Skip to content

fix: link remap restore on tmpfs#50

Merged
fals merged 6 commits into
live-4.2from
filipe/fix-link-remap-restore
Jun 12, 2026
Merged

fix: link remap restore on tmpfs#50
fals merged 6 commits into
live-4.2from
filipe/fix-link-remap-restore

Conversation

@fals

@fals fals commented Jun 12, 2026

Copy link
Copy Markdown
  • Reproduced the link remap issue, when we have the case /dev/shm the file is in tmpfs and criu during dump do not use the magic to dump as ghost file

Kimchi Summary

What changed

Fixes restore failures for mmapped files on external tmpfs mounts (such as /dev/shm in containers) that have been unlinked but retain st_nlink >= 1 by falling back to dump_ghost_remap() to embed the file content directly in the checkpoint image. Adds a ZDTM regression test reproducing the POSIX semaphore pattern.

Why

On external tmpfs mounts CRIU does not dump mount contents, so link_remap.N files created by dump_linked_remap() are lost during migration; the destination node restores with an empty tmpfs, causing ENOENT and broken VMAs. This change detects external tmpfs mounts and stores the file as a ghost remap instead.

Key changes

  • criu/files-reg.c: In check_path_remap(), added a TMPFS_MAGIC check that falls back to dump_ghost_remap() when the mount is external (mi->external) or an external bind (mnt_is_external_bind(mi)).
  • test/zdtm/static/Makefile: Added tmpfs_link_remap test target.
  • test/zdtm/static/tmpfs_link_remap.c: Added new regression test that creates a tmpfs file, mmaps it, hard-links and unlinks the original name (leaving st_nlink=1), then verifies content integrity across checkpoint/restore.
  • test/zdtm/static/tmpfs_link_remap.desc: Added test descriptor requiring --link-remap.

Impact

  • Fixes checkpoint/restore for POSIX semaphores and similar unlinked-tmpfile patterns on container runtime tmpfs mounts.
  • No behavior change for CRIU-managed tmpfs mounts (normal tar-based restore path remains unchanged).

@kimchi-review

kimchi-review Bot commented Jun 12, 2026

Copy link
Copy Markdown

Kimchi Code Review

Property Value
Commit bf86e2d
Author @fals
Files changed 0
Review status Completed
Comments 0
Duration 192s

Summary

📊 Review Score: 94/100 (overall code quality — 0 lowest, 100 highest)
⏱️ Estimated effort to review: 2/5 (1 = trivial, 5 = very complex)

🧪 Tests: yes — A new ZDTM test tmpfs_link_remap was added alongside the fix. It reproduces the exact POSIX-semaphore-on-tmpfs pattern (file on /dev/shm, mmapped, hard-linked, then unlinked) that triggers the buggy dump_linked_remap path. The test verifies both mmap content integrity via CRC and fd metadata after restore, providing solid coverage for the new TMPFS_MAGIC fallback branch.

No significant issues found. LGTM! 🎉

What to expect

Kimchi will analyze the changes in this pull request and post:

  • A summary of the overall changes
  • Inline comments on specific lines with findings categorized by issue type

The review typically completes within a few minutes. This comment will be updated once the review is ready.

Interact with Kimchi
  • @getkimchi review — re-trigger a full review on the latest commit
  • @getkimchi summary — regenerate the PR summary
  • @getkimchi ignore — skip this PR (no review will be posted)
  • Reply to any inline comment to ask follow-up questions or request clarification
Configuration

Reviews are configured by your organization admin.
Review instructions, excluded directories, and severity thresholds can be adjusted per repository in the Kimchi dashboard.


Powered by Kimchi — AI-powered code review by CAST AI

@fals fals changed the title Filipe/fix link remap restore fix: link remap restore on tmpfs Jun 12, 2026

@kimchi-review kimchi-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📊 Review Score: 94/100 (overall code quality — 0 lowest, 100 highest)
⏱️ Estimated effort to review: 2/5 (1 = trivial, 5 = very complex)

🧪 Tests: yes — A new ZDTM test tmpfs_link_remap was added alongside the fix. It reproduces the exact POSIX-semaphore-on-tmpfs pattern (file on /dev/shm, mmapped, hard-linked, then unlinked) that triggers the buggy dump_linked_remap path. The test verifies both mmap content integrity via CRC and fd metadata after restore, providing solid coverage for the new TMPFS_MAGIC fallback branch.

No significant issues found. LGTM! 🎉

@crvtsv

crvtsv commented Jun 12, 2026

Copy link
Copy Markdown

Ack

fals and others added 4 commits June 12, 2026 11:54
The tmpfs_link_remap test was hardcoding /dev/shm paths which don't
exist in the ns test flavor's mount namespace. Rewrite to accept
--dirname, mount tmpfs on it, and create test files there. Move from
TST_NOFILE back to TST_DIR accordingly.

Co-Authored-By: Kimchi <noreply@kimchi.dev>
The test needs CAP_SYS_ADMIN to call mount(). Add 'flags': 'suid' to
the desc file, matching tempfs.desc and mntns_link_remap.desc.

Co-Authored-By: Kimchi <noreply@kimchi.dev>
The blanket TMPFS_MAGIC guard broke mntns_link_remap which uses
dump_linked_remap on CRIU-managed tmpfs (saved via tar). The
link_remap.N file IS preserved in the tar archive for managed mounts,
so dump_linked_remap works correctly there.

Narrow the guard to only trigger for external tmpfs mounts (e.g.
/dev/shm provided by the container runtime), where CRIU does not dump
the mount contents and link_remap.N would be lost on the destination.

Co-Authored-By: Kimchi <noreply@kimchi.dev>
@fals fals merged commit 890a784 into live-4.2 Jun 12, 2026
4 checks passed
@fals fals deleted the filipe/fix-link-remap-restore branch June 12, 2026 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants