Commit c8615d3716fe327c2540cf514a34b227dc9b39e8
Committed by
Linus Torvalds
1 parent
8e467e855c
Exists in
master
and in
20 other branches
idr: deprecate idr_pre_get() and idr_get_new[_above]()
Now that all in-kernel users are converted to ues the new alloc interface, mark the old interface deprecated. We should be able to remove these in a few releases. Signed-off-by: Tejun Heo <tj@kernel.org> Cc: Rusty Russell <rusty@rustcorp.com.au> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 2 changed files with 55 additions and 52 deletions Side-by-side Diff
include/linux/idr.h
... | ... | @@ -73,8 +73,6 @@ |
73 | 73 | */ |
74 | 74 | |
75 | 75 | void *idr_find_slowpath(struct idr *idp, int id); |
76 | -int idr_pre_get(struct idr *idp, gfp_t gfp_mask); | |
77 | -int idr_get_new_above(struct idr *idp, void *ptr, int starting_id, int *id); | |
78 | 76 | void idr_preload(gfp_t gfp_mask); |
79 | 77 | int idr_alloc(struct idr *idp, void *ptr, int start, int end, gfp_t gfp_mask); |
80 | 78 | int idr_for_each(struct idr *idp, |
... | ... | @@ -120,19 +118,6 @@ |
120 | 118 | } |
121 | 119 | |
122 | 120 | /** |
123 | - * idr_get_new - allocate new idr entry | |
124 | - * @idp: idr handle | |
125 | - * @ptr: pointer you want associated with the id | |
126 | - * @id: pointer to the allocated handle | |
127 | - * | |
128 | - * Simple wrapper around idr_get_new_above() w/ @starting_id of zero. | |
129 | - */ | |
130 | -static inline int idr_get_new(struct idr *idp, void *ptr, int *id) | |
131 | -{ | |
132 | - return idr_get_new_above(idp, ptr, 0, id); | |
133 | -} | |
134 | - | |
135 | -/** | |
136 | 121 | * idr_for_each_entry - iterate over an idr's elements of a given type |
137 | 122 | * @idp: idr handle |
138 | 123 | * @entry: the type * to use as cursor |
... | ... | @@ -143,7 +128,56 @@ |
143 | 128 | entry != NULL; \ |
144 | 129 | ++id, entry = (typeof(entry))idr_get_next((idp), &(id))) |
145 | 130 | |
146 | -void __idr_remove_all(struct idr *idp); /* don't use */ | |
131 | +/* | |
132 | + * Don't use the following functions. These exist only to suppress | |
133 | + * deprecated warnings on EXPORT_SYMBOL()s. | |
134 | + */ | |
135 | +int __idr_pre_get(struct idr *idp, gfp_t gfp_mask); | |
136 | +int __idr_get_new_above(struct idr *idp, void *ptr, int starting_id, int *id); | |
137 | +void __idr_remove_all(struct idr *idp); | |
138 | + | |
139 | +/** | |
140 | + * idr_pre_get - reserve resources for idr allocation | |
141 | + * @idp: idr handle | |
142 | + * @gfp_mask: memory allocation flags | |
143 | + * | |
144 | + * Part of old alloc interface. This is going away. Use | |
145 | + * idr_preload[_end]() and idr_alloc() instead. | |
146 | + */ | |
147 | +static inline int __deprecated idr_pre_get(struct idr *idp, gfp_t gfp_mask) | |
148 | +{ | |
149 | + return __idr_pre_get(idp, gfp_mask); | |
150 | +} | |
151 | + | |
152 | +/** | |
153 | + * idr_get_new_above - allocate new idr entry above or equal to a start id | |
154 | + * @idp: idr handle | |
155 | + * @ptr: pointer you want associated with the id | |
156 | + * @starting_id: id to start search at | |
157 | + * @id: pointer to the allocated handle | |
158 | + * | |
159 | + * Part of old alloc interface. This is going away. Use | |
160 | + * idr_preload[_end]() and idr_alloc() instead. | |
161 | + */ | |
162 | +static inline int __deprecated idr_get_new_above(struct idr *idp, void *ptr, | |
163 | + int starting_id, int *id) | |
164 | +{ | |
165 | + return __idr_get_new_above(idp, ptr, starting_id, id); | |
166 | +} | |
167 | + | |
168 | +/** | |
169 | + * idr_get_new - allocate new idr entry | |
170 | + * @idp: idr handle | |
171 | + * @ptr: pointer you want associated with the id | |
172 | + * @id: pointer to the allocated handle | |
173 | + * | |
174 | + * Part of old alloc interface. This is going away. Use | |
175 | + * idr_preload[_end]() and idr_alloc() instead. | |
176 | + */ | |
177 | +static inline int __deprecated idr_get_new(struct idr *idp, void *ptr, int *id) | |
178 | +{ | |
179 | + return __idr_get_new_above(idp, ptr, 0, id); | |
180 | +} | |
147 | 181 | |
148 | 182 | /** |
149 | 183 | * idr_remove_all - remove all ids from the given idr tree |
lib/idr.c
... | ... | @@ -184,20 +184,7 @@ |
184 | 184 | } |
185 | 185 | } |
186 | 186 | |
187 | -/** | |
188 | - * idr_pre_get - reserve resources for idr allocation | |
189 | - * @idp: idr handle | |
190 | - * @gfp_mask: memory allocation flags | |
191 | - * | |
192 | - * This function should be called prior to calling the idr_get_new* functions. | |
193 | - * It preallocates enough memory to satisfy the worst possible allocation. The | |
194 | - * caller should pass in GFP_KERNEL if possible. This of course requires that | |
195 | - * no spinning locks be held. | |
196 | - * | |
197 | - * If the system is REALLY out of memory this function returns %0, | |
198 | - * otherwise %1. | |
199 | - */ | |
200 | -int idr_pre_get(struct idr *idp, gfp_t gfp_mask) | |
187 | +int __idr_pre_get(struct idr *idp, gfp_t gfp_mask) | |
201 | 188 | { |
202 | 189 | while (idp->id_free_cnt < MAX_IDR_FREE) { |
203 | 190 | struct idr_layer *new; |
... | ... | @@ -208,7 +195,7 @@ |
208 | 195 | } |
209 | 196 | return 1; |
210 | 197 | } |
211 | -EXPORT_SYMBOL(idr_pre_get); | |
198 | +EXPORT_SYMBOL(__idr_pre_get); | |
212 | 199 | |
213 | 200 | /** |
214 | 201 | * sub_alloc - try to allocate an id without growing the tree depth |
... | ... | @@ -375,25 +362,7 @@ |
375 | 362 | idr_mark_full(pa, id); |
376 | 363 | } |
377 | 364 | |
378 | -/** | |
379 | - * idr_get_new_above - allocate new idr entry above or equal to a start id | |
380 | - * @idp: idr handle | |
381 | - * @ptr: pointer you want associated with the id | |
382 | - * @starting_id: id to start search at | |
383 | - * @id: pointer to the allocated handle | |
384 | - * | |
385 | - * This is the allocate id function. It should be called with any | |
386 | - * required locks. | |
387 | - * | |
388 | - * If allocation from IDR's private freelist fails, idr_get_new_above() will | |
389 | - * return %-EAGAIN. The caller should retry the idr_pre_get() call to refill | |
390 | - * IDR's preallocation and then retry the idr_get_new_above() call. | |
391 | - * | |
392 | - * If the idr is full idr_get_new_above() will return %-ENOSPC. | |
393 | - * | |
394 | - * @id returns a value in the range @starting_id ... %0x7fffffff | |
395 | - */ | |
396 | -int idr_get_new_above(struct idr *idp, void *ptr, int starting_id, int *id) | |
365 | +int __idr_get_new_above(struct idr *idp, void *ptr, int starting_id, int *id) | |
397 | 366 | { |
398 | 367 | struct idr_layer *pa[MAX_IDR_LEVEL + 1]; |
399 | 368 | int rv; |
... | ... | @@ -406,7 +375,7 @@ |
406 | 375 | *id = rv; |
407 | 376 | return 0; |
408 | 377 | } |
409 | -EXPORT_SYMBOL(idr_get_new_above); | |
378 | +EXPORT_SYMBOL(__idr_get_new_above); | |
410 | 379 | |
411 | 380 | /** |
412 | 381 | * idr_preload - preload for idr_alloc() |
... | ... | @@ -907,7 +876,7 @@ |
907 | 876 | int ida_pre_get(struct ida *ida, gfp_t gfp_mask) |
908 | 877 | { |
909 | 878 | /* allocate idr_layers */ |
910 | - if (!idr_pre_get(&ida->idr, gfp_mask)) | |
879 | + if (!__idr_pre_get(&ida->idr, gfp_mask)) | |
911 | 880 | return 0; |
912 | 881 | |
913 | 882 | /* allocate free_bitmap */ |