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