nfs-ganesha 1.4
Functions

Functions in the public Hash Table interface

Internal implementation details of the hash table

Functions

struct hash_tableHashTable_Init (struct hash_param *hparam)
 Initialize a new hash table.
hash_error_t HashTable_Destroy (struct hash_table *ht, int(*free_func)(struct hash_buff, struct hash_buff))
 Dispose of a hash table.
hash_error_t HashTable_GetLatch (struct hash_table *ht, struct hash_buff *key, struct hash_buff *val, int may_write, struct hash_latch *latch)
 Look up an entry, latching the table.
void HashTable_ReleaseLatched (struct hash_table *ht, struct hash_latch *latch)
 Release lock held on hash table.
hash_error_t HashTable_SetLatched (struct hash_table *ht, struct hash_buff *key, struct hash_buff *val, struct hash_latch *latch, int overwrite, struct hash_buff *stored_key, struct hash_buff *stored_val)
 Set a value in a table following a previous GetLatch.
hash_error_t HashTable_DeleteLatched (struct hash_table *ht, struct hash_buff *key, struct hash_latch *latch, struct hash_buff *stored_key, struct hash_buff *stored_val)
 Delete a value from the store following a previous GetLatch.
hash_error_t HashTable_Delall (struct hash_table *ht, int(*free_func)(struct hash_buff, struct hash_buff))
 Remove and free all (key,val) couples from the hash store.
void HashTable_GetStats (struct hash_table *ht, struct hash_stat *hstat)
 Get information on the hash table.
size_t HashTable_GetSize (struct hash_table *ht)
 Gets the number of entries in the hashtable.
void HashTable_Log (log_components_t component, struct hash_table *ht)
 Log information about the hashtable.
hash_error_t HashTable_Test_And_Set (struct hash_table *ht, struct hash_buff *key, struct hash_buff *val, hash_set_how_t how)
 Set a pair (key,value) into the Hash Table.
hash_error_t HashTable_GetRef (hash_table_t *ht, hash_buffer_t *key, hash_buffer_t *val, void(*get_ref)(hash_buffer_t *))
 Look up a value and take a reference.
hash_error_t HashTable_Get_and_Del (hash_table_t *ht, hash_buffer_t *key, hash_buffer_t *val, hash_buffer_t *stored_key)
 Look up, return, and remove an entry.
hash_error_t HashTable_DelRef (hash_table_t *ht, hash_buffer_t *key, hash_buffer_t *stored_key, hash_buffer_t *stored_val, int(*put_ref)(hash_buffer_t *))
 Decrement the refcount of and possibly remove an entry.
hash_error_t HashTable_DelSafe (hash_table_t *ht, hash_buffer_t *key, hash_buffer_t *val)
 Remove an entry if key and value both match.

Function Documentation

