* index if the file under striped dir is being restored, see
* ct_restore(). */
if (op_data->op_bias & MDS_CREATE_VOLATILE &&
- (int)op_data->op_mds != -1 && lsm != NULL) {
+ (int)op_data->op_mds != -1) {
int i;
tgt = lmv_get_target(lmv, op_data->op_mds, NULL);
if (IS_ERR(tgt))
return tgt;
- /* refill the right parent fid */
- for (i = 0; i < lsm->lsm_md_stripe_count; i++) {
- struct lmv_oinfo *oinfo;
+ if (lsm != NULL) {
+ /* refill the right parent fid */
+ for (i = 0; i < lsm->lsm_md_stripe_count; i++) {
+ struct lmv_oinfo *oinfo;
- oinfo = &lsm->lsm_md_oinfo[i];
- if (oinfo->lmo_mds == op_data->op_mds) {
- *fid = oinfo->lmo_fid;
- break;
+ oinfo = &lsm->lsm_md_oinfo[i];
+ if (oinfo->lmo_mds == op_data->op_mds) {
+ *fid = oinfo->lmo_fid;
+ break;
+ }
}
- }
- /* Hmm, can not find the stripe by mdt_index(op_mds) */
- if (i == lsm->lsm_md_stripe_count)
- tgt = ERR_PTR(-EINVAL);
+ if (i == lsm->lsm_md_stripe_count)
+ *fid = lsm->lsm_md_oinfo[0].lmo_fid;
+ }
return tgt;
}
if (rc != 0)
GOTO(out_unlock_child, rc);
+ /* Migration is incompatible with HSM. */
+ ma->ma_need = MA_HSM;
+ ma->ma_valid = 0;
+ rc = mdt_attr_get_complex(info, mold, ma);
+ if (rc != 0)
+ GOTO(out_unlock_child, rc);
+
+ if ((ma->ma_valid & MA_HSM) && ma->ma_hsm.mh_flags != 0) {
+ rc = -ENOSYS;
+ CERROR("%s: cannot migrate HSM archived file "DFID": rc = %d\n",
+ mdt_obd_name(info->mti_mdt), PFID(old_fid), rc);
+ GOTO(out_unlock_child, rc);
+ }
+
ma->ma_need = MA_LMV;
ma->ma_valid = 0;
ma->ma_lmv = (union lmv_mds_md *)info->mti_xattr_buf;
}
run_test 405 "archive and release under striped directory"
+test_406() {
+ [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
+
+ [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.64) ] &&
+ skip "need MDS version at least 2.7.64" && return 0
+
+ local fid
+ local mdt_index
+
+ copytool_setup
+ mkdir -p $DIR/$tdir
+ fid=$(make_small $DIR/$tdir/$tfile)
+ echo "old fid $fid"
+
+ $LFS hsm_archive $DIR/$tdir/$tfile
+ wait_request_state "$fid" ARCHIVE SUCCEED
+ $LFS hsm_release $DIR/$tdir/$tfile
+
+ # Should migrate $tdir but not $tfile.
+ $LFS mv -M1 $DIR/$tdir &&
+ error "migrating HSM an archived file should fail"
+
+ $LFS hsm_restore $DIR/$tdir/$tfile
+ wait_request_state "$fid" RESTORE SUCCEED
+
+ $LFS hsm_remove $DIR/$tdir/$tfile ||
+ error "cannot remove $DIR/$tdir/$tfile from archive"
+
+ cat $DIR/$tdir/$tfile > /dev/null ||
+ error "cannot read $DIR/$tdir/$tfile"
+
+ $LFS mv -M1 $DIR/$tdir/$tfile ||
+ error "cannot complete migration after HSM remove"
+
+ mdt_index=$($LFS getstripe -M $DIR/$tdir)
+ if ((mdt_index != 1)); then
+ error "expected MDT index 1, got $mdt_index"
+ fi
+
+ # Refresh fid after migration.
+ fid=$(path2fid $DIR/$tdir/$tfile)
+ echo "new fid $fid"
+
+ $LFS hsm_archive $DIR/$tdir/$tfile
+ wait_request_state "$fid" ARCHIVE SUCCEED 1
+
+ lctl set_param debug=+trace
+ $LFS hsm_release $DIR/$tdir/$tfile ||
+ error "cannot release $DIR/$tdir/$tfile"
+
+ $LFS hsm_restore $DIR/$tdir/$tfile
+ wait_request_state "$fid" RESTORE SUCCEED 1
+
+ cat $DIR/$tdir/$tfile > /dev/null ||
+ error "cannot read $DIR/$tdir/$tfile"
+
+ copytool_cleanup
+}
+run_test 406 "attempting to migrate HSM archived files is safe"
+
test_500()
{
[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.92) ] &&