/** * @brief Compare two NFSv4 owners in the hash table * * @param[in] buff1 One key * @param[in] buff2 Another owner * * @retval 0 on equality. * @retval 1 on inequality. */ int compare_nfs4_owner_key(struct gsh_buffdesc *buff1, struct gsh_buffdesc *buff2) { state_owner_t *pkey1 = buff1->addr; state_owner_t *pkey2 = buff2->addr; if (isFullDebug(COMPONENT_STATE) && isDebug(COMPONENT_HASHTABLE)) { char str1[LOG_BUFF_LEN / 2]; char str2[LOG_BUFF_LEN / 2]; struct display_buffer dspbuf1 = {sizeof(str1), str1, str1}; struct display_buffer dspbuf2 = {sizeof(str2), str2, str2}; display_owner(&dspbuf1, pkey1); display_owner(&dspbuf2, pkey2); if (isDebug(COMPONENT_HASHTABLE)) LogFullDebug(COMPONENT_STATE, "{%s} vs {%s}", str1, str2); } if (pkey1 == NULL || pkey2 == NULL) return 1; if (pkey1->so_type != pkey2->so_type) return 1; return compare_nfs4_owner(pkey1, pkey2); }
/** * @brief Compare two NFSv4 owners in the hash table * * @param[in] buff1 One key * @param[in] buff2 Another owner * * @retval 0 on equality. * @retval 1 on inequality. */ int compare_nfs4_owner_key(struct gsh_buffdesc *buff1, struct gsh_buffdesc *buff2) { state_owner_t *pkey1 = buff1->addr; state_owner_t *pkey2 = buff2->addr; if (isFullDebug(COMPONENT_STATE) && isDebug(COMPONENT_HASHTABLE)) { char str1[HASHTABLE_DISPLAY_STRLEN]; char str2[HASHTABLE_DISPLAY_STRLEN]; DisplayOwner(pkey1, str1); DisplayOwner(pkey2, str2); if (isDebug(COMPONENT_HASHTABLE)) LogFullDebug(COMPONENT_STATE, "{%s} vs {%s}", str1, str2); } if (pkey1 == NULL || pkey2 == NULL) return 1; if (pkey1->so_type != pkey2->so_type) return 1; return compare_nfs4_owner(pkey1, pkey2); }
int compare_nfs4_owner(state_owner_t * powner1, state_owner_t * powner2) { if(isFullDebug(COMPONENT_STATE) && isDebug(COMPONENT_HASHTABLE)) { char str1[HASHTABLE_DISPLAY_STRLEN]; char str2[HASHTABLE_DISPLAY_STRLEN]; display_nfs4_owner(powner1, str1); display_nfs4_owner(powner2, str2); LogFullDebug(COMPONENT_STATE, "{%s} vs {%s}", str1, str2); } if(powner1 == NULL || powner2 == NULL) return 1; if(powner1 == powner2) return 0; if(powner1->so_type == STATE_LOCK_OWNER_NFSV4 && powner2->so_type == STATE_OPEN_OWNER_NFSV4) return compare_nfs4_owner(powner1->so_owner.so_nfs4_owner.so_related_owner, powner2); if(powner2->so_type == STATE_LOCK_OWNER_NFSV4 && powner1->so_type == STATE_OPEN_OWNER_NFSV4) return compare_nfs4_owner(powner2->so_owner.so_nfs4_owner.so_related_owner, powner1); if(powner1->so_type != powner2->so_type) return 1; if(powner1->so_owner.so_nfs4_owner.so_clientid != powner2->so_owner.so_nfs4_owner.so_clientid) return 1; if(powner1->so_owner_len != powner2->so_owner_len) return 1; return memcmp(powner1->so_owner_val, powner2->so_owner_val, powner1->so_owner_len); }