Repository navigation
Commit 3288834
virtiofs: keep node names when renaming a name onto itself
A guest rename of a name onto itself, in the same directory, succeeds
on the host without changing anything, as POSIX requires, but it
dropped the names at and below that name from every node of the volume
(microsoft/nvx#1610). A node that the guest knew only through them was
left with no names, so a microVM save then failed with "inode has no
bounded reopenable aliases", and a volume that deduplicates nodes by
path stopped finding it. A node with another hard link kept only the
other name, and once the guest removed that one, the node's requests
failed with ENOENT although the renamed name still reached its object.
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 one name, the first step drops the names that the second
should keep. The microVM alias preflight models the same steps.
A rename whose source and destination are one name now changes no
names and skips the preflight. It still reaches the host after the
same writability checks, so the host fails it as it fails any other
rename: with ENOENT for a missing name, and with EEXIST under
RENAME_NOREPLACE on Linux.
renaming_a_name_onto_itself_keeps_every_name, in virtiofs' microVM
exchange tests, which now cover a rename of a name onto itself too,
renames a directory with nodes below it, a file in it, and a file with
a second hard link each onto itself. It checks that every node keeps
exactly its names, that a snapshot taken right away saves and restores
them, and that the hard-linked file's node still reads the file once
the guest removes the other link; and that the host still fails a
missing name with ENOENT, and RENAME_NOREPLACE with EEXIST on Linux
and EINVAL on Windows. Without the fix, at feature/microvm/dev
b51f915, it fails on Windows and on Linux (Azure Linux 3.0,
nvx-mshv-test), where the renamed directory's node has no names left;
with the fix, it and the package's other tests pass there.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent b51f915 commit 3288834
2 files changed
Lines changed: 92 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
533 | 533 | | |
534 | 534 | | |
535 | 535 | | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
536 | 544 | | |
537 | 545 | | |
538 | 546 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | | - | |
6 | | - | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
37 | 42 | | |
38 | 43 | | |
39 | 44 | | |
| |||
318 | 323 | | |
319 | 324 | | |
320 | 325 | | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
0 commit comments