| 4081 | */ |
| 4082 | |
| 4083 | static void * |
| 4084 | zone_alloc_item(uma_zone_t zone, void *udata, int domain, int flags) |
| 4085 | { |
| 4086 | void *item; |
| 4087 | |
| 4088 | if (zone->uz_max_items > 0 && zone_alloc_limit(zone, 1, flags) == 0) { |
| 4089 | counter_u64_add(zone->uz_fails, 1); |
| 4090 | return (NULL); |
| 4091 | } |
| 4092 | |
| 4093 | /* Avoid allocs targeting empty domains. */ |
| 4094 | if (domain != UMA_ANYDOMAIN && VM_DOMAIN_EMPTY(domain)) |
| 4095 | domain = UMA_ANYDOMAIN; |
| 4096 | |
| 4097 | if (zone->uz_import(zone->uz_arg, &item, 1, domain, flags) != 1) |
| 4098 | goto fail_cnt; |
| 4099 | |
| 4100 | /* |
| 4101 | * We have to call both the zone's init (not the keg's init) |
| 4102 | * and the zone's ctor. This is because the item is going from |
| 4103 | * a keg slab directly to the user, and the user is expecting it |
| 4104 | * to be both zone-init'd as well as zone-ctor'd. |
| 4105 | */ |
| 4106 | if (zone->uz_init != NULL) { |
| 4107 | if (zone->uz_init(item, zone->uz_size, flags) != 0) { |
| 4108 | zone_free_item(zone, item, udata, SKIP_FINI | SKIP_CNT); |
| 4109 | goto fail_cnt; |
| 4110 | } |
| 4111 | } |
| 4112 | item = item_ctor(zone, zone->uz_flags, zone->uz_size, udata, flags, |
| 4113 | item); |
| 4114 | if (item == NULL) |
| 4115 | goto fail; |
| 4116 | |
| 4117 | counter_u64_add(zone->uz_allocs, 1); |
| 4118 | CTR3(KTR_UMA, "zone_alloc_item item %p from %s(%p)", item, |
| 4119 | zone->uz_name, zone); |
| 4120 | |
| 4121 | return (item); |
| 4122 | |
| 4123 | fail_cnt: |
| 4124 | counter_u64_add(zone->uz_fails, 1); |
| 4125 | fail: |
| 4126 | if (zone->uz_max_items > 0) |
| 4127 | zone_free_limit(zone, 1); |
| 4128 | CTR2(KTR_UMA, "zone_alloc_item failed from %s(%p)", |
| 4129 | zone->uz_name, zone); |
| 4130 | |
| 4131 | return (NULL); |
| 4132 | } |
| 4133 | |
| 4134 | /* See uma.h */ |
| 4135 | void |
no test coverage detected