static inline int lmv_name_to_stripe_index(struct lmv_mds_md_v1 *lmv,
const char *name, int namelen)
{
- if (lmv->lmv_magic == LMV_MAGIC_V1)
+ if (lmv->lmv_magic == LMV_MAGIC_V1 ||
+ lmv->lmv_magic == LMV_MAGIC_STRIPE)
return __lmv_name_to_stripe_index(lmv->lmv_hash_type,
lmv->lmv_stripe_count,
lmv->lmv_migrate_hash,
lmv->lmv_migrate_offset,
name, namelen, true);
- if (lmv->lmv_magic == cpu_to_le32(LMV_MAGIC_V1))
+ if (lmv->lmv_magic == cpu_to_le32(LMV_MAGIC_V1) ||
+ lmv->lmv_magic == cpu_to_le32(LMV_MAGIC_STRIPE))
return __lmv_name_to_stripe_index(
le32_to_cpu(lmv->lmv_hash_type),
le32_to_cpu(lmv->lmv_stripe_count),
#define OBD_FAIL_INVALIDATE_UPDATE 0x1705
#define OBD_FAIL_OUT_UPDATE_DROP 0x1707
#define OBD_FAIL_OUT_OBJECT_MISS 0x1708
+#define OBD_FAIL_OUT_EIO 0x1709
/* MIGRATE */
#define OBD_FAIL_MIGRATE_ENTRIES 0x1801
(!list_empty(&lfsck->li_list_scan) ||
!list_empty(&lfsck->li_list_double_scan))) {
rc = lfsck_verify_lpf(env, lfsck);
- /* Fail to verify the .lustre/lost+found/MDTxxxx/ may be not
- * fatal, because the .lustre/lost+found/ maybe not accessed
- * by the LFSCK if it does not add orphans or others to such
- * directory. So go ahead until hit failure when really uses
- * the directory. */
+ /* FIXME: once OI files are missing, this will fail, it should
+ * return error, but to satisfy sanity-lfsck test 4 & 5, leave
+ * it uninitialized here, and any code dereference it need to
+ * check.
+ */
if (rc != 0)
- CDEBUG(D_LFSCK, "%s: master engine fail to verify the "
+ CERROR("%s: master engine fail to verify the "
".lustre/lost+found/, go ahead: rc = %d\n",
lfsck_lfsck2name(lfsck), rc);
}
goto find_child1;
}
- if (unlikely(!dt_try_as_dir(env, child2))) {
- lfsck_object_put(env, child2);
- child2 = NULL;
- rc = -ENOTDIR;
- }
+ if (unlikely(!dt_try_as_dir(env, child2)))
+ GOTO(put, rc = -ENOTDIR);
find_child1:
if (fid_is_zero(&bk->lb_lpf_fid))
GOTO(log, rc = 1);
if (dt_object_remote(orphan)) {
- LASSERT(lfsck->li_lpf_root_obj != NULL);
+ if (lfsck->li_lpf_root_obj == NULL)
+ GOTO(log, rc = -EBADF);
idx = lfsck_find_mdt_idx_by_fid(env, lfsck, cfid);
if (idx < 0)
}
}
- rc = h->th_act(tsi);
+ if (OBD_FAIL_CHECK(OBD_FAIL_OUT_EIO))
+ rc = -EIO;
+ else
+ rc = h->th_act(tsi);
next:
reply_index++;
dt_object_put(env, dt_obj);
}
run_test 15c "LFSCK can repair unmatched MDT-object/OST-object pairs (3)"
+test_15d() {
+ (( $MDSCOUNT > 1 )) || skip "needs >= 2 MDTs"
+
+ check_mount_and_prep
+ rm -rf $DIR/$tdir
+ $LFS mkdir -c -1 $DIR/$tdir || error "create $tdir failed"
+ $LFS setdirstripe -D -i -1 -c 1 $DIR/$tdir ||
+ error "setdirstripe failed"
+
+ createmany -o $DIR/$tdir/f 100 || error "create sub files failed"
+ createmany -d $DIR/$tdir/s 100 || error "create sub dirs failed"
+
+ echo "Migrate $DIR/$tdir to MDT1"
+ $LFS migrate -m 1 $DIR/$tdir &
+ pid=$!
+
+ sleep 2
+ # fail sub transactions on random MDTs, which may cause some file
+ # inaccessible
+ #define OBD_FAIL_OUT_EIO 0x1709
+ for ((i = 0; i < $MDSCOUNT; i++)); do
+ do_facet mds$i $LCTL set_param fail_loc=0x1709
+ sleep 0.1
+ do_facet mds$i $LCTL set_param fail_loc=0
+ done
+
+ wait $pid
+
+ # LFSCK can't fully fix migrating directories, and may leave some
+ # files inaccessible, but it shouldn't cause crash
+ $START_NAMESPACE -A -r ||
+ error "Fail to start LFSCK for namespace"
+
+ wait_all_targets_blocked namespace completed 1
+
+ # resume migration may fail because some file may be inaccessible, but
+ # it shouldn't cause crash
+ $LFS migrate -m 1 $DIR/$tdir
+
+ # rm $tdir to avoid cleanup failure in the end
+ rm -rf $DIR/$tdir/*
+ $LFS rm_entry $DIR/$tdir/*
+ rm -rf $DIR/$tdir || error "rm $tdir failed"
+}
+run_test 15d "LFSCK don't crash upon dir migration failure"
+
test_16() {
(( $MDS1_VERSION > $(version_code 2.5.55) )) ||
skip "MDS older than 2.5.55, LU-3594"