]> git.proxmox.com Git - ceph.git/blame - ceph/src/script/smr_benchmark/linearCopy.sh
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / script / smr_benchmark / linearCopy.sh
CommitLineData
11fdf7f2 1#!/usr/bin/env bash
7c673cae
FG
2
3# copy a linear file from srcFile to destination disk in a loop until writeSize MBs is written
4# destinationDisk is a SMR Host Aware Disk eg. /dev/sdb
5
6if [ "$#" -lt 3 ]; then
7 echo "Usage ./linearCopy.sh srcFile destinationDisk writeSize(MB)"
8 exit
9fi
10
11if [ "$(id -u)" != "0" ]; then
12 echo "Please run as sudo user"
13 exit
14fi
15
16srcFile=$1
17destDisk=$2
18writeSize=$3
19verbose=true
20
21if [ -f time ]; then
22 rm -rf time
23fi
24
25#chunkSize=4096 # in bytes
26chunkSize=1048576 # in bytes
27fileSize=`stat --printf="%s" $srcFile`
28
29numChunksInFile=`echo "$fileSize * (1048576 / $chunkSize)" | bc`
30chunksLeft=$(( $(($writeSize * 1048576)) / $chunkSize))
31
32
33echo "fileSize = $fileSize"
34
35if [ "$(($fileSize % 512))" -ne 0 ]; then
36 echo "$srcFile not 512 byte aligned"
37 exit
38fi
39
40if [ "$(($chunkSize % 512))" -ne 0 ]; then
41 echo "$chunkSize not 512 byte aligned"
42 exit
43fi
44
45if [ "$fileSize" -lt "$chunkSize" ]; then
46 echo "filesize $fileSize should be greater than chunkSize $chunkSize"
47 exit
48fi
49
50
51numFileChunks=$(($fileSize / $chunkSize))
52if [ $verbose == true ]; then
53 echo "numFileChunks = $numFileChunks"
54fi
55
56smrLBAStart=33554432 # TODO query from SMR Drive
57#smrLBAStart=37224448
58
59offset=$(( $smrLBAStart / $(( $chunkSize / 512)) ))
60
61if [ $verbose == true ]; then
62 echo "chunksLeft = $chunksLeft, offset = $offset"
63fi
64
65chunkNum=0
66
67while [ "$chunksLeft" -gt 0 ]; do
68 chunkNum=$(($chunkNum + 1))
69 if [ $verbose == true ]; then
70 echo "CHUNK $chunkNum `date +%H:%M:%S`" >> time
71 fi
72 dd if=$srcFile of=$destDisk seek=$offset bs=$chunkSize 2> tmp
73 cat tmp | grep MB >> time # > /dev/null 2>&1
74 if [ $verbose == true ]; then
75 echo "chunksLeft = $chunksLeft, offset = $offset"
76 fi
77 chunksLeft=$(($chunksLeft - $numFileChunks))
78 offset=$(($offset + $numFileChunks))
79done
80
81if [ -f tmp ]; then
82 rm tmp
83fi
84
85if [ $verbose == false ]; then
86 rm time
87else
88 echo "Time Stamp for Chunk Writes"
89 cat time
90 rm time
91fi