Keep DirectStorage source files alive for queued reads #518

Open
github-bot wants to merge 1 commit from github-bot/gh-518 into a-publier AGit
Owner

@⁠suren1013 on GitHub · 2026-11-27 08:08 UTC · original
suren1013:codex/dstorage-retain-source → a-publier · +103 −20 · 1 files · 1 commits · open

Guards against a title releasing a DirectStorage file right after it queues a read from it. Each queued read keeps its own reference to the source file until the read finishes or is discarded.

Two regression tests fail on the base commit and pass with this patch. In-game testing is pending.

**@⁠suren1013** on GitHub · 2026-11-27 08:08 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/518) `suren1013:codex/dstorage-retain-source` → `a-publier` · +103 −20 · 1 files · 1 commits · open Guards against a title releasing a DirectStorage file right after it queues a read from it. Each queued read keeps its own reference to the source file until the read finishes or is discarded. Two regression tests fail on the base commit and pass with this patch. In-game testing is pending.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 08:10:16 +00:00
Author
Owner

@⁠lvndrpup on GitHub · 2026-11-27 11:17 UTC · original · reviewed

Tested on an RTX 3060 Ti (Windows 11, debug build), base 4eb6cfd against head 444abaa.

base 4eb6cfd head 444abaa
queued_reads_keep_their_source_after_the_caller_releases_it, copied onto base fails: release returns 0, so the file is freed with its read still queued passes
closing_a_queue_releases_the_sources_of_unsubmitted_reads, copied onto base fails the same way passes
cargo test -p victory-hle --lib dstorage 21 passed, 1 ignored (the benchmark)
cargo clippy -p victory-hle --all-targets -- -D warnings, with and without --all-features clean

The fix is the right size. FILE_VTABLE has no Close of its own, so the reference count is the only thing keeping a file's handles open, and a queued read now holds one. The first test also checks that the read gives it back: remove_file succeeds only once the handles, opened without FILE_SHARE_DELETE, are closed. A rejected request takes no reference. A running job drops its own before finish writes the status, so the title never sees a read complete while that read still holds the file.

