1 #! /bin/sh 2 # Copyright (c) 2015 Oracle and/or its affiliates. All Rights Reserved. 3 # Copyright (c) International Business Machines Corp., 2001 4 # 5 # This program is free software; you can redistribute it and/or 6 # modify it under the terms of the GNU General Public License as 7 # published by the Free Software Foundation; either version 2 of 8 # the License, or (at your option) any later version. 9 # 10 # This program is distributed in the hope that it would be useful, 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 # GNU General Public License for more details. 14 # 15 # You should have received a copy of the GNU General Public License 16 # along with this program. If not, see <http://www.gnu.org/licenses/>. 17 # 18 # DESCRIPTION: This script sets up the NFS directories in the remote machine 19 # and runs the LTP's filesystem test: fs_inod. 20 # 21 # Created by: Robbie Williamson (robbiew (at] us.ibm.com) 22 23 TCID="nfs03" 24 TST_TOTAL=1 25 TST_CLEANUP="nfs03_cleanup" 26 27 . nfs_lib.sh 28 . test_net.sh 29 30 DIR_NUM=${DIR_NUM:-"100"} 31 FILE_NUM=${FILE_NUM:-"100"} 32 THREAD_NUM=${THREAD_NUM:-"1"} 33 ORIG_NFSD= 34 35 make_subdirs() 36 { 37 tst_resm TINFO "make '$DIR_NUM' directories" 38 for i in $(seq 0 $DIR_NUM); do 39 ROD mkdir -p dir$i 40 done 41 } 42 43 touch_files() 44 { 45 tst_resm TINFO "create files [0 - $DIR_NUM]/file$DIR_NUM[0 - $FILE_NUM]" 46 for j in $(seq 0 $DIR_NUM); do 47 cd dir$j 48 for k in $(seq 0 $FILE_NUM); do 49 ROD \>file$j$k 50 done 51 cd .. 52 done 53 } 54 55 rm_files() 56 { 57 tst_resm TINFO "rm files [0 - $DIR_NUM]/file$DIR_NUM[0 - $FILE_NUM]" 58 for j in $(seq 0 $DIR_NUM); do 59 cd dir$j 60 for k in $(seq 0 $FILE_NUM); do 61 ROD rm -f file$j$k 62 done 63 cd .. 64 done 65 } 66 67 do_test() 68 { 69 tst_resm TINFO "Multiple processes creating and deleting files" 70 71 tst_resm TINFO "creating dir1 subdirectories & files" 72 ROD mkdir -p dir1 73 ROD cd dir1 74 make_subdirs 75 touch_files & 76 pid1=$! 77 cd .. 78 79 tst_resm TINFO "creating dir2 subdirectories & files" 80 ROD mkdir -p dir2 81 ROD cd dir2 82 make_subdirs 83 touch_files & 84 pid2=$! 85 86 tst_resm TINFO "cd dir1 & removing files" 87 ROD cd ../dir1 88 wait $pid1 89 rm_files & 90 91 tst_resm TINFO "cd dir2 & removing files" 92 ROD cd ../dir2 93 wait $pid2 94 rm_files & 95 96 # wait for all background processes to complete execution 97 wait 98 99 tst_resm TPASS "test done" 100 } 101 102 nfs03_setup() 103 { 104 nfs_setup 105 106 tst_resm TINFO "Setting server side nfsd count to $THREAD_NUM" 107 ORIG_NFSD=$(tst_rhost_run -s -c 'ps -ef | grep nfsd | grep -v grep | wc -l') 108 tst_rhost_run -s -c "rpc.nfsd $THREAD_NUM" 109 } 110 111 nfs03_cleanup() 112 { 113 tst_rhost_run -c "rpc.nfsd $ORIG_NFSD" 114 nfs_cleanup 115 } 116 117 nfs03_setup 118 119 do_test 120 121 tst_exit 122