]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
improve calculation of database transfer size
authorEvan Hunt <each@isc.org>
Sat, 22 Feb 2020 08:37:05 +0000 (00:37 -0800)
committerOndřej Surý <ondrej@sury.org>
Tue, 26 Jan 2021 11:38:32 +0000 (12:38 +0100)
- change name of 'bytes' to 'xfrsize' in dns_db_getsize() parameter list
  and related variables; this is a more accurate representation of what
  the function is doing
- change the size calculations in dns_db_getsize() to more accurately
  represent the space needed for a *XFR message or journal file to contain
  the data in the database. previously we returned the sizes of all
  rdataslabs, including header overhead and offset tables, which
  resulted in the database size being reported as much larger than the
  equivalent *XFR or journal.
- map files caused a particular problem here: the fullname can't be
  determined from the node while a file is being deserialized, because
  the uppernode pointers aren't set yet. so we store "full name length"
  in the dns_rbtnode structure while serializing, and clear it after
  deserialization is complete.

aclocal.m4
lib/dns/include/dns/db.h
lib/dns/rbtdb.c

index fd128f09635f83f67c69dd88135f93c1d5136775..afaa95a961c760e3c5ce8c3461da05a184e87b4e 100644 (file)
@@ -1,4 +1,4 @@
-# generated automatically by aclocal 1.16.2 -*- Autoconf -*-
+# generated automatically by aclocal 1.16.3 -*- Autoconf -*-
 
 # Copyright (C) 1996-2020 Free Software Foundation, Inc.
 
index d00a407ec96328225bb1365892f7ec3af42dd8c0..b79dcae0fa5f8b5d63518664004ea5716ab39fea 100644 (file)
@@ -1489,10 +1489,10 @@ dns_db_getnsec3parameters(dns_db_t *db, dns_dbversion_t *version,
 
 isc_result_t
 dns_db_getsize(dns_db_t *db, dns_dbversion_t *version, uint64_t *records,
-              uint64_t *bytes);
+              uint64_t *xfrsize);
 /*%<
  * On success if 'records' is not NULL, it is set to the number of records
- * in the given version of the database. If 'bytes' is not NULL, it is
+ * in the given version of the database. If 'xfrisize' is not NULL, it is
  * set to the approximate number of bytes needed to transfer the records,
  * counting name, TTL, type, class, and rdata for each RR.  (This is meant
  * to be a rough approximation of the size of a full zone transfer, though
@@ -1502,7 +1502,7 @@ dns_db_getsize(dns_db_t *db, dns_dbversion_t *version, uint64_t *records,
  * \li 'db' is a valid zone database.
  * \li 'version' is NULL or a valid version.
  * \li 'records' is NULL or a pointer to return the record count in.
- * \li 'bytes' is NULL or a pointer to return the byte count in.
+ * \li 'xfrsize' is NULL or a pointer to return the byte count in.
  *
  * Returns:
  * \li #ISC_R_SUCCESS
index ef4510960015082471b4d04b75a976a140ee25f3..a05a0e411381e6c80daa173f808ef50f38fc5c0f 100644 (file)
@@ -441,11 +441,11 @@ typedef struct rbtdb_version {
        unsigned char salt[DNS_NSEC3_SALTSIZE];
 
        /*
-        * records and bytes are covered by rwlock.
+        * records and xfrsize are covered by rwlock.
         */
        isc_rwlock_t rwlock;
        uint64_t records;
-       uint64_t bytes;
+       uint64_t xfrsize;
 
        isc_rwlock_t glue_rwlock;
        size_t glue_table_bits;
