RETURN(0);
}
+static int mdt_hsm_set_exists(struct mdt_thread_info *mti,
+ const struct lu_fid *fid,
+ u32 archive_id)
+{
+ struct mdt_object *obj;
+ struct md_hsm mh;
+ int rc;
+
+ obj = mdt_hsm_get_md_hsm(mti, fid, &mh);
+ if (IS_ERR(obj))
+ GOTO(out, rc = PTR_ERR(obj));
+
+ if (mh.mh_flags & HS_EXISTS &&
+ mh.mh_arch_id == archive_id)
+ GOTO(out_obj, rc = 0);
+
+ mh.mh_flags |= HS_EXISTS;
+ mh.mh_arch_id = archive_id;
+ rc = mdt_hsm_attr_set(mti, obj, &mh);
+
+out_obj:
+ mdt_object_put(mti->mti_env, obj);
+out:
+ return rc;
+}
+
/**
* register all requests from an hal in the memory list
* \param mti [IN] context
}
if (hai->hai_action == HSMA_ARCHIVE) {
- struct mdt_object *obj;
- struct md_hsm hsm;
-
- obj = mdt_hsm_get_md_hsm(mti, &hai->hai_fid, &hsm);
- if (IS_ERR(obj) && (PTR_ERR(obj) == -ENOENT))
+ rc = mdt_hsm_set_exists(mti, &hai->hai_fid,
+ hal->hal_archive_id);
+ if (rc == -ENOENT)
continue;
- if (IS_ERR(obj))
- GOTO(out, rc = PTR_ERR(obj));
-
- hsm.mh_flags |= HS_EXISTS;
- hsm.mh_arch_id = hal->hal_archive_id;
- rc = mdt_hsm_attr_set(mti, obj, &hsm);
- mdt_object_put(mti->mti_env, obj);
- if (rc)
+ else if (rc < 0)
GOTO(out, rc);
}
/**
* check if a request is compatible with file status
* \param hai [IN] request description
- * \param hal_an [IN] request archive number (not used)
+ * \param archive_id [IN] request archive id
* \param rq_flags [IN] request flags
* \param hsm [IN] file HSM metadata
* \retval boolean
*/
bool mdt_hsm_is_action_compat(const struct hsm_action_item *hai,
- const int hal_an, const __u64 rq_flags,
+ u32 archive_id, u64 rq_flags,
const struct md_hsm *hsm)
{
int is_compat = false;
if (!(hsm_flags & HS_NOARCHIVE) &&
(hsm_flags & HS_DIRTY || !(hsm_flags & HS_ARCHIVED)))
is_compat = true;
+
+ if (hsm_flags & HS_EXISTS &&
+ archive_id != 0 &&
+ archive_id != hsm->mh_arch_id)
+ is_compat = false;
+
break;
case HSMA_RESTORE:
if (!(hsm_flags & HS_DIRTY) && (hsm_flags & HS_RELEASED) &&