hash_error_t HashTable_Delall ( struct hash_table ht,
int(*)(struct hash_buff, struct hash_buff free_func 
)

Remove and free all (key,val) couples from the hash store.

This function removes all (key,val) couples from the hashtable and frees the stored data using the supplied function

Parameters:
[in,out]htThe hashtable to be cleared of all entries
[in]free_funcThe function with which to free the contents of each entry
Returns:
HASHTABLE_SUCCESS or errors

Definition at line 857 of file HashTable.c.

hash_error_t HashTable_DeleteLatched ( struct hash_table ht,
struct hash_buff key,
struct hash_latch latch,
struct hash_buff stored_key,
struct hash_buff stored_val 
)

Delete a value from the store following a previous GetLatch.

This function removes a value from the a hash store, the value already having been looked up with GetLatched. In all cases, the lock is released. HashTable_GetLatch must have been called with may_read true.

Parameters:
[in,out]htThe hash store to be modified
[in]keyA buffer descriptore locating the key to remove
[in]latchA pointer to a structure filled by a previous call to HashTable_GetLatched.
[out]stored_keyIf non-NULL, a buffer descriptor the removed key as stored.
[out]stored_valIf non-NULL, a buffer descriptor for the removed value as stored.
Return values:
HASHTABLE_SUCCESSon non-colliding insert
Othererrors on failure

Definition at line 763 of file HashTable.c.

hash_error_t HashTable_DelRef ( hash_table_t ht,
hash_buffer_t key,
hash_buffer_t stored_key,
hash_buffer_t stored_val,
int(*)(hash_buffer_t *)  put_ref 
)

Decrement the refcount of and possibly remove an entry.

This function decrements the reference count and deletes the entry if it goes to zero.

Parameters:
[in,out]htThe hashtable to be modified
[in]keyThe key corresponding to the entry to delete
[out]stored_keyIf non-NULL, a buffer descriptor specifying the key as stored in the hash table
[out]stored_valIf non-NULL, a buffer descriptor specifying the key as stored in the hash table
[in]put_refFunction to decrement the reference count of the located object. If the function returns 0, the entry is deleted. If put_ref is NULL, the entry is deleted unconditionally.
Return values:
HASHTABLE_SUCCESSon deletion
HASHTABLE_NOT_DELETEDput_ref returned a non-zero value

Definition at line 1227 of file HashTable.c.

hash_error_t HashTable_DelSafe ( hash_table_t ht,
hash_buffer_t key,
hash_buffer_t val 
)

Remove an entry if key and value both match.

This function looks up an entry and removes it if both the key and the supplied pointer matches the stored value pointer.

Parameters:
[in,out]htThe hashtable to be modified
[in]keyThe key corresponding to the entry to delete
[in]valA pointer, which should match the stored entry's value pointer.
Return values:
HASHTABLE_SUCCESSon deletion
HASHTABLE_NO_SUCH_KEYif the key was not found or the values did not match.

Definition at line 1291 of file HashTable.c.

hash_error_t HashTable_Destroy ( struct hash_table ht,
int(*)(struct hash_buff, struct hash_buff free_func 
)

Dispose of a hash table.

This function deletes all the entries from the given hash table and then destroys the hash table.

Parameters:
[in,out]htPointer to the hash table. After calling this function, the memory pointed to by ht must not be accessed in any way.
[in]free_funcFunction to free entries as they are deleted
Returns:
HASHTABLE_SUCCESS on success, other things on failure

Definition at line 411 of file HashTable.c.

hash_error_t HashTable_Get_and_Del ( hash_table_t ht,
hash_buffer_t key,
hash_buffer_t val,
hash_buffer_t stored_key 
)

Look up, return, and remove an entry.

If the object specified by key can be found, it will be removed from the hash table and returned to the caller.

Parameters:
[in]htThe hash table to be altered
[in]keyThe key to search for and remove
[out]valThe value associated with the found object
[out]stored_keyBuffer descriptor for key actually stored
Returns:
HASHTABLE_SUCCESS or errors

Definition at line 1176 of file HashTable.c.

hash_error_t HashTable_GetLatch ( struct hash_table ht,
struct hash_buff key,
struct hash_buff val,
int  may_write,
struct hash_latch latch 
)

Look up an entry, latching the table.

This function looks up an entry in the hash table and latches the partition in which that entry would belong in preparation for other activities. This function is a primitive and is intended more for use building other access functions than for client code itself.

[in] ht The hash table to search [in] key The key for which to search [out] val The value found [in] may_write This must be TRUE if the followup call might mutate the hash table (set or delete) [out] latch Opaque structure holding information on the table.

Return values:
HASHTABLE_SUCCESSThe entry was found, the table is latched.
HASHTABLE_ERROR_NOT_FOUNDThe entry was not found, the table is latched.
Others,failure,thetable is not latched.

Definition at line 462 of file HashTable.c.

hash_error_t HashTable_GetRef ( hash_table_t ht,
hash_buffer_t key,
hash_buffer_t val,
void(*)(hash_buffer_t *)  get_ref 
)

Look up a value and take a reference.

This function attempts to locate a key in the hash store and return the associated value. It also calls the supplied function to take a reference before releasing the partition lock. It is implemented as a wrapper around HashTable_GetLatched.

Parameters:
[in]htThe hash store to be searched
[in]keyA buffer descriptore locating the key to find
[out]valA buffer descriptor locating the value found
[in]get_refA function to take a reference on the supplied value
Returns:
HASHTABLE_SUCCESS or errors

Definition at line 1133 of file HashTable.c.

size_t HashTable_GetSize ( struct hash_table ht)

Gets the number of entries in the hashtable.

This function gets the number of entries in the hashtable.

Parameters:
[in]htThe hashtable to be interrogated
Returns:
the number of found entries

Definition at line 966 of file HashTable.c.

void HashTable_GetStats ( struct hash_table ht,
struct hash_stat hstat 
)

Get information on the hash table.

This function provides statistical information (mostly for debugging purposes) on the hash table. Some of this information must be computed at call-time

Parameters:
[in]htThe hashtable to be interrogate
[out]hstatThe result structure to be filled in

Definition at line 921 of file HashTable.c.

struct hash_table* HashTable_Init ( struct hash_param hparam) [read]

Initialize a new hash table.

This function initializes and allocates storage for a hash table.

Parameters:
[in]hparamParameters to determine the hash table's behaviour
Returns:
Pointer to the new hash table, NULL on failure

Definition at line 298 of file HashTable.c.

void HashTable_Log ( log_components_t  component,
struct hash_table ht 
)

Log information about the hashtable.

This debugging function prints information about the hash table to the log.

Parameters:
[in]componentThe component debugging config to use.
[in]htThe hashtable to be used.

Definition at line 989 of file HashTable.c.

void HashTable_ReleaseLatched ( struct hash_table ht,
struct hash_latch latch 
)

Release lock held on hash table.

This function releases the lock on the hash partition acquired and retained by a call to HashTable_GetLatch. This function must be used to free any acquired lock but ONLY if the lock was not already freed by some other means (HashTable_SetLatched or HashTable_DelLatched).

Parameters:
[in]htThe hash table with the lock to be released
[in]latchThe latch structure holding retained state

Definition at line 573 of file HashTable.c.

hash_error_t HashTable_SetLatched ( struct hash_table ht,
struct hash_buff key,
struct hash_buff val,
struct hash_latch latch,
int  overwrite,
struct hash_buff stored_key,
struct hash_buff stored_val 
)

Set a value in a table following a previous GetLatch.

This function sets a value in a hash table following a previous call to the HashTable_GetLatch function. It must only be used after such a call made with the may_write parameter set to true. In all cases, the lock on the hash table is released.

Parameters:
[in,out]htThe hash store to be modified
[in]keyA buffer descriptor locating the key to set
[in]valA buffer descriptor locating the value to insert
[in]latchA pointer to a structure filled by a previous call to HashTable_GetLatched.
[in]overwriteIf true, overwrite a prexisting key, otherwise return error on collision.
[out]stored_keyIf non-NULL, a buffer descriptor for an overwritten key as stored.
[out]stored_valIf non-NULL, a buffer descriptor for an overwritten value as stored.
Return values:
HASHTABLE_SUCCESSon non-colliding insert
HASHTABLE_ERROR_KEY_ALREADY_EXISTSif overwrite disabled
HASHTABLE_OVERWRITTENon successful overwrite
Othererrors on failure

Definition at line 609 of file HashTable.c.

hash_error_t HashTable_Test_And_Set ( struct hash_table ht,
struct hash_buff key,
struct hash_buff val,
hash_set_how_t  how 
)

Set a pair (key,value) into the Hash Table.

Depending on the value of 'how', this function sets a value into the hash table or tests that the hash table contains that value.

This function is deprecated.

Parameters:
[in,out]htThe hashtable to test or alter
[in]keyThe key to be set
[in]valThe value to be stored
[in]howA value determining whether this is a test, a set with overwrite, or a set without overwrite.
Return values:
HASHTABLE_SUCCESSif successfull.

Definition at line 1068 of file HashTable.c.