- car = mdt_cdt_find_request(cdt, 0, &hai->hai_fid);
- if (car == NULL) {
- hai->hai_cookie = 0;
- hai->hai_action = HSMA_NONE;
- } else {
- *hai = *car->car_hai;
- mdt_cdt_put_request(car);
- }
- }
- RETURN(0);
+ /* search for compatible request, if found hai_cookie is set
+ * to the request cookie
+ * it is also used to set the cookie for cancel request by FID
+ */
+ rc = hsm_find_compatible(mti->mti_env, mdt, hal);
+ if (rc)
+ GOTO(out, rc);
+
+ rc = mdt_hsm_register_hal(mti, mdt, cdt, hal);
+
+ GOTO(out, rc);
+out:
+ /* if work has been added, signal the coordinator */
+ if (rc == 0 || rc == -ENODATA)
+ mdt_hsm_cdt_event(cdt);
+
+ return rc;