summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Rosenberg <drosen@google.com>2019-04-30 15:45:21 -0700
committerDaniel Rosenberg <drosen@google.com>2019-05-01 15:29:56 -0700
commit06286985a3f511dc7cf0544c24ae9ea07fecc06a (patch)
tree79e44978aa7138f78769321d55457f17dd7e5fb5
parent1f0277ae23c3f7a4c52629b666d020ebc4e9ac96 (diff)
downloadextras-06286985a3f511dc7cf0544c24ae9ea07fecc06a.tar.gz
Add a max timeout in checkpoint_gc
After one hour, we will abandon our efforts to do checkpointing ahead of time. At that point, it's likely that something has gone wrong with garbage collection. Log dirty segments. Test: Run checkpoint_gc after remounting with checkpoint=disable. This will prevent GC from making progress. The script should exit after one hour Bug: 131557838 Change-Id: Ifbff5d3e889725259d7c797fe6fa1d4a84fc7cec
-rw-r--r--checkpoint_gc/checkpoint_gc.sh8
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