repoobj, repository: add chunk_id to header, introduce packs/ namespace#9692
Open
mr-raj12 wants to merge 7 commits into
Open
repoobj, repository: add chunk_id to header, introduce packs/ namespace#9692mr-raj12 wants to merge 7 commits into
mr-raj12 wants to merge 7 commits into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #9692 +/- ##
==========================================
- Coverage 83.88% 82.81% -1.07%
==========================================
Files 93 93
Lines 15653 15658 +5
Branches 2351 2351
==========================================
- Hits 13130 12967 -163
- Misses 1789 1974 +185
+ Partials 734 717 -17 ☔ View full report in Codecov by Sentry. |
ThomasWaldmann
requested changes
May 31, 2026
Member
|
"The pack filename is the chunk's SHA-256 hex ID." That is never true. For N=1 the pack filename (pack_id) is the chunk_id (id_hash(chunk content), usually not sha256). For N>1 the pack filename (pack_id) shall be sha256(pack content). |
75eea8d to
f1833e8
Compare
192a412 to
5e13bda
Compare
…ckup#8572 Stores chunk_id unencrypted in the per-blob header so borg check can rebuild the chunk_id -> pack location index without decryption. AEAD uses chunk_id as additional data, making key-free recovery circular without an explicit plaintext copy. Header layout: OBJ_MAGIC(8) + version(1) + chunk_id(32) + meta_size(4) + data_size(4) = REPOOBJ_HEADER_SIZE = 49 bytes.
…orgbackup#8572 Introduces pack_id as the borgstore storage key (N=1: pack_id == chunk_id). Chunks move from data/ to packs/ with single-level directory sharding (256 subdirs). check_object() validates the header chunk_id against the pack filename. Adds packs/ to ns_config with levels=[1] and to the permissions maps for no-delete and write-only modes.
…rgbackup#8572 Wrap each pack file in a 13-byte header (magic + version + blob_len) so packs are self-identifying and the [len][blob] unit extends to N>1 without a format revision. Bump version 3->4: packs/ and 49-byte ObjHeader are incompatible with version-3 readers. Fix test_extra_chunks chunk_id mismatch.
_common.py had a hard-coded version check that only allowed v3. Now that repository.py creates v4 repos, every archiver command failed to open the repo. Extend the guard to (3, 4). The --other-repo check (v1 or v3 for borg transfer source) is intentionally left unchanged.
…rror in error message
…efs borgbackup#8572 accept only repo version 4
5e13bda to
b6c075d
Compare
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.
Description
RepoObjblob header grows from 17 bytes (<8sBII) to 49 bytes (<8sB32sII): a 32-bytechunk_idfield between the version byte and the size fields.REPOOBJ_HEADER_SIZE = 49names the fixed part.chunk_idis the ID hash of the plaintext data. Putting it in the unencrypted header lets a forward scanner rebuild thechunk_id -> locationindex without touching the key. It is also the additional authenticated data for AEAD, so a plaintext copy in the header is unavoidable -- recovering it from ciphertext requires the key.Chunks move from
data/topacks/. The new namespace uses one directory level keyed on the first byte of the pack ID (256 subdirs00/..ff/), versus two levels fordata/. For the expected object count per pack, one level is enough.For N=1 packs (one chunk per pack file),
pack_id == chunk_id. The pack filename is the chunk ID (id_hashof the plaintext chunk content).Changes:
repoobj.py: extend struct from<8sBIIto<8sB32sII, addchunk_idtoObjHeader, addREPOOBJ_HEADER_SIZE = 49, passidintoObjHeaderinformat().repository.py: addpacks/tons_configwith{"levels": [1]}, add packs to permission maps, replace alldata/keys withpacks/inget()/put()/delete()/list()/check(), introducepack_id = id(N=1 invariant), wrap stored blobs in a BORGPACK header (13 bytes: magic + version + blob_len), bump repo version to 4.repository_test.py: addchunk_idparameter tofchunk(), fixpchunk()slice to[3:5], updatetest_read_data()to passH(0)aschunk_id.refs #8572
Checklist
master(or maintenance branch if only applicable there)toxor the relevant test subset)