aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/idr.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/idr.h')
-rw-r--r--include/linux/idr.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/include/linux/idr.h b/include/linux/idr.h
index 9a2d762124de..fa035f96f2a3 100644
--- a/include/linux/idr.h
+++ b/include/linux/idr.h
@@ -15,6 +15,7 @@
15#include <linux/types.h> 15#include <linux/types.h>
16#include <linux/bitops.h> 16#include <linux/bitops.h>
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/rcupdate.h>
18 19
19#if BITS_PER_LONG == 32 20#if BITS_PER_LONG == 32
20# define IDR_BITS 5 21# define IDR_BITS 5
@@ -51,6 +52,7 @@ struct idr_layer {
51 unsigned long bitmap; /* A zero bit means "space here" */ 52 unsigned long bitmap; /* A zero bit means "space here" */
52 struct idr_layer *ary[1<<IDR_BITS]; 53 struct idr_layer *ary[1<<IDR_BITS];
53 int count; /* When zero, we can release it */ 54 int count; /* When zero, we can release it */
55 struct rcu_head rcu_head;
54}; 56};
55 57
56struct idr { 58struct idr {
@@ -71,6 +73,28 @@ struct idr {
71} 73}
72#define DEFINE_IDR(name) struct idr name = IDR_INIT(name) 74#define DEFINE_IDR(name) struct idr name = IDR_INIT(name)
73 75
76/* Actions to be taken after a call to _idr_sub_alloc */
77#define IDR_NEED_TO_GROW -2
78#define IDR_NOMORE_SPACE -3
79
80#define _idr_rc_to_errno(rc) ((rc) == -1 ? -EAGAIN : -ENOSPC)
81
82/**
83 * idr synchronization (stolen from radix-tree.h)
84 *
85 * idr_find() is able to be called locklessly, using RCU. The caller must
86 * ensure calls to this function are made within rcu_read_lock() regions.
87 * Other readers (lock-free or otherwise) and modifications may be running
88 * concurrently.
89 *
90 * It is still required that the caller manage the synchronization and
91 * lifetimes of the items. So if RCU lock-free lookups are used, typically
92 * this would mean that the items have their own locks, or are amenable to
93 * lock-free access; and that the items are freed by RCU (or only freed after
94 * having been deleted from the idr tree *and* a synchronize_rcu() grace
95 * period).
96 */
97
74/* 98/*
75 * This is what we export. 99 * This is what we export.
76 */ 100 */