HLE: honor available disk space in storage prompts #3188

Open
andrewpozdnakov7-jpg wants to merge 1 commit from upstream-pr/3190 into main
andrewpozdnakov7-jpg commented 2026-11-26 11:31:38 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-26T11:31:38Z.


Problem

The persistent local storage prompt completes immediately. It currently compares the request with the remaining quota, even when the storage query says the host disk can supply fewer bytes. A title can receive S_OK and then retry an operation with the same insufficient space.

Use the available_free value already calculated by the storage query. This accounts for both the remaining quota and the host disk's free space. GDK space information

Verification

On 63bcca43, the same synthetic fixture requests 301 bytes with 300 available and 900 remaining in the quota. The async status and result both return S_OK on main. Both return E_ABORT with the change. Requests of zero bytes or exactly 300 bytes still succeed. The fixture also covers quota-limited and maximum-size requests.

cargo test --locked -p victory-hle --lib modules::storage::tests::prompt_rejects_space_the_host_cannot_supply -- --exact --nocapture

Full HLE library tests with default features and diagnostics, strict HLE Clippy in both configurations, and the repository asset policy passed. The disk capacity is synthetic so the test can run on any host volume.

Coordination claim

AI-assisted with Codex.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5509246984 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3190). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-26T11:31:38Z. --- ## Problem The persistent local storage prompt completes immediately. It currently compares the request with the remaining quota, even when the storage query says the host disk can supply fewer bytes. A title can receive `S_OK` and then retry an operation with the same insufficient space. Use the `available_free` value already calculated by the storage query. This accounts for both the remaining quota and the host disk's free space. [GDK space information](https://learn.microsoft.com/en-us/gaming/gdk/docs/reference/system/xpersistentlocalstorage/structs/xpersistentlocalstoragespaceinfo) ## Verification On `63bcca43`, the same synthetic fixture requests **301 bytes** with **300 available** and **900 remaining in the quota**. The async status and result both return `S_OK` on main. Both return `E_ABORT` with the change. Requests of zero bytes or exactly 300 bytes still succeed. The fixture also covers quota-limited and maximum-size requests. ```powershell cargo test --locked -p victory-hle --lib modules::storage::tests::prompt_rejects_space_the_host_cannot_supply -- --exact --nocapture ``` Full HLE library tests with default features and diagnostics, strict HLE Clippy in both configurations, and the repository asset policy passed. The disk capacity is synthetic so the test can run on any host volume. [Coordination claim](https://github.com/Marvisak/VIctory/issues/1633#issuecomment-7190686722) AI-assisted with Codex.
AurumCarlos commented 2026-11-26 12:07:33 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by AurumCarlos on 2026-11-26T12:07:33Z.

Review: COMMENTED


Looks good to me. I read it together with space() and xasync::finished:

  • The fix: space() already builds available_free as free.min(disk_free(..)), so the prompt now uses the same "writable now" figure that space_info reports at 0x28. A title that checks the space and then prompts gets a consistent answer. When the disk isn't the limit, available_free == total_free, so nothing changes in that case. On non-Windows hosts disk_free returns u64::MAX, so behaviour there is unchanged too.
  • Split into finish_space_prompt: passing SpaceInfo in is a nice way to test the disk-limited case without needing a full disk. The test drives the same path the vtable entry does (finished → XAsyncGetStatus → prompt_result).
  • Rows: (disk_limited, 301) and (disk_limited, 900) are the ones that flip from S_OK to E_ABORT with this change. The quota_limited rows pass on main as well, since there available_free == total_free. They're fine as guards for the quota limit, but a short comment saying so would make it clear they aren't part of the regression.

One nit: the old doc comment on prompt_for_space explained why it completes immediately ("There is nobody to ask"), and the new one drops that. Maybe keep both parts, e.g.:

