00001
00002 #include "config.h"
00003
00004 #ifndef NO_SYSTEM_INCLUDES
00005 #include <sys/types.h>
00006
00007 #include <ctype.h>
00008 #include <errno.h>
00009 #include <string.h>
00010 #endif
00011
00012 #include "db_int.h"
00013 #include "db_page.h"
00014 #include "db_dispatch.h"
00015 #include "db_am.h"
00016 #include "hash.h"
00017 #include "txn.h"
00018
00019 int CDB___ham_insdel_log(dbenv, txnid, ret_lsnp, flags,
00020 opcode, fileid, pgno, ndx, pagelsn, key,
00021 data)
00022 DB_ENV *dbenv;
00023 DB_TXN *txnid;
00024 DB_LSN *ret_lsnp;
00025 u_int32_t flags;
00026 u_int32_t opcode;
00027 int32_t fileid;
00028 db_pgno_t pgno;
00029 u_int32_t ndx;
00030 DB_LSN * pagelsn;
00031 const DBT *key;
00032 const DBT *data;
00033 {
00034 DBT logrec;
00035 DB_LSN *lsnp, null_lsn;
00036 u_int32_t zero;
00037 u_int32_t rectype, txn_num;
00038 int ret;
00039 u_int8_t *bp;
00040
00041 if (txnid != NULL &&
00042 TAILQ_FIRST(&txnid->kids) != NULL && CDB___txn_activekids(txnid) != 0)
00043 return (CDB___db_child_active_err(dbenv));
00044 rectype = DB_ham_insdel;
00045 txn_num = txnid == NULL ? 0 : txnid->txnid;
00046 if (txnid == NULL) {
00047 ZERO_LSN(null_lsn);
00048 lsnp = &null_lsn;
00049 } else
00050 lsnp = &txnid->last_lsn;
00051 logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
00052 + sizeof(opcode)
00053 + sizeof(fileid)
00054 + sizeof(pgno)
00055 + sizeof(ndx)
00056 + sizeof(*pagelsn)
00057 + sizeof(u_int32_t) + (key == NULL ? 0 : key->size)
00058 + sizeof(u_int32_t) + (data == NULL ? 0 : data->size);
00059 if ((ret = CDB___os_malloc(dbenv, logrec.size, NULL, &logrec.data)) != 0)
00060 return (ret);
00061
00062 bp = logrec.data;
00063 memcpy(bp, &rectype, sizeof(rectype));
00064 bp += sizeof(rectype);
00065 memcpy(bp, &txn_num, sizeof(txn_num));
00066 bp += sizeof(txn_num);
00067 memcpy(bp, lsnp, sizeof(DB_LSN));
00068 bp += sizeof(DB_LSN);
00069 memcpy(bp, &opcode, sizeof(opcode));
00070 bp += sizeof(opcode);
00071 memcpy(bp, &fileid, sizeof(fileid));
00072 bp += sizeof(fileid);
00073 memcpy(bp, &pgno, sizeof(pgno));
00074 bp += sizeof(pgno);
00075 memcpy(bp, &ndx, sizeof(ndx));
00076 bp += sizeof(ndx);
00077 if (pagelsn != NULL)
00078 memcpy(bp, pagelsn, sizeof(*pagelsn));
00079 else
00080 memset(bp, 0, sizeof(*pagelsn));
00081 bp += sizeof(*pagelsn);
00082 if (key == NULL) {
00083 zero = 0;
00084 memcpy(bp, &zero, sizeof(u_int32_t));
00085 bp += sizeof(u_int32_t);
00086 } else {
00087 memcpy(bp, &key->size, sizeof(key->size));
00088 bp += sizeof(key->size);
00089 memcpy(bp, key->data, key->size);
00090 bp += key->size;
00091 }
00092 if (data == NULL) {
00093 zero = 0;
00094 memcpy(bp, &zero, sizeof(u_int32_t));
00095 bp += sizeof(u_int32_t);
00096 } else {
00097 memcpy(bp, &data->size, sizeof(data->size));
00098 bp += sizeof(data->size);
00099 memcpy(bp, data->data, data->size);
00100 bp += data->size;
00101 }
00102 DB_ASSERT((u_int32_t)(bp - (u_int8_t *)logrec.data) == logrec.size);
00103 ret = CDB_log_put(dbenv, ret_lsnp, (DBT *)&logrec, flags);
00104 if (txnid != NULL)
00105 txnid->last_lsn = *ret_lsnp;
00106 CDB___os_free(logrec.data, logrec.size);
00107 return (ret);
00108 }
00109
00110 int
00111 CDB___ham_insdel_print(dbenv, dbtp, lsnp, notused2, notused3)
00112 DB_ENV *dbenv;
00113 DBT *dbtp;
00114 DB_LSN *lsnp;
00115 db_recops notused2;
00116 void *notused3;
00117 {
00118 __ham_insdel_args *argp;
00119 u_int32_t i;
00120 u_int ch;
00121 int ret;
00122
00123 i = 0;
00124 ch = 0;
00125 notused2 = 0;
00126 notused3 = NULL;
00127
00128 if ((ret = CDB___ham_insdel_read(dbenv, dbtp->data, &argp)) != 0)
00129 return (ret);
00130 printf("[%lu][%lu]ham_insdel: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
00131 (u_long)lsnp->file,
00132 (u_long)lsnp->offset,
00133 (u_long)argp->type,
00134 (u_long)argp->txnid->txnid,
00135 (u_long)argp->prev_lsn.file,
00136 (u_long)argp->prev_lsn.offset);
00137 printf("\topcode: %lu\n", (u_long)argp->opcode);
00138 printf("\tfileid: %ld\n", (long)argp->fileid);
00139 printf("\tpgno: %lu\n", (u_long)argp->pgno);
00140 printf("\tndx: %lu\n", (u_long)argp->ndx);
00141 printf("\tpagelsn: [%lu][%lu]\n",
00142 (u_long)argp->pagelsn.file, (u_long)argp->pagelsn.offset);
00143 printf("\tkey: ");
00144 for (i = 0; i < argp->key.size; i++) {
00145 ch = ((u_int8_t *)argp->key.data)[i];
00146 if (isprint(ch) || ch == 0xa)
00147 putchar(ch);
00148 else
00149 printf("%#x ", ch);
00150 }
00151 printf("\n");
00152 printf("\tdata: ");
00153 for (i = 0; i < argp->data.size; i++) {
00154 ch = ((u_int8_t *)argp->data.data)[i];
00155 if (isprint(ch) || ch == 0xa)
00156 putchar(ch);
00157 else
00158 printf("%#x ", ch);
00159 }
00160 printf("\n");
00161 printf("\n");
00162 CDB___os_free(argp, 0);
00163 return (0);
00164 }
00165
00166 int
00167 CDB___ham_insdel_read(dbenv, recbuf, argpp)
00168 DB_ENV *dbenv;
00169 void *recbuf;
00170 __ham_insdel_args **argpp;
00171 {
00172 __ham_insdel_args *argp;
00173 u_int8_t *bp;
00174 int ret;
00175
00176 ret = CDB___os_malloc(dbenv, sizeof(__ham_insdel_args) +
00177 sizeof(DB_TXN), NULL, &argp);
00178 if (ret != 0)
00179 return (ret);
00180 argp->txnid = (DB_TXN *)&argp[1];
00181 bp = recbuf;
00182 memcpy(&argp->type, bp, sizeof(argp->type));
00183 bp += sizeof(argp->type);
00184 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
00185 bp += sizeof(argp->txnid->txnid);
00186 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
00187 bp += sizeof(DB_LSN);
00188 memcpy(&argp->opcode, bp, sizeof(argp->opcode));
00189 bp += sizeof(argp->opcode);
00190 memcpy(&argp->fileid, bp, sizeof(argp->fileid));
00191 bp += sizeof(argp->fileid);
00192 memcpy(&argp->pgno, bp, sizeof(argp->pgno));
00193 bp += sizeof(argp->pgno);
00194 memcpy(&argp->ndx, bp, sizeof(argp->ndx));
00195 bp += sizeof(argp->ndx);
00196 memcpy(&argp->pagelsn, bp, sizeof(argp->pagelsn));
00197 bp += sizeof(argp->pagelsn);
00198 memset(&argp->key, 0, sizeof(argp->key));
00199 memcpy(&argp->key.size, bp, sizeof(u_int32_t));
00200 bp += sizeof(u_int32_t);
00201 argp->key.data = bp;
00202 bp += argp->key.size;
00203 memset(&argp->data, 0, sizeof(argp->data));
00204 memcpy(&argp->data.size, bp, sizeof(u_int32_t));
00205 bp += sizeof(u_int32_t);
00206 argp->data.data = bp;
00207 bp += argp->data.size;
00208 *argpp = argp;
00209 return (0);
00210 }
00211
00212 int CDB___ham_newpage_log(dbenv, txnid, ret_lsnp, flags,
00213 opcode, fileid, prev_pgno, prevlsn, new_pgno, pagelsn,
00214 next_pgno, nextlsn)
00215 DB_ENV *dbenv;
00216 DB_TXN *txnid;
00217 DB_LSN *ret_lsnp;
00218 u_int32_t flags;
00219 u_int32_t opcode;
00220 int32_t fileid;
00221 db_pgno_t prev_pgno;
00222 DB_LSN * prevlsn;
00223 db_pgno_t new_pgno;
00224 DB_LSN * pagelsn;
00225 db_pgno_t next_pgno;
00226 DB_LSN * nextlsn;
00227 {
00228 DBT logrec;
00229 DB_LSN *lsnp, null_lsn;
00230 u_int32_t rectype, txn_num;
00231 int ret;
00232 u_int8_t *bp;
00233
00234 if (txnid != NULL &&
00235 TAILQ_FIRST(&txnid->kids) != NULL && CDB___txn_activekids(txnid) != 0)
00236 return (CDB___db_child_active_err(dbenv));
00237 rectype = DB_ham_newpage;
00238 txn_num = txnid == NULL ? 0 : txnid->txnid;
00239 if (txnid == NULL) {
00240 ZERO_LSN(null_lsn);
00241 lsnp = &null_lsn;
00242 } else
00243 lsnp = &txnid->last_lsn;
00244 logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
00245 + sizeof(opcode)
00246 + sizeof(fileid)
00247 + sizeof(prev_pgno)
00248 + sizeof(*prevlsn)
00249 + sizeof(new_pgno)
00250 + sizeof(*pagelsn)
00251 + sizeof(next_pgno)
00252 + sizeof(*nextlsn);
00253 if ((ret = CDB___os_malloc(dbenv, logrec.size, NULL, &logrec.data)) != 0)
00254 return (ret);
00255
00256 bp = logrec.data;
00257 memcpy(bp, &rectype, sizeof(rectype));
00258 bp += sizeof(rectype);
00259 memcpy(bp, &txn_num, sizeof(txn_num));
00260 bp += sizeof(txn_num);
00261 memcpy(bp, lsnp, sizeof(DB_LSN));
00262 bp += sizeof(DB_LSN);
00263 memcpy(bp, &opcode, sizeof(opcode));
00264 bp += sizeof(opcode);
00265 memcpy(bp, &fileid, sizeof(fileid));
00266 bp += sizeof(fileid);
00267 memcpy(bp, &prev_pgno, sizeof(prev_pgno));
00268 bp += sizeof(prev_pgno);
00269 if (prevlsn != NULL)
00270 memcpy(bp, prevlsn, sizeof(*prevlsn));
00271 else
00272 memset(bp, 0, sizeof(*prevlsn));
00273 bp += sizeof(*prevlsn);
00274 memcpy(bp, &new_pgno, sizeof(new_pgno));
00275 bp += sizeof(new_pgno);
00276 if (pagelsn != NULL)
00277 memcpy(bp, pagelsn, sizeof(*pagelsn));
00278 else
00279 memset(bp, 0, sizeof(*pagelsn));
00280 bp += sizeof(*pagelsn);
00281 memcpy(bp, &next_pgno, sizeof(next_pgno));
00282 bp += sizeof(next_pgno);
00283 if (nextlsn != NULL)
00284 memcpy(bp, nextlsn, sizeof(*nextlsn));
00285 else
00286 memset(bp, 0, sizeof(*nextlsn));
00287 bp += sizeof(*nextlsn);
00288 DB_ASSERT((u_int32_t)(bp - (u_int8_t *)logrec.data) == logrec.size);
00289 ret = CDB_log_put(dbenv, ret_lsnp, (DBT *)&logrec, flags);
00290 if (txnid != NULL)
00291 txnid->last_lsn = *ret_lsnp;
00292 CDB___os_free(logrec.data, logrec.size);
00293 return (ret);
00294 }
00295
00296 int
00297 CDB___ham_newpage_print(dbenv, dbtp, lsnp, notused2, notused3)
00298 DB_ENV *dbenv;
00299 DBT *dbtp;
00300 DB_LSN *lsnp;
00301 db_recops notused2;
00302 void *notused3;
00303 {
00304 __ham_newpage_args *argp;
00305 u_int32_t i;
00306 u_int ch;
00307 int ret;
00308
00309 i = 0;
00310 ch = 0;
00311 notused2 = 0;
00312 notused3 = NULL;
00313
00314 if ((ret = CDB___ham_newpage_read(dbenv, dbtp->data, &argp)) != 0)
00315 return (ret);
00316 printf("[%lu][%lu]ham_newpage: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
00317 (u_long)lsnp->file,
00318 (u_long)lsnp->offset,
00319 (u_long)argp->type,
00320 (u_long)argp->txnid->txnid,
00321 (u_long)argp->prev_lsn.file,
00322 (u_long)argp->prev_lsn.offset);
00323 printf("\topcode: %lu\n", (u_long)argp->opcode);
00324 printf("\tfileid: %ld\n", (long)argp->fileid);
00325 printf("\tprev_pgno: %lu\n", (u_long)argp->prev_pgno);
00326 printf("\tprevlsn: [%lu][%lu]\n",
00327 (u_long)argp->prevlsn.file, (u_long)argp->prevlsn.offset);
00328 printf("\tnew_pgno: %lu\n", (u_long)argp->new_pgno);
00329 printf("\tpagelsn: [%lu][%lu]\n",
00330 (u_long)argp->pagelsn.file, (u_long)argp->pagelsn.offset);
00331 printf("\tnext_pgno: %lu\n", (u_long)argp->next_pgno);
00332 printf("\tnextlsn: [%lu][%lu]\n",
00333 (u_long)argp->nextlsn.file, (u_long)argp->nextlsn.offset);
00334 printf("\n");
00335 CDB___os_free(argp, 0);
00336 return (0);
00337 }
00338
00339 int
00340 CDB___ham_newpage_read(dbenv, recbuf, argpp)
00341 DB_ENV *dbenv;
00342 void *recbuf;
00343 __ham_newpage_args **argpp;
00344 {
00345 __ham_newpage_args *argp;
00346 u_int8_t *bp;
00347 int ret;
00348
00349 ret = CDB___os_malloc(dbenv, sizeof(__ham_newpage_args) +
00350 sizeof(DB_TXN), NULL, &argp);
00351 if (ret != 0)
00352 return (ret);
00353 argp->txnid = (DB_TXN *)&argp[1];
00354 bp = recbuf;
00355 memcpy(&argp->type, bp, sizeof(argp->type));
00356 bp += sizeof(argp->type);
00357 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
00358 bp += sizeof(argp->txnid->txnid);
00359 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
00360 bp += sizeof(DB_LSN);
00361 memcpy(&argp->opcode, bp, sizeof(argp->opcode));
00362 bp += sizeof(argp->opcode);
00363 memcpy(&argp->fileid, bp, sizeof(argp->fileid));
00364 bp += sizeof(argp->fileid);
00365 memcpy(&argp->prev_pgno, bp, sizeof(argp->prev_pgno));
00366 bp += sizeof(argp->prev_pgno);
00367 memcpy(&argp->prevlsn, bp, sizeof(argp->prevlsn));
00368 bp += sizeof(argp->prevlsn);
00369 memcpy(&argp->new_pgno, bp, sizeof(argp->new_pgno));
00370 bp += sizeof(argp->new_pgno);
00371 memcpy(&argp->pagelsn, bp, sizeof(argp->pagelsn));
00372 bp += sizeof(argp->pagelsn);
00373 memcpy(&argp->next_pgno, bp, sizeof(argp->next_pgno));
00374 bp += sizeof(argp->next_pgno);
00375 memcpy(&argp->nextlsn, bp, sizeof(argp->nextlsn));
00376 bp += sizeof(argp->nextlsn);
00377 *argpp = argp;
00378 return (0);
00379 }
00380
00381 int
00382 CDB___ham_splitmeta_print(dbenv, dbtp, lsnp, notused2, notused3)
00383 DB_ENV *dbenv;
00384 DBT *dbtp;
00385 DB_LSN *lsnp;
00386 db_recops notused2;
00387 void *notused3;
00388 {
00389 __ham_splitmeta_args *argp;
00390 u_int32_t i;
00391 u_int ch;
00392 int ret;
00393
00394 i = 0;
00395 ch = 0;
00396 notused2 = 0;
00397 notused3 = NULL;
00398
00399 if ((ret = CDB___ham_splitmeta_read(dbenv, dbtp->data, &argp)) != 0)
00400 return (ret);
00401 printf("[%lu][%lu]ham_splitmeta: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
00402 (u_long)lsnp->file,
00403 (u_long)lsnp->offset,
00404 (u_long)argp->type,
00405 (u_long)argp->txnid->txnid,
00406 (u_long)argp->prev_lsn.file,
00407 (u_long)argp->prev_lsn.offset);
00408 printf("\tfileid: %ld\n", (long)argp->fileid);
00409 printf("\tbucket: %lu\n", (u_long)argp->bucket);
00410 printf("\tovflpoint: %lu\n", (u_long)argp->ovflpoint);
00411 printf("\tspares: %lu\n", (u_long)argp->spares);
00412 printf("\tmetalsn: [%lu][%lu]\n",
00413 (u_long)argp->metalsn.file, (u_long)argp->metalsn.offset);
00414 printf("\n");
00415 CDB___os_free(argp, 0);
00416 return (0);
00417 }
00418
00419 int
00420 CDB___ham_splitmeta_read(dbenv, recbuf, argpp)
00421 DB_ENV *dbenv;
00422 void *recbuf;
00423 __ham_splitmeta_args **argpp;
00424 {
00425 __ham_splitmeta_args *argp;
00426 u_int8_t *bp;
00427 int ret;
00428
00429 ret = CDB___os_malloc(dbenv, sizeof(__ham_splitmeta_args) +
00430 sizeof(DB_TXN), NULL, &argp);
00431 if (ret != 0)
00432 return (ret);
00433 argp->txnid = (DB_TXN *)&argp[1];
00434 bp = recbuf;
00435 memcpy(&argp->type, bp, sizeof(argp->type));
00436 bp += sizeof(argp->type);
00437 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
00438 bp += sizeof(argp->txnid->txnid);
00439 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
00440 bp += sizeof(DB_LSN);
00441 memcpy(&argp->fileid, bp, sizeof(argp->fileid));
00442 bp += sizeof(argp->fileid);
00443 memcpy(&argp->bucket, bp, sizeof(argp->bucket));
00444 bp += sizeof(argp->bucket);
00445 memcpy(&argp->ovflpoint, bp, sizeof(argp->ovflpoint));
00446 bp += sizeof(argp->ovflpoint);
00447 memcpy(&argp->spares, bp, sizeof(argp->spares));
00448 bp += sizeof(argp->spares);
00449 memcpy(&argp->metalsn, bp, sizeof(argp->metalsn));
00450 bp += sizeof(argp->metalsn);
00451 *argpp = argp;
00452 return (0);
00453 }
00454
00455 int CDB___ham_splitdata_log(dbenv, txnid, ret_lsnp, flags,
00456 fileid, opcode, pgno, pageimage, pagelsn)
00457 DB_ENV *dbenv;
00458 DB_TXN *txnid;
00459 DB_LSN *ret_lsnp;
00460 u_int32_t flags;
00461 int32_t fileid;
00462 u_int32_t opcode;
00463 db_pgno_t pgno;
00464 const DBT *pageimage;
00465 DB_LSN * pagelsn;
00466 {
00467 DBT logrec;
00468 DB_LSN *lsnp, null_lsn;
00469 u_int32_t zero;
00470 u_int32_t rectype, txn_num;
00471 int ret;
00472 u_int8_t *bp;
00473
00474 if (txnid != NULL &&
00475 TAILQ_FIRST(&txnid->kids) != NULL && CDB___txn_activekids(txnid) != 0)
00476 return (CDB___db_child_active_err(dbenv));
00477 rectype = DB_ham_splitdata;
00478 txn_num = txnid == NULL ? 0 : txnid->txnid;
00479 if (txnid == NULL) {
00480 ZERO_LSN(null_lsn);
00481 lsnp = &null_lsn;
00482 } else
00483 lsnp = &txnid->last_lsn;
00484 logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
00485 + sizeof(fileid)
00486 + sizeof(opcode)
00487 + sizeof(pgno)
00488 + sizeof(u_int32_t) + (pageimage == NULL ? 0 : pageimage->size)
00489 + sizeof(*pagelsn);
00490 if ((ret = CDB___os_malloc(dbenv, logrec.size, NULL, &logrec.data)) != 0)
00491 return (ret);
00492
00493 bp = logrec.data;
00494 memcpy(bp, &rectype, sizeof(rectype));
00495 bp += sizeof(rectype);
00496 memcpy(bp, &txn_num, sizeof(txn_num));
00497 bp += sizeof(txn_num);
00498 memcpy(bp, lsnp, sizeof(DB_LSN));
00499 bp += sizeof(DB_LSN);
00500 memcpy(bp, &fileid, sizeof(fileid));
00501 bp += sizeof(fileid);
00502 memcpy(bp, &opcode, sizeof(opcode));
00503 bp += sizeof(opcode);
00504 memcpy(bp, &pgno, sizeof(pgno));
00505 bp += sizeof(pgno);
00506 if (pageimage == NULL) {
00507 zero = 0;
00508 memcpy(bp, &zero, sizeof(u_int32_t));
00509 bp += sizeof(u_int32_t);
00510 } else {
00511 memcpy(bp, &pageimage->size, sizeof(pageimage->size));
00512 bp += sizeof(pageimage->size);
00513 memcpy(bp, pageimage->data, pageimage->size);
00514 bp += pageimage->size;
00515 }
00516 if (pagelsn != NULL)
00517 memcpy(bp, pagelsn, sizeof(*pagelsn));
00518 else
00519 memset(bp, 0, sizeof(*pagelsn));
00520 bp += sizeof(*pagelsn);
00521 DB_ASSERT((u_int32_t)(bp - (u_int8_t *)logrec.data) == logrec.size);
00522 ret = CDB_log_put(dbenv, ret_lsnp, (DBT *)&logrec, flags);
00523 if (txnid != NULL)
00524 txnid->last_lsn = *ret_lsnp;
00525 CDB___os_free(logrec.data, logrec.size);
00526 return (ret);
00527 }
00528
00529 int
00530 CDB___ham_splitdata_print(dbenv, dbtp, lsnp, notused2, notused3)
00531 DB_ENV *dbenv;
00532 DBT *dbtp;
00533 DB_LSN *lsnp;
00534 db_recops notused2;
00535 void *notused3;
00536 {
00537 __ham_splitdata_args *argp;
00538 u_int32_t i;
00539 u_int ch;
00540 int ret;
00541
00542 i = 0;
00543 ch = 0;
00544 notused2 = 0;
00545 notused3 = NULL;
00546
00547 if ((ret = CDB___ham_splitdata_read(dbenv, dbtp->data, &argp)) != 0)
00548 return (ret);
00549 printf("[%lu][%lu]ham_splitdata: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
00550 (u_long)lsnp->file,
00551 (u_long)lsnp->offset,
00552 (u_long)argp->type,
00553 (u_long)argp->txnid->txnid,
00554 (u_long)argp->prev_lsn.file,
00555 (u_long)argp->prev_lsn.offset);
00556 printf("\tfileid: %ld\n", (long)argp->fileid);
00557 printf("\topcode: %lu\n", (u_long)argp->opcode);
00558 printf("\tpgno: %lu\n", (u_long)argp->pgno);
00559 printf("\tpageimage: ");
00560 for (i = 0; i < argp->pageimage.size; i++) {
00561 ch = ((u_int8_t *)argp->pageimage.data)[i];
00562 if (isprint(ch) || ch == 0xa)
00563 putchar(ch);
00564 else
00565 printf("%#x ", ch);
00566 }
00567 printf("\n");
00568 printf("\tpagelsn: [%lu][%lu]\n",
00569 (u_long)argp->pagelsn.file, (u_long)argp->pagelsn.offset);
00570 printf("\n");
00571 CDB___os_free(argp, 0);
00572 return (0);
00573 }
00574
00575 int
00576 CDB___ham_splitdata_read(dbenv, recbuf, argpp)
00577 DB_ENV *dbenv;
00578 void *recbuf;
00579 __ham_splitdata_args **argpp;
00580 {
00581 __ham_splitdata_args *argp;
00582 u_int8_t *bp;
00583 int ret;
00584
00585 ret = CDB___os_malloc(dbenv, sizeof(__ham_splitdata_args) +
00586 sizeof(DB_TXN), NULL, &argp);
00587 if (ret != 0)
00588 return (ret);
00589 argp->txnid = (DB_TXN *)&argp[1];
00590 bp = recbuf;
00591 memcpy(&argp->type, bp, sizeof(argp->type));
00592 bp += sizeof(argp->type);
00593 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
00594 bp += sizeof(argp->txnid->txnid);
00595 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
00596 bp += sizeof(DB_LSN);
00597 memcpy(&argp->fileid, bp, sizeof(argp->fileid));
00598 bp += sizeof(argp->fileid);
00599 memcpy(&argp->opcode, bp, sizeof(argp->opcode));
00600 bp += sizeof(argp->opcode);
00601 memcpy(&argp->pgno, bp, sizeof(argp->pgno));
00602 bp += sizeof(argp->pgno);
00603 memset(&argp->pageimage, 0, sizeof(argp->pageimage));
00604 memcpy(&argp->pageimage.size, bp, sizeof(u_int32_t));
00605 bp += sizeof(u_int32_t);
00606 argp->pageimage.data = bp;
00607 bp += argp->pageimage.size;
00608 memcpy(&argp->pagelsn, bp, sizeof(argp->pagelsn));
00609 bp += sizeof(argp->pagelsn);
00610 *argpp = argp;
00611 return (0);
00612 }
00613
00614 int CDB___ham_replace_log(dbenv, txnid, ret_lsnp, flags,
00615 fileid, pgno, ndx, pagelsn, off, olditem,
00616 newitem, makedup)
00617 DB_ENV *dbenv;
00618 DB_TXN *txnid;
00619 DB_LSN *ret_lsnp;
00620 u_int32_t flags;
00621 int32_t fileid;
00622 db_pgno_t pgno;
00623 u_int32_t ndx;
00624 DB_LSN * pagelsn;
00625 int32_t off;
00626 const DBT *olditem;
00627 const DBT *newitem;
00628 u_int32_t makedup;
00629 {
00630 DBT logrec;
00631 DB_LSN *lsnp, null_lsn;
00632 u_int32_t zero;
00633 u_int32_t rectype, txn_num;
00634 int ret;
00635 u_int8_t *bp;
00636
00637 if (txnid != NULL &&
00638 TAILQ_FIRST(&txnid->kids) != NULL && CDB___txn_activekids(txnid) != 0)
00639 return (CDB___db_child_active_err(dbenv));
00640 rectype = DB_ham_replace;
00641 txn_num = txnid == NULL ? 0 : txnid->txnid;
00642 if (txnid == NULL) {
00643 ZERO_LSN(null_lsn);
00644 lsnp = &null_lsn;
00645 } else
00646 lsnp = &txnid->last_lsn;
00647 logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
00648 + sizeof(fileid)
00649 + sizeof(pgno)
00650 + sizeof(ndx)
00651 + sizeof(*pagelsn)
00652 + sizeof(off)
00653 + sizeof(u_int32_t) + (olditem == NULL ? 0 : olditem->size)
00654 + sizeof(u_int32_t) + (newitem == NULL ? 0 : newitem->size)
00655 + sizeof(makedup);
00656 if ((ret = CDB___os_malloc(dbenv, logrec.size, NULL, &logrec.data)) != 0)
00657 return (ret);
00658
00659 bp = logrec.data;
00660 memcpy(bp, &rectype, sizeof(rectype));
00661 bp += sizeof(rectype);
00662 memcpy(bp, &txn_num, sizeof(txn_num));
00663 bp += sizeof(txn_num);
00664 memcpy(bp, lsnp, sizeof(DB_LSN));
00665 bp += sizeof(DB_LSN);
00666 memcpy(bp, &fileid, sizeof(fileid));
00667 bp += sizeof(fileid);
00668 memcpy(bp, &pgno, sizeof(pgno));
00669 bp += sizeof(pgno);
00670 memcpy(bp, &ndx, sizeof(ndx));
00671 bp += sizeof(ndx);
00672 if (pagelsn != NULL)
00673 memcpy(bp, pagelsn, sizeof(*pagelsn));
00674 else
00675 memset(bp, 0, sizeof(*pagelsn));
00676 bp += sizeof(*pagelsn);
00677 memcpy(bp, &off, sizeof(off));
00678 bp += sizeof(off);
00679 if (olditem == NULL) {
00680 zero = 0;
00681 memcpy(bp, &zero, sizeof(u_int32_t));
00682 bp += sizeof(u_int32_t);
00683 } else {
00684 memcpy(bp, &olditem->size, sizeof(olditem->size));
00685 bp += sizeof(olditem->size);
00686 memcpy(bp, olditem->data, olditem->size);
00687 bp += olditem->size;
00688 }
00689 if (newitem == NULL) {
00690 zero = 0;
00691 memcpy(bp, &zero, sizeof(u_int32_t));
00692 bp += sizeof(u_int32_t);
00693 } else {
00694 memcpy(bp, &newitem->size, sizeof(newitem->size));
00695 bp += sizeof(newitem->size);
00696 memcpy(bp, newitem->data, newitem->size);
00697 bp += newitem->size;
00698 }
00699 memcpy(bp, &makedup, sizeof(makedup));
00700 bp += sizeof(makedup);
00701 DB_ASSERT((u_int32_t)(bp - (u_int8_t *)logrec.data) == logrec.size);
00702 ret = CDB_log_put(dbenv, ret_lsnp, (DBT *)&logrec, flags);
00703 if (txnid != NULL)
00704 txnid->last_lsn = *ret_lsnp;
00705 CDB___os_free(logrec.data, logrec.size);
00706 return (ret);
00707 }
00708
00709 int
00710 CDB___ham_replace_print(dbenv, dbtp, lsnp, notused2, notused3)
00711 DB_ENV *dbenv;
00712 DBT *dbtp;
00713 DB_LSN *lsnp;
00714 db_recops notused2;
00715 void *notused3;
00716 {
00717 __ham_replace_args *argp;
00718 u_int32_t i;
00719 u_int ch;
00720 int ret;
00721
00722 i = 0;
00723 ch = 0;
00724 notused2 = 0;
00725 notused3 = NULL;
00726
00727 if ((ret = CDB___ham_replace_read(dbenv, dbtp->data, &argp)) != 0)
00728 return (ret);
00729 printf("[%lu][%lu]ham_replace: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
00730 (u_long)lsnp->file,
00731 (u_long)lsnp->offset,
00732 (u_long)argp->type,
00733 (u_long)argp->txnid->txnid,
00734 (u_long)argp->prev_lsn.file,
00735 (u_long)argp->prev_lsn.offset);
00736 printf("\tfileid: %ld\n", (long)argp->fileid);
00737 printf("\tpgno: %lu\n", (u_long)argp->pgno);
00738 printf("\tndx: %lu\n", (u_long)argp->ndx);
00739 printf("\tpagelsn: [%lu][%lu]\n",
00740 (u_long)argp->pagelsn.file, (u_long)argp->pagelsn.offset);
00741 printf("\toff: %ld\n", (long)argp->off);
00742 printf("\tolditem: ");
00743 for (i = 0; i < argp->olditem.size; i++) {
00744 ch = ((u_int8_t *)argp->olditem.data)[i];
00745 if (isprint(ch) || ch == 0xa)
00746 putchar(ch);
00747 else
00748 printf("%#x ", ch);
00749 }
00750 printf("\n");
00751 printf("\tnewitem: ");
00752 for (i = 0; i < argp->newitem.size; i++) {
00753 ch = ((u_int8_t *)argp->newitem.data)[i];
00754 if (isprint(ch) || ch == 0xa)
00755 putchar(ch);
00756 else
00757 printf("%#x ", ch);
00758 }
00759 printf("\n");
00760 printf("\tmakedup: %lu\n", (u_long)argp->makedup);
00761 printf("\n");
00762 CDB___os_free(argp, 0);
00763 return (0);
00764 }
00765
00766 int
00767 CDB___ham_replace_read(dbenv, recbuf, argpp)
00768 DB_ENV *dbenv;
00769 void *recbuf;
00770 __ham_replace_args **argpp;
00771 {
00772 __ham_replace_args *argp;
00773 u_int8_t *bp;
00774 int ret;
00775
00776 ret = CDB___os_malloc(dbenv, sizeof(__ham_replace_args) +
00777 sizeof(DB_TXN), NULL, &argp);
00778 if (ret != 0)
00779 return (ret);
00780 argp->txnid = (DB_TXN *)&argp[1];
00781 bp = recbuf;
00782 memcpy(&argp->type, bp, sizeof(argp->type));
00783 bp += sizeof(argp->type);
00784 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
00785 bp += sizeof(argp->txnid->txnid);
00786 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
00787 bp += sizeof(DB_LSN);
00788 memcpy(&argp->fileid, bp, sizeof(argp->fileid));
00789 bp += sizeof(argp->fileid);
00790 memcpy(&argp->pgno, bp, sizeof(argp->pgno));
00791 bp += sizeof(argp->pgno);
00792 memcpy(&argp->ndx, bp, sizeof(argp->ndx));
00793 bp += sizeof(argp->ndx);
00794 memcpy(&argp->pagelsn, bp, sizeof(argp->pagelsn));
00795 bp += sizeof(argp->pagelsn);
00796 memcpy(&argp->off, bp, sizeof(argp->off));
00797 bp += sizeof(argp->off);
00798 memset(&argp->olditem, 0, sizeof(argp->olditem));
00799 memcpy(&argp->olditem.size, bp, sizeof(u_int32_t));
00800 bp += sizeof(u_int32_t);
00801 argp->olditem.data = bp;
00802 bp += argp->olditem.size;
00803 memset(&argp->newitem, 0, sizeof(argp->newitem));
00804 memcpy(&argp->newitem.size, bp, sizeof(u_int32_t));
00805 bp += sizeof(u_int32_t);
00806 argp->newitem.data = bp;
00807 bp += argp->newitem.size;
00808 memcpy(&argp->makedup, bp, sizeof(argp->makedup));
00809 bp += sizeof(argp->makedup);
00810 *argpp = argp;
00811 return (0);
00812 }
00813
00814 int
00815 CDB___ham_newpgno_print(dbenv, dbtp, lsnp, notused2, notused3)
00816 DB_ENV *dbenv;
00817 DBT *dbtp;
00818 DB_LSN *lsnp;
00819 db_recops notused2;
00820 void *notused3;
00821 {
00822 __ham_newpgno_args *argp;
00823 u_int32_t i;
00824 u_int ch;
00825 int ret;
00826
00827 i = 0;
00828 ch = 0;
00829 notused2 = 0;
00830 notused3 = NULL;
00831
00832 if ((ret = CDB___ham_newpgno_read(dbenv, dbtp->data, &argp)) != 0)
00833 return (ret);
00834 printf("[%lu][%lu]ham_newpgno: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
00835 (u_long)lsnp->file,
00836 (u_long)lsnp->offset,
00837 (u_long)argp->type,
00838 (u_long)argp->txnid->txnid,
00839 (u_long)argp->prev_lsn.file,
00840 (u_long)argp->prev_lsn.offset);
00841 printf("\topcode: %lu\n", (u_long)argp->opcode);
00842 printf("\tfileid: %ld\n", (long)argp->fileid);
00843 printf("\tpgno: %lu\n", (u_long)argp->pgno);
00844 printf("\tfree_pgno: %lu\n", (u_long)argp->free_pgno);
00845 printf("\told_type: %lu\n", (u_long)argp->old_type);
00846 printf("\told_pgno: %lu\n", (u_long)argp->old_pgno);
00847 printf("\tnew_type: %lu\n", (u_long)argp->new_type);
00848 printf("\tpagelsn: [%lu][%lu]\n",
00849 (u_long)argp->pagelsn.file, (u_long)argp->pagelsn.offset);
00850 printf("\tmetalsn: [%lu][%lu]\n",
00851 (u_long)argp->metalsn.file, (u_long)argp->metalsn.offset);
00852 printf("\n");
00853 CDB___os_free(argp, 0);
00854 return (0);
00855 }
00856
00857 int
00858 CDB___ham_newpgno_read(dbenv, recbuf, argpp)
00859 DB_ENV *dbenv;
00860 void *recbuf;
00861 __ham_newpgno_args **argpp;
00862 {
00863 __ham_newpgno_args *argp;
00864 u_int8_t *bp;
00865 int ret;
00866
00867 ret = CDB___os_malloc(dbenv, sizeof(__ham_newpgno_args) +
00868 sizeof(DB_TXN), NULL, &argp);
00869 if (ret != 0)
00870 return (ret);
00871 argp->txnid = (DB_TXN *)&argp[1];
00872 bp = recbuf;
00873 memcpy(&argp->type, bp, sizeof(argp->type));
00874 bp += sizeof(argp->type);
00875 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
00876 bp += sizeof(argp->txnid->txnid);
00877 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
00878 bp += sizeof(DB_LSN);
00879 memcpy(&argp->opcode, bp, sizeof(argp->opcode));
00880 bp += sizeof(argp->opcode);
00881 memcpy(&argp->fileid, bp, sizeof(argp->fileid));
00882 bp += sizeof(argp->fileid);
00883 memcpy(&argp->pgno, bp, sizeof(argp->pgno));
00884 bp += sizeof(argp->pgno);
00885 memcpy(&argp->free_pgno, bp, sizeof(argp->free_pgno));
00886 bp += sizeof(argp->free_pgno);
00887 memcpy(&argp->old_type, bp, sizeof(argp->old_type));
00888 bp += sizeof(argp->old_type);
00889 memcpy(&argp->old_pgno, bp, sizeof(argp->old_pgno));
00890 bp += sizeof(argp->old_pgno);
00891 memcpy(&argp->new_type, bp, sizeof(argp->new_type));
00892 bp += sizeof(argp->new_type);
00893 memcpy(&argp->pagelsn, bp, sizeof(argp->pagelsn));
00894 bp += sizeof(argp->pagelsn);
00895 memcpy(&argp->metalsn, bp, sizeof(argp->metalsn));
00896 bp += sizeof(argp->metalsn);
00897 *argpp = argp;
00898 return (0);
00899 }
00900
00901 int
00902 CDB___ham_ovfl_print(dbenv, dbtp, lsnp, notused2, notused3)
00903 DB_ENV *dbenv;
00904 DBT *dbtp;
00905 DB_LSN *lsnp;
00906 db_recops notused2;
00907 void *notused3;
00908 {
00909 __ham_ovfl_args *argp;
00910 u_int32_t i;
00911 u_int ch;
00912 int ret;
00913
00914 i = 0;
00915 ch = 0;
00916 notused2 = 0;
00917 notused3 = NULL;
00918
00919 if ((ret = CDB___ham_ovfl_read(dbenv, dbtp->data, &argp)) != 0)
00920 return (ret);
00921 printf("[%lu][%lu]ham_ovfl: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
00922 (u_long)lsnp->file,
00923 (u_long)lsnp->offset,
00924 (u_long)argp->type,
00925 (u_long)argp->txnid->txnid,
00926 (u_long)argp->prev_lsn.file,
00927 (u_long)argp->prev_lsn.offset);
00928 printf("\tfileid: %ld\n", (long)argp->fileid);
00929 printf("\tstart_pgno: %lu\n", (u_long)argp->start_pgno);
00930 printf("\tnpages: %lu\n", (u_long)argp->npages);
00931 printf("\tfree_pgno: %lu\n", (u_long)argp->free_pgno);
00932 printf("\tovflpoint: %lu\n", (u_long)argp->ovflpoint);
00933 printf("\tmetalsn: [%lu][%lu]\n",
00934 (u_long)argp->metalsn.file, (u_long)argp->metalsn.offset);
00935 printf("\n");
00936 CDB___os_free(argp, 0);
00937 return (0);
00938 }
00939
00940 int
00941 CDB___ham_ovfl_read(dbenv, recbuf, argpp)
00942 DB_ENV *dbenv;
00943 void *recbuf;
00944 __ham_ovfl_args **argpp;
00945 {
00946 __ham_ovfl_args *argp;
00947 u_int8_t *bp;
00948 int ret;
00949
00950 ret = CDB___os_malloc(dbenv, sizeof(__ham_ovfl_args) +
00951 sizeof(DB_TXN), NULL, &argp);
00952 if (ret != 0)
00953 return (ret);
00954 argp->txnid = (DB_TXN *)&argp[1];
00955 bp = recbuf;
00956 memcpy(&argp->type, bp, sizeof(argp->type));
00957 bp += sizeof(argp->type);
00958 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
00959 bp += sizeof(argp->txnid->txnid);
00960 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
00961 bp += sizeof(DB_LSN);
00962 memcpy(&argp->fileid, bp, sizeof(argp->fileid));
00963 bp += sizeof(argp->fileid);
00964 memcpy(&argp->start_pgno, bp, sizeof(argp->start_pgno));
00965 bp += sizeof(argp->start_pgno);
00966 memcpy(&argp->npages, bp, sizeof(argp->npages));
00967 bp += sizeof(argp->npages);
00968 memcpy(&argp->free_pgno, bp, sizeof(argp->free_pgno));
00969 bp += sizeof(argp->free_pgno);
00970 memcpy(&argp->ovflpoint, bp, sizeof(argp->ovflpoint));
00971 bp += sizeof(argp->ovflpoint);
00972 memcpy(&argp->metalsn, bp, sizeof(argp->metalsn));
00973 bp += sizeof(argp->metalsn);
00974 *argpp = argp;
00975 return (0);
00976 }
00977
00978 int CDB___ham_copypage_log(dbenv, txnid, ret_lsnp, flags,
00979 fileid, pgno, pagelsn, next_pgno, nextlsn, nnext_pgno,
00980 nnextlsn, page)
00981 DB_ENV *dbenv;
00982 DB_TXN *txnid;
00983 DB_LSN *ret_lsnp;
00984 u_int32_t flags;
00985 int32_t fileid;
00986 db_pgno_t pgno;
00987 DB_LSN * pagelsn;
00988 db_pgno_t next_pgno;
00989 DB_LSN * nextlsn;
00990 db_pgno_t nnext_pgno;
00991 DB_LSN * nnextlsn;
00992 const DBT *page;
00993 {
00994 DBT logrec;
00995 DB_LSN *lsnp, null_lsn;
00996 u_int32_t zero;
00997 u_int32_t rectype, txn_num;
00998 int ret;
00999 u_int8_t *bp;
01000
01001 if (txnid != NULL &&
01002 TAILQ_FIRST(&txnid->kids) != NULL && CDB___txn_activekids(txnid) != 0)
01003 return (CDB___db_child_active_err(dbenv));
01004 rectype = DB_ham_copypage;
01005 txn_num = txnid == NULL ? 0 : txnid->txnid;
01006 if (txnid == NULL) {
01007 ZERO_LSN(null_lsn);
01008 lsnp = &null_lsn;
01009 } else
01010 lsnp = &txnid->last_lsn;
01011 logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
01012 + sizeof(fileid)
01013 + sizeof(pgno)
01014 + sizeof(*pagelsn)
01015 + sizeof(next_pgno)
01016 + sizeof(*nextlsn)
01017 + sizeof(nnext_pgno)
01018 + sizeof(*nnextlsn)
01019 + sizeof(u_int32_t) + (page == NULL ? 0 : page->size);
01020 if ((ret = CDB___os_malloc(dbenv, logrec.size, NULL, &logrec.data)) != 0)
01021 return (ret);
01022
01023 bp = logrec.data;
01024 memcpy(bp, &rectype, sizeof(rectype));
01025 bp += sizeof(rectype);
01026 memcpy(bp, &txn_num, sizeof(txn_num));
01027 bp += sizeof(txn_num);
01028 memcpy(bp, lsnp, sizeof(DB_LSN));
01029 bp += sizeof(DB_LSN);
01030 memcpy(bp, &fileid, sizeof(fileid));
01031 bp += sizeof(fileid);
01032 memcpy(bp, &pgno, sizeof(pgno));
01033 bp += sizeof(pgno);
01034 if (pagelsn != NULL)
01035 memcpy(bp, pagelsn, sizeof(*pagelsn));
01036 else
01037 memset(bp, 0, sizeof(*pagelsn));
01038 bp += sizeof(*pagelsn);
01039 memcpy(bp, &next_pgno, sizeof(next_pgno));
01040 bp += sizeof(next_pgno);
01041 if (nextlsn != NULL)
01042 memcpy(bp, nextlsn, sizeof(*nextlsn));
01043 else
01044 memset(bp, 0, sizeof(*nextlsn));
01045 bp += sizeof(*nextlsn);
01046 memcpy(bp, &nnext_pgno, sizeof(nnext_pgno));
01047 bp += sizeof(nnext_pgno);
01048 if (nnextlsn != NULL)
01049 memcpy(bp, nnextlsn, sizeof(*nnextlsn));
01050 else
01051 memset(bp, 0, sizeof(*nnextlsn));
01052 bp += sizeof(*nnextlsn);
01053 if (page == NULL) {
01054 zero = 0;
01055 memcpy(bp, &zero, sizeof(u_int32_t));
01056 bp += sizeof(u_int32_t);
01057 } else {
01058 memcpy(bp, &page->size, sizeof(page->size));
01059 bp += sizeof(page->size);
01060 memcpy(bp, page->data, page->size);
01061 bp += page->size;
01062 }
01063 DB_ASSERT((u_int32_t)(bp - (u_int8_t *)logrec.data) == logrec.size);
01064 ret = CDB_log_put(dbenv, ret_lsnp, (DBT *)&logrec, flags);
01065 if (txnid != NULL)
01066 txnid->last_lsn = *ret_lsnp;
01067 CDB___os_free(logrec.data, logrec.size);
01068 return (ret);
01069 }
01070
01071 int
01072 CDB___ham_copypage_print(dbenv, dbtp, lsnp, notused2, notused3)
01073 DB_ENV *dbenv;
01074 DBT *dbtp;
01075 DB_LSN *lsnp;
01076 db_recops notused2;
01077 void *notused3;
01078 {
01079 __ham_copypage_args *argp;
01080 u_int32_t i;
01081 u_int ch;
01082 int ret;
01083
01084 i = 0;
01085 ch = 0;
01086 notused2 = 0;
01087 notused3 = NULL;
01088
01089 if ((ret = CDB___ham_copypage_read(dbenv, dbtp->data, &argp)) != 0)
01090 return (ret);
01091 printf("[%lu][%lu]ham_copypage: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
01092 (u_long)lsnp->file,
01093 (u_long)lsnp->offset,
01094 (u_long)argp->type,
01095 (u_long)argp->txnid->txnid,
01096 (u_long)argp->prev_lsn.file,
01097 (u_long)argp->prev_lsn.offset);
01098 printf("\tfileid: %ld\n", (long)argp->fileid);
01099 printf("\tpgno: %lu\n", (u_long)argp->pgno);
01100 printf("\tpagelsn: [%lu][%lu]\n",
01101 (u_long)argp->pagelsn.file, (u_long)argp->pagelsn.offset);
01102 printf("\tnext_pgno: %lu\n", (u_long)argp->next_pgno);
01103 printf("\tnextlsn: [%lu][%lu]\n",
01104 (u_long)argp->nextlsn.file, (u_long)argp->nextlsn.offset);
01105 printf("\tnnext_pgno: %lu\n", (u_long)argp->nnext_pgno);
01106 printf("\tnnextlsn: [%lu][%lu]\n",
01107 (u_long)argp->nnextlsn.file, (u_long)argp->nnextlsn.offset);
01108 printf("\tpage: ");
01109 for (i = 0; i < argp->page.size; i++) {
01110 ch = ((u_int8_t *)argp->page.data)[i];
01111 if (isprint(ch) || ch == 0xa)
01112 putchar(ch);
01113 else
01114 printf("%#x ", ch);
01115 }
01116 printf("\n");
01117 printf("\n");
01118 CDB___os_free(argp, 0);
01119 return (0);
01120 }
01121
01122 int
01123 CDB___ham_copypage_read(dbenv, recbuf, argpp)
01124 DB_ENV *dbenv;
01125 void *recbuf;
01126 __ham_copypage_args **argpp;
01127 {
01128 __ham_copypage_args *argp;
01129 u_int8_t *bp;
01130 int ret;
01131
01132 ret = CDB___os_malloc(dbenv, sizeof(__ham_copypage_args) +
01133 sizeof(DB_TXN), NULL, &argp);
01134 if (ret != 0)
01135 return (ret);
01136 argp->txnid = (DB_TXN *)&argp[1];
01137 bp = recbuf;
01138 memcpy(&argp->type, bp, sizeof(argp->type));
01139 bp += sizeof(argp->type);
01140 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
01141 bp += sizeof(argp->txnid->txnid);
01142 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
01143 bp += sizeof(DB_LSN);
01144 memcpy(&argp->fileid, bp, sizeof(argp->fileid));
01145 bp += sizeof(argp->fileid);
01146 memcpy(&argp->pgno, bp, sizeof(argp->pgno));
01147 bp += sizeof(argp->pgno);
01148 memcpy(&argp->pagelsn, bp, sizeof(argp->pagelsn));
01149 bp += sizeof(argp->pagelsn);
01150 memcpy(&argp->next_pgno, bp, sizeof(argp->next_pgno));
01151 bp += sizeof(argp->next_pgno);
01152 memcpy(&argp->nextlsn, bp, sizeof(argp->nextlsn));
01153 bp += sizeof(argp->nextlsn);
01154 memcpy(&argp->nnext_pgno, bp, sizeof(argp->nnext_pgno));
01155 bp += sizeof(argp->nnext_pgno);
01156 memcpy(&argp->nnextlsn, bp, sizeof(argp->nnextlsn));
01157 bp += sizeof(argp->nnextlsn);
01158 memset(&argp->page, 0, sizeof(argp->page));
01159 memcpy(&argp->page.size, bp, sizeof(u_int32_t));
01160 bp += sizeof(u_int32_t);
01161 argp->page.data = bp;
01162 bp += argp->page.size;
01163 *argpp = argp;
01164 return (0);
01165 }
01166
01167 int CDB___ham_metagroup_log(dbenv, txnid, ret_lsnp, flags,
01168 fileid, bucket, pgno, metalsn, pagelsn)
01169 DB_ENV *dbenv;
01170 DB_TXN *txnid;
01171 DB_LSN *ret_lsnp;
01172 u_int32_t flags;
01173 int32_t fileid;
01174 u_int32_t bucket;
01175 db_pgno_t pgno;
01176 DB_LSN * metalsn;
01177 DB_LSN * pagelsn;
01178 {
01179 DBT logrec;
01180 DB_LSN *lsnp, null_lsn;
01181 u_int32_t rectype, txn_num;
01182 int ret;
01183 u_int8_t *bp;
01184
01185 if (txnid != NULL &&
01186 TAILQ_FIRST(&txnid->kids) != NULL && CDB___txn_activekids(txnid) != 0)
01187 return (CDB___db_child_active_err(dbenv));
01188 rectype = DB_ham_metagroup;
01189 txn_num = txnid == NULL ? 0 : txnid->txnid;
01190 if (txnid == NULL) {
01191 ZERO_LSN(null_lsn);
01192 lsnp = &null_lsn;
01193 } else
01194 lsnp = &txnid->last_lsn;
01195 logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
01196 + sizeof(fileid)
01197 + sizeof(bucket)
01198 + sizeof(pgno)
01199 + sizeof(*metalsn)
01200 + sizeof(*pagelsn);
01201 if ((ret = CDB___os_malloc(dbenv, logrec.size, NULL, &logrec.data)) != 0)
01202 return (ret);
01203
01204 bp = logrec.data;
01205 memcpy(bp, &rectype, sizeof(rectype));
01206 bp += sizeof(rectype);
01207 memcpy(bp, &txn_num, sizeof(txn_num));
01208 bp += sizeof(txn_num);
01209 memcpy(bp, lsnp, sizeof(DB_LSN));
01210 bp += sizeof(DB_LSN);
01211 memcpy(bp, &fileid, sizeof(fileid));
01212 bp += sizeof(fileid);
01213 memcpy(bp, &bucket, sizeof(bucket));
01214 bp += sizeof(bucket);
01215 memcpy(bp, &pgno, sizeof(pgno));
01216 bp += sizeof(pgno);
01217 if (metalsn != NULL)
01218 memcpy(bp, metalsn, sizeof(*metalsn));
01219 else
01220 memset(bp, 0, sizeof(*metalsn));
01221 bp += sizeof(*metalsn);
01222 if (pagelsn != NULL)
01223 memcpy(bp, pagelsn, sizeof(*pagelsn));
01224 else
01225 memset(bp, 0, sizeof(*pagelsn));
01226 bp += sizeof(*pagelsn);
01227 DB_ASSERT((u_int32_t)(bp - (u_int8_t *)logrec.data) == logrec.size);
01228 ret = CDB_log_put(dbenv, ret_lsnp, (DBT *)&logrec, flags);
01229 if (txnid != NULL)
01230 txnid->last_lsn = *ret_lsnp;
01231 CDB___os_free(logrec.data, logrec.size);
01232 return (ret);
01233 }
01234
01235 int
01236 CDB___ham_metagroup_print(dbenv, dbtp, lsnp, notused2, notused3)
01237 DB_ENV *dbenv;
01238 DBT *dbtp;
01239 DB_LSN *lsnp;
01240 db_recops notused2;
01241 void *notused3;
01242 {
01243 __ham_metagroup_args *argp;
01244 u_int32_t i;
01245 u_int ch;
01246 int ret;
01247
01248 i = 0;
01249 ch = 0;
01250 notused2 = 0;
01251 notused3 = NULL;
01252
01253 if ((ret = CDB___ham_metagroup_read(dbenv, dbtp->data, &argp)) != 0)
01254 return (ret);
01255 printf("[%lu][%lu]ham_metagroup: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
01256 (u_long)lsnp->file,
01257 (u_long)lsnp->offset,
01258 (u_long)argp->type,
01259 (u_long)argp->txnid->txnid,
01260 (u_long)argp->prev_lsn.file,
01261 (u_long)argp->prev_lsn.offset);
01262 printf("\tfileid: %ld\n", (long)argp->fileid);
01263 printf("\tbucket: %lu\n", (u_long)argp->bucket);
01264 printf("\tpgno: %lu\n", (u_long)argp->pgno);
01265 printf("\tmetalsn: [%lu][%lu]\n",
01266 (u_long)argp->metalsn.file, (u_long)argp->metalsn.offset);
01267 printf("\tpagelsn: [%lu][%lu]\n",
01268 (u_long)argp->pagelsn.file, (u_long)argp->pagelsn.offset);
01269 printf("\n");
01270 CDB___os_free(argp, 0);
01271 return (0);
01272 }
01273
01274 int
01275 CDB___ham_metagroup_read(dbenv, recbuf, argpp)
01276 DB_ENV *dbenv;
01277 void *recbuf;
01278 __ham_metagroup_args **argpp;
01279 {
01280 __ham_metagroup_args *argp;
01281 u_int8_t *bp;
01282 int ret;
01283
01284 ret = CDB___os_malloc(dbenv, sizeof(__ham_metagroup_args) +
01285 sizeof(DB_TXN), NULL, &argp);
01286 if (ret != 0)
01287 return (ret);
01288 argp->txnid = (DB_TXN *)&argp[1];
01289 bp = recbuf;
01290 memcpy(&argp->type, bp, sizeof(argp->type));
01291 bp += sizeof(argp->type);
01292 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
01293 bp += sizeof(argp->txnid->txnid);
01294 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
01295 bp += sizeof(DB_LSN);
01296 memcpy(&argp->fileid, bp, sizeof(argp->fileid));
01297 bp += sizeof(argp->fileid);
01298 memcpy(&argp->bucket, bp, sizeof(argp->bucket));
01299 bp += sizeof(argp->bucket);
01300 memcpy(&argp->pgno, bp, sizeof(argp->pgno));
01301 bp += sizeof(argp->pgno);
01302 memcpy(&argp->metalsn, bp, sizeof(argp->metalsn));
01303 bp += sizeof(argp->metalsn);
01304 memcpy(&argp->pagelsn, bp, sizeof(argp->pagelsn));
01305 bp += sizeof(argp->pagelsn);
01306 *argpp = argp;
01307 return (0);
01308 }
01309
01310 int
01311 CDB___ham_groupalloc1_print(dbenv, dbtp, lsnp, notused2, notused3)
01312 DB_ENV *dbenv;
01313 DBT *dbtp;
01314 DB_LSN *lsnp;
01315 db_recops notused2;
01316 void *notused3;
01317 {
01318 __ham_groupalloc1_args *argp;
01319 u_int32_t i;
01320 u_int ch;
01321 int ret;
01322
01323 i = 0;
01324 ch = 0;
01325 notused2 = 0;
01326 notused3 = NULL;
01327
01328 if ((ret = CDB___ham_groupalloc1_read(dbenv, dbtp->data, &argp)) != 0)
01329 return (ret);
01330 printf("[%lu][%lu]ham_groupalloc1: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
01331 (u_long)lsnp->file,
01332 (u_long)lsnp->offset,
01333 (u_long)argp->type,
01334 (u_long)argp->txnid->txnid,
01335 (u_long)argp->prev_lsn.file,
01336 (u_long)argp->prev_lsn.offset);
01337 printf("\tfileid: %ld\n", (long)argp->fileid);
01338 printf("\tpgno: %lu\n", (u_long)argp->pgno);
01339 printf("\tmetalsn: [%lu][%lu]\n",
01340 (u_long)argp->metalsn.file, (u_long)argp->metalsn.offset);
01341 printf("\tmmetalsn: [%lu][%lu]\n",
01342 (u_long)argp->mmetalsn.file, (u_long)argp->mmetalsn.offset);
01343 printf("\tstart_pgno: %lu\n", (u_long)argp->start_pgno);
01344 printf("\tnum: %lu\n", (u_long)argp->num);
01345 printf("\n");
01346 CDB___os_free(argp, 0);
01347 return (0);
01348 }
01349
01350 int
01351 CDB___ham_groupalloc1_read(dbenv, recbuf, argpp)
01352 DB_ENV *dbenv;
01353 void *recbuf;
01354 __ham_groupalloc1_args **argpp;
01355 {
01356 __ham_groupalloc1_args *argp;
01357 u_int8_t *bp;
01358 int ret;
01359
01360 ret = CDB___os_malloc(dbenv, sizeof(__ham_groupalloc1_args) +
01361 sizeof(DB_TXN), NULL, &argp);
01362 if (ret != 0)
01363 return (ret);
01364 argp->txnid = (DB_TXN *)&argp[1];
01365 bp = recbuf;
01366 memcpy(&argp->type, bp, sizeof(argp->type));
01367 bp += sizeof(argp->type);
01368 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
01369 bp += sizeof(argp->txnid->txnid);
01370 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
01371 bp += sizeof(DB_LSN);
01372 memcpy(&argp->fileid, bp, sizeof(argp->fileid));
01373 bp += sizeof(argp->fileid);
01374 memcpy(&argp->pgno, bp, sizeof(argp->pgno));
01375 bp += sizeof(argp->pgno);
01376 memcpy(&argp->metalsn, bp, sizeof(argp->metalsn));
01377 bp += sizeof(argp->metalsn);
01378 memcpy(&argp->mmetalsn, bp, sizeof(argp->mmetalsn));
01379 bp += sizeof(argp->mmetalsn);
01380 memcpy(&argp->start_pgno, bp, sizeof(argp->start_pgno));
01381 bp += sizeof(argp->start_pgno);
01382 memcpy(&argp->num, bp, sizeof(argp->num));
01383 bp += sizeof(argp->num);
01384 *argpp = argp;
01385 return (0);
01386 }
01387
01388 int CDB___ham_groupalloc_log(dbenv, txnid, ret_lsnp, flags,
01389 fileid, meta_lsn, alloc_lsn, start_pgno, num, free)
01390 DB_ENV *dbenv;
01391 DB_TXN *txnid;
01392 DB_LSN *ret_lsnp;
01393 u_int32_t flags;
01394 int32_t fileid;
01395 DB_LSN * meta_lsn;
01396 DB_LSN * alloc_lsn;
01397 db_pgno_t start_pgno;
01398 u_int32_t num;
01399 db_pgno_t free;
01400 {
01401 DBT logrec;
01402 DB_LSN *lsnp, null_lsn;
01403 u_int32_t rectype, txn_num;
01404 int ret;
01405 u_int8_t *bp;
01406
01407 if (txnid != NULL &&
01408 TAILQ_FIRST(&txnid->kids) != NULL && CDB___txn_activekids(txnid) != 0)
01409 return (CDB___db_child_active_err(dbenv));
01410 rectype = DB_ham_groupalloc;
01411 txn_num = txnid == NULL ? 0 : txnid->txnid;
01412 if (txnid == NULL) {
01413 ZERO_LSN(null_lsn);
01414 lsnp = &null_lsn;
01415 } else
01416 lsnp = &txnid->last_lsn;
01417 logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
01418 + sizeof(fileid)
01419 + sizeof(*meta_lsn)
01420 + sizeof(*alloc_lsn)
01421 + sizeof(start_pgno)
01422 + sizeof(num)
01423 + sizeof(free);
01424 if ((ret = CDB___os_malloc(dbenv, logrec.size, NULL, &logrec.data)) != 0)
01425 return (ret);
01426
01427 bp = logrec.data;
01428 memcpy(bp, &rectype, sizeof(rectype));
01429 bp += sizeof(rectype);
01430 memcpy(bp, &txn_num, sizeof(txn_num));
01431 bp += sizeof(txn_num);
01432 memcpy(bp, lsnp, sizeof(DB_LSN));
01433 bp += sizeof(DB_LSN);
01434 memcpy(bp, &fileid, sizeof(fileid));
01435 bp += sizeof(fileid);
01436 if (meta_lsn != NULL)
01437 memcpy(bp, meta_lsn, sizeof(*meta_lsn));
01438 else
01439 memset(bp, 0, sizeof(*meta_lsn));
01440 bp += sizeof(*meta_lsn);
01441 if (alloc_lsn != NULL)
01442 memcpy(bp, alloc_lsn, sizeof(*alloc_lsn));
01443 else
01444 memset(bp, 0, sizeof(*alloc_lsn));
01445 bp += sizeof(*alloc_lsn);
01446 memcpy(bp, &start_pgno, sizeof(start_pgno));
01447 bp += sizeof(start_pgno);
01448 memcpy(bp, &num, sizeof(num));
01449 bp += sizeof(num);
01450 memcpy(bp, &free, sizeof(free));
01451 bp += sizeof(free);
01452 DB_ASSERT((u_int32_t)(bp - (u_int8_t *)logrec.data) == logrec.size);
01453 ret = CDB_log_put(dbenv, ret_lsnp, (DBT *)&logrec, flags);
01454 if (txnid != NULL)
01455 txnid->last_lsn = *ret_lsnp;
01456 CDB___os_free(logrec.data, logrec.size);
01457 return (ret);
01458 }
01459
01460 int
01461 CDB___ham_groupalloc_print(dbenv, dbtp, lsnp, notused2, notused3)
01462 DB_ENV *dbenv;
01463 DBT *dbtp;
01464 DB_LSN *lsnp;
01465 db_recops notused2;
01466 void *notused3;
01467 {
01468 __ham_groupalloc_args *argp;
01469 u_int32_t i;
01470 u_int ch;
01471 int ret;
01472
01473 i = 0;
01474 ch = 0;
01475 notused2 = 0;
01476 notused3 = NULL;
01477
01478 if ((ret = CDB___ham_groupalloc_read(dbenv, dbtp->data, &argp)) != 0)
01479 return (ret);
01480 printf("[%lu][%lu]ham_groupalloc: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
01481 (u_long)lsnp->file,
01482 (u_long)lsnp->offset,
01483 (u_long)argp->type,
01484 (u_long)argp->txnid->txnid,
01485 (u_long)argp->prev_lsn.file,
01486 (u_long)argp->prev_lsn.offset);
01487 printf("\tfileid: %ld\n", (long)argp->fileid);
01488 printf("\tmeta_lsn: [%lu][%lu]\n",
01489 (u_long)argp->meta_lsn.file, (u_long)argp->meta_lsn.offset);
01490 printf("\talloc_lsn: [%lu][%lu]\n",
01491 (u_long)argp->alloc_lsn.file, (u_long)argp->alloc_lsn.offset);
01492 printf("\tstart_pgno: %lu\n", (u_long)argp->start_pgno);
01493 printf("\tnum: %lu\n", (u_long)argp->num);
01494 printf("\tfree: %lu\n", (u_long)argp->free);
01495 printf("\n");
01496 CDB___os_free(argp, 0);
01497 return (0);
01498 }
01499
01500 int
01501 CDB___ham_groupalloc_read(dbenv, recbuf, argpp)
01502 DB_ENV *dbenv;
01503 void *recbuf;
01504 __ham_groupalloc_args **argpp;
01505 {
01506 __ham_groupalloc_args *argp;
01507 u_int8_t *bp;
01508 int ret;
01509
01510 ret = CDB___os_malloc(dbenv, sizeof(__ham_groupalloc_args) +
01511 sizeof(DB_TXN), NULL, &argp);
01512 if (ret != 0)
01513 return (ret);
01514 argp->txnid = (DB_TXN *)&argp[1];
01515 bp = recbuf;
01516 memcpy(&argp->type, bp, sizeof(argp->type));
01517 bp += sizeof(argp->type);
01518 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
01519 bp += sizeof(argp->txnid->txnid);
01520 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
01521 bp += sizeof(DB_LSN);
01522 memcpy(&argp->fileid, bp, sizeof(argp->fileid));
01523 bp += sizeof(argp->fileid);
01524 memcpy(&argp->meta_lsn, bp, sizeof(argp->meta_lsn));
01525 bp += sizeof(argp->meta_lsn);
01526 memcpy(&argp->alloc_lsn, bp, sizeof(argp->alloc_lsn));
01527 bp += sizeof(argp->alloc_lsn);
01528 memcpy(&argp->start_pgno, bp, sizeof(argp->start_pgno));
01529 bp += sizeof(argp->start_pgno);
01530 memcpy(&argp->num, bp, sizeof(argp->num));
01531 bp += sizeof(argp->num);
01532 memcpy(&argp->free, bp, sizeof(argp->free));
01533 bp += sizeof(argp->free);
01534 *argpp = argp;
01535 return (0);
01536 }
01537
01538 int
01539 CDB___ham_init_print(dbenv)
01540 DB_ENV *dbenv;
01541 {
01542 int ret;
01543
01544 if ((ret = CDB___db_add_recovery(dbenv,
01545 CDB___ham_insdel_print, DB_ham_insdel)) != 0)
01546 return (ret);
01547 if ((ret = CDB___db_add_recovery(dbenv,
01548 CDB___ham_newpage_print, DB_ham_newpage)) != 0)
01549 return (ret);
01550 if ((ret = CDB___db_add_recovery(dbenv,
01551 CDB___ham_splitmeta_print, DB_ham_splitmeta)) != 0)
01552 return (ret);
01553 if ((ret = CDB___db_add_recovery(dbenv,
01554 CDB___ham_splitdata_print, DB_ham_splitdata)) != 0)
01555 return (ret);
01556 if ((ret = CDB___db_add_recovery(dbenv,
01557 CDB___ham_replace_print, DB_ham_replace)) != 0)
01558 return (ret);
01559 if ((ret = CDB___db_add_recovery(dbenv,
01560 CDB___ham_newpgno_print, DB_ham_newpgno)) != 0)
01561 return (ret);
01562 if ((ret = CDB___db_add_recovery(dbenv,
01563 CDB___ham_ovfl_print, DB_ham_ovfl)) != 0)
01564 return (ret);
01565 if ((ret = CDB___db_add_recovery(dbenv,
01566 CDB___ham_copypage_print, DB_ham_copypage)) != 0)
01567 return (ret);
01568 if ((ret = CDB___db_add_recovery(dbenv,
01569 CDB___ham_metagroup_print, DB_ham_metagroup)) != 0)
01570 return (ret);
01571 if ((ret = CDB___db_add_recovery(dbenv,
01572 CDB___ham_groupalloc1_print, DB_ham_groupalloc1)) != 0)
01573 return (ret);
01574 if ((ret = CDB___db_add_recovery(dbenv,
01575 CDB___ham_groupalloc_print, DB_ham_groupalloc)) != 0)
01576 return (ret);
01577 return (0);
01578 }
01579
01580 int
01581 CDB___ham_init_recover(dbenv)
01582 DB_ENV *dbenv;
01583 {
01584 int ret;
01585
01586 if ((ret = CDB___db_add_recovery(dbenv,
01587 CDB___ham_insdel_recover, DB_ham_insdel)) != 0)
01588 return (ret);
01589 if ((ret = CDB___db_add_recovery(dbenv,
01590 CDB___ham_newpage_recover, DB_ham_newpage)) != 0)
01591 return (ret);
01592 if ((ret = CDB___db_add_recovery(dbenv,
01593 CDB___deprecated_recover, DB_ham_splitmeta)) != 0)
01594 return (ret);
01595 if ((ret = CDB___db_add_recovery(dbenv,
01596 CDB___ham_splitdata_recover, DB_ham_splitdata)) != 0)
01597 return (ret);
01598 if ((ret = CDB___db_add_recovery(dbenv,
01599 CDB___ham_replace_recover, DB_ham_replace)) != 0)
01600 return (ret);
01601 if ((ret = CDB___db_add_recovery(dbenv,
01602 CDB___deprecated_recover, DB_ham_newpgno)) != 0)
01603 return (ret);
01604 if ((ret = CDB___db_add_recovery(dbenv,
01605 CDB___deprecated_recover, DB_ham_ovfl)) != 0)
01606 return (ret);
01607 if ((ret = CDB___db_add_recovery(dbenv,
01608 CDB___ham_copypage_recover, DB_ham_copypage)) != 0)
01609 return (ret);
01610 if ((ret = CDB___db_add_recovery(dbenv,
01611 CDB___ham_metagroup_recover, DB_ham_metagroup)) != 0)
01612 return (ret);
01613 if ((ret = CDB___db_add_recovery(dbenv,
01614 CDB___deprecated_recover, DB_ham_groupalloc1)) != 0)
01615 return (ret);
01616 if ((ret = CDB___db_add_recovery(dbenv,
01617 CDB___ham_groupalloc_recover, DB_ham_groupalloc)) != 0)
01618 return (ret);
01619 return (0);
01620 }
01621