diff options
author | Daniel Rosenberg <drosen@google.com> | 2021-03-02 17:00:51 -0800 |
---|---|---|
committer | Daniel Rosenberg <drosen@google.com> | 2021-03-03 02:42:59 +0000 |
commit | 4528bf00fe7287d514a8651063459750df3f6a51 (patch) | |
tree | 580535173cdf9359eaf4150cd8110903fd363d1b /checkpoint_gc | |
parent | faa8d01ec556137ed260496b2fbbe0fecb1fbfb5 (diff) | |
download | extras-4528bf00fe7287d514a8651063459750df3f6a51.tar.gz |
checkpoint_gc: Use Unusable and adjust thresholds
The upstream version of f2fs provids the 'unusable' sysfs entry, which
monitors exactly the condition we wish to check. If available, we should
use that instead of the number of dirty segments. Additionally, we've
adjusted the max run time of the script and raised the lower threshold
to reflect the more flexible mounting with checkpoint=disable:%u option.
Bug: 178715376
Test: Run fsstress to dirty blocks, run checkpoint_gc.sh
Change-Id: I0d2e86d8b57da8553d93b85338c22b246aff24a5
Diffstat (limited to 'checkpoint_gc')
-rw-r--r-- | checkpoint_gc/checkpoint_gc.sh | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/checkpoint_gc/checkpoint_gc.sh b/checkpoint_gc/checkpoint_gc.sh index f77e63a6..a1169ec0 100644 --- a/checkpoint_gc/checkpoint_gc.sh +++ b/checkpoint_gc/checkpoint_gc.sh @@ -23,32 +23,46 @@ # TARGET_SLOT="${1}" STATUS_FD="${2}" -DIRTY_SEGMENTS_THRESHOLD=100 SLEEP=5 TIME=0 -MAX_TIME=3600 +MAX_TIME=1200 if [ ! -d /dev/sys/fs/by-name/userdata ]; then exit 0 fi +if [ -f /dev/sys/fs/by-name/userdata/unusable ]; then + UNUSABLE=1 + METRIC="unusable blocks" + THRESHOLD=25000 + read START < /dev/sys/fs/by-name/userdata/unusable +else + METRIC="dirty segments" + THRESHOLD=200 + read START < /dev/sys/fs/by-name/userdata/dirty_segments +fi + log -pi -t checkpoint_gc Turning on GC for userdata read OLD_SLEEP < /dev/sys/fs/by-name/userdata/gc_urgent_sleep_time || exit 1 echo 50 > /dev/sys/fs/by-name/userdata/gc_urgent_sleep_time || exit 1 echo 1 > /dev/sys/fs/by-name/userdata/gc_urgent || exit 1 -read DIRTY_SEGMENTS_START < /dev/sys/fs/by-name/userdata/dirty_segments -DIRTY_SEGMENTS=${DIRTY_SEGMENTS_START} -TODO_SEGMENTS=$((${DIRTY_SEGMENTS_START}-${DIRTY_SEGMENTS_THRESHOLD})) -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` + +CURRENT=${START} +TODO=$((${START}-${THRESHOLD})) +while [ ${CURRENT} -gt ${THRESHOLD} ]; do + log -pi -t checkpoint_gc ${METRIC}:${CURRENT} \(threshold:${THRESHOLD}\) + PROGRESS=`echo "(${START}-${CURRENT})/${TODO}"|bc -l` if [[ $PROGRESS == -* ]]; then PROGRESS=0 fi print -u${STATUS_FD} "global_progress ${PROGRESS}" - read DIRTY_SEGMENTS < /dev/sys/fs/by-name/userdata/dirty_segments + if [ ${UNUSABLE} -eq 1 ]; then + read CURRENT < /dev/sys/fs/by-name/userdata/unusable + else + read CURRENT < /dev/sys/fs/by-name/userdata/dirty_segments + fi sleep ${SLEEP} TIME=$((${TIME}+${SLEEP})) if [ ${TIME} -gt ${MAX_TIME} ]; then |