Commit df925e6c authored by Evan Hunt's avatar Evan Hunt

[master] add zone memory context pools

3492.	[bug]		Fixed a regression in zone loading performance
			due to lock contention. [RT #30399]
parent d642d385
3492. [bug] Fixed a regression in zone loading performance
due to lock contention. [RT #30399]
3491. [bug] Slave zones using inline-signing must specify a
file name. [RT #31946]
......
......@@ -3028,7 +3028,8 @@ configure_view(dns_view_t *view, cfg_obj_t *config, cfg_obj_t *vconfig,
}
}
CHECK(dns_zone_create(&zone, mctx));
CHECK(dns_zonemgr_createzone(ns_g_server->zonemgr,
&zone));
CHECK(dns_zone_setorigin(zone, name));
dns_zone_setview(zone, view);
CHECK(dns_zonemgr_managezone(ns_g_server->zonemgr,
......@@ -3582,7 +3583,8 @@ configure_zone(const cfg_obj_t *config, const cfg_obj_t *zconfig,
dns_zone_attach(pview->redirect, &zone);
dns_zone_setview(zone, view);
} else {
CHECK(dns_zone_create(&zone, mctx));
CHECK(dns_zonemgr_createzone(ns_g_server->zonemgr,
&zone));
CHECK(dns_zone_setorigin(zone, origin));
dns_zone_setview(zone, view);
CHECK(dns_zonemgr_managezone(ns_g_server->zonemgr,
......@@ -3645,7 +3647,7 @@ configure_zone(const cfg_obj_t *config, const cfg_obj_t *zconfig,
* We cannot reuse an existing zone, we have
* to create a new one.
*/
CHECK(dns_zone_create(&zone, mctx));
CHECK(dns_zonemgr_createzone(ns_g_server->zonemgr, &zone));
CHECK(dns_zone_setorigin(zone, origin));
dns_zone_setview(zone, view);
if (view->acache != NULL)
......@@ -3763,7 +3765,7 @@ add_keydata_zone(dns_view_t *view, const char *directory, isc_mem_t *mctx) {
}
/* No existing keydata zone was found; create one */
CHECK(dns_zone_create(&zone, mctx));
CHECK(dns_zonemgr_createzone(ns_g_server->zonemgr, &zone));
CHECK(dns_zone_setorigin(zone, dns_rootname));
isc_sha256_data((void *)view->name, strlen(view->name), buffer);
......
......@@ -247,7 +247,8 @@ ixfr_rrstream_create(isc_mem_t *mctx,
s = isc_mem_get(mctx, sizeof(*s));
if (s == NULL)
return (ISC_R_NOMEMORY);
s->common.mctx = mctx;
s->common.mctx = NULL;
isc_mem_attach(mctx, &s->common.mctx);
s->common.methods = &ixfr_rrstream_methods;
s->journal = NULL;
......@@ -289,7 +290,7 @@ ixfr_rrstream_destroy(rrstream_t **rsp) {
ixfr_rrstream_t *s = (ixfr_rrstream_t *) *rsp;
if (s->journal != 0)
dns_journal_destroy(&s->journal);
isc_mem_put(s->common.mctx, s, sizeof(*s));
isc_mem_putanddetach(&s->common.mctx, s, sizeof(*s));
}
static rrstream_methods_t ixfr_rrstream_methods = {
......@@ -335,7 +336,8 @@ axfr_rrstream_create(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *ver,
s = isc_mem_get(mctx, sizeof(*s));
if (s == NULL)
return (ISC_R_NOMEMORY);
s->common.mctx = mctx;
s->common.mctx = NULL;
isc_mem_attach(mctx, &s->common.mctx);
s->common.methods = &axfr_rrstream_methods;
s->it_valid = ISC_FALSE;
......@@ -413,7 +415,7 @@ axfr_rrstream_destroy(rrstream_t **rsp) {
axfr_rrstream_t *s = (axfr_rrstream_t *) *rsp;
if (s->it_valid)
dns_rriterator_destroy(&s->it);
isc_mem_put(s->common.mctx, s, sizeof(*s));
isc_mem_putanddetach(&s->common.mctx, s, sizeof(*s));
}
static rrstream_methods_t axfr_rrstream_methods = {
......@@ -455,7 +457,8 @@ soa_rrstream_create(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *ver,
s = isc_mem_get(mctx, sizeof(*s));
if (s == NULL)
return (ISC_R_NOMEMORY);
s->common.mctx = mctx;
s->common.mctx = NULL;
isc_mem_attach(mctx, &s->common.mctx);
s->common.methods = &soa_rrstream_methods;
s->soa_tuple = NULL;
......@@ -497,7 +500,7 @@ soa_rrstream_destroy(rrstream_t **rsp) {
soa_rrstream_t *s = (soa_rrstream_t *) *rsp;
if (s->soa_tuple != NULL)
dns_difftuple_free(&s->soa_tuple);
isc_mem_put(s->common.mctx, s, sizeof(*s));
isc_mem_putanddetach(&s->common.mctx, s, sizeof(*s));
}
static rrstream_methods_t soa_rrstream_methods = {
......@@ -561,7 +564,8 @@ compound_rrstream_create(isc_mem_t *mctx, rrstream_t **soa_stream,
s = isc_mem_get(mctx, sizeof(*s));
if (s == NULL)
return (ISC_R_NOMEMORY);
s->common.mctx = mctx;
s->common.mctx = NULL;
isc_mem_attach(mctx, &s->common.mctx);
s->common.methods = &compound_rrstream_methods;
s->components[0] = *soa_stream;
s->components[1] = *data_stream;
......@@ -634,7 +638,7 @@ compound_rrstream_destroy(rrstream_t **rsp) {
s->components[0]->methods->destroy(&s->components[0]);
s->components[1]->methods->destroy(&s->components[1]);
s->components[2] = NULL; /* Copy of components[0]. */
isc_mem_put(s->common.mctx, s, sizeof(*s));
isc_mem_putanddetach(&s->common.mctx, s, sizeof(*s));
}
static rrstream_methods_t compound_rrstream_methods = {
......
......@@ -48,7 +48,10 @@ dns_acl_create(isc_mem_t *mctx, int n, dns_acl_t **target) {
acl = isc_mem_get(mctx, sizeof(*acl));
if (acl == NULL)
return (ISC_R_NOMEMORY);
acl->mctx = mctx;
acl->mctx = NULL;
isc_mem_attach(mctx, &acl->mctx);
acl->name = NULL;
result = isc_refcount_init(&acl->refcount, 1);
......@@ -467,7 +470,7 @@ destroy(dns_acl_t *dacl) {
dns_iptable_detach(&dacl->iptable);
isc_refcount_destroy(&dacl->refcount);
dacl->magic = 0;
isc_mem_put(dacl->mctx, dacl, sizeof(*dacl));
isc_mem_putanddetach(&dacl->mctx, dacl, sizeof(*dacl));
}
void
......
......@@ -224,7 +224,8 @@ dns_byaddr_create(isc_mem_t *mctx, isc_netaddr_t *address, dns_view_t *view,
byaddr = isc_mem_get(mctx, sizeof(*byaddr));
if (byaddr == NULL)
return (ISC_R_NOMEMORY);
byaddr->mctx = mctx;
byaddr->mctx = NULL;
isc_mem_attach(mctx, &byaddr->mctx);
byaddr->options = options;
byaddr->event = isc_mem_get(mctx, sizeof(*byaddr->event));
......@@ -277,7 +278,7 @@ dns_byaddr_create(isc_mem_t *mctx, isc_netaddr_t *address, dns_view_t *view,
isc_task_detach(&byaddr->task);
cleanup_byaddr:
isc_mem_put(mctx, byaddr, sizeof(*byaddr));
isc_mem_putanddetach(&mctx, byaddr, sizeof(*byaddr));
return (result);
}
......@@ -310,7 +311,7 @@ dns_byaddr_destroy(dns_byaddr_t **byaddrp) {
DESTROYLOCK(&byaddr->lock);
byaddr->magic = 0;
isc_mem_put(byaddr->mctx, byaddr, sizeof(*byaddr));
isc_mem_putanddetach(&byaddr->mctx, byaddr, sizeof(*byaddr));
*byaddrp = NULL;
}
......
......@@ -89,7 +89,8 @@ dns_dbtable_create(isc_mem_t *mctx, dns_rdataclass_t rdclass,
goto clean3;
dbtable->default_db = NULL;
dbtable->mctx = mctx;
dbtable->mctx = NULL;
isc_mem_attach(mctx, &dbtable->mctx);
dbtable->rdclass = rdclass;
dbtable->magic = DBTABLE_MAGIC;
dbtable->references = 1;
......@@ -105,7 +106,7 @@ dns_dbtable_create(isc_mem_t *mctx, dns_rdataclass_t rdclass,
dns_rbt_destroy(&dbtable->rbt);
clean1:
isc_mem_put(mctx, dbtable, sizeof(*dbtable));
isc_mem_putanddetach(&mctx, dbtable, sizeof(*dbtable));
return (result);
}
......@@ -129,7 +130,7 @@ dbtable_free(dns_dbtable_t *dbtable) {
dbtable->magic = 0;
isc_mem_put(dbtable->mctx, dbtable, sizeof(*dbtable));
isc_mem_putanddetach(&dbtable->mctx, dbtable, sizeof(*dbtable));
}
void
......
......@@ -73,7 +73,8 @@ dns_difftuple_create(isc_mem_t *mctx,
t = isc_mem_allocate(mctx, size);
if (t == NULL)
return (ISC_R_NOMEMORY);
t->mctx = mctx;
t->mctx = NULL;
isc_mem_attach(mctx, &t->mctx);
t->op = op;
datap = (unsigned char *)(t + 1);
......@@ -105,10 +106,15 @@ dns_difftuple_create(isc_mem_t *mctx,
void
dns_difftuple_free(dns_difftuple_t **tp) {
dns_difftuple_t *t = *tp;
isc_mem_t *mctx;
REQUIRE(DNS_DIFFTUPLE_VALID(t));
dns_name_invalidate(&t->name);
t->magic = 0;
isc_mem_free(t->mctx, t);
mctx = t->mctx;
isc_mem_free(mctx, t);
isc_mem_detach(&mctx);
*tp = NULL;
}
......
......@@ -1149,7 +1149,7 @@ dst_key_free(dst_key_t **keyp) {
isc_buffer_free(&key->key_tkeytoken);
}
memset(key, 0, sizeof(dst_key_t));
isc_mem_put(mctx, key, sizeof(dst_key_t));
isc_mem_putanddetach(&mctx, key, sizeof(dst_key_t));
*keyp = NULL;
}
......@@ -1348,10 +1348,10 @@ get_key_struct(dns_name_t *name, unsigned int alg,
isc_mem_put(mctx, key, sizeof(dst_key_t));
return (NULL);
}
isc_mem_attach(mctx, &key->mctx);
key->key_alg = alg;
key->key_flags = flags;
key->key_proto = protocol;
key->mctx = mctx;
key->keydata.generic = NULL;
key->key_size = bits;
key->key_class = rdclass;
......
......@@ -1440,6 +1440,18 @@ dns_zonemgr_setsize(dns_zonemgr_t *zmgr, int num_zones);
*\li zmgr->zonetasks has been initialized.
*/
isc_result_t
dns_zonemgr_createzone(dns_zonemgr_t *zmgr, dns_zone_t **zonep);
/*%<
* Allocate a new zone using a memory context from the
* zone manager's memory context pool.
*
* Require:
*\li 'zmgr' to be a valid zone manager.
*\li 'zonep' != NULL and '*zonep' == NULL.
*/
isc_result_t
dns_zonemgr_managezone(dns_zonemgr_t *zmgr, dns_zone_t *zone);
/*%<
......
......@@ -36,7 +36,8 @@ dns_iptable_create(isc_mem_t *mctx, dns_iptable_t **target) {
tab = isc_mem_get(mctx, sizeof(*tab));
if (tab == NULL)
return (ISC_R_NOMEMORY);
tab->mctx = mctx;
tab->mctx = NULL;
isc_mem_attach(mctx, &tab->mctx);
isc_refcount_init(&tab->refcount, 1);
tab->radix = NULL;
tab->magic = DNS_IPTABLE_MAGIC;
......@@ -184,5 +185,5 @@ destroy_iptable(dns_iptable_t *dtab) {
isc_refcount_destroy(&dtab->refcount);
dtab->magic = 0;
isc_mem_put(dtab->mctx, dtab, sizeof(*dtab));
isc_mem_putanddetach(&dtab->mctx, dtab, sizeof(*dtab));
}
......@@ -568,7 +568,8 @@ journal_open(isc_mem_t *mctx, const char *filename, isc_boolean_t write,
if (j == NULL)
return (ISC_R_NOMEMORY);
j->mctx = mctx;
j->mctx = NULL;
isc_mem_attach(mctx, &j->mctx);
j->state = JOURNAL_STATE_INVALID;
j->fp = NULL;
j->filename = filename;
......@@ -679,7 +680,7 @@ journal_open(isc_mem_t *mctx, const char *filename, isc_boolean_t write,
}
if (j->fp != NULL)
(void)isc_stdio_close(j->fp);
isc_mem_put(j->mctx, j, sizeof(*j));
isc_mem_putanddetach(&j->mctx, j, sizeof(*j));
return (result);
}
......@@ -1244,7 +1245,7 @@ dns_journal_destroy(dns_journal_t **journalp) {
if (j->fp != NULL)
(void)isc_stdio_close(j->fp);
j->magic = 0;
isc_mem_put(j->mctx, j, sizeof(*j));
isc_mem_putanddetach(&j->mctx, j, sizeof(*j));
*journalp = NULL;
}
......
......@@ -67,7 +67,8 @@ dns_keytable_create(isc_mem_t *mctx, dns_keytable_t **keytablep) {
if (result != ISC_R_SUCCESS)
goto cleanup_lock;
keytable->mctx = mctx;
keytable->mctx = NULL;
isc_mem_attach(mctx, &keytable->mctx);
keytable->active_nodes = 0;
keytable->references = 1;
keytable->magic = KEYTABLE_MAGIC;
......@@ -82,7 +83,7 @@ dns_keytable_create(isc_mem_t *mctx, dns_keytable_t **keytablep) {
dns_rbt_destroy(&keytable->table);
cleanup_keytable:
isc_mem_put(mctx, keytable, sizeof(*keytable));
isc_mem_putanddetach(&mctx, keytable, sizeof(*keytable));
return (result);
}
......@@ -137,7 +138,8 @@ dns_keytable_detach(dns_keytable_t **keytablep) {
isc_rwlock_destroy(&keytable->rwlock);
DESTROYLOCK(&keytable->lock);
keytable->magic = 0;
isc_mem_put(keytable->mctx, keytable, sizeof(*keytable));
isc_mem_putanddetach(&keytable->mctx,
keytable, sizeof(*keytable));
}
*keytablep = NULL;
......
......@@ -393,7 +393,8 @@ dns_lookup_create(isc_mem_t *mctx, dns_name_t *name, dns_rdatatype_t type,
lookup = isc_mem_get(mctx, sizeof(*lookup));
if (lookup == NULL)
return (ISC_R_NOMEMORY);
lookup->mctx = mctx;
lookup->mctx = NULL;
isc_mem_attach(mctx, &lookup->mctx);
lookup->options = options;
ievent = isc_event_allocate(mctx, lookup, DNS_EVENT_LOOKUPDONE,
......@@ -452,7 +453,7 @@ dns_lookup_create(isc_mem_t *mctx, dns_name_t *name, dns_rdatatype_t type,
isc_task_detach(&lookup->task);
cleanup_lookup:
isc_mem_put(mctx, lookup, sizeof(*lookup));
isc_mem_putanddetach(&mctx, lookup, sizeof(*lookup));
return (result);
}
......@@ -491,7 +492,7 @@ dns_lookup_destroy(dns_lookup_t **lookupp) {
DESTROYLOCK(&lookup->lock);
lookup->magic = 0;
isc_mem_put(lookup->mctx, lookup, sizeof(*lookup));
isc_mem_putanddetach(&lookup->mctx, lookup, sizeof(*lookup));
*lookupp = NULL;
}
......@@ -732,7 +732,9 @@ dns_message_create(isc_mem_t *mctx, unsigned int intent, dns_message_t **msgp)
for (i = 0; i < DNS_SECTION_MAX; i++)
ISC_LIST_INIT(m->sections[i]);
m->mctx = mctx;
m->mctx = NULL;
isc_mem_attach(mctx, &m->mctx);
ISC_LIST_INIT(m->scratchpad);
ISC_LIST_INIT(m->cleanup);
......@@ -786,7 +788,7 @@ dns_message_create(isc_mem_t *mctx, unsigned int intent, dns_message_t **msgp)
if (m->rdspool != NULL)
isc_mempool_destroy(&m->rdspool);
m->magic = 0;
isc_mem_put(mctx, m, sizeof(dns_message_t));
isc_mem_putanddetach(&mctx, m, sizeof(dns_message_t));
return (ISC_R_NOMEMORY);
}
......@@ -815,7 +817,7 @@ dns_message_destroy(dns_message_t **msgp) {
isc_mempool_destroy(&msg->namepool);
isc_mempool_destroy(&msg->rdspool);
msg->magic = 0;
isc_mem_put(msg->mctx, msg, sizeof(dns_message_t));
isc_mem_putanddetach(&msg->mctx, msg, sizeof(dns_message_t));
}
static isc_result_t
......
......@@ -755,7 +755,8 @@ dns_rbt_create(isc_mem_t *mctx, void (*deleter)(void *, void *),
if (rbt == NULL)
return (ISC_R_NOMEMORY);
rbt->mctx = mctx;
rbt->mctx = NULL;
isc_mem_attach(mctx, &rbt->mctx);
rbt->data_deleter = deleter;
rbt->deleter_arg = deleter_arg;
rbt->root = NULL;
......@@ -767,7 +768,7 @@ dns_rbt_create(isc_mem_t *mctx, void (*deleter)(void *, void *),
#ifdef DNS_RBT_USEHASH
result = inithash(rbt);
if (result != ISC_R_SUCCESS) {
isc_mem_put(mctx, rbt, sizeof(*rbt));
isc_mem_putanddetach(&rbt->mctx, rbt, sizeof(*rbt));
return (result);
}
#endif
......@@ -809,7 +810,7 @@ dns_rbt_destroy2(dns_rbt_t **rbtp, unsigned int quantum) {
rbt->magic = 0;
isc_mem_put(rbt->mctx, rbt, sizeof(*rbt));
isc_mem_putanddetach(&rbt->mctx, rbt, sizeof(*rbt));
*rbtp = NULL;
return (ISC_R_SUCCESS);
}
......
......@@ -212,7 +212,9 @@ dns_test_makezone(const char *name, dns_zone_t **zonep, dns_view_t *view,
else if (!keepview)
keepview = ISC_TRUE;
CHECK(dns_zone_create(&zone, mctx));
zone = *zonep;
if (zone == NULL)
CHECK(dns_zone_create(&zone, mctx));
isc_buffer_constinit(&buffer, name, strlen(name));
isc_buffer_add(&buffer, strlen(name));
......
......@@ -110,6 +110,46 @@ ATF_TC_BODY(zonemgr_managezone, tc) {
dns_test_end();
}
ATF_TC(zonemgr_createzone);
ATF_TC_HEAD(zonemgr_createzone, tc) {
atf_tc_set_md_var(tc, "descr", "create and release a zone");
}
ATF_TC_BODY(zonemgr_createzone, tc) {
dns_zonemgr_t *zonemgr = NULL;
dns_zone_t *zone = NULL;
isc_result_t result;
UNUSED(tc);
result = dns_test_begin(NULL, ISC_TRUE);
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
result = dns_zonemgr_create(mctx, taskmgr, timermgr, socketmgr,
&zonemgr);
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
/* This should not succeed until the dns_zonemgr_setsize() is run */
result = dns_zonemgr_createzone(zonemgr, &zone);
ATF_REQUIRE_EQ(result, ISC_R_FAILURE);
result = dns_zonemgr_setsize(zonemgr, 1);
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
/* Now it should succeed */
result = dns_zonemgr_createzone(zonemgr, &zone);
ATF_CHECK_EQ(result, ISC_R_SUCCESS);
ATF_CHECK(zone != NULL);
if (zone != NULL)
dns_zone_detach(&zone);
dns_zonemgr_shutdown(zonemgr);
dns_zonemgr_detach(&zonemgr);
ATF_REQUIRE_EQ(zonemgr, NULL);
dns_test_end();
}
ATF_TC(zonemgr_unreachable);
ATF_TC_HEAD(zonemgr_unreachable, tc) {
atf_tc_set_md_var(tc, "descr", "manage and release a zone");
......@@ -182,6 +222,7 @@ ATF_TC_BODY(zonemgr_unreachable, tc) {
ATF_TP_ADD_TCS(tp) {
ATF_TP_ADD_TC(tp, zonemgr_create);
ATF_TP_ADD_TC(tp, zonemgr_managezone);
ATF_TP_ADD_TC(tp, zonemgr_createzone);
ATF_TP_ADD_TC(tp, zonemgr_unreachable);
return (atf_no_error());
}
......
......@@ -951,6 +951,7 @@ dns_zone_unload
dns_zonekey_iszonekey
dns_zonemgr_attach
dns_zonemgr_create
dns_zonemgr_createzone
dns_zonemgr_detach
dns_zonemgr_forcemaint
dns_zonemgr_getcount
......
......@@ -25,6 +25,7 @@
#include <isc/file.h>
#include <isc/hex.h>
#include <isc/mutex.h>
#include <isc/pool.h>
#include <isc/print.h>
#include <isc/random.h>
#include <isc/ratelimiter.h>
......@@ -469,6 +470,7 @@ struct dns_zonemgr {
isc_taskpool_t * zonetasks;
isc_taskpool_t * loadtasks;
isc_task_t * task;
isc_pool_t * mctxpool;
isc_ratelimiter_t * rl;
isc_rwlock_t rwlock;
isc_mutex_t iolock;
......@@ -14004,6 +14006,7 @@ dns_zonemgr_create(isc_mem_t *mctx, isc_taskmgr_t *taskmgr,
zmgr->socketmgr = socketmgr;
zmgr->zonetasks = NULL;
zmgr->loadtasks = NULL;
zmgr->mctxpool = NULL;
zmgr->task = NULL;
zmgr->rl = NULL;
ISC_LIST_INIT(zmgr->zones);
......@@ -14071,6 +14074,33 @@ dns_zonemgr_create(isc_mem_t *mctx, isc_taskmgr_t *taskmgr,
return (result);
}
isc_result_t
dns_zonemgr_createzone(dns_zonemgr_t *zmgr, dns_zone_t **zonep) {
isc_result_t result;
isc_mem_t *mctx = NULL;
dns_zone_t *zone = NULL;
void *item;
REQUIRE(DNS_ZONEMGR_VALID(zmgr));
REQUIRE(zonep != NULL && *zonep == NULL);
if (zmgr->mctxpool == NULL)
return (ISC_R_FAILURE);
item = isc_pool_get(zmgr->mctxpool);
if (item == NULL)
return (ISC_R_FAILURE);
isc_mem_attach((isc_mem_t *) item, &mctx);
result = dns_zone_create(&zone, mctx);
isc_mem_detach(&mctx);
if (result == ISC_R_SUCCESS)
*zonep = zone;
return (result);
}
isc_result_t
dns_zonemgr_managezone(dns_zonemgr_t *zmgr, dns_zone_t *zone) {
isc_result_t result;
......@@ -14237,6 +14267,8 @@ dns_zonemgr_shutdown(dns_zonemgr_t *zmgr) {
isc_taskpool_destroy(&zmgr->zonetasks);
if (zmgr->loadtasks != NULL)
isc_taskpool_destroy(&zmgr->loadtasks);
if (zmgr->mctxpool != NULL)
isc_pool_destroy(&zmgr->mctxpool);
RWLOCK(&zmgr->rwlock, isc_rwlocktype_read);
for (zone = ISC_LIST_HEAD(zmgr->zones);
......@@ -14250,21 +14282,54 @@ dns_zonemgr_shutdown(dns_zonemgr_t *zmgr) {
RWUNLOCK(&zmgr->rwlock, isc_rwlocktype_read);
}
static isc_result_t
mctxinit(void **target, void *arg) {
isc_result_t result;
isc_mem_t *mctx = NULL;
UNUSED(arg);
REQUIRE(target != NULL && *target == NULL);
result = isc_mem_create(0, 0, &mctx);
if (result != ISC_R_SUCCESS)
return (result);
isc_mem_setname(mctx, "zonemgr-pool", NULL);
*target = mctx;
return (ISC_R_SUCCESS);
}
static void
mctxfree(void **target) {
isc_mem_t *mctx = *(isc_mem_t **) target;
isc_mem_detach(&mctx);
*target = NULL;
}
#define ZONES_PER_TASK 100
#define ZONES_PER_MCTX 1000
isc_result_t
dns_zonemgr_setsize(dns_zonemgr_t *zmgr, int num_zones) {
isc_result_t result;
int ntasks = num_zones / 100;
int ntasks = num_zones / ZONES_PER_TASK;
int nmctx = num_zones / ZONES_PER_MCTX;
isc_taskpool_t *pool = NULL;
isc_pool_t *mctxpool = NULL;
REQUIRE(DNS_ZONEMGR_VALID(zmgr));
/*
* For anything fewer than 1000 zones we use 10 tasks in
* the task pools. More than that, and we'll scale at one
* task per 100 zones.
* task per 100 zones. Similarly, for anything smaller than
* 2000 zones we use 2 memory contexts, then scale at 1:1000.
*/
if (ntasks < 10)
ntasks = 10;
if (nmctx < 2)
nmctx = 2;
/* Create or resize the zone task pools. */
if (zmgr->zonetasks == NULL)
......@@ -14303,6 +14368,16 @@ dns_zonemgr_setsize(dns_zonemgr_t *zmgr, int num_zones) {
isc_taskpool_setprivilege(zmgr->loadtasks, ISC_TRUE);
#endif
/* Create or resize the zone memory context pool. */
if (zmgr->mctxpool == NULL)
result = isc_pool_create(zmgr->mctx, nmctx, mctxfree,
mctxinit, NULL, &mctxpool);
else
result = isc_pool_expand(&zmgr->mctxpool, nmctx, &mctxpool);
if (result == ISC_R_SUCCESS)
zmgr->mctxpool = mctxpool;
return (result);
}
......
......@@ -58,7 +58,7 @@ OBJS = @ISC_EXTRA_OBJS@ \
httpd.@O@ inet_aton.@O@ iterated_hash.@O@ \
lex.@O@ lfsr.@O@ lib.@O@ log.@O@ \
md5.@O@ mem.@O@ mutexblock.@O@ \
netaddr.@O@ netscope.@O@ ondestroy.@O@ \
netaddr.@O@ netscope.@O@ pool.@O@ ondestroy.@O@ \
parseint.@O@ portset.@O@ quota.@O@ radix.@O@ random.@O@ \
ratelimiter.@O@ refcount.@O@ region.@O@ result.@O@ rwlock.@O@ \
serial.@O@ sha1.@O@ sha2.@O@ sockaddr.@O@ stats.@O@ \
......@@ -74,7 +74,7 @@ SRCS = @ISC_EXTRA_SRCS@ \
httpd.c inet_aton.c iterated_hash.c \
lex.c lfsr.c lib.c log.c \
md5.c mem.c mutexblock.c \
netaddr.c netscope.c ondestroy.c \
netaddr.c netscope.c pool.c ondestroy.c \
parseint.c portset.c quota.c radix.c random.c \
ratelimiter.c refcount.c region.c result.c rwlock.c \
serial.c sha1.c sha2.c sockaddr.c stats.c string.c strtoul.c \
......