/** * * nlm4_send_grant_msg: Send NLMPROC4_GRANTED_MSG * * This runs in the nlm_asyn_thread context. */ static void nlm4_send_grant_msg(state_async_queue_t *arg) { int retval; char buffer[1024]; state_status_t state_status = STATE_SUCCESS; state_cookie_entry_t * cookie_entry; fsal_op_context_t context, * pcontext = &context; state_nlm_async_data_t * nlm_arg = &arg->state_async_data.state_nlm_async_data; if(isDebug(COMPONENT_NLM)) { netobj_to_string(&nlm_arg->nlm_async_args.nlm_async_grant.cookie, buffer, sizeof(buffer)); LogDebug(COMPONENT_NLM, "Sending GRANTED for arg=%p svid=%d start=%llx len=%llx cookie=%s", arg, nlm_arg->nlm_async_args.nlm_async_grant.alock.svid, (unsigned long long) nlm_arg->nlm_async_args.nlm_async_grant.alock.l_offset, (unsigned long long) nlm_arg->nlm_async_args.nlm_async_grant.alock.l_len, buffer); } retval = nlm_send_async(NLMPROC4_GRANTED_MSG, nlm_arg->nlm_async_host, &(nlm_arg->nlm_async_args.nlm_async_grant), nlm_arg->nlm_async_key); dec_nlm_client_ref(nlm_arg->nlm_async_host); free_grant_arg(arg); /* If success, we are done. */ if(retval == RPC_SUCCESS) return; /* * We are not able call granted callback. Some client may retry * the lock again. So remove the existing blocked nlm entry */ LogMajor(COMPONENT_NLM, "GRANTED_MSG RPC call failed with return code %d. Removing the blocking lock", retval); if(state_find_grant(nlm_arg->nlm_async_args.nlm_async_grant.cookie.n_bytes, nlm_arg->nlm_async_args.nlm_async_grant.cookie.n_len, &cookie_entry, &state_status) != STATE_SUCCESS) { /* This must be an old NLM_GRANTED_RES */ LogFullDebug(COMPONENT_NLM, "Could not find cookie=%s status=%s", buffer, state_err_str(state_status)); return; } PTHREAD_RWLOCK_WRLOCK(&cookie_entry->sce_pentry->state_lock); if(cookie_entry->sce_lock_entry->sle_block_data == NULL || !nlm_block_data_to_fsal_context(cookie_entry->sce_lock_entry->sle_block_data, pcontext)) { /* Wow, we're not doing well... */ PTHREAD_RWLOCK_UNLOCK(&cookie_entry->sce_pentry->state_lock); LogFullDebug(COMPONENT_NLM, "Could not find block data for cookie=%s (must be an old NLM_GRANTED_RES)", buffer); return; } PTHREAD_RWLOCK_UNLOCK(&cookie_entry->sce_pentry->state_lock); if(state_release_grant(pcontext, cookie_entry, &state_status) != STATE_SUCCESS) { /* Huh? */ LogFullDebug(COMPONENT_NLM, "Could not release cookie=%s status=%s", buffer, state_err_str(state_status)); } }
/** * nlm4_Granted_Res: Lock Granted Result Handler * * @param parg [IN] * @param pexportlist [IN] * @param pcontextp [IN] * @param pclient [INOUT] * @param ht [INOUT] * @param preq [IN] * @param pres [OUT] * */ int nlm4_Granted_Res(nfs_arg_t * parg /* IN */ , exportlist_t * dummy_pexport /* IN */ , fsal_op_context_t * dummy_pcontext /* IN */ , cache_inode_client_t * pclient /* INOUT */ , hash_table_t * ht /* INOUT */ , struct svc_req *preq /* IN */ , nfs_res_t * pres /* OUT */ ) { nlm4_res * arg = &parg->arg_nlm4_res; char buffer[1024]; state_status_t state_status = STATE_SUCCESS; state_cookie_entry_t * cookie_entry; fsal_op_context_t context, * pcontext = &context; netobj_to_string(&arg->cookie, buffer, 1024); LogDebug(COMPONENT_NLM, "REQUEST PROCESSING: Calling nlm_Granted_Res cookie=%s", buffer); if(state_find_grant(arg->cookie.n_bytes, arg->cookie.n_len, &cookie_entry, &state_status) != STATE_SUCCESS) { /* This must be an old NLM_GRANTED_RES */ LogFullDebug(COMPONENT_NLM, "Could not find cookie=%s (must be an old NLM_GRANTED_RES)", buffer); return NFS_REQ_OK; } P(cookie_entry->sce_pentry->object.file.lock_list_mutex); if(cookie_entry->sce_lock_entry == NULL || cookie_entry->sce_lock_entry->sle_block_data == NULL || !nlm_block_data_to_fsal_context(&cookie_entry->sce_lock_entry->sle_block_data->sbd_block_data.sbd_nlm_block_data, pcontext)) { /* This must be an old NLM_GRANTED_RES */ V(cookie_entry->sce_pentry->object.file.lock_list_mutex); LogFullDebug(COMPONENT_NLM, "Could not find block data for cookie=%s (must be an old NLM_GRANTED_RES)", buffer); return NFS_REQ_OK; } V(cookie_entry->sce_pentry->object.file.lock_list_mutex); if(arg->stat.stat != NLM4_GRANTED) { LogMajor(COMPONENT_NLM, "Granted call failed due to client error, releasing lock"); if(state_release_grant(pcontext, cookie_entry, pclient, &state_status) != STATE_SUCCESS) { LogDebug(COMPONENT_NLM, "cache_inode_release_grant failed"); } } else { state_complete_grant(pcontext, cookie_entry, pclient); nlm_signal_async_resp(cookie_entry); } return NFS_REQ_OK; }
"Could not find block data for cookie=%s (must be an old NLM_GRANTED_RES)", buffer); goto out; } /* Initialize a context, it is ok if the export is stale because * we must clean up the cookie_entry. */ export = cookie_entry->sce_lock_entry->sle_export; get_gsh_export_ref(export); init_root_op_context(&root_op_context, export, export->fsal_export, NFS_V3, 0, NFS_REQUEST); state_status = state_release_grant(cookie_entry); release_root_op_context(); put_gsh_export(export); if (state_status != STATE_SUCCESS) { /* Huh? */ LogFullDebug(COMPONENT_NLM, "Could not release cookie=%s status=%s", buffer, state_err_str(state_status)); } out: free_grant_arg(arg); }