From: Bobi Jam Date: Fri, 9 Apr 2021 04:53:07 +0000 (+0800) Subject: LU-14597 flr: allow multiple primary mirrors X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=40c4127850f1ba18ab116e34187c4a0244e8e956;p=fs%2Flustre-release.git LU-14597 flr: allow multiple primary mirrors Users can set "prefer" flag on any mirror/component, so the IO should not report error if multiple mirrors are encountered. Rename lod_mirror_entry::lme_primary to lme_prefer to avoid confusion. Lustre-change: https://review.whamcloud.com/43247 Lustre-commit: 93258b9d93611e75b79c30f3ddfc2c9c21f25917 Signed-off-by: Bobi Jam Change-Id: I45748e56e38985a0d9028792ba3d976a4e03efb8 Reviewed-by: Wang Shilong Reviewed-by: Andreas Dilger Reviewed-by: Jian Yu Reviewed-on: https://review.whamcloud.com/43535 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Li Xi --- diff --git a/lustre/lod/lod_internal.h b/lustre/lod/lod_internal.h index d4be19a..7a87ec2 100644 --- a/lustre/lod/lod_internal.h +++ b/lustre/lod/lod_internal.h @@ -230,7 +230,7 @@ static inline __u8 lmv_inherit_rr_next(__u8 inherit_rr) struct lod_mirror_entry { __u16 lme_stale:1, - lme_primary:1, + lme_prefer:1, lme_hsm:1; /* mirror id */ __u16 lme_id; diff --git a/lustre/lod/lod_lov.c b/lustre/lod/lod_lov.c index 360877d..4102be2 100644 --- a/lustre/lod/lod_lov.c +++ b/lustre/lod/lod_lov.c @@ -615,7 +615,7 @@ int lod_fill_mirrors(struct lod_object *lo) if (lo->ldo_mirrors[mirror_idx].lme_hsm) RETURN(-EINVAL); lo->ldo_mirrors[mirror_idx].lme_stale |= stale; - lo->ldo_mirrors[mirror_idx].lme_primary |= preferred; + lo->ldo_mirrors[mirror_idx].lme_prefer |= preferred; lo->ldo_mirrors[mirror_idx].lme_end = i; continue; } @@ -633,7 +633,7 @@ int lod_fill_mirrors(struct lod_object *lo) lo->ldo_mirrors[mirror_idx].lme_id = mirror_id; lo->ldo_mirrors[mirror_idx].lme_stale = stale; - lo->ldo_mirrors[mirror_idx].lme_primary = preferred; + lo->ldo_mirrors[mirror_idx].lme_prefer = preferred; lo->ldo_mirrors[mirror_idx].lme_hsm = mirror_hsm; lo->ldo_mirrors[mirror_idx].lme_start = i; lo->ldo_mirrors[mirror_idx].lme_end = i; diff --git a/lustre/lod/lod_object.c b/lustre/lod/lod_object.c index ee095f2..97ec8cb 100644 --- a/lustre/lod/lod_object.c +++ b/lustre/lod/lod_object.c @@ -7195,7 +7195,7 @@ static int lod_primary_pick(const struct lu_env *env, struct lod_object *lo, } /* 2nd pick is for the primary mirror containing unavail OST */ - if (lo->ldo_mirrors[index].lme_primary && second_pick < 0) + if (lo->ldo_mirrors[index].lme_prefer && second_pick < 0) second_pick = index; /* 3rd pick is for non-primary mirror containing unavail OST */ @@ -7206,7 +7206,7 @@ static int lod_primary_pick(const struct lu_env *env, struct lod_object *lo, * we found a non-primary 1st pick, we'd like to find a * potential pirmary mirror. */ - if (picked >= 0 && !lo->ldo_mirrors[index].lme_primary) + if (picked >= 0 && !lo->ldo_mirrors[index].lme_prefer) continue; /* check the availability of OSTs */ @@ -7243,7 +7243,7 @@ static int lod_primary_pick(const struct lu_env *env, struct lod_object *lo, * primary with all OSTs are available, this is the perfect * 1st pick. */ - if (lo->ldo_mirrors[index].lme_primary) + if (lo->ldo_mirrors[index].lme_prefer) break; } /* for all mirrors */ @@ -7749,25 +7749,17 @@ static int lod_declare_update_write_pending(const struct lu_env *env, LASSERT(mlc->mlc_opc == MD_LAYOUT_WRITE || mlc->mlc_opc == MD_LAYOUT_RESYNC); - /* look for the primary mirror */ + /* look for the first preferred mirror */ for (i = 0; i < lo->ldo_mirror_count; i++) { if (lo->ldo_mirrors[i].lme_stale) continue; - if (lo->ldo_mirrors[i].lme_primary == 0) + if (lo->ldo_mirrors[i].lme_prefer == 0) continue; - if (lo->ldo_mirrors[i].lme_hsm) continue; - if (unlikely(primary >= 0)) { - CERROR(DFID " has multiple primary: %u / %u\n", - PFID(lod_object_fid(lo)), - lo->ldo_mirrors[i].lme_id, - lo->ldo_mirrors[primary].lme_id); - RETURN(-EIO); - } - primary = i; + break; } if (primary < 0) { /* no primary, use any in-sync */ diff --git a/lustre/tests/sanity-flr.sh b/lustre/tests/sanity-flr.sh index 49b2939..ce1f7ef 100644 --- a/lustre/tests/sanity-flr.sh +++ b/lustre/tests/sanity-flr.sh @@ -1806,7 +1806,7 @@ write_file_43() { [ $flags = wp ] || error "file mirror state $flags != wp" } -test_43() { +test_43a() { [ $OSTCOUNT -lt 3 ] && skip "needs >= 3 OSTs" && return local tf=$DIR/$tfile @@ -1853,7 +1853,28 @@ test_43() { verify_comp_attr lcme_flags $tf 0x20002 init,stale verify_comp_attr lcme_flags $tf 0x30003 init,stale } -run_test 43 "mirror pick on write" +run_test 43a "mirror pick on write" + +test_43b() { + local tf=$DIR/$tdir/$tfile + + test_mkdir $DIR/$tdir + rm -f $tf + + # create 3 mirrors FLR file, the first 2 mirrors are preferred + $LFS setstripe -N -Eeof --flags=prefer -N -Eeof --flags=prefer \ + -N -Eeof $tf || error "create 3 mirrors file $tf failed" + verify_flr_state $tf "ro" + + echo " ** write to $tf" + dd if=/dev/zero of=$tf bs=1M count=1 || error "write $tf failed" + verify_flr_state $tf "wp" + + echo " ** resync $tf" + $LFS mirror resync $tf || error "resync $tf failed" + verify_flr_state $tf "ro" +} +run_test 43b "allow writing to multiple preferred mirror file" test_44() { [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return