/// There is nobody to ask: granted when the title can write that much now
/// (the quota's rest, as far as the host disk allows), else declined.
<!-- greyfinch-sync:Marvisak/VIctory:review:6073861520 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3190#pullrequestreview-6073861520). Originally posted by [AurumCarlos](https://github.com/AurumCarlos) on 2026-11-26T12:07:33Z. **Review:** COMMENTED --- Looks good to me. I read it together with `space()` and `xasync::finished`: - **The fix**: `space()` already builds `available_free` as `free.min(disk_free(..))`, so the prompt now uses the same "writable now" figure that `space_info` reports at 0x28. A title that checks the space and then prompts gets a consistent answer. When the disk isn't the limit, `available_free == total_free`, so nothing changes in that case. On non-Windows hosts `disk_free` returns `u64::MAX`, so behaviour there is unchanged too. - **Split into `finish_space_prompt`**: passing `SpaceInfo` in is a nice way to test the disk-limited case without needing a full disk. The test drives the same path the vtable entry does (`finished` → `XAsyncGetStatus` → `prompt_result`). - **Rows**: `(disk_limited, 301)` and `(disk_limited, 900)` are the ones that flip from `S_OK` to `E_ABORT` with this change. The `quota_limited` rows pass on `main` as well, since there `available_free == total_free`. They're fine as guards for the quota limit, but a short comment saying so would make it clear they aren't part of the regression. One nit: the old doc comment on `prompt_for_space` explained *why* it completes immediately ("There is nobody to ask"), and the new one drops that. Maybe keep both parts, e.g.: ```rust /// There is nobody to ask: granted when the title can write that much now /// (the quota's rest, as far as the host disk allows), else declined. ```
cloph-dsp commented 2026-11-26 13:04:25 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-26T12:12:00Z.


Independent local verification of head 4f06549 on Windows 11, Rust 1.100.0/MSVC:

  • cargo test --locked -p victory-hle --lib -- --exact modules::storage::tests::prompt_rejects_space_the_host_cannot_supply — 1 passed, 0 failed.
  • git diff --check origin/main HEAD — clean.

Used a worktree-local CARGO_TARGET_DIR to avoid stale shared-target binaries. Synthetic SpaceInfo/AsyncBlock inputs only; no game assets or DRM material used. AI-assisted (Hy4 flash).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7191693823 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3190#issuecomment-7191693823). Originally posted by [cloph-dsp](https://github.com/cloph-dsp) on 2026-11-26T12:12:00Z. --- Independent local verification of head `4f06549` on Windows 11, Rust 1.100.0/MSVC: - `cargo test --locked -p victory-hle --lib -- --exact modules::storage::tests::prompt_rejects_space_the_host_cannot_supply` — 1 passed, 0 failed. - `git diff --check origin/main HEAD` — clean. Used a worktree-local `CARGO_TARGET_DIR` to avoid stale shared-target binaries. Synthetic `SpaceInfo`/`AsyncBlock` inputs only; no game assets or DRM material used. AI-assisted (Hy4 flash).
futurepro62 commented 2026-11-27 22:22:41 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by futurepro62 on 2026-11-27T22:22:41Z.


NVIDIA full-suite run, to go with the reports above by cloph-dsp, since none of them names a GPU run. Tested exact head 4f06549 (on its base 63bcca4).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), dxil.dll from Windows SDK 10.0.26100 (the loader's default), debug.
  • cargo build --workspace --locked, then cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 867 passed, 0 failed, 10 ignored.
  • The new tests ran and passed: prompt_rejects_space_the_host_cannot_supply.
  • --skip leaves out tests that fail on main 63bcca4 on this card too, not because of this PR: heap_direct_texture_reads_mark_their_heap_index ends the victory-shader test process with 0xc0000005 (#2571), so without the skip the rest of that crate never reports; dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views and the two stride_tests hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); gathers_at_a_level_match_the_hardware fails on lane 0 (#1744).

Not tested

  • AMD (the tests take the default adapter), a release build, the title (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7229276857 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3190#issuecomment-7229276857). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-27T22:22:41Z. --- NVIDIA full-suite run, to go with the reports above by cloph-dsp, since none of them names a GPU run. Tested exact head `4f06549` (on its base `63bcca4`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), `dxil.dll` from Windows SDK 10.0.26100 (the loader's default), debug. - `cargo build --workspace --locked`, then `cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware`: **867 passed, 0 failed, 10 ignored**. - The new tests ran and passed: `prompt_rejects_space_the_host_cannot_supply`. - `--skip` leaves out tests that fail on main `63bcca4` on this card too, not because of this PR: `heap_direct_texture_reads_mark_their_heap_index` ends the `victory-shader` test process with `0xc0000005` (#2571), so without the skip the rest of that crate never reports; `dynamic_slots_are_held_until_released`, `lists_share_a_table_and_copies_keep_their_views` and the two `stride_tests` hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); `gathers_at_a_level_match_the_hardware` fails on lane 0 (#1744). **Not tested** - AMD (the tests take the default adapter), a release build, the title (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3190:upstream-pr/3190'
git switch 'upstream-pr/3190'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3190'
git switch 'upstream-pr/3190'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3190'
git switch 'upstream-pr/3190'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3190'
git switch 'main'
git merge --squash 'upstream-pr/3190'
git switch 'main'
git merge --ff-only 'upstream-pr/3190'
git switch 'main'
git merge 'upstream-pr/3190'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Marvisak/VIctory!3188
No description provided.