Repository navigation
Conversation
oni-swr
left a comment
There was a problem hiding this comment.
Review of #543 at d2e70ef, as promised on #324. I read the whole diff.
The logic is right as far as I can see. On a failure, the temps already moved into place are undone in the order they were placed, then the files moved aside go back. A failure while moving files aside only restores them. Comparing names case-insensitively for ASCII only is enough: enc escapes every non-ASCII byte, so names that differ in non-ASCII case are different files anyway.
Tested: merged onto main 9aec53d (clean), cargo test -p xcl --lib -- hle::xgameruntime::gamesave::: 11 passed, 0 failed. RX 7800 XT, Ryzen 7 5700X3D, Windows 11 Pro 26200, Rust 1.100.0 MSVC, debug. Not run: the whole suite or a smoke pair (yours stand).
Two points, neither blocking:
- The crash window lordon1a described. Every blob is moved aside before any temp is placed, so the window covers the whole update. During it, a blob exists only under a
~xcltmp.*name, whichblobs_ofskips. A title crashing on another thread can end the process mid-save, so this isn't only a power-loss case. One fix per blob: hard-link the old file to the backup name (copy if links fail), thenMoveFileExW(temp, dest, REPLACE_EXISTING)asmaindoes. Thendestalways holds the old or the new contents, and rollback is stillreplace_file(backup, dest). My closed branch does this and passes the 11 gamesave tests. I can send it as a follow-up after this merges, or you take it, your call. - A failed restore is silent. If
replace_file(away, dest)fails during rollback, the old blob stays under a temp name and the title sees it as deleted, with nothing in the log. A log line there would make it findable.
Once it's out of draft I'd merge it as is; #491 then duplicates it. Closing my branch.
AI use: Claude Code (Claude Opus 5.5) read the diff and ran the tests; I checked each point.
`apply` wrote the display name and then each blob in turn, each replaced atomically on its own. When a write failed partway it returned E_FAIL, but the display name and the blobs before it were already replaced: a title that writes a header blob and a data blob in one update was left with the new header and the old data after any write error. The GDK says an update succeeds or fails as a whole. Every write now goes to a temp file first; then the files the update replaces or deletes are moved aside and the temps moved into place; a failure anywhere puts the files moved aside back and removes the temps. Only the last op on a blob counts, as it did when the ops ran in order, with names compared without case (one file on NTFS). Fixes ivall#324. Not covered: a crash between moving the files aside and placing the temps leaves the old blobs under their `~xcltmp.*` names, which enumeration skips; recovering those on open would be a change of its own. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
d2e70ef to
897f5ef
Compare
|
@oni-swr thank you for the review and the run. Taken as follows:
Marked ready for review. AI use: Claude Code (Claude Fable 5.1) wrote the change and this reply; the run was mine. |
|
Test report for Tested
Not tested
AI use: Claude Code (Claude Opus 5.5) ran the commands and wrote this report; I checked it before posting. |
|
Tested
Not tested
AI use OpenAI Codex (GPT-6, exact variant not exposed in this session) reviewed the exact diff, ran the GameSave suite and build, checked the logs, and drafted this report. |
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
applyingamesave.rswrote an update's display name and then each blob in turn, each replaced atomically on its own. When one write failed partway it returnedE_FAIL, but the display name and every blob before the failing one were already replaced, so a title that writes a header blob and a data blob in one update was left with the new header and the old data after any write error (disk full, a path over the limit, a locked file). The GDK documentsXGameSaveSubmitUpdateas all or nothing. Fixes #324.What is in it
crates/xcl/src/hle/xgameruntime/gamesave.rs:write_atomicbecomestemp_path/write_temp(temp file written and flushed); the move into place isapply's.applywrites every temp first, then moves the files the update replaces or deletes aside and the temps into place; a failure anywhere moves the files back and removes the temps, so the container stays as it was. Only the last op on a blob name counts, as when the ops ran in order (write then delete deletes; delete then write writes), with names compared without case, sinceMetaandMETAare one file on NTFS (oni-swr's point on the issue). A restore that fails during the rollback logs the blob and the backup it is left under (oni-swr's review). A new test,a_failed_update_leaves_the_container_as_it_was: an update whose second blob cannot be written (a folder is in its place) returnsE_FAILand leaves the first blob, the display name and the folder free of temp files; then write-then-delete, delete-then-write and writeMeta/ deleteMETAin one update.Opened at oni-swr's request after they claimed the issue (their review and branch: see #324). #491 covers the same issue with the staged writes only (no rollback of a rename that fails, and ops are not folded).
Tested
stable-x86_64-pc-windows-msvc, debug (release for the regression run); DXC 1.9.2602.17.main'sapply): fails at the first check after the failed update, blobareads"new"instead of"old"(left: [110, 101, 119], right: [111, 108, 100]).cargo test -p xcl --lib -- hle::xgameruntime::gamesave::: 11 passed, 0 failed (the existingatomic_writes_preserve_xcltmp_blobs_and_skip_leftover_tempsnow checks the temp cleanup throughapply)..\scripts\test.ps1(cargo build --workspace+cargo test --workspace -- --test-threads=4) withXCL_REQUIRE_GPU=wave64,mesh: 677 passed, 0 failed, 41 ignored, 0 SKIPPED (lib 637 / 0 / 21); no new compiler warning.Regression run
scripts/smoke.ps1 -Game <folder>on a retail title, release builds, no uncommitted changes, one after the other on the machine above (a warm-up run ofmainfirst, not shown). Both blocks unedited.main2997c9a:this PR's head
897f5ef:Not tested
~xcltmp.*names, which enumeration skips, where before the same crash left a half-applied but visible container. The window is a few renames long; a recovery pass on open would be a change of its own.AI use
🤖 Generated with Claude Code