Skip to content

sdk/rust: Fix overlayfs whiteout for base files in promoted dirs#316

Open
broady wants to merge 1 commit intotursodatabase:mainfrom
broady:fix/overlayfs-whiteout-promoted-dirs
Open

sdk/rust: Fix overlayfs whiteout for base files in promoted dirs#316
broady wants to merge 1 commit intotursodatabase:mainfrom
broady:fix/overlayfs-whiteout-promoted-dirs

Conversation

@broady
Copy link
Contributor

@broady broady commented Feb 9, 2026

When a base-layer file is unlinked or renamed inside a directory that has been promoted from Base to Delta (via ensure_parent_dirs), the old code walked the base HostFS to decide whether to create a whiteout. For promoted directories the base inode mapping was already removed by promote_to_delta(), so the walk silently returned early -- skipping whiteout creation and leaving the base file visible through the overlay.

This caused dpkg to fail with EEXIST during package installs: unlink of /var/lib/dpkg/status-old succeeded in delta but never created a whiteout, so the subsequent link("status", "status-old") found the base-layer file and returned EEXIST.

Fix by:

  1. Extracting resolve_delta_parent() that walks the delta layer by path to find the parent inode, replacing 9 inline walk patterns across lookup, mkdir, create_file, mknod, symlink, unlink, rmdir, link, and rename. The walk validates that each component is a directory to avoid shadowing by non-directory entries (same class as sdk/rust: Fix overlay lookup using wrong delta parent inode #300).

  2. Changing unlink/rmdir to remove from delta first, then use self.lookup() to detect whether the file is still visible -- if so, it must be from base and needs a whiteout.

  3. Moving delta parent resolution in rename() after copy_up() and ensure_parent_dirs() so the delta directories exist before we try to resolve them.

Add 8 unit tests and extend the existing shell integration test with base-file whiteout coverage.

@broady broady force-pushed the fix/overlayfs-whiteout-promoted-dirs branch from f06ffb3 to c80f682 Compare February 9, 2026 04:02
@broady
Copy link
Contributor Author

broady commented Feb 9, 2026

ah, the test is failing because of a separate fuse issue - cached directory entries, I'll try to address that issue separately (bug/PR)

@broady
Copy link
Contributor Author

broady commented Feb 9, 2026

FUSE cli integration test blocked on #317

@broady broady force-pushed the fix/overlayfs-whiteout-promoted-dirs branch from c80f682 to 54e4a17 Compare February 13, 2026 19:35
@broady
Copy link
Contributor Author

broady commented Feb 13, 2026

ready to review/merge @penberg

When a base-layer file is unlinked or renamed inside a directory
that has been promoted from Base to Delta (via ensure_parent_dirs),
the old code walked the base HostFS to decide whether to create a
whiteout. For promoted directories the base inode mapping was
already removed by promote_to_delta(), so the walk silently
returned early -- skipping whiteout creation and leaving the base
file visible through the overlay.

This caused dpkg to fail with EEXIST during package installs:
unlink of /var/lib/dpkg/status-old succeeded in delta but never
created a whiteout, so the subsequent link("status", "status-old")
found the base-layer file and returned EEXIST.

Fix by:

1. Extracting resolve_delta_parent() that walks the delta layer
   by path to find the parent inode, replacing 9 inline walk
   patterns across lookup, mkdir, create_file, mknod, symlink,
   unlink, rmdir, link, and rename. The walk validates that each
   component is a directory to avoid shadowing by non-directory
   entries (same class as tursodatabase#300).

2. Changing unlink/rmdir to remove from delta first, then use
   self.lookup() to detect whether the file is still visible
   -- if so, it must be from base and needs a whiteout.

3. Moving delta parent resolution in rename() after copy_up()
   and ensure_parent_dirs() so the delta directories exist
   before we try to resolve them.

Add 8 unit tests and extend the existing shell integration test
with base-file whiteout coverage.
@broady broady force-pushed the fix/overlayfs-whiteout-promoted-dirs branch from 54e4a17 to 8a7c44c Compare February 14, 2026 00:57
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.

1 participant