1 /*-
2 * Copyright (c) 1996, 2020 Oracle and/or its affiliates. All rights reserved.
3 *
4 * See the file LICENSE for license information.
5 *
6 * $Id$
7 */
8
9 /*
10 * This file contains verification functions for all types of log records,
11 * one for each type. We can't make this automated like the log_type_print/read
12 * functions because there are no consistent handling. Each type of log records
13 * have unique ways to verify, and unique information to extract.
14 *
15 * In each verification function, we first call the log_type_read function
16 * to get the log_type_args structure, then extract information according to
17 * the type of log. The log types can be made into different categories, each
18 * of which have similar types of information.
19 *
20 * For example, txn_regop and txn_ckp types both have timestamps, and we
21 * want to maintain (timestamp,lsn) mapping, so we will have a on_timestamp
22 * function, and call it in txn_regop_verify and txn_ckp_verify functions,
23 * and in the two functions we may call other on_*** functions to extract and
24 * verify other information.
25 */
26
27 #include "db_config.h"
28
29 #include "db_int.h"
30 #include "dbinc/db_page.h"
31 #include "dbinc/btree.h"
32 #include "dbinc/fop.h"
33 #include "dbinc/hash.h"
34 #include "dbinc/heap.h"
35 #include "dbinc/qam.h"
36 #include "dbinc/txn.h"
37
38 #include "dbinc/log_verify.h"
39
40 static int __log_vrfy_proc __P((DB_LOG_VRFY_INFO *, DB_LSN, DB_LSN,
41 u_int32_t, DB_TXN *, int32_t, int *));
42 static int __lv_ckp_vrfy_handler __P((DB_LOG_VRFY_INFO *,
43 VRFY_TXN_INFO *, void *));
44 static const char *__lv_dbreg_str __P((u_int32_t));
45 static int __lv_dbregid_to_dbtype __P((DB_LOG_VRFY_INFO *, int32_t, DBTYPE *));
46 static int __lv_dbt_str __P((const DBT *, char **));
47 static const char *__lv_dbtype_str __P((DBTYPE));
48 static u_int32_t __lv_first_offset __P((ENV *));
49 static int __lv_new_logfile_vrfy __P((DB_LOG_VRFY_INFO *, const DB_LSN *));
50 static int __lv_log_fwdscr_oncmt __P((DB_LOG_VRFY_INFO *, DB_LSN,
51 u_int32_t, u_int32_t, int32_t));
52 static int __lv_log_fwdscr_onrec __P((DB_LOG_VRFY_INFO *,
53 u_int32_t, u_int32_t, DB_LSN, DB_LSN));
54 static int __lv_log_mismatch __P((DB_LOG_VRFY_INFO *, DB_LSN, DBTYPE, DBTYPE));
55 static int __lv_on_bam_log __P((DB_LOG_VRFY_INFO *, DB_LSN, int32_t));
56 static int __lv_on_ham_log __P((DB_LOG_VRFY_INFO *, DB_LSN, int32_t));
57 static int __lv_on_heap_log __P((DB_LOG_VRFY_INFO *, DB_LSN, int32_t));
58 static int __lv_on_new_txn __P((DB_LOG_VRFY_INFO *, const DB_LSN *,
59 const DB_TXN *, u_int32_t, int32_t, const DBT *));
60 static int __lv_on_nontxn_update __P((DB_LOG_VRFY_INFO *, const DB_LSN *,
61 u_int32_t, u_int32_t, int32_t));
62 static int __lv_on_page_update __P((DB_LOG_VRFY_INFO *, DB_LSN, int32_t,
63 db_pgno_t, DB_TXN *, int *));
64 static int __lv_on_qam_log __P((DB_LOG_VRFY_INFO *, DB_LSN, int32_t));
65 static int __lv_on_timestamp __P((DB_LOG_VRFY_INFO *, const DB_LSN *,
66 int32_t, u_int32_t));
67 static int __lv_on_txn_aborted __P((DB_LOG_VRFY_INFO *));
68 static int __lv_on_txn_logrec __P((DB_LOG_VRFY_INFO *, const DB_LSN *,
69 const DB_LSN *, const DB_TXN *, u_int32_t, int32_t));
70 static int __lv_vrfy_for_dbfile __P((DB_LOG_VRFY_INFO *, int32_t, int *));
71
72 /* General error handlers, called when a check fails. */
73 #define ON_ERROR(lvh, errv) do { \
74 (lvh)->flags |= (errv); \
75 if (F_ISSET((lvh), DB_LOG_VERIFY_CAF)) \
76 ret = 0;/* Ignore the error and continue. */ \
77 goto err; \
78 } while (0)
79
80 /* Used by logs of unsupported types. */
81 #define ON_NOT_SUPPORTED(env, lvh, lsn, ltype) do { \
82 __db_errx((env), DB_STR_A("2536", \
83 "[%lu][%lu] Not supported type of log record %u.", \
84 "%lu %lu %u"), (u_long)((lsn).file), (u_long)((lsn).offset),\
85 (ltype)); \
86 (lvh)->unknown_logrec_cnt++; \
87 goto err; \
88 } while (0)
89
90 #define SKIP_FORWARD_CHK(type) ((type) != DB___txn_regop && \
91 (type) != DB___txn_ckp && (type) != DB___fop_rename && \
92 (type) != DB___txn_child)
93
94 #define NOTCOMMIT(type) ((type) != DB___txn_regop && \
95 (type) != DB___txn_child)
96
97 #define LOG_VRFY_PROC(lvh, lsn, argp, fileid) do { \
98 int __lv_log_vrfy_proc_step = 0; \
99 if ((ret = __log_vrfy_proc((lvh), (lsn), (argp)->prev_lsn, \
100 (argp)->type, (argp)->txnp, (fileid), \
101 &__lv_log_vrfy_proc_step)) != 0) \
102 goto err; \
103 if (__lv_log_vrfy_proc_step == 1) \
104 goto out; \
105 else if (__lv_log_vrfy_proc_step == -1) \
106 goto err; \
107 else \
108 DB_ASSERT(lvh->dbenv->env, \
109 __lv_log_vrfy_proc_step == 0); \
110 } while (0)
111
112 /* Log record handlers used by log types involving page updates. */
113 #define ON_PAGE_UPDATE(lvh, lsn, argp, pgno) do { \
114 int __lv_onpgupdate_res; \
115 if ((ret = __lv_on_page_update((lvh), (lsn), (argp)->fileid, \
116 (pgno), (argp)->txnp, &__lv_onpgupdate_res)) != 0) \
117 goto err; \
118 if (__lv_onpgupdate_res == 1) \
119 goto out; \
120 else if (__lv_onpgupdate_res == -1) \
121 goto err; \
122 else \
123 DB_ASSERT(lvh->dbenv->env, __lv_onpgupdate_res == 0); \
124 } while (0)
125
126 static int
__lv_on_page_update(lvh,lsn,fileid,pgno,txnp,step)127 __lv_on_page_update(lvh, lsn, fileid, pgno, txnp, step)
128 DB_LOG_VRFY_INFO *lvh;
129 DB_LSN lsn;
130 int32_t fileid;
131 db_pgno_t pgno;
132 DB_TXN *txnp;
133 int *step;
134 {
135 u_int32_t otxn, txnid;
136 int res, ret;
137
138 txnid = txnp->txnid;
139 res = ret = 0;
140
141 if ((ret = __add_page_to_txn(lvh, fileid, pgno,
142 txnid, &otxn, &res)) != 0)
143 ON_ERROR(lvh, DB_LOG_VERIFY_INTERR);
144 if (res != -1) {/* No access violation, we are done. */
145 *step = 0;
146 goto out;
147 }
148 /*
149 * It's OK for a child txn to update its parent's page, but not OK
150 * for a parent txn to update its active child's pages. We can't
151 * detect the child's abort, so we may false alarm that a parent txn
152 * is updating its child's pages.
153 */
154 if ((ret = __is_ancestor_txn(lvh, otxn, txnid, lsn, &res)) != 0)
155 ON_ERROR(lvh, DB_LOG_VERIFY_INTERR);
156 if (res) {/* The txnid is updating its parent otxn's pages. */
157 *step = 0;
158 goto out;
159 }
160 if ((ret = __is_ancestor_txn(lvh, txnid, otxn, lsn, &res)) != 0)
161 ON_ERROR(lvh, DB_LOG_VERIFY_INTERR);
162 if (res) {/* The txnid is updating its active child otxn's pages. */
163 __db_errx(lvh->dbenv->env, DB_STR_A("2537",
164 "[%lu][%lu] [WARNING] Parent txn %lx is updating its "
165 "active child txn %lx's pages, or %lx aborted.",
166 "%lu %lu %lx %lx %lx"), (u_long)lsn.file,
167 (u_long)lsn.offset, (u_long)txnid,
168 (u_long)otxn, (u_long)otxn);
169 *step = 0;
170 goto out;
171 }
172 /*
173 * It's likely that the two txns are parent-child and the child
174 * aborted, but from the log we can't figure out this fact.
175 */
176 __db_errx(lvh->dbenv->env, DB_STR_A("2538",
177 "[%lu][%lu] [WARNING] Txn %lx is updating txn %lx's pages.",
178 "%lu %lu %lx %lx"), (u_long)lsn.file, (u_long)lsn.offset,
179 (u_long)txnid, (u_long)otxn);
180 *step = 0;
181 out:
182 err:
183 return (ret);
184 }
185
186 /*
187 * This macro is put in all types of verify functions where a db file is
188 * updated, but no page number/lock involved.
189 */
190 #define ON_PAGE_UPDATE4
191
192 /*
193 * General log record handler used by all log verify functions.
194 */
195 static int
__log_vrfy_proc(lvh,lsn,prev_lsn,type,txnp,fileid,step)196 __log_vrfy_proc(lvh, lsn, prev_lsn, type, txnp, fileid, step)
197 DB_LOG_VRFY_INFO *lvh;
198 DB_LSN lsn, prev_lsn;
199 u_int32_t type; /* Log record type. */
200 DB_TXN *txnp;
201 int32_t fileid;
202 int *step;
203 {
204 int dovrfy, ret;
205
206 dovrfy = 1;
207 ret = 0;
208 /*
209 * step is used to tell if go on with the rest of the caller, or
210 * goto err/out.
211 * 0: go on after this function; 1: goto out; -1: goto err.
212 */
213 *step = 0;
214
215 if (F_ISSET(lvh, DB_LOG_VERIFY_FORWARD)) {
216 /* Commits are not abort/beginnings. */
217 if (NOTCOMMIT(type) && ((ret = __lv_log_fwdscr_onrec(
218 lvh, txnp->txnid, type, prev_lsn, lsn)) != 0))
219 goto err;
220 if (SKIP_FORWARD_CHK(type))
221 goto out;
222 } else {/* Verifying */
223 if (F_ISSET(lvh, DB_LOG_VERIFY_VERBOSE))
224 __db_errx(lvh->dbenv->env, DB_STR_A("2539",
225 "[%lu][%lu] Verifying log record of type %s",
226 "%lu %lu %s"), (u_long)lsn.file,
227 (u_long)lsn.offset, LOGTYPE_NAME(lvh, type));
228 /*
229 * If verifying a log range and we've passed the initial part
230 * which may have partial txns, remove the PARTIAL bit.
231 */
232 if (F_ISSET(lvh, DB_LOG_VERIFY_PARTIAL) &&
233 LOG_COMPARE(&lsn, &(lvh->valid_lsn)) >= 0) {
234 lvh->valid_lsn.offset = lvh->valid_lsn.file = 0;
235 F_CLR(lvh, DB_LOG_VERIFY_PARTIAL);
236 }
237
238 if ((ret = __lv_new_logfile_vrfy(lvh, &lsn)) != 0)
239 ON_ERROR(lvh, DB_LOG_VERIFY_ERR);
240 /* If only verify a db file, ignore logs about other dbs. */
241 if (F_ISSET(lvh, DB_LOG_VERIFY_DBFILE) && fileid !=
242 INVAL_DBREGID && (ret = __lv_vrfy_for_dbfile(lvh,
243 fileid, &dovrfy)) != 0)
244 goto err;
245 if (!dovrfy)
246 goto out;
247 if (lvh->aborted_txnid != 0 &&
248 ((ret = __lv_on_txn_aborted(lvh)) != 0))
249 goto err;
250 if ((ret = __get_aborttxn(lvh, lsn)) != 0)
251 goto err;
252 if (txnp->txnid >= TXN_MINIMUM) {
253 if ((ret = __lv_on_txn_logrec(lvh, &lsn, &(prev_lsn),
254 txnp, type, fileid)) != 0)
255 ON_ERROR(lvh, DB_LOG_VERIFY_ERR);
256 } else {/* Non-txnal updates. */
257 if ((ret = __lv_on_nontxn_update(lvh, &lsn,
258 txnp->txnid, type, fileid)) != 0)
259 ON_ERROR(lvh, DB_LOG_VERIFY_ERR);
260 }
261 }
262 if (0) {
263 out:
264 *step = 1;
265 }
266 if (0) {
267 err:
268 *step = -1;
269 }
270 return (ret);
271 }
272
273 /* Log record handlers used by log types for each access method. */
274 static int
__lv_on_bam_log(lvh,lsn,fileid)275 __lv_on_bam_log(lvh, lsn, fileid)
276 DB_LOG_VRFY_INFO *lvh;
277 DB_LSN lsn;
278 int32_t fileid;
279 {
280 int ret;
281 DBTYPE dbtype;
282 if ((ret = __lv_dbregid_to_dbtype(lvh, fileid, &dbtype)) == 0 &&
283 dbtype != DB_BTREE && dbtype != DB_RECNO && dbtype != DB_HASH)
284 ret = __lv_log_mismatch(lvh, lsn, dbtype, DB_BTREE);
285 if (ret == DB_NOTFOUND && F_ISSET(lvh, DB_LOG_VERIFY_PARTIAL))
286 ret = 0;
287 return (ret);
288 }
289
290 static int
__lv_on_ham_log(lvh,lsn,fileid)291 __lv_on_ham_log(lvh, lsn, fileid)
292 DB_LOG_VRFY_INFO *lvh;
293 DB_LSN lsn;
294 int32_t fileid;
295 {
296 int ret;
297 DBTYPE dbtype;
298 if ((ret = __lv_dbregid_to_dbtype(lvh, fileid, &dbtype)) == 0 &&
299 dbtype != DB_HASH)
300 ret = __lv_log_mismatch(lvh, lsn, dbtype, DB_HASH);
301 if (ret == DB_NOTFOUND && F_ISSET(lvh, DB_LOG_VERIFY_PARTIAL))
302 ret = 0;
303 return (ret);
304 }
305
306 static int
__lv_on_heap_log(lvh,lsn,fileid)307 __lv_on_heap_log(lvh, lsn, fileid)
308 DB_LOG_VRFY_INFO *lvh;
309 DB_LSN lsn;
310 int32_t fileid;
311 {
312 int ret;
313 DBTYPE dbtype;
314 if ((ret = __lv_dbregid_to_dbtype(lvh, fileid, &dbtype)) == 0 &&
315 dbtype != DB_HEAP)
316 ret = __lv_log_mismatch(lvh, lsn, dbtype, DB_HEAP);
317 if (ret == DB_NOTFOUND && F_ISSET(lvh, DB_LOG_VERIFY_PARTIAL))
318 ret = 0;
319 return (ret);
320 }
321
322 static int
__lv_on_qam_log(lvh,lsn,fileid)323 __lv_on_qam_log(lvh, lsn, fileid)
324 DB_LOG_VRFY_INFO *lvh;
325 DB_LSN lsn;
326 int32_t fileid;
327 {
328 int ret;
329 DBTYPE dbtype;
330 if ((ret = __lv_dbregid_to_dbtype(lvh, fileid, &dbtype)) == 0 &&
331 dbtype != DB_QUEUE)
332 ret = __lv_log_mismatch(lvh, lsn, dbtype, DB_QUEUE);
333 if (ret == DB_NOTFOUND && F_ISSET(lvh, DB_LOG_VERIFY_PARTIAL))
334 ret = 0;
335 return (ret);
336 }
337
338 /* Catch commits and store into lvinfo->txnrngs database. */
339 static int
__lv_log_fwdscr_oncmt(lvinfo,lsn,txnid,ptxnid,timestamp)340 __lv_log_fwdscr_oncmt(lvinfo, lsn, txnid, ptxnid, timestamp)
341 DB_LOG_VRFY_INFO *lvinfo;
342 DB_LSN lsn;
343 u_int32_t txnid, ptxnid;
344 int32_t timestamp;
345 {
346 int ret;
347 struct __lv_txnrange tr;
348 DBT key, data;
349
350 memset(&tr, 0, sizeof(tr));
351 memset(&key, 0, sizeof(DBT));
352 memset(&data, 0, sizeof(DBT));
353 tr.txnid = txnid;
354 tr.end = lsn;
355 tr.when_commit = timestamp;
356 tr.ptxnid = ptxnid;
357 key.data = &(txnid);
358 key.size = sizeof(txnid);
359 data.data = &tr;
360 data.size = sizeof(tr);
361 if ((ret = __db_put(lvinfo->txnrngs, lvinfo->ip, NULL,
362 &key, &data, 0)) != 0)
363 goto err;
364 err:
365 return (ret);
366 }
367
368 /* Catch aborts and txn beginnings and store into lvinfo->txnrngs database. */
369 static int
__lv_log_fwdscr_onrec(lvinfo,txnid,lrtype,prevlsn,lsn)370 __lv_log_fwdscr_onrec(lvinfo, txnid, lrtype, prevlsn, lsn)
371 DB_LOG_VRFY_INFO *lvinfo;
372 u_int32_t txnid, lrtype;
373 DB_LSN prevlsn, lsn;
374 {
375 int doput, ret, ret2, tret;
376 u_int32_t putflag;
377 struct __lv_txnrange tr, *ptr;
378 DBC *csr;
379 DBT key, key2, data, data2;
380
381 /* Ignore non-txnal log records. */
382 if (txnid < TXN_MINIMUM)
383 return (0);
384
385 /* Not used for now, but may be used later. Pass lint checks. */
386 COMPQUIET(lrtype ,0);
387 putflag = 0;
388 doput = ret = ret2 = 0;
389 csr = NULL;
390 memset(&tr, 0, sizeof(tr));
391 memset(&key, 0, sizeof(DBT));
392 memset(&data, 0, sizeof(DBT));
393 memset(&key2, 0, sizeof(DBT));
394 memset(&data2, 0, sizeof(DBT));
395 key.data = &txnid;
396 key.size = sizeof(txnid);
397 tr.txnid = txnid;
398 tr.when_commit = 0;/* This is not a __txn_regop record. */
399
400 if ((ret = __db_cursor(lvinfo->txnrngs, lvinfo->ip,
401 NULL, &csr, 0)) != 0)
402 goto err;
403 /*
404 * If the txnid is first seen here or reused later, it's aborted
405 * after this log record; if this log record is the 1st one of a txn,
406 * we have the beginning of the txn; otherwise the log record is one
407 * of the actions taken within the txn, and we don't do anything.
408 */
409 if ((ret = __dbc_get(csr, &key, &data, DB_SET)) != 0 &&
410 ret != DB_NOTFOUND)
411 goto err;
412
413 ptr = (struct __lv_txnrange *)data.data;
414 if (ret == DB_NOTFOUND || !IS_ZERO_LSN(ptr->begin)) {
415 tr.end = lsn;
416 data.data = &tr;
417 data.size = sizeof(tr);
418 doput = 1;
419 key2.data = &lsn;
420 key2.size = sizeof(lsn);
421 data2.data = &(tr.txnid);
422 data2.size = sizeof(tr.txnid);
423 putflag = DB_KEYFIRST;
424 if ((ret2 = __db_put(lvinfo->txnaborts, lvinfo->ip, NULL,
425 &key2, &data2, 0)) != 0) {
426 ret = ret2;
427 goto err;
428 }
429 } else if (ret == 0 && IS_ZERO_LSN(prevlsn)) {/* The beginning of txn.*/
430 /* The begin field must be [0, 0]. */
431 DB_ASSERT(lvinfo->dbenv->env, IS_ZERO_LSN(ptr->begin));
432 ptr->begin = lsn;
433 putflag = DB_CURRENT;
434 doput = 1;
435 }
436
437 if (doput && (ret = __dbc_put(csr, &key, &data, putflag)) != 0)
438 goto err;
439 err:
440 if (csr != NULL && (tret = __dbc_close(csr)) != 0 && ret == 0)
441 ret = tret;
442
443 return (ret);
444 }
445
446 /*
447 * Return 0 from dovrfy if verifying logs for a specified db file, and fileid
448 * is not the one we want; Otherwise return 1 from dovrfy. If DB operations
449 * failed, the error is returned.
450 */
451 static int
__lv_vrfy_for_dbfile(lvh,fileid,dovrfy)452 __lv_vrfy_for_dbfile(lvh, fileid, dovrfy)
453 DB_LOG_VRFY_INFO *lvh;
454 int32_t fileid;
455 int *dovrfy;
456 {
457 u_int8_t tmpuid[DB_FILE_ID_LEN];
458 VRFY_FILEREG_INFO *fregp;
459 u_int32_t i;
460 int ret, tret;
461 DBT tgtkey;
462
463 ret = tret = 0;
464 *dovrfy = 0;
465 fregp = NULL;
466 memset(tmpuid, 0, sizeof(u_int8_t) * DB_FILE_ID_LEN);
467 memset(&tgtkey, 0, sizeof(tgtkey));
468 tgtkey.data = lvh->target_dbid;
469 tgtkey.size = DB_FILE_ID_LEN;
470 ret = __get_filereg_info(lvh, &tgtkey, &fregp);
471
472 /*
473 * If the target db file is not seen yet, we don't verify any file,
474 * and it does not mean anything wrong.
475 */
476 if (ret == DB_NOTFOUND) {
477 ret = 0;
478 goto out;
479 }
480 if (ret != 0)
481 goto err;
482
483 for (i = 0; i < fregp->regcnt; i++)
484 if (fregp->dbregids[i] == fileid) {
485 *dovrfy = 1;
486 goto out;
487 }
488 out:
489 err:
490 if (fregp != NULL &&
491 (tret = __free_filereg_info(fregp)) != 0 && ret == 0)
492 ret = tret;
493
494 return (ret);
495 }
496
497 static int
__lv_log_mismatch(lvh,lsn,dbtype,exp_dbtype)498 __lv_log_mismatch(lvh, lsn, dbtype, exp_dbtype)
499 DB_LOG_VRFY_INFO *lvh;
500 DB_LSN lsn;
501 DBTYPE dbtype, exp_dbtype;
502 {
503 int ret;
504
505 __db_errx(lvh->dbenv->env, DB_STR_A("2540",
506 "[%lu][%lu] Log record type does not match related database type, "
507 "current database type: %s, expected database type according to "
508 "the log record type: %s.", "%lu %lu %s %s"),
509 (u_long)lsn.file, (u_long)lsn.offset, __lv_dbtype_str(dbtype),
510 __lv_dbtype_str(exp_dbtype));
511 ret = DB_LOG_VERIFY_BAD;
512 ON_ERROR(lvh, DB_LOG_VERIFY_ERR);
513 err:
514 return (ret);
515 }
516
517 static int
__lv_dbregid_to_dbtype(lvh,id,ptype)518 __lv_dbregid_to_dbtype(lvh, id, ptype)
519 DB_LOG_VRFY_INFO *lvh;
520 int32_t id;
521 DBTYPE *ptype;
522 {
523 int ret;
524 VRFY_FILELIFE *pflife;
525
526 ret = 0;
527 pflife = NULL;
528
529 if ((ret = __get_filelife(lvh, id, &pflife)) != 0)
530 goto err;
531 *ptype = pflife->dbtype;
532 err:
533 if (pflife != NULL)
534 __os_free(lvh->dbenv->env, pflife);
535
536 return (ret);
537 }
538
539 /*
540 * __db_log_verify_global_report --
541 * Report statistics data in DB_LOG_VRFY_INFO handle.
542 *
543 * PUBLIC: void __db_log_verify_global_report __P((const DB_LOG_VRFY_INFO *));
544 */
__db_log_verify_global_report(lvinfo)545 void __db_log_verify_global_report (lvinfo)
546 const DB_LOG_VRFY_INFO *lvinfo;
547 {
548 u_int32_t i, nltype;
549
550 __db_msg(lvinfo->dbenv->env,
551 "Number of active transactions: %u;", lvinfo->ntxn_active);
552 __db_msg(lvinfo->dbenv->env,
553 "Number of committed transactions: %u;", lvinfo->ntxn_commit);
554 __db_msg(lvinfo->dbenv->env,
555 "Number of aborted transactions: %u;", lvinfo->ntxn_abort);
556 __db_msg(lvinfo->dbenv->env,
557 "Number of prepared transactions: %u;", lvinfo->ntxn_prep);
558 __db_msg(lvinfo->dbenv->env,
559 "Total number of checkpoint: %u;", lvinfo->nckp);
560 __db_msg(lvinfo->dbenv->env,
561 "Total number of non-transactional updates: %u;",
562 lvinfo->non_txnup_cnt);
563 __db_msg(lvinfo->dbenv->env,
564 "Total number of unknown log records: %u;",
565 lvinfo->unknown_logrec_cnt);
566 __db_msg(lvinfo->dbenv->env,
567 "Total number of app-specific log record: %u;",
568 lvinfo->external_logrec_cnt);
569 __db_msg(lvinfo->dbenv->env,
570 "The number of each type of log record:");
571
572 for (i = 0; i < 256; i++) {
573 nltype = lvinfo->lrtypes[i];
574 if (LOGTYPE_NAME(lvinfo, i) != NULL)
575 __db_msg(lvinfo->dbenv->env, "\n\t%s : %u;",
576 LOGTYPE_NAME(lvinfo, i), nltype);
577 }
578 }
579
580 /*
581 * PUBLIC: int __crdel_metasub_verify __P((ENV *, DBT *, DB_LSN *,
582 * PUBLIC: db_recops, void *));
583 */
584 int
__crdel_metasub_verify(env,dbtp,lsnp,notused2,lvhp)585 __crdel_metasub_verify(env, dbtp, lsnp, notused2, lvhp)
586 ENV *env;
587 DBT *dbtp;
588 DB_LSN *lsnp;
589 db_recops notused2;
590 void *lvhp;
591 {
592 __crdel_metasub_args *argp;
593 DB_LOG_VRFY_INFO *lvh;
594 int ret;
595
596 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
597 lvh = (DB_LOG_VRFY_INFO *)lvhp;
598
599 if ((ret =
600 __crdel_metasub_read(env, NULL, NULL, dbtp->data, &argp)) != 0)
601 return (ret);
602
603 LOG_VRFY_PROC(lvh, *lsnp, argp, argp->fileid);
604 ON_PAGE_UPDATE(lvh, *lsnp, argp, argp->pgno);
605
606 out:
607
608 err:
609
610 __os_free(env, argp);
611
612 return (ret);
613 }
614
615 /*
616 * PUBLIC: int __crdel_inmem_create_verify __P((ENV *, DBT *,
617 * PUBLIC: DB_LSN *, db_recops, void *));
618 */
619 int
__crdel_inmem_create_verify(env,dbtp,lsnp,notused2,lvhp)620 __crdel_inmem_create_verify(env, dbtp, lsnp, notused2, lvhp)
621 ENV *env;
622 DBT *dbtp;
623 DB_LSN *lsnp;
624 db_recops notused2;
625 void *lvhp;
626 {
627 __crdel_inmem_create_args *argp;
628 DB_LOG_VRFY_INFO *lvh;
629 int ret;
630
631 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
632 lvh = (DB_LOG_VRFY_INFO *)lvhp;
633
634 if ((ret = __crdel_inmem_create_read(env, dbtp->data, &argp)) != 0)
635 return (ret);
636
637 LOG_VRFY_PROC(lvh, *lsnp, argp, argp->fileid);
638
639 out:
640
641 err:
642
643 __os_free(env, argp);
644
645 return (ret);
646 }
647
648 /*
649 * PUBLIC: int __crdel_inmem_rename_verify __P((ENV *, DBT *,
650 * PUBLIC: DB_LSN *, db_recops, void *));
651 */
652 int
__crdel_inmem_rename_verify(env,dbtp,lsnp,notused2,lvhp)653 __crdel_inmem_rename_verify(env, dbtp, lsnp, notused2, lvhp)
654 ENV *env;
655 DBT *dbtp;
656 DB_LSN *lsnp;
657 db_recops notused2;
658 void *lvhp;
659 {
660 __crdel_inmem_rename_args *argp;
661 DB_LOG_VRFY_INFO *lvh;
662 int ret;
663
664 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
665 lvh = (DB_LOG_VRFY_INFO *)lvhp;
666
667 if ((ret = __crdel_inmem_rename_read(env, dbtp->data, &argp)) != 0)
668 return (ret);
669
670 LOG_VRFY_PROC(lvh, *lsnp, argp, INVAL_DBREGID);
671
672 out:
673
674 err:
675
676 __os_free(env, argp);
677
678 return (ret);
679 }
680
681 /*
682 * PUBLIC: int __crdel_inmem_remove_verify __P((ENV *, DBT *,
683 * PUBLIC: DB_LSN *, db_recops, void *));
684 */
685 int
__crdel_inmem_remove_verify(env,dbtp,lsnp,notused2,lvhp)686 __crdel_inmem_remove_verify(env, dbtp, lsnp, notused2, lvhp)
687 ENV *env;
688 DBT *dbtp;
689 DB_LSN *lsnp;
690 db_recops notused2;
691 void *lvhp;
692 {
693 __crdel_inmem_remove_args *argp;
694 DB_LOG_VRFY_INFO *lvh;
695 int ret;
696
697 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
698 lvh = (DB_LOG_VRFY_INFO *)lvhp;
699
700 if ((ret = __crdel_inmem_remove_read(env, dbtp->data, &argp)) != 0)
701 return (ret);
702
703 LOG_VRFY_PROC(lvh, *lsnp, argp, INVAL_DBREGID);
704
705 out:
706
707 err:
708
709 __os_free(env, argp);
710
711 return (ret);
712 }
713
714 /*
715 * PUBLIC: int __db_addrem_verify __P((ENV *, DBT *, DB_LSN *,
716 * PUBLIC: db_recops, void *));
717 */
718 int
__db_addrem_verify(env,dbtp,lsnp,notused2,lvhp)719 __db_addrem_verify(env, dbtp, lsnp, notused2, lvhp)
720 ENV *env;
721 DBT *dbtp;
722 DB_LSN *lsnp;
723 db_recops notused2;
724 void *lvhp;
725 {
726 __db_addrem_args *argp;
727 DB_LOG_VRFY_INFO *lvh;
728 int ret;
729
730 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
731 lvh = (DB_LOG_VRFY_INFO *)lvhp;
732
733 if ((ret =
734 __db_addrem_read(env, NULL, NULL, dbtp->data, &argp)) != 0)
735 return (ret);
736
737 LOG_VRFY_PROC(lvh, *lsnp, argp, argp->fileid);
738 ON_PAGE_UPDATE(lvh, *lsnp, argp, argp->pgno);
739
740 out:
741
742 err:
743
744 __os_free(env, argp);
745
746 return (ret);
747 }
748
749 /*
750 * PUBLIC: int __db_big_verify __P((ENV *, DBT *, DB_LSN *,
751 * PUBLIC: db_recops, void *));
752 */
753 int
__db_big_verify(env,dbtp,lsnp,notused2,lvhp)754 __db_big_verify(env, dbtp, lsnp, notused2, lvhp)
755 ENV *env;
756 DBT *dbtp;
757 DB_LSN *lsnp;
758 db_recops notused2;
759 void *lvhp;
760 {
761 __db_big_args *argp;
762 DB_LOG_VRFY_INFO *lvh;
763 int ret;
764
765 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
766 lvh = (DB_LOG_VRFY_INFO *)lvhp;
767
768 if ((ret =
769 __db_big_read(env, NULL, NULL, dbtp->data, &argp)) != 0)
770 return (ret);
771
772 LOG_VRFY_PROC(lvh, *lsnp, argp, argp->fileid);
773 ON_PAGE_UPDATE(lvh, *lsnp, argp, argp->pgno);
774
775 out:
776
777 err:
778
779 __os_free(env, argp);
780
781 return (ret);
782 }
783
784 /*
785 * PUBLIC: int __db_ovref_verify __P((ENV *, DBT *, DB_LSN *,
786 * PUBLIC: db_recops, void *));
787 */
788 int
__db_ovref_verify(env,dbtp,lsnp,notused2,lvhp)789 __db_ovref_verify(env, dbtp, lsnp, notused2, lvhp)
790 ENV *env;
791 DBT *dbtp;
792 DB_LSN *lsnp;
793 db_recops notused2;
794 void *lvhp;
795 {
796 __db_ovref_args *argp;
797 DB_LOG_VRFY_INFO *lvh;
798 int ret;
799
800 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
801 lvh = (DB_LOG_VRFY_INFO *)lvhp;
802
803 if ((ret =
804 __db_ovref_read(env, NULL, NULL, dbtp->data, &argp)) != 0)
805 return (ret);
806
807 LOG_VRFY_PROC(lvh, *lsnp, argp, argp->fileid);
808 ON_PAGE_UPDATE(lvh, *lsnp, argp, argp->pgno);
809
810 out:
811
812 err:
813
814 __os_free(env, argp);
815
816 return (ret);
817 }
818
819 /*
820 * PUBLIC: int __db_relink_42_verify __P((ENV *, DBT *, DB_LSN *,
821 * PUBLIC: db_recops, void *));
822 */
823 int
__db_relink_42_verify(env,dbtp,lsnp,notused2,lvhp)824 __db_relink_42_verify(env, dbtp, lsnp, notused2, lvhp)
825 ENV *env;
826 DBT *dbtp;
827 DB_LSN *lsnp;
828 db_recops notused2;
829 void *lvhp;
830 {
831 __db_relink_42_args *argp;
832 DB_LOG_VRFY_INFO *lvh;
833 int ret;
834
835 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
836 lvh = (DB_LOG_VRFY_INFO *)lvhp;
837
838 if ((ret =
839 __db_relink_42_read(env, NULL, NULL, dbtp->data, &argp)) != 0)
840 return (ret);
841
842 ON_NOT_SUPPORTED(env, lvh, *lsnp, argp->type);
843 /* LOG_VRFY_PROC(lvh, *lsnp, argp, argp->fileid); */
844 err:
845
846 __os_free(env, argp);
847
848 return (ret);
849 }
850
851 /*
852 * PUBLIC: int __db_debug_verify __P((ENV *, DBT *, DB_LSN *,
853 * PUBLIC: db_recops, void *));
854 */
855 int
__db_debug_verify(env,dbtp,lsnp,notused2,lvhp)856 __db_debug_verify(env, dbtp, lsnp, notused2, lvhp)
857 ENV *env;
858 DBT *dbtp;
859 DB_LSN *lsnp;
860 db_recops notused2;
861 void *lvhp;
862 {
863 __db_debug_args *argp;
864 DB_LOG_VRFY_INFO *lvh;
865 int ret;
866
867 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
868 lvh = (DB_LOG_VRFY_INFO *)lvhp;
869
870 if ((ret = __db_debug_read(env, dbtp->data, &argp)) != 0)
871 return (ret);
872
873 LOG_VRFY_PROC(lvh, *lsnp, argp, argp->fileid);
874
875 out:
876
877 err:
878
879 __os_free(env, argp);
880
881 return (ret);
882 }
883
884 /*
885 * PUBLIC: int __db_noop_verify __P((ENV *, DBT *, DB_LSN *,
886 * PUBLIC: db_recops, void *));
887 */
888 int
__db_noop_verify(env,dbtp,lsnp,notused2,lvhp)889 __db_noop_verify(env, dbtp, lsnp, notused2, lvhp)
890 ENV *env;
891 DBT *dbtp;
892 DB_LSN *lsnp;
893 db_recops notused2;
894 void *lvhp;
895 {
896 __db_noop_args *argp;
897 DB_LOG_VRFY_INFO *lvh;
898 int ret;
899
900 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
901 lvh = (DB_LOG_VRFY_INFO *)lvhp;
902
903 if ((ret =
904 __db_noop_read(env, NULL, NULL, dbtp->data, &argp)) != 0)
905 return (ret);
906
907 LOG_VRFY_PROC(lvh, *lsnp, argp, argp->fileid);
908
909 out:
910
911 err:
912
913 __os_free(env, argp);
914
915 return (ret);
916 }
917
918 /*
919 * PUBLIC: int __db_pg_alloc_42_verify __P((ENV *, DBT *, DB_LSN *,
920 * PUBLIC: db_recops, void *));
921 */
922 int
__db_pg_alloc_42_verify(env,dbtp,lsnp,notused2,lvhp)923 __db_pg_alloc_42_verify(env, dbtp, lsnp, notused2, lvhp)
924 ENV *env;
925 DBT *dbtp;
926 DB_LSN *lsnp;
927 db_recops notused2;
928 void *lvhp;
929 {
930 __db_pg_alloc_42_args *argp;
931 DB_LOG_VRFY_INFO *lvh;
932 int ret;
933
934 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
935 lvh = (DB_LOG_VRFY_INFO *)lvhp;
936
937 if ((ret =
938 __db_pg_alloc_42_read(env, NULL, NULL, dbtp->data, &argp)) != 0)
939 return (ret);
940
941 ON_NOT_SUPPORTED(env, lvh, *lsnp, argp->type);
942 /* LOG_VRFY_PROC(lvh, *lsnp, argp, argp->fileid); */
943 err:
944
945 __os_free(env, argp);
946
947 return (ret);
948 }
949
950 /*
951 * PUBLIC: int __db_pg_alloc_verify __P((ENV *, DBT *, DB_LSN *,
952 * PUBLIC: db_recops, void *));
953 */
954 int
__db_pg_alloc_verify(env,dbtp,lsnp,notused2,lvhp)955 __db_pg_alloc_verify(env, dbtp, lsnp, notused2, lvhp)
956 ENV *env;
957 DBT *dbtp;
958 DB_LSN *lsnp;
959 db_recops notused2;
960 void *lvhp;
961 {
962 __db_pg_alloc_args *argp;
963 DB_LOG_VRFY_INFO *lvh;
964 int ret;
965
966 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
967 lvh = (DB_LOG_VRFY_INFO *)lvhp;
968
969 if ((ret =
970 __db_pg_alloc_read(env, NULL, NULL, dbtp->data, &argp)) != 0)
971 return (ret);
972
973 LOG_VRFY_PROC(lvh, *lsnp, argp, argp->fileid);
974 ON_PAGE_UPDATE(lvh, *lsnp, argp, argp->pgno);
975
976 out:
977
978 err:
979
980 __os_free(env, argp);
981
982 return (ret);
983 }
984
985 /*
986 * PUBLIC: int __db_pg_free_42_verify __P((ENV *, DBT *, DB_LSN *,
987 * PUBLIC: db_recops, void *));
988 */
989 int
__db_pg_free_42_verify(env,dbtp,lsnp,notused2,lvhp)990 __db_pg_free_42_verify(env, dbtp, lsnp, notused2, lvhp)
991 ENV *env;
992 DBT *dbtp;
993 DB_LSN *lsnp;
994 db_recops notused2;
995 void *lvhp;
996 {
997 __db_pg_free_42_args *argp;
998 DB_LOG_VRFY_INFO *lvh;
999 int ret;
1000
1001 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
1002 lvh = (DB_LOG_VRFY_INFO *)lvhp;
1003
1004 if ((ret =
1005 __db_pg_free_42_read(env, NULL, NULL, dbtp->data, &argp)) != 0)
1006 return (ret);
1007
1008 ON_NOT_SUPPORTED(env, lvh, *lsnp, argp->type);
1009 /* LOG_VRFY_PROC(lvh, *lsnp, argp, argp->fileid); */
1010 err:
1011
1012 __os_free(env, argp);
1013
1014 return (ret);
1015 }
1016
1017 /*
1018 * PUBLIC: int __db_pg_free_verify __P((ENV *, DBT *, DB_LSN *,
1019 * PUBLIC: db_recops, void *));
1020 */
1021 int
__db_pg_free_verify(env,dbtp,lsnp,notused2,lvhp)1022 __db_pg_free_verify(env, dbtp, lsnp, notused2, lvhp)
1023 ENV *env;
1024 DBT *dbtp;
1025 DB_LSN *lsnp;
1026 db_recops notused2;
1027 void *lvhp;
1028 {
1029 __db_pg_free_args *argp;
1030 DB_LOG_VRFY_INFO *lvh;
1031 int ret;
1032
1033 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
1034 lvh = (DB_LOG_VRFY_INFO *)lvhp;
1035
1036 if ((ret =
1037 __db_pg_free_read(env, NULL, NULL, dbtp->data, &argp)) != 0)
1038 return (ret);
1039
1040 LOG_VRFY_PROC(lvh, *lsnp, argp, argp->fileid);
1041 ON_PAGE_UPDATE(lvh, *lsnp, argp, argp->pgno);
1042
1043 out:
1044
1045 err:
1046
1047 __os_free(env, argp);
1048
1049 return (ret);
1050 }
1051
1052 /*
1053 * PUBLIC: int __db_cksum_verify __P((ENV *, DBT *, DB_LSN *,
1054 * PUBLIC: db_recops, void *));
1055 */
1056 int
__db_cksum_verify(env,dbtp,lsnp,notused2,lvhp)1057 __db_cksum_verify(env, dbtp, lsnp, notused2, lvhp)
1058 ENV *env;
1059 DBT *dbtp;
1060 DB_LSN *lsnp;
1061 db_recops notused2;
1062 void *lvhp;
1063 {
1064 __db_cksum_args *argp;
1065 DB_LOG_VRFY_INFO *lvh;
1066 int ret;
1067
1068 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
1069 lvh = (DB_LOG_VRFY_INFO *)lvhp;
1070
1071 if ((ret = __db_cksum_read(env, dbtp->data, &argp)) != 0)
1072 return (ret);
1073
1074 LOG_VRFY_PROC(lvh, *lsnp, argp, INVAL_DBREGID);
1075
1076 out:
1077
1078 err:
1079
1080 __os_free(env, argp);
1081
1082 return (ret);
1083 }
1084
1085 /*
1086 * PUBLIC: int __db_pg_freedata_42_verify __P((ENV *, DBT *,
1087 * PUBLIC: DB_LSN *, db_recops, void *));
1088 */
1089 int
__db_pg_freedata_42_verify(env,dbtp,lsnp,notused2,lvhp)1090 __db_pg_freedata_42_verify(env, dbtp, lsnp, notused2, lvhp)
1091 ENV *env;
1092 DBT *dbtp;
1093 DB_LSN *lsnp;
1094 db_recops notused2;
1095 void *lvhp;
1096 {
1097 __db_pg_freedata_42_args *argp;
1098 DB_LOG_VRFY_INFO *lvh;
1099 int ret;
1100
1101 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
1102 lvh = (DB_LOG_VRFY_INFO *)lvhp;
1103
1104 if ((ret =
1105 __db_pg_freedata_42_read(env, NULL, NULL, dbtp->data, &argp)) != 0)
1106 return (ret);
1107
1108 ON_NOT_SUPPORTED(env, lvh, *lsnp, argp->type);
1109 /* LOG_VRFY_PROC(lvh, *lsnp, argp, argp->fileid); */
1110 err:
1111
1112 __os_free(env, argp);
1113
1114 return (ret);
1115 }
1116
1117 /*
1118 * PUBLIC: int __db_pg_freedata_verify __P((ENV *, DBT *, DB_LSN *,
1119 * PUBLIC: db_recops, void *));
1120 */
1121 int
__db_pg_freedata_verify(env,dbtp,lsnp,notused2,lvhp)1122 __db_pg_freedata_verify(env, dbtp, lsnp, notused2, lvhp)
1123 ENV *env;
1124 DBT *dbtp;
1125 DB_LSN *lsnp;
1126 db_recops notused2;
1127 void *lvhp;
1128 {
1129 __db_pg_freedata_args *argp;
1130 DB_LOG_VRFY_INFO *lvh;
1131 int ret;
1132
1133 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
1134 lvh = (DB_LOG_VRFY_INFO *)lvhp;
1135
1136 if ((ret =
1137 __db_pg_freedata_read(env, NULL, NULL, dbtp->data, &argp)) != 0)
1138 return (ret);
1139
1140 LOG_VRFY_PROC(lvh, *lsnp, argp, argp->fileid);
1141 ON_PAGE_UPDATE(lvh, *lsnp, argp, argp->pgno);
1142
1143 out:
1144
1145 err:
1146
1147 __os_free(env, argp);
1148
1149 return (ret);
1150 }
1151
1152 /*
1153 * PUBLIC: int __db_pg_init_verify __P((ENV *, DBT *, DB_LSN *,
1154 * PUBLIC: db_recops, void *));
1155 */
1156 int
__db_pg_init_verify(env,dbtp,lsnp,notused2,lvhp)1157 __db_pg_init_verify(env, dbtp, lsnp, notused2, lvhp)
1158 ENV *env;
1159 DBT *dbtp;
1160 DB_LSN *lsnp;
1161 db_recops notused2;
1162 void *lvhp;
1163 {
1164 __db_pg_init_args *argp;
1165 DB_LOG_VRFY_INFO *lvh;
1166 int ret;
1167
1168 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
1169 lvh = (DB_LOG_VRFY_INFO *)lvhp;
1170
1171 if ((ret =
1172 __db_pg_init_read(env, NULL, NULL, dbtp->data, &argp)) != 0)
1173 return (ret);
1174
1175 LOG_VRFY_PROC(lvh, *lsnp, argp, argp->fileid);
1176 ON_PAGE_UPDATE(lvh, *lsnp, argp, argp->pgno);
1177
1178 out:
1179
1180 err:
1181
1182 __os_free(env, argp);
1183
1184 return (ret);
1185 }
1186
1187 /*
1188 * PUBLIC: int __db_pg_sort_44_verify __P((ENV *, DBT *, DB_LSN *,
1189 * PUBLIC: db_recops, void *));
1190 */
1191 int
__db_pg_sort_44_verify(env,dbtp,lsnp,notused2,lvhp)1192 __db_pg_sort_44_verify(env, dbtp, lsnp, notused2, lvhp)
1193 ENV *env;
1194 DBT *dbtp;
1195 DB_LSN *lsnp;
1196 db_recops notused2;
1197 void *lvhp;
1198 {
1199 __db_pg_sort_44_args *argp;
1200 DB_LOG_VRFY_INFO *lvh;
1201 int ret;
1202
1203 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
1204 lvh = (DB_LOG_VRFY_INFO *)lvhp;
1205
1206 if ((ret =
1207 __db_pg_sort_44_read(env, NULL, NULL, dbtp->data, &argp)) != 0)
1208 return (ret);
1209
1210 ON_NOT_SUPPORTED(env, lvh, *lsnp, argp->type);
1211 /* LOG_VRFY_PROC(lvh, *lsnp, argp, argp->fileid); */
1212 err:
1213
1214 __os_free(env, argp);
1215
1216 return (ret);
1217 }
1218
1219 /*
1220 * PUBLIC: int __db_pg_trunc_verify __P((ENV *, DBT *, DB_LSN *,
1221 * PUBLIC: db_recops, void *));
1222 */
1223 int
__db_pg_trunc_verify(env,dbtp,lsnp,notused2,lvhp)1224 __db_pg_trunc_verify(env, dbtp, lsnp, notused2, lvhp)
1225 ENV *env;
1226 DBT *dbtp;
1227 DB_LSN *lsnp;
1228 db_recops notused2;
1229 void *lvhp;
1230 {
1231 __db_pg_trunc_args *argp;
1232 DB_LOG_VRFY_INFO *lvh;
1233 int ret;
1234
1235 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
1236 lvh = (DB_LOG_VRFY_INFO *)lvhp;
1237
1238 if ((ret =
1239 __db_pg_trunc_read(env, NULL, NULL, dbtp->data, &argp)) != 0)
1240 return (ret);
1241
1242 LOG_VRFY_PROC(lvh, *lsnp, argp, argp->fileid);
1243 ON_PAGE_UPDATE4 /* No pages are locked by txns. */
1244 out:
1245 err:
1246 __os_free(env, argp);
1247
1248 return (ret);
1249 }
1250
1251 /*
1252 * PUBLIC: int __db_realloc_verify __P((ENV *, DBT *, DB_LSN *,
1253 * PUBLIC: db_recops, void *));
1254 */
1255 int
__db_realloc_verify(env,dbtp,lsnp,notused2,lvhp)1256 __db_realloc_verify(env, dbtp, lsnp, notused2, lvhp)
1257 ENV *env;
1258 DBT *dbtp;
1259 DB_LSN *lsnp;
1260 db_recops notused2;
1261 void *lvhp;
1262 {
1263 __db_realloc_args *argp;
1264 DB_LOG_VRFY_INFO *lvh;
1265 int ret;
1266
1267 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
1268 lvh = (DB_LOG_VRFY_INFO *)lvhp;
1269
1270 if ((ret =
1271 __db_realloc_read(env, NULL, NULL, dbtp->data, &argp)) != 0)
1272 return (ret);
1273
1274 LOG_VRFY_PROC(lvh, *lsnp, argp, argp->fileid);
1275 ON_PAGE_UPDATE4 /* No pages are locked by txns. */
1276
1277 out:
1278
1279 err:
1280
1281 __os_free(env, argp);
1282
1283 return (ret);
1284 }
1285
1286 /*
1287 * PUBLIC: int __db_relink_verify __P((ENV *, DBT *, DB_LSN *,
1288 * PUBLIC: db_recops, void *));
1289 */
1290 int
__db_relink_verify(env,dbtp,lsnp,notused2,lvhp)1291 __db_relink_verify(env, dbtp, lsnp, notused2, lvhp)
1292 ENV *env;
1293 DBT *dbtp;
1294 DB_LSN *lsnp;
1295 db_recops notused2;
1296 void *lvhp;
1297 {
1298 __db_relink_args *argp;
1299 DB_LOG_VRFY_INFO *lvh;
1300 int ret;
1301
1302 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
1303 lvh = (DB_LOG_VRFY_INFO *)lvhp;
1304
1305 if ((ret =
1306 __db_relink_read(env, NULL, NULL, dbtp->data, &argp)) != 0)
1307 return (ret);
1308
1309 LOG_VRFY_PROC(lvh, *lsnp, argp, argp->fileid);
1310 ON_PAGE_UPDATE(lvh, *lsnp, argp, argp->pgno);
1311
1312 out:
1313
1314 err:
1315
1316 __os_free(env, argp);
1317
1318 return (ret);
1319 }
1320
1321 /*
1322 * PUBLIC: int __db_merge_verify __P((ENV *, DBT *, DB_LSN *,
1323 * PUBLIC: db_recops, void *));
1324 */
1325 int
__db_merge_verify(env,dbtp,lsnp,notused2,lvhp)1326 __db_merge_verify(env, dbtp, lsnp, notused2, lvhp)
1327 ENV *env;
1328 DBT *dbtp;
1329 DB_LSN *lsnp;
1330 db_recops notused2;
1331 void *lvhp;
1332 {
1333 __db_merge_args *argp;
1334 DB_LOG_VRFY_INFO *lvh;
1335 int ret;
1336
1337 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
1338 lvh = (DB_LOG_VRFY_INFO *)lvhp;
1339
1340 if ((ret =
1341 __db_merge_read(env, NULL, NULL, dbtp->data, &argp)) != 0)
1342 return (ret);
1343
1344 LOG_VRFY_PROC(lvh, *lsnp, argp, argp->fileid);
1345 ON_PAGE_UPDATE(lvh, *lsnp, argp, argp->pgno);
1346
1347 out:
1348
1349 err:
1350
1351 __os_free(env, argp);
1352
1353 return (ret);
1354 }
1355
1356 /*
1357 * PUBLIC: int __db_pgno_verify __P((ENV *, DBT *, DB_LSN *,
1358 * PUBLIC: db_recops, void *));
1359 */
1360 int
__db_pgno_verify(env,dbtp,lsnp,notused2,lvhp)1361 __db_pgno_verify(env, dbtp, lsnp, notused2, lvhp)
1362 ENV *env;
1363 DBT *dbtp;
1364 DB_LSN *lsnp;
1365 db_recops notused2;
1366 void *lvhp;
1367 {
1368 __db_pgno_args *argp;
1369 DB_LOG_VRFY_INFO *lvh;
1370 int ret;
1371
1372 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
1373 lvh = (DB_LOG_VRFY_INFO *)lvhp;
1374
1375 if ((ret =
1376 __db_pgno_read(env, NULL, NULL, dbtp->data, &argp)) != 0)
1377 return (ret);
1378
1379 LOG_VRFY_PROC(lvh, *lsnp, argp, argp->fileid);
1380 ON_PAGE_UPDATE(lvh, *lsnp, argp, argp->pgno);
1381
1382 out:
1383
1384 err:
1385
1386 __os_free(env, argp);
1387 return (ret);
1388 }
1389
1390 static const char *
__lv_dbreg_str(op)1391 __lv_dbreg_str(op)
1392 u_int32_t op;
1393 {
1394 const char *p;
1395
1396 switch (op) {
1397 case DBREG_CHKPNT:
1398 p = "DBREG_CHKPNT";
1399 break;
1400 case DBREG_RCLOSE:
1401 p = "DBREG_RCLOSE";
1402 break;
1403 case DBREG_CLOSE:
1404 p = "DBREG_CLOSE";
1405 break;
1406 case DBREG_OPEN:
1407 p = "DBREG_OPEN";
1408 break;
1409 case DBREG_PREOPEN:
1410 p = "DBREG_PREOPEN";
1411 break;
1412 case DBREG_REOPEN:
1413 p = "DBREG_REOPEN";
1414 break;
1415 case DBREG_XCHKPNT:
1416 p = "DBREG_XCHKPNT";
1417 break;
1418 case DBREG_XOPEN:
1419 p = "DBREG_XOPEN";
1420 break;
1421 case DBREG_XREOPEN:
1422 p = "DBREG_XREOPEN";
1423 break;
1424 default:
1425 p = DB_STR_P("Unknown dbreg op code");
1426 break;
1427 }
1428
1429 return (p);
1430 }
1431
1432 static int
__lv_dbt_str(dbt,str)1433 __lv_dbt_str(dbt, str)
1434 const DBT *dbt;
1435 char **str;
1436 {
1437 char *p, *q;
1438 u_int32_t buflen, bufsz, i;
1439 int ret;
1440
1441 ret = 0;
1442 p = q = NULL;
1443 buflen = bufsz = i = 0;
1444 bufsz = sizeof(char) * dbt->size * 2;
1445
1446 if ((ret = __os_malloc(NULL, bufsz, &p)) != 0)
1447 goto err;
1448 q = (char *)dbt->data;
1449
1450 memset(p, 0, bufsz);
1451 /*
1452 * Each unprintable character takes up several bytes, so be ware of
1453 * memory access violation.
1454 */
1455 for (i = 0; i < dbt->size && buflen < bufsz; i++) {
1456 buflen = (u_int32_t)strlen(p);
1457 snprintf(p + buflen, bufsz - (buflen + 1),
1458 isprint(q[i]) || q[i] == 0x0a ? "%c" : "%x", q[i]);
1459 }
1460 *str = p;
1461 err:
1462 return (ret);
1463 }
1464
1465 static const char *
__lv_dbtype_str(dbtype)1466 __lv_dbtype_str(dbtype)
1467 DBTYPE dbtype;
1468 {
1469 char *p;
1470
1471 switch (dbtype) {
1472 case DB_BTREE:
1473 p = "DB_BTREE";
1474 break;
1475 case DB_HASH:
1476 p = "DB_HASH";
1477 break;
1478 case DB_RECNO:
1479 p = "DB_RECNO";
1480 break;
1481 case DB_QUEUE:
1482 p = "DB_QUEUE";
1483 break;
1484 default:
1485 p = DB_STR_P("Unknown db type");
1486 break;
1487 }
1488
1489 return (p);
1490 }
1491
1492 /*
1493 * PUBLIC: int __dbreg_register_verify __P((ENV *, DBT *, DB_LSN *,
1494 * PUBLIC: db_recops, void *));
1495 */
1496 int
__dbreg_register_verify(env,dbtp,lsnp,notused2,lvhp)1497 __dbreg_register_verify(env, dbtp, lsnp, notused2, lvhp)
1498 ENV *env;
1499 DBT *dbtp;
1500 DB_LSN *lsnp;
1501 db_recops notused2;
1502 void *lvhp;
1503 {
1504 __dbreg_register_args *argp;
1505 DB_LOG_VRFY_INFO *lvh;
1506 VRFY_FILEREG_INFO *fregp, freg;
1507 VRFY_FILELIFE *pflife, flife;
1508 int checklife, rmv_dblife, ret, ret2;
1509 u_int32_t opcode;
1510 char *puid;
1511 const char *dbfname;
1512
1513 dbfname = NULL;
1514 checklife = 1;
1515 opcode = 0;
1516 ret = ret2 = rmv_dblife = 0;
1517 puid = NULL;
1518 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
1519 lvh = (DB_LOG_VRFY_INFO *)lvhp;
1520 fregp = NULL;
1521 pflife = NULL;
1522 memset(&flife, 0, sizeof(flife));
1523 memset(&freg, 0, sizeof(freg));
1524
1525 if ((ret = __dbreg_register_read(env, dbtp->data, &argp)) != 0)
1526 return (ret);
1527
1528 opcode = FLD_ISSET(argp->opcode, DBREG_OP_MASK);
1529 dbfname = argp->name.size == 0 ? "(null)" : (char *)(argp->name.data);
1530 /*
1531 * We don't call LOG_VRFY_PROC macro here, so we have to copy the code
1532 * snippet in __log_vrfy_proc here.
1533 */
1534 if (F_ISSET(lvh, DB_LOG_VERIFY_FORWARD)) {
1535 if ((ret = __lv_log_fwdscr_onrec(lvh, argp->txnp->txnid,
1536 argp->type, argp->prev_lsn, *lsnp)) != 0)
1537 goto err;
1538 goto out;
1539 }
1540 if (lvh->aborted_txnid != 0 && (ret = __lv_on_txn_aborted(lvh)) != 0)
1541 goto err;
1542
1543 if ((ret = __get_filereg_info(lvh, &(argp->uid), &fregp)) != 0 &&
1544 ret != DB_NOTFOUND)
1545 goto err;
1546
1547 /*
1548 * When DBREG_CLOSE, we should remove the fileuid-filename mapping
1549 * from filereg because the file can be opened again with a different
1550 * fileuid after closed.
1551 */
1552 if (ret == 0 && IS_DBREG_CLOSE(opcode)) {
1553 if ((ret = __db_del(lvh->fileregs, lvh->ip, NULL,
1554 &(argp->uid), 0)) != 0)
1555 goto err;
1556 }
1557
1558 /*
1559 * If this db file is seen for the 1st time, store filereg and
1560 * filelife info. Since we will do a end-to-begin scan before the
1561 * verification, we will be able to get the record but it's regcnt
1562 * is 0 since we didn't know any dbregid yet.
1563 */
1564 if (ret == DB_NOTFOUND || fregp->regcnt == 0) {
1565 /* Store filereg info unless it's a CLOSE. */
1566 freg.fileid = argp->uid;
1567 if (!IS_DBREG_CLOSE(opcode)) {
1568 freg.regcnt = 1;
1569 freg.dbregids = &(argp->fileid);
1570 } else {
1571 freg.regcnt = 0;
1572 freg.dbregids = NULL;
1573 }
1574 if (ret == DB_NOTFOUND) {
1575 /*
1576 * If the db file is an in-memory db file, we can arrive
1577 * here because there is no __fop_rename log for it;
1578 * if the __fop_rename log record is out of the log range we
1579 * verify, we will also arrive here.
1580 */
1581 if ((ret = __os_malloc(env, argp->name.size + 1,
1582 &(freg.fname))) != 0)
1583 goto err;
1584 memset(freg.fname, 0,
1585 sizeof(char) * (argp->name.size + 1));
1586 (void)strncpy(freg.fname,
1587 (const char *)(argp->name.data), argp->name.size);
1588 } else /* We already have the name. */
1589 if ((ret = __os_strdup(env,
1590 fregp->fname, &(freg.fname))) != 0)
1591 goto err;
1592
1593 if (!IS_DBREG_OPEN(opcode) &&
1594 !F_ISSET(lvh, DB_LOG_VERIFY_PARTIAL)) {
1595 /* It's likely that the DBREG_OPEN is not seen.*/
1596 __db_msg(env, DB_STR_A("2541",
1597 "[%lu][%lu] Suspicious dbreg operation: %s, the "
1598 "database file %s's register in log region does "
1599 "not begin with an open operation.",
1600 "%lu %lu %s %s"), (u_long)lsnp->file,
1601 (u_long)lsnp->offset,
1602 __lv_dbreg_str(opcode), dbfname);
1603 }
1604
1605 /*
1606 * PREOPEN is only generated when opening an in-memory db.
1607 * Because we need to log the fileid we're allocating, but we
1608 * don't have all the details yet, we are preopening the
1609 * database and will actually complete the open later. So
1610 * PREOPEN is not a real open, and the log should be ignored
1611 * in log_verify.
1612 * If fileuid is in a CLOSE operation there is no need to
1613 * record it.
1614 */
1615 if ((opcode != DBREG_PREOPEN) && !IS_DBREG_CLOSE(opcode) &&
1616 (ret = __put_filereg_info(lvh, &freg)) != 0)
1617 goto err;
1618
1619 /* Store filelife info unless it's a CLOSE dbreg operation. */
1620 if (!IS_DBREG_CLOSE(opcode)) {
1621 flife.lifetime = opcode;
1622 flife.dbregid = argp->fileid;
1623 flife.lsn = *lsnp;
1624 flife.dbtype = argp->ftype;
1625 flife.meta_pgno = argp->meta_pgno;
1626 memcpy(flife.fileid, argp->uid.data, argp->uid.size);
1627 if ((ret = __put_filelife(lvh, &flife)) != 0)
1628 goto err;
1629 }
1630 /* on_txn_logrec relies on the freg info in db first. */
1631 LOG_VRFY_PROC(lvh, *lsnp, argp, argp->fileid);
1632 goto out;
1633 }
1634
1635 /*
1636 * Add dbregid if it's new, and store the file register info; or
1637 * remove dbregid from fregp if we are closing the file.
1638 */
1639 if ((ret = __add_dbregid(lvh, fregp, argp->fileid,
1640 opcode, *lsnp, argp->ftype, argp->meta_pgno, &ret2)) != 0)
1641 goto err;
1642 ret = ret2;
1643 if (ret != 0 && ret != 1 && ret != 2 && ret != -1)
1644 goto err;/* DB operation error. */
1645 if (ret != 0) {
1646 /* Newly seen dbregid does not need to check life. */
1647 if (ret == 1)
1648 checklife = 0;
1649 else if (ret == -1)
1650 rmv_dblife = 1;/* The dbreg file id is closed. */
1651 else if (ret == 2) {
1652 __db_errx(env, DB_STR_A("2542",
1653 "[%lu][%lu] Wrong dbreg operation "
1654 "sequence, opening %s for id %d which is already "
1655 "open.", "%lu %lu %s %d"),
1656 (u_long)lsnp->file, (u_long)lsnp->offset,
1657 dbfname, argp->fileid);
1658 ret = DB_LOG_VERIFY_BAD;
1659 ON_ERROR(lvh, DB_LOG_VERIFY_ERR);
1660 }
1661 if (!rmv_dblife && (ret = __put_filereg_info(lvh, fregp)) != 0)
1662 goto err;
1663 }
1664
1665 LOG_VRFY_PROC(lvh, *lsnp, argp, argp->fileid);
1666
1667 if (!checklife)
1668 goto out;
1669
1670 /*
1671 * Verify the database type does not change, and the lifetime of a
1672 * db file follow an open/chkpnt->[chkpnt]->close order.
1673 * A VRFY_FILELIFE record is removed from db on DBREG_CLOSE,
1674 * and inserted into db on DBREG_OPEN.
1675 */
1676 if (!IS_DBREG_OPEN(opcode) &&
1677 (ret = __get_filelife(lvh, argp->fileid, &pflife)) != 0) {
1678 if (ret == DB_NOTFOUND) {
1679 if (!F_ISSET(lvh, DB_LOG_VERIFY_PARTIAL)) {
1680 __db_errx(env, DB_STR_A("2543",
1681 "[%lu][%lu] Wrong dbreg operation sequence,"
1682 "file %s with id %d is first seen of "
1683 "status: %s", "%lu %lu %s %d %s"),
1684 (u_long)lsnp->file, (u_long)lsnp->offset,
1685 dbfname, argp->fileid,
1686 __lv_dbreg_str(opcode));
1687 ret = DB_LOG_VERIFY_BAD;
1688 ON_ERROR(lvh, DB_LOG_VERIFY_ERR);
1689 } else
1690 ret = 0;
1691 }
1692 goto err;
1693 }
1694
1695 /* Can't go on verifying without pflife. */
1696 if (pflife == NULL)
1697 goto out;
1698 if (argp->ftype != pflife->dbtype) {
1699 if ((ret = __lv_dbt_str(&(argp->uid), &puid)) != 0)
1700 goto err;
1701 __db_errx(env, DB_STR_A("2544",
1702 "[%lu][%lu] The dbtype of database file %s with uid %s "
1703 " and id %d has changed from %s to %s.",
1704 "%lu %lu %s %s %d %s %s"), (u_long)lsnp->file,
1705 (u_long)lsnp->offset, dbfname, puid,
1706 pflife->dbregid, __lv_dbtype_str(pflife->dbtype),
1707 __lv_dbtype_str(argp->ftype));
1708
1709 __os_free(env, puid);
1710 ret = DB_LOG_VERIFY_BAD;
1711 ON_ERROR(lvh, DB_LOG_VERIFY_ERR);
1712 }
1713
1714 if ((IS_DBREG_CLOSE(opcode) &&
1715 (pflife->lifetime != DBREG_CHKPNT ||
1716 pflife->lifetime != DBREG_XCHKPNT) &&
1717 !IS_DBREG_OPEN(pflife->lifetime))) {
1718 __db_errx(env, DB_STR_A("2545",
1719 "[%lu][%lu] Wrong dbreg operation sequence for file %s "
1720 "with id %d, current status: %s, new status: %s",
1721 "%lu %lu %s %d %s %s"), (u_long)lsnp->file,
1722 (u_long)lsnp->offset, dbfname, pflife->dbregid,
1723 __lv_dbreg_str(pflife->lifetime),
1724 __lv_dbreg_str(opcode));
1725 ret = DB_LOG_VERIFY_BAD;
1726 ON_ERROR(lvh, DB_LOG_VERIFY_ERR);
1727 }
1728
1729 pflife->lifetime = opcode;
1730 pflife->lsn = *lsnp;
1731 if ((!rmv_dblife && (ret = __put_filelife(lvh, pflife)) != 0) ||
1732 ((rmv_dblife || IS_DBREG_CLOSE(opcode)) &&
1733 ((ret = __del_filelife(lvh, argp->fileid)) != 0)))
1734 goto err;
1735
1736 out:
1737 /* There may be something to do here in future. */
1738 err:
1739 __os_free(env, argp);
1740 if (fregp != NULL &&
1741 (ret2 = __free_filereg_info(fregp)) != 0 && ret == 0)
1742 ret = ret2;
1743 if (freg.fname != NULL)
1744 __os_free(env, freg.fname);
1745 if (pflife != NULL)
1746 __os_free(env, pflife);
1747
1748 return (ret);
1749 }
1750
1751 /*
1752 * PUBLIC: int __dbreg_register_42_verify __P((ENV *, DBT *, DB_LSN *,
1753 * PUBLIC: db_recops, void *));
1754 */
1755 int
__dbreg_register_42_verify(env,dbtp,lsnp,notused2,lvhp)1756 __dbreg_register_42_verify(env, dbtp, lsnp, notused2, lvhp)
1757 ENV *env;
1758 DBT *dbtp;
1759 DB_LSN *lsnp;
1760 db_recops notused2;
1761 void *lvhp;
1762 {
1763 __dbreg_register_42_args *argp;
1764 DB_LOG_VRFY_INFO *lvh;
1765 int ret;
1766
1767 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
1768 lvh = (DB_LOG_VRFY_INFO *)lvhp;
1769
1770 if ((ret = __dbreg_register_42_read(env, dbtp->data, &argp)) != 0)
1771 goto err;
1772
1773 ON_NOT_SUPPORTED(env, lvh, *lsnp, argp->type);
1774 /* LOG_VRFY_PROC(lvh, *lsnp, argp, argp->fileid); */
1775
1776 err:
1777 __os_free(env, argp);
1778 return (ret);
1779 }
1780
1781 /*
1782 * PUBLIC: int __bam_split_verify __P((ENV *, DBT *, DB_LSN *,
1783 * PUBLIC: db_recops, void *));
1784 */
1785 int
__bam_split_verify(env,dbtp,lsnp,notused2,lvhp)1786 __bam_split_verify(env, dbtp, lsnp, notused2, lvhp)
1787 ENV *env;
1788 DBT *dbtp;
1789 DB_LSN *lsnp;
1790 db_recops notused2;
1791 void *lvhp;
1792 {
1793 __bam_split_args *argp;
1794 DB_LOG_VRFY_INFO *lvh;
1795 int ret;
1796
1797 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
1798 lvh = (DB_LOG_VRFY_INFO *)lvhp;
1799
1800 if ((ret =
1801 __bam_split_read(env, NULL, NULL, dbtp->data, &argp)) != 0)
1802 return (ret);
1803
1804 LOG_VRFY_PROC(lvh, *lsnp, argp, argp->fileid);
1805
1806 ON_PAGE_UPDATE(lvh, *lsnp, argp, argp->left);
1807 ON_PAGE_UPDATE(lvh, *lsnp, argp, argp->right);
1808 /* Parent page lock is always released before __bam_page returns. */
1809
1810 if ((ret = __lv_on_bam_log(lvh, *lsnp, argp->fileid)) != 0)
1811 goto err;
1812
1813 out:
1814
1815 err:
1816
1817 __os_free(env, argp);
1818 return (ret);
1819 }
1820
1821 /*
1822 * PUBLIC: int __bam_split_42_verify __P((ENV *, DBT *, DB_LSN *,
1823 * PUBLIC: db_recops, void *));
1824 */
1825 int
__bam_split_42_verify(env,dbtp,lsnp,notused2,lvhp)1826 __bam_split_42_verify(env, dbtp, lsnp, notused2, lvhp)
1827 ENV *env;
1828 DBT *dbtp;
1829 DB_LSN *lsnp;
1830 db_recops notused2;
1831 void *lvhp;
1832 {
1833 __bam_split_42_args *argp;
1834 DB_LOG_VRFY_INFO *lvh;
1835 int ret;
1836
1837 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
1838 lvh = (DB_LOG_VRFY_INFO *)lvhp;
1839
1840 if ((ret =
1841 __bam_split_42_read(env, NULL, NULL, dbtp->data, &argp)) != 0)
1842 return (ret);
1843
1844 ON_NOT_SUPPORTED(env, lvh, *lsnp, argp->type);
1845 /* LOG_VRFY_PROC(lvh, *lsnp, argp, argp->fileid); */
1846
1847 err:
1848
1849 __os_free(env, argp);
1850 return (ret);
1851 }
1852
1853 /*
1854 * PUBLIC: int __bam_rsplit_verify __P((ENV *, DBT *, DB_LSN *,
1855 * PUBLIC: db_recops, void *));
1856 */
1857 int
__bam_rsplit_verify(env,dbtp,lsnp,notused2,lvhp)1858 __bam_rsplit_verify(env, dbtp, lsnp, notused2, lvhp)
1859 ENV *env;
1860 DBT *dbtp;
1861 DB_LSN *lsnp;
1862 db_recops notused2;
1863 void *lvhp;
1864 {
1865 __bam_rsplit_args *argp;
1866 DB_LOG_VRFY_INFO *lvh;
1867 int ret;
1868
1869 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
1870 lvh = (DB_LOG_VRFY_INFO *)lvhp;
1871
1872 if ((ret =
1873 __bam_rsplit_read(env, NULL, NULL, dbtp->data, &argp)) != 0)
1874 return (ret);
1875
1876 LOG_VRFY_PROC(lvh, *lsnp, argp, argp->fileid);
1877
1878 ON_PAGE_UPDATE(lvh, *lsnp, argp, argp->pgno);
1879 if ((ret = __lv_on_bam_log(lvh, *lsnp, argp->fileid)) != 0)
1880 goto err;
1881
1882 out:
1883
1884 err:
1885
1886 __os_free(env, argp);
1887 return (ret);
1888 }
1889
1890 /*
1891 * PUBLIC: int __bam_adj_verify __P((ENV *, DBT *, DB_LSN *,
1892 * PUBLIC: db_recops, void *));
1893 */
1894 int
__bam_adj_verify(env,dbtp,lsnp,notused2,lvhp)1895 __bam_adj_verify(env, dbtp, lsnp, notused2, lvhp)
1896 ENV *env;
1897 DBT *dbtp;
1898 DB_LSN *lsnp;
1899 db_recops notused2;
1900 void *lvhp;
1901 {
1902 __bam_adj_args *argp;
1903 DB_LOG_VRFY_INFO *lvh;
1904 int ret;
1905
1906 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
1907 lvh = (DB_LOG_VRFY_INFO *)lvhp;
1908
1909 if ((ret =
1910 __bam_adj_read(env, NULL, NULL, dbtp->data, &argp)) != 0)
1911 return (ret);
1912
1913 LOG_VRFY_PROC(lvh, *lsnp, argp, argp->fileid);
1914
1915 ON_PAGE_UPDATE(lvh, *lsnp, argp, argp->pgno);
1916 if ((ret = __lv_on_bam_log(lvh, *lsnp, argp->fileid)) != 0)
1917 goto err;
1918
1919 out:
1920
1921 err:
1922
1923 __os_free(env, argp);
1924 return (ret);
1925 }
1926
1927 /*
1928 * PUBLIC: int __bam_irep_verify __P((ENV *, DBT *, DB_LSN *,
1929 * PUBLIC: db_recops, void *));
1930 */
1931 int
__bam_irep_verify(env,dbtp,lsnp,notused2,lvhp)1932 __bam_irep_verify(env, dbtp, lsnp, notused2, lvhp)
1933 ENV *env;
1934 DBT *dbtp;
1935 DB_LSN *lsnp;
1936 db_recops notused2;
1937 void *lvhp;
1938 {
1939 __bam_irep_args *argp;
1940 DB_LOG_VRFY_INFO *lvh;
1941 int ret;
1942
1943 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
1944 lvh = (DB_LOG_VRFY_INFO *)lvhp;
1945
1946 if ((ret =
1947 __bam_irep_read(env, NULL, NULL, dbtp->data, &argp)) != 0)
1948 return (ret);
1949
1950 LOG_VRFY_PROC(lvh, *lsnp, argp, argp->fileid);
1951
1952 ON_PAGE_UPDATE(lvh, *lsnp, argp, argp->pgno);
1953 if ((ret = __lv_on_bam_log(lvh, *lsnp, argp->fileid)) != 0)
1954 goto err;
1955
1956 out:
1957
1958 err:
1959
1960 __os_free(env, argp);
1961 return (ret);
1962 }
1963
1964 /*
1965 * PUBLIC: int __bam_cadjust_verify __P((ENV *, DBT *, DB_LSN *,
1966 * PUBLIC: db_recops, void *));
1967 */
1968 int
__bam_cadjust_verify(env,dbtp,lsnp,notused2,lvhp)1969 __bam_cadjust_verify(env, dbtp, lsnp, notused2, lvhp)
1970 ENV *env;
1971 DBT *dbtp;
1972 DB_LSN *lsnp;
1973 db_recops notused2;
1974 void *lvhp;
1975 {
1976 __bam_cadjust_args *argp;
1977 DB_LOG_VRFY_INFO *lvh;
1978 int ret;
1979
1980 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
1981 lvh = (DB_LOG_VRFY_INFO *)lvhp;
1982
1983 if ((ret =
1984 __bam_cadjust_read(env, NULL, NULL, dbtp->data, &argp)) != 0)
1985 return (ret);
1986
1987 LOG_VRFY_PROC(lvh, *lsnp, argp, argp->fileid);
1988
1989 ON_PAGE_UPDATE(lvh, *lsnp, argp, argp->pgno);
1990 if ((ret = __lv_on_bam_log(lvh, *lsnp, argp->fileid)) != 0)
1991 goto err;
1992
1993 out:
1994
1995 err:
1996
1997 __os_free(env, argp);
1998 return (ret);
1999 }
2000
2001 /*
2002 * PUBLIC: int __bam_cdel_verify __P((ENV *, DBT *, DB_LSN *,
2003 * PUBLIC: db_recops, void *));
2004 */
2005 int
__bam_cdel_verify(env,dbtp,lsnp,notused2,lvhp)2006 __bam_cdel_verify(env, dbtp, lsnp, notused2, lvhp)
2007 ENV *env;
2008 DBT *dbtp;
2009 DB_LSN *lsnp;
2010 db_recops notused2;
2011 void *lvhp;
2012 {
2013 __bam_cdel_args *argp;
2014 DB_LOG_VRFY_INFO *lvh;
2015 int ret;
2016
2017 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
2018 lvh = (DB_LOG_VRFY_INFO *)lvhp;
2019
2020 if ((ret =
2021 __bam_cdel_read(env, NULL, NULL, dbtp->data, &argp)) != 0)
2022 return (ret);
2023
2024 LOG_VRFY_PROC(lvh, *lsnp, argp, argp->fileid);
2025
2026 ON_PAGE_UPDATE(lvh, *lsnp, argp, argp->pgno);
2027 if ((ret = __lv_on_bam_log(lvh, *lsnp, argp->fileid)) != 0)
2028 goto err;
2029
2030 out:
2031
2032 err:
2033
2034 __os_free(env, argp);
2035 return (ret);
2036 }
2037
2038 /*
2039 * PUBLIC: int __bam_repl_verify __P((ENV *, DBT *, DB_LSN *,
2040 * PUBLIC: db_recops, void *));
2041 */
2042 int
__bam_repl_verify(env,dbtp,lsnp,notused2,lvhp)2043 __bam_repl_verify(env, dbtp, lsnp, notused2, lvhp)
2044 ENV *env;
2045 DBT *dbtp;
2046 DB_LSN *lsnp;
2047 db_recops notused2;
2048 void *lvhp;
2049 {
2050 __bam_repl_args *argp;
2051 DB_LOG_VRFY_INFO *lvh;
2052 int ret;
2053
2054 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
2055 lvh = (DB_LOG_VRFY_INFO *)lvhp;
2056
2057 if ((ret =
2058 __bam_repl_read(env, NULL, NULL, dbtp->data, &argp)) != 0)
2059 return (ret);
2060
2061 LOG_VRFY_PROC(lvh, *lsnp, argp, argp->fileid);
2062
2063 ON_PAGE_UPDATE(lvh, *lsnp, argp, argp->pgno);
2064 if ((ret = __lv_on_bam_log(lvh, *lsnp, argp->fileid)) != 0)
2065 goto err;
2066
2067 out:
2068
2069 err:
2070
2071 __os_free(env, argp);
2072 return (ret);
2073 }
2074
2075 /*
2076 * PUBLIC: int __bam_root_verify __P((ENV *, DBT *, DB_LSN *,
2077 * PUBLIC: db_recops, void *));
2078 */
2079 int
__bam_root_verify(env,dbtp,lsnp,notused2,lvhp)2080 __bam_root_verify(env, dbtp, lsnp, notused2, lvhp)
2081 ENV *env;
2082 DBT *dbtp;
2083 DB_LSN *lsnp;
2084 db_recops notused2;
2085 void *lvhp;
2086 {
2087 __bam_root_args *argp;
2088 DB_LOG_VRFY_INFO *lvh;
2089 int ret;
2090
2091 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
2092 lvh = (DB_LOG_VRFY_INFO *)lvhp;
2093
2094 if ((ret =
2095 __bam_root_read(env, NULL, NULL, dbtp->data, &argp)) != 0)
2096 return (ret);
2097
2098 LOG_VRFY_PROC(lvh, *lsnp, argp, argp->fileid);
2099 if ((ret = __lv_on_bam_log(lvh, *lsnp, argp->fileid)) != 0)
2100 goto err;
2101
2102 out:
2103
2104 err:
2105
2106 __os_free(env, argp);
2107 return (ret);
2108 }
2109
2110 /*
2111 * PUBLIC: int __bam_curadj_verify __P((ENV *, DBT *, DB_LSN *,
2112 * PUBLIC: db_recops, void *));
2113 */
2114 int
__bam_curadj_verify(env,dbtp,lsnp,notused2,lvhp)2115 __bam_curadj_verify(env, dbtp, lsnp, notused2, lvhp)
2116 ENV *env;
2117 DBT *dbtp;
2118 DB_LSN *lsnp;
2119 db_recops notused2;
2120 void *lvhp;
2121 {
2122 __bam_curadj_args *argp;
2123 DB_LOG_VRFY_INFO *lvh;
2124 int ret;
2125
2126 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
2127 lvh = (DB_LOG_VRFY_INFO *)lvhp;
2128
2129 if ((ret =
2130 __bam_curadj_read(env, NULL, NULL, dbtp->data, &argp)) != 0)
2131 return (ret);
2132
2133 LOG_VRFY_PROC(lvh, *lsnp, argp, argp->fileid);
2134 if ((ret = __lv_on_bam_log(lvh, *lsnp, argp->fileid)) != 0)
2135 goto err;
2136
2137 out:
2138
2139 err:
2140
2141 __os_free(env, argp);
2142
2143 return (ret);
2144 }
2145
2146 /*
2147 * PUBLIC: int __bam_rcuradj_verify __P((ENV *, DBT *, DB_LSN *,
2148 * PUBLIC: db_recops, void *));
2149 */
2150 int
__bam_rcuradj_verify(env,dbtp,lsnp,notused2,lvhp)2151 __bam_rcuradj_verify(env, dbtp, lsnp, notused2, lvhp)
2152 ENV *env;
2153 DBT *dbtp;
2154 DB_LSN *lsnp;
2155 db_recops notused2;
2156 void *lvhp;
2157 {
2158 __bam_rcuradj_args *argp;
2159 DB_LOG_VRFY_INFO *lvh;
2160 int ret;
2161
2162 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
2163 lvh = (DB_LOG_VRFY_INFO *)lvhp;
2164
2165 if ((ret =
2166 __bam_rcuradj_read(env, NULL, NULL, dbtp->data, &argp)) != 0)
2167 return (ret);
2168
2169 LOG_VRFY_PROC(lvh, *lsnp, argp, argp->fileid);
2170 if ((ret = __lv_on_bam_log(lvh, *lsnp, argp->fileid)) != 0)
2171 goto err;
2172
2173 out:
2174
2175 err:
2176
2177 __os_free(env, argp);
2178
2179 return (ret);
2180 }
2181
2182 /*
2183 * PUBLIC: int __bam_relink_43_verify __P((ENV *, DBT *, DB_LSN *,
2184 * PUBLIC: db_recops, void *));
2185 */
2186 int
__bam_relink_43_verify(env,dbtp,lsnp,notused2,lvhp)2187 __bam_relink_43_verify(env, dbtp, lsnp, notused2, lvhp)
2188 ENV *env;
2189 DBT *dbtp;
2190 DB_LSN *lsnp;
2191 db_recops notused2;
2192 void *lvhp;
2193 {
2194 __bam_relink_43_args *argp;
2195 DB_LOG_VRFY_INFO *lvh;
2196 int ret;
2197
2198 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
2199 lvh = (DB_LOG_VRFY_INFO *)lvhp;
2200
2201 if ((ret =
2202 __bam_relink_43_read(env, NULL, NULL, dbtp->data, &argp)) != 0)
2203 return (ret);
2204
2205 ON_NOT_SUPPORTED(env, lvh, *lsnp, argp->type);
2206 /* LOG_VRFY_PROC(lvh, *lsnp, argp, argp->fileid); */
2207 err:
2208
2209 __os_free(env, argp);
2210
2211 return (ret);
2212 }
2213
2214 /*
2215 * PUBLIC: int __bam_merge_44_verify __P((ENV *, DBT *, DB_LSN *,
2216 * PUBLIC: db_recops, void *));
2217 */
2218 int
__bam_merge_44_verify(env,dbtp,lsnp,notused2,lvhp)2219 __bam_merge_44_verify(env, dbtp, lsnp, notused2, lvhp)
2220 ENV *env;
2221 DBT *dbtp;
2222 DB_LSN *lsnp;
2223 db_recops notused2;
2224 void *lvhp;
2225 {
2226 __bam_merge_44_args *argp;
2227 DB_LOG_VRFY_INFO *lvh;
2228 int ret;
2229
2230 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
2231 lvh = (DB_LOG_VRFY_INFO *)lvhp;
2232
2233 if ((ret =
2234 __bam_merge_44_read(env, NULL, NULL, dbtp->data, &argp)) != 0)
2235 return (ret);
2236
2237 ON_NOT_SUPPORTED(env, lvh, *lsnp, argp->type);
2238 /* LOG_VRFY_PROC(lvh, *lsnp, argp, argp->fileid); */
2239 err:
2240
2241 __os_free(env, argp);
2242
2243 return (ret);
2244 }
2245
2246 /*
2247 * PUBLIC: int __fop_create_42_verify __P((ENV *, DBT *, DB_LSN *,
2248 * PUBLIC: db_recops, void *));
2249 */
2250 int
__fop_create_42_verify(env,dbtp,lsnp,notused2,lvhp)2251 __fop_create_42_verify(env, dbtp, lsnp, notused2, lvhp)
2252 ENV *env;
2253 DBT *dbtp;
2254 DB_LSN *lsnp;
2255 db_recops notused2;
2256 void *lvhp;
2257 {
2258 __fop_create_42_args *argp;
2259 DB_LOG_VRFY_INFO *lvh;
2260 int ret;
2261
2262 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
2263 lvh = (DB_LOG_VRFY_INFO *)lvhp;
2264
2265 if ((ret = __fop_create_42_read(env, dbtp->data, &argp)) != 0)
2266 return (ret);
2267
2268 ON_NOT_SUPPORTED(env, lvh, *lsnp, argp->type);
2269 /* LOG_VRFY_PROC(lvh, *lsnp, argp, INVAL_DBREGID); */
2270 err:
2271
2272 __os_free(env, argp);
2273
2274 return (ret);
2275 }
2276
2277 /*
2278 * PUBLIC: int __fop_create_60_verify __P((ENV *, DBT *, DB_LSN *,
2279 * PUBLIC: db_recops, void *));
2280 */
2281 int
__fop_create_60_verify(env,dbtp,lsnp,notused2,lvhp)2282 __fop_create_60_verify(env, dbtp, lsnp, notused2, lvhp)
2283 ENV *env;
2284 DBT *dbtp;
2285 DB_LSN *lsnp;
2286 db_recops notused2;
2287 void *lvhp;
2288 {
2289 __fop_create_60_args *argp;
2290 DB_LOG_VRFY_INFO *lvh;
2291 int ret;
2292
2293 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
2294 lvh = (DB_LOG_VRFY_INFO *)lvhp;
2295
2296 if ((ret = __fop_create_60_read(env, dbtp->data, &argp)) != 0)
2297 return (ret);
2298
2299 ON_NOT_SUPPORTED(env, lvh, *lsnp, argp->type);
2300 /* LOG_VRFY_PROC(lvh, *lsnp, argp, INVAL_DBREGID); */
2301 err:
2302
2303 __os_free(env, argp);
2304
2305 return (ret);
2306 }
2307
2308 /*
2309 * PUBLIC: int __fop_create_verify __P((ENV *, DBT *, DB_LSN *,
2310 * PUBLIC: db_recops, void *));
2311 */
2312 int
__fop_create_verify(env,dbtp,lsnp,notused2,lvhp)2313 __fop_create_verify(env, dbtp, lsnp, notused2, lvhp)
2314 ENV *env;
2315 DBT *dbtp;
2316 DB_LSN *lsnp;
2317 db_recops notused2;
2318 void *lvhp;
2319 {
2320 __fop_create_args *argp;
2321 DB_LOG_VRFY_INFO *lvh;
2322 int ret;
2323
2324 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
2325 lvh = (DB_LOG_VRFY_INFO *)lvhp;
2326
2327 if ((ret = __fop_create_read(env, dbtp->data, &argp)) != 0)
2328 return (ret);
2329
2330 LOG_VRFY_PROC(lvh, *lsnp, argp, INVAL_DBREGID);
2331
2332 out:
2333
2334 err:
2335
2336 __os_free(env, argp);
2337
2338 return (ret);
2339 }
2340
2341 /*
2342 * PUBLIC: int __fop_remove_60_verify __P((ENV *, DBT *, DB_LSN *,
2343 * PUBLIC: db_recops, void *));
2344 */
2345 int
__fop_remove_60_verify(env,dbtp,lsnp,notused2,lvhp)2346 __fop_remove_60_verify(env, dbtp, lsnp, notused2, lvhp)
2347 ENV *env;
2348 DBT *dbtp;
2349 DB_LSN *lsnp;
2350 db_recops notused2;
2351 void *lvhp;
2352 {
2353 __fop_remove_60_args *argp;
2354 DB_LOG_VRFY_INFO *lvh;
2355 int ret;
2356
2357 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
2358 lvh = (DB_LOG_VRFY_INFO *)lvhp;
2359
2360 if ((ret = __fop_remove_60_read(env, dbtp->data, &argp)) != 0)
2361 return (ret);
2362
2363 ON_NOT_SUPPORTED(env, lvh, *lsnp, argp->type);
2364 /*LOG_VRFY_PROC(lvh, *lsnp, argp, INVAL_DBREGID);*/
2365
2366 err:
2367
2368 __os_free(env, argp);
2369
2370 return (ret);
2371 }
2372
2373 /*
2374 * PUBLIC: int __fop_remove_verify __P((ENV *, DBT *, DB_LSN *,
2375 * PUBLIC: db_recops, void *));
2376 */
2377 int
__fop_remove_verify(env,dbtp,lsnp,notused2,lvhp)2378 __fop_remove_verify(env, dbtp, lsnp, notused2, lvhp)
2379 ENV *env;
2380 DBT *dbtp;
2381 DB_LSN *lsnp;
2382 db_recops notused2;
2383 void *lvhp;
2384 {
2385 __fop_remove_args *argp;
2386 DB_LOG_VRFY_INFO *lvh;
2387 int ret;
2388
2389 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
2390 lvh = (DB_LOG_VRFY_INFO *)lvhp;
2391
2392 if ((ret = __fop_remove_read(env, dbtp->data, &argp)) != 0)
2393 return (ret);
2394
2395 LOG_VRFY_PROC(lvh, *lsnp, argp, INVAL_DBREGID);
2396
2397 out:
2398
2399 err:
2400
2401 __os_free(env, argp);
2402
2403 return (ret);
2404 }
2405
2406 /*
2407 * PUBLIC: int __fop_write_42_verify __P((ENV *, DBT *, DB_LSN *,
2408 * PUBLIC: db_recops, void *));
2409 */
2410 int
__fop_write_42_verify(env,dbtp,lsnp,notused2,lvhp)2411 __fop_write_42_verify(env, dbtp, lsnp, notused2, lvhp)
2412 ENV *env;
2413 DBT *dbtp;
2414 DB_LSN *lsnp;
2415 db_recops notused2;
2416 void *lvhp;
2417 {
2418 __fop_write_42_args *argp;
2419 DB_LOG_VRFY_INFO *lvh;
2420 int ret;
2421
2422 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
2423 lvh = (DB_LOG_VRFY_INFO *)lvhp;
2424
2425 if ((ret = __fop_write_42_read(env, dbtp->data, &argp)) != 0)
2426 return (ret);
2427
2428 ON_NOT_SUPPORTED(env, lvh, *lsnp, argp->type);
2429 /* LOG_VRFY_PROC(lvh, *lsnp, argp, INVAL_DBREGID); */
2430 err:
2431
2432 __os_free(env, argp);
2433 return (ret);
2434 }
2435
2436 /*
2437 * PUBLIC: int __fop_write_60_verify __P((ENV *, DBT *, DB_LSN *,
2438 * PUBLIC: db_recops, void *));
2439 */
2440 int
__fop_write_60_verify(env,dbtp,lsnp,notused2,lvhp)2441 __fop_write_60_verify(env, dbtp, lsnp, notused2, lvhp)
2442 ENV *env;
2443 DBT *dbtp;
2444 DB_LSN *lsnp;
2445 db_recops notused2;
2446 void *lvhp;
2447 {
2448 __fop_write_60_args *argp;
2449 DB_LOG_VRFY_INFO *lvh;
2450 int ret;
2451
2452 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
2453 lvh = (DB_LOG_VRFY_INFO *)lvhp;
2454
2455 if ((ret = __fop_write_60_read(env, dbtp->data, &argp)) != 0)
2456 return (ret);
2457
2458 ON_NOT_SUPPORTED(env, lvh, *lsnp, argp->type);
2459 /* LOG_VRFY_PROC(lvh, *lsnp, argp, INVAL_DBREGID); */
2460 err:
2461
2462 __os_free(env, argp);
2463 return (ret);
2464 }
2465
2466 /*
2467 * PUBLIC: int __fop_write_verify __P((ENV *, DBT *, DB_LSN *,
2468 * PUBLIC: db_recops, void *));
2469 */
2470 int
__fop_write_verify(env,dbtp,lsnp,notused2,lvhp)2471 __fop_write_verify(env, dbtp, lsnp, notused2, lvhp)
2472 ENV *env;
2473 DBT *dbtp;
2474 DB_LSN *lsnp;
2475 db_recops notused2;
2476 void *lvhp;
2477 {
2478 __fop_write_args *argp;
2479 DB_LOG_VRFY_INFO *lvh;
2480 int ret;
2481
2482 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
2483 lvh = (DB_LOG_VRFY_INFO *)lvhp;
2484
2485 if ((ret = __fop_write_read(env, dbtp->data, &argp)) != 0)
2486 return (ret);
2487
2488 LOG_VRFY_PROC(lvh, *lsnp, argp, INVAL_DBREGID);
2489 ON_PAGE_UPDATE4 /* No pages are locked by txns. */
2490 out:
2491
2492 err:
2493
2494 __os_free(env, argp);
2495 return (ret);
2496 }
2497
2498 /*
2499 * PUBLIC: int __fop_write_file_60_verify __P((ENV *, DBT *, DB_LSN *,
2500 * PUBLIC: db_recops, void *));
2501 */
2502 int
__fop_write_file_60_verify(env,dbtp,lsnp,notused2,lvhp)2503 __fop_write_file_60_verify(env, dbtp, lsnp, notused2, lvhp)
2504 ENV *env;
2505 DBT *dbtp;
2506 DB_LSN *lsnp;
2507 db_recops notused2;
2508 void *lvhp;
2509 {
2510 __fop_write_file_60_args *argp;
2511 DB_LOG_VRFY_INFO *lvh;
2512 int ret;
2513
2514 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
2515 lvh = (DB_LOG_VRFY_INFO *)lvhp;
2516
2517 if ((ret = __fop_write_file_60_read(env, dbtp->data, &argp)) != 0)
2518 return (ret);
2519
2520 ON_NOT_SUPPORTED(env, lvh, *lsnp, argp->type);
2521 /*LOG_VRFY_PROC(lvh, *lsnp, argp, INVAL_DBREGID);*/
2522 err:
2523 __os_free(env, argp);
2524 return (ret);
2525 }
2526
2527 /*
2528 * PUBLIC: int __fop_write_file_verify __P((ENV *, DBT *, DB_LSN *,
2529 * PUBLIC: db_recops, void *));
2530 */
2531 int
__fop_write_file_verify(env,dbtp,lsnp,notused2,lvhp)2532 __fop_write_file_verify(env, dbtp, lsnp, notused2, lvhp)
2533 ENV *env;
2534 DBT *dbtp;
2535 DB_LSN *lsnp;
2536 db_recops notused2;
2537 void *lvhp;
2538 {
2539 __fop_write_file_args *argp;
2540 DB_LOG_VRFY_INFO *lvh;
2541 int ret;
2542
2543 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
2544 lvh = (DB_LOG_VRFY_INFO *)lvhp;
2545
2546 if ((ret = __fop_write_file_read(env, dbtp->data, &argp)) != 0)
2547 return (ret);
2548
2549 LOG_VRFY_PROC(lvh, *lsnp, argp, INVAL_DBREGID);
2550 ON_PAGE_UPDATE4 /* No pages are locked by txns. */
2551 out:
2552
2553 err:
2554
2555 __os_free(env, argp);
2556 return (ret);
2557 }
2558
2559 /*
2560 * PUBLIC: int __fop_rename_42_verify __P((ENV *, DBT *, DB_LSN *,
2561 * PUBLIC: db_recops, void *));
2562 */
2563 int
__fop_rename_42_verify(env,dbtp,lsnp,notused2,lvhp)2564 __fop_rename_42_verify(env, dbtp, lsnp, notused2, lvhp)
2565 ENV *env;
2566 DBT *dbtp;
2567 DB_LSN *lsnp;
2568 db_recops notused2;
2569 void *lvhp;
2570 {
2571 __fop_rename_42_args *argp;
2572 DB_LOG_VRFY_INFO *lvh;
2573 int ret;
2574
2575 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
2576 lvh = (DB_LOG_VRFY_INFO *)lvhp;
2577
2578 if ((ret = __fop_rename_42_read(env, dbtp->data, &argp)) != 0)
2579 return (ret);
2580
2581 ON_NOT_SUPPORTED(env, lvh, *lsnp, argp->type);
2582 /* LOG_VRFY_PROC(lvh, *lsnp, argp, INVAL_DBREGID); */
2583 err:
2584
2585 __os_free(env, argp);
2586
2587 return (ret);
2588 }
2589
2590 /*
2591 * PUBLIC: int __fop_rename_60_verify __P((ENV *, DBT *, DB_LSN *,
2592 * PUBLIC: db_recops, void *));
2593 */
2594 int
__fop_rename_60_verify(env,dbtp,lsnp,notused2,lvhp)2595 __fop_rename_60_verify(env, dbtp, lsnp, notused2, lvhp)
2596 ENV *env;
2597 DBT *dbtp;
2598 DB_LSN *lsnp;
2599 db_recops notused2;
2600 void *lvhp;
2601 {
2602 __fop_rename_60_args *argp;
2603 DB_LOG_VRFY_INFO *lvh;
2604 int ret;
2605
2606 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
2607 lvh = (DB_LOG_VRFY_INFO *)lvhp;
2608
2609 if ((ret = __fop_rename_60_read(env, dbtp->data, &argp)) != 0)
2610 return (ret);
2611
2612 ON_NOT_SUPPORTED(env, lvh, *lsnp, argp->type);
2613 /* LOG_VRFY_PROC(lvh, *lsnp, argp, INVAL_DBREGID); */
2614 err:
2615
2616 __os_free(env, argp);
2617
2618 return (ret);
2619 }
2620
2621 /*
2622 * PUBLIC: int __fop_rename_verify __P((ENV *, DBT *, DB_LSN *,
2623 * PUBLIC: db_recops, void *));
2624 */
2625 int
__fop_rename_verify(env,dbtp,lsnp,notused2,lvhp)2626 __fop_rename_verify(env, dbtp, lsnp, notused2, lvhp)
2627 ENV *env;
2628 DBT *dbtp;
2629 DB_LSN *lsnp;
2630 db_recops notused2;
2631 void *lvhp;
2632 {
2633 __fop_rename_args *argp;
2634 DB_LOG_VRFY_INFO *lvh;
2635 char *buf;
2636 int ret;
2637 size_t buflen;
2638 VRFY_FILEREG_INFO freg, *fregp;
2639
2640 memset(&freg, 0, sizeof(freg));
2641 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
2642 lvh = (DB_LOG_VRFY_INFO *)lvhp;
2643 buf = NULL;
2644
2645 if ((ret = __fop_rename_read(env, dbtp->data, &argp)) != 0)
2646 return (ret);
2647
2648 LOG_VRFY_PROC(lvh, *lsnp, argp, INVAL_DBREGID);
2649 if (F_ISSET(lvh, DB_LOG_VERIFY_FORWARD)) {
2650 /*
2651 * Since we get the fname-fuid map when iterating from end to
2652 * beginning, we only store the latest file name, that's the
2653 * name supposed to be used currently. So if the fileid is
2654 * already stored, and we see it again here, it means the db
2655 * file was renamed and we already have its latest name.
2656 *
2657 * Store the dbfile path (dir/fname) in case there are db
2658 * files with same name in different data directories.
2659 */
2660 if (__get_filereg_info(lvh, &(argp->fileid), &fregp) == 0) {
2661 if (fregp != NULL &&
2662 (ret = __free_filereg_info(fregp)) != 0)
2663 goto err;
2664 goto out;
2665 }
2666 freg.fileid = argp->fileid;
2667 if ((ret = __os_malloc(env, buflen = argp->dirname.size +
2668 argp->newname.size + 2, &buf)) != 0)
2669 goto err;
2670 snprintf(buf, buflen, "%s/%s", (char *)argp->dirname.data,
2671 (char *)argp->newname.data);
2672 freg.fname = buf;
2673 /* Store the dbfilename<-->dbfileid map. */
2674 if ((ret = __put_filereg_info(lvh, &freg)) != 0)
2675 goto err;
2676 }
2677 out:
2678
2679 err:
2680 if (buf != NULL)
2681 __os_free(lvh->dbenv->env, buf);
2682 __os_free(env, argp);
2683
2684 return (ret);
2685 }
2686
2687 /*
2688 * PUBLIC: int __fop_file_remove_60_verify __P((ENV *, DBT *, DB_LSN *,
2689 * PUBLIC: db_recops, void *));
2690 */
2691 int
__fop_file_remove_60_verify(env,dbtp,lsnp,notused2,lvhp)2692 __fop_file_remove_60_verify(env, dbtp, lsnp, notused2, lvhp)
2693 ENV *env;
2694 DBT *dbtp;
2695 DB_LSN *lsnp;
2696 db_recops notused2;
2697 void *lvhp;
2698 {
2699 __fop_file_remove_60_args *argp;
2700 DB_LOG_VRFY_INFO *lvh;
2701 int ret;
2702
2703 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
2704 lvh = (DB_LOG_VRFY_INFO *)lvhp;
2705
2706 if ((ret = __fop_file_remove_60_read(env, dbtp->data, &argp)) != 0)
2707 return (ret);
2708
2709 ON_NOT_SUPPORTED(env, lvh, *lsnp, argp->type);
2710 /*LOG_VRFY_PROC(lvh, *lsnp, argp, INVAL_DBREGID);*/
2711
2712 err:
2713
2714 __os_free(env, argp);
2715
2716 return (ret);
2717 }
2718
2719 /*
2720 * PUBLIC: int __fop_file_remove_verify __P((ENV *, DBT *, DB_LSN *,
2721 * PUBLIC: db_recops, void *));
2722 */
2723 int
__fop_file_remove_verify(env,dbtp,lsnp,notused2,lvhp)2724 __fop_file_remove_verify(env, dbtp, lsnp, notused2, lvhp)
2725 ENV *env;
2726 DBT *dbtp;
2727 DB_LSN *lsnp;
2728 db_recops notused2;
2729 void *lvhp;
2730 {
2731 __fop_file_remove_args *argp;
2732 DB_LOG_VRFY_INFO *lvh;
2733 int ret;
2734
2735 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
2736 lvh = (DB_LOG_VRFY_INFO *)lvhp;
2737
2738 if ((ret = __fop_file_remove_read(env, dbtp->data, &argp)) != 0)
2739 return (ret);
2740
2741 LOG_VRFY_PROC(lvh, *lsnp, argp, INVAL_DBREGID);
2742
2743 out:
2744
2745 err:
2746
2747 __os_free(env, argp);
2748
2749 return (ret);
2750 }
2751
2752 #ifdef HAVE_HASH
2753 /*
2754 * PUBLIC: int __ham_insdel_verify __P((ENV *, DBT *, DB_LSN *,
2755 * PUBLIC: db_recops, void *));
2756 */
2757 int
__ham_insdel_verify(env,dbtp,lsnp,notused2,lvhp)2758 __ham_insdel_verify(env, dbtp, lsnp, notused2, lvhp)
2759 ENV *env;
2760 DBT *dbtp;
2761 DB_LSN *lsnp;
2762 db_recops notused2;
2763 void *lvhp;
2764 {
2765 __ham_insdel_args *argp;
2766 DB_LOG_VRFY_INFO *lvh;
2767 int ret;
2768
2769 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
2770 lvh = (DB_LOG_VRFY_INFO *)lvhp;
2771
2772 if ((ret =
2773 __ham_insdel_read(env, NULL, NULL, dbtp->data, &argp)) != 0)
2774 return (ret);
2775
2776 LOG_VRFY_PROC(lvh, *lsnp, argp, argp->fileid);
2777 ON_PAGE_UPDATE(lvh, *lsnp, argp, argp->pgno);
2778 if ((ret = __lv_on_ham_log(lvh, *lsnp, argp->fileid)) != 0)
2779 goto err;
2780
2781 out:
2782
2783 err:
2784
2785 __os_free(env, argp);
2786 return (ret);
2787 }
2788
2789 /*
2790 * PUBLIC: int __ham_newpage_verify __P((ENV *, DBT *, DB_LSN *,
2791 * PUBLIC: db_recops, void *));
2792 */
2793 int
__ham_newpage_verify(env,dbtp,lsnp,notused2,lvhp)2794 __ham_newpage_verify(env, dbtp, lsnp, notused2, lvhp)
2795 ENV *env;
2796 DBT *dbtp;
2797 DB_LSN *lsnp;
2798 db_recops notused2;
2799 void *lvhp;
2800 {
2801 __ham_newpage_args *argp;
2802 DB_LOG_VRFY_INFO *lvh;
2803 int ret;
2804
2805 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
2806 lvh = (DB_LOG_VRFY_INFO *)lvhp;
2807
2808 if ((ret =
2809 __ham_newpage_read(env, NULL, NULL, dbtp->data, &argp)) != 0)
2810 return (ret);
2811
2812 LOG_VRFY_PROC(lvh, *lsnp, argp, argp->fileid);
2813
2814 ON_PAGE_UPDATE4 /* No pages are locked by txns. */
2815 if ((ret = __lv_on_ham_log(lvh, *lsnp, argp->fileid)) != 0)
2816 goto err;
2817
2818 out:
2819
2820 err:
2821
2822 __os_free(env, argp);
2823 return (ret);
2824 }
2825
2826 /*
2827 * PUBLIC: int __ham_splitdata_verify __P((ENV *, DBT *, DB_LSN *,
2828 * PUBLIC: db_recops, void *));
2829 */
2830 int
__ham_splitdata_verify(env,dbtp,lsnp,notused2,lvhp)2831 __ham_splitdata_verify(env, dbtp, lsnp, notused2, lvhp)
2832 ENV *env;
2833 DBT *dbtp;
2834 DB_LSN *lsnp;
2835 db_recops notused2;
2836 void *lvhp;
2837 {
2838 __ham_splitdata_args *argp;
2839 DB_LOG_VRFY_INFO *lvh;
2840 int ret;
2841
2842 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
2843 lvh = (DB_LOG_VRFY_INFO *)lvhp;
2844
2845 if ((ret =
2846 __ham_splitdata_read(env, NULL, NULL, dbtp->data, &argp)) != 0)
2847 return (ret);
2848
2849 LOG_VRFY_PROC(lvh, *lsnp, argp, argp->fileid);
2850 ON_PAGE_UPDATE(lvh, *lsnp, argp, argp->pgno);
2851 if ((ret = __lv_on_ham_log(lvh, *lsnp, argp->fileid)) != 0)
2852 goto err;
2853
2854 out:
2855
2856 err:
2857
2858 __os_free(env, argp);
2859
2860 return (ret);
2861 }
2862
2863 /*
2864 * PUBLIC: int __ham_replace_verify __P((ENV *, DBT *, DB_LSN *,
2865 * PUBLIC: db_recops, void *));
2866 */
2867 int
__ham_replace_verify(env,dbtp,lsnp,notused2,lvhp)2868 __ham_replace_verify(env, dbtp, lsnp, notused2, lvhp)
2869 ENV *env;
2870 DBT *dbtp;
2871 DB_LSN *lsnp;
2872 db_recops notused2;
2873 void *lvhp;
2874 {
2875 __ham_replace_args *argp;
2876 DB_LOG_VRFY_INFO *lvh;
2877 int ret;
2878
2879 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
2880 lvh = (DB_LOG_VRFY_INFO *)lvhp;
2881
2882 if ((ret =
2883 __ham_replace_read(env, NULL, NULL, dbtp->data, &argp)) != 0)
2884 return (ret);
2885
2886 LOG_VRFY_PROC(lvh, *lsnp, argp, argp->fileid);
2887
2888 ON_PAGE_UPDATE(lvh, *lsnp, argp, argp->pgno);
2889 if ((ret = __lv_on_ham_log(lvh, *lsnp, argp->fileid)) != 0)
2890 goto err;
2891
2892 out:
2893
2894 err:
2895
2896 __os_free(env, argp);
2897
2898 return (ret);
2899 }
2900
2901 /*
2902 * PUBLIC: int __ham_copypage_verify __P((ENV *, DBT *, DB_LSN *,
2903 * PUBLIC: db_recops, void *));
2904 */
2905 int
__ham_copypage_verify(env,dbtp,lsnp,notused2,lvhp)2906 __ham_copypage_verify(env, dbtp, lsnp, notused2, lvhp)
2907 ENV *env;
2908 DBT *dbtp;
2909 DB_LSN *lsnp;
2910 db_recops notused2;
2911 void *lvhp;
2912 {
2913 __ham_copypage_args *argp;
2914 DB_LOG_VRFY_INFO *lvh;
2915 int ret;
2916
2917 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
2918 lvh = (DB_LOG_VRFY_INFO *)lvhp;
2919
2920 if ((ret =
2921 __ham_copypage_read(env, NULL, NULL, dbtp->data, &argp)) != 0)
2922 return (ret);
2923
2924 LOG_VRFY_PROC(lvh, *lsnp, argp, argp->fileid);
2925 ON_PAGE_UPDATE(lvh, *lsnp, argp, argp->pgno);
2926 if ((ret = __lv_on_ham_log(lvh, *lsnp, argp->fileid)) != 0)
2927 goto err;
2928
2929 out:
2930
2931 err:
2932
2933 __os_free(env, argp);
2934 return (ret);
2935 }
2936
2937 /*
2938 * PUBLIC: int __ham_metagroup_42_verify __P((ENV *, DBT *, DB_LSN *,
2939 * PUBLIC: db_recops, void *));
2940 */
2941 int
__ham_metagroup_42_verify(env,dbtp,lsnp,notused2,lvhp)2942 __ham_metagroup_42_verify(env, dbtp, lsnp, notused2, lvhp)
2943 ENV *env;
2944 DBT *dbtp;
2945 DB_LSN *lsnp;
2946 db_recops notused2;
2947 void *lvhp;
2948 {
2949 __ham_metagroup_42_args *argp;
2950 DB_LOG_VRFY_INFO *lvh;
2951 int ret;
2952
2953 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
2954 lvh = (DB_LOG_VRFY_INFO *)lvhp;
2955
2956 if ((ret =
2957 __ham_metagroup_42_read(env, NULL, NULL, dbtp->data, &argp)) != 0)
2958 return (ret);
2959
2960 ON_NOT_SUPPORTED(env, lvh, *lsnp, argp->type);
2961 /* LOG_VRFY_PROC(lvh, *lsnp, argp, argp->fileid); */
2962 err:
2963
2964 __os_free(env, argp);
2965
2966 return (ret);
2967 }
2968
2969 /*
2970 * PUBLIC: int __ham_metagroup_verify __P((ENV *, DBT *, DB_LSN *,
2971 * PUBLIC: db_recops, void *));
2972 */
2973 int
__ham_metagroup_verify(env,dbtp,lsnp,notused2,lvhp)2974 __ham_metagroup_verify(env, dbtp, lsnp, notused2, lvhp)
2975 ENV *env;
2976 DBT *dbtp;
2977 DB_LSN *lsnp;
2978 db_recops notused2;
2979 void *lvhp;
2980 {
2981 __ham_metagroup_args *argp;
2982 DB_LOG_VRFY_INFO *lvh;
2983 int ret;
2984
2985 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
2986 lvh = (DB_LOG_VRFY_INFO *)lvhp;
2987
2988 if ((ret =
2989 __ham_metagroup_read(env, NULL, NULL, dbtp->data, &argp)) != 0)
2990 return (ret);
2991
2992 LOG_VRFY_PROC(lvh, *lsnp, argp, argp->fileid);
2993 ON_PAGE_UPDATE(lvh, *lsnp, argp, argp->pgno);
2994 if ((ret = __lv_on_ham_log(lvh, *lsnp, argp->fileid)) != 0)
2995 goto err;
2996
2997 out:
2998
2999 err:
3000
3001 __os_free(env, argp);
3002 return (ret);
3003 }
3004
3005 /*
3006 * PUBLIC: int __ham_groupalloc_42_verify __P((ENV *, DBT *,
3007 * PUBLIC: DB_LSN *, db_recops, void *));
3008 */
3009 int
__ham_groupalloc_42_verify(env,dbtp,lsnp,notused2,lvhp)3010 __ham_groupalloc_42_verify(env, dbtp, lsnp, notused2, lvhp)
3011 ENV *env;
3012 DBT *dbtp;
3013 DB_LSN *lsnp;
3014 db_recops notused2;
3015 void *lvhp;
3016 {
3017 __ham_groupalloc_42_args *argp;
3018 DB_LOG_VRFY_INFO *lvh;
3019 int ret;
3020
3021 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
3022 lvh = (DB_LOG_VRFY_INFO *)lvhp;
3023
3024 if ((ret =
3025 __ham_groupalloc_42_read(env, NULL, NULL, dbtp->data, &argp)) != 0)
3026 return (ret);
3027
3028 ON_NOT_SUPPORTED(env, lvh, *lsnp, argp->type);
3029 /* LOG_VRFY_PROC(lvh, *lsnp, argp, argp->fileid); */
3030 err:
3031
3032 __os_free(env, argp);
3033
3034 return (ret);
3035 }
3036
3037 /*
3038 * PUBLIC: int __ham_groupalloc_verify __P((ENV *, DBT *, DB_LSN *,
3039 * PUBLIC: db_recops, void *));
3040 */
3041 int
__ham_groupalloc_verify(env,dbtp,lsnp,notused2,lvhp)3042 __ham_groupalloc_verify(env, dbtp, lsnp, notused2, lvhp)
3043 ENV *env;
3044 DBT *dbtp;
3045 DB_LSN *lsnp;
3046 db_recops notused2;
3047 void *lvhp;
3048 {
3049 __ham_groupalloc_args *argp;
3050 DB_LOG_VRFY_INFO *lvh;
3051 VRFY_FILELIFE *pflife;
3052 int ret;
3053
3054 ret = 0;
3055 pflife = NULL;
3056
3057 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
3058 lvh = (DB_LOG_VRFY_INFO *)lvhp;
3059
3060 if ((ret =
3061 __ham_groupalloc_read(env, NULL, NULL, dbtp->data, &argp)) != 0)
3062 return (ret);
3063
3064 LOG_VRFY_PROC(lvh, *lsnp, argp, argp->fileid);
3065 ON_PAGE_UPDATE4 /* No pages are locked by txns. */
3066
3067 /*
3068 * The __ham_groupalloc record is only generated when creating the
3069 * hash sub database so it will always be on the master database's
3070 * fileid.
3071 */
3072
3073 if ((ret = __get_filelife(lvh, argp->fileid, &pflife)) != 0)
3074 goto err;
3075
3076 if (pflife->meta_pgno != PGNO_BASE_MD) {
3077 __db_errx(lvh->dbenv->env, DB_STR_A("2546",
3078 "[%lu][%lu] __ham_groupalloc should apply only to the "
3079 "master database with meta page number 0, current meta "
3080 "page number is %d.", "%lu %lu %d"),
3081 (u_long)lsnp->file, (u_long)lsnp->offset,
3082 pflife->meta_pgno);
3083 ret = DB_LOG_VERIFY_BAD;
3084 ON_ERROR(lvh, DB_LOG_VERIFY_ERR);
3085 }
3086
3087 out:
3088
3089 err:
3090 if (pflife != NULL)
3091 __os_free(lvh->dbenv->env, pflife);
3092
3093 __os_free(env, argp);
3094 return (ret);
3095 }
3096
3097 /*
3098 * PUBLIC: int __ham_changeslot_verify __P((ENV *, DBT *, DB_LSN *,
3099 * PUBLIC: db_recops, void *));
3100 */
3101 int
__ham_changeslot_verify(env,dbtp,lsnp,notused2,lvhp)3102 __ham_changeslot_verify(env, dbtp, lsnp, notused2, lvhp)
3103 ENV *env;
3104 DBT *dbtp;
3105 DB_LSN *lsnp;
3106 db_recops notused2;
3107 void *lvhp;
3108 {
3109 __ham_changeslot_args *argp;
3110 DB_LOG_VRFY_INFO *lvh;
3111 int ret;
3112
3113 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
3114 lvh = (DB_LOG_VRFY_INFO *)lvhp;
3115
3116 if ((ret =
3117 __ham_changeslot_read(env, NULL, NULL, dbtp->data, &argp)) != 0)
3118 return (ret);
3119
3120 LOG_VRFY_PROC(lvh, *lsnp, argp, argp->fileid);
3121 ON_PAGE_UPDATE4 /* No pages are locked by txns. */
3122 if ((ret = __lv_on_ham_log(lvh, *lsnp, argp->fileid)) != 0)
3123 goto err;
3124
3125 out:
3126
3127 err:
3128
3129 __os_free(env, argp);
3130
3131 return (ret);
3132 }
3133
3134 /*
3135 * PUBLIC: int __ham_contract_verify __P((ENV *, DBT *, DB_LSN *,
3136 * PUBLIC: db_recops, void *));
3137 */
3138 int
__ham_contract_verify(env,dbtp,lsnp,notused2,lvhp)3139 __ham_contract_verify(env, dbtp, lsnp, notused2, lvhp)
3140 ENV *env;
3141 DBT *dbtp;
3142 DB_LSN *lsnp;
3143 db_recops notused2;
3144 void *lvhp;
3145 {
3146 __ham_contract_args *argp;
3147 DB_LOG_VRFY_INFO *lvh;
3148 int ret;
3149
3150 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
3151 lvh = (DB_LOG_VRFY_INFO *)lvhp;
3152
3153 if ((ret =
3154 __ham_contract_read(env, NULL, NULL, dbtp->data, &argp)) != 0)
3155 return (ret);
3156
3157 LOG_VRFY_PROC(lvh, *lsnp, argp, argp->fileid);
3158 ON_PAGE_UPDATE(lvh, *lsnp, argp, argp->pgno);
3159 if ((ret = __lv_on_ham_log(lvh, *lsnp, argp->fileid)) != 0)
3160 goto err;
3161
3162 out:
3163
3164 err:
3165
3166 __os_free(env, argp);
3167 return (ret);
3168 }
3169
3170 /*
3171 * PUBLIC: int __ham_curadj_verify __P((ENV *, DBT *, DB_LSN *,
3172 * PUBLIC: db_recops, void *));
3173 */
3174 int
__ham_curadj_verify(env,dbtp,lsnp,notused2,lvhp)3175 __ham_curadj_verify(env, dbtp, lsnp, notused2, lvhp)
3176 ENV *env;
3177 DBT *dbtp;
3178 DB_LSN *lsnp;
3179 db_recops notused2;
3180 void *lvhp;
3181 {
3182 __ham_curadj_args *argp;
3183 DB_LOG_VRFY_INFO *lvh;
3184 int ret;
3185
3186 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
3187 lvh = (DB_LOG_VRFY_INFO *)lvhp;
3188
3189 if ((ret =
3190 __ham_curadj_read(env, NULL, NULL, dbtp->data, &argp)) != 0)
3191 return (ret);
3192
3193 LOG_VRFY_PROC(lvh, *lsnp, argp, argp->fileid);
3194 ON_PAGE_UPDATE(lvh, *lsnp, argp, argp->pgno);
3195 if ((ret = __lv_on_ham_log(lvh, *lsnp, argp->fileid)) != 0)
3196 goto err;
3197
3198 out:
3199
3200 err:
3201
3202 __os_free(env, argp);
3203
3204 return (ret);
3205 }
3206
3207 /*
3208 * PUBLIC: int __ham_chgpg_verify __P((ENV *, DBT *, DB_LSN *,
3209 * PUBLIC: db_recops, void *));
3210 */
3211 int
__ham_chgpg_verify(env,dbtp,lsnp,notused2,lvhp)3212 __ham_chgpg_verify(env, dbtp, lsnp, notused2, lvhp)
3213 ENV *env;
3214 DBT *dbtp;
3215 DB_LSN *lsnp;
3216 db_recops notused2;
3217 void *lvhp;
3218 {
3219 __ham_chgpg_args *argp;
3220 DB_LOG_VRFY_INFO *lvh;
3221 int ret;
3222
3223 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
3224 lvh = (DB_LOG_VRFY_INFO *)lvhp;
3225
3226 if ((ret =
3227 __ham_chgpg_read(env, NULL, NULL, dbtp->data, &argp)) != 0)
3228 return (ret);
3229
3230 LOG_VRFY_PROC(lvh, *lsnp, argp, argp->fileid);
3231 ON_PAGE_UPDATE4 /* No pages are locked by txns. */
3232 if ((ret = __lv_on_ham_log(lvh, *lsnp, argp->fileid)) != 0)
3233 goto err;
3234
3235 out:
3236
3237 err:
3238
3239 __os_free(env, argp);
3240 return (ret);
3241 }
3242 #endif
3243
3244 #ifdef HAVE_HEAP
3245 /*
3246 * PUBLIC: int __heap_addrem_verify
3247 * PUBLIC: __P((ENV *, DBT *, DB_LSN *, db_recops, void *));
3248 */
3249 int
__heap_addrem_verify(env,dbtp,lsnp,notused2,lvhp)3250 __heap_addrem_verify(env, dbtp, lsnp, notused2, lvhp)
3251 ENV *env;
3252 DBT *dbtp;
3253 DB_LSN *lsnp;
3254 db_recops notused2;
3255 void *lvhp;
3256 {
3257 __heap_addrem_args *argp;
3258 DB_LOG_VRFY_INFO *lvh;
3259 int ret;
3260
3261 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
3262 lvh = (DB_LOG_VRFY_INFO *)lvhp;
3263
3264 if ((ret =
3265 __heap_addrem_read(env, NULL, NULL, dbtp->data, &argp)) != 0)
3266 return (ret);
3267
3268 LOG_VRFY_PROC(lvh, *lsnp, argp, argp->fileid);
3269 ON_PAGE_UPDATE(lvh, *lsnp, argp, argp->pgno);
3270 if ((ret = __lv_on_heap_log(lvh, *lsnp, argp->fileid)) != 0)
3271 goto err;
3272 out:
3273
3274 err:
3275 __os_free(env, argp);
3276 return (ret);
3277 }
3278
3279 /*
3280 * PUBLIC: int __heap_addrem_60_verify
3281 * PUBLIC: __P((ENV *, DBT *, DB_LSN *, db_recops, void *));
3282 */
3283 int
__heap_addrem_60_verify(env,dbtp,lsnp,notused2,lvhp)3284 __heap_addrem_60_verify(env, dbtp, lsnp, notused2, lvhp)
3285 ENV *env;
3286 DBT *dbtp;
3287 DB_LSN *lsnp;
3288 db_recops notused2;
3289 void *lvhp;
3290 {
3291 __heap_addrem_60_args *argp;
3292 DB_LOG_VRFY_INFO *lvh;
3293 int ret;
3294
3295 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
3296 lvh = (DB_LOG_VRFY_INFO *)lvhp;
3297
3298 if ((ret =
3299 __heap_addrem_60_read(env, NULL, NULL, dbtp->data, &argp)) != 0)
3300 return (ret);
3301
3302 LOG_VRFY_PROC(lvh, *lsnp, argp, argp->fileid);
3303 ON_PAGE_UPDATE(lvh, *lsnp, argp, argp->pgno);
3304 if ((ret = __lv_on_heap_log(lvh, *lsnp, argp->fileid)) != 0)
3305 goto err;
3306 out:
3307
3308 err:
3309 __os_free(env, argp);
3310 return (ret);
3311 }
3312
3313 /*
3314 * PUBLIC: int __heap_pg_alloc_verify
3315 * PUBLIC: __P((ENV *, DBT *, DB_LSN *, db_recops, void *));
3316 */
3317 int
__heap_pg_alloc_verify(env,dbtp,lsnp,notused2,lvhp)3318 __heap_pg_alloc_verify(env, dbtp, lsnp, notused2, lvhp)
3319 ENV *env;
3320 DBT *dbtp;
3321 DB_LSN *lsnp;
3322 db_recops notused2;
3323 void *lvhp;
3324 {
3325 __heap_pg_alloc_args *argp;
3326 DB_LOG_VRFY_INFO *lvh;
3327 int ret;
3328
3329 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
3330 lvh = (DB_LOG_VRFY_INFO *)lvhp;
3331
3332 if ((ret =
3333 __heap_pg_alloc_read(env, NULL, NULL, dbtp->data, &argp)) != 0)
3334 return (ret);
3335
3336 LOG_VRFY_PROC(lvh, *lsnp, argp, argp->fileid);
3337 ON_PAGE_UPDATE(lvh, *lsnp, argp, argp->pgno);
3338 if ((ret = __lv_on_heap_log(lvh, *lsnp, argp->fileid)) != 0)
3339 goto err;
3340 out:
3341
3342 err:
3343 __os_free(env, argp);
3344 return (ret);
3345 }
3346
3347 /*
3348 * PUBLIC: int __heap_trunc_meta_verify
3349 * PUBLIC: __P((ENV *, DBT *, DB_LSN *, db_recops, void *));
3350 */
3351 int
__heap_trunc_meta_verify(env,dbtp,lsnp,notused2,lvhp)3352 __heap_trunc_meta_verify(env, dbtp, lsnp, notused2, lvhp)
3353 ENV *env;
3354 DBT *dbtp;
3355 DB_LSN *lsnp;
3356 db_recops notused2;
3357 void *lvhp;
3358 {
3359 __heap_trunc_meta_args *argp;
3360 DB_LOG_VRFY_INFO *lvh;
3361 int ret;
3362
3363 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
3364 lvh = (DB_LOG_VRFY_INFO *)lvhp;
3365
3366 if ((ret =
3367 __heap_trunc_meta_read(env, NULL, NULL, dbtp->data, &argp)) != 0)
3368 return (ret);
3369
3370 LOG_VRFY_PROC(lvh, *lsnp, argp, argp->fileid);
3371 ON_PAGE_UPDATE(lvh, *lsnp, argp, argp->pgno);
3372 if ((ret = __lv_on_heap_log(lvh, *lsnp, argp->fileid)) != 0)
3373 goto err;
3374 out:
3375
3376 err:
3377
3378 __os_free(env, argp);
3379 return (ret);
3380 }
3381
3382 /*
3383 * PUBLIC: int __heap_trunc_page_verify
3384 * PUBLIC: __P((ENV *, DBT *, DB_LSN *, db_recops, void *));
3385 */
3386 int
__heap_trunc_page_verify(env,dbtp,lsnp,notused2,lvhp)3387 __heap_trunc_page_verify(env, dbtp, lsnp, notused2, lvhp)
3388 ENV *env;
3389 DBT *dbtp;
3390 DB_LSN *lsnp;
3391 db_recops notused2;
3392 void *lvhp;
3393 {
3394 __heap_trunc_page_args *argp;
3395 DB_LOG_VRFY_INFO *lvh;
3396 int ret;
3397
3398 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
3399 lvh = (DB_LOG_VRFY_INFO *)lvhp;
3400
3401 if ((ret =
3402 __heap_trunc_page_read(env, NULL, NULL, dbtp->data, &argp)) != 0)
3403 return (ret);
3404
3405 LOG_VRFY_PROC(lvh, *lsnp, argp, argp->fileid);
3406 ON_PAGE_UPDATE(lvh, *lsnp, argp, argp->pgno);
3407 if ((ret = __lv_on_heap_log(lvh, *lsnp, argp->fileid)) != 0)
3408 goto err;
3409 out:
3410
3411 err:
3412 __os_free(env, argp);
3413 return (ret);
3414 }
3415 #endif
3416
3417 #ifdef HAVE_QUEUE
3418 /*
3419 * PUBLIC: int __qam_incfirst_verify __P((ENV *, DBT *, DB_LSN *,
3420 * PUBLIC: db_recops, void *));
3421 */
3422 int
__qam_incfirst_verify(env,dbtp,lsnp,notused2,lvhp)3423 __qam_incfirst_verify(env, dbtp, lsnp, notused2, lvhp)
3424 ENV *env;
3425 DBT *dbtp;
3426 DB_LSN *lsnp;
3427 db_recops notused2;
3428 void *lvhp;
3429 {
3430 __qam_incfirst_args *argp;
3431 DB_LOG_VRFY_INFO *lvh;
3432 int ret;
3433
3434 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
3435 lvh = (DB_LOG_VRFY_INFO *)lvhp;
3436
3437 if ((ret =
3438 __qam_incfirst_read(env, NULL, NULL, dbtp->data, &argp)) != 0)
3439 return (ret);
3440
3441 LOG_VRFY_PROC(lvh, *lsnp, argp, argp->fileid);
3442 if ((ret = __lv_on_qam_log(lvh, *lsnp, argp->fileid)) != 0)
3443 goto err;
3444
3445 out:
3446
3447 err:
3448
3449 __os_free(env, argp);
3450
3451 return (ret);
3452 }
3453
3454 /*
3455 * PUBLIC: int __qam_mvptr_verify __P((ENV *, DBT *, DB_LSN *,
3456 * PUBLIC: db_recops, void *));
3457 */
3458 int
__qam_mvptr_verify(env,dbtp,lsnp,notused2,lvhp)3459 __qam_mvptr_verify(env, dbtp, lsnp, notused2, lvhp)
3460 ENV *env;
3461 DBT *dbtp;
3462 DB_LSN *lsnp;
3463 db_recops notused2;
3464 void *lvhp;
3465 {
3466 __qam_mvptr_args *argp;
3467 DB_LOG_VRFY_INFO *lvh;
3468 int ret;
3469
3470 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
3471 lvh = (DB_LOG_VRFY_INFO *)lvhp;
3472
3473 if ((ret =
3474 __qam_mvptr_read(env, NULL, NULL, dbtp->data, &argp)) != 0)
3475 return (ret);
3476
3477 LOG_VRFY_PROC(lvh, *lsnp, argp, argp->fileid);
3478 if ((ret = __lv_on_qam_log(lvh, *lsnp, argp->fileid)) != 0)
3479 goto err;
3480
3481 out:
3482
3483 err:
3484
3485 __os_free(env, argp);
3486
3487 return (ret);
3488 }
3489
3490 /*
3491 * PUBLIC: int __qam_del_verify __P((ENV *, DBT *, DB_LSN *,
3492 * PUBLIC: db_recops, void *));
3493 */
3494 int
__qam_del_verify(env,dbtp,lsnp,notused2,lvhp)3495 __qam_del_verify(env, dbtp, lsnp, notused2, lvhp)
3496 ENV *env;
3497 DBT *dbtp;
3498 DB_LSN *lsnp;
3499 db_recops notused2;
3500 void *lvhp;
3501 {
3502 __qam_del_args *argp;
3503 DB_LOG_VRFY_INFO *lvh;
3504 int ret;
3505
3506 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
3507 lvh = (DB_LOG_VRFY_INFO *)lvhp;
3508
3509 if ((ret =
3510 __qam_del_read(env, NULL, NULL, dbtp->data, &argp)) != 0)
3511 return (ret);
3512
3513 LOG_VRFY_PROC(lvh, *lsnp, argp, argp->fileid);
3514 if ((ret = __lv_on_qam_log(lvh, *lsnp, argp->fileid)) != 0)
3515 goto err;
3516
3517 out:
3518
3519 err:
3520
3521 __os_free(env, argp);
3522
3523 return (ret);
3524 }
3525
3526 /*
3527 * PUBLIC: int __qam_add_verify __P((ENV *, DBT *, DB_LSN *,
3528 * PUBLIC: db_recops, void *));
3529 */
3530 int
__qam_add_verify(env,dbtp,lsnp,notused2,lvhp)3531 __qam_add_verify(env, dbtp, lsnp, notused2, lvhp)
3532 ENV *env;
3533 DBT *dbtp;
3534 DB_LSN *lsnp;
3535 db_recops notused2;
3536 void *lvhp;
3537 {
3538 __qam_add_args *argp;
3539 DB_LOG_VRFY_INFO *lvh;
3540 int ret;
3541
3542 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
3543 lvh = (DB_LOG_VRFY_INFO *)lvhp;
3544
3545 if ((ret =
3546 __qam_add_read(env, NULL, NULL, dbtp->data, &argp)) != 0)
3547 return (ret);
3548
3549 LOG_VRFY_PROC(lvh, *lsnp, argp, argp->fileid);
3550 if ((ret = __lv_on_qam_log(lvh, *lsnp, argp->fileid)) != 0)
3551 goto err;
3552
3553 out:
3554
3555 err:
3556
3557 __os_free(env, argp);
3558
3559 return (ret);
3560 }
3561
3562 /*
3563 * PUBLIC: int __qam_delext_verify __P((ENV *, DBT *, DB_LSN *,
3564 * PUBLIC: db_recops, void *));
3565 */
3566 int
__qam_delext_verify(env,dbtp,lsnp,notused2,lvhp)3567 __qam_delext_verify(env, dbtp, lsnp, notused2, lvhp)
3568 ENV *env;
3569 DBT *dbtp;
3570 DB_LSN *lsnp;
3571 db_recops notused2;
3572 void *lvhp;
3573 {
3574 __qam_delext_args *argp;
3575 DB_LOG_VRFY_INFO *lvh;
3576 int ret;
3577
3578 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
3579 lvh = (DB_LOG_VRFY_INFO *)lvhp;
3580
3581 if ((ret =
3582 __qam_delext_read(env, NULL, NULL, dbtp->data, &argp)) != 0)
3583 return (ret);
3584
3585 LOG_VRFY_PROC(lvh, *lsnp, argp, INVAL_DBREGID);
3586 if ((ret = __lv_on_qam_log(lvh, *lsnp, argp->fileid)) != 0)
3587 goto err;
3588
3589 out:
3590
3591 err:
3592
3593 __os_free(env, argp);
3594
3595 return (ret);
3596 }
3597 #endif
3598
3599 /*
3600 * PUBLIC: int __txn_regop_42_verify __P((ENV *, DBT *, DB_LSN *,
3601 * PUBLIC: db_recops, void *));
3602 */
3603 int
__txn_regop_42_verify(env,dbtp,lsnp,notused2,lvhp)3604 __txn_regop_42_verify(env, dbtp, lsnp, notused2, lvhp)
3605 ENV *env;
3606 DBT *dbtp;
3607 DB_LSN *lsnp;
3608 db_recops notused2;
3609 void *lvhp;
3610 {
3611 __txn_regop_42_args *argp;
3612 DB_LOG_VRFY_INFO *lvh;
3613 int ret;
3614
3615 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
3616 lvh = (DB_LOG_VRFY_INFO *)lvhp;
3617
3618 if ((ret = __txn_regop_42_read(env, dbtp->data, &argp)) != 0)
3619 return (ret);
3620
3621 ON_NOT_SUPPORTED(env, lvh, *lsnp, argp->type);
3622 /* LOG_VRFY_PROC(lvh, *lsnp, argp, INVAL_DBREGID); */
3623 err:
3624
3625 __os_free(env, argp);
3626
3627 return (ret);
3628 }
3629
3630 /*
3631 * PUBLIC: int __txn_regop_verify __P((ENV *, DBT *, DB_LSN *,
3632 * PUBLIC: db_recops, void *));
3633 */
3634 int
__txn_regop_verify(env,dbtp,lsnp,notused2,lvhp)3635 __txn_regop_verify(env, dbtp, lsnp, notused2, lvhp)
3636 ENV *env;
3637 DBT *dbtp;
3638 DB_LSN *lsnp;
3639 db_recops notused2;
3640 void *lvhp;
3641 {
3642 __txn_regop_args *argp;
3643 DB_LOG_VRFY_INFO *lvh;
3644 int ret, ret2, started;
3645 VRFY_TXN_INFO *ptvi, *pptvi;
3646 VRFY_TIMESTAMP_INFO tsinfo;
3647
3648 ptvi = pptvi = NULL;
3649 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
3650 lvh = (DB_LOG_VRFY_INFO *)lvhp;
3651 ret = ret2 = started = 0;
3652
3653 if ((ret = __txn_regop_read(env, dbtp->data, &argp)) != 0)
3654 return (ret);
3655
3656 /*
3657 * The __lv_log_fwdscr_oncmt call must precede LOG_VRFY_PROC otherwise
3658 * this txn will be taken as an aborted txn.
3659 */
3660 if (F_ISSET(lvh, DB_LOG_VERIFY_FORWARD)) {
3661 if ((ret = __lv_log_fwdscr_oncmt(lvh, *lsnp,
3662 argp->txnp->txnid, 0, argp->timestamp)) != 0)
3663 goto err;
3664
3665 tsinfo.lsn = *lsnp;
3666 tsinfo.timestamp = argp->timestamp;
3667 tsinfo.logtype = argp->type;
3668 if ((ret = __put_timestamp_info(lvh, &tsinfo)) != 0)
3669 goto err;
3670 goto out; /* We are done. */
3671 }
3672
3673 LOG_VRFY_PROC(lvh, *lsnp, argp, INVAL_DBREGID);
3674 if ((ret = __del_txn_pages(lvh, argp->txnp->txnid)) != 0 &&
3675 ret != DB_NOTFOUND)
3676 goto err;/* Some txns may have updated no pages. */
3677 if ((ret = __lv_on_timestamp(lvh, lsnp, argp->timestamp,
3678 DB___txn_regop)) != 0)
3679 goto err;
3680 if ((ret = __get_txn_vrfy_info(lvh, argp->txnp->txnid, &ptvi)) != 0 &&
3681 ret != DB_NOTFOUND)
3682 goto err;
3683 if (ret == DB_NOTFOUND && !F_ISSET(lvh, DB_LOG_VERIFY_PARTIAL)) {
3684 if (!IS_ZERO_LSN(lvh->lv_config->start_lsn) &&
3685 (ret2 = __txn_started(lvh, lvh->lv_config->start_lsn,
3686 argp->txnp->txnid, &started)) == 0 && started != 0) {
3687 ret = 0;
3688 goto err;
3689 }
3690 if (ret2 != 0)
3691 ret = ret2;
3692 __db_errx(lvh->dbenv->env, DB_STR_A("2547",
3693 "[%lu][%lu] Can not find an active transaction's "
3694 "information, txnid: %lx.", "%lu %lu %lx"),
3695 (u_long)lsnp->file, (u_long)lsnp->offset,
3696 (u_long)argp->txnp->txnid);
3697 ON_ERROR(lvh, DB_LOG_VERIFY_INTERR);
3698
3699 }
3700
3701 if (ptvi == NULL) {
3702 if (ret == DB_NOTFOUND &&
3703 F_ISSET(lvh, DB_LOG_VERIFY_PARTIAL))
3704 ret = 0;
3705 goto out;
3706
3707 }
3708 DB_ASSERT(env, ptvi->ptxnid == 0);
3709
3710 /*
3711 * This log record is only logged when committing a outermost txn,
3712 * child txn commits are logged in __txn_child_log.
3713 */
3714 if (ptvi->ptxnid == 0) {
3715 if (ptvi->status == TXN_STAT_PREPARE)
3716 lvh->ntxn_prep--;
3717 else if (ptvi->status == TXN_STAT_ACTIVE)
3718 lvh->ntxn_active--;
3719 lvh->ntxn_commit++;
3720 }
3721 ptvi->status = TXN_STAT_COMMIT;
3722 DB_ASSERT(env, IS_ZERO_LSN(ptvi->last_lsn));
3723 ptvi->last_lsn = *lsnp;
3724 if ((ret = __put_txn_vrfy_info(lvh, ptvi)) != 0)
3725 goto err;
3726
3727 /* Report txn stats. */
3728 if (F_ISSET(lvh, DB_LOG_VERIFY_VERBOSE))
3729 __db_msg(env, DB_STR_A("2548",
3730 "[%lu][%lu] The number of active, committed and aborted "
3731 "child txns of txn %lx: %u, %u, %u.",
3732 "%lu %lu %lx %u %u %u"), (u_long)lsnp->file,
3733 (u_long)lsnp->offset, (u_long)ptvi->txnid,
3734 ptvi->nchild_active, ptvi->nchild_commit,
3735 ptvi->nchild_abort);
3736 out:
3737 err:
3738
3739 if (pptvi != NULL && (ret2 = __free_txninfo(pptvi)) != 0 && ret == 0)
3740 ret = ret2;
3741 if (ptvi != NULL && (ret2 = __free_txninfo(ptvi)) != 0 && ret == 0)
3742 ret = ret2;
3743 __os_free(env, argp);
3744
3745 return (ret);
3746 }
3747
3748 /*
3749 * PUBLIC: int __txn_ckp_42_verify __P((ENV *, DBT *, DB_LSN *,
3750 * PUBLIC: db_recops, void *));
3751 */
3752 int
__txn_ckp_42_verify(env,dbtp,lsnp,notused2,lvhp)3753 __txn_ckp_42_verify(env, dbtp, lsnp, notused2, lvhp)
3754 ENV *env;
3755 DBT *dbtp;
3756 DB_LSN *lsnp;
3757 db_recops notused2;
3758 void *lvhp;
3759 {
3760 __txn_ckp_42_args *argp;
3761 DB_LOG_VRFY_INFO *lvh;
3762 int ret;
3763
3764 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
3765 lvh = (DB_LOG_VRFY_INFO *)lvhp;
3766
3767 if ((ret = __txn_ckp_42_read(env, dbtp->data, &argp)) != 0)
3768 return (ret);
3769
3770 ON_NOT_SUPPORTED(env, lvh, *lsnp, argp->type);
3771 /* LOG_VRFY_PROC(lvh, *lsnp, argp, INVAL_DBREGID); */
3772 err:
3773
3774 __os_free(env, argp);
3775
3776 return (ret);
3777 }
3778
3779 /*
3780 * PUBLIC: int __txn_ckp_verify __P((ENV *, DBT *, DB_LSN *,
3781 * PUBLIC: db_recops, void *));
3782 */
3783 int
__txn_ckp_verify(env,dbtp,lsnp,notused2,lvhp)3784 __txn_ckp_verify(env, dbtp, lsnp, notused2, lvhp)
3785 ENV *env;
3786 DBT *dbtp;
3787 DB_LSN *lsnp;
3788 db_recops notused2;
3789 void *lvhp;
3790 {
3791 __txn_ckp_args *argp;
3792 DB_LOG_VRFY_INFO *lvh;
3793 VRFY_CKP_INFO *lastckp, ckpinfo;
3794 int ret;
3795 struct __ckp_verify_params cvp;
3796 VRFY_TIMESTAMP_INFO tsinfo;
3797 char timebuf[CTIME_BUFLEN];
3798 time_t ckp_time, lastckp_time;
3799
3800 lastckp = NULL;
3801 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
3802 lvh = (DB_LOG_VRFY_INFO *)lvhp;
3803 memset(&ckpinfo, 0, sizeof(ckpinfo));
3804 memset(&cvp, 0, sizeof(cvp));
3805
3806 if ((ret = __txn_ckp_read(env, dbtp->data, &argp)) != 0)
3807 return (ret);
3808
3809 LOG_VRFY_PROC(lvh, *lsnp, argp, INVAL_DBREGID);
3810
3811 if (F_ISSET(lvh, DB_LOG_VERIFY_FORWARD)) {
3812 tsinfo.lsn = *lsnp;
3813 tsinfo.timestamp = argp->timestamp;
3814 tsinfo.logtype = argp->type;
3815 /*
3816 * Store the first ckp_lsn, or the least one greater than the
3817 * starting point. There will be no partial txns after
3818 * valid_lsn.
3819 */
3820 if (!(!IS_ZERO_LSN(lvh->lv_config->start_lsn) &&
3821 LOG_COMPARE(&(lvh->lv_config->start_lsn),
3822 &(argp->ckp_lsn)) > 0))
3823 lvh->valid_lsn = argp->ckp_lsn;
3824 if ((ret = __put_timestamp_info(lvh, &tsinfo)) != 0)
3825 goto err;
3826 goto out;/* We are done, exit. */
3827 }
3828 lvh->nckp++;
3829 ckp_time = (time_t)argp->timestamp;
3830 __db_msg(env, DB_STR_A("2549",
3831 "[%lu][%lu] Checkpoint record, ckp_lsn: [%lu][%lu], "
3832 "timestamp: %s. Total checkpoint: %u",
3833 "%lu %lu %lu %lu %s %u"), (u_long)lsnp->file,
3834 (u_long)lsnp->offset, (u_long)argp->ckp_lsn.file,
3835 (u_long)argp->ckp_lsn.offset,
3836 __os_ctime(&ckp_time, timebuf), lvh->nckp);
3837
3838 if ((ret = __lv_on_timestamp(lvh, lsnp,
3839 argp->timestamp, DB___txn_ckp)) != 0)
3840 goto err;
3841 if (((ret = __get_last_ckp_info(lvh, &lastckp)) != 0) &&
3842 ret != DB_NOTFOUND)
3843 return (ret);
3844 if (ret == DB_NOTFOUND)
3845 goto cont;
3846
3847 if (LOG_COMPARE(&(argp->last_ckp), &(lastckp->lsn)) != 0) {
3848 __db_errx(env, DB_STR_A("2550",
3849 "[%lu][%lu] Last known checkpoint [%lu][%lu] not equal "
3850 "to last_ckp :[%lu][%lu]. Some checkpoint log records "
3851 "may be missing.", "%lu %lu %lu %lu %lu %lu"),
3852 (u_long)lsnp->file, (u_long)lsnp->offset,
3853 (u_long)lastckp->lsn.file, (u_long)lastckp->lsn.offset,
3854 (u_long)argp->last_ckp.file, (u_long)argp->last_ckp.offset);
3855 ret = DB_LOG_VERIFY_BAD;
3856 ON_ERROR(lvh, DB_LOG_VERIFY_ERR);
3857 }
3858
3859 /*
3860 * Checkpoint are generally not performed quite often, so we see this
3861 * as an error, but in txn commits we see it as a warning.
3862 */
3863 lastckp_time = (time_t)lastckp->timestamp;
3864 if (argp->timestamp < lastckp->timestamp) {
3865 __db_errx(env, DB_STR_A("2551",
3866 "[%lu][%lu] Last known checkpoint [%lu, %lu] has a "
3867 "timestamp %s smaller than this checkpoint timestamp %s.",
3868 "%lu %lu %lu %lu %s %s"), (u_long)lsnp->file,
3869 (u_long)lsnp->offset, (u_long)lastckp->lsn.file,
3870 (u_long)lastckp->lsn.offset,
3871 __os_ctime(&lastckp_time, timebuf),
3872 __os_ctime(&ckp_time, timebuf));
3873 ret = DB_LOG_VERIFY_BAD;
3874 ON_ERROR(lvh, DB_LOG_VERIFY_ERR);
3875 }
3876
3877 cont:
3878 cvp.env = env;
3879 cvp.lsn = *lsnp;
3880 cvp.ckp_lsn = argp->ckp_lsn;
3881
3882 /*
3883 * Verify that all active txn's first lsn is greater than
3884 * argp->ckp_lsn.
3885 */
3886 if ((ret = __iterate_txninfo(lvh, 0, 0,
3887 __lv_ckp_vrfy_handler, &cvp)) != 0)
3888 ON_ERROR(lvh, DB_LOG_VERIFY_ERR);
3889 ckpinfo.timestamp = argp->timestamp;
3890 ckpinfo.lsn = *lsnp;
3891 ckpinfo.ckplsn = argp->ckp_lsn;
3892
3893 if ((ret = __put_ckp_info(lvh, &ckpinfo)) != 0)
3894 goto err;
3895 out:
3896 err:
3897 if (argp)
3898 __os_free(env, argp);
3899 if (lastckp)
3900 __os_free(env, lastckp);
3901 return (ret);
3902 }
3903
3904 static int
__lv_ckp_vrfy_handler(lvinfo,txninfop,param)3905 __lv_ckp_vrfy_handler(lvinfo, txninfop, param)
3906 DB_LOG_VRFY_INFO *lvinfo;
3907 VRFY_TXN_INFO *txninfop;
3908 void *param;
3909 {
3910 struct __ckp_verify_params *cvp;
3911 int ret;
3912
3913 ret = 0;
3914 cvp = (struct __ckp_verify_params *)param;
3915 /* ckp_lsn should be less than any active txn's first lsn. */
3916 if (txninfop->status == TXN_STAT_ACTIVE && LOG_COMPARE(&(cvp->ckp_lsn),
3917 &(txninfop->first_lsn)) >= 0) {
3918 __db_errx(cvp->env, DB_STR_A("2552",
3919 "[%lu][%lu] ckp log's ckp_lsn [%lu][%lu] greater than "
3920 "active txn %lx 's first lsn [%lu][%lu]",
3921 "%lu %lu %lu %lu %lx %lu %lu"),
3922 (u_long)cvp->lsn.file, (u_long)cvp->lsn.offset,
3923 (u_long)cvp->ckp_lsn.file, (u_long)cvp->ckp_lsn.offset,
3924 (u_long)txninfop->txnid,
3925 (u_long)txninfop->first_lsn.file,
3926 (u_long)txninfop->first_lsn.offset);
3927 lvinfo->flags |= DB_LOG_VERIFY_ERR;
3928 if (!F_ISSET(lvinfo, DB_LOG_VERIFY_CAF))
3929 /* Stop the iteration. */
3930 ret = DB_LOG_VERIFY_BAD;
3931 }
3932
3933 return (ret);
3934 }
3935
3936 /*
3937 * PUBLIC: int __txn_child_verify __P((ENV *, DBT *, DB_LSN *,
3938 * PUBLIC: db_recops, void *));
3939 */
3940 int
__txn_child_verify(env,dbtp,lsnp,notused2,lvhp)3941 __txn_child_verify(env, dbtp, lsnp, notused2, lvhp)
3942 ENV *env;
3943 DBT *dbtp;
3944 DB_LSN *lsnp;
3945 db_recops notused2;
3946 void *lvhp;
3947 {
3948 __txn_child_args *argp;
3949 DB_LOG_VRFY_INFO *lvh;
3950 VRFY_TXN_INFO *ptvi, *ptvi2;
3951 int ret, ret2, started;
3952
3953 /*
3954 * This function is called when a txn T0's child txn T1 commits. Before
3955 * this log record we don't know T0 and T1's relationship. This means
3956 * we never know the T0 has an active child txn T1, all child txns
3957 * we know are committed.
3958 */
3959 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
3960 lvh = (DB_LOG_VRFY_INFO *)lvhp;
3961 ptvi = ptvi2 = NULL;
3962 ret = ret2 = started = 0;
3963
3964 if ((ret = __txn_child_read(env, dbtp->data, &argp)) != 0)
3965 return (ret);
3966
3967 /*
3968 * The __lv_log_fwdscr_oncmt call must precede LOG_VRFY_PROC otherwise
3969 * this txn will be taken as an aborted txn.
3970 */
3971 if (F_ISSET(lvh, DB_LOG_VERIFY_FORWARD)) {
3972 if ((ret = __lv_log_fwdscr_oncmt(lvh, argp->c_lsn, argp->child,
3973 argp->txnp->txnid, 0)) != 0)
3974 goto err;
3975 if ((ret = __lv_log_fwdscr_onrec(lvh, argp->txnp->txnid,
3976 argp->type, argp->prev_lsn, *lsnp)) != 0)
3977 goto err;
3978 goto out;/* We are done. */
3979 }
3980 LOG_VRFY_PROC(lvh, *lsnp, argp, INVAL_DBREGID);
3981 if ((ret = __return_txn_pages(lvh, argp->child,
3982 argp->txnp->txnid)) != 0 && ret != DB_NOTFOUND)
3983 goto err;/* Some txns may have updated no pages. */
3984
3985 /* Update parent txn info. */
3986 if ((ret = __get_txn_vrfy_info(lvh, argp->txnp->txnid, &ptvi)) != 0 &&
3987 ret != DB_NOTFOUND)
3988 goto err;
3989 if (ret == DB_NOTFOUND && !F_ISSET(lvh, DB_LOG_VERIFY_PARTIAL)) {
3990 if (!IS_ZERO_LSN(lvh->lv_config->start_lsn) &&
3991 ((ret2 = __txn_started(lvh, lvh->lv_config->start_lsn,
3992 argp->txnp->txnid, &started)) == 0) && started != 0) {
3993 ret = 0;
3994 goto err;
3995 }
3996 if (ret2 != 0)
3997 ret = ret2;
3998 __db_errx(lvh->dbenv->env, DB_STR_A("2547",
3999 "[%lu][%lu] Can not find an active transaction's "
4000 "information, txnid: %lx.", "%lu %lu %lx"),
4001 (u_long)lsnp->file, (u_long)lsnp->offset,
4002 (u_long)argp->txnp->txnid);
4003 ON_ERROR(lvh, DB_LOG_VERIFY_INTERR);
4004
4005 }
4006 if (ptvi == NULL) {
4007 if (ret == DB_NOTFOUND &&
4008 F_ISSET(lvh, DB_LOG_VERIFY_PARTIAL))
4009 ret = 0;
4010 goto out;
4011
4012 }
4013 ptvi->nchild_commit++;
4014 /*
4015 * The start of this child txn caused lvh->ntxn_active to be
4016 * incremented unnecessarily, so decrement it.
4017 */
4018 lvh->ntxn_active--;
4019 if (ptvi->status != TXN_STAT_ACTIVE) {
4020 __db_errx(lvh->dbenv->env, DB_STR_A("2554",
4021 "[%lu][%lu] Parent txn %lx ended "
4022 "before child txn %lx ends.", "%lu %lu %lx %lx"),
4023 (u_long)lsnp->file, (u_long)lsnp->offset,
4024 (u_long)argp->txnp->txnid, (u_long)argp->child);
4025 ON_ERROR(lvh, DB_LOG_VERIFY_ERR);
4026 }
4027 if ((ret = __put_txn_vrfy_info(lvh, ptvi)) != 0)
4028 goto err;
4029
4030 /* Update child txn info. */
4031 if ((ret = __get_txn_vrfy_info(lvh, argp->child, &ptvi2)) != 0 &&
4032 ret != DB_NOTFOUND)
4033 goto err;
4034 if (ret == DB_NOTFOUND && !F_ISSET(lvh, DB_LOG_VERIFY_PARTIAL)) {
4035 if (!IS_ZERO_LSN(lvh->lv_config->start_lsn) &&
4036 ((ret2 = __txn_started(lvh, lvh->lv_config->start_lsn,
4037 argp->child, &started)) == 0) && started != 0) {
4038 ret = 0;
4039 goto err;
4040 }
4041 if (ret2 != 0)
4042 ret = ret2;
4043 __db_errx(lvh->dbenv->env, DB_STR_A("2547",
4044 "[%lu][%lu] Can not find an active "
4045 "transaction's information, txnid: %lx.",
4046 "%lu %lu %lx"), (u_long)lsnp->file,
4047 (u_long)lsnp->offset, (u_long)argp->child);
4048 ON_ERROR(lvh, DB_LOG_VERIFY_INTERR);
4049
4050 }
4051 if (ptvi2 == NULL) {
4052 if (ret == DB_NOTFOUND &&
4053 F_ISSET(lvh, DB_LOG_VERIFY_PARTIAL))
4054 ret = 0;
4055 goto out;
4056
4057 }
4058 if (ptvi2->status != TXN_STAT_ACTIVE) {
4059 __db_errx(lvh->dbenv->env, DB_STR_A("2556",
4060 "[%lu][%lu] Txn %lx ended before it commits.",
4061 "%lu %lu %lx"), (u_long)lsnp->file,
4062 (u_long)lsnp->offset, (u_long)argp->child);
4063 ON_ERROR(lvh, DB_LOG_VERIFY_ERR);
4064 }
4065 ptvi2->status = TXN_STAT_COMMIT;
4066 if ((ret = __put_txn_vrfy_info(lvh, ptvi2)) != 0)
4067 goto err;
4068 out:
4069 err:
4070 __os_free(env, argp);
4071 if (ptvi != NULL && (ret2 = __free_txninfo(ptvi)) != 0 && ret == 0)
4072 ret = ret2;
4073 if (ptvi2 != NULL && (ret2 = __free_txninfo(ptvi2)) != 0 && ret == 0)
4074 ret = ret2;
4075
4076 return (ret);
4077 }
4078
4079 /*
4080 * PUBLIC: int __txn_xa_regop_42_verify __P((ENV *, DBT *, DB_LSN *,
4081 * PUBLIC: db_recops, void *));
4082 */
4083 int
__txn_xa_regop_42_verify(env,dbtp,lsnp,notused2,lvhp)4084 __txn_xa_regop_42_verify(env, dbtp, lsnp, notused2, lvhp)
4085 ENV *env;
4086 DBT *dbtp;
4087 DB_LSN *lsnp;
4088 db_recops notused2;
4089 void *lvhp;
4090 {
4091 __txn_xa_regop_42_args *argp;
4092 DB_LOG_VRFY_INFO *lvh;
4093 int ret;
4094
4095 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
4096 lvh = (DB_LOG_VRFY_INFO *)lvhp;
4097
4098 if ((ret = __txn_xa_regop_42_read(env, dbtp->data, &argp)) != 0)
4099 return (ret);
4100
4101 ON_NOT_SUPPORTED(env, lvh, *lsnp, argp->type);
4102 /* LOG_VRFY_PROC(lvh, *lsnp, argp, INVAL_DBREGID); */
4103 err:
4104 __os_free(env, argp);
4105
4106 return (ret);
4107 }
4108
4109 /*
4110 * PUBLIC: int __txn_prepare_verify __P((ENV *, DBT *, DB_LSN *,
4111 * PUBLIC: db_recops, void *));
4112 */
4113 int
__txn_prepare_verify(env,dbtp,lsnp,notused2,lvhp)4114 __txn_prepare_verify(env, dbtp, lsnp, notused2, lvhp)
4115 ENV *env;
4116 DBT *dbtp;
4117 DB_LSN *lsnp;
4118 db_recops notused2;
4119 void *lvhp;
4120 {
4121 __txn_prepare_args *argp;
4122 DB_LOG_VRFY_INFO *lvh;
4123 VRFY_TXN_INFO *ptvi;
4124 int ret, ret2, started;
4125
4126 ret = ret2 = started = 0;
4127 ptvi = NULL;
4128 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
4129 lvh = (DB_LOG_VRFY_INFO *)lvhp;
4130
4131 if ((ret = __txn_prepare_read(env, dbtp->data, &argp)) != 0)
4132 return (ret);
4133
4134 LOG_VRFY_PROC(lvh, *lsnp, argp, INVAL_DBREGID);
4135
4136 if ((ret = __get_txn_vrfy_info(lvh, argp->txnp->txnid, &ptvi)) != 0 &&
4137 ret != DB_NOTFOUND)
4138 goto err;
4139
4140 if (ret == DB_NOTFOUND && !F_ISSET(lvh, DB_LOG_VERIFY_PARTIAL)) {
4141 if (!IS_ZERO_LSN(lvh->lv_config->start_lsn) &&
4142 ((ret2 = __txn_started(lvh, lvh->lv_config->start_lsn,
4143 argp->txnp->txnid, &started)) == 0) && started != 0) {
4144 ret = 0;
4145 goto err;
4146 }
4147 if (ret2 != 0)
4148 ret = ret2;
4149 __db_errx(lvh->dbenv->env, DB_STR_A("2547",
4150 "[%lu][%lu] Can not find an active transaction's "
4151 "information, txnid: %lx.", "%lu %lu %lx"),
4152 (u_long)lsnp->file, (u_long)lsnp->offset,
4153 (u_long)argp->txnp->txnid);
4154 ON_ERROR(lvh, DB_LOG_VERIFY_INTERR);
4155
4156 }
4157 if (ptvi == NULL) {
4158 if (ret == DB_NOTFOUND &&
4159 F_ISSET(lvh, DB_LOG_VERIFY_PARTIAL))
4160 ret = 0;
4161 goto out;
4162
4163 }
4164 DB_ASSERT(env,
4165 (IS_ZERO_LSN(ptvi->prep_lsn) && ptvi->status != TXN_STAT_PREPARE) ||
4166 (!IS_ZERO_LSN(ptvi->prep_lsn) && ptvi->status == TXN_STAT_PREPARE));
4167
4168 lvh->ntxn_prep++;
4169 lvh->ntxn_active--;
4170
4171 if (!IS_ZERO_LSN(ptvi->prep_lsn)) {/* Prepared more than once. */
4172
4173 __db_errx(lvh->dbenv->env, DB_STR_A("2558",
4174 "[%lu][%lu] Multiple txn_prepare log record for "
4175 "transaction %lx, previous prepare lsn: [%lu, %lu].",
4176 "%lu %lu %lx %lu %lu"), (u_long)lsnp->file,
4177 (u_long)lsnp->offset, (u_long)argp->txnp->txnid,
4178 (u_long)ptvi->prep_lsn.file, (u_long)ptvi->prep_lsn.offset);
4179 } else {
4180 ptvi->prep_lsn = *lsnp;
4181 ptvi->status = TXN_STAT_PREPARE;
4182 }
4183 ret = __put_txn_vrfy_info(lvh, ptvi);
4184 out:
4185 err:
4186 __os_free(env, argp);
4187 if (ptvi != NULL && (ret2 = __free_txninfo(ptvi)) != 0 && ret == 0)
4188 ret = ret2;
4189 return (ret);
4190 }
4191
4192 /*
4193 * PUBLIC: int __txn_recycle_verify __P((ENV *, DBT *, DB_LSN *,
4194 * PUBLIC: db_recops, void *));
4195 */
4196 int
__txn_recycle_verify(env,dbtp,lsnp,notused2,lvhp)4197 __txn_recycle_verify(env, dbtp, lsnp, notused2, lvhp)
4198 ENV *env;
4199 DBT *dbtp;
4200 DB_LSN *lsnp;
4201 db_recops notused2;
4202 void *lvhp;
4203 {
4204 __txn_recycle_args *argp;
4205 DB_LOG_VRFY_INFO *lvh;
4206 int ret;
4207
4208 COMPQUIET(notused2, DB_TXN_LOG_VERIFY);
4209 lvh = (DB_LOG_VRFY_INFO *)lvhp;
4210 ret = 0;
4211
4212 if ((ret = __txn_recycle_read(env, dbtp->data, &argp)) != 0)
4213 return (ret);
4214
4215 LOG_VRFY_PROC(lvh, *lsnp, argp, INVAL_DBREGID);
4216
4217 /* Add recycle info for all txns whose ID is in the [min, max] range. */
4218 ret = __add_recycle_lsn_range(lvh, lsnp, argp->min, argp->max);
4219
4220 out:
4221
4222 err:
4223
4224 __os_free(env, argp);
4225 return (ret);
4226 }
4227
4228 /* Handle log types having timestamps, so far only __txn_ckp and __txn_regop. */
4229 static int
__lv_on_timestamp(lvh,lsn,timestamp,logtype)4230 __lv_on_timestamp(lvh, lsn, timestamp, logtype)
4231 DB_LOG_VRFY_INFO *lvh;
4232 const DB_LSN *lsn;
4233 int32_t timestamp;
4234 u_int32_t logtype;
4235 {
4236 VRFY_TIMESTAMP_INFO *ltsinfo;
4237 int ret;
4238
4239 ltsinfo = NULL;
4240 ret = 0;
4241 if ((ret = __get_latest_timestamp_info(lvh, *lsn, <sinfo)) == 0) {
4242 DB_ASSERT(lvh->dbenv->env, ltsinfo != NULL);
4243 if (ltsinfo->timestamp >= timestamp &&
4244 F_ISSET(lvh, DB_LOG_VERIFY_VERBOSE)) {
4245 __db_errx(lvh->dbenv->env, DB_STR_A("2559",
4246 "[%lu][%lu] [WARNING] This log record of type %s "
4247 "does not have a greater time stamp than "
4248 "[%lu, %lu] of type %s", "%lu %lu %s %lu %lu %s"),
4249 (u_long)lsn->file, (u_long)lsn->offset,
4250 LOGTYPE_NAME(lvh, logtype),
4251 (u_long)ltsinfo->lsn.file,
4252 (u_long)ltsinfo->lsn.offset,
4253 LOGTYPE_NAME(lvh, ltsinfo->logtype));
4254 lvh->flags |= DB_LOG_VERIFY_WARNING;
4255 }
4256 }
4257 if (ltsinfo != NULL)
4258 __os_free(lvh->dbenv->env, ltsinfo);
4259 if (ret == DB_NOTFOUND)
4260 ret = 0;
4261
4262 return (ret);
4263 }
4264
4265 /*
4266 * Called whenever the log record belongs to a transaction.
4267 */
4268 static int
__lv_on_txn_logrec(lvh,lsnp,prev_lsnp,txnp,type,dbregid)4269 __lv_on_txn_logrec(lvh, lsnp, prev_lsnp, txnp, type, dbregid)
4270 DB_LOG_VRFY_INFO *lvh;
4271 const DB_LSN *lsnp;
4272 const DB_LSN *prev_lsnp;
4273 const DB_TXN *txnp;
4274 u_int32_t type;
4275 int32_t dbregid;
4276 {
4277 DBT fid;
4278 VRFY_TXN_INFO *pvti;
4279 u_int32_t txnid;
4280 VRFY_FILEREG_INFO *fregp;
4281 int ret, ret2, started;
4282
4283 ret = ret2 = started = 0;
4284 pvti = NULL;
4285 fregp = NULL;
4286 lvh->lrtypes[type]++;/* Increment per-type log record count. */
4287 txnid = txnp->txnid;
4288 memset(&fid, 0, sizeof(fid));
4289
4290 if (dbregid == INVAL_DBREGID)
4291 goto cont;
4292 if ((ret = __get_filereg_by_dbregid(lvh, dbregid, &fregp)) != 0) {
4293 if (ret == DB_NOTFOUND) {
4294 /*
4295 * It's likely that we are verifying a subset of logs
4296 * and the DBREG_OPEN is outside the range.
4297 */
4298 if (!F_ISSET(lvh, DB_LOG_VERIFY_PARTIAL))
4299 __db_msg(lvh->dbenv->env, DB_STR_A("2560",
4300 "[%lu][%lu] Transaction %lx is updating a "
4301 "db file %d not registered.",
4302 "%lu %lu %lx %d"),
4303 (u_long)lsnp->file, (u_long)lsnp->offset,
4304 (u_long)txnp->txnid, dbregid);
4305 goto cont;
4306 } else
4307 goto err;
4308 }
4309
4310 fid = fregp->fileid;
4311 cont:
4312 if (IS_ZERO_LSN(*prev_lsnp) &&
4313 (ret = __lv_on_new_txn(lvh, lsnp, txnp, type, dbregid, &fid)) != 0)
4314 goto err;
4315
4316 if ((ret = __get_txn_vrfy_info(lvh, txnid, &pvti)) != 0 &&
4317 ret != DB_NOTFOUND)
4318 goto err;
4319
4320 /* If can't find the txn, there is an internal error. */
4321 if (ret == DB_NOTFOUND && !F_ISSET(lvh, DB_LOG_VERIFY_PARTIAL)) {
4322 /*
4323 * If verifying from middle, it's expected that txns begun
4324 * before start are not found.
4325 */
4326 if (!IS_ZERO_LSN(lvh->lv_config->start_lsn) && ((ret2 =
4327 __txn_started(lvh, lvh->lv_config->start_lsn, txnid,
4328 &started)) == 0) && started != 0) {
4329 ret = 0;
4330 goto out;/* We are done. */
4331 }
4332 if (ret2 != 0)
4333 ret = ret2;
4334
4335 __db_errx(lvh->dbenv->env, DB_STR_A("2547",
4336 "[%lu][%lu] Can not find an active transaction's "
4337 "information, txnid: %lx.", "%lu %lu %lx"),
4338 (u_long)lsnp->file, (u_long)lsnp->offset, (u_long)txnid);
4339 ON_ERROR(lvh, DB_LOG_VERIFY_INTERR);
4340 }
4341
4342 /* Can't proceed without the txn info. */
4343 if (pvti == NULL) {
4344 if (ret == DB_NOTFOUND && F_ISSET(lvh, DB_LOG_VERIFY_PARTIAL))
4345 ret = 0;
4346 goto out;
4347 }
4348
4349 /* Check if prev lsn is wrong, and some log records may be missing. */
4350 if (!IS_ZERO_LSN(*prev_lsnp) &&
4351 LOG_COMPARE(prev_lsnp, &(pvti->cur_lsn)) != 0) {
4352 __db_errx(lvh->dbenv->env, DB_STR_A("2562",
4353 "[%lu][%lu] Previous record for transaction %lx is "
4354 "[%lu][%lu] and prev_lsn is [%lu][%lu].",
4355 "%lu %lu %lx %lu %lu %lu %lu"), (u_long)lsnp->file,
4356 (u_long)lsnp->offset, (u_long)pvti->txnid,
4357 (u_long)pvti->cur_lsn.file, (u_long)pvti->cur_lsn.offset,
4358 (u_long)prev_lsnp->file, (u_long)prev_lsnp->offset);
4359 ret = DB_LOG_VERIFY_BAD;
4360 ON_ERROR(lvh, DB_LOG_VERIFY_ERR);
4361 }
4362
4363 /*
4364 * After the txn is prepared, the only valid log record for this txn
4365 * is the commit record.
4366 */
4367 if (pvti->status == TXN_STAT_PREPARE && type != DB___txn_regop) {
4368 __db_errx(lvh->dbenv->env, DB_STR_A("2563",
4369 "[%lu][%lu] Update action is performed in a "
4370 "prepared transaction %lx.", "%lu %lu %lx"),
4371 (u_long)lsnp->file, (u_long)lsnp->offset, (u_long)txnid);
4372 ret = DB_LOG_VERIFY_BAD;
4373 ON_ERROR(lvh, DB_LOG_VERIFY_ERR);
4374 }
4375 pvti->cur_lsn = *lsnp;
4376 pvti->flags = txnp->flags;
4377 if (dbregid != INVAL_DBREGID && fid.size > 0 &&
4378 (ret = __add_file_updated(pvti, &fid, dbregid)) != 0)
4379 goto err;
4380 if ((ret = __put_txn_vrfy_info(lvh, pvti)) != 0)
4381 goto err;
4382 out:
4383 err:
4384 if (pvti != NULL && (ret2 = __free_txninfo(pvti)) != 0 && ret == 0)
4385 ret = ret2;
4386 if (fregp != NULL &&
4387 (ret2 = __free_filereg_info(fregp)) != 0 && ret == 0)
4388 ret = ret2;
4389 return (ret);
4390 }
4391
4392 /*
4393 * Called whenever a new transaction is started, including child transactions.
4394 */
4395 static int
__lv_on_new_txn(lvh,lsnp,txnp,type,dbregid,fid)4396 __lv_on_new_txn (lvh, lsnp, txnp, type, dbregid, fid)
4397 DB_LOG_VRFY_INFO *lvh;
4398 const DB_LSN *lsnp;
4399 const DB_TXN *txnp;
4400 u_int32_t type;
4401 int32_t dbregid;
4402 const DBT *fid;
4403 {
4404 VRFY_TXN_INFO vti, *pvti, *vtip;
4405 int ret, tret;
4406 u_int32_t txnid;
4407 ENV *env;
4408
4409 ret = tret = 0;
4410 txnid = txnp->txnid;
4411 pvti = NULL;
4412 memset(&vti, 0, sizeof(vti));
4413 vti.txnid = txnid;
4414 env = lvh->dbenv->env;
4415 /* Log record type, may be used later. Pass lint checks. */
4416 COMPQUIET(type, 0);
4417
4418 /*
4419 * It's possible that the new txn is a child txn, we will decrement
4420 * this value in __txn_child_verify when we realize this, because
4421 * this value only records the number of outermost active txns.
4422 */
4423 lvh->ntxn_active++;
4424
4425 if ((ret = __get_txn_vrfy_info(lvh, txnid, &pvti)) != 0 &&
4426 ret != DB_NOTFOUND)
4427 goto err;
4428 if (ret == DB_NOTFOUND)
4429 vtip = &vti;
4430 else {/* The txnid is reused, may be illegal. */
4431 vtip = pvti;
4432 /*
4433 * If this txn id was recycled, this use is legal. A legal
4434 * recyclable txnid is immediately not recyclable after
4435 * it's recycled here. And it's impossible for vtip->status
4436 * to be TXN_STAT_ACTIVE, since we have made it TXN_STAT_ABORT
4437 * when we detected this txn id recycle just now.
4438 */
4439 if (vtip->num_recycle > 0 && LOG_COMPARE(&(vtip->recycle_lsns
4440 [vtip->num_recycle - 1]), lsnp) < 0) {
4441 DB_ASSERT(env, vtip->status != TXN_STAT_ACTIVE);
4442 if ((ret = __rem_last_recycle_lsn(vtip)) != 0)
4443 goto err;
4444 if ((ret = __clear_fileups(vtip)) != 0)
4445 goto err;
4446
4447 vtip->status = 0;
4448 ZERO_LSN(vtip->prep_lsn);
4449 ZERO_LSN(vtip->last_lsn);
4450
4451 vtip->nchild_active = 0;
4452 vtip->nchild_commit = 0;
4453 vtip->nchild_abort = 0;
4454 /*
4455 * We may goto the else branch if this txn has child txns
4456 * before any updates done on its behalf. So we should
4457 * exclude this possibility to conclude a failed verification.
4458 */
4459 } else if (vtip->nchild_active + vtip->nchild_commit +
4460 vtip->nchild_abort == 0) {
4461 __db_errx(env, DB_STR_A("2564",
4462 "[%lu][%lu] Transaction id %lx reused without "
4463 "being recycled with a __txn_recycle.",
4464 "%lu %lu %lx"),
4465 (u_long)lsnp->file, (u_long)lsnp->offset,
4466 (u_long)txnid);
4467 ret = DB_LOG_VERIFY_BAD;
4468 ON_ERROR(lvh, DB_LOG_VERIFY_ERR);
4469 }
4470 }
4471
4472 vtip->first_lsn = *lsnp;
4473 vtip->cur_lsn = *lsnp;
4474 vtip->flags = txnp->flags;
4475
4476 /*
4477 * It's possible that the first log rec does not update any file,
4478 * like the __txn_child type of record.
4479 */
4480 if (fid->size > 0 && (ret =
4481 __add_file_updated(vtip, fid, dbregid)) != 0)
4482 goto err;
4483 if ((ret = __put_txn_vrfy_info(lvh, vtip)) != 0)
4484 goto err;
4485
4486 err:
4487 if (pvti != NULL && (tret = __free_txninfo(pvti)) != 0 && ret == 0)
4488 ret = tret;
4489 if ((tret = __free_txninfo_stack(&vti)) != 0 && ret == 0)
4490 ret = tret;
4491
4492 return (ret);
4493 }
4494
4495 /* Called when we detect that a new log file is used. */
4496 static int
__lv_new_logfile_vrfy(lvh,lsnp)4497 __lv_new_logfile_vrfy(lvh, lsnp)
4498 DB_LOG_VRFY_INFO *lvh;
4499 const DB_LSN *lsnp;
4500 {
4501 int ret;
4502
4503 ret = 0;
4504 if (IS_ZERO_LSN(lvh->last_lsn) || lvh->last_lsn.file == lsnp->file) {
4505 lvh->last_lsn = *lsnp;
4506 return (0);
4507 }
4508
4509 /*
4510 * If file number changed, it must have been incremented,
4511 * and the offset is 0.
4512 * */
4513 if (lsnp->file - lvh->last_lsn.file != 1 || lsnp->offset !=
4514 __lv_first_offset(lvh->dbenv->env)) {
4515 __db_errx(lvh->dbenv->env,
4516 "[%lu][%lu] Last log record verified ([%lu][%lu]) is not "
4517 "immidiately before the current log record.",
4518 (u_long)lsnp->file, (u_long)lsnp->offset,
4519 (u_long)lvh->last_lsn.file, (u_long)lvh->last_lsn.offset);
4520 ret = DB_LOG_VERIFY_BAD;
4521 ON_ERROR(lvh, DB_LOG_VERIFY_ERR);
4522 }
4523
4524 lvh->last_lsn = *lsnp;
4525 err:
4526 return (ret);
4527 }
4528
4529 static u_int32_t
__lv_first_offset(env)4530 __lv_first_offset(env)
4531 ENV *env;
4532 {
4533 u_int32_t sz;
4534
4535 if (CRYPTO_ON(env))
4536 sz = HDR_CRYPTO_SZ;
4537 else
4538 sz = HDR_NORMAL_SZ;
4539
4540 sz += sizeof(LOGP);
4541
4542 return sz;
4543 }
4544
4545 /* Called when we see a non-transactional update log record. */
4546 static int
__lv_on_nontxn_update(lvh,lsnp,txnid,logtype,fileid)4547 __lv_on_nontxn_update(lvh, lsnp, txnid, logtype, fileid)
4548 DB_LOG_VRFY_INFO *lvh;
4549 const DB_LSN *lsnp;
4550 u_int32_t txnid, logtype;
4551 int32_t fileid;
4552 {
4553 lvh->lrtypes[logtype]++;
4554 COMPQUIET(txnid, 0);
4555 if (fileid != INVAL_DBREGID) {
4556 lvh->non_txnup_cnt++;
4557 __db_msg(lvh->dbenv->env, DB_STR_A("2565",
4558 "[%lu][%lu] Non-transactional update, "
4559 "log type: %u, fileid: %d.", "%lu %lu %u %d"),
4560 (u_long)lsnp->file, (u_long)lsnp->offset, logtype, fileid);
4561 }
4562
4563 return (0);
4564 }
4565
4566 static int
__lv_on_txn_aborted(lvinfo)4567 __lv_on_txn_aborted(lvinfo)
4568 DB_LOG_VRFY_INFO *lvinfo;
4569 {
4570 int ret, ret2, sres;
4571 VRFY_TXN_INFO *ptvi;
4572 u_int32_t abtid;
4573 DB_LSN lsn, slsn;
4574
4575 ret = ret2 = sres = 0;
4576 abtid = lvinfo->aborted_txnid;
4577 lsn = lvinfo->aborted_txnlsn;
4578 slsn = lvinfo->lv_config->start_lsn;
4579 ptvi = NULL;
4580
4581 if ((ret = __del_txn_pages(lvinfo, lvinfo->aborted_txnid)) != 0 &&
4582 ret != DB_NOTFOUND)
4583 goto err;/* Some txns may have updated no pages. */
4584 ret = __get_txn_vrfy_info(lvinfo, lvinfo->aborted_txnid, &ptvi);
4585 if (ret == DB_NOTFOUND && !F_ISSET(lvinfo, DB_LOG_VERIFY_PARTIAL)) {
4586 /*
4587 * If verifying from slsn and the txn abtid started before
4588 * slsn, it's expected that we can't find the txn.
4589 */
4590 if (!IS_ZERO_LSN(slsn) && (ret2 = __txn_started(lvinfo, slsn,
4591 abtid, &sres)) == 0 && sres != 0) {
4592 ret = 0;
4593 goto err;
4594 }
4595 if (ret2 != 0)
4596 ret = ret2;/* Use the same error msg below. */
4597 __db_errx(lvinfo->dbenv->env, DB_STR_A("2547",
4598 "[%lu][%lu] Can not find an active transaction's "
4599 "information, txnid: %lx.", "%lu %lu %lx"),
4600 (u_long)lsn.file, (u_long)lsn.offset,
4601 (u_long)lvinfo->aborted_txnid);
4602 ON_ERROR(lvinfo, DB_LOG_VERIFY_INTERR);
4603 }
4604 if (ptvi == NULL) {
4605 if (ret == DB_NOTFOUND &&
4606 F_ISSET(lvinfo, DB_LOG_VERIFY_PARTIAL))
4607 ret = 0;
4608 goto out;
4609 }
4610 ptvi->status = TXN_STAT_ABORT;
4611 lvinfo->ntxn_abort++;
4612 lvinfo->ntxn_active--;
4613 /* Report txn stats. */
4614 if (F_ISSET(lvinfo, DB_LOG_VERIFY_VERBOSE)) {
4615 __db_msg(lvinfo->dbenv->env, DB_STR_A("2567",
4616 "[%lu][%lu] Txn %lx aborted after this log record.",
4617 "%lu %lu %lx"), (u_long)lvinfo->aborted_txnlsn.file,
4618 (u_long)lvinfo->aborted_txnlsn.offset, (u_long)ptvi->txnid);
4619 __db_msg(lvinfo->dbenv->env, DB_STR_A("2568",
4620 "\tThe number of active, committed and aborted child txns "
4621 "of txn %lx: %u, %u, %u.", "%lx %u %u %u"),
4622 (u_long)ptvi->txnid, ptvi->nchild_active,
4623 ptvi->nchild_commit, ptvi->nchild_abort);
4624 }
4625 lvinfo->aborted_txnid = 0;
4626 lvinfo->aborted_txnlsn.file = lvinfo->aborted_txnlsn.offset = 0;
4627 if ((ret = __put_txn_vrfy_info(lvinfo, ptvi)) != 0)
4628 goto err;
4629 if ((ret = __free_txninfo(ptvi)) != 0)
4630 goto err;
4631 out:
4632 err:
4633 return (ret);
4634 }
4635