#include <config.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <isc/file.h>
#include <isc/mem.h>
#include <isc/stdio.h>
#include <isc/string.h>
#include <isc/util.h>
#include <dns/compress.h>
#include <dns/db.h>
#include <dns/dbiterator.h>
#include <dns/diff.h>
#include <dns/fixedname.h>
#include <dns/journal.h>
#include <dns/log.h>
#include <dns/rdataset.h>
#include <dns/rdatasetiter.h>
#include <dns/result.h>
#include <dns/soa.h>
Go to the source code of this file.
Data Structures | |
struct | journal_rawpos_t |
On-disk representation of a "pointer" to a journal entry. These are used in the journal header to locate the beginning and end of the journal, and in the journal index to locate other transactions. More... | |
union | journal_rawheader_t |
The on-disk representation of the journal header. All numbers are stored in big-endian order. More... | |
struct | journal_rawxhdr_t |
The on-disk representation of the transaction header. There is one of these at the beginning of each transaction. More... | |
struct | journal_rawrrhdr_t |
The on-disk representation of the RR header. There is one of these at the beginning of each RR. More... | |
struct | journal_pos_t |
The in-core representation of the journal header. More... | |
struct | journal_header_t |
struct | journal_xhdr_t |
The in-core representation of the transaction header. More... | |
struct | journal_rrhdr_t |
The in-core representation of the RR header. More... | |
struct | dns_journal |
Defines | |
#define | JOURNAL_COMMON_LOGARGS dns_lctx, DNS_LOGCATEGORY_GENERAL, DNS_LOGMODULE_JOURNAL |
#define | JOURNAL_DEBUG_LOGARGS(n) JOURNAL_COMMON_LOGARGS, ISC_LOG_DEBUG(n) |
#define | FAIL(code) |
It would be non-sensical (or at least obtuse) to use FAIL() with an ISC_R_SUCCESS code, but the test is there to keep the Solaris compiler from complaining about "end-of-loop code not reached". | |
#define | CHECK(op) |
#define | JOURNAL_SERIALSET 0x01U |
#define | JOURNAL_HEADER_SIZE 64 |
The header is of a fixed size, with some spare room for future extensions. | |
#define | POS_VALID(pos) ((pos).offset != 0) |
#define | POS_INVALIDATE(pos) ((pos).offset = 0, (pos).serial = 0) |
#define | JOURNAL_EMPTY(h) ((h)->begin.offset == (h)->end.offset) |
#define | DNS_JOURNAL_MAGIC ISC_MAGIC('J', 'O', 'U', 'R') |
#define | DNS_JOURNAL_VALID(t) ISC_MAGIC_VALID(t, DNS_JOURNAL_MAGIC) |
Enumerations | |
enum | journal_state_t { JOURNAL_STATE_INVALID, JOURNAL_STATE_READ, JOURNAL_STATE_WRITE, JOURNAL_STATE_TRANSACTION, JOURNAL_STATE_INLINE } |
Functions | |
static isc_result_t | index_to_disk (dns_journal_t *) |
static isc_uint32_t | decode_uint32 (unsigned char *p) |
static void | encode_uint32 (isc_uint32_t val, unsigned char *p) |
isc_result_t | dns_db_createsoatuple (dns_db_t *db, dns_dbversion_t *ver, isc_mem_t *mctx, dns_diffop_t op, dns_difftuple_t **tp) |
static void | journal_pos_decode (journal_rawpos_t *raw, journal_pos_t *cooked) |
static void | journal_pos_encode (journal_rawpos_t *raw, journal_pos_t *cooked) |
static void | journal_header_decode (journal_rawheader_t *raw, journal_header_t *cooked) |
static void | journal_header_encode (journal_header_t *cooked, journal_rawheader_t *raw) |
static isc_result_t | journal_seek (dns_journal_t *j, isc_uint32_t offset) |
static isc_result_t | journal_read (dns_journal_t *j, void *mem, size_t nbytes) |
static isc_result_t | journal_write (dns_journal_t *j, void *mem, size_t nbytes) |
static isc_result_t | journal_fsync (dns_journal_t *j) |
static isc_result_t | journal_read_xhdr (dns_journal_t *j, journal_xhdr_t *xhdr) |
static isc_result_t | journal_write_xhdr (dns_journal_t *j, isc_uint32_t size, isc_uint32_t serial0, isc_uint32_t serial1) |
static isc_result_t | journal_read_rrhdr (dns_journal_t *j, journal_rrhdr_t *rrhdr) |
static isc_result_t | journal_file_create (isc_mem_t *mctx, const char *filename) |
static isc_result_t | journal_open (isc_mem_t *mctx, const char *filename, isc_boolean_t writable, isc_boolean_t create, dns_journal_t **journalp) |
isc_result_t | dns_journal_open (isc_mem_t *mctx, const char *filename, unsigned int mode, dns_journal_t **journalp) |
Open the journal file 'filename' and create a dns_journal_t object for it. | |
static int | ixfr_order (const void *av, const void *bv) |
static isc_result_t | journal_next (dns_journal_t *j, journal_pos_t *pos) |
static void | index_find (dns_journal_t *j, isc_uint32_t serial, journal_pos_t *best_guess) |
static void | index_add (dns_journal_t *j, journal_pos_t *pos) |
static void | index_invalidate (dns_journal_t *j, isc_uint32_t serial) |
static isc_result_t | journal_find (dns_journal_t *j, isc_uint32_t serial, journal_pos_t *pos) |
isc_result_t | dns_journal_begin_transaction (dns_journal_t *j) |
Prepare to write a new transaction to the open journal file 'j'. | |
isc_result_t | dns_journal_writediff (dns_journal_t *j, dns_diff_t *diff) |
Write 'diff' to the current transaction of journal file 'j'. | |
isc_result_t | dns_journal_commit (dns_journal_t *j) |
Commit the current transaction of journal file 'j'. | |
isc_result_t | dns_journal_write_transaction (dns_journal_t *j, dns_diff_t *diff) |
void | dns_journal_destroy (dns_journal_t **journalp) |
Destroy a dns_journal_t, closing any open files and freeing its memory. | |
static isc_result_t | roll_forward (dns_journal_t *j, dns_db_t *db, unsigned int options) |
isc_result_t | dns_journal_rollforward (isc_mem_t *mctx, dns_db_t *db, unsigned int options, const char *filename) |
Roll forward (play back) the journal file "filename" into the database "db". This should be called when the server starts after a shutdown or crash. | |
isc_result_t | dns_journal_print (isc_mem_t *mctx, const char *filename, FILE *file) |
isc_uint32_t | dns_journal_first_serial (dns_journal_t *j) |
Write a complete transaction at once to a journal file, sorting it if necessary, and commit it. Equivalent to calling dns_diff_sort(), dns_journal_begin_transaction(), dns_journal_writediff(), and dns_journal_commit(). | |
isc_uint32_t | dns_journal_last_serial (dns_journal_t *j) |
Get the first and last addressable serial number in the journal. | |
void | dns_journal_set_sourceserial (dns_journal_t *j, isc_uint32_t sourceserial) |
Get and set source serial. | |
isc_boolean_t | dns_journal_get_sourceserial (dns_journal_t *j, isc_uint32_t *sourceserial) |
static isc_result_t | read_one_rr (dns_journal_t *j) |
static isc_result_t | size_buffer (isc_mem_t *mctx, isc_buffer_t *b, unsigned size) |
isc_result_t | dns_journal_iter_init (dns_journal_t *j, isc_uint32_t begin_serial, isc_uint32_t end_serial) |
Prepare to iterate over the transactions that will bring the database from SOA serial number 'begin_serial' to 'end_serial'. | |
isc_result_t | dns_journal_first_rr (dns_journal_t *j) |
isc_result_t | dns_journal_next_rr (dns_journal_t *j) |
Position the iterator at the first/next RR in a journal transaction sequence established using dns_journal_iter_init(). | |
void | dns_journal_current_rr (dns_journal_t *j, dns_name_t **name, isc_uint32_t *ttl, dns_rdata_t **rdata) |
Get the name, ttl, and rdata of the current journal RR. | |
static isc_result_t | get_name_diff (dns_db_t *db, dns_dbversion_t *ver, isc_stdtime_t now, dns_dbiterator_t *dbit, dns_name_t *name, dns_diffop_t op, dns_diff_t *diff) |
static int | rdata_order (const void *av, const void *bv) |
static isc_result_t | dns_diff_subtract (dns_diff_t diff[2], dns_diff_t *r) |
static isc_result_t | diff_namespace (dns_db_t *dba, dns_dbversion_t *dbvera, dns_db_t *dbb, dns_dbversion_t *dbverb, unsigned int options, dns_diff_t *resultdiff) |
isc_result_t | dns_db_diff (isc_mem_t *mctx, dns_db_t *dba, dns_dbversion_t *dbvera, dns_db_t *dbb, dns_dbversion_t *dbverb, const char *filename) |
isc_result_t | dns_db_diffx (dns_diff_t *diff, dns_db_t *dba, dns_dbversion_t *dbvera, dns_db_t *dbb, dns_dbversion_t *dbverb, const char *filename) |
Compare the databases 'dba' and 'dbb' and generate a diff/journal entry containing the changes to make 'dba' from 'dbb' (note the order). This journal entry will consist of a single, possibly very large transaction. Append the journal entry to the journal file specified by 'journal_filename' if non-NULL. | |
isc_result_t | dns_journal_compact (isc_mem_t *mctx, char *filename, isc_uint32_t serial, isc_uint32_t target_size) |
Attempt to compact the journal if it is greater that 'target_size'. Changes from 'serial' onwards will be preserved. If the journal exists and is non-empty 'serial' must exist in the journal. | |
Variables | |
static isc_boolean_t | bind8_compat = ISC_TRUE |
When true, accept IXFR difference sequences where the SOA serial number does not change (BIND 8 sends such sequences). | |
static journal_header_t | initial_journal_header = { ";BIND LOG V9\n", { 0, 0 }, { 0, 0 }, 0, 0, 0 } |
Initial contents to store in the header of a newly created journal file. |
A journal file consists of
Definition in file journal.c.
#define JOURNAL_COMMON_LOGARGS dns_lctx, DNS_LOGCATEGORY_GENERAL, DNS_LOGMODULE_JOURNAL |
Definition at line 93 of file journal.c.
Referenced by dns_journal_commit(), dns_journal_print(), journal_file_create(), journal_fsync(), journal_next(), journal_open(), journal_read(), journal_seek(), journal_write(), read_one_rr(), and roll_forward().
#define JOURNAL_DEBUG_LOGARGS | ( | n | ) | JOURNAL_COMMON_LOGARGS, ISC_LOG_DEBUG(n) |
Definition at line 96 of file journal.c.
Referenced by dns_db_diffx(), dns_journal_print(), dns_journal_rollforward(), dns_journal_writediff(), and roll_forward().
#define FAIL | ( | code | ) |
Value:
do { result = (code); \ if (result != ISC_R_SUCCESS) goto failure; \ } while (0)
#define CHECK | ( | op | ) |
Value:
do { result = (op); \ if (result != ISC_R_SUCCESS) goto failure; \ } while (0)
#define JOURNAL_SERIALSET 0x01U |
Definition at line 114 of file journal.c.
Referenced by journal_header_decode(), and journal_header_encode().
#define JOURNAL_HEADER_SIZE 64 |
The header is of a fixed size, with some spare room for future extensions.
Definition at line 206 of file journal.c.
Referenced by journal_file_create().
#define POS_VALID | ( | pos | ) | ((pos).offset != 0) |
Definition at line 256 of file journal.c.
Referenced by dns_journal_compact(), index_add(), and index_find().
#define POS_INVALIDATE | ( | pos | ) | ((pos).offset = 0, (pos).serial = 0) |
#define JOURNAL_EMPTY | ( | h | ) | ((h)->begin.offset == (h)->end.offset) |
Definition at line 300 of file journal.c.
Referenced by dns_journal_begin_transaction(), dns_journal_commit(), dns_journal_compact(), and dns_journal_rollforward().
#define DNS_JOURNAL_MAGIC ISC_MAGIC('J', 'O', 'U', 'R') |
#define DNS_JOURNAL_VALID | ( | t | ) | ISC_MAGIC_VALID(t, DNS_JOURNAL_MAGIC) |
Definition at line 347 of file journal.c.
Referenced by dns_journal_begin_transaction(), dns_journal_commit(), dns_journal_destroy(), journal_find(), journal_next(), and roll_forward().
enum journal_state_t |
static isc_result_t index_to_disk | ( | dns_journal_t * | j | ) | [static] |
Definition at line 2316 of file journal.c.
References CHECK, encode_uint32(), dns_journal::header, dns_journal::index, journal_header_t::index_size, INSIST, ISC_R_SUCCESS, journal_seek(), journal_write(), journal_pos_t::offset, dns_journal::rawindex, and journal_pos_t::serial.
Referenced by dns_journal_commit(), and dns_journal_compact().
static isc_uint32_t decode_uint32 | ( | unsigned char * | p | ) | [inline, static] |
Definition at line 119 of file journal.c.
Referenced by journal_header_decode(), journal_open(), journal_pos_decode(), journal_read_rrhdr(), journal_read_xhdr(), and soa_get().
static void encode_uint32 | ( | isc_uint32_t | val, | |
unsigned char * | p | |||
) | [inline, static] |
Definition at line 127 of file journal.c.
Referenced by index_to_disk(), journal_header_encode(), journal_pos_encode(), journal_write_xhdr(), and soa_set().
isc_result_t dns_db_createsoatuple | ( | dns_db_t * | db, | |
dns_dbversion_t * | ver, | |||
isc_mem_t * | mctx, | |||
dns_diffop_t | op, | |||
dns_difftuple_t ** | tp | |||
) |
brief Create a diff tuple for the current database SOA. XXX this probably belongs somewhere else.
Definition at line 135 of file journal.c.
References dns_db_detachnode(), dns_db_findnode(), dns_db_findrdataset(), dns_db_origin(), dns_difftuple_create(), dns_fixedname_init, dns_fixedname_name, dns_name_copy(), DNS_RDATA_INIT, dns_rdataset_current(), dns_rdataset_disassociate(), dns_rdataset_first(), dns_rdataset_getownercase(), dns_rdataset_init(), fixed, freenode(), ISC_FALSE, ISC_R_SUCCESS, dns_rdataset::ttl, and UNEXPECTED_ERROR.
Referenced by ns_xfr_start(), receive_secure_serial(), soa_rrstream_create(), update_soa_serial(), and xfrin_send_request().
static void journal_pos_decode | ( | journal_rawpos_t * | raw, | |
journal_pos_t * | cooked | |||
) | [static] |
Definition at line 350 of file journal.c.
References decode_uint32(), journal_rawpos_t::offset, journal_pos_t::offset, journal_rawpos_t::serial, and journal_pos_t::serial.
Referenced by journal_header_decode().
static void journal_pos_encode | ( | journal_rawpos_t * | raw, | |
journal_pos_t * | cooked | |||
) | [static] |
Definition at line 356 of file journal.c.
References encode_uint32(), journal_rawpos_t::offset, journal_pos_t::offset, journal_rawpos_t::serial, and journal_pos_t::serial.
Referenced by journal_header_encode().
static void journal_header_decode | ( | journal_rawheader_t * | raw, | |
journal_header_t * | cooked | |||
) | [static] |
Definition at line 362 of file journal.c.
References journal_header_t::begin, journal_rawheader_t::begin, decode_uint32(), journal_header_t::end, journal_rawheader_t::end, journal_rawheader_t::flags, journal_rawheader_t::format, journal_header_t::format, journal_rawheader_t::h, journal_rawheader_t::index_size, journal_header_t::index_size, INSIST, ISC_TF, journal_pos_decode(), JOURNAL_SERIALSET, journal_header_t::serialset, journal_rawheader_t::sourceserial, and journal_header_t::sourceserial.
Referenced by journal_open().
static void journal_header_encode | ( | journal_header_t * | cooked, | |
journal_rawheader_t * | raw | |||
) | [static] |
Definition at line 373 of file journal.c.
References journal_header_t::begin, journal_rawheader_t::begin, encode_uint32(), journal_header_t::end, journal_rawheader_t::end, journal_rawheader_t::flags, journal_rawheader_t::format, journal_header_t::format, journal_rawheader_t::h, journal_rawheader_t::index_size, journal_header_t::index_size, INSIST, journal_pos_encode(), JOURNAL_SERIALSET, journal_rawheader_t::pad, journal_header_t::serialset, journal_rawheader_t::sourceserial, and journal_header_t::sourceserial.
Referenced by dns_journal_commit(), dns_journal_compact(), and journal_file_create().
static isc_result_t journal_seek | ( | dns_journal_t * | j, | |
isc_uint32_t | offset | |||
) | [static] |
Definition at line 392 of file journal.c.
References dns_journal::filename, dns_journal::fp, ISC_LOG_ERROR, isc_log_write(), ISC_R_SUCCESS, ISC_R_UNEXPECTED, isc_result_totext(), isc_stdio_seek(), JOURNAL_COMMON_LOGARGS, and dns_journal::offset.
Referenced by dns_journal_begin_transaction(), dns_journal_commit(), dns_journal_compact(), dns_journal_first_rr(), index_to_disk(), journal_next(), and journal_open().
static isc_result_t journal_read | ( | dns_journal_t * | j, | |
void * | mem, | |||
size_t | nbytes | |||
) | [static] |
Definition at line 407 of file journal.c.
References dns_journal::filename, dns_journal::fp, ISC_LOG_ERROR, isc_log_write(), ISC_R_EOF, ISC_R_NOMORE, ISC_R_SUCCESS, ISC_R_UNEXPECTED, isc_result_totext(), isc_stdio_read(), JOURNAL_COMMON_LOGARGS, and dns_journal::offset.
Referenced by dns_journal_compact(), journal_open(), journal_read_rrhdr(), journal_read_xhdr(), and read_one_rr().
static isc_result_t journal_write | ( | dns_journal_t * | j, | |
void * | mem, | |||
size_t | nbytes | |||
) | [static] |
Definition at line 424 of file journal.c.
References dns_journal::filename, dns_journal::fp, ISC_LOG_ERROR, isc_log_write(), ISC_R_SUCCESS, ISC_R_UNEXPECTED, isc_result_totext(), isc_stdio_write(), JOURNAL_COMMON_LOGARGS, and dns_journal::offset.
Referenced by dns_journal_begin_transaction(), dns_journal_commit(), dns_journal_compact(), dns_journal_writediff(), index_to_disk(), and journal_write_xhdr().
static isc_result_t journal_fsync | ( | dns_journal_t * | j | ) | [static] |
Definition at line 439 of file journal.c.
References dns_journal::filename, dns_journal::fp, ISC_LOG_ERROR, isc_log_write(), ISC_R_SUCCESS, ISC_R_UNEXPECTED, isc_result_totext(), isc_stdio_flush(), isc_stdio_sync(), and JOURNAL_COMMON_LOGARGS.
Referenced by dns_journal_commit(), and dns_journal_compact().
static isc_result_t journal_read_xhdr | ( | dns_journal_t * | j, | |
journal_xhdr_t * | xhdr | |||
) | [static] |
Definition at line 463 of file journal.c.
References decode_uint32(), ISC_R_SUCCESS, journal_read(), journal_rawxhdr_t::serial0, journal_xhdr_t::serial0, journal_rawxhdr_t::serial1, journal_xhdr_t::serial1, journal_rawxhdr_t::size, and journal_xhdr_t::size.
Referenced by journal_next(), and read_one_rr().
static isc_result_t journal_write_xhdr | ( | dns_journal_t * | j, | |
isc_uint32_t | size, | |||
isc_uint32_t | serial0, | |||
isc_uint32_t | serial1 | |||
) | [static] |
Definition at line 476 of file journal.c.
References encode_uint32(), journal_write(), journal_rawxhdr_t::serial0, journal_rawxhdr_t::serial1, and journal_rawxhdr_t::size.
Referenced by dns_journal_commit().
static isc_result_t journal_read_rrhdr | ( | dns_journal_t * | j, | |
journal_rrhdr_t * | rrhdr | |||
) | [static] |
Definition at line 492 of file journal.c.
References decode_uint32(), ISC_R_SUCCESS, journal_read(), journal_rawrrhdr_t::size, and journal_rrhdr_t::size.
Referenced by read_one_rr().
static isc_result_t journal_file_create | ( | isc_mem_t * | mctx, | |
const char * | filename | |||
) | [static] |
Definition at line 503 of file journal.c.
References header, journal_header_t::index_size, initial_journal_header, INSIST, isc_file_remove(), ISC_LOG_ERROR, isc_log_write(), isc_mem_get, isc_mem_put, ISC_R_NOMEMORY, ISC_R_SUCCESS, ISC_R_UNEXPECTED, isc_result_totext(), isc_stdio_close(), isc_stdio_open(), isc_stdio_write(), JOURNAL_COMMON_LOGARGS, journal_header_encode(), and JOURNAL_HEADER_SIZE.
Referenced by journal_open().
static isc_result_t journal_open | ( | isc_mem_t * | mctx, | |
const char * | filename, | |||
isc_boolean_t | writable, | |||
isc_boolean_t | create, | |||
dns_journal_t ** | journalp | |||
) | [static] |
Definition at line 563 of file journal.c.
References CHECK, dns_journal::dctx, decode_uint32(), dns_decompress_init(), DNS_DECOMPRESS_NONE, DNS_JOURNAL_MAGIC, dns_name_init(), dns_rdata_init(), FAIL, dns_journal::filename, journal_header_t::format, journal_rawheader_t::format, dns_journal::fp, journal_rawheader_t::h, dns_journal::header, dns_journal::index, journal_header_t::index_size, initial_journal_header, INSIST, isc_buffer_init, ISC_LOG_DEBUG, ISC_LOG_ERROR, isc_log_write(), isc_mem_attach(), isc_mem_free, isc_mem_get, isc_mem_put, isc_mem_putanddetach, isc_mem_strdup, ISC_R_FILENOTFOUND, ISC_R_NOMEMORY, ISC_R_NOTFOUND, ISC_R_SUCCESS, ISC_R_UNEXPECTED, isc_result_totext(), isc_stdio_close(), isc_stdio_open(), dns_journal::it, JOURNAL_COMMON_LOGARGS, journal_file_create(), journal_header_decode(), journal_read(), journal_seek(), JOURNAL_STATE_INVALID, JOURNAL_STATE_READ, JOURNAL_STATE_WRITE, dns_journal::magic, dns_journal::mctx, dns_journal::name, dns_journal::offset, journal_pos_t::offset, dns_journal::rawindex, dns_journal::rdata, journal_pos_t::serial, dns_journal::source, dns_journal::state, and dns_journal::target.
Referenced by dns_journal_compact(), and dns_journal_open().
isc_result_t dns_journal_open | ( | isc_mem_t * | mctx, | |
const char * | filename, | |||
unsigned int | mode, | |||
dns_journal_t ** | journalp | |||
) |
Open the journal file 'filename' and create a dns_journal_t object for it.
DNS_JOURNAL_CREATE open the journal for reading and writing and create the journal if it does not exist. DNS_JOURNAL_WRITE open the journal for reading and writing. DNS_JOURNAL_READ open the journal for reading only.
Definition at line 698 of file journal.c.
References DNS_JOURNAL_CREATE, DNS_JOURNAL_WRITE, ISC_R_NOTFOUND, ISC_R_SUCCESS, isc_string_printf(), ISC_TF, and journal_open().
Referenced by dns_db_diffx(), dns_journal_print(), dns_journal_rollforward(), ixfr_init(), ixfr_rrstream_create(), receive_secure_serial(), update_action(), zone_journal(), and zone_postload().
static int ixfr_order | ( | const void * | av, | |
const void * | bv | |||
) | [static] |
Definition at line 738 of file journal.c.
References DNS_DIFFOP_ADD, DNS_DIFFOP_ADDRESIGN, DNS_DIFFOP_DEL, DNS_DIFFOP_DELRESIGN, INSIST, dns_difftuple::op, r, dns_difftuple::rdata, and dns_rdata::type.
Referenced by dns_journal_write_transaction().
static isc_result_t journal_next | ( | dns_journal_t * | j, | |
journal_pos_t * | pos | |||
) | [static] |
Definition at line 802 of file journal.c.
References DNS_JOURNAL_VALID, journal_header_t::end, dns_journal::filename, dns_journal::header, ISC_LOG_ERROR, isc_log_write(), ISC_R_NOMORE, ISC_R_SUCCESS, ISC_R_UNEXPECTED, JOURNAL_COMMON_LOGARGS, journal_read_xhdr(), journal_seek(), journal_pos_t::offset, REQUIRE, return(), journal_pos_t::serial, journal_xhdr_t::serial0, journal_xhdr_t::serial1, and journal_xhdr_t::size.
Referenced by dns_journal_commit(), dns_journal_compact(), and journal_find().
static void index_find | ( | dns_journal_t * | j, | |
isc_uint32_t | serial, | |||
journal_pos_t * | best_guess | |||
) | [static] |
Definition at line 855 of file journal.c.
References DNS_SERIAL_GE, DNS_SERIAL_GT, dns_journal::header, dns_journal::index, journal_header_t::index_size, POS_VALID, and journal_pos_t::serial.
Referenced by journal_find().
static void index_add | ( | dns_journal_t * | j, | |
journal_pos_t * | pos | |||
) | [static] |
Definition at line 877 of file journal.c.
References header, dns_journal::header, dns_journal::index, journal_header_t::index_size, INSIST, POS_INVALIDATE, and POS_VALID.
Referenced by dns_journal_commit(), and dns_journal_compact().
static void index_invalidate | ( | dns_journal_t * | j, | |
isc_uint32_t | serial | |||
) | [static] |
Definition at line 916 of file journal.c.
References DNS_SERIAL_GT, dns_journal::header, dns_journal::index, journal_header_t::index_size, POS_INVALIDATE, and journal_pos_t::serial.
Referenced by dns_journal_commit().
static isc_result_t journal_find | ( | dns_journal_t * | j, | |
isc_uint32_t | serial, | |||
journal_pos_t * | pos | |||
) | [static] |
Definition at line 946 of file journal.c.
References journal_header_t::begin, DNS_JOURNAL_VALID, DNS_SERIAL_GT, journal_header_t::end, dns_journal::header, index_find(), ISC_R_NOTFOUND, ISC_R_RANGE, ISC_R_SUCCESS, journal_next(), REQUIRE, and journal_pos_t::serial.
Referenced by dns_journal_iter_init(), and roll_forward().
isc_result_t dns_journal_begin_transaction | ( | dns_journal_t * | j | ) |
Prepare to write a new transaction to the open journal file 'j'.
Requires:
Definition at line 975 of file journal.c.
References CHECK, DNS_JOURNAL_VALID, journal_header_t::end, dns_journal::header, journal_header_t::index_size, ISC_R_SUCCESS, JOURNAL_EMPTY, journal_seek(), JOURNAL_STATE_INLINE, JOURNAL_STATE_TRANSACTION, JOURNAL_STATE_WRITE, journal_write(), dns_journal::n_soa, dns_journal::offset, journal_pos_t::offset, dns_journal::pos, REQUIRE, dns_journal::state, and dns_journal::x.
Referenced by dns_journal_write_transaction(), and ixfr_apply().
isc_result_t dns_journal_writediff | ( | dns_journal_t * | j, | |
dns_diff_t * | diff | |||
) |
Write 'diff' to the current transaction of journal file 'j'.
Requires:
Definition at line 1016 of file journal.c.
References isc_region::base, buffer, CHECK, dns_rdata::data, dns_diff_print(), DNS_DIFF_VALID, dns_soa_getserial(), INSIST, isc_buffer_availablelength, isc_buffer_init, isc_buffer_putmem, isc_buffer_putuint16, isc_buffer_putuint32, isc_buffer_usedregion, ISC_LIST_HEAD, ISC_LIST_NEXT, isc_log_write(), isc_mem_get, isc_mem_put, ISC_R_NOMEMORY, ISC_R_SUCCESS, JOURNAL_DEBUG_LOGARGS, JOURNAL_STATE_TRANSACTION, journal_write(), isc_region::length, dns_rdata::length, dns_name::length, dns_journal::mctx, dns_journal::n_soa, dns_difftuple::name, dns_name::ndata, journal_pos_t::offset, dns_journal::pos, dns_difftuple::rdata, dns_rdata::rdclass, REQUIRE, journal_pos_t::serial, dns_journal::state, dns_difftuple::ttl, dns_rdata::type, and dns_journal::x.
Referenced by dns_journal_write_transaction(), and ixfr_apply().
isc_result_t dns_journal_commit | ( | dns_journal_t * | j | ) |
Commit the current transaction of journal file 'j'.
Requires:
Definition at line 1100 of file journal.c.
References journal_header_t::begin, bind8_compat, CHECK, DNS_JOURNAL_VALID, DNS_SERIAL_GT, journal_header_t::end, dns_journal::filename, dns_journal::header, index_add(), index_invalidate(), index_to_disk(), ISC_LOG_ERROR, isc_log_write(), ISC_R_SUCCESS, ISC_R_UNEXPECTED, JOURNAL_COMMON_LOGARGS, JOURNAL_EMPTY, journal_fsync(), journal_header_encode(), journal_next(), journal_seek(), JOURNAL_STATE_INLINE, JOURNAL_STATE_TRANSACTION, JOURNAL_STATE_WRITE, journal_write(), journal_write_xhdr(), dns_journal::n_soa, journal_pos_t::offset, dns_journal::pos, REQUIRE, journal_pos_t::serial, dns_journal::state, and dns_journal::x.
Referenced by dns_journal_write_transaction(), ixfr_commit(), and receive_secure_serial().
isc_result_t dns_journal_write_transaction | ( | dns_journal_t * | j, | |
dns_diff_t * | diff | |||
) |
Definition at line 1226 of file journal.c.
References CHECK, dns_diff_sort(), dns_journal_begin_transaction(), dns_journal_commit(), dns_journal_writediff(), ISC_R_SUCCESS, and ixfr_order().
Referenced by dns_db_diffx(), update_action(), and zone_journal().
void dns_journal_destroy | ( | dns_journal_t ** | journalp | ) |
Destroy a dns_journal_t, closing any open files and freeing its memory.
Definition at line 1238 of file journal.c.
References isc_buffer::base, dns_journal::dctx, dns_decompress_invalidate(), DNS_JOURNAL_VALID, dns_name_invalidate(), dns_journal::filename, dns_journal::fp, dns_journal::header, dns_journal::index, journal_header_t::index_size, isc_mem_free, isc_mem_put, isc_mem_putanddetach, ISC_R_FAILURE, isc_stdio_close(), dns_journal::it, isc_buffer::length, dns_journal::magic, dns_journal::mctx, dns_journal::name, dns_journal::rawindex, REQUIRE, dns_journal::result, dns_journal::source, and dns_journal::target.
Referenced by dns_db_diffx(), dns_journal_compact(), dns_journal_print(), dns_journal_rollforward(), ixfr_rrstream_destroy(), maybe_free(), receive_secure_serial(), update_action(), xfrin_fail(), xfrin_recv_done(), xfrin_reset(), zone_journal(), and zone_postload().
static isc_result_t roll_forward | ( | dns_journal_t * | j, | |
dns_db_t * | db, | |||
unsigned int | options | |||
) | [static] |
Definition at line 1272 of file journal.c.
References isc_buffer::base, CHECK, dns_journal::current_serial, dns_db_closeversion(), dns_db_getsoaserial(), dns_db_newversion(), DNS_DB_VALID, dns_diff_append(), dns_diff_apply(), dns_diff_clear(), dns_diff_init(), dns_diff_print(), DNS_DIFFOP_ADD, DNS_DIFFOP_ADDRESIGN, DNS_DIFFOP_DEL, DNS_DIFFOP_DELRESIGN, dns_difftuple_create(), dns_journal_current_rr(), dns_journal_first_rr(), dns_journal_iter_init(), dns_journal_last_serial(), dns_journal_next_rr(), DNS_JOURNAL_VALID, DNS_JOURNALOPT_RESIGN, DNS_R_UPTODATE, FAIL, dns_journal::filename, INSIST, isc_buffer_init, ISC_FALSE, ISC_LOG_ERROR, isc_log_write(), isc_mem_put, ISC_R_NOMORE, ISC_R_SUCCESS, ISC_R_UNEXPECTED, ISC_TRUE, dns_journal::it, JOURNAL_COMMON_LOGARGS, JOURNAL_DEBUG_LOGARGS, journal_find(), isc_buffer::length, dns_diff::mctx, dns_journal::mctx, name, REQUIRE, ttl, and dns_rdata::type.
Referenced by dns_journal_rollforward().
isc_result_t dns_journal_rollforward | ( | isc_mem_t * | mctx, | |
dns_db_t * | db, | |||
unsigned int | options, | |||
const char * | filename | |||
) |
Roll forward (play back) the journal file "filename" into the database "db". This should be called when the server starts after a shutdown or crash.
Requires:
Definition at line 1406 of file journal.c.
References DNS_DB_VALID, dns_journal_destroy(), dns_journal_open(), DNS_JOURNAL_READ, DNS_R_NOJOURNAL, DNS_R_UPTODATE, dns_journal::header, isc_log_write(), ISC_R_NOTFOUND, ISC_R_SUCCESS, JOURNAL_DEBUG_LOGARGS, JOURNAL_EMPTY, REQUIRE, and roll_forward().
Referenced by zone_postload().
isc_result_t dns_journal_print | ( | isc_mem_t * | mctx, | |
const char * | filename, | |||
FILE * | file | |||
) |
Definition at line 1435 of file journal.c.
References isc_buffer::base, CHECK, cleanup(), dns_diff_append(), dns_diff_clear(), dns_diff_init(), dns_diff_print(), DNS_DIFFOP_ADD, DNS_DIFFOP_DEL, dns_difftuple_create(), dns_journal_current_rr(), dns_journal_destroy(), dns_journal_first_rr(), dns_journal_first_serial(), dns_journal_iter_init(), dns_journal_last_serial(), dns_journal_next_rr(), dns_journal_open(), DNS_JOURNAL_READ, DNS_R_NOJOURNAL, FAIL, dns_journal::filename, dns_journal::header, isc_buffer_init, ISC_LOG_ERROR, isc_log_write(), isc_mem_put, ISC_R_NOMORE, ISC_R_NOTFOUND, ISC_R_SUCCESS, ISC_R_UNEXPECTED, isc_result_totext(), JOURNAL_COMMON_LOGARGS, JOURNAL_DEBUG_LOGARGS, isc_buffer::length, dns_diff::mctx, dns_journal::mctx, name, REQUIRE, journal_header_t::serialset, journal_header_t::sourceserial, ttl, and dns_rdata::type.
isc_uint32_t dns_journal_first_serial | ( | dns_journal_t * | j | ) |
Write a complete transaction at once to a journal file, sorting it if necessary, and commit it. Equivalent to calling dns_diff_sort(), dns_journal_begin_transaction(), dns_journal_writediff(), and dns_journal_commit().
Requires:
Definition at line 1547 of file journal.c.
References journal_header_t::begin, dns_journal::header, and journal_pos_t::serial.
Referenced by dns_journal_print(), and receive_secure_serial().
isc_uint32_t dns_journal_last_serial | ( | dns_journal_t * | j | ) |
Get the first and last addressable serial number in the journal.
Definition at line 1552 of file journal.c.
References journal_header_t::end, dns_journal::header, and journal_pos_t::serial.
Referenced by dns_journal_print(), roll_forward(), and zone_postload().
void dns_journal_set_sourceserial | ( | dns_journal_t * | j, | |
isc_uint32_t | sourceserial | |||
) |
Get and set source serial.
Returns: ISC_TRUE if sourceserial has previously been set.
Definition at line 1557 of file journal.c.
References dns_journal::header, ISC_TRUE, JOURNAL_STATE_INLINE, JOURNAL_STATE_TRANSACTION, JOURNAL_STATE_WRITE, REQUIRE, journal_header_t::serialset, journal_header_t::sourceserial, and dns_journal::state.
Referenced by receive_secure_serial(), and zone_journal().
isc_boolean_t dns_journal_get_sourceserial | ( | dns_journal_t * | j, | |
isc_uint32_t * | sourceserial | |||
) |
Definition at line 1570 of file journal.c.
References dns_journal::header, ISC_FALSE, ISC_TRUE, REQUIRE, journal_header_t::serialset, and journal_header_t::sourceserial.
Referenced by receive_secure_serial().
static isc_result_t read_one_rr | ( | dns_journal_t * | j | ) | [static] |
Definition at line 1657 of file journal.c.
References isc_buffer::base, CHECK, isc_buffer::current, dns_journal::current_serial, dns_journal::dctx, dns_name_fromwire(), DNS_R_FORMERR, dns_rdata_fromwire(), dns_rdata_reset(), dns_soa_getserial(), dns_journal::epos, FAIL, dns_journal::filename, INSIST, isc_buffer_add, isc_buffer_getuint16(), isc_buffer_getuint32(), isc_buffer_remaininglength, isc_buffer_setactive, ISC_LOG_ERROR, isc_log_write(), ISC_R_NOMORE, ISC_R_SUCCESS, ISC_R_UNEXPECTED, dns_journal::it, JOURNAL_COMMON_LOGARGS, journal_read(), journal_read_rrhdr(), journal_read_xhdr(), dns_journal::mctx, dns_journal::name, journal_pos_t::offset, dns_journal::offset, dns_journal::rdata, rdclass, dns_journal::result, journal_xhdr_t::serial0, journal_rrhdr_t::size, journal_xhdr_t::size, size_buffer(), dns_journal::source, dns_journal::target, dns_journal::ttl, ttl, isc_buffer::used, dns_journal::xpos, and dns_journal::xsize.
Referenced by dns_journal_first_rr(), and dns_journal_next_rr().
static isc_result_t size_buffer | ( | isc_mem_t * | mctx, | |
isc_buffer_t * | b, | |||
unsigned | size | |||
) | [static] |
Definition at line 1603 of file journal.c.
References isc_buffer::base, isc_buffer_clear, isc_mem_get, isc_mem_put, ISC_R_NOMEMORY, ISC_R_SUCCESS, and isc_buffer::length.
Referenced by read_one_rr().
isc_result_t dns_journal_iter_init | ( | dns_journal_t * | j, | |
isc_uint32_t | begin_serial, | |||
isc_uint32_t | end_serial | |||
) |
Prepare to iterate over the transactions that will bring the database from SOA serial number 'begin_serial' to 'end_serial'.
Returns:
Definition at line 1618 of file journal.c.
References dns_journal::bpos, CHECK, dns_journal::epos, INSIST, ISC_R_SUCCESS, dns_journal::it, journal_find(), dns_journal::result, and journal_pos_t::serial.
Referenced by dns_journal_print(), ixfr_rrstream_create(), roll_forward(), and sync_secure_journal().
isc_result_t dns_journal_first_rr | ( | dns_journal_t * | j | ) |
Definition at line 1637 of file journal.c.
References dns_journal::bpos, CHECK, dns_journal::current_serial, dns_journal::it, journal_seek(), journal_pos_t::offset, read_one_rr(), journal_pos_t::serial, dns_journal::xpos, and dns_journal::xsize.
Referenced by dns_journal_print(), ixfr_rrstream_first(), roll_forward(), and sync_secure_journal().
isc_result_t dns_journal_next_rr | ( | dns_journal_t * | j | ) |
Position the iterator at the first/next RR in a journal transaction sequence established using dns_journal_iter_init().
Requires:
Definition at line 1770 of file journal.c.
References dns_journal::it, read_one_rr(), and dns_journal::result.
Referenced by dns_journal_print(), ixfr_rrstream_next(), roll_forward(), and sync_secure_journal().
void dns_journal_current_rr | ( | dns_journal_t * | j, | |
dns_name_t ** | name, | |||
isc_uint32_t * | ttl, | |||
dns_rdata_t ** | rdata | |||
) |
Get the name, ttl, and rdata of the current journal RR.
Requires:
Definition at line 1776 of file journal.c.
References ISC_R_SUCCESS, dns_journal::it, dns_journal::name, dns_journal::rdata, REQUIRE, dns_journal::result, and dns_journal::ttl.
Referenced by dns_journal_print(), ixfr_rrstream_current(), roll_forward(), and sync_secure_journal().
static isc_result_t get_name_diff | ( | dns_db_t * | db, | |
dns_dbversion_t * | ver, | |||
isc_stdtime_t | now, | |||
dns_dbiterator_t * | dbit, | |||
dns_name_t * | name, | |||
dns_diffop_t | op, | |||
dns_diff_t * | diff | |||
) | [static] |
Definition at line 1800 of file journal.c.
References dns_db_allrdatasets(), dns_db_detachnode(), dns_dbiterator_current(), dns_diff_append(), dns_difftuple_create(), DNS_RDATA_INIT, dns_rdataset_current(), dns_rdataset_disassociate(), dns_rdataset_first(), dns_rdataset_init(), dns_rdataset_next(), dns_rdatasetiter_current(), dns_rdatasetiter_destroy(), dns_rdatasetiter_first(), dns_rdatasetiter_next(), ISC_R_NOMORE, ISC_R_SUCCESS, dns_diff::mctx, and dns_rdataset::ttl.
Referenced by diff_namespace().
static int rdata_order | ( | const void * | av, | |
const void * | bv | |||
) | [static] |
Definition at line 1866 of file journal.c.
References dns_rdata_compare(), r, dns_difftuple::rdata, and dns_rdata::type.
Referenced by dns_diff_subtract().
static isc_result_t dns_diff_subtract | ( | dns_diff_t | diff[2], | |
dns_diff_t * | r | |||
) | [static] |
Definition at line 1880 of file journal.c.
References append(), CHECK, dns_diff_sort(), dns_difftuple_free(), INSIST, ISC_LIST_APPEND, ISC_LIST_HEAD, ISC_LIST_UNLINK, ISC_R_SUCCESS, ISC_TF, rdata_order(), and ttl.
Referenced by diff_namespace().
static isc_result_t diff_namespace | ( | dns_db_t * | dba, | |
dns_dbversion_t * | dbvera, | |||
dns_db_t * | dbb, | |||
dns_dbversion_t * | dbverb, | |||
unsigned int | options, | |||
dns_diff_t * | resultdiff | |||
) | [static] |
Definition at line 1934 of file journal.c.
References CHECK, dns_db_createiterator(), dns_dbiterator_destroy(), dns_dbiterator_first(), dns_dbiterator_next(), dns_diff_clear(), dns_diff_init(), dns_diff_subtract(), DNS_DIFFOP_ADD, DNS_DIFFOP_DEL, dns_fixedname_init, dns_fixedname_name, dns_name_compare(), FAIL, get_name_diff(), INSIST, ISC_FALSE, ISC_LIST_APPENDLIST, ISC_LIST_EMPTY, ISC_R_NOMORE, ISC_R_SUCCESS, ISC_TRUE, and dns_diff::mctx.
Referenced by dns_db_diffx().
isc_result_t dns_db_diff | ( | isc_mem_t * | mctx, | |
dns_db_t * | dba, | |||
dns_dbversion_t * | dbvera, | |||
dns_db_t * | dbb, | |||
dns_dbversion_t * | dbverb, | |||
const char * | filename | |||
) |
Definition at line 2044 of file journal.c.
References dns_db_diffx(), dns_diff_clear(), and dns_diff_init().
Referenced by zone_replacedb().
isc_result_t dns_db_diffx | ( | dns_diff_t * | diff, | |
dns_db_t * | dba, | |||
dns_dbversion_t * | dbvera, | |||
dns_db_t * | dbb, | |||
dns_dbversion_t * | dbverb, | |||
const char * | filename | |||
) |
Compare the databases 'dba' and 'dbb' and generate a diff/journal entry containing the changes to make 'dba' from 'dbb' (note the order). This journal entry will consist of a single, possibly very large transaction. Append the journal entry to the journal file specified by 'journal_filename' if non-NULL.
Definition at line 2060 of file journal.c.
References CHECK, diff_namespace(), DNS_DB_NONSEC3, DNS_DB_NSEC3ONLY, DNS_JOURNAL_CREATE, dns_journal_destroy(), dns_journal_open(), dns_journal_write_transaction(), ISC_LIST_EMPTY, isc_log_write(), ISC_R_SUCCESS, journal, JOURNAL_DEBUG_LOGARGS, and dns_diff::mctx.
Referenced by ATF_TC_BODY(), dns_db_diff(), sync_secure_db(), and zone_unchanged().
isc_result_t dns_journal_compact | ( | isc_mem_t * | mctx, | |
char * | filename, | |||
isc_uint32_t | serial, | |||
isc_uint32_t | target_size | |||
) |
Attempt to compact the journal if it is greater that 'target_size'. Changes from 'serial' onwards will be preserved. If the journal exists and is non-empty 'serial' must exist in the journal.
Definition at line 2090 of file journal.c.
References journal_header_t::begin, CHECK, dns_journal_destroy(), DNS_SERIAL_GE, DNS_SERIAL_GT, journal_header_t::end, dns_journal::header, dns_journal::index, index_add(), journal_header_t::index_size, index_to_disk(), INSIST, ISC_FALSE, isc_file_remove(), isc_mem_get, isc_mem_put, ISC_R_FAILURE, ISC_R_FILENOTFOUND, ISC_R_NOMEMORY, ISC_R_NOTFOUND, ISC_R_RANGE, ISC_R_SUCCESS, isc_string_printf(), ISC_TRUE, JOURNAL_EMPTY, journal_fsync(), journal_header_encode(), journal_next(), journal_open(), journal_read(), journal_seek(), journal_write(), journal_pos_t::offset, POS_VALID, POST, journal_pos_t::serial, journal_header_t::serialset, and journal_header_t::sourceserial.
Referenced by dump_done(), zone_replacedb(), and zone_xfrdone().
isc_boolean_t bind8_compat = ISC_TRUE [static] |
When true, accept IXFR difference sequences where the SOA serial number does not change (BIND 8 sends such sequences).
Definition at line 86 of file journal.c.
Referenced by dns_journal_commit().
journal_header_t initial_journal_header = { ";BIND LOG V9\n", { 0, 0 }, { 0, 0 }, 0, 0, 0 } [static] |
Initial contents to store in the header of a newly created journal file.
The header starts with the magic string ";BIND LOG V9\n" to identify the file as a BIND 9 journal file. An ASCII identification string is used rather than a binary magic number to be consistent with BIND 8 (BIND 8 journal files are ASCII text files).
Definition at line 298 of file journal.c.
Referenced by journal_file_create(), and journal_open().