xref: /aosp_15_r20/external/f2fs-tools/scripts/spo_test.sh (revision 59bfda1f02d633cd6b8b69f31eee485d40f6eef6)
1*59bfda1fSAndroid Build Coastguard Worker#!/bin/bash
2*59bfda1fSAndroid Build Coastguard Worker
3*59bfda1fSAndroid Build Coastguard WorkerMNT=/mnt/f2fs
4*59bfda1fSAndroid Build Coastguard WorkerDEV=/dev/sdb1
5*59bfda1fSAndroid Build Coastguard WorkerUSER_DIR=/home/zeus
6*59bfda1fSAndroid Build Coastguard WorkerF2FS_DIR=$USER_DIR/f2fs_test
7*59bfda1fSAndroid Build Coastguard Worker
8*59bfda1fSAndroid Build Coastguard Workercheck_stop() {
9*59bfda1fSAndroid Build Coastguard Worker	stop=`cat /tmp/stop`
10*59bfda1fSAndroid Build Coastguard Worker	if [ $stop -eq 1 ]; then
11*59bfda1fSAndroid Build Coastguard Worker		exit
12*59bfda1fSAndroid Build Coastguard Worker	fi
13*59bfda1fSAndroid Build Coastguard Worker}
14*59bfda1fSAndroid Build Coastguard Worker
15*59bfda1fSAndroid Build Coastguard Workercase $1 in
16*59bfda1fSAndroid Build Coastguard Workerstart)
17*59bfda1fSAndroid Build Coastguard Worker	echo 0 > /tmp/stop
18*59bfda1fSAndroid Build Coastguard Worker	umount /mnt/*
19*59bfda1fSAndroid Build Coastguard Worker	echo 3 > /proc/sys/vm/drop_caches
20*59bfda1fSAndroid Build Coastguard Worker	echo 8 > /proc/sys/kernel/printk
21*59bfda1fSAndroid Build Coastguard Worker
22*59bfda1fSAndroid Build Coastguard Worker	date >> $USER_DIR/por_result
23*59bfda1fSAndroid Build Coastguard Worker	sync
24*59bfda1fSAndroid Build Coastguard Worker
25*59bfda1fSAndroid Build Coastguard Worker	insmod $F2FS_DIR/src/fs/f2fs/f2fs.ko || exit
26*59bfda1fSAndroid Build Coastguard Worker
27*59bfda1fSAndroid Build Coastguard Worker	echo Start checking F2FS without fsync
28*59bfda1fSAndroid Build Coastguard Worker	check_stop
29*59bfda1fSAndroid Build Coastguard Worker	fsck.f2fs $DEV -d 0 || exit
30*59bfda1fSAndroid Build Coastguard Worker	mount -t f2fs -o disable_roll_forward $DEV $MNT || exit
31*59bfda1fSAndroid Build Coastguard Worker	umount $MNT
32*59bfda1fSAndroid Build Coastguard Worker	echo 3 > /proc/sys/vm/drop_caches
33*59bfda1fSAndroid Build Coastguard Worker
34*59bfda1fSAndroid Build Coastguard Worker	echo Start checking F2FS with fsync
35*59bfda1fSAndroid Build Coastguard Worker	check_stop
36*59bfda1fSAndroid Build Coastguard Worker	fsck.f2fs $DEV -d 0 || exit
37*59bfda1fSAndroid Build Coastguard Worker	mount -t f2fs $DEV $MNT || exit
38*59bfda1fSAndroid Build Coastguard Worker	umount $MNT
39*59bfda1fSAndroid Build Coastguard Worker
40*59bfda1fSAndroid Build Coastguard Worker	check_stop
41*59bfda1fSAndroid Build Coastguard Worker	fsck.f2fs $DEV -d 0 || exit
42*59bfda1fSAndroid Build Coastguard Worker	mount -t f2fs $DEV $MNT || exit
43*59bfda1fSAndroid Build Coastguard Worker
44*59bfda1fSAndroid Build Coastguard Worker	count=`cat $USER_DIR/por_time`
45*59bfda1fSAndroid Build Coastguard Worker	if [ $count -eq 20 ]; then
46*59bfda1fSAndroid Build Coastguard Worker		echo Start rm all
47*59bfda1fSAndroid Build Coastguard Worker		time rm -rf $MNT/* || exit
48*59bfda1fSAndroid Build Coastguard Worker		echo 0 > $USER_DIR/por_time
49*59bfda1fSAndroid Build Coastguard Worker		sync
50*59bfda1fSAndroid Build Coastguard Worker	else
51*59bfda1fSAndroid Build Coastguard Worker		echo $((count+1)) > $USER_DIR/por_time
52*59bfda1fSAndroid Build Coastguard Worker	fi
53*59bfda1fSAndroid Build Coastguard Worker	echo 8 > /proc/sys/kernel/printk
54*59bfda1fSAndroid Build Coastguard Worker	echo Start fsstress
55*59bfda1fSAndroid Build Coastguard Worker	date
56*59bfda1fSAndroid Build Coastguard Worker	$F2FS_DIR/stress_test/fsstress/fsstress -z -f link=0 -f mkdir=3 -f mknod=3 -f rmdir=2 -f symlink=3 -f truncate=4 -f write=10 -f creat=10 -f unlink=5 -f rename=5 -f fsync=10 -p 10 -n 10000 -l 0 -d $MNT &
57*59bfda1fSAndroid Build Coastguard Worker	RANDOM=`date '+%s'`
58*59bfda1fSAndroid Build Coastguard Worker	rand=$[($RANDOM % 540) + 60]
59*59bfda1fSAndroid Build Coastguard Worker	echo Start sleep: $rand seconds
60*59bfda1fSAndroid Build Coastguard Worker	sleep $rand
61*59bfda1fSAndroid Build Coastguard Worker
62*59bfda1fSAndroid Build Coastguard Worker	echo Reboot now
63*59bfda1fSAndroid Build Coastguard Worker	check_stop
64*59bfda1fSAndroid Build Coastguard Worker	echo b > /proc/sysrq-trigger
65*59bfda1fSAndroid Build Coastguard Worker	;;
66*59bfda1fSAndroid Build Coastguard Workerstop)
67*59bfda1fSAndroid Build Coastguard Worker	killall -9 fsstress
68*59bfda1fSAndroid Build Coastguard Worker	echo 1 > /tmp/stop
69*59bfda1fSAndroid Build Coastguard Worker	;;
70*59bfda1fSAndroid Build Coastguard Workeresac
71