Home | History | Annotate | Download | only in nfs_stress
      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 	for j in $(seq 0 $DIR_NUM); do
     46 		cd dir$j
     47 		for k in $(seq 0 $FILE_NUM); do
     48 			ROD touch file$j$k
     49 		done
     50 		cd ..
     51 	done
     52 }
     53 
     54 rm_files()
     55 {
     56 	for j in $(seq 0 $DIR_NUM); do
     57 		cd dir$j
     58 		for k in $(seq 0 $FILE_NUM); do
     59 			ROD rm -f file$j$k
     60 		done
     61 		cd ..
     62 	done
     63 }
     64 
     65 do_test()
     66 {
     67 	tst_resm TINFO "Multiple processes creating and deleting files"
     68 
     69 	tst_resm TINFO "creating dir1 subdirectories & files"
     70 	ROD mkdir -p dir1
     71 	cd dir1
     72 	make_subdirs
     73 	touch_files &
     74 	pid1=$!
     75 	cd ..
     76 
     77 	tst_resm TINFO "creating dir2 subdirectories & files"
     78 	ROD mkdir -p dir2
     79 	cd dir2
     80 	make_subdirs
     81 	touch_files &
     82 	pid2=$!
     83 
     84 	tst_resm TINFO "cd dir1 & removing files"
     85 	cd ../dir1
     86 	wait $pid1
     87 	rm_files &
     88 
     89 	tst_resm TINFO "cd dir2 & removing files"
     90 	cd ../dir2
     91 	wait $pid2
     92 	rm_files &
     93 
     94 	# wait for all background processes to complete execution
     95 	wait
     96 
     97 	tst_resm TPASS "test done"
     98 }
     99 
    100 nfs03_setup()
    101 {
    102 	nfs_setup
    103 
    104 	tst_resm TINFO "Setting server side nfsd count to $THREAD_NUM"
    105 	ORIG_NFSD=$(tst_rhost_run -s -c 'ps -ef | grep -w nfsd | grep -v grep | wc -l')
    106 	tst_rhost_run -s -c "rpc.nfsd $THREAD_NUM"
    107 }
    108 
    109 nfs03_cleanup()
    110 {
    111 	tst_rhost_run -c "rpc.nfsd $ORIG_NFSD"
    112 	nfs_cleanup
    113 }
    114 
    115 nfs03_setup
    116 
    117 do_test
    118 
    119 tst_exit
    120