1 /* zn_malloc.c - zone-based malloc routines */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 2003-2004 The OpenLDAP Foundation.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted only as authorized by the OpenLDAP
12 * A copy of this license is available in the file LICENSE in the
13 * top-level directory of the distribution or, alternatively, at
14 * <http://www.OpenLDAP.org/license.html>.
16 /* Copyright 2004 IBM Corporation
17 * All rights reserved.
18 * Redisribution and use in source and binary forms, with or without
19 * modification, are permitted only as authorizd by the OpenLADP
23 * This work originally developed by Jong-Hyuk Choi
24 * 2004/12/09 jongchoi@OpenLDAP.org
30 #include <ac/string.h>
31 #include <sys/types.h>
37 #ifdef SLAP_ZONE_ALLOC
39 static int slap_zone_cmp(const void *v1, const void *v2);
40 void * slap_replenish_zopool(void *ctx);
43 slap_zo_release(void *data)
45 struct zone_object *zo = (struct zone_object *)data;
54 struct zone_heap *zh = ctx;
55 int pad = 2*sizeof(int)-1, pad_shift;
56 int order_start = -1, i, j;
57 struct zone_object *zo;
62 } while (pad_shift >>= 1);
64 ldap_pvt_thread_mutex_lock( &zh->zh_mutex );
65 for (i = 0; i < zh->zh_zoneorder - order_start + 1; i++) {
66 zo = LDAP_LIST_FIRST(&zh->zh_free[i]);
68 struct zone_object *zo_tmp = zo;
69 zo = LDAP_LIST_NEXT(zo, zo_link);
70 LDAP_LIST_REMOVE(zo_tmp, zo_link);
71 LDAP_LIST_INSERT_HEAD(&zh->zh_zopool, zo_tmp, zo_link);
76 for (i = 0; i < zh->zh_numzones; i++) {
77 for (j = 0; j < zh->zh_zoneorder - order_start + 1; j++) {
78 ch_free(zh->zh_maps[i][j]);
80 ch_free(zh->zh_maps[i]);
81 munmap(zh->zh_zones[i], zh->zh_zonesize);
82 ldap_pvt_thread_rdwr_destroy(&zh->zh_znlock[i]);
85 ch_free(zh->zh_zones);
86 ch_free(zh->zh_seqno);
87 ch_free(zh->zh_znlock);
89 avl_free(zh->zh_zonetree, slap_zo_release);
91 zo = LDAP_LIST_FIRST(&zh->zh_zopool);
93 struct zone_object *zo_tmp = zo;
94 zo = LDAP_LIST_NEXT(zo, zo_link);
95 if (!zo_tmp->zo_blockhead) {
96 LDAP_LIST_REMOVE(zo_tmp, zo_link);
99 zo = LDAP_LIST_FIRST(&zh->zh_zopool);
101 struct zone_object *zo_tmp = zo;
102 zo = LDAP_LIST_NEXT(zo, zo_link);
105 ldap_pvt_thread_mutex_unlock(&zh->zh_mutex);
106 ldap_pvt_thread_rdwr_destroy(&zh->zh_lock);
107 ldap_pvt_thread_mutex_destroy(&zh->zh_mutex);
119 struct zone_heap *zh = NULL;
121 int pad = 2*sizeof(int)-1, pad_shift;
123 int order = -1, order_start = -1, order_end = -1;
125 struct zone_object *zo;
127 Debug(LDAP_DEBUG_NONE,
128 "--> slap_zn_mem_create: initsize=%d, maxsize=%d\n",
129 initsize, maxsize, 0);
130 Debug(LDAP_DEBUG_NONE,
131 "++> slap_zn_mem_create: deltasize=%d, zonesize=%d\n",
132 deltasize, zonesize, 0);
134 zh = (struct zone_heap *)ch_calloc(1, sizeof(struct zone_heap));
136 zh->zh_fd = open("/dev/zero", O_RDWR);
139 zh->zh_zonesize = zonesize;
141 zh->zh_zonesize = SLAP_ZONE_SIZE;
144 zpad = zh->zh_zonesize - 1;
145 zh->zh_numzones = ((initsize + zpad) & ~zpad) / zh->zh_zonesize;
147 if ( maxsize && maxsize >= initsize ) {
148 zh->zh_maxzones = ((maxsize + zpad) & ~zpad) / zh->zh_zonesize;
150 zh->zh_maxzones = ((initsize + zpad) & ~zpad) / zh->zh_zonesize;
154 zh->zh_deltazones = ((deltasize + zpad) & ~zpad) / zh->zh_zonesize;
156 zh->zh_deltazones = ((SLAP_ZONE_DELTA+zpad) & ~zpad) / zh->zh_zonesize;
159 size_shift = zh->zh_zonesize - 1;
162 } while (size_shift >>= 1);
167 } while (pad_shift >>= 1);
169 order = order_end - order_start + 1;
171 zh->zh_zones = (void **)ch_malloc(zh->zh_maxzones * sizeof(void*));
172 zh->zh_znlock = (ldap_pvt_thread_rdwr_t *)ch_malloc(
173 zh->zh_maxzones * sizeof(ldap_pvt_thread_rdwr_t *));
174 zh->zh_maps = (unsigned char ***)ch_malloc(
175 zh->zh_maxzones * sizeof(unsigned char**));
177 zh->zh_zoneorder = order_end;
178 zh->zh_free = (struct zh_freelist *)
179 ch_malloc(order * sizeof(struct zh_freelist));
180 zh->zh_seqno = (unsigned long *)ch_calloc(zh->zh_maxzones,
181 sizeof(unsigned long));
182 for (i = 0; i < order; i++) {
183 LDAP_LIST_INIT(&zh->zh_free[i]);
185 LDAP_LIST_INIT(&zh->zh_zopool);
187 for (i = 0; i < zh->zh_numzones; i++) {
188 zh->zh_zones[i] = mmap(0, zh->zh_zonesize, PROT_READ | PROT_WRITE,
189 MAP_PRIVATE, zh->zh_fd, 0);
190 zh->zh_maps[i] = (unsigned char **)
191 ch_malloc(order * sizeof(unsigned char *));
192 for (j = 0; j < order; j++) {
193 int shiftamt = order_start + 1 + j;
194 int nummaps = zh->zh_zonesize >> shiftamt;
197 if (!nummaps) nummaps = 1;
198 zh->zh_maps[i][j] = (unsigned char *)ch_malloc(nummaps);
199 memset(zh->zh_maps[i][j], 0, nummaps);
202 if (LDAP_LIST_EMPTY(&zh->zh_zopool)) {
203 slap_replenish_zopool(zh);
205 zo = LDAP_LIST_FIRST(&zh->zh_zopool);
206 LDAP_LIST_REMOVE(zo, zo_link);
207 zo->zo_ptr = zh->zh_zones[i];
209 LDAP_LIST_INSERT_HEAD(&zh->zh_free[order-1], zo, zo_link);
211 if (LDAP_LIST_EMPTY(&zh->zh_zopool)) {
212 slap_replenish_zopool(zh);
214 zo = LDAP_LIST_FIRST(&zh->zh_zopool);
215 LDAP_LIST_REMOVE(zo, zo_link);
216 zo->zo_ptr = zh->zh_zones[i];
217 zo->zo_siz = zh->zh_zonesize;
219 avl_insert(&zh->zh_zonetree, zo, slap_zone_cmp, avl_dup_error);
220 ldap_pvt_thread_rdwr_init(&zh->zh_znlock[i]);
223 ldap_pvt_thread_mutex_init(&zh->zh_mutex);
224 ldap_pvt_thread_rdwr_init(&zh->zh_lock);
235 struct zone_heap *zh = ctx;
236 ber_len_t size_shift;
237 int pad = 2*sizeof(int)-1, pad_shift;
238 int order = -1, order_start = -1;
239 struct zone_object *zo, *zo_new, *zo_left, *zo_right;
240 ber_len_t *ptr, *new;
245 Debug(LDAP_DEBUG_NONE,
246 "--> slap_zn_malloc: size=%d\n", size, 0, 0);
248 if (!zh) return ber_memalloc_x(size, NULL);
250 /* round up to doubleword boundary */
251 size += 2*sizeof(ber_len_t) + pad;
254 size_shift = size - 1;
257 } while (size_shift >>= 1);
262 } while (pad_shift >>= 1);
266 ldap_pvt_thread_mutex_lock( &zh->zh_mutex );
267 for (i = order; i <= zh->zh_zoneorder &&
268 LDAP_LIST_EMPTY(&zh->zh_free[i-order_start]); i++);
271 zo_new = LDAP_LIST_FIRST(&zh->zh_free[i-order_start]);
272 LDAP_LIST_REMOVE(zo_new, zo_link);
273 ptr = zo_new->zo_ptr;
274 idx = zo_new->zo_idx;
275 diff = (unsigned long)((char*)ptr -
276 (char*)zh->zh_zones[idx]) >> (order + 1);
277 zh->zh_maps[idx][order-order_start][diff>>3] |= (1 << (diff & 0x7));
278 *ptr++ = zh->zh_seqno[idx];
279 *ptr++ = size - 2*sizeof(ber_len_t);
280 zo_new->zo_ptr = NULL;
282 LDAP_LIST_INSERT_HEAD(&zh->zh_zopool, zo_new, zo_link);
283 ldap_pvt_thread_mutex_unlock( &zh->zh_mutex );
284 Debug(LDAP_DEBUG_NONE, "slap_zn_malloc: returning 0x%x, 0x%x\n",
285 ptr, (int)ptr>>(zh->zh_zoneorder+1), 0);
287 } else if (i <= zh->zh_zoneorder) {
288 for (j = i; j > order; j--) {
289 zo_left = LDAP_LIST_FIRST(&zh->zh_free[j-order_start]);
290 LDAP_LIST_REMOVE(zo_left, zo_link);
291 if (LDAP_LIST_EMPTY(&zh->zh_zopool)) {
292 slap_replenish_zopool(zh);
294 zo_right = LDAP_LIST_FIRST(&zh->zh_zopool);
295 LDAP_LIST_REMOVE(zo_right, zo_link);
296 zo_right->zo_ptr = zo_left->zo_ptr + (1 << j);
297 zo_right->zo_idx = zo_left->zo_idx;
298 Debug(LDAP_DEBUG_NONE,
299 "slap_zn_malloc: split (left=0x%x, right=0x%x)\n",
300 zo_left->zo_ptr, zo_right->zo_ptr, 0);
301 if (j == order + 1) {
302 ptr = zo_left->zo_ptr;
303 diff = (unsigned long)((char*)ptr -
304 (char*)zh->zh_zones[zo_left->zo_idx]) >> (order+1);
305 zh->zh_maps[zo_left->zo_idx][order-order_start][diff>>3] |=
307 *ptr++ = zh->zh_seqno[zo_left->zo_idx];
308 *ptr++ = size - 2*sizeof(ber_len_t);
309 LDAP_LIST_INSERT_HEAD(
310 &zh->zh_free[j-1-order_start], zo_right, zo_link);
311 LDAP_LIST_INSERT_HEAD(&zh->zh_zopool, zo_left, zo_link);
312 ldap_pvt_thread_mutex_unlock( &zh->zh_mutex );
313 Debug(LDAP_DEBUG_NONE,
314 "slap_zn_malloc: returning 0x%x, 0x%x\n",
315 ptr, (int)ptr>>(zh->zh_zoneorder+1), 0);
318 LDAP_LIST_INSERT_HEAD(
319 &zh->zh_free[j-1-order_start], zo_right, zo_link);
320 LDAP_LIST_INSERT_HEAD(
321 &zh->zh_free[j-1-order_start], zo_left, zo_link);
327 if ( zh->zh_maxzones < zh->zh_numzones + zh->zh_deltazones ) {
328 ldap_pvt_thread_mutex_unlock( &zh->zh_mutex );
329 Debug( LDAP_DEBUG_TRACE,
330 "slap_zn_malloc of %lu bytes failed, using ch_malloc\n",
332 Debug(LDAP_DEBUG_NONE,
333 "slap_zn_malloc: returning 0x%x, 0x%x\n",
334 ptr, (int)ptr>>(zh->zh_zoneorder+1), 0);
335 return (void*)ch_malloc(size);
338 for (i = zh->zh_numzones; i < zh->zh_numzones+zh->zh_deltazones; i++) {
339 zh->zh_zones[i] = mmap(0, zh->zh_zonesize, PROT_READ | PROT_WRITE,
340 MAP_PRIVATE, zh->zh_fd, 0);
341 zh->zh_maps[i] = (unsigned char **)
342 ch_malloc((zh->zh_zoneorder - order_start + 1) *
343 sizeof(unsigned char *));
344 for (j = 0; j < zh->zh_zoneorder-order_start+1; j++) {
345 int shiftamt = order_start + 1 + j;
346 int nummaps = zh->zh_zonesize >> shiftamt;
349 if (!nummaps) nummaps = 1;
350 zh->zh_maps[i][j] = (unsigned char *)ch_malloc(nummaps);
351 memset(zh->zh_maps[i][j], 0, nummaps);
354 if (LDAP_LIST_EMPTY(&zh->zh_zopool)) {
355 slap_replenish_zopool(zh);
357 zo = LDAP_LIST_FIRST(&zh->zh_zopool);
358 LDAP_LIST_REMOVE(zo, zo_link);
359 zo->zo_ptr = zh->zh_zones[i];
361 LDAP_LIST_INSERT_HEAD(&zh->
362 zh_free[zh->zh_zoneorder-order_start],zo,zo_link);
364 if (LDAP_LIST_EMPTY(&zh->zh_zopool)) {
365 slap_replenish_zopool(zh);
367 zo = LDAP_LIST_FIRST(&zh->zh_zopool);
368 LDAP_LIST_REMOVE(zo, zo_link);
369 zo->zo_ptr = zh->zh_zones[i];
370 zo->zo_siz = zh->zh_zonesize;
372 avl_insert(&zh->zh_zonetree, zo, slap_zone_cmp, avl_dup_error);
373 ldap_pvt_thread_rdwr_init(&zh->zh_znlock[i]);
375 zh->zh_numzones += zh->zh_deltazones;
376 ldap_pvt_thread_mutex_unlock( &zh->zh_mutex );
382 slap_zn_calloc( ber_len_t n, ber_len_t size, void *ctx )
386 new = slap_zn_malloc( n*size, ctx );
388 memset( new, 0, n*size );
394 slap_zn_realloc(void *ptr, ber_len_t size, void *ctx)
396 struct zone_heap *zh = ctx;
397 int pad = 2*sizeof(int)-1, pad_shift;
398 int order_start = -1, order = -1;
399 struct zone_object zoi, *zoo;
400 ber_len_t *p = (ber_len_t *)ptr, *new;
404 struct zone_heap *zone = NULL;
406 Debug(LDAP_DEBUG_NONE,
407 "--> slap_zn_realloc: ptr=0x%x, size=%d\n", ptr, size, 0);
410 return slap_zn_malloc(size, zh);
416 ldap_pvt_thread_mutex_lock( &zh->zh_mutex );
417 zoo = avl_find(zh->zh_zonetree, &zoi, slap_zone_cmp);
418 ldap_pvt_thread_mutex_unlock( &zh->zh_mutex );
421 /* Not our memory? */
423 /* duplicate of realloc behavior, oh well */
424 new = ber_memrealloc_x(ptr, size, NULL);
428 Debug(LDAP_DEBUG_ANY, "ch_realloc of %lu bytes failed\n",
431 exit( EXIT_FAILURE );
434 assert(zoo->zo_idx != -1);
436 zone = zh->zh_zones[zoo->zo_idx];
439 slap_zn_free(ptr, zh);
443 newptr = slap_zn_malloc(size, zh);
445 AC_MEMCPY(newptr, ptr, size);
447 AC_MEMCPY(newptr, ptr, p[-1]);
449 slap_zn_free(ptr, zh);
454 slap_zn_free(void *ptr, void *ctx)
456 struct zone_heap *zh = ctx;
457 int size, size_shift, order_size;
458 int pad = 2*sizeof(int)-1, pad_shift;
459 ber_len_t *p = (ber_len_t *)ptr, *tmpp;
460 int order_start = -1, order = -1;
461 struct zone_object zoi, *zoo, *zo;
463 int i, k, inserted = 0, idx;
464 struct zone_heap *zone = NULL;
469 Debug(LDAP_DEBUG_NONE, "--> slap_zn_free: ptr=0x%x\n", ptr, 0, 0);
472 ldap_pvt_thread_mutex_lock( &zh->zh_mutex );
473 zoo = avl_find(zh->zh_zonetree, &zoi, slap_zone_cmp);
474 ldap_pvt_thread_mutex_unlock( &zh->zh_mutex );
478 ber_memfree_x(ptr, NULL);
482 zone = zh->zh_zones[idx];
485 size_shift = size + 2*sizeof(ber_len_t) - 1;
488 } while (size_shift >>= 1);
493 } while (pad_shift >>= 1);
495 ldap_pvt_thread_mutex_lock( &zh->zh_mutex );
496 for (i = order, tmpp = p; i <= zh->zh_zoneorder; i++) {
497 order_size = 1 << (i+1);
498 diff = (unsigned long)((char*)tmpp - (char*)zone) >> (i+1);
499 zh->zh_maps[idx][i-order_start][diff>>3] &= (~(1 << (diff & 0x7)));
500 if (diff == ((diff>>1)<<1)) {
501 if (!(zh->zh_maps[idx][i-order_start][(diff+1)>>3] &
502 (1<<((diff+1)&0x7)))) {
503 zo = LDAP_LIST_FIRST(&zh->zh_free[i-order_start]);
505 if ((char*)zo->zo_ptr == (char*)tmpp) {
506 LDAP_LIST_REMOVE( zo, zo_link );
507 } else if ((char*)zo->zo_ptr ==
508 (char*)tmpp + order_size) {
509 LDAP_LIST_REMOVE(zo, zo_link);
512 zo = LDAP_LIST_NEXT(zo, zo_link);
515 if (i < zh->zh_zoneorder) {
518 Debug(LDAP_DEBUG_NONE,
519 "slap_zn_free: merging 0x%x\n",
521 LDAP_LIST_INSERT_HEAD(&zh->zh_free[i-order_start+1],
526 if (LDAP_LIST_EMPTY(&zh->zh_zopool)) {
527 slap_replenish_zopool(zh);
529 zo = LDAP_LIST_FIRST(&zh->zh_zopool);
530 LDAP_LIST_REMOVE(zo, zo_link);
533 Debug(LDAP_DEBUG_NONE,
534 "slap_zn_free: merging 0x%x\n",
536 LDAP_LIST_INSERT_HEAD(&zh->zh_free[i-order_start],
540 Debug(LDAP_DEBUG_ANY, "slap_zn_free: "
541 "free object not found while bit is clear.\n",
548 if (LDAP_LIST_EMPTY(&zh->zh_zopool)) {
549 slap_replenish_zopool(zh);
551 zo = LDAP_LIST_FIRST(&zh->zh_zopool);
552 LDAP_LIST_REMOVE(zo, zo_link);
555 Debug(LDAP_DEBUG_NONE,
556 "slap_zn_free: merging 0x%x\n",
558 LDAP_LIST_INSERT_HEAD(&zh->zh_free[i-order_start],
564 if (!(zh->zh_maps[idx][i-order_start][(diff-1)>>3] &
565 (1<<((diff-1)&0x7)))) {
566 zo = LDAP_LIST_FIRST(&zh->zh_free[i-order_start]);
568 if ((char*)zo->zo_ptr == (char*)tmpp) {
569 LDAP_LIST_REMOVE(zo, zo_link);
570 } else if ((char*)tmpp == zo->zo_ptr + order_size) {
571 LDAP_LIST_REMOVE(zo, zo_link);
575 zo = LDAP_LIST_NEXT(zo, zo_link);
578 if (i < zh->zh_zoneorder) {
580 Debug(LDAP_DEBUG_NONE,
581 "slap_zn_free: merging 0x%x\n",
583 LDAP_LIST_INSERT_HEAD(&zh->zh_free[i-order_start+1],
588 if (LDAP_LIST_EMPTY(&zh->zh_zopool)) {
589 slap_replenish_zopool(zh);
591 zo = LDAP_LIST_FIRST(&zh->zh_zopool);
592 LDAP_LIST_REMOVE(zo, zo_link);
595 Debug(LDAP_DEBUG_NONE,
596 "slap_zn_free: merging 0x%x\n",
598 LDAP_LIST_INSERT_HEAD(&zh->zh_free[i-order_start],
602 Debug(LDAP_DEBUG_ANY, "slap_zn_free: "
603 "free object not found while bit is clear.\n",
610 if (LDAP_LIST_EMPTY(&zh->zh_zopool)) {
611 slap_replenish_zopool(zh);
613 zo = LDAP_LIST_FIRST(&zh->zh_zopool);
614 LDAP_LIST_REMOVE(zo, zo_link);
617 Debug(LDAP_DEBUG_NONE,
618 "slap_zn_free: merging 0x%x\n",
620 LDAP_LIST_INSERT_HEAD(&zh->zh_free[i-order_start],
627 ldap_pvt_thread_mutex_unlock( &zh->zh_mutex );
632 slap_zone_cmp(const void *v1, const void *v2)
634 const struct zone_object *zo1 = v1;
635 const struct zone_object *zo2 = v2;
640 zpad = zo2->zo_siz - 1;
641 ptr1 = (char*)(((unsigned long)zo1->zo_ptr + zpad) & ~zpad);
642 ptr2 = (char*)zo2->zo_ptr + ((char*)ptr1 - (char*)zo1->zo_ptr);
643 ptr2 = (char*)(((unsigned long)ptr2 + zpad) & ~zpad);
644 return (int)((char*)ptr1 - (char*)ptr2);
648 slap_replenish_zopool(
652 struct zone_heap* zh = ctx;
653 struct zone_object *zo_block;
656 zo_block = (struct zone_object *)ch_malloc(
657 SLAP_ZONE_ZOBLOCK * sizeof(struct zone_object));
659 if ( zo_block == NULL ) {
663 zo_block[0].zo_blockhead = 1;
664 LDAP_LIST_INSERT_HEAD(&zh->zh_zopool, &zo_block[0], zo_link);
665 for (i = 1; i < SLAP_ZONE_ZOBLOCK; i++) {
666 zo_block[i].zo_blockhead = 0;
667 LDAP_LIST_INSERT_HEAD(&zh->zh_zopool, &zo_block[i], zo_link );
679 struct zone_heap* zh = ctx;
680 struct zone_object zoi, *zoo;
681 struct zone_heap *zone = NULL;
682 int seqno = *((ber_len_t*)ptr - 2);
683 int idx = -1, rc = 0;
684 int pad = 2*sizeof(int)-1, pad_shift;
685 int order_start = -1, i;
686 struct zone_object *zo;
691 } while (pad_shift >>= 1);
696 ldap_pvt_thread_mutex_lock( &zh->zh_mutex );
697 zoo = avl_find(zh->zh_zonetree, &zoi, slap_zone_cmp);
702 madvise(zh->zh_zones[idx], zh->zh_zonesize, MADV_DONTNEED);
703 for (i = 0; i < zh->zh_zoneorder - order_start + 1; i++) {
704 int shiftamt = order_start + 1 + i;
705 int nummaps = zh->zh_zonesize >> shiftamt;
708 if (!nummaps) nummaps = 1;
709 memset(zh->zh_maps[idx][i], 0, nummaps);
710 zo = LDAP_LIST_FIRST(&zh->zh_free[i]);
712 struct zone_object *zo_tmp = zo;
713 zo = LDAP_LIST_NEXT(zo, zo_link);
714 if (zo_tmp && zo_tmp->zo_idx == idx) {
715 LDAP_LIST_REMOVE(zo_tmp, zo_link);
716 LDAP_LIST_INSERT_HEAD(&zh->zh_zopool, zo_tmp, zo_link);
720 if (LDAP_LIST_EMPTY(&zh->zh_zopool)) {
721 slap_replenish_zopool(zh);
723 zo = LDAP_LIST_FIRST(&zh->zh_zopool);
724 LDAP_LIST_REMOVE(zo, zo_link);
725 zo->zo_ptr = zh->zh_zones[idx];
727 LDAP_LIST_INSERT_HEAD(&zh->zh_free[zh->zh_zoneorder-order_start],
731 Debug(LDAP_DEBUG_NONE, "zone not found for (ctx=0x%x, ptr=0x%x) !\n",
735 ldap_pvt_thread_mutex_unlock( &zh->zh_mutex );
736 Debug(LDAP_DEBUG_NONE, "zone %d invalidate\n", idx, 0, 0);
747 struct zone_heap* zh = ctx;
748 struct zone_object zoi, *zoo;
749 struct zone_heap *zone = NULL;
755 zoo = avl_find(zh->zh_zonetree, &zoi, slap_zone_cmp);
760 assert(seqno <= zh->zh_seqno[idx]);
761 rc = (seqno == zh->zh_seqno[idx]);
771 struct zone_heap* zh = ctx;
772 ldap_pvt_thread_rdwr_rlock(&zh->zh_lock);
779 struct zone_heap* zh = ctx;
780 ldap_pvt_thread_rdwr_runlock(&zh->zh_lock);
787 struct zone_heap* zh = ctx;
788 ldap_pvt_thread_rdwr_wlock(&zh->zh_lock);
795 struct zone_heap* zh = ctx;
796 ldap_pvt_thread_rdwr_wunlock(&zh->zh_lock);
804 struct zone_heap* zh = ctx;
805 struct zone_object zoi, *zoo;
806 struct zone_heap *zone = NULL;
812 ldap_pvt_thread_mutex_lock( &zh->zh_mutex );
813 zoo = avl_find(zh->zh_zonetree, &zoi, slap_zone_cmp);
814 ldap_pvt_thread_mutex_unlock( &zh->zh_mutex );
819 ldap_pvt_thread_rdwr_rlock(&zh->zh_znlock[idx]);
828 struct zone_heap* zh = ctx;
829 struct zone_object zoi, *zoo;
830 struct zone_heap *zone = NULL;
836 ldap_pvt_thread_mutex_lock( &zh->zh_mutex );
837 zoo = avl_find(zh->zh_zonetree, &zoi, slap_zone_cmp);
838 ldap_pvt_thread_mutex_unlock( &zh->zh_mutex );
843 ldap_pvt_thread_rdwr_runlock(&zh->zh_znlock[idx]);
852 struct zone_heap* zh = ctx;
853 struct zone_object zoi, *zoo;
854 struct zone_heap *zone = NULL;
860 ldap_pvt_thread_mutex_lock( &zh->zh_mutex );
861 zoo = avl_find(zh->zh_zonetree, &zoi, slap_zone_cmp);
862 ldap_pvt_thread_mutex_unlock( &zh->zh_mutex );
867 ldap_pvt_thread_rdwr_wlock(&zh->zh_znlock[idx]);
876 struct zone_heap* zh = ctx;
877 struct zone_object zoi, *zoo;
878 struct zone_heap *zone = NULL;
884 ldap_pvt_thread_mutex_lock( &zh->zh_mutex );
885 zoo = avl_find(zh->zh_zonetree, &zoi, slap_zone_cmp);
886 ldap_pvt_thread_mutex_unlock( &zh->zh_mutex );
891 ldap_pvt_thread_rdwr_wunlock(&zh->zh_znlock[idx]);
895 #endif /* SLAP_ZONE_ALLOC */