1#!/bin/sh 2################################################################################ 3# 4# Copyright (C) 2022 Huawei Device Co., Ltd. 5# SPDX-License-Identifier: GPL-2.0 6# 7# Legacy blkg rwstat helpers enabled by CONFIG_BLK_CGROUP_RWSTAT. 8# Do not use in new code. 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15# 16################################################################################ 17# File: performance_init.sh 18# 19# Description: enhancedf2fs05 and enhancedf2fs06 testsuite init script 20# 21# Authors: Li Zhanming - lizhanming3@h-partners.com 22# 23# History: April 8 2022 - init scripts 24# 25################################################################################ 26 27source tst_oh.sh 28 29state_init() 30{ 31 mkfs.f2fs -d1 -t1 -O quota $IMG_FILE 32 losetup /dev/block/loop1 $IMG_FILE 33 mount -t f2fs /dev/block/loop1 /mnt/f2fs_mount/ 34} 35 36performance_init() 37{ 38 local ret=0 39 local segs_path=/sys/kernel/debug/f2fs/status 40 41 tst_res TINFO "Start performance_init.sh." 42 local a=$(cat $segs_path | grep segs | awk -F ' ' '{print$3}') 43 echo "start Embedded file system $(date +%Y%m%d%H%M%S)...." >> log06.txt 44 local i=0 45 while [ $i -lt 37 ] 46 do 47 dd if=/dev/zero of=/mnt/f2fs_mount/image$i bs=512M count=1 48 i=$(( $i + 1 )) 49 done 50 echo "end Embedded file system $(date +%Y%m%d%H%M%S)...." >> log06.txt 51 local b=$(cat $segs_path | grep "valid blocks" | awk -F ' ' '{print$3}' | tr -cd "[0-9]") 52 local result_left=$(echo | awk "{print $a*512-$b}") 53 local result_right=$(echo | awk "{print $a*512*0.1}") 54 local result=$(echo "$result_left $result_right" \ 55 | awk '{if ($result_left -lt $result_right) print 1; else print 0}') 56 if [ $result -gt 0 ];then 57 tst_res TPASS "Inequality holds." 58 else 59 tst_res TFAIL "Inequality does not hold." 60 ret=$(( $ret + 1 )) 61 fi 62 63 sleep 60 64 if [ $(cat /sys/fs/f2fs/loop1/discard_type) == '2' ];then 65 tst_res TPASS "performance model successfully." 66 else 67 tst_res TFAIL "performance model failed." 68 ret=$(( $ret + 1 )) 69 fi 70 echo 1 > /sys/kernel/debug/tracing/tracing_on 71 echo 1 > /sys/kernel/debug/tracing/events/f2fs/f2fs_issue_discard/enable 72 if [ $? -eq 0 ]; then 73 tst_res TPASS "Trace opened successfully." 74 else 75 tst_res TFAIL "Trace start failed." 76 ret=$(( $ret + 1 )) 77 fi 78 79 if [ $ret -eq 0 ];then 80 tst_res TPASS "performance_init successfully." 81 else 82 tst_res TFAIL "performance_init failed!" 83 fi 84} 85 86state_init 87performance_init 88