#!/bin/ksh set -e mp=/var/tmp/bonnie [[ ! -b /dev/thin/bonnie ]] && echo could not find block device /dev/thin/bonnie && exit 1 [[ ! -d $mp/ ]] && echo create $mp/ first && exit 1 function check_no_mount { tmp=`mount | grep $mp` [[ -n $tmp ]] && echo "$tmp" && exit 1 unset tmp } function check_mount { tmp=`mount | grep $mp` [[ -z $tmp ]] && echo not mounted && exit 1 unset tmp } function fsbench { [[ -z $1 ]] && echo function fsbench needs fs && exit 1 fs=$1 echo echo $fs echo check_no_mount sync sleep 1 blkdiscard /dev/thin/bonnie -f if [[ $fs = ext4 ]]; then mkfs.ext4 -O 64bit /dev/thin/bonnie tune2fs -l /dev/thin/bonnie > /var/tmp/$fs-features.txt mount -t ext4 /dev/thin/bonnie $mp/ elif [[ $fs = xfs ]]; then mkfs.xfs /dev/thin/bonnie xfs_info /dev/thin/bonnie > /var/tmp/$fs-features.txt mount -t xfs /dev/thin/bonnie $mp/ elif [[ $fs = btrfs ]]; then mkfs.btrfs /dev/thin/bonnie mount -t btrfs /dev/thin/bonnie $mp/ elif [[ $fs = btrfs-zlib ]]; then mkfs.btrfs /dev/thin/bonnie mount -t btrfs -o compress=zlib /dev/thin/bonnie $mp/ elif [[ $fs = btrfs-lzo ]]; then mkfs.btrfs /dev/thin/bonnie mount -t btrfs -o compress=lzo /dev/thin/bonnie $mp/ elif [[ $fs = btrfs-zstd ]]; then mkfs.btrfs /dev/thin/bonnie mount -t btrfs -o compress=zstd /dev/thin/bonnie $mp/ elif [[ $fs = reiser4-lzo1 ]]; then echo y | mkfs.reiser4 --discard -o compress=lzo1 /dev/thin/bonnie mount -t reiser4 -o txmod=wa /dev/thin/bonnie $mp/ elif [[ $fs = reiser4-zstd1 ]]; then echo y | mkfs.reiser4 --discard -o compress=zstd1 /dev/thin/bonnie mount -t reiser4 -o txmod=wa /dev/thin/bonnie $mp/ elif [[ $fs = reiser4-gzip1 ]]; then echo y | mkfs.reiser4 --discard -o compress=gzip1 /dev/thin/bonnie mount -t reiser4 -o txmod=wa /dev/thin/bonnie $mp/ elif [[ $fs = f2fs ]]; then mkfs.f2fs -O extra_attr,inode_checksum,sb_checksum,compression /dev/thin/bonnie mount -t f2fs -o compress_chksum,atgc,gc_merge,lazytime /dev/thin/bonnie $mp/ elif [[ $fs = f2fs-lz4 ]]; then mkfs.f2fs -O extra_attr,inode_checksum,sb_checksum,compression /dev/thin/bonnie mount -t f2fs -o compress_algorithm=lz4,compress_extension=*,compress_chksum,atgc,gc_merge,lazytime \ /dev/thin/bonnie $mp/ elif [[ $fs = f2fs-lzo-rle ]]; then mkfs.f2fs -O extra_attr,inode_checksum,sb_checksum,compression /dev/thin/bonnie mount -o compress_algorithm=lzo-rle,compress_extension=*,compress_chksum,atgc,gc_merge,lazytime \ /dev/thin/bonnie $mp/ elif [[ $fs = f2fs-zstd ]]; then mkfs.f2fs -O extra_attr,inode_checksum,sb_checksum,compression /dev/thin/bonnie mount -t f2fs -o compress_algorithm=zstd,compress_extension=*,compress_chksum,atgc,gc_merge,lazytime \ /dev/thin/bonnie $mp/ else echo donno about fs keyword $fs exit 1 fi check_mount mount | grep $mp > /var/tmp/$fs-mount-options.txt ## RAM 1G and direct I/O # RAM 1G bonnie++ -u root -x 5 -r 1024 -m $fs -d $mp/ | grep -v ^name, > /var/tmp/$fs.bon bon_csv2txt < /var/tmp/$fs.bon > /var/tmp/${fs%\.bon}.txt bon_csv2html < /var/tmp/$fs.bon > /var/tmp/${f%\.bon}.html # -D prevents reiser4 from working # Can't open file ./Bonnie.31002.0000 lsattr -a $mp/ > /var/tmp/$fs-lsattr.txt 2>/dev/null umount $mp/ echo all good for $fs unset fs } #chattr -c $mp/ #fsbench ext4 #fsbench xfs #fsbench btrfs #fsbench f2fs chattr +c $mp/ #fsbench btrfs-zlib #fsbench btrfs-lzo #fsbench btrfs-zstd #fsbench reiser4-gzip1 #fsbench reiser4-lzo1 #fsbench reiser4-zstd1 #fsbench f2fs-lz4 #fsbench f2fs-lzo-rle fsbench f2fs-zstd