X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fceph%2Fsrc%2Fscript%2Fsmr_benchmark%2FlinearCopy.sh;fp=src%2Fceph%2Fsrc%2Fscript%2Fsmr_benchmark%2FlinearCopy.sh;h=30a6044a86ec6548a79a4375c6ff59c1960f0220;hb=812ff6ca9fcd3e629e49d4328905f33eee8ca3f5;hp=0000000000000000000000000000000000000000;hpb=15280273faafb77777eab341909a3f495cf248d9;p=stor4nfv.git diff --git a/src/ceph/src/script/smr_benchmark/linearCopy.sh b/src/ceph/src/script/smr_benchmark/linearCopy.sh new file mode 100755 index 0000000..30a6044 --- /dev/null +++ b/src/ceph/src/script/smr_benchmark/linearCopy.sh @@ -0,0 +1,91 @@ +#! /bin/bash + +# copy a linear file from srcFile to destination disk in a loop until writeSize MBs is written +# destinationDisk is a SMR Host Aware Disk eg. /dev/sdb + +if [ "$#" -lt 3 ]; then + echo "Usage ./linearCopy.sh srcFile destinationDisk writeSize(MB)" + exit +fi + +if [ "$(id -u)" != "0" ]; then + echo "Please run as sudo user" + exit +fi + +srcFile=$1 +destDisk=$2 +writeSize=$3 +verbose=true + +if [ -f time ]; then + rm -rf time +fi + +#chunkSize=4096 # in bytes +chunkSize=1048576 # in bytes +fileSize=`stat --printf="%s" $srcFile` + +numChunksInFile=`echo "$fileSize * (1048576 / $chunkSize)" | bc` +chunksLeft=$(( $(($writeSize * 1048576)) / $chunkSize)) + + +echo "fileSize = $fileSize" + +if [ "$(($fileSize % 512))" -ne 0 ]; then + echo "$srcFile not 512 byte aligned" + exit +fi + +if [ "$(($chunkSize % 512))" -ne 0 ]; then + echo "$chunkSize not 512 byte aligned" + exit +fi + +if [ "$fileSize" -lt "$chunkSize" ]; then + echo "filesize $fileSize should be greater than chunkSize $chunkSize" + exit +fi + + +numFileChunks=$(($fileSize / $chunkSize)) +if [ $verbose == true ]; then + echo "numFileChunks = $numFileChunks" +fi + +smrLBAStart=33554432 # TODO query from SMR Drive +#smrLBAStart=37224448 + +offset=$(( $smrLBAStart / $(( $chunkSize / 512)) )) + +if [ $verbose == true ]; then + echo "chunksLeft = $chunksLeft, offset = $offset" +fi + +chunkNum=0 + +while [ "$chunksLeft" -gt 0 ]; do + chunkNum=$(($chunkNum + 1)) + if [ $verbose == true ]; then + echo "CHUNK $chunkNum `date +%H:%M:%S`" >> time + fi + dd if=$srcFile of=$destDisk seek=$offset bs=$chunkSize 2> tmp + cat tmp | grep MB >> time # > /dev/null 2>&1 + if [ $verbose == true ]; then + echo "chunksLeft = $chunksLeft, offset = $offset" + fi + chunksLeft=$(($chunksLeft - $numFileChunks)) + offset=$(($offset + $numFileChunks)) +done + +if [ -f tmp ]; then + rm tmp +fi + +if [ $verbose == false ]; then + rm time +else + echo "Time Stamp for Chunk Writes" + cat time + rm time +fi