Repository navigation
fix(libSceSaveData.native): count PS5 save data in 64 KiB blocks, at most 16384 - #7960
Merged
oneandonlydean merged 1 commit intoOct 20, 2026
Merged
Conversation
…most 16384 The PS5 references count save data differently from the PS4: SharpEmu uses a 64 KiB block, and SharpEmu and KytyPS5 allow 48 to 16384 blocks per save, which at 64 KiB a block is 3 MiB to 1 GiB, the PS4's byte range. The module used the PS4 values, 32 KiB blocks and a 32768-block maximum. At 64 KiB a block, sceSaveDataDirNameSearch and sceSaveDataGetMountInfo therefore counted up to twice the blocks a save's files use, and a save without a recorded size reported 32768 blocks, which is 2 GiB. The search test now expects 64 KiB blocks and the 16384 maximum, and the block accounting gets its own technical debt entry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
libSceSaveData.nativecounts save data in PS4 units.SAVE_DATA_BLOCK_BYTESis 32768 andSAVE_DATA_BLOCKS_MAXis 32768: the PS4's 32 KiB block and the top of its 96 to 32768-block range (shadPS4savedata.cpp). SharpEmu uses a 64 KiB block, and SharpEmu and KytyPS5 allow 48 to 16384 blocks per save, which at 64 KiB a block is 3 MiB to 1 GiB, the PS4's byte range:SaveDataExports.cssets 65536, 16384 and 48, and counts used blocks in 64 KiB. It rounds the save's total size once, while this module rounds each file.libSaveData.cppsets 48 and 16384, and itssceSaveDataMount3rejects a creating mount outside that range. It has no block size and reports all of a save's blocks as free, so the 64 KiB block comes from SharpEmu alone.On
main, thesceSaveDataDirNameSearchinfos andsceSaveDataGetMountInfotherefore count up to twice the 64 KiB blocks a save's files use. A save without a recorded size reports 32768 blocks, which is 2 GiB at 64 KiB a block. A scratch program run againstmain5eba12d creates a save withsceSaveDataMount3(blocks48, mode0x21), writes a 1,000,000-byte file, unmounts and searches. The search returnsblocks=48 free=17, so 31 blocks are used. With 64 KiB blocks the file takes 16 and leaves 32 free.Titles read these counts as 64 KiB blocks:
blocks - free_blocksandfree_blocksback to bytes at 65536 bytes a block. For the save above, that gives 2,031,616 used and 1,114,112 free bytes onmain, and 1,048,576 and 2,097,152 with this change. What the title does with the two byte counts was not traced. It still shows only a flat grey screen (feat(libs): add the Voice and IME exports PPSA24191 needs to load #7852), so no visible effect is known.blocksas 64 KiB each. fix(libSceSaveData.native): report a directory's own block count and free blocks #5173 read this out of the title with gdb: five saves at the 32768-block maximum summed to 10 GiB against a 9 GiB budget.This change:
SAVE_DATA_BLOCK_BYTESto 65536 andSAVE_DATA_BLOCKS_MAXto 16384. Each file is rounded up to 64 KiB blocks, and a save without a recorded size reports 16384.blocksabove 16384 is now kept as 16384 (the existing clamp was at 32768), as SharpEmu clamps it. A save already recorded above 16384 now reports 16384.sceSaveDataDirNameSearchdebt entry into its own entry forsceSaveDataDirNameSearch,sceSaveDataGetMountInfoandsceSaveDataMount3, which states the gaps first. Both entries stay under 1000 characters.Not measured on a console. The console's file system overhead is not counted. A
blocksabove 16384 is clamped to 16384 and a non-zero one below 48 is kept as given, where KytyPS5 rejects such a creating mount; what the console does is unknown.Interplay with #7780 (open): it builds
libSceSaveData, which PS4 titles import, from these sources. With both merged, that module would also count 64 KiB blocks up to 16384, while PS4 saves use 32 KiB blocks up to 32768 (shadPS4 above;SD_BLOCKS_MAXis 32768 in theSaveDataCore.hppthat #7780 removes). OnmainonlylibSceSaveData.nativeis built from these sources, so the values stay constants in the module. Whichever of the two merges second can give the PS4 target its own values, for example as compile definitions set in #7780'sSaveDataLibrary.cmake. #6977 (open) adds a PS4sceSaveDataMountto this module itself, and it passes the title'sblocks, counted in 32 KiB, tosceSaveDataMount3unchanged. With this change those would be read as 64 KiB blocks.Tested
Gentoo Linux, kernel 7.2.8, GCC 16.2.1, glibc 2.43, Ninja, Release,
BUILD_TESTING=ON, onmaind047690.guest_savedata_search(core/libs/tests/GuestSaveDataSearch.cpp) now checks:sceSaveDataGetMountInfo(was 94).MountInfohelper that the new checks share.Export.cppandSaveData.hppfrommain, the test fails withsearch info must report the save's blocks and free blocks. In a scratch copy of the test,Requirereports and continues. That copy shows each of the 5 changed or new assertions failing on themainsources and every other assertion passing.Export.cppfrommain, the test fails witha save must report the blocks it was created with, less those its files take. The mount-info and 64 KiB checks fail too.SaveData.hppfrommain, it fails at the unsized-save check, and the 16384 check fails too.blocks=48 free=32.tools/select_tests.pyas CI selects them: 219 passed, 0 failed, 0 skipped. They include the sixguest_savedata_*tests oflibSceSaveData.native, the foursavedata_memory_*tests,savedata_native_write_replacementandpatched_libraries.tools/check_compile.py --base upstream/main: 2 translation units compile.Export.cppandGuestSaveDataSearch.cppcompile without warnings withx86_64-w64-mingw32-g++16.2.0-fsyntax-only -Wall -Wextra, as onmain. This is a syntax check, not a Windows build or run.tools/check_conventions.py --base upstream/mainwith this title and body: all checks passed.tools/pr_overlap.py --branchreports no overlapping lines. It could not compare test: organize library tests and label CTest suites #6044, feat(wasm): run relinked titles in the browser with WebGPU #6879 and feat: run PS4 games on the AGC driver — Limbo (CUSA01664) in game (integration branch) #6977, which conflict withmain; merged with this branch, feat(wasm): run relinked titles in the browser with WebGPU #6879 and feat: run PS4 games on the AGC driver — Limbo (CUSA01664) in game (integration branch) #6977 conflict in the same files as they do withmain, and fix(savedata): build libSceSaveData and libSceSaveDataDialog from the native sources #7780 merges cleanly.Not run on Windows, macOS or a console.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code