From 7f1dad956d08736bf1a8d429e2a7ebb88358d6a7 Mon Sep 17 00:00:00 2001 From: Salvo Giangreco Date: Tue, 11 Feb 2025 15:28:56 +0100 Subject: [PATCH] external/android-tools: fix f2fs images building Change-Id: Ia9e22f101d4c5d35a936653cc4e67bf754996791 --- ...s-give-6-sections-for-overprovision-.patch | 63 +++++++++++++++++++ scripts/build_dependencies.sh | 1 + scripts/cleanup.sh | 2 +- 3 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 external/patches/android-tools/0001-Revert-f2fs-tools-give-6-sections-for-overprovision-.patch diff --git a/external/patches/android-tools/0001-Revert-f2fs-tools-give-6-sections-for-overprovision-.patch b/external/patches/android-tools/0001-Revert-f2fs-tools-give-6-sections-for-overprovision-.patch new file mode 100644 index 000000000..fb2e814ad --- /dev/null +++ b/external/patches/android-tools/0001-Revert-f2fs-tools-give-6-sections-for-overprovision-.patch @@ -0,0 +1,63 @@ +From 562ea9bc565cafbf550c48bc660ecf3aa00b4ddc Mon Sep 17 00:00:00 2001 +From: Salvo Giangreco +Date: Tue, 11 Feb 2025 15:14:15 +0100 +Subject: [PATCH] Revert "f2fs-tools: give 6 sections for overprovision buffer" + +This reverts commit 5da4e5241503b385e4a7e75b1b2bb3367b38be96. +--- + include/f2fs_fs.h | 8 +------- + mkfs/f2fs_format.c | 5 ++--- + 2 files changed, 3 insertions(+), 10 deletions(-) + +diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h +index 870a6e4..fc56396 100644 +--- a/include/f2fs_fs.h ++++ b/include/f2fs_fs.h +@@ -1775,12 +1775,6 @@ static inline uint32_t get_reserved(struct f2fs_super_block *sb, double ovp) + return round_up(reserved, segs_per_sec) * segs_per_sec; + } + +-static inline uint32_t overprovision_segment_buffer(struct f2fs_super_block *sb) +-{ +- /* Give 6 current sections to avoid huge GC overheads. */ +- return 6 * get_sb(segs_per_sec); +-} +- + static inline double get_best_overprovision(struct f2fs_super_block *sb) + { + double ovp, candidate, end, diff, space; +@@ -1804,7 +1798,7 @@ static inline double get_best_overprovision(struct f2fs_super_block *sb) + if (ovp < 0) + continue; + space = usable_main_segs - max((double)reserved, ovp) - +- overprovision_segment_buffer(sb); ++ 2 * get_sb(segs_per_sec); + if (max_space < space) { + max_space = space; + max_ovp = candidate; +diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c +index c9d335a..9e1b0d6 100644 +--- a/mkfs/f2fs_format.c ++++ b/mkfs/f2fs_format.c +@@ -779,8 +779,7 @@ static int f2fs_write_check_point_pack(void) + * In non configurable reserved section case, overprovision + * segments are always bigger than two sections. + */ +- if (get_cp(overprov_segment_count) < +- overprovision_segment_buffer(sb)) { ++ if (get_cp(overprov_segment_count) < 2 * get_sb(segs_per_sec)) { + MSG(0, "\tError: Not enough overprovision segments (%u)\n", + get_cp(overprov_segment_count)); + goto free_cp_payload; +@@ -789,7 +788,7 @@ static int f2fs_write_check_point_pack(void) + get_cp(rsvd_segment_count)); + } else { + set_cp(overprov_segment_count, get_cp(overprov_segment_count) + +- overprovision_segment_buffer(sb)); ++ 2 * get_sb(segs_per_sec)); + } + + if (f2fs_get_usable_segments(sb) <= get_cp(overprov_segment_count)) { +-- +2.48.1 + diff --git a/scripts/build_dependencies.sh b/scripts/build_dependencies.sh index bbd0ed5a9..a91a829d0 100755 --- a/scripts/build_dependencies.sh +++ b/scripts/build_dependencies.sh @@ -54,6 +54,7 @@ BUILD_ANDROID_TOOLS() -DANDROID_TOOLS_USE_BUNDLED_FMT=ON \ -DANDROID_TOOLS_USE_BUNDLED_LIBUSB=ON \ .. + git -C "../vendor/f2fs-tools" apply "$SRC_DIR/external/patches/android-tools/0001-Revert-f2fs-tools-give-6-sections-for-overprovision-.patch" make -j"$JOBS" --quiet find "vendor" -maxdepth 1 -type f -exec test -x {} \; -exec cp --preserve=all {} "$TOOLS_DIR" \; cd .. diff --git a/scripts/cleanup.sh b/scripts/cleanup.sh index f47a2921d..85c8b9714 100755 --- a/scripts/cleanup.sh +++ b/scripts/cleanup.sh @@ -97,7 +97,7 @@ if $TOOLS; then echo "- Cleaning dependencies dir..." rm -rf "$(dirname "$TOOLS_DIR")" { - cd "$SRC_DIR/external/android-tools" && git clean -f -d -x && cd - + cd "$SRC_DIR/external/android-tools" && git clean -f -d -x && git -C "./vendor/f2fs-tools" checkout . && cd - cd "$SRC_DIR/external/apktool" && git clean -f -d -x && git checkout . && cd - cd "$SRC_DIR/external/erofs-utils" && git clean -f -d -x && cd - cd "$SRC_DIR/external/samfirm.js" && git clean -f -d -x && cd -