ipc: do cyclic id allocation for the ipc object.
[linux-2.6-microblaze.git] / ipc / util.c
index 71f3f39..d126d15 100644 (file)
@@ -220,9 +220,14 @@ static inline int ipc_idr_alloc(struct ipc_ids *ids, struct kern_ipc_perm *new)
         */
 
        if (next_id < 0) { /* !CHECKPOINT_RESTORE or next_id is unset */
+               int max_idx;
+
+               max_idx = max(ids->in_use*3/2, ipc_min_cycle);
+               max_idx = min(max_idx, ipc_mni);
 
                /* allocate the idx, with a NULL struct kern_ipc_perm */
-               idx = idr_alloc(&ids->ipcs_idr, NULL, 0, 0, GFP_NOWAIT);
+               idx = idr_alloc_cyclic(&ids->ipcs_idr, NULL, 0, max_idx,
+                                       GFP_NOWAIT);
 
                if (idx >= 0) {
                        /*