Lines Matching defs:cache

29  * This module provides the kernel cache.
114 kidmap_purge_sid2pid_cache(idmap_sid2pid_cache_t *cache, size_t limit);
117 kidmap_purge_pid2sid_cache(idmap_pid2sid_cache_t *cache, size_t limit);
180 kidmap_cache_create(idmap_cache_t *cache)
182 avl_create(&cache->sid2pid.tree, (avl_comp_fn)kidmap_compare_sid,
184 mutex_init(&cache->sid2pid.mutex, NULL, MUTEX_DEFAULT, NULL);
185 cache->sid2pid.purge_time = 0;
186 cache->sid2pid.head.flink = &cache->sid2pid.head;
187 cache->sid2pid.head.blink = &cache->sid2pid.head;
188 cache->sid2pid.uid_num = 0;
189 cache->sid2pid.gid_num = 0;
190 cache->sid2pid.pid_num = 0;
192 avl_create(&cache->uid2sid.tree, (avl_comp_fn)kidmap_compare_pid,
194 mutex_init(&cache->uid2sid.mutex, NULL, MUTEX_DEFAULT, NULL);
195 cache->uid2sid.purge_time = 0;
196 cache->uid2sid.head.flink = &cache->uid2sid.head;
197 cache->uid2sid.head.blink = &cache->uid2sid.head;
199 avl_create(&cache->gid2sid.tree, (avl_comp_fn)kidmap_compare_pid,
201 mutex_init(&cache->gid2sid.mutex, NULL, MUTEX_DEFAULT, NULL);
202 cache->gid2sid.purge_time = 0;
203 cache->gid2sid.head.flink = &cache->gid2sid.head;
204 cache->gid2sid.head.blink = &cache->gid2sid.head;
209 kidmap_cache_delete(idmap_cache_t *cache)
216 while ((sid2pid = avl_destroy_nodes(&cache->sid2pid.tree, &cookie))
220 avl_destroy(&cache->sid2pid.tree);
221 mutex_destroy(&cache->sid2pid.mutex);
225 while ((pid2sid = avl_destroy_nodes(&cache->uid2sid.tree, &cookie))
229 avl_destroy(&cache->uid2sid.tree);
230 mutex_destroy(&cache->uid2sid.mutex);
234 while ((pid2sid = avl_destroy_nodes(&cache->gid2sid.tree, &cookie))
238 avl_destroy(&cache->gid2sid.tree);
239 mutex_destroy(&cache->gid2sid.mutex);
244 kidmap_cache_get_data(idmap_cache_t *cache, size_t *uidbysid, size_t *gidbysid,
247 mutex_enter(&cache->sid2pid.mutex);
248 *uidbysid = cache->sid2pid.uid_num;
249 *gidbysid = cache->sid2pid.gid_num;
250 *pidbysid = cache->sid2pid.pid_num;
251 mutex_exit(&cache->sid2pid.mutex);
253 mutex_enter(&cache->uid2sid.mutex);
254 *sidbyuid = avl_numnodes(&cache->uid2sid.tree);
255 mutex_exit(&cache->uid2sid.mutex);
257 mutex_enter(&cache->gid2sid.mutex);
258 *sidbygid = avl_numnodes(&cache->gid2sid.tree);
259 mutex_exit(&cache->gid2sid.mutex);
264 kidmap_cache_purge(idmap_cache_t *cache)
270 mutex_enter(&cache->sid2pid.mutex);
272 while ((sid2pid = avl_destroy_nodes(&cache->sid2pid.tree, &cookie))
276 avl_destroy(&cache->sid2pid.tree);
277 avl_create(&cache->sid2pid.tree, (avl_comp_fn)kidmap_compare_sid,
279 cache->sid2pid.purge_time = 0;
280 cache->sid2pid.head.flink = &cache->sid2pid.head;
281 cache->sid2pid.head.blink = &cache->sid2pid.head;
282 cache->sid2pid.uid_num = 0;
283 cache->sid2pid.gid_num = 0;
284 cache->sid2pid.pid_num = 0;
285 mutex_exit(&cache->sid2pid.mutex);
288 mutex_enter(&cache->uid2sid.mutex);
290 while ((pid2sid = avl_destroy_nodes(&cache->uid2sid.tree, &cookie))
294 avl_destroy(&cache->uid2sid.tree);
295 avl_create(&cache->uid2sid.tree, (avl_comp_fn)kidmap_compare_pid,
297 cache->uid2sid.purge_time = 0;
298 cache->uid2sid.head.flink = &cache->uid2sid.head;
299 cache->uid2sid.head.blink = &cache->uid2sid.head;
300 mutex_exit(&cache->uid2sid.mutex);
303 mutex_enter(&cache->gid2sid.mutex);
305 while ((pid2sid = avl_destroy_nodes(&cache->gid2sid.tree, &cookie))
309 avl_destroy(&cache->gid2sid.tree);
310 avl_create(&cache->gid2sid.tree, (avl_comp_fn)kidmap_compare_pid,
312 cache->gid2sid.purge_time = 0;
313 cache->gid2sid.head.flink = &cache->gid2sid.head;
314 cache->gid2sid.head.blink = &cache->gid2sid.head;
315 mutex_exit(&cache->gid2sid.mutex);
320 kidmap_cache_lookup_uidbysid(idmap_cache_t *cache, const char *sid_prefix,
332 mutex_enter(&cache->sid2pid.mutex);
334 result = avl_find(&cache->sid2pid.tree, &entry, &where);
336 list_move(&cache->sid2pid.head, result);
343 mutex_exit(&cache->sid2pid.mutex);
350 kidmap_cache_lookup_gidbysid(idmap_cache_t *cache, const char *sid_prefix,
362 mutex_enter(&cache->sid2pid.mutex);
364 result = avl_find(&cache->sid2pid.tree, &entry, &where);
366 list_move(&cache->sid2pid.head, result);
373 mutex_exit(&cache->sid2pid.mutex);
380 kidmap_cache_lookup_pidbysid(idmap_cache_t *cache, const char *sid_prefix,
392 mutex_enter(&cache->sid2pid.mutex);
394 result = avl_find(&cache->sid2pid.tree, &entry, &where);
396 list_move(&cache->sid2pid.head, result);
410 mutex_exit(&cache->sid2pid.mutex);
418 kidmap_cache_lookup_sidbyuid(idmap_cache_t *cache, const char **sid_prefix,
429 mutex_enter(&cache->uid2sid.mutex);
431 result = avl_find(&cache->uid2sid.tree, &entry, &where);
433 list_move(&cache->uid2sid.head, result);
441 mutex_exit(&cache->uid2sid.mutex);
448 kidmap_cache_lookup_sidbygid(idmap_cache_t *cache, const char **sid_prefix,
459 mutex_enter(&cache->gid2sid.mutex);
461 result = avl_find(&cache->gid2sid.tree, &entry, &where);
463 list_move(&cache->gid2sid.head, result);
471 mutex_exit(&cache->gid2sid.mutex);
478 kidmap_cache_add_sid2uid(idmap_cache_t *cache, const char *sid_prefix,
495 mutex_enter(&cache->sid2pid.mutex);
497 result = avl_find(&cache->sid2pid.tree, &find, &where);
500 cache->sid2pid.uid_num++;
512 cache->sid2pid.uid_num++;
514 list_insert(&cache->sid2pid.head, new);
515 avl_insert(&cache->sid2pid.tree, new, where);
518 if ((avl_numnodes(&cache->sid2pid.tree) >
520 (cache->sid2pid.purge_time + CACHE_PURGE_INTERVAL <
522 kidmap_purge_sid2pid_cache(&cache->sid2pid,
525 mutex_exit(&cache->sid2pid.mutex);
536 mutex_enter(&cache->uid2sid.mutex);
538 result = avl_find(&cache->uid2sid.tree, &find, &where);
550 list_insert(&cache->uid2sid.head, new);
551 avl_insert(&cache->uid2sid.tree, new, where);
554 if ((avl_numnodes(&cache->uid2sid.tree) >
556 (cache->uid2sid.purge_time + CACHE_PURGE_INTERVAL <
558 kidmap_purge_pid2sid_cache(&cache->uid2sid,
561 mutex_exit(&cache->uid2sid.mutex);
568 kidmap_cache_add_sid2gid(idmap_cache_t *cache, const char *sid_prefix,
584 mutex_enter(&cache->sid2pid.mutex);
586 result = avl_find(&cache->sid2pid.tree, &find, &where);
589 cache->sid2pid.gid_num++;
601 cache->sid2pid.gid_num++;
603 list_insert(&cache->sid2pid.head, new);
604 avl_insert(&cache->sid2pid.tree, new, where);
607 if ((avl_numnodes(&cache->sid2pid.tree) >
609 (cache->sid2pid.purge_time + CACHE_PURGE_INTERVAL <
611 kidmap_purge_sid2pid_cache(&cache->sid2pid,
614 mutex_exit(&cache->sid2pid.mutex);
625 mutex_enter(&cache->gid2sid.mutex);
627 result = avl_find(&cache->gid2sid.tree, &find, &where);
639 list_insert(&cache->gid2sid.head, new);
640 avl_insert(&cache->gid2sid.tree, new, where);
643 if ((avl_numnodes(&cache->gid2sid.tree) >
645 (cache->gid2sid.purge_time + CACHE_PURGE_INTERVAL <
647 kidmap_purge_pid2sid_cache(&cache->gid2sid,
650 mutex_exit(&cache->gid2sid.mutex);
656 kidmap_cache_add_sid2pid(idmap_cache_t *cache, const char *sid_prefix,
672 mutex_enter(&cache->sid2pid.mutex);
674 result = avl_find(&cache->sid2pid.tree, &find, &where);
677 cache->sid2pid.pid_num++;
681 cache->sid2pid.uid_num++;
686 cache->sid2pid.gid_num++;
700 cache->sid2pid.uid_num++;
706 cache->sid2pid.gid_num++;
708 cache->sid2pid.pid_num++;
710 list_insert(&cache->sid2pid.head, new);
711 avl_insert(&cache->sid2pid.tree, new, where);
714 if ((avl_numnodes(&cache->sid2pid.tree) >
716 (cache->sid2pid.purge_time + CACHE_PURGE_INTERVAL <
718 kidmap_purge_sid2pid_cache(&cache->sid2pid,
721 mutex_exit(&cache->sid2pid.mutex);
732 mutex_enter(&cache->uid2sid.mutex);
734 result = avl_find(&cache->uid2sid.tree, &find, &where);
746 list_insert(&cache->uid2sid.head, new);
747 avl_insert(&cache->uid2sid.tree, new, where);
750 if ((avl_numnodes(&cache->uid2sid.tree) >
752 (cache->uid2sid.purge_time +
755 kidmap_purge_pid2sid_cache(&cache->uid2sid,
758 mutex_exit(&cache->uid2sid.mutex);
760 mutex_enter(&cache->gid2sid.mutex);
762 result = avl_find(&cache->gid2sid.tree, &find, &where);
774 list_insert(&cache->gid2sid.head, new);
775 avl_insert(&cache->gid2sid.tree, new, where);
778 if ((avl_numnodes(&cache->gid2sid.tree) >
780 (cache->gid2sid.purge_time +
782 kidmap_purge_pid2sid_cache(&cache->gid2sid,
785 mutex_exit(&cache->gid2sid.mutex);
795 kidmap_purge_sid2pid_cache(idmap_sid2pid_cache_t *cache, size_t limit)
800 while (avl_numnodes(&cache->tree) > limit) {
802 item = cache->head.blink;
804 avl_remove(&cache->tree, item);
806 cache->uid_num--;
808 cache->gid_num--;
810 cache->pid_num--;
813 cache->purge_time = now;
818 kidmap_purge_pid2sid_cache(idmap_pid2sid_cache_t *cache, size_t limit)
823 while (avl_numnodes(&cache->tree) > limit) {
825 item = cache->head.blink;
827 avl_remove(&cache->tree, item);
830 cache->purge_time = now;