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@us.ibm.com) 6 7TST_CLEANUP="nfs03_cleanup" 8TST_SETUP="nfs03_setup" 9TST_TESTFUNC="do_test" 10 11. nfs_lib.sh 12 13DIR_NUM=${DIR_NUM:-"100"} 14FILE_NUM=${FILE_NUM:-"100"} 15THREAD_NUM=${THREAD_NUM:-"1"} 16ORIG_NFSD= 17 18make_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 26touch_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 37rm_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 48do_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 80nfs03_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 89nfs03_cleanup() 90{ 91 tst_rhost_run -c "rpc.nfsd $ORIG_NFSD" 92 nfs_cleanup 93} 94 95tst_run 96