#!/bin/bash

bs=(64k 128k 256k 512k)

su=(65536 131072 262144 524288)

nj=(50 100 150 200)

name=${HOSTNAME%%.*}

cd "/mnt/ceph"

for i in "${su[@]}"
do 
    for j in "${bs[@]}" 
    do
        for k in "${nj[@]}"
        do 
            mkdir "/mnt/ceph/test_fio_"$name"_su_"$i"_bs_"$j"_nj_"$k

            setfattr -n ceph.dir.layout.stripe_unit -v $i "/mnt/ceph/test_fio_"$name"_su_"$i"_bs_"$j"_nj_"$k 
            setfattr -n ceph.dir.layout.stripe_count -v 8 "/mnt/ceph/test_fio_"$name"_su_"$i"_bs_"$j"_nj_"$k
            setfattr -n ceph.dir.layout.object_size -v 4194304 "/mnt/ceph/test_fio_"$name"_su_"$i"_bs_"$j"_nj_"$k

            cd "/mnt/ceph/test_fio_"$name"_su_"$i"_bs_"$j"_nj_"$k

            fio --name=randwrite --ioengine=libaio --iodepth=64 --rw=randwrite --bs=$j --size=8G --numjobs=$k --runtime=180 --group_reporting --direct=1 > fio_test.log
        done
    done
done
