1 #! /bin/sh 2 # SPDX-License-Identifier: GPL-2.0-or-later 3 # Copyright (c) 2015-2018 Oracle and/or its affiliates. All Rights Reserved. 4 # Copyright (c) International Business Machines Corp., 2001 5 # Created by: Robbie Williamson (robbiew (at] us.ibm.com) 6 7 TST_CLEANUP="nfs03_cleanup" 8 TST_SETUP="nfs03_setup" 9 TST_TESTFUNC="do_test" 10 11 . nfs_lib.sh 12 13 DIR_NUM=${DIR_NUM:-"100"} 14 FILE_NUM=${FILE_NUM:-"100"} 15 THREAD_NUM=${THREAD_NUM:-"1"} 16 ORIG_NFSD= 17 18 make_subdirs() 19 { 20 tst_res TINFO "make '$DIR_NUM' directories" 21 for i in $(seq 0 $DIR_NUM); do 22 ROD mkdir -p dir$i 23 done 24 } 25 26 touch_files() 27 { 28 for j in $(seq 0 $DIR_NUM); do 29 cd dir$j 30 for k in $(seq 0 $FILE_NUM); do 31 ROD touch file$j$k 32 done 33 cd .. 34 done 35 } 36 37 rm_files() 38 { 39 for j in $(seq 0 $DIR_NUM); do 40 cd dir$j 41 for k in $(seq 0 $FILE_NUM); do 42 ROD rm -f file$j$k 43 done 44 cd .. 45 done 46 } 47 48 do_test() 49 { 50 tst_res TINFO "Multiple processes creating and deleting files" 51 52 tst_res TINFO "creating dir1 subdirectories & files" 53 ROD mkdir -p dir1 54 cd dir1 55 make_subdirs 56 touch_files & 57 pid1=$! 58 cd .. 59 60 tst_res TINFO "creating dir2 subdirectories & files" 61 ROD mkdir -p dir2 62 cd dir2 63 make_subdirs 64 touch_files & 65 pid2=$! 66 67 tst_res TINFO "cd dir1 & removing files" 68 cd ../dir1 69 wait $pid1 70 rm_files & 71 72 tst_res TINFO "cd dir2 & removing files" 73 cd ../dir2 74 wait $pid2 75 rm_files 76 77 tst_res TPASS "test done" 78 } 79 80 nfs03_setup() 81 { 82 nfs_setup 83 84 tst_res TINFO "Setting server side nfsd count to $THREAD_NUM" 85 ORIG_NFSD=$(tst_rhost_run -s -c 'ps -ef | grep -w nfsd | grep -v grep | wc -l') 86 tst_rhost_run -s -c "rpc.nfsd $THREAD_NUM" 87 } 88 89 nfs03_cleanup() 90 { 91 tst_rhost_run -c "rpc.nfsd $ORIG_NFSD" 92 nfs_cleanup 93 } 94 95 tst_run 96