diff options
author | Daniel Rosenberg <drosen@google.com> | 2019-05-02 13:15:39 -0700 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2019-05-02 13:15:39 -0700 |
commit | 9f3fe616554718ac4f8bf523c4d55f2debfa2e3c (patch) | |
tree | 79e44978aa7138f78769321d55457f17dd7e5fb5 | |
parent | 1f0277ae23c3f7a4c52629b666d020ebc4e9ac96 (diff) | |
parent | 06286985a3f511dc7cf0544c24ae9ea07fecc06a (diff) | |
download | extras-9f3fe616554718ac4f8bf523c4d55f2debfa2e3c.tar.gz |
Add a max timeout in checkpoint_gc
am: 06286985a3
Change-Id: I0372f7e39a6641a937f8757e8c7a60bc7a0177dd
-rw-r--r-- | checkpoint_gc/checkpoint_gc.sh | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/checkpoint_gc/checkpoint_gc.sh b/checkpoint_gc/checkpoint_gc.sh index 93785804..d653ee56 100644 --- a/checkpoint_gc/checkpoint_gc.sh +++ b/checkpoint_gc/checkpoint_gc.sh @@ -26,6 +26,8 @@ STATUS_FD="${2}" DIRTY_SEGMENTS_THRESHOLD=100 SLEEP=5 +TIME=0 +MAX_TIME=3600 NAME=`while read dev dir type opt; do if [ /data = ${dir} -a f2fs = ${type} ]; then @@ -42,8 +44,8 @@ echo 1 > /sys/fs/f2fs/${NAME}/gc_urgent || exit 1 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 + log -pi -t checkpoint_gc dirty segments:${DIRTY_SEGMENTS} \(threshold:${DIRTY_SEGMENTS_THRESHOLD}\) PROGRESS=`echo "(${DIRTY_SEGMENTS_START}-${DIRTY_SEGMENTS})/${TODO_SEGMENTS}"|bc -l` if [[ $PROGRESS == -* ]]; then PROGRESS=0 @@ -51,6 +53,10 @@ while [ ${DIRTY_SEGMENTS} -gt ${DIRTY_SEGMENTS_THRESHOLD} ]; do print -u${STATUS_FD} "global_progress ${PROGRESS}" read DIRTY_SEGMENTS < /sys/fs/f2fs/${NAME}/dirty_segments sleep ${SLEEP} + TIME=$((${TIME}+${SLEEP})) + if [ ${TIME} -gt ${MAX_TIME} ]; then + break + fi # In case someone turns it off behind our back echo 1 > /sys/fs/f2fs/${NAME}/gc_urgent done |