liyujie
2025-08-28 b3810562527858a3b3d98ffa6e9c9c5b0f4a9a8e
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
#!/bin/sh
# This script should be run prior to running executing the filesystem tests.
# valid devices need to be passed for Device Mapper to work correctly
# 03/14/03 mridge@us.ibm.com added instance and time command line options
 
cd `dirname $0`
export LTPROOT=${PWD}
echo $LTPROOT | grep testscripts > /dev/null 2>&1
if [ $? -eq 0 ]; then
 cd ..
 export LTPROOT=${PWD}
fi
 
export TMPBASE="/tmp"
 
 
usage()
{
   cat <<-END >&2
   usage: ${0##*/} [ -a part1 ] [ -b part2 ]
 
   Note: In order to run this test, you must turn on "device mapper"
        component in kernel (it is under device drivers item when you
        run make menuconfig); and you must install userspace supporting
        files (libdevmapper and dmsetup). They are in the device-mapper
        package. You can download it from http://www.sistina.com. Follow
        the README/INSTALL file within the package to install it.
 
 
   defaults:
   part1=$part1
   part2=$part2
   ltproot=$LTPROOT
   tmpdir=$TMPBASE
 
   example: ${0##*/} -a hdc1 -b hdc2
 
 
   END
exit
}
 
while getopts :a:b: arg
do      case $arg in
       a)    part1=$OPTARG;;
                b)      part2=$OPTARG;;
 
                \?)     echo "************** Help Info: ********************"
                        usage;;
        esac
done
 
if [ ! -n "$part1"  ]; then
  echo "Missing 1st partition. You must pass 2 partitions for testing"
  usage;
  exit
fi
 
if [ ! -n "$part2" ]; then
  echo "Missing 2nd partition. You must pass 2 partitions for testing"
  usage;
  exit
fi
 
echo "Starting Device Mapper Tests..."
 
echo "0 10240 linear " $part1 "0" > ltp-dev-mapper-table1
echo "0 100000 linear " $part1 "0" > ltp-dev-mapper-table2
echo "0 100000 linear " $part2 "0" > ltp-dev-mapper-table3
echo "0 200000 striped 2 16 " $part1 "0" $part2 "0" > ltp-dev-mapper-table4
 
echo "Creating Devices..."
 
dmsetup create dm-test-1 ltp-dev-mapper-table1
dmsetup create dm-test-2 ltp-dev-mapper-table2
dmsetup create dm-test-3 ltp-dev-mapper-table3
dmsetup create dm-test-4 ltp-dev-mapper-table4
 
echo "Device Info..."
 
dmsetup info dm-test-1
dmsetup info dm-test-2
dmsetup info dm-test-3
dmsetup info dm-test-4
 
echo "Device Dependancies..."
 
dmsetup deps dm-test-1
dmsetup deps dm-test-2
dmsetup deps dm-test-3
dmsetup deps dm-test-4
 
echo "Device Status..."
 
dmsetup status dm-test-1
dmsetup status dm-test-2
dmsetup status dm-test-3
dmsetup status dm-test-4
 
echo "Device Tables..."
 
dmsetup table dm-test-1
dmsetup table dm-test-2
dmsetup table dm-test-3
dmsetup table dm-test-4
 
echo "Device Mapper Version..."
 
dmsetup version
 
echo "Device Waiting..."
 
#dmsetup wait dm-test-1
#dmsetup wait dm-test-2
#dmsetup wait dm-test-3
#dmsetup wait dm-test-4
 
echo "Device Mapper Removing Devices..."
 
dmsetup remove dm-test-1
dmsetup remove dm-test-2
dmsetup remove dm-test-3
dmsetup remove dm-test-4
 
echo "Device Mapper Re-Creating Devices..."
 
dmsetup create dm-test-1 ltp-dev-mapper-table1
dmsetup create dm-test-2 ltp-dev-mapper-table2
dmsetup create dm-test-3 ltp-dev-mapper-table3
dmsetup create dm-test-4 ltp-dev-mapper-table4
 
echo "Re-Naming Devices..."
 
dmsetup rename dm-test-1 dm-test-1-new
dmsetup rename dm-test-2 dm-test-2-new
dmsetup rename dm-test-3 dm-test-3-new
dmsetup rename dm-test-4 dm-test-4-new
 
echo "Suspend Devices..."
 
dmsetup suspend dm-test-1-new
dmsetup suspend dm-test-2-new
dmsetup suspend dm-test-3-new
dmsetup suspend dm-test-4-new
 
echo "0 102400 linear " $part1 "0" > ltp-dev-mapper-table1
echo "0 200000 linear " $part1 "0" > ltp-dev-mapper-table2
echo "0 200000 linear " $part2 "0" > ltp-dev-mapper-table3
echo "0 400000 striped 2 16 " $part1 "0" $part2 "0" > ltp-dev-mapper-table4
 
echo "Re-loading Devices..."
 
dmsetup reload dm-test-1-new ltp-dev-mapper-table1
dmsetup reload dm-test-2-new ltp-dev-mapper-table2
dmsetup reload dm-test-3-new ltp-dev-mapper-table3
dmsetup reload dm-test-4-new ltp-dev-mapper-table4
 
echo "Resuming Devices..."
 
dmsetup resume dm-test-1-new
dmsetup resume dm-test-2-new
dmsetup resume dm-test-3-new
dmsetup resume dm-test-4-new
 
echo "Device Info..."
 
dmsetup info dm-test-1-new
dmsetup info dm-test-2-new
dmsetup info dm-test-3-new
dmsetup info dm-test-4-new
 
echo "Device Dependancies..."
 
dmsetup deps dm-test-1-new
dmsetup deps dm-test-2-new
dmsetup deps dm-test-3-new
dmsetup deps dm-test-4-new
 
echo "Device Status..."
 
dmsetup status dm-test-1-new
dmsetup status dm-test-2-new
dmsetup status dm-test-3-new
dmsetup status dm-test-4-new
 
echo "Device Tables..."
 
dmsetup table dm-test-1-new
dmsetup table dm-test-2-new
dmsetup table dm-test-3-new
dmsetup table dm-test-4-new
 
echo "Device Mapper Remove-all..."
 
dmsetup remove_all
 
echo "Device Mapper Checking Status - Shouldn't be anything to check"
 
dmsetup status dm-test-1-new
dmsetup status dm-test-2-new
dmsetup status dm-test-3-new
dmsetup status dm-test-4-new