It merges cleanly with the other open PRs on dstorage.rs that still merge with a-publier (#525, #471, #461, #402, #375, #254).

The PR has no description. One line saying what it guards against (a title releasing a file right after it enqueues a read from it) would help whoever merges it.

**@⁠lvndrpup** on GitHub · 2026-11-27 11:17 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/518#pullrequestreview-6087334778) · **reviewed** Tested on an RTX 3060 Ti (Windows 11, debug build), base `4eb6cfd` against head `444abaa`. | | base `4eb6cfd` | head `444abaa` | |---|---|---| | `queued_reads_keep_their_source_after_the_caller_releases_it`, copied onto base | fails: `release` returns 0, so the file is freed with its read still queued | passes | | `closing_a_queue_releases_the_sources_of_unsubmitted_reads`, copied onto base | fails the same way | passes | | `cargo test -p victory-hle --lib dstorage` | | 21 passed, 1 ignored (the benchmark) | | `cargo clippy -p victory-hle --all-targets -- -D warnings`, with and without `--all-features` | | clean | The fix is the right size. `FILE_VTABLE` has no Close of its own, so the reference count is the only thing keeping a file's handles open, and a queued read now holds one. The first test also checks that the read gives it back: `remove_file` succeeds only once the handles, opened without `FILE_SHARE_DELETE`, are closed. A rejected request takes no reference. A running job drops its own before `finish` writes the status, so the title never sees a read complete while that read still holds the file. It merges cleanly with the other open PRs on `dstorage.rs` that still merge with `a-publier` (#525, #471, #461, #402, #375, #254). The PR has no description. One line saying what it guards against (a title releasing a file right after it enqueues a read from it) would help whoever merges it.
Author
Owner

@⁠MamaLeVrai on GitHub · 2026-11-27 11:40 UTC · original

Tested on an RX 6950 XT (RDNA 2), driver 32.0.21045.29003, Windows 11 build 26300, Rust 1.98.1, release. At 444abaa: victory-hle 165 passed, 0 failed, 2 ignored.

AI-assisted (Claude Code); no game data.

**@⁠MamaLeVrai** on GitHub · 2026-11-27 11:40 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/518#issuecomment-7217344056) Tested on an RX 6950 XT (RDNA 2), driver 32.0.21045.29003, Windows 11 build 26300, Rust 1.98.1, release. At `444abaa`: `victory-hle` 165 passed, 0 failed, 2 ignored. AI-assisted (Claude Code); no game data.
Author
Owner

@⁠suren1013 on GitHub · 2026-11-27 13:56 UTC · original

Tested on an RTX 3060 Ti (Windows 11, debug build), base 4eb6cfd against head 444abaa.

base 4eb6cfd head 444abaa
queued_reads_keep_their_source_after_the_caller_releases_it, copied onto base fails: release returns 0, so the file is freed with its read still queued passes
closing_a_queue_releases_the_sources_of_unsubmitted_reads, copied onto base fails the same way passes
cargo test -p victory-hle --lib dstorage 21 passed, 1 ignored (the benchmark)
cargo clippy -p victory-hle --all-targets -- -D warnings, with and without --all-features clean
The fix is the right size. FILE_VTABLE has no Close of its own, so the reference count is the only thing keeping a file's handles open, and a queued read now holds one. The first test also checks that the read gives it back: remove_file succeeds only once the handles, opened without FILE_SHARE_DELETE, are closed. A rejected request takes no reference. A running job drops its own before finish writes the status, so the title never sees a read complete while that read still holds the file.

It merges cleanly with the other open PRs on dstorage.rs that still merge with a-publier (#525, #471, #461, #402, #375, #254).

The PR has no description. One line saying what it guards against (a title releasing a file right after it enqueues a read from it) would help whoever merges it.

Thanks, I've added a description to the PR. Still unit tests only , not run in-game, so if anyone with a working dump can confirm the bug shows up in play, that would help.

**@⁠suren1013** on GitHub · 2026-11-27 13:56 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/518#issuecomment-7220123535) > Tested on an RTX 3060 Ti (Windows 11, debug build), base `4eb6cfd` against head `444abaa`. > > base `4eb6cfd` head `444abaa` > `queued_reads_keep_their_source_after_the_caller_releases_it`, copied onto base fails: `release` returns 0, so the file is freed with its read still queued passes > `closing_a_queue_releases_the_sources_of_unsubmitted_reads`, copied onto base fails the same way passes > `cargo test -p victory-hle --lib dstorage` 21 passed, 1 ignored (the benchmark) > `cargo clippy -p victory-hle --all-targets -- -D warnings`, with and without `--all-features` clean > The fix is the right size. `FILE_VTABLE` has no Close of its own, so the reference count is the only thing keeping a file's handles open, and a queued read now holds one. The first test also checks that the read gives it back: `remove_file` succeeds only once the handles, opened without `FILE_SHARE_DELETE`, are closed. A rejected request takes no reference. A running job drops its own before `finish` writes the status, so the title never sees a read complete while that read still holds the file. > > It merges cleanly with the other open PRs on `dstorage.rs` that still merge with `a-publier` ([#525](https://git.gtahub.st/github/Belobug--VIctory-Belobug-AMD/pulls/525), [#471](https://git.gtahub.st/github/Belobug--VIctory-Belobug-AMD/pulls/471), [#461](https://git.gtahub.st/github/Belobug--VIctory-Belobug-AMD/pulls/461), [#402](https://git.gtahub.st/github/Belobug--VIctory-Belobug-AMD/pulls/402), [#375](https://git.gtahub.st/github/Belobug--VIctory-Belobug-AMD/pulls/375), [#254](https://git.gtahub.st/github/Belobug--VIctory-Belobug-AMD/pulls/254)). > > The PR has no description. One line saying what it guards against (a title releasing a file right after it enqueues a read from it) would help whoever merges it. Thanks, I've added a description to the PR. Still unit tests only , not run in-game, so if anyone with a working dump can confirm the bug shows up in play, that would help.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/518/head:github-bot/gh-518'
git switch 'github-bot/gh-518'

Merge

Merge the changes and update on Forgejo.
git switch 'a-publier'
git merge --no-ff 'github-bot/gh-518'
git switch 'github-bot/gh-518'
git rebase 'a-publier'
git switch 'a-publier'
git merge --ff-only 'github-bot/gh-518'
git switch 'github-bot/gh-518'
git rebase 'a-publier'
git switch 'a-publier'
git merge --no-ff 'github-bot/gh-518'
git switch 'a-publier'
git merge --squash 'github-bot/gh-518'
git switch 'a-publier'
git merge --ff-only 'github-bot/gh-518'
git switch 'a-publier'
git merge 'github-bot/gh-518'
git push origin 'a-publier'
This discussion has been locked. Commenting is limited to contributors.
No description provided.