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: enhancedf2fs05.sh 18# 19# Description: performance mode, discard is greater than or equal to 1 block 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 29source performance_init.sh 30 31do_setup() 32{ 33 34} 35 36do_test() 37{ 38 local ret=0 39 40 tst_res TINFO "Start test discard size >= 1 block in performance mode." 41 42 cat /sys/kernel/debug/tracing/trace_pipe | grep issue_discard >> log05.txt & 43 mkdir /mnt/f2fs_mount/test5 44 if [ $? -eq 0 ]; then 45 tst_res TPASS "Creation test5 dir successfully." 46 else 47 tst_res TFAIL "Creation test5 dir failed." 48 ret=$(( $ret + 1 )) 49 fi 50 local i=0 51 while [ $i -lt 200 ] 52 do 53 dd if=/dev/zero of=/mnt/f2fs_mount/test5/image$i bs=4k count=1 54 i=$((i+1)) 55 done 56 rm -rf /mnt/f2fs_mount/test5/image*[1,3,5,7,9] 57 if [ $? -eq 0 ]; then 58 tst_res TPASS "Delete successfully." 59 else 60 tst_res TFAIL "Delete failed." 61 ret=$(( $ret + 1 )) 62 fi 63 64 sleep 90 65 kill %1 66 local blklen=$(cat log05.txt | awk 'NR == 1' | awk -F '0x' '{print$3}') 67 if [ $((16#$blklen)) -ge 1 ];then 68 tst_res TPASS "Log printing successfully." 69 else 70 tst_res TFAIL "Log printing failed." 71 ret=$(( $ret + 1 )) 72 fi 73 74 if [ $ret -eq 0 ];then 75 tst_res TPASS "performance mode, discard is greater than or equal to \ 76 1 block pass." 77 else 78 tst_res TFAIL "performance mode, discard is greater than or equal to \ 79 1 block failed!" 80 fi 81} 82 83do_clean() 84{ 85 rm -rf log05.txt 86 losetup -d /dev/block/loop1 87 umount /mnt/f2fs_mount 88} 89 90do_setup 91do_test 92do_clean 93tst_exit