summaryrefslogtreecommitdiff
path: root/tests/fs/bcachefs/benches.ktest
blob: 42ec05a44765ee94fb1db2bb8cb9d628f151e699 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/bash

. $(dirname $(readlink -e ${BASH_SOURCE[0]}))/bcachefs-test-libs.sh

config-scratch-devs 32G

config-timeout $(stress_timeout)

test_fsmark()
{
    QUOTA=
    MKFSOPTS=
    NFILES=10000
    DEV=/dev/sdb
    XATTR=""
    NO_FSCK=1
    NO_RM=0
    THREADS=16
    FSTYP=xfs
    FSTYP=bcachefs
     
    while [ $# -gt 0 ]; do
	case "$1" in
	-N)     NFILES=$2 ; shift ;;
	-d)     DEV=$2 ; shift ;;
	-X)     XATTR="-X $2"; shift ;;
	-r)     NO_RM=1 ;;
	-t)     THREADS=$2 ; shift ;;
	--)     shift ; break ;;
	esac
	shift
    done
    MKFSOPTS="$MKFSOPTS $*"
     
    sh -c "echo 3 > /proc/sys/vm/drop_caches"
     
    echo QUOTA=$QUOTA
    echo MKFSOPTS=$MKFSOPTS
    echo DEV=$DEV
    echo THREADS=$THREADS
     
    dirs=""
    for i in `seq 1 $THREADS`; do
	dirs="$dirs -d /mnt/scratch/$i"
    done
     
    cycles=$((512 / $THREADS))

    mkdir -p /mnt/scratch
     
    umount /mnt/scratch > /dev/null 2>&1 || true

    blkdiscard $DEV

    if [[ $FSTYP = xfs ]]; then
	mkfs.xfs -d agcount=75 $DEV
	mount -o logbsize=262144 $DEV /mnt/scratch
    else
	bcachefs format -f --version=14 --no_initialize --bucket=2M $DEV
	mount -o version_upgrade,shard_inode_numbers $DEV /mnt/scratch
	bcachefs device resize-journal $DEV 4G
	umount /mnt/scratch
	mount -o version_upgrade,shard_inode_numbers $DEV /mnt/scratch
    fi
     
    chmod 777 /mnt/scratch
    (cd /mnt/scratch; time fs_mark $XATTR -D 10000 -S0 -n $NFILES -s 0 -L $cycles $dirs)
    xfs_io -c syncfs /mnt/scratch/
    umount /mnt/scratch

    if [ $NO_FSCK = 0 ]; then
	echo Repair
	if [[ $FSTYP = xfs ]]; then
	    time xfs_repair $DEV 2>&1 | tail -25
	else
	    time fsck.$FSTYP $DEV 2>&1 | tail -25
	fi
    fi

    echo Mount
    time mount $DEV /mnt/scratch
     
    if [ $NO_RM -ne 0 ]; then
	    exit
    fi
     
    echo Removing files
    for f in /mnt/scratch/* ; do time rm -rf $f &  done
    wait
     
    umount /mnt/scratch
}

main "$@"