summaryrefslogtreecommitdiff
path: root/checkpoint_gc
diff options
context:
space:
mode:
authorDaniel Rosenberg <drosen@google.com>2019-03-22 16:01:10 -0700
committerDaniel Rosenberg <drosen@google.com>2019-03-25 14:58:46 -0700
commitdfae9c448d14fe4015c25eed5cb209d855e38b98 (patch)
treea358e1152f4a4f89183dac39ea3f1b299400502b /checkpoint_gc
parenta3cec0985a0df8a01a2a1ca143ba6aa035536d2c (diff)
downloadextras-dfae9c448d14fe4015c25eed5cb209d855e38b98.tar.gz
Change checkpoint_gc to run until threshold is met
Run until garbage collection is done to prevent long boot times while f2fs checkpointing runs garbage collection Test: Apply update, or run /vendor/bin/checkpoint_gc UNUSED 1 Bug: 123367711 Change-Id: I4481b9179a819621dd77f5088778950e49d73ff3
Diffstat (limited to 'checkpoint_gc')
-rw-r--r--checkpoint_gc/checkpoint_gc.sh24
1 files changed, 14 insertions, 10 deletions
diff --git a/checkpoint_gc/checkpoint_gc.sh b/checkpoint_gc/checkpoint_gc.sh
index bf86e214..d5f7ab40 100644
--- a/checkpoint_gc/checkpoint_gc.sh
+++ b/checkpoint_gc/checkpoint_gc.sh
@@ -23,9 +23,10 @@
# TARGET_SLOT="${1}"
STATUS_FD="${2}"
-GC_TIME=120
DIRTY_SEGMENTS_THRESHOLD=100
+SLEEP=5
+
NAME=`while read dev dir type opt; do
if [ /data = ${dir} -a f2fs = ${type} ]; then
echo ${dev##*/}
@@ -38,16 +39,19 @@ fi
log -pi -t checkpoint_gc Turning on GC for ${NAME}
echo 1 > /sys/fs/f2fs/${NAME}/gc_urgent || exit 1
-COUNT=0
-STEP=5
-while [ ${COUNT} -lt ${GC_TIME} ]; do
- print -u${STATUS_FD} "global_progress `echo $COUNT/$GC_TIME|bc -l`"
- read DIRTY_SEGMENTS < /sys/fs/f2fs/${NAME}/dirty_segments
- if [ ${DIRTY_SEGMENTS} -le ${DIRTY_SEGMENTS_THRESHOLD} ]; then
- break
+read DIRTY_SEGMENTS_START < /sys/fs/f2fs/${NAME}/dirty_segments
+DIRTY_SEGMENTS=${DIRTY_SEGMENTS_START}
+TODO_SEGMENTS=$((${DIRTY_SEGMENTS_START}-${DIRTY_SEGMENTS_THRESHOLD}))
+echo $DIRTY_SEGMENTS_START
+while [ ${DIRTY_SEGMENTS} -gt ${DIRTY_SEGMENTS_THRESHOLD} ]; do
+ echo $DIRTY_SEGMENTS
+ PROGRESS=`echo "(${DIRTY_SEGMENTS_START}-${DIRTY_SEGMENTS})/${TODO_SEGMENTS}"|bc -l`
+ if [[ $PROGRESS == -* ]]; then
+ PROGRESS=0
fi
- sleep ${STEP}
- COUNT=$((${COUNT}+${STEP}))
+ print -u${STATUS_FD} "global_progress ${PROGRESS}"
+ read DIRTY_SEGMENTS < /sys/fs/f2fs/${NAME}/dirty_segments
+ sleep ${SLEEP}
done
log -pi -t checkpoint_gc Turning off GC for ${NAME}