struct hsm_action_list *hal)
{
struct hsm_action_item *hai;
- int rc, i, ok_cnt;
+ int rc = 0, i;
+ bool check = false;
ENTRY;
- ok_cnt = 0;
hai = hai_first(hal);
for (i = 0; i < hal->hal_count; i++, hai = hai_next(hai)) {
/* We only support ARCHIVE, RESTORE, REMOVE and CANCEL here. */
if (hai->hai_action == HSMA_NONE)
RETURN(-EINVAL);
- /* in a cancel request hai_cookie may be set by caller to
- * show the request to be canceled
- * if not we need to search by FID
+ /* In a cancel request hai_cookie may be set by caller to show
+ * the request to be canceled. If there is at least one cancel
+ * request that does not have a cookie set we need to search by
+ * FID; we can skip checking in all other cases
*/
- if (hai->hai_action == HSMA_CANCEL && hai->hai_cookie != 0)
- ok_cnt++;
- else
- hai->hai_cookie = 0;
+ if (hai->hai_action == HSMA_CANCEL && hai->hai_cookie == 0) {
+ check = true;
+ break;
+ }
}
- /* if all requests are cancel with cookie, no need to find compatible */
- if (ok_cnt == hal->hal_count)
- RETURN(0);
-
- rc = cdt_llog_process(env, mdt, hsm_find_compatible_cb, hal, 0, 0,
- READ);
+ if (check)
+ rc = cdt_llog_process(env, mdt, hsm_find_compatible_cb, hal, 0,
+ 0, READ);
RETURN(rc);
}
md5sum $f2 &
sleep 2
+ do_facet $SINGLEMDS "$LCTL get_param $HSM_PARAM.actions"
# after umount hsm_actions->O/x/x log shouldn't have
# double RESTORE records like below
#[0x200000401:0x1:0x0]...0x58d03a0d/0x58d03a0c action=RESTORE...WAITING
sleep 30 &&
do_facet $SINGLEMDS "$LCTL get_param $HSM_PARAM.actions"&
fail $SINGLEMDS
+ do_facet $SINGLEMDS $LCTL set_param fail_loc=0
+
+ do_facet $SINGLEMDS "$LCTL get_param $HSM_PARAM.actions"
copytool_continue
- wait_request_state $fid RESTORE SUCCEED
+ wait_all_done 100 $fid
}
run_test 407 "Check for double RESTORE records in llog"