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++) {
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
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)
/* 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;
}
LCONSOLE_ERROR_MSG(0x144, "%s: MDC0 can not be"
" (de)activated.\n",
mti->mti_svname);
- GOTO(end, rc = -EINVAL);
+ GOTO(end, rc = -EPERM);
}
}
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"
# 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"
"$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 -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
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