Whamcloud - gitweb
LU-14597 flr: allow multiple primary mirrors 47/43247/3
authorBobi Jam <bobijam@whamcloud.com>
Fri, 9 Apr 2021 04:53:07 +0000 (12:53 +0800)
committerOleg Drokin <green@whamcloud.com>
Wed, 21 Apr 2021 03:15:32 +0000 (03:15 +0000)
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.

Signed-off-by: Bobi Jam <bobijam@whamcloud.com>
Change-Id: I45748e56e38985a0d9028792ba3d976a4e03efb8
Reviewed-on: https://review.whamcloud.com/43247
Reviewed-by: Wang Shilong <wshilong@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Jian Yu <yujian@whamcloud.com>
lustre/lod/lod_internal.h
lustre/lod/lod_lov.c
lustre/lod/lod_object.c
lustre/tests/sanity-flr.sh

index 7a913a0..241a77c 100644 (file)
@@ -191,7 +191,7 @@ struct lod_default_striping {
 
 struct lod_mirror_entry {
        __u16   lme_stale:1,
-               lme_primary:1;
+               lme_prefer:1;
        /* mirror id */
        __u16   lme_id;
        /* start,end index of this mirror in ldo_comp_entries */
index 849414b..9dacc8b 100644 (file)
@@ -607,7 +607,7 @@ int lod_fill_mirrors(struct lod_object *lo)
 
                if (mirror_id_of(lod_comp->llc_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_end = i;
                        continue;
                }
@@ -621,7 +621,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_start = i;
                lo->ldo_mirrors[mirror_idx].lme_end = i;
        }
index a1cdfc7..f24539c 100644 (file)
@@ -7336,7 +7336,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 */
@@ -7347,7 +7347,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 */
@@ -7384,7 +7384,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 */
 
@@ -7628,22 +7628,15 @@ 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 (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 */
index b15e70f..531b5a0 100644 (file)
@@ -1894,7 +1894,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
@@ -1941,7 +1941,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