Skip to content

Commit

Permalink
external/android-tools: fix f2fs images building
Browse files Browse the repository at this point in the history
Change-Id: Ia9e22f101d4c5d35a936653cc4e67bf754996791
  • Loading branch information
salvogiangri committed Feb 11, 2025
1 parent 21c71ba commit 7f1dad9
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
From 562ea9bc565cafbf550c48bc660ecf3aa00b4ddc Mon Sep 17 00:00:00 2001
From: Salvo Giangreco <giangrecosalvo9@gmail.com>
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

1 change: 1 addition & 0 deletions scripts/build_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 ..
Expand Down
2 changes: 1 addition & 1 deletion scripts/cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 -
Expand Down

0 comments on commit 7f1dad9

Please sign in to comment.