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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
|
#!/usr/bin/env bash
source $CEPH_ROOT/qa/standalone/ceph-helpers.sh
[ `uname` = FreeBSD ] && exit 0
function run() {
local dir=$1
shift
local funcs=${@:-$(set | sed -n -e 's/^\(TEST_[0-9a-z_]*\) .*/\1/p')}
for func in $funcs ; do
setup $dir || return 1
$func $dir || return 1
teardown $dir || return 1
done
}
function TEST_bluestore() {
local dir=$1
local flimit=$(ulimit -n)
if [ $flimit -lt 1536 ]; then
echo "Low open file limit ($flimit), test may fail. Increase to 1536 or higher and retry if that happens."
fi
export CEPH_MON="127.0.0.1:7146" # git grep '\<7146\>' : there must be only one
export CEPH_ARGS
CEPH_ARGS+="--fsid=$(uuidgen) --auth-supported=none "
CEPH_ARGS+="--mon-host=$CEPH_MON "
CEPH_ARGS+="--bluestore_block_size=2147483648 "
CEPH_ARGS+="--bluestore_block_db_create=true "
CEPH_ARGS+="--bluestore_block_db_size=1073741824 "
CEPH_ARGS+="--bluestore_block_wal_size=536870912 "
CEPH_ARGS+="--bluestore_block_wal_create=true "
CEPH_ARGS+="--bluestore_fsck_on_mount=true "
run_mon $dir a || return 1
run_mgr $dir x || return 1
run_osd $dir 0 || return 1
osd_pid0=$(cat $dir/osd.0.pid)
run_osd $dir 1 || return 1
osd_pid1=$(cat $dir/osd.1.pid)
run_osd $dir 2 || return 1
osd_pid2=$(cat $dir/osd.2.pid)
run_osd $dir 3 || return 1
osd_pid3=$(cat $dir/osd.3.pid)
sleep 5
create_pool foo 16
# write some objects
timeout 60 rados bench -p foo 30 write -b 4096 --no-cleanup #|| return 1
echo "after bench"
# kill
while kill $osd_pid0; do sleep 1 ; done
ceph osd down 0
while kill $osd_pid1; do sleep 1 ; done
ceph osd down 1
while kill $osd_pid2; do sleep 1 ; done
ceph osd down 2
while kill $osd_pid3; do sleep 1 ; done
ceph osd down 3
# expand slow devices
ceph-bluestore-tool --path $dir/0 fsck || return 1
ceph-bluestore-tool --path $dir/1 fsck || return 1
ceph-bluestore-tool --path $dir/2 fsck || return 1
ceph-bluestore-tool --path $dir/3 fsck || return 1
truncate $dir/0/block -s 4294967296 # 4GB
ceph-bluestore-tool --path $dir/0 bluefs-bdev-expand || return 1
truncate $dir/1/block -s 11811160064 # 11GB to get bdev label at 10737418240
ceph-bluestore-tool --path $dir/1 bluefs-bdev-expand || return 1
truncate $dir/2/block -s 4295099392 # 4GB + 129KB
ceph-bluestore-tool --path $dir/2 bluefs-bdev-expand || return 1
truncate $dir/3/block -s 4293918720 # 4GB - 1MB
ceph-bluestore-tool --path $dir/3 bluefs-bdev-expand || return 1
# slow, DB, WAL -> slow, DB
ceph-bluestore-tool --path $dir/0 fsck || return 1
ceph-bluestore-tool --path $dir/1 fsck || return 1
ceph-bluestore-tool --path $dir/2 fsck || return 1
ceph-bluestore-tool --path $dir/3 fsck || return 1
ceph-bluestore-tool --path $dir/0 bluefs-bdev-sizes
ceph-bluestore-tool --path $dir/0 \
--devs-source $dir/0/block.wal \
--dev-target $dir/0/block.db \
--command bluefs-bdev-migrate || return 1
ceph-bluestore-tool --path $dir/0 fsck || return 1
# slow, DB, WAL -> slow, WAL
ceph-bluestore-tool --path $dir/1 \
--devs-source $dir/1/block.db \
--dev-target $dir/1/block \
--command bluefs-bdev-migrate || return 1
ceph-bluestore-tool --path $dir/1 fsck || return 1
# slow, DB, WAL -> slow
ceph-bluestore-tool --path $dir/2 \
--devs-source $dir/2/block.wal \
--devs-source $dir/2/block.db \
--dev-target $dir/2/block \
--command bluefs-bdev-migrate || return 1
ceph-bluestore-tool --path $dir/2 fsck || return 1
# slow, DB, WAL -> slow, WAL (negative case)
ceph-bluestore-tool --path $dir/3 \
--devs-source $dir/3/block.db \
--dev-target $dir/3/block.wal \
--command bluefs-bdev-migrate
# Migration to WAL is unsupported
if [ $? -eq 0 ]; then
return 1
fi
ceph-bluestore-tool --path $dir/3 fsck || return 1
# slow, DB, WAL -> slow, DB (WAL to slow then slow to DB)
ceph-bluestore-tool --path $dir/3 \
--devs-source $dir/3/block.wal \
--dev-target $dir/3/block \
--command bluefs-bdev-migrate || return 1
ceph-bluestore-tool --path $dir/3 fsck || return 1
ceph-bluestore-tool --path $dir/3 \
--devs-source $dir/3/block \
--dev-target $dir/3/block.db \
--command bluefs-bdev-migrate || return 1
ceph-bluestore-tool --path $dir/3 fsck || return 1
activate_osd $dir 0 || return 1
osd_pid0=$(cat $dir/osd.0.pid)
activate_osd $dir 1 || return 1
osd_pid1=$(cat $dir/osd.1.pid)
activate_osd $dir 2 || return 1
osd_pid2=$(cat $dir/osd.2.pid)
activate_osd $dir 3 || return 1
osd_pid3=$(cat $dir/osd.3.pid)
wait_for_clean || return 1
# write some objects
timeout 60 rados bench -p foo 30 write -b 4096 --no-cleanup #|| return 1
# kill
while kill $osd_pid0; do sleep 1 ; done
ceph osd down 0
while kill $osd_pid1; do sleep 1 ; done
ceph osd down 1
while kill $osd_pid2; do sleep 1 ; done
ceph osd down 2
while kill $osd_pid3; do sleep 1 ; done
ceph osd down 3
# slow, DB -> slow, DB, WAL
ceph-bluestore-tool --path $dir/0 fsck || return 1
dd if=/dev/zero of=$dir/0/wal count=512 bs=1M
ceph-bluestore-tool --path $dir/0 \
--dev-target $dir/0/wal \
--command bluefs-bdev-new-wal || return 1
ceph-bluestore-tool --path $dir/0 fsck || return 1
# slow, WAL -> slow, DB, WAL
ceph-bluestore-tool --path $dir/1 fsck || return 1
dd if=/dev/zero of=$dir/1/db count=1024 bs=1M
ceph-bluestore-tool --path $dir/1 \
--dev-target $dir/1/db \
--command bluefs-bdev-new-db || return 1
ceph-bluestore-tool --path $dir/1 \
--devs-source $dir/1/block \
--dev-target $dir/1/block.db \
--command bluefs-bdev-migrate || return 1
ceph-bluestore-tool --path $dir/1 fsck || return 1
# slow -> slow, DB, WAL
ceph-bluestore-tool --path $dir/2 fsck || return 1
ceph-bluestore-tool --path $dir/2 \
--command bluefs-bdev-new-db || return 1
ceph-bluestore-tool --path $dir/2 \
--command bluefs-bdev-new-wal || return 1
ceph-bluestore-tool --path $dir/2 \
--devs-source $dir/2/block \
--dev-target $dir/2/block.db \
--command bluefs-bdev-migrate || return 1
ceph-bluestore-tool --path $dir/2 fsck || return 1
# slow, DB -> slow, WAL
ceph-bluestore-tool --path $dir/3 fsck || return 1
ceph-bluestore-tool --path $dir/3 \
--command bluefs-bdev-new-wal || return 1
ceph-bluestore-tool --path $dir/3 \
--devs-source $dir/3/block.db \
--dev-target $dir/3/block \
--command bluefs-bdev-migrate || return 1
ceph-bluestore-tool --path $dir/3 fsck || return 1
activate_osd $dir 0 || return 1
osd_pid0=$(cat $dir/osd.0.pid)
activate_osd $dir 1 || return 1
osd_pid1=$(cat $dir/osd.1.pid)
activate_osd $dir 2 || return 1
osd_pid2=$(cat $dir/osd.2.pid)
activate_osd $dir 3 || return 1
osd_pid3=$(cat $dir/osd.3.pid)
# write some objects
timeout 60 rados bench -p foo 30 write -b 4096 --no-cleanup #|| return 1
# kill
while kill $osd_pid0; do sleep 1 ; done
ceph osd down 0
while kill $osd_pid1; do sleep 1 ; done
ceph osd down 1
while kill $osd_pid2; do sleep 1 ; done
ceph osd down 2
while kill $osd_pid3; do sleep 1 ; done
ceph osd down 3
# slow, DB1, WAL -> slow, DB2, WAL
ceph-bluestore-tool --path $dir/0 fsck || return 1
dd if=/dev/zero of=$dir/0/db2 count=1024 bs=1M
ceph-bluestore-tool --path $dir/0 \
--devs-source $dir/0/block.db \
--dev-target $dir/0/db2 \
--command bluefs-bdev-migrate || return 1
ceph-bluestore-tool --path $dir/0 fsck || return 1
# slow, DB, WAL1 -> slow, DB, WAL2
dd if=/dev/zero of=$dir/0/wal2 count=512 bs=1M
ceph-bluestore-tool --path $dir/0 \
--devs-source $dir/0/block.wal \
--dev-target $dir/0/wal2 \
--command bluefs-bdev-migrate || return 1
rm -rf $dir/0/wal
ceph-bluestore-tool --path $dir/0 fsck || return 1
# slow, DB + WAL -> slow, DB2 -> slow
ceph-bluestore-tool --path $dir/1 fsck || return 1
dd if=/dev/zero of=$dir/1/db2 count=1024 bs=1M
ceph-bluestore-tool --path $dir/1 \
--devs-source $dir/1/block.db \
--devs-source $dir/1/block.wal \
--dev-target $dir/1/db2 \
--command bluefs-bdev-migrate || return 1
rm -rf $dir/1/db
ceph-bluestore-tool --path $dir/1 fsck || return 1
ceph-bluestore-tool --path $dir/1 \
--devs-source $dir/1/block.db \
--dev-target $dir/1/block \
--command bluefs-bdev-migrate || return 1
rm -rf $dir/1/db2
ceph-bluestore-tool --path $dir/1 fsck || return 1
# slow -> slow, DB (negative case)
ceph-objectstore-tool --type bluestore --data-path $dir/2 \
--op fsck --no-mon-config || return 1
dd if=/dev/zero of=$dir/2/db2 count=1024 bs=1M
ceph-bluestore-tool --path $dir/2 \
--devs-source $dir/2/block \
--dev-target $dir/2/db2 \
--command bluefs-bdev-migrate
# Migration from slow-only to new device is unsupported
if [ $? -eq 0 ]; then
return 1
fi
ceph-bluestore-tool --path $dir/2 fsck || return 1
# slow + DB + WAL -> slow, DB2
dd if=/dev/zero of=$dir/2/db2 count=1024 bs=1M
ceph-bluestore-tool --path $dir/2 \
--devs-source $dir/2/block \
--devs-source $dir/2/block.db \
--devs-source $dir/2/block.wal \
--dev-target $dir/2/db2 \
--command bluefs-bdev-migrate || return 1
ceph-bluestore-tool --path $dir/2 fsck || return 1
# slow + WAL -> slow2, WAL2
dd if=/dev/zero of=$dir/3/wal2 count=1024 bs=1M
ceph-bluestore-tool --path $dir/3 \
--devs-source $dir/3/block \
--devs-source $dir/3/block.wal \
--dev-target $dir/3/wal2 \
--command bluefs-bdev-migrate || return 1
ceph-bluestore-tool --path $dir/3 fsck || return 1
activate_osd $dir 0 || return 1
osd_pid0=$(cat $dir/osd.0.pid)
activate_osd $dir 1 || return 1
osd_pid1=$(cat $dir/osd.1.pid)
activate_osd $dir 2 || return 1
osd_pid2=$(cat $dir/osd.2.pid)
activate_osd $dir 3 || return 1
osd_pid3=$(cat $dir/osd.3.pid)
# write some objects
timeout 60 rados bench -p foo 30 write -b 4096 --no-cleanup #|| return 1
wait_for_clean || return 1
}
function TEST_bluestore2() {
local dir=$1
local flimit=$(ulimit -n)
if [ $flimit -lt 1536 ]; then
echo "Low open file limit ($flimit), test may fail. Increase to 1536 or higher and retry if that happens."
fi
export CEPH_MON="127.0.0.1:7146" # git grep '\<7146\>' : there must be only one
export CEPH_ARGS
CEPH_ARGS+="--fsid=$(uuidgen) --auth-supported=none "
CEPH_ARGS+="--mon-host=$CEPH_MON "
CEPH_ARGS+="--bluestore_block_size=4294967296 "
CEPH_ARGS+="--bluestore_block_db_create=true "
CEPH_ARGS+="--bluestore_block_db_size=1073741824 "
CEPH_ARGS+="--bluestore_block_wal_create=false "
CEPH_ARGS+="--bluestore_fsck_on_mount=true "
CEPH_ARGS+="--osd_pool_default_size=1 "
CEPH_ARGS+="--osd_pool_default_min_size=1 "
CEPH_ARGS+="--bluestore_debug_enforce_settings=ssd "
run_mon $dir a || return 1
run_mgr $dir x || return 1
run_osd $dir 0 || return 1
osd_pid0=$(cat $dir/osd.0.pid)
sleep 5
create_pool foo 16
retry = 0
while [[ $retry -le 5 ]]; do
# write some objects
timeout 60 rados bench -p foo 10 write --write-omap --no-cleanup #|| return 1
#give RocksDB some time to cooldown and put files to slow level(s)
sleep 10
db_used=$( ceph tell osd.0 perf dump bluefs | jq ".bluefs.db_used_bytes" )
spilled_over=$( ceph tell osd.0 perf dump bluefs | jq ".bluefs.slow_used_bytes" )
((retry+=1))
test $spilled_over -eq 0 || break
done
test $spilled_over -gt 0 || return 1
while kill $osd_pid0; do sleep 1 ; done
ceph osd down 0
ceph-bluestore-tool --path $dir/0 \
--devs-source $dir/0/block.db \
--dev-target $dir/0/block \
--command bluefs-bdev-migrate || return 1
ceph-bluestore-tool --path $dir/0 \
--command bluefs-bdev-sizes || return 1
ceph-bluestore-tool --path $dir/0 \
--command fsck || return 1
activate_osd $dir 0 || return 1
osd_pid0=$(cat $dir/osd.0.pid)
wait_for_clean || return 1
}
function TEST_bluestore_expand() {
local dir=$1
local flimit=$(ulimit -n)
if [ $flimit -lt 1536 ]; then
echo "Low open file limit ($flimit), test may fail. Increase to 1536 or higher and retry if that happens."
fi
export CEPH_MON="127.0.0.1:7146" # git grep '\<7146\>' : there must be only one
export CEPH_ARGS
CEPH_ARGS+="--fsid=$(uuidgen) --auth-supported=none "
CEPH_ARGS+="--mon-host=$CEPH_MON "
CEPH_ARGS+="--bluestore_block_size=4294967296 "
CEPH_ARGS+="--bluestore_block_db_create=true "
CEPH_ARGS+="--bluestore_block_db_size=1073741824 "
CEPH_ARGS+="--bluestore_block_wal_create=false "
CEPH_ARGS+="--bluestore_fsck_on_mount=true "
CEPH_ARGS+="--osd_pool_default_size=1 "
CEPH_ARGS+="--osd_pool_default_min_size=1 "
CEPH_ARGS+="--bluestore_debug_enforce_settings=ssd "
run_mon $dir a || return 1
run_mgr $dir x || return 1
run_osd $dir 0 || return 1
osd_pid0=$(cat $dir/osd.0.pid)
sleep 5
create_pool foo 16
# write some objects
timeout 60 rados bench -p foo 30 write -b 4096 --no-cleanup #|| return 1
sleep 5
total_space_before=$( ceph tell osd.0 perf dump bluefs | jq ".bluefs.slow_total_bytes" )
free_space_before=`ceph tell osd.0 bluestore bluefs device info | grep "BDEV_SLOW" -A 2 | grep free | cut -d':' -f 2 | cut -d"," -f 1 | cut -d' ' -f 2`
# kill
while kill $osd_pid0; do sleep 1 ; done
ceph osd down 0
# destage allocation to file before expand (in case fast-shutdown skipped that step)
ceph-bluestore-tool --log-file $dir/bluestore_tool.log --path $dir/0 allocmap || return 1
# expand slow devices
ceph-bluestore-tool --log-file $dir/bluestore_tool.log --path $dir/0 fsck || return 1
requested_space=4294967296 # 4GB
truncate $dir/0/block -s $requested_space
ceph-bluestore-tool --log-file $dir/bluestore_tool.log --path $dir/0 bluefs-bdev-expand || return 1
# slow, DB, WAL -> slow, DB
ceph-bluestore-tool --log-file $dir/bluestore_tool.log --path $dir/0 fsck || return 1
# compare allocation-file with RocksDB state
ceph-bluestore-tool --log-file $dir/bluestore_tool.log --path $dir/0 qfsck || return 1
ceph-bluestore-tool --log-file $dir/bluestore_tool.log --path $dir/0 bluefs-bdev-sizes
activate_osd $dir 0 || return 1
osd_pid0=$(cat $dir/osd.0.pid)
wait_for_clean || return 1
total_space_after=$( ceph tell osd.0 perf dump bluefs | jq ".bluefs.slow_total_bytes" )
free_space_after=`ceph tell osd.0 bluestore bluefs device info | grep "BDEV_SLOW" -A 2 | grep free | cut -d':' -f 2 | cut -d"," -f 1 | cut -d' ' -f 2`
if [$total_space_after != $requested_space]; then
echo "total_space_after = $total_space_after"
echo "requested_space = $requested_space"
return 1;
fi
total_space_added=$((total_space_after - total_space_before))
free_space_added=$((free_space_after - free_space_before))
let new_used_space=($total_space_added - $free_space_added)
echo $new_used_space
# allow upto 128KB to be consumed
if [ $new_used_space -gt 131072 ]; then
echo "total_space_added = $total_space_added"
echo "free_space_added = $free_space_added"
return 1;
fi
# kill
while kill $osd_pid0; do sleep 1 ; done
ceph osd down 0
ceph-bluestore-tool --log-file $dir/bluestore_tool.log --path $dir/0 qfsck || return 1
}
main osd-bluefs-volume-ops "$@"
# Local Variables:
# compile-command: "cd ../.. ; make -j4 && test/osd/osd-bluefs-volume-ops.sh"
# End:
|