On Wed, 12 Jul 2023, Darrick J. Wong wrote: > Mikulas, does this solve the forkbomb problem? > > --D Yes, this patch works. Tested-by: Mikulas Patocka <mpatocka@xxxxxxxxxx> Mikulas > diff --git a/tests/generic/558 b/tests/generic/558 > index 4e22ce656b..de5c28d00d 100755 > --- a/tests/generic/558 > +++ b/tests/generic/558 > @@ -39,15 +39,21 @@ _scratch_mkfs_sized $((1024 * 1024 * 1024)) >>$seqres.full 2>&1 > _scratch_mount > > i=0 > -free_inode=`_get_free_inode $SCRATCH_MNT` > -file_per_dir=1000 > -loop=$((free_inode / file_per_dir + 1)) > +free_inodes=$(_get_free_inode $SCRATCH_MNT) > +nr_cpus=$(( $($here/src/feature -o) * 4 * LOAD_FACTOR )) > +echo "free inodes: $free_inodes nr_cpus: $nr_cpus" >> $seqres.full > + > +if ((free_inodes <= nr_cpus)); then > + nr_cpus=1 > + files_per_dir=$free_inodes > +else > + files_per_dir=$(( (free_inodes + nr_cpus - 1) / nr_cpus )) > +fi > mkdir -p $SCRATCH_MNT/testdir > > echo "Create $((loop * file_per_dir)) files in $SCRATCH_MNT/testdir" >>$seqres.full > -while [ $i -lt $loop ]; do > - create_file $SCRATCH_MNT/testdir $file_per_dir $i >>$seqres.full 2>&1 & > - let i=$i+1 > +for ((i = 0; i < nr_cpus; i++)); do > + create_file $SCRATCH_MNT/testdir $files_per_dir $i >>$seqres.full 2>&1 & > done > wait > >