@@ -2286,6 +2286,186 @@ test_203() {
2286
2286
}
2287
2287
run_test 203 " mirror file preserve mirror ID"
2288
2288
2289
+ # Simple test of FLR + self-extending layout, SEL in non-primary mirror
2290
+ test_204a () {
2291
+ [ $( lustre_version_code $SINGLEMDS ) -lt $( version_code $SEL_VER ) ] &&
2292
+ skip " skipped for lustre < $SEL_VER "
2293
+
2294
+ local comp_file=$DIR /$tdir /$tfile
2295
+ local flg_opts=" "
2296
+ local found=" "
2297
+
2298
+ test_mkdir $DIR /$tdir
2299
+
2300
+ # first mirror is 0-10M, then 10M-(-1), second mirror is 1M followed
2301
+ # by extension space to -1
2302
+ $LFS setstripe -N -E 10M -E-1 -N -E 1M -E-1 -z64M $comp_file ||
2303
+ error " Create $comp_file failed"
2304
+
2305
+ # Write to first component, extending & staling second mirror
2306
+ dd if=/dev/zero bs=2M count=1 of=$comp_file conv=notrunc ||
2307
+ error " dd to extend + stale failed"
2308
+
2309
+ $LFS getstripe $comp_file
2310
+
2311
+ flg_opts=" --component-flags init,stale"
2312
+ found=$( $LFS find --component-end 65M $flg_opts $comp_file | wc -l)
2313
+ [ $found -eq 1 ] || error " write: Second comp end incorrect"
2314
+
2315
+ flg_opts=" --component-flags extension"
2316
+ found=$( $LFS find --component-start 65M $flg_opts $comp_file | wc -l)
2317
+ [ $found -eq 1 ] || error " write: Third comp start incorrect"
2318
+
2319
+ # mirror resync should not change the extents
2320
+ $LFS mirror resync $comp_file
2321
+
2322
+ flg_opts=" --component-flags init"
2323
+ found=$( $LFS find --component-end 65M $flg_opts $comp_file | wc -l)
2324
+ [ $found -eq 1 ] || error " resync: Second comp end incorrect"
2325
+
2326
+ flg_opts=" --component-flags extension"
2327
+ found=$( $LFS find --component-start 65M $flg_opts $comp_file | wc -l)
2328
+ [ $found -eq 1 ] || error " resync: Third comp start incorrect"
2329
+
2330
+ sel_layout_sanity $comp_file 5
2331
+
2332
+ rm -f $comp_file
2333
+ }
2334
+ run_test 204a " FLR write/stale/resync tests with self-extending mirror"
2335
+
2336
+ # Simple test of FLR + self-extending layout, SEL in primary mirror
2337
+ test_204b () {
2338
+ [ $( lustre_version_code $SINGLEMDS ) -lt $( version_code $SEL_VER ) ] &&
2339
+ skip " skipped for lustre < $SEL_VER "
2340
+
2341
+ local comp_file=$DIR /$tdir /$tfile
2342
+ local flg_opts=" "
2343
+ local found=" "
2344
+
2345
+ test_mkdir $DIR /$tdir
2346
+
2347
+ # first mirror is 1M followed by extension space to -1, second mirror
2348
+ # is 0-10M, then 10M-(-1),
2349
+ $LFS setstripe -N -E 1M -E-1 -z64M -N -E 10M -E-1 $comp_file ||
2350
+ error " Create $comp_file failed"
2351
+
2352
+ # Write to first component, extending first component & staling
2353
+ # other mirror
2354
+ dd if=/dev/zero bs=2M count=1 of=$comp_file conv=notrunc ||
2355
+ error " dd to extend + stale failed"
2356
+
2357
+ $LFS getstripe $comp_file
2358
+
2359
+ flg_opts=" --component-flags init"
2360
+ found=$( $LFS find --component-end 65M $flg_opts $comp_file | wc -l)
2361
+ [ $found -eq 1 ] || error " write: First comp end incorrect"
2362
+
2363
+ flg_opts=" --component-flags extension"
2364
+ found=$( $LFS find --component-start 65M $flg_opts $comp_file | wc -l)
2365
+ [ $found -eq 1 ] || error " write: Second comp start incorrect"
2366
+
2367
+ flg_opts=" --component-flags init,stale"
2368
+ found=$( $LFS find --component-end 10M $flg_opts $comp_file | wc -l)
2369
+ [ $found -eq 1 ] || error " write: First mirror comp flags incorrect"
2370
+
2371
+ # This component is staled because it overlaps the extended first
2372
+ # component of the primary mirror, even though it doesn't overlap
2373
+ # the actual write - thus not inited.
2374
+ flg_opts=" --component-flags stale"
2375
+ found=$( $LFS find --component-start 10M $flg_opts $comp_file | wc -l)
2376
+ [ $found -eq 1 ] || error " write: Second mirror comp flags incorrect"
2377
+
2378
+ # mirror resync should not change the extents
2379
+ $LFS mirror resync $comp_file
2380
+
2381
+ $LFS getstripe $comp_file
2382
+
2383
+ flg_opts=" --component-flags init"
2384
+ found=$( $LFS find --component-end 65M $flg_opts $comp_file | wc -l)
2385
+ [ $found -eq 1 ] || error " resync: First comp end incorrect"
2386
+
2387
+ flg_opts=" --component-flags extension"
2388
+ found=$( $LFS find --component-start 65M $flg_opts $comp_file | wc -l)
2389
+ [ $found -eq 1 ] || error " resync: Second comp start incorrect"
2390
+
2391
+ flg_opts=" --component-flags init"
2392
+ found=$( $LFS find --component-end 10M $flg_opts $comp_file | wc -l)
2393
+ [ $found -eq 1 ] || error " resync: First mirror comp flags incorrect"
2394
+
2395
+ flg_opts=" --component-flags init"
2396
+ found=$( $LFS find --component-start 10M $flg_opts $comp_file | wc -l)
2397
+ [ $found -eq 1 ] || error " resync: Second mirror comp flags incorrect"
2398
+
2399
+ sel_layout_sanity $comp_file 5
2400
+
2401
+ rm -f $comp_file
2402
+ }
2403
+ run_test 204b " FLR write/stale/resync tests with self-extending primary"
2404
+
2405
+ # FLR + SEL failed extension & component removal
2406
+ # extension space in second mirror
2407
+ test_204c () {
2408
+ [ $OSTCOUNT -lt 2 ] && skip " needs >= 2 OSTs" && return
2409
+ [ $( lustre_version_code $SINGLEMDS ) -lt $( version_code $SEL_VER ) ] &&
2410
+ skip " skipped for lustre < $SEL_VER "
2411
+
2412
+ local comp_file=$DIR /$tdir /$tfile
2413
+ local found=" "
2414
+ local ost_idx1=0
2415
+ local ost_name=$( ostname_from_index $ost_idx1 )
2416
+
2417
+ test_mkdir $DIR /$tdir
2418
+
2419
+ # first mirror is is 0-10M, then 10M-(-1), second mirror is 0-1M, then
2420
+ # extension space from 1M to 1G, then normal space to -1
2421
+ $LFS setstripe -N -E 10M -E-1 -N -E 1M -E 1G -i $ost_idx1 -z 64M \
2422
+ -E -1 $comp_file || error " Create $comp_file failed"
2423
+
2424
+ do_facet ost1 $LCTL set_param -n obdfilter.$ost_name .degraded=1
2425
+ sleep_maxage
2426
+
2427
+ # write to first comp (0 - 10M) of mirror 1, extending + staling
2428
+ # first + second comp of mirror 2
2429
+ dd if=/dev/zero bs=2M count=1 of=$comp_file conv=notrunc
2430
+ RC=$?
2431
+
2432
+ do_facet ost1 $LCTL set_param -n obdfilter.$ost_name .degraded=0
2433
+ sleep_maxage
2434
+
2435
+ [ $RC -eq 0 ] || error " dd to extend + stale failed"
2436
+
2437
+ $LFS getstripe $comp_file
2438
+
2439
+ found=$( $LFS find --component-start 0m --component-end 1m \
2440
+ --comp-flags init,stale $comp_file | wc -l)
2441
+ [ $found -eq 1 ] || error " write: First mirror comp incorrect"
2442
+
2443
+ found=$( $LFS find --component-start 1m --component-end EOF \
2444
+ --comp-flags stale,^init $comp_file | wc -l)
2445
+ [ $found -eq 1 ] || error " write: Second mirror comp incorrect"
2446
+
2447
+ local mirror_id=$( $LFS getstripe --component-start=1m \
2448
+ --component-end=EOF $comp_file | \
2449
+ grep lcme_mirror_id | awk ' { print $2 }' )
2450
+
2451
+ [[ $mirror_id -eq 2 ]] ||
2452
+ error " component not in correct mirror? $mirror_id "
2453
+
2454
+ $LFS mirror resync $comp_file
2455
+
2456
+ $LFS getstripe $comp_file
2457
+
2458
+ # component dimensions should not change from resync
2459
+ found=$( $LFS find --component-start 1m --component-end EOF \
2460
+ --component-flags init $comp_file | wc -l)
2461
+ [ $found -eq 1 ] || error " resync: Second mirror comp incorrect"
2462
+
2463
+ sel_layout_sanity $comp_file 4
2464
+
2465
+ rm -f $comp_file
2466
+ }
2467
+ run_test 204c " FLR write/stale/resync test with component removal"
2468
+
2289
2469
complete $SECONDS
2290
2470
check_and_cleanup_lustre
2291
2471
exit_status
0 commit comments