Lines Matching refs:ids

38  *  The ids->rwsem must be taken when:
76 int ids;
110 * @ids: ipc identifier set
113 * below ipc_mni) then initialise the keys hashtable and ids idr.
115 void ipc_init_ids(struct ipc_ids *ids)
117 ids->in_use = 0;
118 ids->seq = 0;
119 init_rwsem(&ids->rwsem);
120 rhashtable_init(&ids->key_ht, &ipc_kht_params);
121 idr_init(&ids->ipcs_idr);
122 ids->max_idx = -1;
123 ids->last_idx = -1;
125 ids->next_id = -1;
135 * @ids: ipc id table to iterate.
139 int ids, int (*show)(struct seq_file *, void *))
149 iface->ids = ids;
164 * @ids: ipc identifier set
172 static struct kern_ipc_perm *ipc_findkey(struct ipc_ids *ids, key_t key)
176 ipcp = rhashtable_lookup_fast(&ids->key_ht, &key,
202 static inline int ipc_idr_alloc(struct ipc_ids *ids, struct kern_ipc_perm *new)
207 next_id = ids->next_id;
208 ids->next_id = -1;
226 max_idx = max(ids->in_use*3/2, ipc_min_cycle);
230 idx = idr_alloc_cyclic(&ids->ipcs_idr, NULL, 0, max_idx,
239 if (idx <= ids->last_idx) {
240 ids->seq++;
241 if (ids->seq >= ipcid_seq_max())
242 ids->seq = 0;
244 ids->last_idx = idx;
246 new->seq = ids->seq;
251 idr_replace(&ids->ipcs_idr, new, idx);
255 idx = idr_alloc(&ids->ipcs_idr, new, ipcid_to_idx(next_id),
265 * @ids: ipc identifier set
267 * @limit: limit for the number of used ids
269 * Add an entry 'new' to the ipc ids idr. The permissions object is
278 int ipc_addid(struct ipc_ids *ids, struct kern_ipc_perm *new, int limit)
290 if (ids->in_use >= limit)
305 idx = ipc_idr_alloc(ids, new);
309 err = rhashtable_insert_fast(&ids->key_ht, &new->khtnode,
312 idr_remove(&ids->ipcs_idr, idx);
323 ids->in_use++;
324 if (idx > ids->max_idx)
325 ids->max_idx = idx;
332 * @ids: ipc identifier set
339 static int ipcget_new(struct ipc_namespace *ns, struct ipc_ids *ids,
344 down_write(&ids->rwsem);
346 up_write(&ids->rwsem);
386 * @ids: ipc identifier set
397 static int ipcget_public(struct ipc_namespace *ns, struct ipc_ids *ids,
408 down_write(&ids->rwsem);
409 ipcp = ipc_findkey(ids, params->key);
434 up_write(&ids->rwsem);
441 * @ids: ipc identifier set
447 static void ipc_kht_remove(struct ipc_ids *ids, struct kern_ipc_perm *ipcp)
450 WARN_ON_ONCE(rhashtable_remove_fast(&ids->key_ht, &ipcp->khtnode,
456 * @ids: ipc identifier set
459 * The function determines the highest assigned index in @ids. It is intended
460 * to be called when ids->max_idx needs to be updated.
461 * Updating ids->max_idx is necessary when the current highest index ipc
467 static int ipc_search_maxidx(struct ipc_ids *ids, int limit)
483 if (idr_get_next(&ids->ipcs_idr, &tmpidx))
491 * @ids: ipc identifier set
497 void ipc_rmid(struct ipc_ids *ids, struct kern_ipc_perm *ipcp)
501 WARN_ON_ONCE(idr_remove(&ids->ipcs_idr, idx) != ipcp);
502 ipc_kht_remove(ids, ipcp);
503 ids->in_use--;
506 if (unlikely(idx == ids->max_idx)) {
507 idx = ids->max_idx-1;
509 idx = ipc_search_maxidx(ids, idx);
510 ids->max_idx = idx;
516 * @ids: ipc identifier set
522 void ipc_set_key_private(struct ipc_ids *ids, struct kern_ipc_perm *ipcp)
524 ipc_kht_remove(ids, ipcp);
619 * @ids: ipc identifier set
622 * Look for an id in the ipc ids idr and return associated ipc object.
627 struct kern_ipc_perm *ipc_obtain_object_idr(struct ipc_ids *ids, int id)
632 out = idr_find(&ids->ipcs_idr, idx);
641 * @ids: ipc identifier set
650 struct kern_ipc_perm *ipc_obtain_object_check(struct ipc_ids *ids, int id)
652 struct kern_ipc_perm *out = ipc_obtain_object_idr(ids, id);
666 * @ids: ipc identifier set
673 int ipcget(struct ipc_namespace *ns, struct ipc_ids *ids,
677 return ipcget_new(ns, ids, ops, params);
679 return ipcget_public(ns, ids, ops, params);
705 * @ids: the table of ids where to look for the ipc
723 struct ipc_ids *ids, int id, int cmd,
730 ipcp = ipc_obtain_object_check(ids, id);
787 * @ids: ipc identifier set
800 static struct kern_ipc_perm *sysvipc_find_ipc(struct ipc_ids *ids, loff_t *pos)
808 ipc = idr_get_next(&ids->ipcs_idr, &tmpidx);
831 return sysvipc_find_ipc(&iter->ns->ids[iface->ids], pos);
842 struct ipc_ids *ids;
844 ids = &iter->ns->ids[iface->ids];
850 down_read(&ids->rwsem);
861 return sysvipc_find_ipc(ids, pos);
869 struct ipc_ids *ids;
875 ids = &iter->ns->ids[iface->ids];
877 up_read(&ids->rwsem);