- /* 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;
- if (import)
- class_import_get(import);
- }
- 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[2] = { NULL, (char *)llcd->llcd_cookies };
-
- list_del(&llcd->llcd_list);
- if (llcd->llcd_cookiebytes == 0) {
- CDEBUG(D_RPCTRACE, "put empty llcd %p:%p\n",
- llcd, llcd->llcd_ctxt);
- llcd_put(llcd);
- continue;
- }
-
- mutex_down(&llcd->llcd_ctxt->loc_sem);
- if (llcd->llcd_ctxt->loc_imp == NULL) {
- mutex_up(&llcd->llcd_ctxt->loc_sem);
- CWARN("import will be destroyed, put "
- "llcd %p:%p\n", llcd, llcd->llcd_ctxt);
- llcd_put(llcd);
- continue;
- }
- mutex_up(&llcd->llcd_ctxt->loc_sem);
-
- if (!import || (import == LP_POISON) ||
- (import->imp_client == LP_POISON)) {
- CERROR("No import %p (llcd=%p, ctxt=%p)\n",
- import, llcd, llcd->llcd_ctxt);
- llcd_put(llcd);
- continue;
- }
-
- OBD_FAIL_TIMEOUT(OBD_FAIL_PTLRPC_DELAY_RECOV, 10);
-
- request = ptlrpc_request_alloc(import, &RQF_LOG_CANCEL);
- if (request == NULL) {
- rc = -ENOMEM;
- stop_log_commit(lcm, lcd, rc);
- break;
- }
-
- req_capsule_set_size(&request->rq_pill, &RMF_LOGCOOKIES,
- RCL_CLIENT,llcd->llcd_cookiebytes);
-
- rc = ptlrpc_request_bufs_pack(request,
- LUSTRE_LOG_VERSION,
- OBD_LOG_CANCEL, bufs,
- NULL);
- if (rc) {
- ptlrpc_request_free(request);
- stop_log_commit(lcm, lcd, rc);
- break;
- }
-
- /* XXX FIXME bug 249, 5515 */
- request->rq_request_portal = LDLM_CANCEL_REQUEST_PORTAL;
- request->rq_reply_portal = LDLM_CANCEL_REPLY_PORTAL;
-
- ptlrpc_request_set_replen(request);
- mutex_down(&llcd->llcd_ctxt->loc_sem);
- if (llcd->llcd_ctxt->loc_imp == NULL) {
- mutex_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;
- }
- mutex_up(&llcd->llcd_ctxt->loc_sem);
- rc = ptlrpc_queue_wait(request);
- ptlrpc_req_finished(request);
-
- /* 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;
- }
-
- 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);
- }