@@ -1396,7 +1396,7 @@ newversion(dns_db_t *db, dns_dbversion_t **versionp) {
                        RWLOCK(&rbtdb->current_version->rwlock,
                               isc_rwlocktype_read);
                        version->records = rbtdb->current_version->records;
-                       version->bytes = rbtdb->current_version->bytes;
+                       version->xfrsize = rbtdb->current_version->xfrsize;
                        RWUNLOCK(&rbtdb->current_version->rwlock,
                                 isc_rwlocktype_read);
                        rbtdb->next_serial++;
@@ -6067,18 +6067,18 @@ recordsize(rdatasetheader_t *header, unsigned int namelen) {
 }
 
 static void
-update_recordsandbytes(bool add, rbtdb_version_t *rbtversion,
-                      rdatasetheader_t *header, unsigned int namelen) {
+update_recordsandxfrsize(bool add, rbtdb_version_t *rbtversion,
+                        rdatasetheader_t *header, unsigned int namelen) {
        unsigned char *hdr = (unsigned char *)header;
        size_t hdrsize = sizeof(*header);
 
        RWLOCK(&rbtversion->rwlock, isc_rwlocktype_write);
        if (add) {
                rbtversion->records += dns_rdataslab_count(hdr, hdrsize);
-               rbtversion->bytes += recordsize(header, namelen);
+               rbtversion->xfrsize += recordsize(header, namelen);
        } else {
                rbtversion->records -= dns_rdataslab_count(hdr, hdrsize);
-               rbtversion->bytes -= recordsize(header, namelen);
+               rbtversion->xfrsize -= recordsize(header, namelen);
        }
        RWUNLOCK(&rbtversion->rwlock, isc_rwlocktype_write);
 }
@@ -6491,9 +6491,9 @@ find_header:
                        }
                        newheader->next = topheader->next;
                        if (rbtversion != NULL && !header_nx) {
-                               update_recordsandbytes(false, rbtversion,
-                                                      header,
-                                                      nodename->length);
+                               update_recordsandxfrsize(false, rbtversion,
+                                                        header,
+                                                        nodename->length);
                        }
                        free_rdataset(rbtdb, rbtdb->common.mctx, header);
                } else {
@@ -6544,9 +6544,9 @@ find_header:
                                }
                        }
                        if (rbtversion != NULL && !header_nx) {
-                               update_recordsandbytes(false, rbtversion,
-                                                      header,
-                                                      nodename->length);
+                               update_recordsandxfrsize(false, rbtversion,
+                                                        header,
+                                                        nodename->length);
                        }
                }
        } else {
@@ -6623,8 +6623,8 @@ find_header:
        }
 
        if (rbtversion != NULL && !newheader_nx) {
-               update_recordsandbytes(true, rbtversion, newheader,
-                                      nodename->length);
+               update_recordsandxfrsize(true, rbtversion, newheader,
+                                        nodename->length);
        }
 
        /*
@@ -7118,8 +7118,8 @@ subtractrdataset(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version,
                         * to additional info.  We need to clear these fields
                         * to avoid having duplicated references.
                         */
-                       update_recordsandbytes(true, rbtversion, newheader,
-                                              nodename->length);
+                       update_recordsandxfrsize(true, rbtversion, newheader,
+                                                nodename->length);
                } else if (result == DNS_R_NXRRSET) {
                        /*
                         * This subtraction would remove all of the rdata;
@@ -7155,8 +7155,8 @@ subtractrdataset(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version,
                 * topheader.
                 */
                INSIST(rbtversion->serial >= topheader->serial);
-               update_recordsandbytes(false, rbtversion, header,
-                                      nodename->length);
+               update_recordsandxfrsize(false, rbtversion, header,
+                                        nodename->length);
                if (topheader_prev != NULL) {
                        topheader_prev->next = newheader;
                } else {
@@ -7520,8 +7520,8 @@ rbt_datafixer(dns_rbtnode_t *rbtnode, void *base, size_t filesize, void *arg,
                        }
                }
 
-               update_recordsandbytes(true, rbtdb->current_version, header,
-                                      rbtnode->fullnamelen);
+               update_recordsandxfrsize(true, rbtdb->current_version, header,
+                                        rbtnode->fullnamelen);
        }
 
        /* We're done deserializing; clear fullnamelen */
@@ -8142,7 +8142,7 @@ getnsec3parameters(dns_db_t *db, dns_dbversion_t *version, dns_hash_t *hash,
 
 static isc_result_t
 getsize(dns_db_t *db, dns_dbversion_t *version, uint64_t *records,
-       uint64_t *bytes) {
+       uint64_t *xfrsize) {
        dns_rbtdb_t *rbtdb;
        isc_result_t result = ISC_R_SUCCESS;
        rbtdb_version_t *rbtversion = version;
@@ -8162,8 +8162,8 @@ getsize(dns_db_t *db, dns_dbversion_t *version, uint64_t *records,
                *records = rbtversion->records;
        }
 
-       if (bytes != NULL) {
-               *bytes = rbtversion->bytes;
+       if (xfrsize != NULL) {
+               *xfrsize = rbtversion->xfrsize;
        }
        RWUNLOCK(&rbtversion->rwlock, isc_rwlocktype_read);
        RBTDB_UNLOCK(&rbtdb->lock, isc_rwlocktype_read);
@@ -8805,7 +8805,7 @@ dns_rbtdb_create(isc_mem_t *mctx, const dns_name_t *origin, dns_dbtype_t type,
        }
 
        rbtdb->current_version->records = 0;
-       rbtdb->current_version->bytes = 0;
+       rbtdb->current_version->xfrsize = 0;
        rbtdb->future_version = NULL;
        ISC_LIST_INIT(rbtdb->open_versions);
        /*