- /* Move all of the pending cancels from the same OST off of
- * the list, so we don't get multiple threads blocked and/or
- * doing upcalls on the same OST in case of failure. */
- spin_lock(&lcm->lcm_llcd_lock);
- if (!list_empty(sending_list)) {
- list_move_tail(sending_list->next,
- &lcd->lcd_llcd_list);
- llcd = list_entry(lcd->lcd_llcd_list.next,
- typeof(*llcd), llcd_list);
- LASSERT(llcd->llcd_lcm == lcm);
- import = llcd->llcd_ctxt->loc_imp;
- }
- list_for_each_entry_safe(llcd, n, sending_list, llcd_list) {
- LASSERT(llcd->llcd_lcm == lcm);
- if (import == llcd->llcd_ctxt->loc_imp)
- list_move_tail(&llcd->llcd_list,
- &lcd->lcd_llcd_list);
- }
- if (sending_list != &lcm->lcm_llcd_resend) {
- list_for_each_entry_safe(llcd, n, &lcm->lcm_llcd_resend,
- llcd_list) {
- LASSERT(llcd->llcd_lcm == lcm);
- if (import == llcd->llcd_ctxt->loc_imp)
- list_move_tail(&llcd->llcd_list,
- &lcd->lcd_llcd_list);
- }
- }
- spin_unlock(&lcm->lcm_llcd_lock);
-
- /* We are the only one manipulating our local list - no lock */
- list_for_each_entry_safe(llcd,n, &lcd->lcd_llcd_list,llcd_list){
- char *bufs[1] = {(char *)llcd->llcd_cookies};
-
- list_del(&llcd->llcd_list);
- if (llcd->llcd_cookiebytes == 0) {
- CDEBUG(D_HA, "put empty llcd %p:%p\n",
- llcd, llcd->llcd_ctxt);
- llcd_put(llcd);
- continue;
- }
-
- down(&llcd->llcd_ctxt->loc_sem);
- if (llcd->llcd_ctxt->loc_imp == NULL) {
- up(&llcd->llcd_ctxt->loc_sem);
- CWARN("import will be destroyed, put "
- "llcd %p:%p\n", llcd, llcd->llcd_ctxt);
- llcd_put(llcd);
- continue;
- }
-
- request = ptlrpc_prep_req(import, OBD_LOG_CANCEL, 1,
- &llcd->llcd_cookiebytes,
- bufs);
- up(&llcd->llcd_ctxt->loc_sem);
-
- if (request == NULL) {
- rc = -ENOMEM;
- CERROR("error preparing commit: rc %d\n", rc);
-
- spin_lock(&lcm->lcm_llcd_lock);
- list_splice(&lcd->lcd_llcd_list,
- &lcm->lcm_llcd_resend);
- INIT_LIST_HEAD(&lcd->lcd_llcd_list);
- spin_unlock(&lcm->lcm_llcd_lock);
- break;
- }
-
- request->rq_replen = lustre_msg_size(0, NULL);
- down(&llcd->llcd_ctxt->loc_sem);
- if (llcd->llcd_ctxt->loc_imp == NULL) {
- up(&llcd->llcd_ctxt->loc_sem);
- CWARN("import will be destroyed, put "
- "llcd %p:%p\n", llcd, llcd->llcd_ctxt);
- llcd_put(llcd);
- ptlrpc_req_finished(request);
- continue;
- }
- rc = ptlrpc_queue_wait(request);
- ptlrpc_req_finished(request);
- up(&llcd->llcd_ctxt->loc_sem);
-
- /* If the RPC failed, we put this and the remaining
- * messages onto the resend list for another time. */
- if (rc == 0) {
- llcd_put(llcd);
- continue;
- }
-
-#if 0 /* FIXME just put llcd, not put it on resend list */
- spin_lock(&lcm->lcm_llcd_lock);
- list_splice(&lcd->lcd_llcd_list, &lcm->lcm_llcd_resend);
- if (++llcd->llcd_tries < 5) {
- CERROR("commit %p failed on attempt %d: rc %d\n",
- llcd, llcd->llcd_tries, rc);
-
- list_add_tail(&llcd->llcd_list,
- &lcm->lcm_llcd_resend);
- spin_unlock(&lcm->lcm_llcd_lock);
- } else {
- spin_unlock(&lcm->lcm_llcd_lock);
-#endif
- CERROR("commit %p:%p drop %d cookies: rc %d\n",
- llcd, llcd->llcd_ctxt,
- (int)(llcd->llcd_cookiebytes /
- sizeof(*llcd->llcd_cookies)), rc);
- llcd_put(llcd);
-#if 0
- }
- break;
-#endif
- }