History

Merge branch 'ida-4.19' of git://git.infradead.org/users/willy/linux-dax

Pull IDA updates from Matthew Wilcox: "A better IDA API: id = ida_alloc(ida, GFP_xxx); ida_free(ida, id); rather than the cumbersome ida_simple_get(), ida_simple_remove(). The new IDA API is similar to ida_simple_get() but better named. The internal restructuring of the IDA code removes the bitmap preallocation nonsense. I hope the net -200 lines of code is convincing" * 'ida-4.19' of git://git.infradead.org/users/willy/linux-dax: (29 commits) ida: Change ida_get_new_above to return the id ida: Remove old API test_ida: check_ida_destroy and check_ida_alloc test_ida: Convert check_ida_conv to new API test_ida: Move ida_check_max test_ida: Move ida_check_leaf idr-test: Convert ida_check_nomem to new API ida: Start new test_ida module target/iscsi: Allocate session IDs from an IDA iscsi target: fix session creation failure handling drm/vmwgfx: Convert to new IDA API dmaengine: Convert to new IDA API ppc: Convert vas ID allocation to new IDA API media: Convert entity ID allocation to new IDA API ppc: Convert mmu context allocation to new IDA API Convert net_namespace to new IDA API cb710: Convert to new IDA API rsxx: Convert to new IDA API osd: Convert to new IDA API sd: Convert to new IDA API ...

Linus Torvalds committed 8 years ago

Commit aba16dc2 parents c4726e7 1df895128 files · +485 −679Browse files

Showing the changes to include/linux (1 of 28 files). Show all

Unified · Split

include/linux/idr.h+54−14
@@ -236,34 +236,74 @@ struct ida { · 235 unmodified lines
236236 }
237237 #define DEFINE_IDA(name) struct ida name = IDA_INIT(name)
238238
239−int ida_pre_get(struct ida *ida, gfp_t gfp_mask);
240−int ida_get_new_above(struct ida *ida, int starting_id, int *p_id);
241−void ida_remove(struct ida *ida, int id);
239+int ida_alloc_range(struct ida *, unsigned int min, unsigned int max, gfp_t);
240+void ida_free(struct ida *, unsigned int id);
242241 void ida_destroy(struct ida *ida);
243242
244−int ida_simple_get(struct ida *ida, unsigned int start, unsigned int end,
245− gfp_t gfp_mask);
246−void ida_simple_remove(struct ida *ida, unsigned int id);
243+/**
244+ * ida_alloc() - Allocate an unused ID.
245+ * @ida: IDA handle.
246+ * @gfp: Memory allocation flags.
247+ *
248+ * Allocate an ID between 0 and %INT_MAX, inclusive.
249+ *
250+ * Context: Any context.
251+ * Return: The allocated ID, or %-ENOMEM if memory could not be allocated,
252+ * or %-ENOSPC if there are no free IDs.
253+ */
254+static inline int ida_alloc(struct ida *ida, gfp_t gfp)
255+{
256+ return ida_alloc_range(ida, 0, ~0, gfp);
257+}
247258
248−static inline void ida_init(struct ida *ida)
259+/**
260+ * ida_alloc_min() - Allocate an unused ID.
261+ * @ida: IDA handle.
262+ * @min: Lowest ID to allocate.
263+ * @gfp: Memory allocation flags.
264+ *
265+ * Allocate an ID between @min and %INT_MAX, inclusive.
266+ *
267+ * Context: Any context.
268+ * Return: The allocated ID, or %-ENOMEM if memory could not be allocated,
269+ * or %-ENOSPC if there are no free IDs.
270+ */
271+static inline int ida_alloc_min(struct ida *ida, unsigned int min, gfp_t gfp)
249272 {
250− INIT_RADIX_TREE(&ida->ida_rt, IDR_RT_MARKER | GFP_NOWAIT);
273+ return ida_alloc_range(ida, min, ~0, gfp);
251274 }
252275
253276 /**
254− * ida_get_new - allocate new ID
255− * @ida: idr handle
256− * @p_id: pointer to the allocated handle
277+ * ida_alloc_max() - Allocate an unused ID.
278+ * @ida: IDA handle.
279+ * @max: Highest ID to allocate.
280+ * @gfp: Memory allocation flags.
281+ *
282+ * Allocate an ID between 0 and @max, inclusive.
257283 *
258− * Simple wrapper around ida_get_new_above() w/ @starting_id of zero.
284+ * Context: Any context.
285+ * Return: The allocated ID, or %-ENOMEM if memory could not be allocated,
286+ * or %-ENOSPC if there are no free IDs.
259287 */
260−static inline int ida_get_new(struct ida *ida, int *p_id)
288+static inline int ida_alloc_max(struct ida *ida, unsigned int max, gfp_t gfp)
261289 {
262− return ida_get_new_above(ida, 0, p_id);
290+ return ida_alloc_range(ida, 0, max, gfp);
263291 }
264292
293+static inline void ida_init(struct ida *ida)
294+{
295+ INIT_RADIX_TREE(&ida->ida_rt, IDR_RT_MARKER | GFP_NOWAIT);
296+}
297+
298+#define ida_simple_get(ida, start, end, gfp) \
299+ ida_alloc_range(ida, start, (end) - 1, gfp)
300+#define ida_simple_remove(ida, id) ida_free(ida, id)
301+
265302 static inline bool ida_is_empty(const struct ida *ida)
266303 {
267304 return radix_tree_empty(&ida->ida_rt);
268305 }
306+
307+/* in lib/radix-tree.c */
308+int ida_pre_get(struct ida *ida, gfp_t gfp_mask);
269309 #endif /* __IDR_H__ */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t