Linux Kernel
3.7.1
|
#include <linux/slab.h>
#include <linux/init.h>
#include <linux/export.h>
#include <linux/err.h>
#include <linux/string.h>
#include <linux/idr.h>
#include <linux/spinlock.h>
Go to the source code of this file.
EXPORT_SYMBOL | ( | idr_pre_get | ) |
EXPORT_SYMBOL | ( | idr_get_new_above | ) |
EXPORT_SYMBOL | ( | idr_get_new | ) |
EXPORT_SYMBOL | ( | idr_remove | ) |
EXPORT_SYMBOL | ( | idr_remove_all | ) |
EXPORT_SYMBOL | ( | idr_destroy | ) |
EXPORT_SYMBOL | ( | idr_find | ) |
EXPORT_SYMBOL | ( | idr_for_each | ) |
EXPORT_SYMBOL | ( | idr_get_next | ) |
EXPORT_SYMBOL | ( | idr_replace | ) |
EXPORT_SYMBOL | ( | idr_init | ) |
EXPORT_SYMBOL | ( | ida_pre_get | ) |
EXPORT_SYMBOL | ( | ida_get_new_above | ) |
EXPORT_SYMBOL | ( | ida_get_new | ) |
EXPORT_SYMBOL | ( | ida_remove | ) |
EXPORT_SYMBOL | ( | ida_destroy | ) |
EXPORT_SYMBOL | ( | ida_simple_get | ) |
EXPORT_SYMBOL | ( | ida_simple_remove | ) |
EXPORT_SYMBOL | ( | ida_init | ) |
ida_get_new - allocate new ID : idr handle : pointer to the allocated handle
Allocate new ID. It should be called with any required locks.
If memory is required, it will return %-EAGAIN, you should unlock and go back to the idr_pre_get() call. If the idr is full, it will return %-ENOSPC.
returns a value in the range %0 ... %0x7fffffff.
ida_get_new_above - allocate new ID above or equal to a start id : ida handle : id to start search at : pointer to the allocated handle
Allocate new ID above or equal to . It should be called with any required locks.
If memory is required, it will return %-EAGAIN, you should unlock and go back to the ida_pre_get() call. If the ida is full, it will return %-ENOSPC.
returns a value in the range ... %0x7fffffff.
ida_pre_get - reserve resources for ida allocation : ida handle : memory allocation flag
This function should be called prior to locking and calling the following function. It preallocates enough memory to satisfy the worst possible allocation.
If the system is REALLY out of memory this function returns %0, otherwise %1.
ida_simple_get - get a new id. : the (initialized) ida. : the minimum id (inclusive, < 0x8000000) : the maximum id (exclusive, < 0x8000000 or 0) : memory allocation flags
Allocates an id in the range start <= id < end, or returns -ENOSPC. On memory allocation failure, returns -ENOMEM.
Use ida_simple_remove() to get rid of an id.
idr_find - return pointer for given id : idr handle : lookup key
Return the pointer given the id it has been registered with. A NULL return indicates that is not valid or you passed NULL in idr_get_new().
This function can be called under rcu_read_lock(), given that the leaf pointers lifetimes are correctly managed.
idr_get_new - allocate new idr entry : idr handle : pointer you want associated with the id : pointer to the allocated handle
If allocation from IDR's private freelist fails, idr_get_new_above() will return %-EAGAIN. The caller should retry the idr_pre_get() call to refill IDR's preallocation and then retry the idr_get_new_above() call.
If the idr is full idr_get_new_above() will return %-ENOSPC.
returns a value in the range %0 ... %0x7fffffff
idr_get_new_above - allocate new idr entry above or equal to a start id : idr handle : pointer you want associated with the id : id to start search at : pointer to the allocated handle
This is the allocate id function. It should be called with any required locks.
If allocation from IDR's private freelist fails, idr_get_new_above() will return %-EAGAIN. The caller should retry the idr_pre_get() call to refill IDR's preallocation and then retry the idr_get_new_above() call.
If the idr is full idr_get_new_above() will return %-ENOSPC.
returns a value in the range ... %0x7fffffff
idr_get_next - lookup next object of id to given id. : idr handle : pointer to lookup key
Returns pointer to registered object with id, which is next number to given id. After being looked up, * will be updated for the next iteration.
This function can be called under rcu_read_lock(), given that the leaf pointers lifetimes are correctly managed.
idr_pre_get - reserve resources for idr allocation : idr handle : memory allocation flags
This function should be called prior to calling the idr_get_new* functions. It preallocates enough memory to satisfy the worst possible allocation. The caller should pass in GFP_KERNEL if possible. This of course requires that no spinning locks be held.
If the system is REALLY out of memory this function returns %0, otherwise %1.
idr_remove_all - remove all ids from the given idr tree : idr handle
idr_destroy() only frees up unused, cached idp_layers, but this function will remove all id mappings and leave all idp_layers unused.
A typical clean-up sequence for objects stored in an idr tree will use idr_for_each() to free all objects, if necessay, then idr_remove_all() to remove all ids, and idr_destroy() to free up the cached idr_layers.
idr_replace - replace pointer for given id : idr handle : pointer you want associated with the id : lookup key
Replace the pointer registered with an id and return the old value. A %-ENOENT return indicates that was not found. A %-EINVAL return indicates that was not within valid constraints.
The caller must serialize with writers.