00001
00002 #include "db_config.h"
00003
00004 #ifndef NO_SYSTEM_INCLUDES
00005 #include <sys/types.h>
00006
00007 #include <ctype.h>
00008 #include <string.h>
00009 #endif
00010
00011 #include "db_int.h"
00012 #include "dbinc/crypto.h"
00013 #include "dbinc/db_page.h"
00014 #include "dbinc/db_dispatch.h"
00015 #include "dbinc/db_am.h"
00016 #include "dbinc/btree.h"
00017 #include "dbinc/log.h"
00018 #include "dbinc/rep.h"
00019 #include "dbinc/txn.h"
00020
00021
00022
00023
00024
00025
00026 int
00027 __bam_split_log(dbp, txnid, ret_lsnp, flags, left, llsn, right, rlsn, indx,
00028 npgno, nlsn, root_pgno, pg, opflags)
00029 DB *dbp;
00030 DB_TXN *txnid;
00031 DB_LSN *ret_lsnp;
00032 u_int32_t flags;
00033 db_pgno_t left;
00034 DB_LSN * llsn;
00035 db_pgno_t right;
00036 DB_LSN * rlsn;
00037 u_int32_t indx;
00038 db_pgno_t npgno;
00039 DB_LSN * nlsn;
00040 db_pgno_t root_pgno;
00041 const DBT *pg;
00042 u_int32_t opflags;
00043 {
00044 DBT logrec;
00045 DB_ENV *dbenv;
00046 DB_LSN *lsnp, null_lsn;
00047 u_int32_t zero;
00048 u_int32_t uinttmp;
00049 u_int32_t npad, rectype, txn_num;
00050 int ret;
00051 u_int8_t *bp;
00052
00053 dbenv = dbp->dbenv;
00054 rectype = DB___bam_split;
00055 npad = 0;
00056
00057 if (txnid == NULL) {
00058 txn_num = 0;
00059 null_lsn.file = 0;
00060 null_lsn.offset = 0;
00061 lsnp = &null_lsn;
00062 } else {
00063 if (TAILQ_FIRST(&txnid->kids) != NULL &&
00064 (ret = __txn_activekids(dbenv, rectype, txnid)) != 0)
00065 return (ret);
00066 txn_num = txnid->txnid;
00067 lsnp = &txnid->last_lsn;
00068 }
00069
00070 logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
00071 + sizeof(u_int32_t)
00072 + sizeof(u_int32_t)
00073 + sizeof(*llsn)
00074 + sizeof(u_int32_t)
00075 + sizeof(*rlsn)
00076 + sizeof(u_int32_t)
00077 + sizeof(u_int32_t)
00078 + sizeof(*nlsn)
00079 + sizeof(u_int32_t)
00080 + sizeof(u_int32_t) + (pg == NULL ? 0 : pg->size)
00081 + sizeof(u_int32_t);
00082 if (CRYPTO_ON(dbenv)) {
00083 npad =
00084 ((DB_CIPHER *)dbenv->crypto_handle)->adj_size(logrec.size);
00085 logrec.size += npad;
00086 }
00087
00088 if ((ret = __os_malloc(dbenv,
00089 logrec.size, &logrec.data)) != 0)
00090 return (ret);
00091
00092 if (npad > 0)
00093 memset((u_int8_t *)logrec.data + logrec.size - npad, 0, npad);
00094
00095 bp = logrec.data;
00096
00097 memcpy(bp, &rectype, sizeof(rectype));
00098 bp += sizeof(rectype);
00099
00100 memcpy(bp, &txn_num, sizeof(txn_num));
00101 bp += sizeof(txn_num);
00102
00103 memcpy(bp, lsnp, sizeof(DB_LSN));
00104 bp += sizeof(DB_LSN);
00105
00106 DB_ASSERT(dbp->log_filename != NULL);
00107 if (dbp->log_filename->id == DB_LOGFILEID_INVALID &&
00108 (ret = __dbreg_lazy_id(dbp)) != 0)
00109 return (ret);
00110
00111 uinttmp = (u_int32_t)dbp->log_filename->id;
00112 memcpy(bp, &uinttmp, sizeof(uinttmp));
00113 bp += sizeof(uinttmp);
00114
00115 uinttmp = (u_int32_t)left;
00116 memcpy(bp, &uinttmp, sizeof(uinttmp));
00117 bp += sizeof(uinttmp);
00118
00119 if (llsn != NULL)
00120 memcpy(bp, llsn, sizeof(*llsn));
00121 else
00122 memset(bp, 0, sizeof(*llsn));
00123 bp += sizeof(*llsn);
00124
00125 uinttmp = (u_int32_t)right;
00126 memcpy(bp, &uinttmp, sizeof(uinttmp));
00127 bp += sizeof(uinttmp);
00128
00129 if (rlsn != NULL)
00130 memcpy(bp, rlsn, sizeof(*rlsn));
00131 else
00132 memset(bp, 0, sizeof(*rlsn));
00133 bp += sizeof(*rlsn);
00134
00135 uinttmp = (u_int32_t)indx;
00136 memcpy(bp, &uinttmp, sizeof(uinttmp));
00137 bp += sizeof(uinttmp);
00138
00139 uinttmp = (u_int32_t)npgno;
00140 memcpy(bp, &uinttmp, sizeof(uinttmp));
00141 bp += sizeof(uinttmp);
00142
00143 if (nlsn != NULL)
00144 memcpy(bp, nlsn, sizeof(*nlsn));
00145 else
00146 memset(bp, 0, sizeof(*nlsn));
00147 bp += sizeof(*nlsn);
00148
00149 uinttmp = (u_int32_t)root_pgno;
00150 memcpy(bp, &uinttmp, sizeof(uinttmp));
00151 bp += sizeof(uinttmp);
00152
00153 if (pg == NULL) {
00154 zero = 0;
00155 memcpy(bp, &zero, sizeof(u_int32_t));
00156 bp += sizeof(u_int32_t);
00157 } else {
00158 memcpy(bp, &pg->size, sizeof(pg->size));
00159 bp += sizeof(pg->size);
00160 memcpy(bp, pg->data, pg->size);
00161 bp += pg->size;
00162 }
00163
00164 uinttmp = (u_int32_t)opflags;
00165 memcpy(bp, &uinttmp, sizeof(uinttmp));
00166 bp += sizeof(uinttmp);
00167
00168 DB_ASSERT((u_int32_t)(bp - (u_int8_t *)logrec.data) <= logrec.size);
00169 ret = dbenv->log_put(dbenv,
00170 ret_lsnp, (DBT *)&logrec, flags | DB_NOCOPY);
00171 if (txnid != NULL && ret == 0)
00172 txnid->last_lsn = *ret_lsnp;
00173 #ifdef LOG_DIAGNOSTIC
00174 if (ret != 0)
00175 (void)__bam_split_print(dbenv,
00176 (DBT *)&logrec, ret_lsnp, NULL, NULL);
00177 #endif
00178 __os_free(dbenv, logrec.data);
00179 return (ret);
00180 }
00181
00182
00183
00184
00185
00186 int
00187 __bam_split_getpgnos(dbenv, rec, lsnp, notused1, summary)
00188 DB_ENV *dbenv;
00189 DBT *rec;
00190 DB_LSN *lsnp;
00191 db_recops notused1;
00192 void *summary;
00193 {
00194 DB *dbp;
00195 TXN_RECS *t;
00196 __bam_split_args *argp;
00197 u_int32_t ret;
00198
00199 COMPQUIET(notused1, DB_TXN_ABORT);
00200
00201 argp = NULL;
00202 t = (TXN_RECS *)summary;
00203
00204 if ((ret = __bam_split_read(dbenv, rec->data, &argp)) != 0)
00205 return (ret);
00206
00207 if ((ret = __dbreg_id_to_db(dbenv,
00208 argp->txnid, &dbp, argp->fileid, 0)) != 0)
00209 goto err;
00210
00211 if ((ret = __rep_check_alloc(dbenv, t, 3)) != 0)
00212 goto err;
00213
00214 t->array[t->npages].flags = 0;
00215 t->array[t->npages].fid = argp->fileid;
00216 t->array[t->npages].lsn = *lsnp;
00217 t->array[t->npages].pgdesc.pgno = argp->left;
00218 t->array[t->npages].pgdesc.type = DB_PAGE_LOCK;
00219 memcpy(t->array[t->npages].pgdesc.fileid, dbp->fileid,
00220 DB_FILE_ID_LEN);
00221 t->npages++;
00222 t->array[t->npages].flags = 0;
00223 t->array[t->npages].fid = argp->fileid;
00224 t->array[t->npages].lsn = *lsnp;
00225 t->array[t->npages].pgdesc.pgno = argp->right;
00226 t->array[t->npages].pgdesc.type = DB_PAGE_LOCK;
00227 memcpy(t->array[t->npages].pgdesc.fileid, dbp->fileid,
00228 DB_FILE_ID_LEN);
00229 t->npages++;
00230 if (argp->root_pgno != PGNO_INVALID) {
00231 t->array[t->npages].flags = 0;
00232 t->array[t->npages].fid = argp->fileid;
00233 t->array[t->npages].lsn = *lsnp;
00234 t->array[t->npages].pgdesc.pgno = argp->root_pgno;
00235 t->array[t->npages].pgdesc.type = DB_PAGE_LOCK;
00236 memcpy(t->array[t->npages].pgdesc.fileid, dbp->fileid,
00237 DB_FILE_ID_LEN);
00238 t->npages++;
00239 }
00240
00241 err: if (argp != NULL)
00242 __os_free(dbenv, argp);
00243 return (ret);
00244 }
00245
00246
00247
00248
00249
00250 int
00251 __bam_split_print(dbenv, dbtp, lsnp, notused2, notused3)
00252 DB_ENV *dbenv;
00253 DBT *dbtp;
00254 DB_LSN *lsnp;
00255 db_recops notused2;
00256 void *notused3;
00257 {
00258 __bam_split_args *argp;
00259 u_int32_t i;
00260 int ch;
00261 int ret;
00262
00263 notused2 = DB_TXN_ABORT;
00264 notused3 = NULL;
00265
00266 if ((ret = __bam_split_read(dbenv, dbtp->data, &argp)) != 0)
00267 return (ret);
00268 (void)printf(
00269 "[%lu][%lu]__bam_split: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
00270 (u_long)lsnp->file,
00271 (u_long)lsnp->offset,
00272 (u_long)argp->type,
00273 (u_long)argp->txnid->txnid,
00274 (u_long)argp->prev_lsn.file,
00275 (u_long)argp->prev_lsn.offset);
00276 (void)printf("\tfileid: %ld\n", (long)argp->fileid);
00277 (void)printf("\tleft: %lu\n", (u_long)argp->left);
00278 (void)printf("\tllsn: [%lu][%lu]\n",
00279 (u_long)argp->llsn.file, (u_long)argp->llsn.offset);
00280 (void)printf("\tright: %lu\n", (u_long)argp->right);
00281 (void)printf("\trlsn: [%lu][%lu]\n",
00282 (u_long)argp->rlsn.file, (u_long)argp->rlsn.offset);
00283 (void)printf("\tindx: %lu\n", (u_long)argp->indx);
00284 (void)printf("\tnpgno: %lu\n", (u_long)argp->npgno);
00285 (void)printf("\tnlsn: [%lu][%lu]\n",
00286 (u_long)argp->nlsn.file, (u_long)argp->nlsn.offset);
00287 (void)printf("\troot_pgno: %lu\n", (u_long)argp->root_pgno);
00288 (void)printf("\tpg: ");
00289 for (i = 0; i < argp->pg.size; i++) {
00290 ch = ((u_int8_t *)argp->pg.data)[i];
00291 printf(isprint(ch) || ch == 0x0a ? "%c" : "%#x ", ch);
00292 }
00293 (void)printf("\n");
00294 (void)printf("\topflags: %lu\n", (u_long)argp->opflags);
00295 (void)printf("\n");
00296 __os_free(dbenv, argp);
00297 return (0);
00298 }
00299
00300
00301
00302
00303 int
00304 __bam_split_read(dbenv, recbuf, argpp)
00305 DB_ENV *dbenv;
00306 void *recbuf;
00307 __bam_split_args **argpp;
00308 {
00309 __bam_split_args *argp;
00310 u_int32_t uinttmp;
00311 u_int8_t *bp;
00312 int ret;
00313
00314 if ((ret = __os_malloc(dbenv,
00315 sizeof(__bam_split_args) + sizeof(DB_TXN), &argp)) != 0)
00316 return (ret);
00317
00318 argp->txnid = (DB_TXN *)&argp[1];
00319
00320 bp = recbuf;
00321 memcpy(&argp->type, bp, sizeof(argp->type));
00322 bp += sizeof(argp->type);
00323
00324 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
00325 bp += sizeof(argp->txnid->txnid);
00326
00327 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
00328 bp += sizeof(DB_LSN);
00329
00330 memcpy(&uinttmp, bp, sizeof(uinttmp));
00331 argp->fileid = (int32_t)uinttmp;
00332 bp += sizeof(uinttmp);
00333
00334 memcpy(&uinttmp, bp, sizeof(uinttmp));
00335 argp->left = (db_pgno_t)uinttmp;
00336 bp += sizeof(uinttmp);
00337
00338 memcpy(&argp->llsn, bp, sizeof(argp->llsn));
00339 bp += sizeof(argp->llsn);
00340
00341 memcpy(&uinttmp, bp, sizeof(uinttmp));
00342 argp->right = (db_pgno_t)uinttmp;
00343 bp += sizeof(uinttmp);
00344
00345 memcpy(&argp->rlsn, bp, sizeof(argp->rlsn));
00346 bp += sizeof(argp->rlsn);
00347
00348 memcpy(&uinttmp, bp, sizeof(uinttmp));
00349 argp->indx = (u_int32_t)uinttmp;
00350 bp += sizeof(uinttmp);
00351
00352 memcpy(&uinttmp, bp, sizeof(uinttmp));
00353 argp->npgno = (db_pgno_t)uinttmp;
00354 bp += sizeof(uinttmp);
00355
00356 memcpy(&argp->nlsn, bp, sizeof(argp->nlsn));
00357 bp += sizeof(argp->nlsn);
00358
00359 memcpy(&uinttmp, bp, sizeof(uinttmp));
00360 argp->root_pgno = (db_pgno_t)uinttmp;
00361 bp += sizeof(uinttmp);
00362
00363 memset(&argp->pg, 0, sizeof(argp->pg));
00364 memcpy(&argp->pg.size, bp, sizeof(u_int32_t));
00365 bp += sizeof(u_int32_t);
00366 argp->pg.data = bp;
00367 bp += argp->pg.size;
00368
00369 memcpy(&uinttmp, bp, sizeof(uinttmp));
00370 argp->opflags = (u_int32_t)uinttmp;
00371 bp += sizeof(uinttmp);
00372
00373 *argpp = argp;
00374 return (0);
00375 }
00376
00377
00378
00379
00380
00381
00382 int
00383 __bam_rsplit_log(dbp, txnid, ret_lsnp, flags, pgno, pgdbt, root_pgno, nrec, rootent,
00384 rootlsn)
00385 DB *dbp;
00386 DB_TXN *txnid;
00387 DB_LSN *ret_lsnp;
00388 u_int32_t flags;
00389 db_pgno_t pgno;
00390 const DBT *pgdbt;
00391 db_pgno_t root_pgno;
00392 db_pgno_t nrec;
00393 const DBT *rootent;
00394 DB_LSN * rootlsn;
00395 {
00396 DBT logrec;
00397 DB_ENV *dbenv;
00398 DB_LSN *lsnp, null_lsn;
00399 u_int32_t zero;
00400 u_int32_t uinttmp;
00401 u_int32_t npad, rectype, txn_num;
00402 int ret;
00403 u_int8_t *bp;
00404
00405 dbenv = dbp->dbenv;
00406 rectype = DB___bam_rsplit;
00407 npad = 0;
00408
00409 if (txnid == NULL) {
00410 txn_num = 0;
00411 null_lsn.file = 0;
00412 null_lsn.offset = 0;
00413 lsnp = &null_lsn;
00414 } else {
00415 if (TAILQ_FIRST(&txnid->kids) != NULL &&
00416 (ret = __txn_activekids(dbenv, rectype, txnid)) != 0)
00417 return (ret);
00418 txn_num = txnid->txnid;
00419 lsnp = &txnid->last_lsn;
00420 }
00421
00422 logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
00423 + sizeof(u_int32_t)
00424 + sizeof(u_int32_t)
00425 + sizeof(u_int32_t) + (pgdbt == NULL ? 0 : pgdbt->size)
00426 + sizeof(u_int32_t)
00427 + sizeof(u_int32_t)
00428 + sizeof(u_int32_t) + (rootent == NULL ? 0 : rootent->size)
00429 + sizeof(*rootlsn);
00430 if (CRYPTO_ON(dbenv)) {
00431 npad =
00432 ((DB_CIPHER *)dbenv->crypto_handle)->adj_size(logrec.size);
00433 logrec.size += npad;
00434 }
00435
00436 if ((ret = __os_malloc(dbenv,
00437 logrec.size, &logrec.data)) != 0)
00438 return (ret);
00439
00440 if (npad > 0)
00441 memset((u_int8_t *)logrec.data + logrec.size - npad, 0, npad);
00442
00443 bp = logrec.data;
00444
00445 memcpy(bp, &rectype, sizeof(rectype));
00446 bp += sizeof(rectype);
00447
00448 memcpy(bp, &txn_num, sizeof(txn_num));
00449 bp += sizeof(txn_num);
00450
00451 memcpy(bp, lsnp, sizeof(DB_LSN));
00452 bp += sizeof(DB_LSN);
00453
00454 DB_ASSERT(dbp->log_filename != NULL);
00455 if (dbp->log_filename->id == DB_LOGFILEID_INVALID &&
00456 (ret = __dbreg_lazy_id(dbp)) != 0)
00457 return (ret);
00458
00459 uinttmp = (u_int32_t)dbp->log_filename->id;
00460 memcpy(bp, &uinttmp, sizeof(uinttmp));
00461 bp += sizeof(uinttmp);
00462
00463 uinttmp = (u_int32_t)pgno;
00464 memcpy(bp, &uinttmp, sizeof(uinttmp));
00465 bp += sizeof(uinttmp);
00466
00467 if (pgdbt == NULL) {
00468 zero = 0;
00469 memcpy(bp, &zero, sizeof(u_int32_t));
00470 bp += sizeof(u_int32_t);
00471 } else {
00472 memcpy(bp, &pgdbt->size, sizeof(pgdbt->size));
00473 bp += sizeof(pgdbt->size);
00474 memcpy(bp, pgdbt->data, pgdbt->size);
00475 bp += pgdbt->size;
00476 }
00477
00478 uinttmp = (u_int32_t)root_pgno;
00479 memcpy(bp, &uinttmp, sizeof(uinttmp));
00480 bp += sizeof(uinttmp);
00481
00482 uinttmp = (u_int32_t)nrec;
00483 memcpy(bp, &uinttmp, sizeof(uinttmp));
00484 bp += sizeof(uinttmp);
00485
00486 if (rootent == NULL) {
00487 zero = 0;
00488 memcpy(bp, &zero, sizeof(u_int32_t));
00489 bp += sizeof(u_int32_t);
00490 } else {
00491 memcpy(bp, &rootent->size, sizeof(rootent->size));
00492 bp += sizeof(rootent->size);
00493 memcpy(bp, rootent->data, rootent->size);
00494 bp += rootent->size;
00495 }
00496
00497 if (rootlsn != NULL)
00498 memcpy(bp, rootlsn, sizeof(*rootlsn));
00499 else
00500 memset(bp, 0, sizeof(*rootlsn));
00501 bp += sizeof(*rootlsn);
00502
00503 DB_ASSERT((u_int32_t)(bp - (u_int8_t *)logrec.data) <= logrec.size);
00504 ret = dbenv->log_put(dbenv,
00505 ret_lsnp, (DBT *)&logrec, flags | DB_NOCOPY);
00506 if (txnid != NULL && ret == 0)
00507 txnid->last_lsn = *ret_lsnp;
00508 #ifdef LOG_DIAGNOSTIC
00509 if (ret != 0)
00510 (void)__bam_rsplit_print(dbenv,
00511 (DBT *)&logrec, ret_lsnp, NULL, NULL);
00512 #endif
00513 __os_free(dbenv, logrec.data);
00514 return (ret);
00515 }
00516
00517
00518
00519
00520
00521 int
00522 __bam_rsplit_getpgnos(dbenv, rec, lsnp, notused1, summary)
00523 DB_ENV *dbenv;
00524 DBT *rec;
00525 DB_LSN *lsnp;
00526 db_recops notused1;
00527 void *summary;
00528 {
00529 DB *dbp;
00530 TXN_RECS *t;
00531 __bam_rsplit_args *argp;
00532 u_int32_t ret;
00533
00534 COMPQUIET(notused1, DB_TXN_ABORT);
00535
00536 argp = NULL;
00537 t = (TXN_RECS *)summary;
00538
00539 if ((ret = __bam_rsplit_read(dbenv, rec->data, &argp)) != 0)
00540 return (ret);
00541
00542 if ((ret = __dbreg_id_to_db(dbenv,
00543 argp->txnid, &dbp, argp->fileid, 0)) != 0)
00544 goto err;
00545
00546 if ((ret = __rep_check_alloc(dbenv, t, 2)) != 0)
00547 goto err;
00548
00549 t->array[t->npages].flags = 0;
00550 t->array[t->npages].fid = argp->fileid;
00551 t->array[t->npages].lsn = *lsnp;
00552 t->array[t->npages].pgdesc.pgno = argp->pgno;
00553 t->array[t->npages].pgdesc.type = DB_PAGE_LOCK;
00554 memcpy(t->array[t->npages].pgdesc.fileid, dbp->fileid,
00555 DB_FILE_ID_LEN);
00556 t->npages++;
00557 t->array[t->npages].flags = 0;
00558 t->array[t->npages].fid = argp->fileid;
00559 t->array[t->npages].lsn = *lsnp;
00560 t->array[t->npages].pgdesc.pgno = argp->root_pgno;
00561 t->array[t->npages].pgdesc.type = DB_PAGE_LOCK;
00562 memcpy(t->array[t->npages].pgdesc.fileid, dbp->fileid,
00563 DB_FILE_ID_LEN);
00564 t->npages++;
00565
00566 err: if (argp != NULL)
00567 __os_free(dbenv, argp);
00568 return (ret);
00569 }
00570
00571
00572
00573
00574
00575 int
00576 __bam_rsplit_print(dbenv, dbtp, lsnp, notused2, notused3)
00577 DB_ENV *dbenv;
00578 DBT *dbtp;
00579 DB_LSN *lsnp;
00580 db_recops notused2;
00581 void *notused3;
00582 {
00583 __bam_rsplit_args *argp;
00584 u_int32_t i;
00585 int ch;
00586 int ret;
00587
00588 notused2 = DB_TXN_ABORT;
00589 notused3 = NULL;
00590
00591 if ((ret = __bam_rsplit_read(dbenv, dbtp->data, &argp)) != 0)
00592 return (ret);
00593 (void)printf(
00594 "[%lu][%lu]__bam_rsplit: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
00595 (u_long)lsnp->file,
00596 (u_long)lsnp->offset,
00597 (u_long)argp->type,
00598 (u_long)argp->txnid->txnid,
00599 (u_long)argp->prev_lsn.file,
00600 (u_long)argp->prev_lsn.offset);
00601 (void)printf("\tfileid: %ld\n", (long)argp->fileid);
00602 (void)printf("\tpgno: %lu\n", (u_long)argp->pgno);
00603 (void)printf("\tpgdbt: ");
00604 for (i = 0; i < argp->pgdbt.size; i++) {
00605 ch = ((u_int8_t *)argp->pgdbt.data)[i];
00606 printf(isprint(ch) || ch == 0x0a ? "%c" : "%#x ", ch);
00607 }
00608 (void)printf("\n");
00609 (void)printf("\troot_pgno: %lu\n", (u_long)argp->root_pgno);
00610 (void)printf("\tnrec: %lu\n", (u_long)argp->nrec);
00611 (void)printf("\trootent: ");
00612 for (i = 0; i < argp->rootent.size; i++) {
00613 ch = ((u_int8_t *)argp->rootent.data)[i];
00614 printf(isprint(ch) || ch == 0x0a ? "%c" : "%#x ", ch);
00615 }
00616 (void)printf("\n");
00617 (void)printf("\trootlsn: [%lu][%lu]\n",
00618 (u_long)argp->rootlsn.file, (u_long)argp->rootlsn.offset);
00619 (void)printf("\n");
00620 __os_free(dbenv, argp);
00621 return (0);
00622 }
00623
00624
00625
00626
00627 int
00628 __bam_rsplit_read(dbenv, recbuf, argpp)
00629 DB_ENV *dbenv;
00630 void *recbuf;
00631 __bam_rsplit_args **argpp;
00632 {
00633 __bam_rsplit_args *argp;
00634 u_int32_t uinttmp;
00635 u_int8_t *bp;
00636 int ret;
00637
00638 if ((ret = __os_malloc(dbenv,
00639 sizeof(__bam_rsplit_args) + sizeof(DB_TXN), &argp)) != 0)
00640 return (ret);
00641
00642 argp->txnid = (DB_TXN *)&argp[1];
00643
00644 bp = recbuf;
00645 memcpy(&argp->type, bp, sizeof(argp->type));
00646 bp += sizeof(argp->type);
00647
00648 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
00649 bp += sizeof(argp->txnid->txnid);
00650
00651 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
00652 bp += sizeof(DB_LSN);
00653
00654 memcpy(&uinttmp, bp, sizeof(uinttmp));
00655 argp->fileid = (int32_t)uinttmp;
00656 bp += sizeof(uinttmp);
00657
00658 memcpy(&uinttmp, bp, sizeof(uinttmp));
00659 argp->pgno = (db_pgno_t)uinttmp;
00660 bp += sizeof(uinttmp);
00661
00662 memset(&argp->pgdbt, 0, sizeof(argp->pgdbt));
00663 memcpy(&argp->pgdbt.size, bp, sizeof(u_int32_t));
00664 bp += sizeof(u_int32_t);
00665 argp->pgdbt.data = bp;
00666 bp += argp->pgdbt.size;
00667
00668 memcpy(&uinttmp, bp, sizeof(uinttmp));
00669 argp->root_pgno = (db_pgno_t)uinttmp;
00670 bp += sizeof(uinttmp);
00671
00672 memcpy(&uinttmp, bp, sizeof(uinttmp));
00673 argp->nrec = (db_pgno_t)uinttmp;
00674 bp += sizeof(uinttmp);
00675
00676 memset(&argp->rootent, 0, sizeof(argp->rootent));
00677 memcpy(&argp->rootent.size, bp, sizeof(u_int32_t));
00678 bp += sizeof(u_int32_t);
00679 argp->rootent.data = bp;
00680 bp += argp->rootent.size;
00681
00682 memcpy(&argp->rootlsn, bp, sizeof(argp->rootlsn));
00683 bp += sizeof(argp->rootlsn);
00684
00685 *argpp = argp;
00686 return (0);
00687 }
00688
00689
00690
00691
00692
00693
00694 int
00695 __bam_adj_log(dbp, txnid, ret_lsnp, flags, pgno, lsn, indx, indx_copy, is_insert)
00696 DB *dbp;
00697 DB_TXN *txnid;
00698 DB_LSN *ret_lsnp;
00699 u_int32_t flags;
00700 db_pgno_t pgno;
00701 DB_LSN * lsn;
00702 u_int32_t indx;
00703 u_int32_t indx_copy;
00704 u_int32_t is_insert;
00705 {
00706 DBT logrec;
00707 DB_ENV *dbenv;
00708 DB_LSN *lsnp, null_lsn;
00709 u_int32_t uinttmp;
00710 u_int32_t npad, rectype, txn_num;
00711 int ret;
00712 u_int8_t *bp;
00713
00714 dbenv = dbp->dbenv;
00715 rectype = DB___bam_adj;
00716 npad = 0;
00717
00718 if (txnid == NULL) {
00719 txn_num = 0;
00720 null_lsn.file = 0;
00721 null_lsn.offset = 0;
00722 lsnp = &null_lsn;
00723 } else {
00724 if (TAILQ_FIRST(&txnid->kids) != NULL &&
00725 (ret = __txn_activekids(dbenv, rectype, txnid)) != 0)
00726 return (ret);
00727 txn_num = txnid->txnid;
00728 lsnp = &txnid->last_lsn;
00729 }
00730
00731 logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
00732 + sizeof(u_int32_t)
00733 + sizeof(u_int32_t)
00734 + sizeof(*lsn)
00735 + sizeof(u_int32_t)
00736 + sizeof(u_int32_t)
00737 + sizeof(u_int32_t);
00738 if (CRYPTO_ON(dbenv)) {
00739 npad =
00740 ((DB_CIPHER *)dbenv->crypto_handle)->adj_size(logrec.size);
00741 logrec.size += npad;
00742 }
00743
00744 if ((ret = __os_malloc(dbenv,
00745 logrec.size, &logrec.data)) != 0)
00746 return (ret);
00747
00748 if (npad > 0)
00749 memset((u_int8_t *)logrec.data + logrec.size - npad, 0, npad);
00750
00751 bp = logrec.data;
00752
00753 memcpy(bp, &rectype, sizeof(rectype));
00754 bp += sizeof(rectype);
00755
00756 memcpy(bp, &txn_num, sizeof(txn_num));
00757 bp += sizeof(txn_num);
00758
00759 memcpy(bp, lsnp, sizeof(DB_LSN));
00760 bp += sizeof(DB_LSN);
00761
00762 DB_ASSERT(dbp->log_filename != NULL);
00763 if (dbp->log_filename->id == DB_LOGFILEID_INVALID &&
00764 (ret = __dbreg_lazy_id(dbp)) != 0)
00765 return (ret);
00766
00767 uinttmp = (u_int32_t)dbp->log_filename->id;
00768 memcpy(bp, &uinttmp, sizeof(uinttmp));
00769 bp += sizeof(uinttmp);
00770
00771 uinttmp = (u_int32_t)pgno;
00772 memcpy(bp, &uinttmp, sizeof(uinttmp));
00773 bp += sizeof(uinttmp);
00774
00775 if (lsn != NULL)
00776 memcpy(bp, lsn, sizeof(*lsn));
00777 else
00778 memset(bp, 0, sizeof(*lsn));
00779 bp += sizeof(*lsn);
00780
00781 uinttmp = (u_int32_t)indx;
00782 memcpy(bp, &uinttmp, sizeof(uinttmp));
00783 bp += sizeof(uinttmp);
00784
00785 uinttmp = (u_int32_t)indx_copy;
00786 memcpy(bp, &uinttmp, sizeof(uinttmp));
00787 bp += sizeof(uinttmp);
00788
00789 uinttmp = (u_int32_t)is_insert;
00790 memcpy(bp, &uinttmp, sizeof(uinttmp));
00791 bp += sizeof(uinttmp);
00792
00793 DB_ASSERT((u_int32_t)(bp - (u_int8_t *)logrec.data) <= logrec.size);
00794 ret = dbenv->log_put(dbenv,
00795 ret_lsnp, (DBT *)&logrec, flags | DB_NOCOPY);
00796 if (txnid != NULL && ret == 0)
00797 txnid->last_lsn = *ret_lsnp;
00798 #ifdef LOG_DIAGNOSTIC
00799 if (ret != 0)
00800 (void)__bam_adj_print(dbenv,
00801 (DBT *)&logrec, ret_lsnp, NULL, NULL);
00802 #endif
00803 __os_free(dbenv, logrec.data);
00804 return (ret);
00805 }
00806
00807
00808
00809
00810
00811 int
00812 __bam_adj_getpgnos(dbenv, rec, lsnp, notused1, summary)
00813 DB_ENV *dbenv;
00814 DBT *rec;
00815 DB_LSN *lsnp;
00816 db_recops notused1;
00817 void *summary;
00818 {
00819 DB *dbp;
00820 TXN_RECS *t;
00821 __bam_adj_args *argp;
00822 u_int32_t ret;
00823
00824 COMPQUIET(notused1, DB_TXN_ABORT);
00825
00826 argp = NULL;
00827 t = (TXN_RECS *)summary;
00828
00829 if ((ret = __bam_adj_read(dbenv, rec->data, &argp)) != 0)
00830 return (ret);
00831
00832 if ((ret = __dbreg_id_to_db(dbenv,
00833 argp->txnid, &dbp, argp->fileid, 0)) != 0)
00834 goto err;
00835
00836 if ((ret = __rep_check_alloc(dbenv, t, 1)) != 0)
00837 goto err;
00838
00839 t->array[t->npages].flags = 0;
00840 t->array[t->npages].fid = argp->fileid;
00841 t->array[t->npages].lsn = *lsnp;
00842 t->array[t->npages].pgdesc.pgno = argp->pgno;
00843 t->array[t->npages].pgdesc.type = DB_PAGE_LOCK;
00844 memcpy(t->array[t->npages].pgdesc.fileid, dbp->fileid,
00845 DB_FILE_ID_LEN);
00846 t->npages++;
00847
00848 err: if (argp != NULL)
00849 __os_free(dbenv, argp);
00850 return (ret);
00851 }
00852
00853
00854
00855
00856
00857 int
00858 __bam_adj_print(dbenv, dbtp, lsnp, notused2, notused3)
00859 DB_ENV *dbenv;
00860 DBT *dbtp;
00861 DB_LSN *lsnp;
00862 db_recops notused2;
00863 void *notused3;
00864 {
00865 __bam_adj_args *argp;
00866 int ret;
00867
00868 notused2 = DB_TXN_ABORT;
00869 notused3 = NULL;
00870
00871 if ((ret = __bam_adj_read(dbenv, dbtp->data, &argp)) != 0)
00872 return (ret);
00873 (void)printf(
00874 "[%lu][%lu]__bam_adj: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
00875 (u_long)lsnp->file,
00876 (u_long)lsnp->offset,
00877 (u_long)argp->type,
00878 (u_long)argp->txnid->txnid,
00879 (u_long)argp->prev_lsn.file,
00880 (u_long)argp->prev_lsn.offset);
00881 (void)printf("\tfileid: %ld\n", (long)argp->fileid);
00882 (void)printf("\tpgno: %lu\n", (u_long)argp->pgno);
00883 (void)printf("\tlsn: [%lu][%lu]\n",
00884 (u_long)argp->lsn.file, (u_long)argp->lsn.offset);
00885 (void)printf("\tindx: %lu\n", (u_long)argp->indx);
00886 (void)printf("\tindx_copy: %lu\n", (u_long)argp->indx_copy);
00887 (void)printf("\tis_insert: %lu\n", (u_long)argp->is_insert);
00888 (void)printf("\n");
00889 __os_free(dbenv, argp);
00890 return (0);
00891 }
00892
00893
00894
00895
00896 int
00897 __bam_adj_read(dbenv, recbuf, argpp)
00898 DB_ENV *dbenv;
00899 void *recbuf;
00900 __bam_adj_args **argpp;
00901 {
00902 __bam_adj_args *argp;
00903 u_int32_t uinttmp;
00904 u_int8_t *bp;
00905 int ret;
00906
00907 if ((ret = __os_malloc(dbenv,
00908 sizeof(__bam_adj_args) + sizeof(DB_TXN), &argp)) != 0)
00909 return (ret);
00910
00911 argp->txnid = (DB_TXN *)&argp[1];
00912
00913 bp = recbuf;
00914 memcpy(&argp->type, bp, sizeof(argp->type));
00915 bp += sizeof(argp->type);
00916
00917 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
00918 bp += sizeof(argp->txnid->txnid);
00919
00920 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
00921 bp += sizeof(DB_LSN);
00922
00923 memcpy(&uinttmp, bp, sizeof(uinttmp));
00924 argp->fileid = (int32_t)uinttmp;
00925 bp += sizeof(uinttmp);
00926
00927 memcpy(&uinttmp, bp, sizeof(uinttmp));
00928 argp->pgno = (db_pgno_t)uinttmp;
00929 bp += sizeof(uinttmp);
00930
00931 memcpy(&argp->lsn, bp, sizeof(argp->lsn));
00932 bp += sizeof(argp->lsn);
00933
00934 memcpy(&uinttmp, bp, sizeof(uinttmp));
00935 argp->indx = (u_int32_t)uinttmp;
00936 bp += sizeof(uinttmp);
00937
00938 memcpy(&uinttmp, bp, sizeof(uinttmp));
00939 argp->indx_copy = (u_int32_t)uinttmp;
00940 bp += sizeof(uinttmp);
00941
00942 memcpy(&uinttmp, bp, sizeof(uinttmp));
00943 argp->is_insert = (u_int32_t)uinttmp;
00944 bp += sizeof(uinttmp);
00945
00946 *argpp = argp;
00947 return (0);
00948 }
00949
00950
00951
00952
00953
00954 int
00955 __bam_cadjust_log(dbp, txnid, ret_lsnp, flags, pgno, lsn, indx, adjust, opflags)
00956 DB *dbp;
00957 DB_TXN *txnid;
00958 DB_LSN *ret_lsnp;
00959 u_int32_t flags;
00960 db_pgno_t pgno;
00961 DB_LSN * lsn;
00962 u_int32_t indx;
00963 int32_t adjust;
00964 u_int32_t opflags;
00965 {
00966 DBT logrec;
00967 DB_ENV *dbenv;
00968 DB_LSN *lsnp, null_lsn;
00969 u_int32_t uinttmp;
00970 u_int32_t npad, rectype, txn_num;
00971 int ret;
00972 u_int8_t *bp;
00973
00974 dbenv = dbp->dbenv;
00975 rectype = DB___bam_cadjust;
00976 npad = 0;
00977
00978 if (txnid == NULL) {
00979 txn_num = 0;
00980 null_lsn.file = 0;
00981 null_lsn.offset = 0;
00982 lsnp = &null_lsn;
00983 } else {
00984 if (TAILQ_FIRST(&txnid->kids) != NULL &&
00985 (ret = __txn_activekids(dbenv, rectype, txnid)) != 0)
00986 return (ret);
00987 txn_num = txnid->txnid;
00988 lsnp = &txnid->last_lsn;
00989 }
00990
00991 logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
00992 + sizeof(u_int32_t)
00993 + sizeof(u_int32_t)
00994 + sizeof(*lsn)
00995 + sizeof(u_int32_t)
00996 + sizeof(u_int32_t)
00997 + sizeof(u_int32_t);
00998 if (CRYPTO_ON(dbenv)) {
00999 npad =
01000 ((DB_CIPHER *)dbenv->crypto_handle)->adj_size(logrec.size);
01001 logrec.size += npad;
01002 }
01003
01004 if ((ret = __os_malloc(dbenv,
01005 logrec.size, &logrec.data)) != 0)
01006 return (ret);
01007
01008 if (npad > 0)
01009 memset((u_int8_t *)logrec.data + logrec.size - npad, 0, npad);
01010
01011 bp = logrec.data;
01012
01013 memcpy(bp, &rectype, sizeof(rectype));
01014 bp += sizeof(rectype);
01015
01016 memcpy(bp, &txn_num, sizeof(txn_num));
01017 bp += sizeof(txn_num);
01018
01019 memcpy(bp, lsnp, sizeof(DB_LSN));
01020 bp += sizeof(DB_LSN);
01021
01022 DB_ASSERT(dbp->log_filename != NULL);
01023 if (dbp->log_filename->id == DB_LOGFILEID_INVALID &&
01024 (ret = __dbreg_lazy_id(dbp)) != 0)
01025 return (ret);
01026
01027 uinttmp = (u_int32_t)dbp->log_filename->id;
01028 memcpy(bp, &uinttmp, sizeof(uinttmp));
01029 bp += sizeof(uinttmp);
01030
01031 uinttmp = (u_int32_t)pgno;
01032 memcpy(bp, &uinttmp, sizeof(uinttmp));
01033 bp += sizeof(uinttmp);
01034
01035 if (lsn != NULL)
01036 memcpy(bp, lsn, sizeof(*lsn));
01037 else
01038 memset(bp, 0, sizeof(*lsn));
01039 bp += sizeof(*lsn);
01040
01041 uinttmp = (u_int32_t)indx;
01042 memcpy(bp, &uinttmp, sizeof(uinttmp));
01043 bp += sizeof(uinttmp);
01044
01045 uinttmp = (u_int32_t)adjust;
01046 memcpy(bp, &uinttmp, sizeof(uinttmp));
01047 bp += sizeof(uinttmp);
01048
01049 uinttmp = (u_int32_t)opflags;
01050 memcpy(bp, &uinttmp, sizeof(uinttmp));
01051 bp += sizeof(uinttmp);
01052
01053 DB_ASSERT((u_int32_t)(bp - (u_int8_t *)logrec.data) <= logrec.size);
01054 ret = dbenv->log_put(dbenv,
01055 ret_lsnp, (DBT *)&logrec, flags | DB_NOCOPY);
01056 if (txnid != NULL && ret == 0)
01057 txnid->last_lsn = *ret_lsnp;
01058 #ifdef LOG_DIAGNOSTIC
01059 if (ret != 0)
01060 (void)__bam_cadjust_print(dbenv,
01061 (DBT *)&logrec, ret_lsnp, NULL, NULL);
01062 #endif
01063 __os_free(dbenv, logrec.data);
01064 return (ret);
01065 }
01066
01067
01068
01069
01070
01071 int
01072 __bam_cadjust_getpgnos(dbenv, rec, lsnp, notused1, summary)
01073 DB_ENV *dbenv;
01074 DBT *rec;
01075 DB_LSN *lsnp;
01076 db_recops notused1;
01077 void *summary;
01078 {
01079 DB *dbp;
01080 TXN_RECS *t;
01081 __bam_cadjust_args *argp;
01082 u_int32_t ret;
01083
01084 COMPQUIET(notused1, DB_TXN_ABORT);
01085
01086 argp = NULL;
01087 t = (TXN_RECS *)summary;
01088
01089 if ((ret = __bam_cadjust_read(dbenv, rec->data, &argp)) != 0)
01090 return (ret);
01091
01092 if ((ret = __dbreg_id_to_db(dbenv,
01093 argp->txnid, &dbp, argp->fileid, 0)) != 0)
01094 goto err;
01095
01096 if ((ret = __rep_check_alloc(dbenv, t, 1)) != 0)
01097 goto err;
01098
01099 t->array[t->npages].flags = 0;
01100 t->array[t->npages].fid = argp->fileid;
01101 t->array[t->npages].lsn = *lsnp;
01102 t->array[t->npages].pgdesc.pgno = argp->pgno;
01103 t->array[t->npages].pgdesc.type = DB_PAGE_LOCK;
01104 memcpy(t->array[t->npages].pgdesc.fileid, dbp->fileid,
01105 DB_FILE_ID_LEN);
01106 t->npages++;
01107
01108 err: if (argp != NULL)
01109 __os_free(dbenv, argp);
01110 return (ret);
01111 }
01112
01113
01114
01115
01116
01117 int
01118 __bam_cadjust_print(dbenv, dbtp, lsnp, notused2, notused3)
01119 DB_ENV *dbenv;
01120 DBT *dbtp;
01121 DB_LSN *lsnp;
01122 db_recops notused2;
01123 void *notused3;
01124 {
01125 __bam_cadjust_args *argp;
01126 int ret;
01127
01128 notused2 = DB_TXN_ABORT;
01129 notused3 = NULL;
01130
01131 if ((ret = __bam_cadjust_read(dbenv, dbtp->data, &argp)) != 0)
01132 return (ret);
01133 (void)printf(
01134 "[%lu][%lu]__bam_cadjust: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
01135 (u_long)lsnp->file,
01136 (u_long)lsnp->offset,
01137 (u_long)argp->type,
01138 (u_long)argp->txnid->txnid,
01139 (u_long)argp->prev_lsn.file,
01140 (u_long)argp->prev_lsn.offset);
01141 (void)printf("\tfileid: %ld\n", (long)argp->fileid);
01142 (void)printf("\tpgno: %lu\n", (u_long)argp->pgno);
01143 (void)printf("\tlsn: [%lu][%lu]\n",
01144 (u_long)argp->lsn.file, (u_long)argp->lsn.offset);
01145 (void)printf("\tindx: %lu\n", (u_long)argp->indx);
01146 (void)printf("\tadjust: %ld\n", (long)argp->adjust);
01147 (void)printf("\topflags: %lu\n", (u_long)argp->opflags);
01148 (void)printf("\n");
01149 __os_free(dbenv, argp);
01150 return (0);
01151 }
01152
01153
01154
01155
01156
01157 int
01158 __bam_cadjust_read(dbenv, recbuf, argpp)
01159 DB_ENV *dbenv;
01160 void *recbuf;
01161 __bam_cadjust_args **argpp;
01162 {
01163 __bam_cadjust_args *argp;
01164 u_int32_t uinttmp;
01165 u_int8_t *bp;
01166 int ret;
01167
01168 if ((ret = __os_malloc(dbenv,
01169 sizeof(__bam_cadjust_args) + sizeof(DB_TXN), &argp)) != 0)
01170 return (ret);
01171
01172 argp->txnid = (DB_TXN *)&argp[1];
01173
01174 bp = recbuf;
01175 memcpy(&argp->type, bp, sizeof(argp->type));
01176 bp += sizeof(argp->type);
01177
01178 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
01179 bp += sizeof(argp->txnid->txnid);
01180
01181 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
01182 bp += sizeof(DB_LSN);
01183
01184 memcpy(&uinttmp, bp, sizeof(uinttmp));
01185 argp->fileid = (int32_t)uinttmp;
01186 bp += sizeof(uinttmp);
01187
01188 memcpy(&uinttmp, bp, sizeof(uinttmp));
01189 argp->pgno = (db_pgno_t)uinttmp;
01190 bp += sizeof(uinttmp);
01191
01192 memcpy(&argp->lsn, bp, sizeof(argp->lsn));
01193 bp += sizeof(argp->lsn);
01194
01195 memcpy(&uinttmp, bp, sizeof(uinttmp));
01196 argp->indx = (u_int32_t)uinttmp;
01197 bp += sizeof(uinttmp);
01198
01199 memcpy(&uinttmp, bp, sizeof(uinttmp));
01200 argp->adjust = (int32_t)uinttmp;
01201 bp += sizeof(uinttmp);
01202
01203 memcpy(&uinttmp, bp, sizeof(uinttmp));
01204 argp->opflags = (u_int32_t)uinttmp;
01205 bp += sizeof(uinttmp);
01206
01207 *argpp = argp;
01208 return (0);
01209 }
01210
01211
01212
01213
01214
01215 int
01216 __bam_cdel_log(dbp, txnid, ret_lsnp, flags, pgno, lsn, indx)
01217 DB *dbp;
01218 DB_TXN *txnid;
01219 DB_LSN *ret_lsnp;
01220 u_int32_t flags;
01221 db_pgno_t pgno;
01222 DB_LSN * lsn;
01223 u_int32_t indx;
01224 {
01225 DBT logrec;
01226 DB_ENV *dbenv;
01227 DB_LSN *lsnp, null_lsn;
01228 u_int32_t uinttmp;
01229 u_int32_t npad, rectype, txn_num;
01230 int ret;
01231 u_int8_t *bp;
01232
01233 dbenv = dbp->dbenv;
01234 rectype = DB___bam_cdel;
01235 npad = 0;
01236
01237 if (txnid == NULL) {
01238 txn_num = 0;
01239 null_lsn.file = 0;
01240 null_lsn.offset = 0;
01241 lsnp = &null_lsn;
01242 } else {
01243 if (TAILQ_FIRST(&txnid->kids) != NULL &&
01244 (ret = __txn_activekids(dbenv, rectype, txnid)) != 0)
01245 return (ret);
01246 txn_num = txnid->txnid;
01247 lsnp = &txnid->last_lsn;
01248 }
01249
01250 logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
01251 + sizeof(u_int32_t)
01252 + sizeof(u_int32_t)
01253 + sizeof(*lsn)
01254 + sizeof(u_int32_t);
01255 if (CRYPTO_ON(dbenv)) {
01256 npad =
01257 ((DB_CIPHER *)dbenv->crypto_handle)->adj_size(logrec.size);
01258 logrec.size += npad;
01259 }
01260
01261 if ((ret = __os_malloc(dbenv,
01262 logrec.size, &logrec.data)) != 0)
01263 return (ret);
01264
01265 if (npad > 0)
01266 memset((u_int8_t *)logrec.data + logrec.size - npad, 0, npad);
01267
01268 bp = logrec.data;
01269
01270 memcpy(bp, &rectype, sizeof(rectype));
01271 bp += sizeof(rectype);
01272
01273 memcpy(bp, &txn_num, sizeof(txn_num));
01274 bp += sizeof(txn_num);
01275
01276 memcpy(bp, lsnp, sizeof(DB_LSN));
01277 bp += sizeof(DB_LSN);
01278
01279 DB_ASSERT(dbp->log_filename != NULL);
01280 if (dbp->log_filename->id == DB_LOGFILEID_INVALID &&
01281 (ret = __dbreg_lazy_id(dbp)) != 0)
01282 return (ret);
01283
01284 uinttmp = (u_int32_t)dbp->log_filename->id;
01285 memcpy(bp, &uinttmp, sizeof(uinttmp));
01286 bp += sizeof(uinttmp);
01287
01288 uinttmp = (u_int32_t)pgno;
01289 memcpy(bp, &uinttmp, sizeof(uinttmp));
01290 bp += sizeof(uinttmp);
01291
01292 if (lsn != NULL)
01293 memcpy(bp, lsn, sizeof(*lsn));
01294 else
01295 memset(bp, 0, sizeof(*lsn));
01296 bp += sizeof(*lsn);
01297
01298 uinttmp = (u_int32_t)indx;
01299 memcpy(bp, &uinttmp, sizeof(uinttmp));
01300 bp += sizeof(uinttmp);
01301
01302 DB_ASSERT((u_int32_t)(bp - (u_int8_t *)logrec.data) <= logrec.size);
01303 ret = dbenv->log_put(dbenv,
01304 ret_lsnp, (DBT *)&logrec, flags | DB_NOCOPY);
01305 if (txnid != NULL && ret == 0)
01306 txnid->last_lsn = *ret_lsnp;
01307 #ifdef LOG_DIAGNOSTIC
01308 if (ret != 0)
01309 (void)__bam_cdel_print(dbenv,
01310 (DBT *)&logrec, ret_lsnp, NULL, NULL);
01311 #endif
01312 __os_free(dbenv, logrec.data);
01313 return (ret);
01314 }
01315
01316
01317
01318
01319
01320 int
01321 __bam_cdel_getpgnos(dbenv, rec, lsnp, notused1, summary)
01322 DB_ENV *dbenv;
01323 DBT *rec;
01324 DB_LSN *lsnp;
01325 db_recops notused1;
01326 void *summary;
01327 {
01328 DB *dbp;
01329 TXN_RECS *t;
01330 __bam_cdel_args *argp;
01331 u_int32_t ret;
01332
01333 COMPQUIET(notused1, DB_TXN_ABORT);
01334
01335 argp = NULL;
01336 t = (TXN_RECS *)summary;
01337
01338 if ((ret = __bam_cdel_read(dbenv, rec->data, &argp)) != 0)
01339 return (ret);
01340
01341 if ((ret = __dbreg_id_to_db(dbenv,
01342 argp->txnid, &dbp, argp->fileid, 0)) != 0)
01343 goto err;
01344
01345 if ((ret = __rep_check_alloc(dbenv, t, 1)) != 0)
01346 goto err;
01347
01348 t->array[t->npages].flags = 0;
01349 t->array[t->npages].fid = argp->fileid;
01350 t->array[t->npages].lsn = *lsnp;
01351 t->array[t->npages].pgdesc.pgno = argp->pgno;
01352 t->array[t->npages].pgdesc.type = DB_PAGE_LOCK;
01353 memcpy(t->array[t->npages].pgdesc.fileid, dbp->fileid,
01354 DB_FILE_ID_LEN);
01355 t->npages++;
01356
01357 err: if (argp != NULL)
01358 __os_free(dbenv, argp);
01359 return (ret);
01360 }
01361
01362
01363
01364
01365
01366 int
01367 __bam_cdel_print(dbenv, dbtp, lsnp, notused2, notused3)
01368 DB_ENV *dbenv;
01369 DBT *dbtp;
01370 DB_LSN *lsnp;
01371 db_recops notused2;
01372 void *notused3;
01373 {
01374 __bam_cdel_args *argp;
01375 int ret;
01376
01377 notused2 = DB_TXN_ABORT;
01378 notused3 = NULL;
01379
01380 if ((ret = __bam_cdel_read(dbenv, dbtp->data, &argp)) != 0)
01381 return (ret);
01382 (void)printf(
01383 "[%lu][%lu]__bam_cdel: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
01384 (u_long)lsnp->file,
01385 (u_long)lsnp->offset,
01386 (u_long)argp->type,
01387 (u_long)argp->txnid->txnid,
01388 (u_long)argp->prev_lsn.file,
01389 (u_long)argp->prev_lsn.offset);
01390 (void)printf("\tfileid: %ld\n", (long)argp->fileid);
01391 (void)printf("\tpgno: %lu\n", (u_long)argp->pgno);
01392 (void)printf("\tlsn: [%lu][%lu]\n",
01393 (u_long)argp->lsn.file, (u_long)argp->lsn.offset);
01394 (void)printf("\tindx: %lu\n", (u_long)argp->indx);
01395 (void)printf("\n");
01396 __os_free(dbenv, argp);
01397 return (0);
01398 }
01399
01400
01401
01402
01403 int
01404 __bam_cdel_read(dbenv, recbuf, argpp)
01405 DB_ENV *dbenv;
01406 void *recbuf;
01407 __bam_cdel_args **argpp;
01408 {
01409 __bam_cdel_args *argp;
01410 u_int32_t uinttmp;
01411 u_int8_t *bp;
01412 int ret;
01413
01414 if ((ret = __os_malloc(dbenv,
01415 sizeof(__bam_cdel_args) + sizeof(DB_TXN), &argp)) != 0)
01416 return (ret);
01417
01418 argp->txnid = (DB_TXN *)&argp[1];
01419
01420 bp = recbuf;
01421 memcpy(&argp->type, bp, sizeof(argp->type));
01422 bp += sizeof(argp->type);
01423
01424 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
01425 bp += sizeof(argp->txnid->txnid);
01426
01427 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
01428 bp += sizeof(DB_LSN);
01429
01430 memcpy(&uinttmp, bp, sizeof(uinttmp));
01431 argp->fileid = (int32_t)uinttmp;
01432 bp += sizeof(uinttmp);
01433
01434 memcpy(&uinttmp, bp, sizeof(uinttmp));
01435 argp->pgno = (db_pgno_t)uinttmp;
01436 bp += sizeof(uinttmp);
01437
01438 memcpy(&argp->lsn, bp, sizeof(argp->lsn));
01439 bp += sizeof(argp->lsn);
01440
01441 memcpy(&uinttmp, bp, sizeof(uinttmp));
01442 argp->indx = (u_int32_t)uinttmp;
01443 bp += sizeof(uinttmp);
01444
01445 *argpp = argp;
01446 return (0);
01447 }
01448
01449
01450
01451
01452
01453
01454 int
01455 __bam_repl_log(dbp, txnid, ret_lsnp, flags, pgno, lsn, indx, isdeleted, orig,
01456 repl, prefix, suffix)
01457 DB *dbp;
01458 DB_TXN *txnid;
01459 DB_LSN *ret_lsnp;
01460 u_int32_t flags;
01461 db_pgno_t pgno;
01462 DB_LSN * lsn;
01463 u_int32_t indx;
01464 u_int32_t isdeleted;
01465 const DBT *orig;
01466 const DBT *repl;
01467 u_int32_t prefix;
01468 u_int32_t suffix;
01469 {
01470 DBT logrec;
01471 DB_ENV *dbenv;
01472 DB_LSN *lsnp, null_lsn;
01473 u_int32_t zero;
01474 u_int32_t uinttmp;
01475 u_int32_t npad, rectype, txn_num;
01476 int ret;
01477 u_int8_t *bp;
01478
01479 dbenv = dbp->dbenv;
01480 rectype = DB___bam_repl;
01481 npad = 0;
01482
01483 if (txnid == NULL) {
01484 txn_num = 0;
01485 null_lsn.file = 0;
01486 null_lsn.offset = 0;
01487 lsnp = &null_lsn;
01488 } else {
01489 if (TAILQ_FIRST(&txnid->kids) != NULL &&
01490 (ret = __txn_activekids(dbenv, rectype, txnid)) != 0)
01491 return (ret);
01492 txn_num = txnid->txnid;
01493 lsnp = &txnid->last_lsn;
01494 }
01495
01496 logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
01497 + sizeof(u_int32_t)
01498 + sizeof(u_int32_t)
01499 + sizeof(*lsn)
01500 + sizeof(u_int32_t)
01501 + sizeof(u_int32_t)
01502 + sizeof(u_int32_t) + (orig == NULL ? 0 : orig->size)
01503 + sizeof(u_int32_t) + (repl == NULL ? 0 : repl->size)
01504 + sizeof(u_int32_t)
01505 + sizeof(u_int32_t);
01506 if (CRYPTO_ON(dbenv)) {
01507 npad =
01508 ((DB_CIPHER *)dbenv->crypto_handle)->adj_size(logrec.size);
01509 logrec.size += npad;
01510 }
01511
01512 if ((ret = __os_malloc(dbenv,
01513 logrec.size, &logrec.data)) != 0)
01514 return (ret);
01515
01516 if (npad > 0)
01517 memset((u_int8_t *)logrec.data + logrec.size - npad, 0, npad);
01518
01519 bp = logrec.data;
01520
01521 memcpy(bp, &rectype, sizeof(rectype));
01522 bp += sizeof(rectype);
01523
01524 memcpy(bp, &txn_num, sizeof(txn_num));
01525 bp += sizeof(txn_num);
01526
01527 memcpy(bp, lsnp, sizeof(DB_LSN));
01528 bp += sizeof(DB_LSN);
01529
01530 DB_ASSERT(dbp->log_filename != NULL);
01531 if (dbp->log_filename->id == DB_LOGFILEID_INVALID &&
01532 (ret = __dbreg_lazy_id(dbp)) != 0)
01533 return (ret);
01534
01535 uinttmp = (u_int32_t)dbp->log_filename->id;
01536 memcpy(bp, &uinttmp, sizeof(uinttmp));
01537 bp += sizeof(uinttmp);
01538
01539 uinttmp = (u_int32_t)pgno;
01540 memcpy(bp, &uinttmp, sizeof(uinttmp));
01541 bp += sizeof(uinttmp);
01542
01543 if (lsn != NULL)
01544 memcpy(bp, lsn, sizeof(*lsn));
01545 else
01546 memset(bp, 0, sizeof(*lsn));
01547 bp += sizeof(*lsn);
01548
01549 uinttmp = (u_int32_t)indx;
01550 memcpy(bp, &uinttmp, sizeof(uinttmp));
01551 bp += sizeof(uinttmp);
01552
01553 uinttmp = (u_int32_t)isdeleted;
01554 memcpy(bp, &uinttmp, sizeof(uinttmp));
01555 bp += sizeof(uinttmp);
01556
01557 if (orig == NULL) {
01558 zero = 0;
01559 memcpy(bp, &zero, sizeof(u_int32_t));
01560 bp += sizeof(u_int32_t);
01561 } else {
01562 memcpy(bp, &orig->size, sizeof(orig->size));
01563 bp += sizeof(orig->size);
01564 memcpy(bp, orig->data, orig->size);
01565 bp += orig->size;
01566 }
01567
01568 if (repl == NULL) {
01569 zero = 0;
01570 memcpy(bp, &zero, sizeof(u_int32_t));
01571 bp += sizeof(u_int32_t);
01572 } else {
01573 memcpy(bp, &repl->size, sizeof(repl->size));
01574 bp += sizeof(repl->size);
01575 memcpy(bp, repl->data, repl->size);
01576 bp += repl->size;
01577 }
01578
01579 uinttmp = (u_int32_t)prefix;
01580 memcpy(bp, &uinttmp, sizeof(uinttmp));
01581 bp += sizeof(uinttmp);
01582
01583 uinttmp = (u_int32_t)suffix;
01584 memcpy(bp, &uinttmp, sizeof(uinttmp));
01585 bp += sizeof(uinttmp);
01586
01587 DB_ASSERT((u_int32_t)(bp - (u_int8_t *)logrec.data) <= logrec.size);
01588 ret = dbenv->log_put(dbenv,
01589 ret_lsnp, (DBT *)&logrec, flags | DB_NOCOPY);
01590 if (txnid != NULL && ret == 0)
01591 txnid->last_lsn = *ret_lsnp;
01592 #ifdef LOG_DIAGNOSTIC
01593 if (ret != 0)
01594 (void)__bam_repl_print(dbenv,
01595 (DBT *)&logrec, ret_lsnp, NULL, NULL);
01596 #endif
01597 __os_free(dbenv, logrec.data);
01598 return (ret);
01599 }
01600
01601
01602
01603
01604
01605 int
01606 __bam_repl_getpgnos(dbenv, rec, lsnp, notused1, summary)
01607 DB_ENV *dbenv;
01608 DBT *rec;
01609 DB_LSN *lsnp;
01610 db_recops notused1;
01611 void *summary;
01612 {
01613 DB *dbp;
01614 TXN_RECS *t;
01615 __bam_repl_args *argp;
01616 u_int32_t ret;
01617
01618 COMPQUIET(notused1, DB_TXN_ABORT);
01619
01620 argp = NULL;
01621 t = (TXN_RECS *)summary;
01622
01623 if ((ret = __bam_repl_read(dbenv, rec->data, &argp)) != 0)
01624 return (ret);
01625
01626 if ((ret = __dbreg_id_to_db(dbenv,
01627 argp->txnid, &dbp, argp->fileid, 0)) != 0)
01628 goto err;
01629
01630 if ((ret = __rep_check_alloc(dbenv, t, 1)) != 0)
01631 goto err;
01632
01633 t->array[t->npages].flags = 0;
01634 t->array[t->npages].fid = argp->fileid;
01635 t->array[t->npages].lsn = *lsnp;
01636 t->array[t->npages].pgdesc.pgno = argp->pgno;
01637 t->array[t->npages].pgdesc.type = DB_PAGE_LOCK;
01638 memcpy(t->array[t->npages].pgdesc.fileid, dbp->fileid,
01639 DB_FILE_ID_LEN);
01640 t->npages++;
01641
01642 err: if (argp != NULL)
01643 __os_free(dbenv, argp);
01644 return (ret);
01645 }
01646
01647
01648
01649
01650
01651 int
01652 __bam_repl_print(dbenv, dbtp, lsnp, notused2, notused3)
01653 DB_ENV *dbenv;
01654 DBT *dbtp;
01655 DB_LSN *lsnp;
01656 db_recops notused2;
01657 void *notused3;
01658 {
01659 __bam_repl_args *argp;
01660 u_int32_t i;
01661 int ch;
01662 int ret;
01663
01664 notused2 = DB_TXN_ABORT;
01665 notused3 = NULL;
01666
01667 if ((ret = __bam_repl_read(dbenv, dbtp->data, &argp)) != 0)
01668 return (ret);
01669 (void)printf(
01670 "[%lu][%lu]__bam_repl: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
01671 (u_long)lsnp->file,
01672 (u_long)lsnp->offset,
01673 (u_long)argp->type,
01674 (u_long)argp->txnid->txnid,
01675 (u_long)argp->prev_lsn.file,
01676 (u_long)argp->prev_lsn.offset);
01677 (void)printf("\tfileid: %ld\n", (long)argp->fileid);
01678 (void)printf("\tpgno: %lu\n", (u_long)argp->pgno);
01679 (void)printf("\tlsn: [%lu][%lu]\n",
01680 (u_long)argp->lsn.file, (u_long)argp->lsn.offset);
01681 (void)printf("\tindx: %lu\n", (u_long)argp->indx);
01682 (void)printf("\tisdeleted: %lu\n", (u_long)argp->isdeleted);
01683 (void)printf("\torig: ");
01684 for (i = 0; i < argp->orig.size; i++) {
01685 ch = ((u_int8_t *)argp->orig.data)[i];
01686 printf(isprint(ch) || ch == 0x0a ? "%c" : "%#x ", ch);
01687 }
01688 (void)printf("\n");
01689 (void)printf("\trepl: ");
01690 for (i = 0; i < argp->repl.size; i++) {
01691 ch = ((u_int8_t *)argp->repl.data)[i];
01692 printf(isprint(ch) || ch == 0x0a ? "%c" : "%#x ", ch);
01693 }
01694 (void)printf("\n");
01695 (void)printf("\tprefix: %lu\n", (u_long)argp->prefix);
01696 (void)printf("\tsuffix: %lu\n", (u_long)argp->suffix);
01697 (void)printf("\n");
01698 __os_free(dbenv, argp);
01699 return (0);
01700 }
01701
01702
01703
01704
01705 int
01706 __bam_repl_read(dbenv, recbuf, argpp)
01707 DB_ENV *dbenv;
01708 void *recbuf;
01709 __bam_repl_args **argpp;
01710 {
01711 __bam_repl_args *argp;
01712 u_int32_t uinttmp;
01713 u_int8_t *bp;
01714 int ret;
01715
01716 if ((ret = __os_malloc(dbenv,
01717 sizeof(__bam_repl_args) + sizeof(DB_TXN), &argp)) != 0)
01718 return (ret);
01719
01720 argp->txnid = (DB_TXN *)&argp[1];
01721
01722 bp = recbuf;
01723 memcpy(&argp->type, bp, sizeof(argp->type));
01724 bp += sizeof(argp->type);
01725
01726 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
01727 bp += sizeof(argp->txnid->txnid);
01728
01729 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
01730 bp += sizeof(DB_LSN);
01731
01732 memcpy(&uinttmp, bp, sizeof(uinttmp));
01733 argp->fileid = (int32_t)uinttmp;
01734 bp += sizeof(uinttmp);
01735
01736 memcpy(&uinttmp, bp, sizeof(uinttmp));
01737 argp->pgno = (db_pgno_t)uinttmp;
01738 bp += sizeof(uinttmp);
01739
01740 memcpy(&argp->lsn, bp, sizeof(argp->lsn));
01741 bp += sizeof(argp->lsn);
01742
01743 memcpy(&uinttmp, bp, sizeof(uinttmp));
01744 argp->indx = (u_int32_t)uinttmp;
01745 bp += sizeof(uinttmp);
01746
01747 memcpy(&uinttmp, bp, sizeof(uinttmp));
01748 argp->isdeleted = (u_int32_t)uinttmp;
01749 bp += sizeof(uinttmp);
01750
01751 memset(&argp->orig, 0, sizeof(argp->orig));
01752 memcpy(&argp->orig.size, bp, sizeof(u_int32_t));
01753 bp += sizeof(u_int32_t);
01754 argp->orig.data = bp;
01755 bp += argp->orig.size;
01756
01757 memset(&argp->repl, 0, sizeof(argp->repl));
01758 memcpy(&argp->repl.size, bp, sizeof(u_int32_t));
01759 bp += sizeof(u_int32_t);
01760 argp->repl.data = bp;
01761 bp += argp->repl.size;
01762
01763 memcpy(&uinttmp, bp, sizeof(uinttmp));
01764 argp->prefix = (u_int32_t)uinttmp;
01765 bp += sizeof(uinttmp);
01766
01767 memcpy(&uinttmp, bp, sizeof(uinttmp));
01768 argp->suffix = (u_int32_t)uinttmp;
01769 bp += sizeof(uinttmp);
01770
01771 *argpp = argp;
01772 return (0);
01773 }
01774
01775
01776
01777
01778
01779 int
01780 __bam_root_log(dbp, txnid, ret_lsnp, flags, meta_pgno, root_pgno, meta_lsn)
01781 DB *dbp;
01782 DB_TXN *txnid;
01783 DB_LSN *ret_lsnp;
01784 u_int32_t flags;
01785 db_pgno_t meta_pgno;
01786 db_pgno_t root_pgno;
01787 DB_LSN * meta_lsn;
01788 {
01789 DBT logrec;
01790 DB_ENV *dbenv;
01791 DB_LSN *lsnp, null_lsn;
01792 u_int32_t uinttmp;
01793 u_int32_t npad, rectype, txn_num;
01794 int ret;
01795 u_int8_t *bp;
01796
01797 dbenv = dbp->dbenv;
01798 rectype = DB___bam_root;
01799 npad = 0;
01800
01801 if (txnid == NULL) {
01802 txn_num = 0;
01803 null_lsn.file = 0;
01804 null_lsn.offset = 0;
01805 lsnp = &null_lsn;
01806 } else {
01807 if (TAILQ_FIRST(&txnid->kids) != NULL &&
01808 (ret = __txn_activekids(dbenv, rectype, txnid)) != 0)
01809 return (ret);
01810 txn_num = txnid->txnid;
01811 lsnp = &txnid->last_lsn;
01812 }
01813
01814 logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
01815 + sizeof(u_int32_t)
01816 + sizeof(u_int32_t)
01817 + sizeof(u_int32_t)
01818 + sizeof(*meta_lsn);
01819 if (CRYPTO_ON(dbenv)) {
01820 npad =
01821 ((DB_CIPHER *)dbenv->crypto_handle)->adj_size(logrec.size);
01822 logrec.size += npad;
01823 }
01824
01825 if ((ret = __os_malloc(dbenv,
01826 logrec.size, &logrec.data)) != 0)
01827 return (ret);
01828
01829 if (npad > 0)
01830 memset((u_int8_t *)logrec.data + logrec.size - npad, 0, npad);
01831
01832 bp = logrec.data;
01833
01834 memcpy(bp, &rectype, sizeof(rectype));
01835 bp += sizeof(rectype);
01836
01837 memcpy(bp, &txn_num, sizeof(txn_num));
01838 bp += sizeof(txn_num);
01839
01840 memcpy(bp, lsnp, sizeof(DB_LSN));
01841 bp += sizeof(DB_LSN);
01842
01843 DB_ASSERT(dbp->log_filename != NULL);
01844 if (dbp->log_filename->id == DB_LOGFILEID_INVALID &&
01845 (ret = __dbreg_lazy_id(dbp)) != 0)
01846 return (ret);
01847
01848 uinttmp = (u_int32_t)dbp->log_filename->id;
01849 memcpy(bp, &uinttmp, sizeof(uinttmp));
01850 bp += sizeof(uinttmp);
01851
01852 uinttmp = (u_int32_t)meta_pgno;
01853 memcpy(bp, &uinttmp, sizeof(uinttmp));
01854 bp += sizeof(uinttmp);
01855
01856 uinttmp = (u_int32_t)root_pgno;
01857 memcpy(bp, &uinttmp, sizeof(uinttmp));
01858 bp += sizeof(uinttmp);
01859
01860 if (meta_lsn != NULL)
01861 memcpy(bp, meta_lsn, sizeof(*meta_lsn));
01862 else
01863 memset(bp, 0, sizeof(*meta_lsn));
01864 bp += sizeof(*meta_lsn);
01865
01866 DB_ASSERT((u_int32_t)(bp - (u_int8_t *)logrec.data) <= logrec.size);
01867 ret = dbenv->log_put(dbenv,
01868 ret_lsnp, (DBT *)&logrec, flags | DB_NOCOPY);
01869 if (txnid != NULL && ret == 0)
01870 txnid->last_lsn = *ret_lsnp;
01871 #ifdef LOG_DIAGNOSTIC
01872 if (ret != 0)
01873 (void)__bam_root_print(dbenv,
01874 (DBT *)&logrec, ret_lsnp, NULL, NULL);
01875 #endif
01876 __os_free(dbenv, logrec.data);
01877 return (ret);
01878 }
01879
01880
01881
01882
01883
01884 int
01885 __bam_root_getpgnos(dbenv, rec, lsnp, notused1, summary)
01886 DB_ENV *dbenv;
01887 DBT *rec;
01888 DB_LSN *lsnp;
01889 db_recops notused1;
01890 void *summary;
01891 {
01892 DB *dbp;
01893 TXN_RECS *t;
01894 __bam_root_args *argp;
01895 u_int32_t ret;
01896
01897 COMPQUIET(notused1, DB_TXN_ABORT);
01898
01899 argp = NULL;
01900 t = (TXN_RECS *)summary;
01901
01902 if ((ret = __bam_root_read(dbenv, rec->data, &argp)) != 0)
01903 return (ret);
01904
01905 if ((ret = __dbreg_id_to_db(dbenv,
01906 argp->txnid, &dbp, argp->fileid, 0)) != 0)
01907 goto err;
01908
01909 if ((ret = __rep_check_alloc(dbenv, t, 2)) != 0)
01910 goto err;
01911
01912 t->array[t->npages].flags = 0;
01913 t->array[t->npages].fid = argp->fileid;
01914 t->array[t->npages].lsn = *lsnp;
01915 t->array[t->npages].pgdesc.pgno = argp->meta_pgno;
01916 t->array[t->npages].pgdesc.type = DB_PAGE_LOCK;
01917 memcpy(t->array[t->npages].pgdesc.fileid, dbp->fileid,
01918 DB_FILE_ID_LEN);
01919 t->npages++;
01920 t->array[t->npages].flags = 0;
01921 t->array[t->npages].fid = argp->fileid;
01922 t->array[t->npages].lsn = *lsnp;
01923 t->array[t->npages].pgdesc.pgno = argp->root_pgno;
01924 t->array[t->npages].pgdesc.type = DB_PAGE_LOCK;
01925 memcpy(t->array[t->npages].pgdesc.fileid, dbp->fileid,
01926 DB_FILE_ID_LEN);
01927 t->npages++;
01928
01929 err: if (argp != NULL)
01930 __os_free(dbenv, argp);
01931 return (ret);
01932 }
01933
01934
01935
01936
01937
01938 int
01939 __bam_root_print(dbenv, dbtp, lsnp, notused2, notused3)
01940 DB_ENV *dbenv;
01941 DBT *dbtp;
01942 DB_LSN *lsnp;
01943 db_recops notused2;
01944 void *notused3;
01945 {
01946 __bam_root_args *argp;
01947 int ret;
01948
01949 notused2 = DB_TXN_ABORT;
01950 notused3 = NULL;
01951
01952 if ((ret = __bam_root_read(dbenv, dbtp->data, &argp)) != 0)
01953 return (ret);
01954 (void)printf(
01955 "[%lu][%lu]__bam_root: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
01956 (u_long)lsnp->file,
01957 (u_long)lsnp->offset,
01958 (u_long)argp->type,
01959 (u_long)argp->txnid->txnid,
01960 (u_long)argp->prev_lsn.file,
01961 (u_long)argp->prev_lsn.offset);
01962 (void)printf("\tfileid: %ld\n", (long)argp->fileid);
01963 (void)printf("\tmeta_pgno: %lu\n", (u_long)argp->meta_pgno);
01964 (void)printf("\troot_pgno: %lu\n", (u_long)argp->root_pgno);
01965 (void)printf("\tmeta_lsn: [%lu][%lu]\n",
01966 (u_long)argp->meta_lsn.file, (u_long)argp->meta_lsn.offset);
01967 (void)printf("\n");
01968 __os_free(dbenv, argp);
01969 return (0);
01970 }
01971
01972
01973
01974
01975 int
01976 __bam_root_read(dbenv, recbuf, argpp)
01977 DB_ENV *dbenv;
01978 void *recbuf;
01979 __bam_root_args **argpp;
01980 {
01981 __bam_root_args *argp;
01982 u_int32_t uinttmp;
01983 u_int8_t *bp;
01984 int ret;
01985
01986 if ((ret = __os_malloc(dbenv,
01987 sizeof(__bam_root_args) + sizeof(DB_TXN), &argp)) != 0)
01988 return (ret);
01989
01990 argp->txnid = (DB_TXN *)&argp[1];
01991
01992 bp = recbuf;
01993 memcpy(&argp->type, bp, sizeof(argp->type));
01994 bp += sizeof(argp->type);
01995
01996 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
01997 bp += sizeof(argp->txnid->txnid);
01998
01999 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
02000 bp += sizeof(DB_LSN);
02001
02002 memcpy(&uinttmp, bp, sizeof(uinttmp));
02003 argp->fileid = (int32_t)uinttmp;
02004 bp += sizeof(uinttmp);
02005
02006 memcpy(&uinttmp, bp, sizeof(uinttmp));
02007 argp->meta_pgno = (db_pgno_t)uinttmp;
02008 bp += sizeof(uinttmp);
02009
02010 memcpy(&uinttmp, bp, sizeof(uinttmp));
02011 argp->root_pgno = (db_pgno_t)uinttmp;
02012 bp += sizeof(uinttmp);
02013
02014 memcpy(&argp->meta_lsn, bp, sizeof(argp->meta_lsn));
02015 bp += sizeof(argp->meta_lsn);
02016
02017 *argpp = argp;
02018 return (0);
02019 }
02020
02021
02022
02023
02024
02025
02026 int
02027 __bam_curadj_log(dbp, txnid, ret_lsnp, flags, mode, from_pgno, to_pgno, left_pgno, first_indx,
02028 from_indx, to_indx)
02029 DB *dbp;
02030 DB_TXN *txnid;
02031 DB_LSN *ret_lsnp;
02032 u_int32_t flags;
02033 db_ca_mode mode;
02034 db_pgno_t from_pgno;
02035 db_pgno_t to_pgno;
02036 db_pgno_t left_pgno;
02037 u_int32_t first_indx;
02038 u_int32_t from_indx;
02039 u_int32_t to_indx;
02040 {
02041 DBT logrec;
02042 DB_ENV *dbenv;
02043 DB_LSN *lsnp, null_lsn;
02044 u_int32_t uinttmp;
02045 u_int32_t npad, rectype, txn_num;
02046 int ret;
02047 u_int8_t *bp;
02048
02049 dbenv = dbp->dbenv;
02050 rectype = DB___bam_curadj;
02051 npad = 0;
02052
02053 if (txnid == NULL) {
02054 txn_num = 0;
02055 null_lsn.file = 0;
02056 null_lsn.offset = 0;
02057 lsnp = &null_lsn;
02058 } else {
02059 if (TAILQ_FIRST(&txnid->kids) != NULL &&
02060 (ret = __txn_activekids(dbenv, rectype, txnid)) != 0)
02061 return (ret);
02062 txn_num = txnid->txnid;
02063 lsnp = &txnid->last_lsn;
02064 }
02065
02066 logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
02067 + sizeof(u_int32_t)
02068 + sizeof(u_int32_t)
02069 + sizeof(u_int32_t)
02070 + sizeof(u_int32_t)
02071 + sizeof(u_int32_t)
02072 + sizeof(u_int32_t)
02073 + sizeof(u_int32_t)
02074 + sizeof(u_int32_t);
02075 if (CRYPTO_ON(dbenv)) {
02076 npad =
02077 ((DB_CIPHER *)dbenv->crypto_handle)->adj_size(logrec.size);
02078 logrec.size += npad;
02079 }
02080
02081 if ((ret = __os_malloc(dbenv,
02082 logrec.size, &logrec.data)) != 0)
02083 return (ret);
02084
02085 if (npad > 0)
02086 memset((u_int8_t *)logrec.data + logrec.size - npad, 0, npad);
02087
02088 bp = logrec.data;
02089
02090 memcpy(bp, &rectype, sizeof(rectype));
02091 bp += sizeof(rectype);
02092
02093 memcpy(bp, &txn_num, sizeof(txn_num));
02094 bp += sizeof(txn_num);
02095
02096 memcpy(bp, lsnp, sizeof(DB_LSN));
02097 bp += sizeof(DB_LSN);
02098
02099 DB_ASSERT(dbp->log_filename != NULL);
02100 if (dbp->log_filename->id == DB_LOGFILEID_INVALID &&
02101 (ret = __dbreg_lazy_id(dbp)) != 0)
02102 return (ret);
02103
02104 uinttmp = (u_int32_t)dbp->log_filename->id;
02105 memcpy(bp, &uinttmp, sizeof(uinttmp));
02106 bp += sizeof(uinttmp);
02107
02108 uinttmp = (u_int32_t)mode;
02109 memcpy(bp, &uinttmp, sizeof(uinttmp));
02110 bp += sizeof(uinttmp);
02111
02112 uinttmp = (u_int32_t)from_pgno;
02113 memcpy(bp, &uinttmp, sizeof(uinttmp));
02114 bp += sizeof(uinttmp);
02115
02116 uinttmp = (u_int32_t)to_pgno;
02117 memcpy(bp, &uinttmp, sizeof(uinttmp));
02118 bp += sizeof(uinttmp);
02119
02120 uinttmp = (u_int32_t)left_pgno;
02121 memcpy(bp, &uinttmp, sizeof(uinttmp));
02122 bp += sizeof(uinttmp);
02123
02124 uinttmp = (u_int32_t)first_indx;
02125 memcpy(bp, &uinttmp, sizeof(uinttmp));
02126 bp += sizeof(uinttmp);
02127
02128 uinttmp = (u_int32_t)from_indx;
02129 memcpy(bp, &uinttmp, sizeof(uinttmp));
02130 bp += sizeof(uinttmp);
02131
02132 uinttmp = (u_int32_t)to_indx;
02133 memcpy(bp, &uinttmp, sizeof(uinttmp));
02134 bp += sizeof(uinttmp);
02135
02136 DB_ASSERT((u_int32_t)(bp - (u_int8_t *)logrec.data) <= logrec.size);
02137 ret = dbenv->log_put(dbenv,
02138 ret_lsnp, (DBT *)&logrec, flags | DB_NOCOPY);
02139 if (txnid != NULL && ret == 0)
02140 txnid->last_lsn = *ret_lsnp;
02141 #ifdef LOG_DIAGNOSTIC
02142 if (ret != 0)
02143 (void)__bam_curadj_print(dbenv,
02144 (DBT *)&logrec, ret_lsnp, NULL, NULL);
02145 #endif
02146 __os_free(dbenv, logrec.data);
02147 return (ret);
02148 }
02149
02150
02151
02152
02153
02154 int
02155 __bam_curadj_getpgnos(dbenv, rec, lsnp, notused1, summary)
02156 DB_ENV *dbenv;
02157 DBT *rec;
02158 DB_LSN *lsnp;
02159 db_recops notused1;
02160 void *summary;
02161 {
02162 TXN_RECS *t;
02163 int ret;
02164 COMPQUIET(rec, NULL);
02165 COMPQUIET(notused1, DB_TXN_ABORT);
02166
02167 t = (TXN_RECS *)summary;
02168
02169 if ((ret = __rep_check_alloc(dbenv, t, 1)) != 0)
02170 return (ret);
02171
02172 t->array[t->npages].flags = LSN_PAGE_NOLOCK;
02173 t->array[t->npages].lsn = *lsnp;
02174 t->array[t->npages].fid = DB_LOGFILEID_INVALID;
02175 memset(&t->array[t->npages].pgdesc, 0,
02176 sizeof(t->array[t->npages].pgdesc));
02177
02178 t->npages++;
02179
02180 return (0);
02181 }
02182
02183
02184
02185
02186
02187 int
02188 __bam_curadj_print(dbenv, dbtp, lsnp, notused2, notused3)
02189 DB_ENV *dbenv;
02190 DBT *dbtp;
02191 DB_LSN *lsnp;
02192 db_recops notused2;
02193 void *notused3;
02194 {
02195 __bam_curadj_args *argp;
02196 int ret;
02197
02198 notused2 = DB_TXN_ABORT;
02199 notused3 = NULL;
02200
02201 if ((ret = __bam_curadj_read(dbenv, dbtp->data, &argp)) != 0)
02202 return (ret);
02203 (void)printf(
02204 "[%lu][%lu]__bam_curadj: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
02205 (u_long)lsnp->file,
02206 (u_long)lsnp->offset,
02207 (u_long)argp->type,
02208 (u_long)argp->txnid->txnid,
02209 (u_long)argp->prev_lsn.file,
02210 (u_long)argp->prev_lsn.offset);
02211 (void)printf("\tfileid: %ld\n", (long)argp->fileid);
02212 (void)printf("\tmode: %ld\n", (long)argp->mode);
02213 (void)printf("\tfrom_pgno: %lu\n", (u_long)argp->from_pgno);
02214 (void)printf("\tto_pgno: %lu\n", (u_long)argp->to_pgno);
02215 (void)printf("\tleft_pgno: %lu\n", (u_long)argp->left_pgno);
02216 (void)printf("\tfirst_indx: %lu\n", (u_long)argp->first_indx);
02217 (void)printf("\tfrom_indx: %lu\n", (u_long)argp->from_indx);
02218 (void)printf("\tto_indx: %lu\n", (u_long)argp->to_indx);
02219 (void)printf("\n");
02220 __os_free(dbenv, argp);
02221 return (0);
02222 }
02223
02224
02225
02226
02227 int
02228 __bam_curadj_read(dbenv, recbuf, argpp)
02229 DB_ENV *dbenv;
02230 void *recbuf;
02231 __bam_curadj_args **argpp;
02232 {
02233 __bam_curadj_args *argp;
02234 u_int32_t uinttmp;
02235 u_int8_t *bp;
02236 int ret;
02237
02238 if ((ret = __os_malloc(dbenv,
02239 sizeof(__bam_curadj_args) + sizeof(DB_TXN), &argp)) != 0)
02240 return (ret);
02241
02242 argp->txnid = (DB_TXN *)&argp[1];
02243
02244 bp = recbuf;
02245 memcpy(&argp->type, bp, sizeof(argp->type));
02246 bp += sizeof(argp->type);
02247
02248 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
02249 bp += sizeof(argp->txnid->txnid);
02250
02251 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
02252 bp += sizeof(DB_LSN);
02253
02254 memcpy(&uinttmp, bp, sizeof(uinttmp));
02255 argp->fileid = (int32_t)uinttmp;
02256 bp += sizeof(uinttmp);
02257
02258 memcpy(&uinttmp, bp, sizeof(uinttmp));
02259 argp->mode = (db_ca_mode)uinttmp;
02260 bp += sizeof(uinttmp);
02261
02262 memcpy(&uinttmp, bp, sizeof(uinttmp));
02263 argp->from_pgno = (db_pgno_t)uinttmp;
02264 bp += sizeof(uinttmp);
02265
02266 memcpy(&uinttmp, bp, sizeof(uinttmp));
02267 argp->to_pgno = (db_pgno_t)uinttmp;
02268 bp += sizeof(uinttmp);
02269
02270 memcpy(&uinttmp, bp, sizeof(uinttmp));
02271 argp->left_pgno = (db_pgno_t)uinttmp;
02272 bp += sizeof(uinttmp);
02273
02274 memcpy(&uinttmp, bp, sizeof(uinttmp));
02275 argp->first_indx = (u_int32_t)uinttmp;
02276 bp += sizeof(uinttmp);
02277
02278 memcpy(&uinttmp, bp, sizeof(uinttmp));
02279 argp->from_indx = (u_int32_t)uinttmp;
02280 bp += sizeof(uinttmp);
02281
02282 memcpy(&uinttmp, bp, sizeof(uinttmp));
02283 argp->to_indx = (u_int32_t)uinttmp;
02284 bp += sizeof(uinttmp);
02285
02286 *argpp = argp;
02287 return (0);
02288 }
02289
02290
02291
02292
02293
02294 int
02295 __bam_rcuradj_log(dbp, txnid, ret_lsnp, flags, mode, root, recno, order)
02296 DB *dbp;
02297 DB_TXN *txnid;
02298 DB_LSN *ret_lsnp;
02299 u_int32_t flags;
02300 ca_recno_arg mode;
02301 db_pgno_t root;
02302 db_recno_t recno;
02303 u_int32_t order;
02304 {
02305 DBT logrec;
02306 DB_ENV *dbenv;
02307 DB_LSN *lsnp, null_lsn;
02308 u_int32_t uinttmp;
02309 u_int32_t npad, rectype, txn_num;
02310 int ret;
02311 u_int8_t *bp;
02312
02313 dbenv = dbp->dbenv;
02314 rectype = DB___bam_rcuradj;
02315 npad = 0;
02316
02317 if (txnid == NULL) {
02318 txn_num = 0;
02319 null_lsn.file = 0;
02320 null_lsn.offset = 0;
02321 lsnp = &null_lsn;
02322 } else {
02323 if (TAILQ_FIRST(&txnid->kids) != NULL &&
02324 (ret = __txn_activekids(dbenv, rectype, txnid)) != 0)
02325 return (ret);
02326 txn_num = txnid->txnid;
02327 lsnp = &txnid->last_lsn;
02328 }
02329
02330 logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
02331 + sizeof(u_int32_t)
02332 + sizeof(u_int32_t)
02333 + sizeof(u_int32_t)
02334 + sizeof(u_int32_t)
02335 + sizeof(u_int32_t);
02336 if (CRYPTO_ON(dbenv)) {
02337 npad =
02338 ((DB_CIPHER *)dbenv->crypto_handle)->adj_size(logrec.size);
02339 logrec.size += npad;
02340 }
02341
02342 if ((ret = __os_malloc(dbenv,
02343 logrec.size, &logrec.data)) != 0)
02344 return (ret);
02345
02346 if (npad > 0)
02347 memset((u_int8_t *)logrec.data + logrec.size - npad, 0, npad);
02348
02349 bp = logrec.data;
02350
02351 memcpy(bp, &rectype, sizeof(rectype));
02352 bp += sizeof(rectype);
02353
02354 memcpy(bp, &txn_num, sizeof(txn_num));
02355 bp += sizeof(txn_num);
02356
02357 memcpy(bp, lsnp, sizeof(DB_LSN));
02358 bp += sizeof(DB_LSN);
02359
02360 DB_ASSERT(dbp->log_filename != NULL);
02361 if (dbp->log_filename->id == DB_LOGFILEID_INVALID &&
02362 (ret = __dbreg_lazy_id(dbp)) != 0)
02363 return (ret);
02364
02365 uinttmp = (u_int32_t)dbp->log_filename->id;
02366 memcpy(bp, &uinttmp, sizeof(uinttmp));
02367 bp += sizeof(uinttmp);
02368
02369 uinttmp = (u_int32_t)mode;
02370 memcpy(bp, &uinttmp, sizeof(uinttmp));
02371 bp += sizeof(uinttmp);
02372
02373 uinttmp = (u_int32_t)root;
02374 memcpy(bp, &uinttmp, sizeof(uinttmp));
02375 bp += sizeof(uinttmp);
02376
02377 uinttmp = (u_int32_t)recno;
02378 memcpy(bp, &uinttmp, sizeof(uinttmp));
02379 bp += sizeof(uinttmp);
02380
02381 uinttmp = (u_int32_t)order;
02382 memcpy(bp, &uinttmp, sizeof(uinttmp));
02383 bp += sizeof(uinttmp);
02384
02385 DB_ASSERT((u_int32_t)(bp - (u_int8_t *)logrec.data) <= logrec.size);
02386 ret = dbenv->log_put(dbenv,
02387 ret_lsnp, (DBT *)&logrec, flags | DB_NOCOPY);
02388 if (txnid != NULL && ret == 0)
02389 txnid->last_lsn = *ret_lsnp;
02390 #ifdef LOG_DIAGNOSTIC
02391 if (ret != 0)
02392 (void)__bam_rcuradj_print(dbenv,
02393 (DBT *)&logrec, ret_lsnp, NULL, NULL);
02394 #endif
02395 __os_free(dbenv, logrec.data);
02396 return (ret);
02397 }
02398
02399
02400
02401
02402
02403 int
02404 __bam_rcuradj_getpgnos(dbenv, rec, lsnp, notused1, summary)
02405 DB_ENV *dbenv;
02406 DBT *rec;
02407 DB_LSN *lsnp;
02408 db_recops notused1;
02409 void *summary;
02410 {
02411 TXN_RECS *t;
02412 int ret;
02413 COMPQUIET(rec, NULL);
02414 COMPQUIET(notused1, DB_TXN_ABORT);
02415
02416 t = (TXN_RECS *)summary;
02417
02418 if ((ret = __rep_check_alloc(dbenv, t, 1)) != 0)
02419 return (ret);
02420
02421 t->array[t->npages].flags = LSN_PAGE_NOLOCK;
02422 t->array[t->npages].lsn = *lsnp;
02423 t->array[t->npages].fid = DB_LOGFILEID_INVALID;
02424 memset(&t->array[t->npages].pgdesc, 0,
02425 sizeof(t->array[t->npages].pgdesc));
02426
02427 t->npages++;
02428
02429 return (0);
02430 }
02431
02432
02433
02434
02435
02436 int
02437 __bam_rcuradj_print(dbenv, dbtp, lsnp, notused2, notused3)
02438 DB_ENV *dbenv;
02439 DBT *dbtp;
02440 DB_LSN *lsnp;
02441 db_recops notused2;
02442 void *notused3;
02443 {
02444 __bam_rcuradj_args *argp;
02445 int ret;
02446
02447 notused2 = DB_TXN_ABORT;
02448 notused3 = NULL;
02449
02450 if ((ret = __bam_rcuradj_read(dbenv, dbtp->data, &argp)) != 0)
02451 return (ret);
02452 (void)printf(
02453 "[%lu][%lu]__bam_rcuradj: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
02454 (u_long)lsnp->file,
02455 (u_long)lsnp->offset,
02456 (u_long)argp->type,
02457 (u_long)argp->txnid->txnid,
02458 (u_long)argp->prev_lsn.file,
02459 (u_long)argp->prev_lsn.offset);
02460 (void)printf("\tfileid: %ld\n", (long)argp->fileid);
02461 (void)printf("\tmode: %ld\n", (long)argp->mode);
02462 (void)printf("\troot: %ld\n", (long)argp->root);
02463 (void)printf("\trecno: %ld\n", (long)argp->recno);
02464 (void)printf("\torder: %ld\n", (long)argp->order);
02465 (void)printf("\n");
02466 __os_free(dbenv, argp);
02467 return (0);
02468 }
02469
02470
02471
02472
02473
02474 int
02475 __bam_rcuradj_read(dbenv, recbuf, argpp)
02476 DB_ENV *dbenv;
02477 void *recbuf;
02478 __bam_rcuradj_args **argpp;
02479 {
02480 __bam_rcuradj_args *argp;
02481 u_int32_t uinttmp;
02482 u_int8_t *bp;
02483 int ret;
02484
02485 if ((ret = __os_malloc(dbenv,
02486 sizeof(__bam_rcuradj_args) + sizeof(DB_TXN), &argp)) != 0)
02487 return (ret);
02488
02489 argp->txnid = (DB_TXN *)&argp[1];
02490
02491 bp = recbuf;
02492 memcpy(&argp->type, bp, sizeof(argp->type));
02493 bp += sizeof(argp->type);
02494
02495 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
02496 bp += sizeof(argp->txnid->txnid);
02497
02498 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
02499 bp += sizeof(DB_LSN);
02500
02501 memcpy(&uinttmp, bp, sizeof(uinttmp));
02502 argp->fileid = (int32_t)uinttmp;
02503 bp += sizeof(uinttmp);
02504
02505 memcpy(&uinttmp, bp, sizeof(uinttmp));
02506 argp->mode = (ca_recno_arg)uinttmp;
02507 bp += sizeof(uinttmp);
02508
02509 memcpy(&uinttmp, bp, sizeof(uinttmp));
02510 argp->root = (db_pgno_t)uinttmp;
02511 bp += sizeof(uinttmp);
02512
02513 memcpy(&uinttmp, bp, sizeof(uinttmp));
02514 argp->recno = (db_recno_t)uinttmp;
02515 bp += sizeof(uinttmp);
02516
02517 memcpy(&uinttmp, bp, sizeof(uinttmp));
02518 argp->order = (u_int32_t)uinttmp;
02519 bp += sizeof(uinttmp);
02520
02521 *argpp = argp;
02522 return (0);
02523 }
02524
02525
02526
02527
02528
02529 int
02530 __bam_init_print(dbenv, dtabp, dtabsizep)
02531 DB_ENV *dbenv;
02532 int (***dtabp)__P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
02533 size_t *dtabsizep;
02534 {
02535 int ret;
02536
02537 if ((ret = __db_add_recovery(dbenv, dtabp, dtabsizep,
02538 __bam_split_print, DB___bam_split)) != 0)
02539 return (ret);
02540 if ((ret = __db_add_recovery(dbenv, dtabp, dtabsizep,
02541 __bam_rsplit_print, DB___bam_rsplit)) != 0)
02542 return (ret);
02543 if ((ret = __db_add_recovery(dbenv, dtabp, dtabsizep,
02544 __bam_adj_print, DB___bam_adj)) != 0)
02545 return (ret);
02546 if ((ret = __db_add_recovery(dbenv, dtabp, dtabsizep,
02547 __bam_cadjust_print, DB___bam_cadjust)) != 0)
02548 return (ret);
02549 if ((ret = __db_add_recovery(dbenv, dtabp, dtabsizep,
02550 __bam_cdel_print, DB___bam_cdel)) != 0)
02551 return (ret);
02552 if ((ret = __db_add_recovery(dbenv, dtabp, dtabsizep,
02553 __bam_repl_print, DB___bam_repl)) != 0)
02554 return (ret);
02555 if ((ret = __db_add_recovery(dbenv, dtabp, dtabsizep,
02556 __bam_root_print, DB___bam_root)) != 0)
02557 return (ret);
02558 if ((ret = __db_add_recovery(dbenv, dtabp, dtabsizep,
02559 __bam_curadj_print, DB___bam_curadj)) != 0)
02560 return (ret);
02561 if ((ret = __db_add_recovery(dbenv, dtabp, dtabsizep,
02562 __bam_rcuradj_print, DB___bam_rcuradj)) != 0)
02563 return (ret);
02564 return (0);
02565 }
02566
02567
02568
02569
02570
02571 int
02572 __bam_init_getpgnos(dbenv, dtabp, dtabsizep)
02573 DB_ENV *dbenv;
02574 int (***dtabp)__P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
02575 size_t *dtabsizep;
02576 {
02577 int ret;
02578
02579 if ((ret = __db_add_recovery(dbenv, dtabp, dtabsizep,
02580 __bam_split_getpgnos, DB___bam_split)) != 0)
02581 return (ret);
02582 if ((ret = __db_add_recovery(dbenv, dtabp, dtabsizep,
02583 __bam_rsplit_getpgnos, DB___bam_rsplit)) != 0)
02584 return (ret);
02585 if ((ret = __db_add_recovery(dbenv, dtabp, dtabsizep,
02586 __bam_adj_getpgnos, DB___bam_adj)) != 0)
02587 return (ret);
02588 if ((ret = __db_add_recovery(dbenv, dtabp, dtabsizep,
02589 __bam_cadjust_getpgnos, DB___bam_cadjust)) != 0)
02590 return (ret);
02591 if ((ret = __db_add_recovery(dbenv, dtabp, dtabsizep,
02592 __bam_cdel_getpgnos, DB___bam_cdel)) != 0)
02593 return (ret);
02594 if ((ret = __db_add_recovery(dbenv, dtabp, dtabsizep,
02595 __bam_repl_getpgnos, DB___bam_repl)) != 0)
02596 return (ret);
02597 if ((ret = __db_add_recovery(dbenv, dtabp, dtabsizep,
02598 __bam_root_getpgnos, DB___bam_root)) != 0)
02599 return (ret);
02600 if ((ret = __db_add_recovery(dbenv, dtabp, dtabsizep,
02601 __bam_curadj_getpgnos, DB___bam_curadj)) != 0)
02602 return (ret);
02603 if ((ret = __db_add_recovery(dbenv, dtabp, dtabsizep,
02604 __bam_rcuradj_getpgnos, DB___bam_rcuradj)) != 0)
02605 return (ret);
02606 return (0);
02607 }
02608
02609
02610
02611
02612
02613 int
02614 __bam_init_recover(dbenv, dtabp, dtabsizep)
02615 DB_ENV *dbenv;
02616 int (***dtabp)__P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
02617 size_t *dtabsizep;
02618 {
02619 int ret;
02620
02621 if ((ret = __db_add_recovery(dbenv, dtabp, dtabsizep,
02622 __bam_split_recover, DB___bam_split)) != 0)
02623 return (ret);
02624 if ((ret = __db_add_recovery(dbenv, dtabp, dtabsizep,
02625 __bam_rsplit_recover, DB___bam_rsplit)) != 0)
02626 return (ret);
02627 if ((ret = __db_add_recovery(dbenv, dtabp, dtabsizep,
02628 __bam_adj_recover, DB___bam_adj)) != 0)
02629 return (ret);
02630 if ((ret = __db_add_recovery(dbenv, dtabp, dtabsizep,
02631 __bam_cadjust_recover, DB___bam_cadjust)) != 0)
02632 return (ret);
02633 if ((ret = __db_add_recovery(dbenv, dtabp, dtabsizep,
02634 __bam_cdel_recover, DB___bam_cdel)) != 0)
02635 return (ret);
02636 if ((ret = __db_add_recovery(dbenv, dtabp, dtabsizep,
02637 __bam_repl_recover, DB___bam_repl)) != 0)
02638 return (ret);
02639 if ((ret = __db_add_recovery(dbenv, dtabp, dtabsizep,
02640 __bam_root_recover, DB___bam_root)) != 0)
02641 return (ret);
02642 if ((ret = __db_add_recovery(dbenv, dtabp, dtabsizep,
02643 __bam_curadj_recover, DB___bam_curadj)) != 0)
02644 return (ret);
02645 if ((ret = __db_add_recovery(dbenv, dtabp, dtabsizep,
02646 __bam_rcuradj_recover, DB___bam_rcuradj)) != 0)
02647 return (ret);
02648 return (0);
02649 }