nfs-ganesha 1.4
|
Functions | |
struct hash_table * | HashTable_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. |
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
[in,out] | ht | The hashtable to be cleared of all entries |
[in] | free_func | The function with which to free the contents of each entry |
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.
[in,out] | ht | The hash store to be modified |
[in] | key | A buffer descriptore locating the key to remove |
[in] | latch | A pointer to a structure filled by a previous call to HashTable_GetLatched. |
[out] | stored_key | If non-NULL, a buffer descriptor the removed key as stored. |
[out] | stored_val | If non-NULL, a buffer descriptor for the removed value as stored. |
HASHTABLE_SUCCESS | on non-colliding insert |
Other | errors 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.
[in,out] | ht | The hashtable to be modified |
[in] | key | The key corresponding to the entry to delete |
[out] | stored_key | If non-NULL, a buffer descriptor specifying the key as stored in the hash table |
[out] | stored_val | If non-NULL, a buffer descriptor specifying the key as stored in the hash table |
[in] | put_ref | Function 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. |
HASHTABLE_SUCCESS | on deletion |
HASHTABLE_NOT_DELETED | put_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.
[in,out] | ht | The hashtable to be modified |
[in] | key | The key corresponding to the entry to delete |
[in] | val | A pointer, which should match the stored entry's value pointer. |
HASHTABLE_SUCCESS | on deletion |
HASHTABLE_NO_SUCH_KEY | if 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.
[in,out] | ht | Pointer to the hash table. After calling this function, the memory pointed to by ht must not be accessed in any way. |
[in] | free_func | Function to free entries as they are deleted |
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.
[in] | ht | The hash table to be altered |
[in] | key | The key to search for and remove |
[out] | val | The value associated with the found object |
[out] | stored_key | Buffer descriptor for key actually stored |
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.
HASHTABLE_SUCCESS | The entry was found, the table is latched. |
HASHTABLE_ERROR_NOT_FOUND | The entry was not found, the table is latched. |
Others,failure,the | table 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.
[in] | ht | The hash store to be searched |
[in] | key | A buffer descriptore locating the key to find |
[out] | val | A buffer descriptor locating the value found |
[in] | get_ref | A function to take a reference on the supplied value |
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.
[in] | ht | The hashtable to be interrogated |
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
[in] | ht | The hashtable to be interrogate |
[out] | hstat | The 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.
[in] | hparam | Parameters to determine the hash table's behaviour |
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.
[in] | component | The component debugging config to use. |
[in] | ht | The 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).
[in] | ht | The hash table with the lock to be released |
[in] | latch | The 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.
[in,out] | ht | The hash store to be modified |
[in] | key | A buffer descriptor locating the key to set |
[in] | val | A buffer descriptor locating the value to insert |
[in] | latch | A pointer to a structure filled by a previous call to HashTable_GetLatched. |
[in] | overwrite | If true, overwrite a prexisting key, otherwise return error on collision. |
[out] | stored_key | If non-NULL, a buffer descriptor for an overwritten key as stored. |
[out] | stored_val | If non-NULL, a buffer descriptor for an overwritten value as stored. |
HASHTABLE_SUCCESS | on non-colliding insert |
HASHTABLE_ERROR_KEY_ALREADY_EXISTS | if overwrite disabled |
HASHTABLE_OVERWRITTEN | on successful overwrite |
Other | errors 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.
[in,out] | ht | The hashtable to test or alter |
[in] | key | The key to be set |
[in] | val | The value to be stored |
[in] | how | A value determining whether this is a test, a set with overwrite, or a set without overwrite. |
HASHTABLE_SUCCESS | if successfull. |
Definition at line 1068 of file HashTable.c.