1#!/bin/sh 2################################################################################ 3# 4# Copyright (C) 2022 Huawei Device Co., Ltd. 5# SPDX-License-Identifier: GPL-2.0 6# 7# Unless required by applicable law or agreed to in writing, software 8# distributed under the License is distributed on an "AS IS" BASIS, 9# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10# See the License for the specific language governing permissions and 11# limitations under the License. 12# 13################################################################################ 14# File: enhancedf2fs03.sh 15# 16# Description: equilibrium mode, discard is greater than or equal to 16 block 17# 18# Authors: Li Zhanming - lizhanming3@h-partners.com 19# 20# History: April 8 2022 - init scripts 21# 22################################################################################ 23 24source tst_oh.sh 25 26source equilibrium_init.sh 27 28do_setup() 29{ 30 31} 32 33do_test() 34{ 35 local ret=0 36 37 tst_res TINFO "Start test discard size >= 16 blocks in equilibrium mode." 38 39 cat /sys/kernel/debug/tracing/trace_pipe | grep issue_discard >> log03.txt & 40 sleep 60 41 mkdir $DISK_PATH/test3 42 if [ $? -eq 0 ]; then 43 tst_res TPASS "Creation test3 dir successfully." 44 else 45 tst_res TFAIL "Creation test3 dir fail." 46 ret=$(( $ret + 1 )) 47 fi 48 49 local i=0 50 while [ $i -lt 50 ] 51 do 52 dd if=/dev/zero of=$DISK_PATH/test3/image$i bs=512K count=1 53 i=$(( $i + 1 )) 54 done 55 echo "y" | rm $DISK_PATH/test3/image*[1,3,5,7,9] 56 if [ $? -eq 0 ]; then 57 tst_res TPASS "Deleted successfully." 58 else 59 tst_res TFAIL "Deleted fail." 60 ret=$(( $ret + 1 )) 61 fi 62 63 sleep 90 64 kill %1 65 66 local blklen=$(cat log03.txt | awk 'NR == 1' | awk -F '0x' '{print$3}') 67 if [ $((16#$blklen)) -ge 16 ];then 68 tst_res TPASS "blklen = $blklen >= 16 successfully." 69 else 70 tst_res TFAIL "blklen = $blklen >= 16 fail." 71 ret=$(( $ret + 1 )) 72 fi 73 74 if [ $ret -eq 0 ];then 75 tst_res TPASS "equilibrium mode, discard is greater than or equal to \ 76 16 block pass." 77 else 78 tst_res TFAIL "equilibrium mode, discard is greater than or equal to \ 79 16 block failed!" 80 fi 81} 82 83do_clean() 84{ 85 echo "y" | rm $DISK_PATH/test3/* 86 rmdir $DISK_PATH/test3/ 87 echo "y" | rm $DISK_PATH/f2fs_test/* 88 rmdir $DISK_PATH/f2fs_test/ 89} 90 91do_setup 92do_test 93do_clean 94tst_exit