Home | History | Annotate | Download | only in scripts
      1 #!/bin/bash
      2 
      3 MNT=/mnt/f2fs
      4 DEV=/dev/sdb1
      5 USER_DIR=/home/zeus
      6 F2FS_DIR=$USER_DIR/f2fs_test
      7 
      8 check_stop() {
      9 	stop=`cat /tmp/stop`
     10 	if [ $stop -eq 1 ]; then
     11 		exit
     12 	fi
     13 }
     14 
     15 case $1 in
     16 start)
     17 	echo 0 > /tmp/stop
     18 	umount /mnt/*
     19 	echo 3 > /proc/sys/vm/drop_caches
     20 	echo 8 > /proc/sys/kernel/printk
     21 
     22 	date >> $USER_DIR/por_result
     23 	sync
     24 
     25 	insmod $F2FS_DIR/src/fs/f2fs/f2fs.ko || exit
     26 
     27 	echo Start checking F2FS without fsync
     28 	check_stop
     29 	fsck.f2fs $DEV -d 0 || exit
     30 	mount -t f2fs -o disable_roll_forward $DEV $MNT || exit
     31 	umount $MNT
     32 	echo 3 > /proc/sys/vm/drop_caches
     33 
     34 	echo Start checking F2FS with fsync
     35 	check_stop
     36 	fsck.f2fs $DEV -d 0 || exit
     37 	mount -t f2fs $DEV $MNT || exit
     38 	umount $MNT
     39 
     40 	check_stop
     41 	fsck.f2fs $DEV -d 0 || exit
     42 	mount -t f2fs $DEV $MNT || exit
     43 
     44 	count=`cat $USER_DIR/por_time`
     45 	if [ $count -eq 20 ]; then
     46 		echo Start rm all
     47 		time rm -rf $MNT/* || exit
     48 		echo 0 > $USER_DIR/por_time
     49 		sync
     50 	else
     51 		echo $((count+1)) > $USER_DIR/por_time
     52 	fi
     53 	echo 8 > /proc/sys/kernel/printk
     54 	echo Start fsstress
     55 	date
     56 	$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 	RANDOM=`date '+%s'`
     58 	rand=$[($RANDOM % 540) + 60]
     59 	echo Start sleep: $rand seconds
     60 	sleep $rand
     61 
     62 	echo Reboot now
     63 	check_stop
     64 	echo b > /proc/sysrq-trigger
     65 	;;
     66 stop)
     67 	killall -9 fsstress
     68 	echo 1 > /tmp/stop
     69 	;;
     70 esac
     71