From d041e1e4c64f61664266fc10758cd9c5366fa6fa Mon Sep 17 00:00:00 2001 From: Adam Lesinski Date: Mon, 24 Aug 2026 16:21:20 -0700 Subject: [PATCH] fix(mkfs): reserve correct htree checksum tail --- .github/workflows/cmake.yml | 9 ++++++++- CMake/Finde2fs.cmake | 2 ++ .../patches/e2fsprogs-fix-htree-root-limit.patch | 16 ++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 CMake/patches/e2fsprogs-fix-htree-root-limit.patch diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index d473ca7e..45cf75ef 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -87,6 +87,13 @@ jobs: ls obd_mp sudo diff -r --exclude "lost+found" test_data obd_mp sudo umount obd_mp + mkdir -p htree_data/crowded + for i in $(seq 1 1000); do touch "htree_data/crowded/file-${i}"; done + tar -cf htree.tar -C htree_data . + truncate -s 1g htree.img + /opt/overlaybd/bin/overlaybd-apply --mkfs --raw htree.tar htree.img + sudo e2fsck -fn htree.img 2>&1 | tee htree-e2fsck.log || true + ! grep -F "invalid limit (506)" htree-e2fsck.log - name: E2E Test turboOCIv1 working-directory: ${{github.workspace}}/build shell: bash @@ -124,4 +131,4 @@ jobs: uses: namespacelabs/breakpoint-action@v0 with: duration: 30m - authorized-users: dines-rl \ No newline at end of file + authorized-users: dines-rl diff --git a/CMake/Finde2fs.cmake b/CMake/Finde2fs.cmake index 15c58fda..a89cf8ba 100644 --- a/CMake/Finde2fs.cmake +++ b/CMake/Finde2fs.cmake @@ -1,10 +1,12 @@ if(NOT ORIGIN_EXT2FS) message("Add and build standalone libext2fs") include(FetchContent) + set(_e2fsprogs_htree_patch "${CMAKE_CURRENT_LIST_DIR}/patches/e2fsprogs-fix-htree-root-limit.patch") FetchContent_Declare( e2fsprogs GIT_REPOSITORY https://github.com/data-accelerator/e2fsprogs.git GIT_TAG b4cf6c751196a12b1df9a269d8e0b516b99fe6a7 + PATCH_COMMAND sh -c "git apply --reverse --check '${_e2fsprogs_htree_patch}' 2>/dev/null || git apply '${_e2fsprogs_htree_patch}'" ) FetchContent_GetProperties(e2fsprogs) diff --git a/CMake/patches/e2fsprogs-fix-htree-root-limit.patch b/CMake/patches/e2fsprogs-fix-htree-root-limit.patch new file mode 100644 index 00000000..414ae855 --- /dev/null +++ b/CMake/patches/e2fsprogs-fix-htree-root-limit.patch @@ -0,0 +1,16 @@ +diff --git a/lib/ext2fs/expanddir.c b/lib/ext2fs/expanddir.c +index 898a362c..d86d695e 100644 +--- a/lib/ext2fs/expanddir.c ++++ b/lib/ext2fs/expanddir.c +@@ -185,7 +185,10 @@ static errcode_t make_indexed_dir(ext2_filsys fs, ext2_ino_t dir, struct ext2_i + entries = root->entries; + entries->block = ext2fs_cpu_to_le32(1); + ((struct ext2_dx_countlimit *) entries)->count = ext2fs_cpu_to_le16(1); +- ((struct ext2_dx_countlimit *) entries)->limit = ext2fs_cpu_to_le16((blocksize - (32 + csum_size)) / sizeof(struct ext2_dx_entry)); ++ ((struct ext2_dx_countlimit *) entries)->limit = ext2fs_cpu_to_le16( ++ (blocksize - 32 - ++ (csum_size ? sizeof(struct ext2_dx_tail) : 0)) / ++ sizeof(struct ext2_dx_entry)); + + /* write out blocks */ + for (int i = 0; i < dx_info.levels; i++)