Lines Matching refs:ids

38  *  The ids->rwsem must be taken when:
75 int ids;
109 * @ids: ipc identifier set
112 * below ipc_mni) then initialise the keys hashtable and ids idr.
114 void ipc_init_ids(struct ipc_ids *ids)
116 ids->in_use = 0;
117 ids->seq = 0;
118 init_rwsem(&ids->rwsem);
119 rhashtable_init(&ids->key_ht, &ipc_kht_params);
120 idr_init(&ids->ipcs_idr);
121 ids->max_idx = -1;
122 ids->last_idx = -1;
124 ids->next_id = -1;
134 * @ids: ipc id table to iterate.
138 int ids, int (*show)(struct seq_file *, void *))
148 iface->ids = ids;
163 * @ids: ipc identifier set
171 static struct kern_ipc_perm *ipc_findkey(struct ipc_ids *ids, key_t key)
175 ipcp = rhashtable_lookup_fast(&ids->key_ht, &key,
201 static inline int ipc_idr_alloc(struct ipc_ids *ids, struct kern_ipc_perm *new)
206 next_id = ids->next_id;
207 ids->next_id = -1;
225 max_idx = max(ids->in_use*3/2, ipc_min_cycle);
229 idx = idr_alloc_cyclic(&ids->ipcs_idr, NULL, 0, max_idx,
238 if (idx <= ids->last_idx) {
239 ids->seq++;
240 if (ids->seq >= ipcid_seq_max())
241 ids->seq = 0;
243 ids->last_idx = idx;
245 new->seq = ids->seq;
250 idr_replace(&ids->ipcs_idr, new, idx);
254 idx = idr_alloc(&ids->ipcs_idr, new, ipcid_to_idx(next_id),
264 * @ids: ipc identifier set
266 * @limit: limit for the number of used ids
268 * Add an entry 'new' to the ipc ids idr. The permissions object is
277 int ipc_addid(struct ipc_ids *ids, struct kern_ipc_perm *new, int limit)
289 if (ids->in_use >= limit)
304 idx = ipc_idr_alloc(ids, new);
308 err = rhashtable_insert_fast(&ids->key_ht, &new->khtnode,
311 idr_remove(&ids->ipcs_idr, idx);
322 ids->in_use++;
323 if (idx > ids->max_idx)
324 ids->max_idx = idx;
331 * @ids: ipc identifier set
338 static int ipcget_new(struct ipc_namespace *ns, struct ipc_ids *ids,
343 down_write(&ids->rwsem);
345 up_write(&ids->rwsem);
385 * @ids: ipc identifier set
396 static int ipcget_public(struct ipc_namespace *ns, struct ipc_ids *ids,
407 down_write(&ids->rwsem);
408 ipcp = ipc_findkey(ids, params->key);
433 up_write(&ids->rwsem);
440 * @ids: ipc identifier set
446 static void ipc_kht_remove(struct ipc_ids *ids, struct kern_ipc_perm *ipcp)
449 WARN_ON_ONCE(rhashtable_remove_fast(&ids->key_ht, &ipcp->khtnode,
455 * @ids: ipc identifier set
461 void ipc_rmid(struct ipc_ids *ids, struct kern_ipc_perm *ipcp)
465 WARN_ON_ONCE(idr_remove(&ids->ipcs_idr, idx) != ipcp);
466 ipc_kht_remove(ids, ipcp);
467 ids->in_use--;
470 if (unlikely(idx == ids->max_idx)) {
475 } while (!idr_find(&ids->ipcs_idr, idx));
476 ids->max_idx = idx;
482 * @ids: ipc identifier set
488 void ipc_set_key_private(struct ipc_ids *ids, struct kern_ipc_perm *ipcp)
490 ipc_kht_remove(ids, ipcp);
585 * @ids: ipc identifier set
588 * Look for an id in the ipc ids idr and return associated ipc object.
593 struct kern_ipc_perm *ipc_obtain_object_idr(struct ipc_ids *ids, int id)
598 out = idr_find(&ids->ipcs_idr, idx);
607 * @ids: ipc identifier set
616 struct kern_ipc_perm *ipc_obtain_object_check(struct ipc_ids *ids, int id)
618 struct kern_ipc_perm *out = ipc_obtain_object_idr(ids, id);
632 * @ids: ipc identifier set
639 int ipcget(struct ipc_namespace *ns, struct ipc_ids *ids,
643 return ipcget_new(ns, ids, ops, params);
645 return ipcget_public(ns, ids, ops, params);
671 * @ids: the table of ids where to look for the ipc
689 struct ipc_ids *ids, int id, int cmd,
696 ipcp = ipc_obtain_object_check(ids, id);
754 static struct kern_ipc_perm *sysvipc_find_ipc(struct ipc_ids *ids, loff_t pos,
758 int max_idx = ipc_get_maxidx(ids);
764 ipc = idr_find(&ids->ipcs_idr, pos);
786 return sysvipc_find_ipc(&iter->ns->ids[iface->ids], *pos, pos);
797 struct ipc_ids *ids;
799 ids = &iter->ns->ids[iface->ids];
805 down_read(&ids->rwsem);
816 return sysvipc_find_ipc(ids, *pos - 1, pos);
824 struct ipc_ids *ids;
830 ids = &iter->ns->ids[iface->ids];
832 up_read(&ids->rwsem);