Repository navigation
Commit 2a483a0
virtiofs: keep node names when renaming one hard link onto another
A guest rename of a hard link onto another link of the same object
succeeds on a Linux host without changing anything, as POSIX requires,
but HostFs dropped the source name from the object's node
(microsoft/nvx#1620). Once the guest removed the other link, the node
had no names left although the source still reached its object, so
requests on the node failed with ENOENT, and a microVM save failed
with "inode has no bounded reopenable aliases".
VirtioFs::rename tracks a rename that is not an exchange as a move: it
drops the names at and below the destination, which the host replaced,
and then rewrites those at and below the source under the destination.
When both are links of one object, renameat2 replaces and moves
nothing, but the node keeps only the destination's name.
After a successful rename on a POSIX host, HostFs now checks whether
the source still reaches the destination's object, and then changes no
names. It decides from the host's result, not from the two names
before the rename: through overlayfs, two hard links in a lower layer
report one inode number, but the rename still moves one onto the
other. A Windows host does move the name: NTFS removes the source
link, which the move's bookkeeping already records, and a rename that
changes only the case of a name leaves the old spelling reaching the
object, so the check stays off there. The rename still passes the
move's alias-limit preflight, and the names that it keeps already fit
the limits.
renaming_a_hard_link_onto_another_link_keeps_the_remaining_names, in
virtiofs' microVM rename tests, renames a hard link onto another link
of its object in one directory and across two, after checking that the
host still fails such a rename under RENAME_NOREPLACE, with EEXIST on
Linux and EINVAL on Windows. On Linux, the node keeps all three names,
a snapshot taken right away saves and restores them, and the node
still reads the object through the source once the guest removes the
other links. On Windows, the host keeps only the destination, and so
does the node. Without the fix, on top of the fix for
microsoft/nvx#1610 at feature/microvm/dev b51f915, it fails on Linux
(nvx-kvm-test, Azure Linux 3, kernel 6.18), where the node keeps only
the destination, and passes on Windows; with it, it and the package's
other tests pass on both.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 1270a97 commit 2a483a0
3 files changed
Lines changed: 85 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
150 | 162 | | |
151 | 163 | | |
152 | 164 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
552 | 552 | | |
553 | 553 | | |
554 | 554 | | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
555 | 563 | | |
556 | 564 | | |
557 | 565 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | | - | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
399 | 400 | | |
400 | 401 | | |
401 | 402 | | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
0 commit comments