4 # The contents of this file are subject to the terms of the
5 # Common Development and Distribution License (the "License").
6 # You may not use this file except in compliance with the License.
8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 # or http://www.opensolaris.org/os/licensing.
10 # See the License for the specific language governing permissions
11 # and limitations under the License.
13 # When distributing Covered Code, include this CDDL HEADER in each
14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 # If applicable, add the following below this CDDL HEADER, with the
16 # fields enclosed by brackets "[]" replaced with your own identifying
17 # information: Portions Copyright [yyyy] [name of copyright owner]
23 # Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 # Use is subject to license terms.
28 # Copyright (c) 2013, 2016 by Delphix. All rights reserved.
31 . $STF_SUITE/tests/functional/mv_files/mv_files.cfg
34 # Determine whether this version of the ksh being
35 # executed has a bug where the limit of background
38 function check_bg_procs_limit_num
40 echo "#!/bin/ksh" > /var/tmp/exitsZero.ksh
41 echo "exit 0" >> /var/tmp/exitsZero.ksh
42 chmod 777 /var/tmp/exitsZero.ksh
44 cat <<EOF > /var/tmp/testbackgprocs.ksh
47 # exitsZero.ksh is a one line script
48 # that exit with status of "0"
55 /var/tmp/exitsZero.ksh &
65 (( \$? == 127 )) && exit 1
70 ksh /var/tmp/testbackgprocs.ksh
71 if [[ $? -eq 1 ]]; then
73 # Current ksh being executed has a limit
74 # of 25 background processes.
87 create_pool $TESTPOOL "$disklist"
89 if ! is_global_zone ; then
93 rm -rf $TESTDIR || log_unresolved Could not remove $TESTDIR
94 mkdir -p $TESTDIR || log_unresolved Could not create $TESTDIR
96 rm -rf $TESTDIR_TGT || log_unresolved Could not remove $TESTDIR_TGT
97 mkdir -p $TESTDIR_TGT || log_unresolved Could not create $TESTDIR_TGT
99 log_must zfs create $TESTPOOL/$TESTFS
100 log_must zfs set mountpoint=$TESTDIR $TESTPOOL/$TESTFS
102 log_must zfs create $TESTPOOL/$TESTFS_TGT
103 log_must zfs set mountpoint=$TESTDIR_TGT $TESTPOOL/$TESTFS_TGT
105 mkdir -p $OLDDIR || log_unresolved Could not create $OLDDIR
106 mkdir -p $NEWDIR_IN_FS || log_unresolved Could not create $NEWDIR_IN_FS
107 mkdir -p $NEWDIR_ACROSS_FS || log_unresolved Could not create $NEWDIR_ACROSS_FS
115 ps -e | grep $pid >/dev/null 2>&1
116 (( $? == 0 )) && wait $pid
122 # Generate given number files in a
123 # directory of zfs file system
124 # $1 - the directory holds the generated files
125 # $2 - number of to-be-generated files
128 function generate_files
131 typeset -i proc_num=0
133 if (( $2 == $MVNUMFILES )); then
139 while (( count <= $2 ))
141 cp /etc/passwd $1/file_$count \
146 proc_num=`echo $PIDS | wc -w`
147 if (( proc_num >= GANGPIDS )); then
153 (( count = count + 1 ))
159 # Move given number files from one directory to
160 # another directory in parallel
161 # $1 - source directory
162 # $2 - target directory
167 find $1 -type f -print | xargs -i \
168 mv {} $2 > /dev/null 2>&1
172 # Count the files number after moving, and
173 # compare it with the original number
174 # $1 - directory that to be operated
175 # $2 - original files number
180 file_num=`find $1 -type f -print | \
182 (( file_num != $2 )) && \
183 log_fail "The file number of target directory"\
184 "$2 is not equal to that of the source "\
190 # Running the 'mv' test
199 typeset -i inc_num=$(( MVNUMFILES + MVNUMINCR ))
202 for num in $MVNUMFILES $inc_num
204 generate_files $old $num
207 count_files $new $num
210 count_files $old $num
213 typeset dir=$(get_device_dir $DISKS)
214 verify_filesys "$TESTPOOL" "$TESTPOOL/$TESTFS" "$dir"