Whamcloud - gitweb
LU-8922 lod: check master stripes properly 76/24776/5
authorDi Wang <di.wang@intel.com>
Mon, 9 Jan 2017 15:07:36 +0000 (10:07 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 26 Apr 2017 03:36:45 +0000 (03:36 +0000)
When creating striped directory, it should
first check if the stripe has been created
on the current MDT, otherwise it might create
duplicate stripes on the master MDT, especially
when one MDT is deactived, and specified stripes
is larger than the active MDTs.

Test-Parameters: envdefinitions=ONLY=50 testlist=conf-sanity,conf-sanity,conf-sanity
Test-Parameters: envdefinitions=ONLY=50 testlist=conf-sanity,conf-sanity,conf-sanity
Signed-off-by: Di Wang <di.wang@intel.com>
Change-Id: Id3bba2817c4c7c9584f9129e32555f0f676b3364
Reviewed-on: https://review.whamcloud.com/24776
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Fan Yong <fan.yong@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/lod/lod_object.c
lustre/mgs/mgs_llog.c
lustre/tests/conf-sanity.sh
lustre/tests/test-framework.sh

index 06656be..a7bce5a 100644 (file)
@@ -1822,7 +1822,7 @@ static int lod_prep_md_striped_create(const struct lu_env *env,
        if (stripe == NULL)
                GOTO(out_free, rc = -ENOMEM);
 
        if (stripe == NULL)
                GOTO(out_free, rc = -ENOMEM);
 
-       /* Start index will be the master MDT */
+       /* Start index must be the master MDT */
        master_index = lu_site2seq(lod2lu_dev(lod)->ld_site)->ss_node_id;
        idx_array[0] = master_index;
        for (i = 0; i < stripe_count; i++) {
        master_index = lu_site2seq(lod2lu_dev(lod)->ld_site)->ss_node_id;
        idx_array[0] = master_index;
        for (i = 0; i < stripe_count; i++) {
@@ -1842,19 +1842,6 @@ static int lod_prep_md_striped_create(const struct lu_env *env,
 
                        CDEBUG(D_INFO, "try idx %d, mdt cnt %u, allocated %u\n",
                               idx, lod->lod_remote_mdt_count + 1, i);
 
                        CDEBUG(D_INFO, "try idx %d, mdt cnt %u, allocated %u\n",
                               idx, lod->lod_remote_mdt_count + 1, i);
-                       if (idx == master_index) {
-                               /* Allocate the FID locally */
-                               rc = obd_fid_alloc(env, lod->lod_child_exp,
-                                                  &fid, NULL);
-                               if (rc < 0)
-                                       GOTO(out_put, rc);
-                               tgt_dt = lod->lod_child;
-                               break;
-                       }
-
-                       /* Find next available target */
-                       if (!cfs_bitmap_check(ltd->ltd_tgt_bitmap, idx))
-                               continue;
 
                        if (likely(!OBD_FAIL_CHECK(OBD_FAIL_LARGE_STRIPE))) {
                                /* check whether the idx already exists
 
                        if (likely(!OBD_FAIL_CHECK(OBD_FAIL_LARGE_STRIPE))) {
                                /* check whether the idx already exists
@@ -1870,6 +1857,22 @@ static int lod_prep_md_striped_create(const struct lu_env *env,
                                        continue;
                        }
 
                                        continue;
                        }
 
+                       /* Sigh, this index is not in the bitmap, let's check
+                        * next available target */
+                       if (!cfs_bitmap_check(ltd->ltd_tgt_bitmap, idx) &&
+                           idx != master_index)
+                               continue;
+
+                       if (idx == master_index) {
+                               /* Allocate the FID locally */
+                               rc = obd_fid_alloc(env, lod->lod_child_exp,
+                                                  &fid, NULL);
+                               if (rc < 0)
+                                       GOTO(out_put, rc);
+                               tgt_dt = lod->lod_child;
+                               break;
+                       }
+
                        /* check the status of the OSP */
                        tgt = LTD_TGT(ltd, idx);
                        if (tgt == NULL)
                        /* check the status of the OSP */
                        tgt = LTD_TGT(ltd, idx);
                        if (tgt == NULL)
@@ -1895,7 +1898,7 @@ static int lod_prep_md_striped_create(const struct lu_env *env,
                /* Can not allocate more stripes */
                if (j == lod->lod_remote_mdt_count) {
                        CDEBUG(D_INFO, "%s: require stripes %u only get %d\n",
                /* Can not allocate more stripes */
                if (j == lod->lod_remote_mdt_count) {
                        CDEBUG(D_INFO, "%s: require stripes %u only get %d\n",
-                              lod2obd(lod)->obd_name, stripe_count, i - 1);
+                              lod2obd(lod)->obd_name, stripe_count, i);
                        break;
                }
 
                        break;
                }
 
index 81eb22f..679ef0e 100644 (file)
@@ -3599,7 +3599,7 @@ static int mgs_write_log_param(const struct lu_env *env,
                                LCONSOLE_ERROR_MSG(0x144, "%s: MDC0 can not be"
                                                   " (de)activated.\n",
                                                   mti->mti_svname);
                                LCONSOLE_ERROR_MSG(0x144, "%s: MDC0 can not be"
                                                   " (de)activated.\n",
                                                   mti->mti_svname);
-                               GOTO(end, rc = -EINVAL);
+                               GOTO(end, rc = -EPERM);
                        }
                }
 
                        }
                }
 
index d794a41..3683fa1 100755 (executable)
@@ -1207,27 +1207,8 @@ test_29() {
        fi
 
        # check MDTs too
        fi
 
        # check MDTs too
-       for num in $(seq $MDSCOUNT); do
-               local mdtosc=$(get_mdtosc_proc_path mds${num} $FSNAME-OST0001)
-               local MPROC="osc.$mdtosc.active"
-               local MAX=30
-               local WAIT=0
-               while [ 1 ]; do
-                       sleep 5
-                       RESULT=$(do_facet mds${num} "$LCTL get_param -n $MPROC")
-                       [ ${PIPESTATUS[0]} = 0 ] || error "Can't read $MPROC"
-                       if [ $RESULT -eq $DEAC ]; then
-                               echo -n "MDT deactivated also after"
-                               echo "$WAIT sec (got $RESULT)"
-                               break
-                       fi
-                       WAIT=$((WAIT + 5))
-                       if [ $WAIT -eq $MAX ]; then
-                               error "MDT active: wanted $DEAC got $RESULT"
-                       fi
-                       echo "Waiting $(($MAX - $WAIT))secs for MDT deactivated"
-               done
-       done
+       wait_osp_active ost ${FSNAME}-OST0001 1 0
+
        # test new client starts deactivated
        umount_client $MOUNT || error "umount_client $MOUNT failed"
        mount_client $MOUNT || error "mount_client $MOUNT failed"
        # test new client starts deactivated
        umount_client $MOUNT || error "umount_client $MOUNT failed"
        mount_client $MOUNT || error "mount_client $MOUNT failed"
@@ -3740,6 +3721,7 @@ test_50i() {
        # prepare MDT/OST, make OSC inactive for OST1
        [ "$MDSCOUNT" -lt "2" ] && skip_env "$MDSCOUNT < 2, skipping" && return
 
        # prepare MDT/OST, make OSC inactive for OST1
        [ "$MDSCOUNT" -lt "2" ] && skip_env "$MDSCOUNT < 2, skipping" && return
 
+       load_modules
        [ $(facet_fstype mds2) == zfs ] && import_zpool mds2
        do_facet mds2 "$TUNEFS --param mdc.active=0 $(mdsdevname 2)" ||
                error "tunefs MDT2 failed"
        [ $(facet_fstype mds2) == zfs ] && import_zpool mds2
        do_facet mds2 "$TUNEFS --param mdc.active=0 $(mdsdevname 2)" ||
                error "tunefs MDT2 failed"
@@ -3775,9 +3757,18 @@ test_50i() {
                "$TEST" "${FSNAME}-MDT0001.mdc.active" 0 ||
                error "Unable to deactivate MDT2"
 
                "$TEST" "${FSNAME}-MDT0001.mdc.active" 0 ||
                error "Unable to deactivate MDT2"
 
+       wait_osp_active mds ${FSNAME}-MDT0001 1 0
+
        $LFS mkdir -i1 $DIR/$tdir/2 &&
                error "mkdir $DIR/$tdir/2 succeeds after deactive MDT"
 
        $LFS mkdir -i1 $DIR/$tdir/2 &&
                error "mkdir $DIR/$tdir/2 succeeds after deactive MDT"
 
+       $LFS mkdir -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
+               error "mkdir $DIR/$tdir/striped_dir fails after deactive MDT2"
+
+       local stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
+       [ $stripe_count -eq $((MDSCOUNT - 1)) ] ||
+               error "wrong $stripe_count != $((MDSCOUNT -1)) for striped_dir"
+
        # cleanup
        umount_client $MOUNT || error "Unable to umount client"
        stop_mds
        # cleanup
        umount_client $MOUNT || error "Unable to umount client"
        stop_mds
index 6ed34d0..6d074c7 100755 (executable)
@@ -6279,6 +6279,47 @@ wait_clients_import_state () {
        fi
 }
 
        fi
 }
 
+wait_osp_active() {
+       local facet=$1
+       local tgt_name=$2
+       local tgt_idx=$3
+       local expected=$4
+       local num
+
+       # wait until all MDTs are in the expected state
+       for ((num = 1; num <= $MDSCOUNT; num++)); do
+               local mdtosp=$(get_mdtosc_proc_path mds${num} ${tgt_name})
+               local mproc
+
+               if [ $facet = "mds" ]; then
+                       mproc="osp.$mdtosp.active"
+                       [ $num -eq $((tgt_idx + 1)) ] && continue
+               else
+                       mproc="osc.$mdtosp.active"
+               fi
+
+               echo "check $mproc"
+               while [ 1 ]; do
+                       sleep 5
+                       local result=$(do_facet mds${num} "$LCTL get_param -n $mproc")
+                       local max=30
+                       local wait=0
+
+                       [ ${PIPESTATUS[0]} = 0 ] || error "Can't read $mproc"
+                       if [ $result -eq $expected ]; then
+                               echo -n "target updated after"
+                               echo "$wait sec (got $result)"
+                               break
+                       fi
+                       wait=$((wait + 5))
+                       if [ $wait -eq $max ]; then
+                               error "$tgt_name: wanted $expected got $result"
+                       fi
+                       echo "Waiting $((max - wait)) secs for $tgt_name"
+               done
+       done
+}
+
 oos_full() {
        local -a AVAILA
        local -a GRANTA
 oos_full() {
        local -a AVAILA
        local -a GRANTA