diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 18:24:20 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 18:24:20 +0000 |
commit | 483eb2f56657e8e7f419ab1a4fab8dce9ade8609 (patch) | |
tree | e5d88d25d870d5dedacb6bbdbe2a966086a0a5cf /src/script/smr_benchmark/linearCopy.sh | |
parent | Initial commit. (diff) | |
download | ceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.tar.xz ceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.zip |
Adding upstream version 14.2.21.upstream/14.2.21upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/script/smr_benchmark/linearCopy.sh')
-rwxr-xr-x | src/script/smr_benchmark/linearCopy.sh | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/src/script/smr_benchmark/linearCopy.sh b/src/script/smr_benchmark/linearCopy.sh new file mode 100755 index 00000000..416a7e74 --- /dev/null +++ b/src/script/smr_benchmark/linearCopy.sh @@ -0,0 +1,91 @@ +#!/usr/bin/env 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 |