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.
Signed-off-by: Di Wang <di.wang@intel.com>
Change-Id: I089f5cf517c71816151e8ece1b36b9064ee3b7f2
Reviewed-on: https://review.whamcloud.com/24247
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: Lai Siyao <lai.siyao@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
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++) {
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
+ /* 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)
/* 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);
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);
# 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
[ $(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"
rm -rf $DIR/$tdir/2 || error "unlink dir failed"
# deactivate MDC for MDT2
rm -rf $DIR/$tdir/2 || error "unlink dir failed"
# deactivate MDC for MDT2
- local TEST="$LCTL get_param -n mdc.${FSNAME}-MDT0001-mdc-[!M]*.active"
+ TEST="$LCTL get_param -n mdc.${FSNAME}-MDT0001-mdc-[!M]*.active"
set_conf_param_and_check client \
"$TEST" "${FSNAME}-MDT0001.mdc.active" 0 ||
error "Unable to deactivate MDT2"
set_conf_param_and_check client \
"$TEST" "${FSNAME}-MDT0001.mdc.active" 0 ||
error "Unable to deactivate MDT2"
$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