Compare commits

...

2 Commits

Author SHA1 Message Date
Ondřej Surý
2f710fbe16 EXP: get rid of node locknum 2021-07-16 12:52:41 +02:00
Ondřej Surý
4f1a5db9fb EXP: Reduce the node_locks count to 3 2021-07-16 12:52:35 +02:00
4 changed files with 234 additions and 481 deletions

View File

@@ -40,8 +40,6 @@ ISC_LANG_BEGINDECLS
#define DNS_RBT_USEMAGIC 1
#define DNS_RBT_LOCKLENGTH (sizeof(((dns_rbtnode_t *)0)->locknum) * 8)
#define DNS_RBTNODE_MAGIC ISC_MAGIC('R', 'B', 'N', 'O')
#if DNS_RBT_USEMAGIC
#define DNS_RBTNODE_VALID(n) ISC_MAGIC_VALID(n, DNS_RBTNODE_MAGIC)
@@ -160,8 +158,7 @@ struct dns_rbtnode {
uint8_t : 0; /* start of bitfields c/o node lock */
uint8_t dirty : 1;
uint8_t wild : 1;
uint8_t : 0; /* end of bitfields c/o node lock */
uint16_t locknum; /* note that this is not in the bitfield */
uint8_t : 0; /* end of bitfields c/o node lock */
isc_refcount_t references;
/*@}*/
};

View File

@@ -236,9 +236,8 @@ getdata(dns_rbtnode_t *node, file_header_t *header) {
* Structure elements from the rbtdb.c, not
* used as part of the rbt.c algorithms.
*/
#define DIRTY(node) ((node)->dirty)
#define WILD(node) ((node)->wild)
#define LOCKNUM(node) ((node)->locknum)
#define DIRTY(node) ((node)->dirty)
#define WILD(node) ((node)->wild)
/*%
* The variable length stuff stored after the node has the following
@@ -2279,7 +2278,6 @@ create_node(isc_mem_t *mctx, const dns_name_t *name, dns_rbtnode_t **nodep) {
ISC_LINK_INIT(node, deadlink);
LOCKNUM(node) = 0;
WILD(node) = 0;
DIRTY(node) = 0;
isc_refcount_init(&node->references, 0);
@@ -3081,8 +3079,6 @@ dns_rbt_printnodeinfo(dns_rbtnode_t *n, FILE *f) {
(n->down_is_relative == 1 ? " D" : ""),
(n->data_is_relative == 1 ? " T" : ""));
fprintf(f, "node lock address = %u\n", n->locknum);
fprintf(f, "Parent: %p\n", n->parent);
fprintf(f, "Right: %p\n", n->right);
fprintf(f, "Left: %p\n", n->left);

File diff suppressed because it is too large Load Diff

View File

@@ -109,9 +109,8 @@ const char *ownercase_vectors[12][2] = {
static bool
ownercase_test_one(const char *str1, const char *str2) {
isc_result_t result;
rbtdb_nodelock_t node_locks[1];
dns_rbtdb_t rbtdb = { .node_locks = node_locks };
dns_rbtnode_t rbtnode = { .locknum = 0 };
dns_rbtdb_t rbtdb = { 0 };
dns_rbtnode_t rbtnode = { 0 };
rdatasetheader_t header = { 0 };
unsigned char *raw = (unsigned char *)(&header) + sizeof(header);
dns_rdataset_t rdataset = {
@@ -126,9 +125,8 @@ ownercase_test_one(const char *str1, const char *str2) {
dns_fixedname_t fname1, fname2;
dns_name_t *name1, *name2;
memset(node_locks, 0, sizeof(node_locks));
/* Minimal initialization of the mock objects */
NODE_INITLOCK(&rbtdb.node_locks[0].lock);
NODE_INITLOCK(&rbtdb.node_lock.lock);
name1 = dns_fixedname_initname(&fname1);
isc_buffer_constinit(&b, str1, strlen(str1));
@@ -150,7 +148,7 @@ ownercase_test_one(const char *str1, const char *str2) {
/* Retrieve the case to name2 */
dns_rdataset_getownercase(&rdataset, name2);
NODE_DESTROYLOCK(&rbtdb.node_locks[0].lock);
NODE_DESTROYLOCK(&rbtdb.node_lock.lock);
return (dns_name_caseequal(name1, name2));
}
@@ -173,9 +171,8 @@ ownercase_test(void **state) {
static void
setownercase_test(void **state) {
isc_result_t result;
rbtdb_nodelock_t node_locks[1];
dns_rbtdb_t rbtdb = { .node_locks = node_locks };
dns_rbtnode_t rbtnode = { .locknum = 0 };
dns_rbtdb_t rbtdb = { 0 };
dns_rbtnode_t rbtnode = { 0 };
rdatasetheader_t header = { 0 };
unsigned char *raw = (unsigned char *)(&header) + sizeof(header);
dns_rdataset_t rdataset = {
@@ -195,8 +192,7 @@ setownercase_test(void **state) {
UNUSED(state);
/* Minimal initialization of the mock objects */
memset(node_locks, 0, sizeof(node_locks));
NODE_INITLOCK(&rbtdb.node_locks[0].lock);
NODE_INITLOCK(&rbtdb.node_lock.lock);
name1 = dns_fixedname_initname(&fname1);
isc_buffer_constinit(&b, str1, strlen(str1));
@@ -215,7 +211,7 @@ setownercase_test(void **state) {
/* Retrieve the case to name2 */
dns_rdataset_getownercase(&rdataset, name2);
NODE_DESTROYLOCK(&rbtdb.node_locks[0].lock);
NODE_DESTROYLOCK(&rbtdb.node_lock.lock);
assert_true(dns_name_caseequal(name1, name2));
}