18a272653SPeter Holm#!/bin/sh 28a272653SPeter Holm 38a272653SPeter Holm# 44d846d26SWarner Losh# SPDX-License-Identifier: BSD-2-Clause 58a272653SPeter Holm# 68a272653SPeter Holm# Copyright (c) 2021 Peter Holm <pho@FreeBSD.org> 78a272653SPeter Holm# 88a272653SPeter Holm# Redistribution and use in source and binary forms, with or without 98a272653SPeter Holm# modification, are permitted provided that the following conditions 108a272653SPeter Holm# are met: 118a272653SPeter Holm# 1. Redistributions of source code must retain the above copyright 128a272653SPeter Holm# notice, this list of conditions and the following disclaimer. 138a272653SPeter Holm# 2. Redistributions in binary form must reproduce the above copyright 148a272653SPeter Holm# notice, this list of conditions and the following disclaimer in the 158a272653SPeter Holm# documentation and/or other materials provided with the distribution. 168a272653SPeter Holm# 178a272653SPeter Holm# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 188a272653SPeter Holm# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 198a272653SPeter Holm# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 208a272653SPeter Holm# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 218a272653SPeter Holm# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 228a272653SPeter Holm# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 238a272653SPeter Holm# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 248a272653SPeter Holm# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 258a272653SPeter Holm# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 268a272653SPeter Holm# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 278a272653SPeter Holm# SUCH DAMAGE. 288a272653SPeter Holm# 298a272653SPeter Holm 308a272653SPeter Holm# No problems seen 318a272653SPeter Holm 328a272653SPeter Holm# fsync: giving up on dirty 0xc9659438: tag devfs, type VCHR 338a272653SPeter Holm# usecount 1, writecount 0, refcount 41 mountedhere 0xc96a2000 348a272653SPeter Holm# flags (VI_ACTIVE) 358a272653SPeter Holm# v_object 0xc9824aa0 ref 0 pages 355 cleanbuf 37 dirtybuf 2 368a272653SPeter Holm# lock type devfs: EXCL by thread 0xccbca6a0 (pid 42225, dd, tid 100234) 378a272653SPeter Holm# #0 0xc0c26533 at __lockmgr_args+0xae3 388a272653SPeter Holm# #1 0xc0d06cc3 at vop_stdlock+0x53 398a272653SPeter Holm# #2 0xc1212cc0 at VOP_LOCK1_APV+0xe0 408a272653SPeter Holm# #3 0xc0d2b24a at _vn_lock+0xba 418a272653SPeter Holm# #4 0xc0f3f22b at ffs_sync+0x34b 428a272653SPeter Holm# #5 0xc0f22343 at softdep_ast_cleanup_proc+0x213 438a272653SPeter Holm# #6 0xc0ca7fbb at userret+0x1ab 448a272653SPeter Holm# #7 0xc11e0618 at syscall+0x5e8 458a272653SPeter Holm# #8 0xc11cb09e at Xint0x80_syscall+0x2e 468a272653SPeter Holm# dev label/tmp 478a272653SPeter Holm 488a272653SPeter Holm. ../default.cfg 498a272653SPeter Holm 508a272653SPeter Holm[ -d $RUNDIR ] || mkdir -p $RUNDIR && 518a272653SPeter Holm find $RUNDIR -name "split.*" -delete 528a272653SPeter Holmexport LANG=C 538a272653SPeter Holms=0 548a272653SPeter Holmkfree=`df -k $RUNDIR | tail -1 | awk '{print $4}'` 558a272653SPeter Holm[ $kfree -gt 100 ] && kfree=$((kfree - 100)) 568a272653SPeter Holmparallel=$((`sysctl -n hw.ncpu` + 1)) 578a272653SPeter Holmparallel=2 588a272653SPeter Holmcap=$((9 * 1024 * 1024)) # 9GB 598a272653SPeter Holmmx=$((kfree / parallel / 2)) 608a272653SPeter Holm[ $mx -gt $cap ] && mx=$cap 618a272653SPeter Holm 628a272653SPeter Holmrun() { 638a272653SPeter Holm local blocks md5 md5a orig s spmax spmin 648a272653SPeter Holm 658a272653SPeter Holm s=0 668a272653SPeter Holm cd $RUNDIR 678a272653SPeter Holm blocks=`jot -r 1 1 $mx` 688a272653SPeter Holm dd if=/dev/random of=file.$1 bs=1023 count=$blocks status=none 698a272653SPeter Holm orig=`ls -l file.$1 | tail -1` 708a272653SPeter Holm md5=`md5 -q file.$1` 718a272653SPeter Holm spmin=$((1023 * 4)) 728a272653SPeter Holm spmax=$((1023 * blocks / 2)) 738a272653SPeter Holm rm -f split.$1.* 748a272653SPeter Holm split -a 4 -b `jot -r 1 $spmin $spmax` file.$1 split.$1. 758a272653SPeter Holm rm file.$1 768a272653SPeter Holm cat split.$1.* > file.$1 778a272653SPeter Holm rm split.$1.* 788a272653SPeter Holm md5a=`md5 -q file.$1` 798a272653SPeter Holm if [ $md5 != $md5a ]; then 808a272653SPeter Holm echo FAIL 818a272653SPeter Holm echo "orig $orig $md5" 828a272653SPeter Holm orig=`ls -l file.$1 | tail -1` 838a272653SPeter Holm echo "new $orig $md5a" 848a272653SPeter Holm s=1 858a272653SPeter Holm fi 868a272653SPeter Holm rm file.$1 878a272653SPeter Holm return $s 888a272653SPeter Holm 898a272653SPeter Holm} 908a272653SPeter Holm 918a272653SPeter Holmfor i in `jot $parallel`; do 928a272653SPeter Holm run $i & 938a272653SPeter Holm pids="$pids $!" 948a272653SPeter Holmdone 958a272653SPeter Holmfor pid in $pids; do 968a272653SPeter Holm wait $pid 978a272653SPeter Holm [ $? -ne 0 ] && s=1 988a272653SPeter Holmdone 998a272653SPeter Holmexit $s 100