blob: 416a7e7423ce3e0540eb6ff4a44bb894bdac2735 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
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
|