Skip to content

Commit 3d7895b

Browse files
paf-49Oleg Drokin
authored andcommitted
LU-10070 lod: SEL: Add FLR support
Add FLR support for self-extending layouts. The basic model is that when a layout intent would modify an FLR replica, we first run the extent_update code to perform any layout extent changes for self extending layouts. This treats the FLR operations (stale, resync, etc) similarly to i/o, creating initialized layout where those operations need it. This makes the interaction between SEL and FLR fairly simple. Add FLR tests for self-extending layouts Cray-bug-id: LUS-2528 Signed-off-by: Patrick Farrell <[email protected]> Change-Id: Ia23df8e226955f64e9b19df993b66d2d4f820f33 Reviewed-on: https://review.whamcloud.com/33785 Reviewed-by: Patrick Farrell <[email protected]> Tested-by: jenkins <[email protected]> Tested-by: Maloo <[email protected]> Reviewed-by: Alexey Lyashkov <[email protected]> Reviewed-by: Oleg Drokin <[email protected]>
1 parent 4eca26d commit 3d7895b

File tree

2 files changed

+230
-9
lines changed

2 files changed

+230
-9
lines changed

lustre/lod/lod_object.c

Lines changed: 50 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6786,15 +6786,21 @@ static inline int lod_comp_index(struct lod_object *lo,
67866786
/**
67876787
* Stale other mirrors by writing extent.
67886788
*/
6789-
static void lod_stale_components(struct lod_object *lo, int primary,
6790-
struct lu_extent *extent)
6789+
static int lod_stale_components(const struct lu_env *env, struct lod_object *lo,
6790+
int primary, struct lu_extent *extent,
6791+
struct thandle *th)
67916792
{
67926793
struct lod_layout_component *pri_comp, *lod_comp;
6794+
struct lu_extent pri_extent;
6795+
int rc = 0;
67936796
int i;
6797+
ENTRY;
67946798

67956799
/* The writing extent decides which components in the primary
67966800
* are affected... */
67976801
CDEBUG(D_LAYOUT, "primary mirror %d, "DEXT"\n", primary, PEXT(extent));
6802+
6803+
restart:
67986804
lod_foreach_mirror_comp(pri_comp, lo, primary) {
67996805
if (!lu_extent_is_overlapped(extent, &pri_comp->llc_extent))
68006806
continue;
@@ -6803,15 +6809,27 @@ static void lod_stale_components(struct lod_object *lo, int primary,
68036809
lod_comp_index(lo, pri_comp),
68046810
PEXT(&pri_comp->llc_extent));
68056811

6812+
pri_extent.e_start = pri_comp->llc_extent.e_start;
6813+
pri_extent.e_end = pri_comp->llc_extent.e_end;
6814+
68066815
for (i = 0; i < lo->ldo_mirror_count; i++) {
68076816
if (i == primary)
68086817
continue;
6818+
rc = lod_declare_update_extents(env, lo, &pri_extent,
6819+
th, i, 0);
6820+
/* if update_extents changed the layout, it may have
6821+
* reallocated the component array, so start over to
6822+
* avoid using stale pointers */
6823+
if (rc == 1)
6824+
goto restart;
6825+
if (rc < 0)
6826+
RETURN(rc);
68096827

68106828
/* ... and then stale other components that are
68116829
* overlapping with primary components */
68126830
lod_foreach_mirror_comp(lod_comp, lo, i) {
68136831
if (!lu_extent_is_overlapped(
6814-
&pri_comp->llc_extent,
6832+
&pri_extent,
68156833
&lod_comp->llc_extent))
68166834
continue;
68176835

@@ -6823,6 +6841,8 @@ static void lod_stale_components(struct lod_object *lo, int primary,
68236841
}
68246842
}
68256843
}
6844+
6845+
RETURN(rc);
68266846
}
68276847

68286848
/**
@@ -7058,6 +7078,7 @@ static int lod_declare_update_rdonly(const struct lu_env *env,
70587078

70597079
if (mlc->mlc_opc == MD_LAYOUT_WRITE) {
70607080
struct layout_intent *layout = mlc->mlc_intent;
7081+
int write = layout->li_opc == LAYOUT_INTENT_WRITE;
70617082
int picked;
70627083

70637084
extent = layout->li_extent;
@@ -7072,6 +7093,12 @@ static int lod_declare_update_rdonly(const struct lu_env *env,
70727093
PFID(lod_object_fid(lo)),
70737094
lo->ldo_mirrors[picked].lme_id);
70747095

7096+
/* Update extents of primary before staling */
7097+
rc = lod_declare_update_extents(env, lo, &extent, th, picked,
7098+
write);
7099+
if (rc < 0)
7100+
GOTO(out, rc);
7101+
70757102
if (layout->li_opc == LAYOUT_INTENT_TRUNC) {
70767103
/**
70777104
* trunc transfers [0, size) in the intent extent, we'd
@@ -7082,7 +7109,9 @@ static int lod_declare_update_rdonly(const struct lu_env *env,
70827109
}
70837110

70847111
/* stale overlapping components from other mirrors */
7085-
lod_stale_components(lo, picked, &extent);
7112+
rc = lod_stale_components(env, lo, picked, &extent, th);
7113+
if (rc < 0)
7114+
GOTO(out, rc);
70867115

70877116
/* restore truncate intent extent */
70887117
if (layout->li_opc == LAYOUT_INTENT_TRUNC)
@@ -7222,13 +7251,22 @@ static int lod_declare_update_write_pending(const struct lu_env *env,
72227251
* 2. transfer layout version to all objects to close write era. */
72237252

72247253
if (mlc->mlc_opc == MD_LAYOUT_WRITE) {
7254+
struct layout_intent *layout = mlc->mlc_intent;
7255+
int write = layout->li_opc == LAYOUT_INTENT_WRITE;
7256+
72257257
LASSERT(mlc->mlc_intent != NULL);
72267258

72277259
extent = mlc->mlc_intent->li_extent;
72287260

72297261
CDEBUG(D_LAYOUT, DFID": intent to write: "DEXT"\n",
72307262
PFID(lod_object_fid(lo)), PEXT(&extent));
72317263

7264+
/* 1. Update extents of primary before staling */
7265+
rc = lod_declare_update_extents(env, lo, &extent, th, primary,
7266+
write);
7267+
if (rc < 0)
7268+
GOTO(out, rc);
7269+
72327270
if (mlc->mlc_intent->li_opc == LAYOUT_INTENT_TRUNC) {
72337271
/**
72347272
* trunc transfers [0, size) in the intent extent, we'd
@@ -7237,10 +7275,13 @@ static int lod_declare_update_write_pending(const struct lu_env *env,
72377275
extent.e_start = extent.e_end;
72387276
extent.e_end = OBD_OBJECT_EOF;
72397277
}
7240-
/* 1. stale overlapping components */
7241-
lod_stale_components(lo, primary, &extent);
72427278

7243-
/* 2. find out the components need instantiating.
7279+
/* 2. stale overlapping components */
7280+
rc = lod_stale_components(env, lo, primary, &extent, th);
7281+
if (rc < 0)
7282+
GOTO(out, rc);
7283+
7284+
/* 3. find the components which need instantiating.
72447285
* instantiate [0, mlc->mlc_intent->e_end) */
72457286

72467287
/* restore truncate intent extent */
@@ -7380,9 +7421,9 @@ static int lod_declare_update_sync_pending(const struct lu_env *env,
73807421
GOTO(out, rc = -EINVAL);
73817422
}
73827423

7383-
CDEBUG(D_LAYOUT, DFID": resynced %u/%zu components\n",
7424+
CDEBUG(D_LAYOUT, DFID": synced %u resynced %u/%zu components\n",
73847425
PFID(lod_object_fid(lo)),
7385-
resync_components, mlc->mlc_resync_count);
7426+
sync_components, resync_components, mlc->mlc_resync_count);
73867427

73877428
lo->ldo_flr_state = LCM_FL_RDONLY;
73887429
lod_obj_inc_layout_gen(lo);

lustre/tests/sanity-flr.sh

Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2286,6 +2286,186 @@ test_203() {
22862286
}
22872287
run_test 203 "mirror file preserve mirror ID"
22882288

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+
22892469
complete $SECONDS
22902470
check_and_cleanup_lustre
22912471
exit_status

0 commit comments

Comments
 (0)