int compare_nfs4_owner_key(hash_buffer_t * buff1, hash_buffer_t * buff2) { if(isFullDebug(COMPONENT_STATE) && isDebug(COMPONENT_HASHTABLE)) { char str1[HASHTABLE_DISPLAY_STRLEN]; char str2[HASHTABLE_DISPLAY_STRLEN]; display_nfs4_owner_key(buff1, str1); display_nfs4_owner_key(buff2, str2); if(isDebug(COMPONENT_HASHTABLE)) LogFullDebug(COMPONENT_STATE, "{%s} vs {%s}", str1, str2); } state_nfs4_owner_name_t *pname1 = (state_nfs4_owner_name_t *) buff1->pdata; state_nfs4_owner_name_t *pname2 = (state_nfs4_owner_name_t *) buff2->pdata; if(pname1 == NULL || pname2 == NULL) return 1; if(pname1->son_islock != pname2->son_islock) return 1; if(pname1->son_clientid != pname2->son_clientid) return 1; if(pname1->son_owner_len != pname2->son_owner_len) return 1; return memcmp(pname1->son_owner_val, pname2->son_owner_val, pname1->son_owner_len); } /* compare_nfs4_owner */
/** * nfs4_owner_Set * * * This routine sets a open owner into the related hashtable * * @return 1 if ok, 0 otherwise. * */ int nfs4_owner_Set(state_nfs4_owner_name_t * pname, state_owner_t * powner) { hash_buffer_t buffkey; hash_buffer_t buffval; int rc; buffkey.pdata = (caddr_t) pname; buffkey.len = sizeof(state_nfs4_owner_name_t); if(isFullDebug(COMPONENT_STATE) && isDebug(COMPONENT_HASHTABLE)) { char str[HASHTABLE_DISPLAY_STRLEN]; display_nfs4_owner_key(&buffkey, str); LogFullDebug(COMPONENT_STATE, "KEY {%s}", str); } buffval.pdata = (caddr_t) powner; buffval.len = sizeof(state_owner_t); P(nfs4_owner_counter_lock); nfs4_owner_counter += 1; powner->so_owner.so_nfs4_owner.so_counter = nfs4_owner_counter; V(nfs4_owner_counter_lock); rc = HashTable_Test_And_Set (ht_nfs4_owner, &buffkey, &buffval, HASHTABLE_SET_HOW_SET_NO_OVERWRITE); if(rc != HASHTABLE_SUCCESS) { LogDebug(COMPONENT_STATE, "Failed to insert nfs4 owner into hash table rc = %d", rc); return 0; } return 1; } /* nfs4_owner_Set */
/** * * nfs4_owner_Get_Pointer * * This routine gets a pointer to an open owner from the open owners's hashtable. * * @param pstate [IN] pointer to the stateid to be checked. * @param ppstate_data [OUT] pointer's state found * * @return 1 if ok, 0 otherwise. * */ int nfs4_owner_Get_Pointer(state_nfs4_owner_name_t * pname, state_owner_t ** powner) { hash_buffer_t buffkey; hash_buffer_t buffval; if(isFullDebug(COMPONENT_STATE) && isDebug(COMPONENT_HASHTABLE)) { char str[HASHTABLE_DISPLAY_STRLEN]; buffkey.pdata = (caddr_t) pname; buffkey.len = sizeof(state_nfs4_owner_name_t); display_nfs4_owner_key(&buffkey, str); LogFullDebug(COMPONENT_STATE, "KEY {%s}", str); } buffkey.pdata = (caddr_t) pname; buffkey.len = sizeof(state_nfs4_owner_name_t); if(HashTable_GetRef(ht_nfs4_owner, &buffkey, &buffval, Hash_inc_state_owner_ref) != HASHTABLE_SUCCESS) { *powner = NULL; LogFullDebug(COMPONENT_STATE, "NOTFOUND"); return 0; } *powner = (state_owner_t *) buffval.pdata; LogFullDebug(COMPONENT_STATE, "FOUND"); return 1; } /* nfs4_owner_Get_Pointer */