1/*- 2 * See the file LICENSE for redistribution information. 3 * 4 * Copyright (c) 1996,2008 Oracle. All rights reserved. 5 */ 6/* 7 * Copyright (c) 1990, 1993, 1994, 1995, 1996 8 * Keith Bostic. All rights reserved. 9 */ 10/* 11 * Copyright (c) 1990, 1993, 1994, 1995 12 * The Regents of the University of California. All rights reserved. 13 * 14 * This code is derived from software contributed to Berkeley by 15 * Mike Olson. 16 * 17 * Redistribution and use in source and binary forms, with or without 18 * modification, are permitted provided that the following conditions 19 * are met: 20 * 1. Redistributions of source code must retain the above copyright 21 * notice, this list of conditions and the following disclaimer. 22 * 2. Redistributions in binary form must reproduce the above copyright 23 * notice, this list of conditions and the following disclaimer in the 24 * documentation and/or other materials provided with the distribution. 25 * 3. Neither the name of the University nor the names of its contributors 26 * may be used to endorse or promote products derived from this software 27 * without specific prior written permission. 28 * 29 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 30 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 31 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 32 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 33 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 34 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 35 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 36 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 37 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 38 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 39 * SUCH DAMAGE. 40 * 41 * $Id: bt_open.c,v 12.25 2008/01/30 12:18:21 mjc Exp $ 42 */ 43 44#include "db_config.h" 45 46#include "db_int.h" 47#include "dbinc/crypto.h" 48#include "dbinc/db_page.h" 49#include "dbinc/db_swap.h" 50#include "dbinc/btree.h" 51#include "dbinc/lock.h" 52#include "dbinc/log.h" 53#include "dbinc/mp.h" 54#include "dbinc/fop.h" 55 56static void __bam_init_meta __P((DB *, BTMETA *, db_pgno_t, DB_LSN *)); 57 58/* 59 * __bam_open -- 60 * Open a btree. 61 * 62 * PUBLIC: int __bam_open __P((DB *, DB_THREAD_INFO *, 63 * PUBLIC: DB_TXN *, const char *, db_pgno_t, u_int32_t)); 64 */ 65int 66__bam_open(dbp, ip, txn, name, base_pgno, flags) 67 DB *dbp; 68 DB_THREAD_INFO *ip; 69 DB_TXN *txn; 70 const char *name; 71 db_pgno_t base_pgno; 72 u_int32_t flags; 73{ 74 BTREE *t; 75 76 COMPQUIET(name, NULL); 77 t = dbp->bt_internal; 78 79 /* 80 * We don't permit the user to specify a prefix routine if they didn't 81 * also specify a comparison routine, they can't know enough about our 82 * comparison routine to get it right. 83 */ 84 if (t->bt_compare == __bam_defcmp && t->bt_prefix != __bam_defpfx) { 85 __db_errx(dbp->env, 86"prefix comparison may not be specified for default comparison routine"); 87 return (EINVAL); 88 } 89 90 /* 91 * Verify that the bt_minkey value specified won't cause the 92 * calculation of ovflsize to underflow [#2406] for this pagesize. 93 */ 94 if (B_MINKEY_TO_OVFLSIZE(dbp, t->bt_minkey, dbp->pgsize) > 95 B_MINKEY_TO_OVFLSIZE(dbp, DEFMINKEYPAGE, dbp->pgsize)) { 96 __db_errx(dbp->env, 97 "bt_minkey value of %lu too high for page size of %lu", 98 (u_long)t->bt_minkey, (u_long)dbp->pgsize); 99 return (EINVAL); 100 } 101 102 /* Start up the tree. */ 103 return (__bam_read_root(dbp, ip, txn, base_pgno, flags)); 104} 105 106/* 107 * __bam_metachk -- 108 * 109 * PUBLIC: int __bam_metachk __P((DB *, const char *, BTMETA *)); 110 */ 111int 112__bam_metachk(dbp, name, btm) 113 DB *dbp; 114 const char *name; 115 BTMETA *btm; 116{ 117 ENV *env; 118 u_int32_t vers; 119 int ret; 120 121 env = dbp->env; 122 123 /* 124 * At this point, all we know is that the magic number is for a Btree. 125 * Check the version, the database may be out of date. 126 */ 127 vers = btm->dbmeta.version; 128 if (F_ISSET(dbp, DB_AM_SWAP)) 129 M_32_SWAP(vers); 130 switch (vers) { 131 case 6: 132 case 7: 133 __db_errx(env, 134 "%s: btree version %lu requires a version upgrade", 135 name, (u_long)vers); 136 return (DB_OLD_VERSION); 137 case 8: 138 case 9: 139 break; 140 default: 141 __db_errx(env, 142 "%s: unsupported btree version: %lu", name, (u_long)vers); 143 return (EINVAL); 144 } 145 146 /* Swap the page if we need to. */ 147 if (F_ISSET(dbp, DB_AM_SWAP) && 148 (ret = __bam_mswap(env, (PAGE *)btm)) != 0) 149 return (ret); 150 151 /* 152 * Check application info against metadata info, and set info, flags, 153 * and type based on metadata info. 154 */ 155 if ((ret = 156 __db_fchk(env, "DB->open", btm->dbmeta.flags, BTM_MASK)) != 0) 157 return (ret); 158 159 if (F_ISSET(&btm->dbmeta, BTM_RECNO)) { 160 if (dbp->type == DB_BTREE) 161 goto wrong_type; 162 dbp->type = DB_RECNO; 163 DB_ILLEGAL_METHOD(dbp, DB_OK_RECNO); 164 } else { 165 if (dbp->type == DB_RECNO) 166 goto wrong_type; 167 dbp->type = DB_BTREE; 168 DB_ILLEGAL_METHOD(dbp, DB_OK_BTREE); 169 } 170 171 if (F_ISSET(&btm->dbmeta, BTM_DUP)) 172 F_SET(dbp, DB_AM_DUP); 173 else 174 if (F_ISSET(dbp, DB_AM_DUP)) { 175 __db_errx(env, 176 "%s: DB_DUP specified to open method but not set in database", 177 name); 178 return (EINVAL); 179 } 180 181 if (F_ISSET(&btm->dbmeta, BTM_RECNUM)) { 182 if (dbp->type != DB_BTREE) 183 goto wrong_type; 184 F_SET(dbp, DB_AM_RECNUM); 185 186 if ((ret = __db_fcchk(env, 187 "DB->open", dbp->flags, DB_AM_DUP, DB_AM_RECNUM)) != 0) 188 return (ret); 189 } else 190 if (F_ISSET(dbp, DB_AM_RECNUM)) { 191 __db_errx(env, 192 "%s: DB_RECNUM specified to open method but not set in database", 193 name); 194 return (EINVAL); 195 } 196 197 if (F_ISSET(&btm->dbmeta, BTM_FIXEDLEN)) { 198 if (dbp->type != DB_RECNO) 199 goto wrong_type; 200 F_SET(dbp, DB_AM_FIXEDLEN); 201 } else 202 if (F_ISSET(dbp, DB_AM_FIXEDLEN)) { 203 __db_errx(env, 204 "%s: DB_FIXEDLEN specified to open method but not set in database", 205 name); 206 return (EINVAL); 207 } 208 209 if (F_ISSET(&btm->dbmeta, BTM_RENUMBER)) { 210 if (dbp->type != DB_RECNO) 211 goto wrong_type; 212 F_SET(dbp, DB_AM_RENUMBER); 213 } else 214 if (F_ISSET(dbp, DB_AM_RENUMBER)) { 215 __db_errx(env, 216 "%s: DB_RENUMBER specified to open method but not set in database", 217 name); 218 return (EINVAL); 219 } 220 221 if (F_ISSET(&btm->dbmeta, BTM_SUBDB)) 222 F_SET(dbp, DB_AM_SUBDB); 223 else 224 if (F_ISSET(dbp, DB_AM_SUBDB)) { 225 __db_errx(env, 226 "%s: multiple databases specified but not supported by file", 227 name); 228 return (EINVAL); 229 } 230 231 if (F_ISSET(&btm->dbmeta, BTM_DUPSORT)) { 232 if (dbp->dup_compare == NULL) 233 dbp->dup_compare = __bam_defcmp; 234 F_SET(dbp, DB_AM_DUPSORT); 235 } else 236 if (dbp->dup_compare != NULL) { 237 __db_errx(env, 238 "%s: duplicate sort specified but not supported in database", 239 name); 240 return (EINVAL); 241 } 242 243 /* Set the page size. */ 244 dbp->pgsize = btm->dbmeta.pagesize; 245 246 /* Copy the file's ID. */ 247 memcpy(dbp->fileid, btm->dbmeta.uid, DB_FILE_ID_LEN); 248 249 return (0); 250 251wrong_type: 252 if (dbp->type == DB_BTREE) 253 __db_errx(env, 254 "open method type is Btree, database type is Recno"); 255 else 256 __db_errx(env, 257 "open method type is Recno, database type is Btree"); 258 return (EINVAL); 259} 260 261/* 262 * __bam_read_root -- 263 * Read the root page and check a tree. 264 * 265 * PUBLIC: int __bam_read_root __P((DB *, 266 * PUBLIC: DB_THREAD_INFO *, DB_TXN *, db_pgno_t, u_int32_t)); 267 */ 268int 269__bam_read_root(dbp, ip, txn, base_pgno, flags) 270 DB *dbp; 271 DB_THREAD_INFO *ip; 272 DB_TXN *txn; 273 db_pgno_t base_pgno; 274 u_int32_t flags; 275{ 276 BTMETA *meta; 277 BTREE *t; 278 DBC *dbc; 279 DB_LOCK metalock; 280 DB_MPOOLFILE *mpf; 281 int ret, t_ret; 282 283 COMPQUIET(flags, 0); 284 285 meta = NULL; 286 t = dbp->bt_internal; 287 LOCK_INIT(metalock); 288 mpf = dbp->mpf; 289 ret = 0; 290 291 /* Get a cursor. */ 292 if ((ret = __db_cursor(dbp, ip, txn, &dbc, 0)) != 0) 293 return (ret); 294 295 /* Get the metadata page. */ 296 if ((ret = 297 __db_lget(dbc, 0, base_pgno, DB_LOCK_READ, 0, &metalock)) != 0) 298 goto err; 299 if ((ret = __memp_fget(mpf, &base_pgno, ip, dbc->txn, 0, &meta)) != 0) 300 goto err; 301 302 /* 303 * If the magic number is set, the tree has been created. Correct 304 * any fields that may not be right. Note, all of the local flags 305 * were set by DB->open. 306 * 307 * Otherwise, we'd better be in recovery or abort, in which case the 308 * metadata page will be created/initialized elsewhere. 309 */ 310 if (meta->dbmeta.magic == DB_BTREEMAGIC) { 311 t->bt_minkey = meta->minkey; 312 t->re_pad = (int)meta->re_pad; 313 t->re_len = meta->re_len; 314 315 t->bt_meta = base_pgno; 316 t->bt_root = meta->root; 317 if (PGNO(meta) == PGNO_BASE_MD && !F_ISSET(dbp, DB_AM_RECOVER)) 318 __memp_set_last_pgno(mpf, meta->dbmeta.last_pgno); 319 } else { 320 DB_ASSERT(dbp->env, 321 IS_RECOVERING(dbp->env) || F_ISSET(dbp, DB_AM_RECOVER)); 322 } 323 324 /* 325 * !!! 326 * If creating a subdatabase, we've already done an insert when 327 * we put the subdatabase's entry into the master database, so 328 * our last-page-inserted value is wrongly initialized for the 329 * master database, not the subdatabase we're creating. I'm not 330 * sure where the *right* place to clear this value is, it's not 331 * intuitively obvious that it belongs here. 332 */ 333 t->bt_lpgno = PGNO_INVALID; 334 335err: /* Put the metadata page back. */ 336 if (meta != NULL && (t_ret = __memp_fput(mpf, 337 ip, meta, dbc->priority)) != 0 && ret == 0) 338 ret = t_ret; 339 if ((t_ret = __LPUT(dbc, metalock)) != 0 && ret == 0) 340 ret = t_ret; 341 342 if ((t_ret = __dbc_close(dbc)) != 0 && ret == 0) 343 ret = t_ret; 344 return (ret); 345} 346 347/* 348 * __bam_init_meta -- 349 * 350 * Initialize a btree meta-data page. The following fields may need 351 * to be updated later: last_pgno, root. 352 */ 353static void 354__bam_init_meta(dbp, meta, pgno, lsnp) 355 DB *dbp; 356 BTMETA *meta; 357 db_pgno_t pgno; 358 DB_LSN *lsnp; 359{ 360 BTREE *t; 361 ENV *env; 362 363 env = dbp->env; 364 t = dbp->bt_internal; 365 366 memset(meta, 0, sizeof(BTMETA)); 367 meta->dbmeta.lsn = *lsnp; 368 meta->dbmeta.pgno = pgno; 369 meta->dbmeta.magic = DB_BTREEMAGIC; 370 meta->dbmeta.version = DB_BTREEVERSION; 371 meta->dbmeta.pagesize = dbp->pgsize; 372 if (F_ISSET(dbp, DB_AM_CHKSUM)) 373 FLD_SET(meta->dbmeta.metaflags, DBMETA_CHKSUM); 374 if (F_ISSET(dbp, DB_AM_ENCRYPT)) { 375 meta->dbmeta.encrypt_alg = env->crypto_handle->alg; 376 DB_ASSERT(env, meta->dbmeta.encrypt_alg != 0); 377 meta->crypto_magic = meta->dbmeta.magic; 378 } 379 meta->dbmeta.type = P_BTREEMETA; 380 meta->dbmeta.free = PGNO_INVALID; 381 meta->dbmeta.last_pgno = pgno; 382 if (F_ISSET(dbp, DB_AM_DUP)) 383 F_SET(&meta->dbmeta, BTM_DUP); 384 if (F_ISSET(dbp, DB_AM_FIXEDLEN)) 385 F_SET(&meta->dbmeta, BTM_FIXEDLEN); 386 if (F_ISSET(dbp, DB_AM_RECNUM)) 387 F_SET(&meta->dbmeta, BTM_RECNUM); 388 if (F_ISSET(dbp, DB_AM_RENUMBER)) 389 F_SET(&meta->dbmeta, BTM_RENUMBER); 390 if (F_ISSET(dbp, DB_AM_SUBDB)) 391 F_SET(&meta->dbmeta, BTM_SUBDB); 392 if (dbp->dup_compare != NULL) 393 F_SET(&meta->dbmeta, BTM_DUPSORT); 394 if (dbp->type == DB_RECNO) 395 F_SET(&meta->dbmeta, BTM_RECNO); 396 memcpy(meta->dbmeta.uid, dbp->fileid, DB_FILE_ID_LEN); 397 398 meta->minkey = t->bt_minkey; 399 meta->re_len = t->re_len; 400 meta->re_pad = (u_int32_t)t->re_pad; 401} 402 403/* 404 * __bam_new_file -- 405 * Create the necessary pages to begin a new database file. 406 * 407 * This code appears more complex than it is because of the two cases (named 408 * and unnamed). The way to read the code is that for each page being created, 409 * there are three parts: 1) a "get page" chunk (which either uses malloc'd 410 * memory or calls __memp_fget), 2) the initialization, and 3) the "put page" 411 * chunk which either does a fop write or an __memp_fput. 412 * 413 * PUBLIC: int __bam_new_file __P((DB *, 414 * PUBLIC: DB_THREAD_INFO *, DB_TXN *, DB_FH *, const char *)); 415 */ 416int 417__bam_new_file(dbp, ip, txn, fhp, name) 418 DB *dbp; 419 DB_THREAD_INFO *ip; 420 DB_TXN *txn; 421 DB_FH *fhp; 422 const char *name; 423{ 424 BTMETA *meta; 425 DBT pdbt; 426 DB_LSN lsn; 427 DB_MPOOLFILE *mpf; 428 DB_PGINFO pginfo; 429 ENV *env; 430 PAGE *root; 431 db_pgno_t pgno; 432 int ret, t_ret; 433 void *buf; 434 435 env = dbp->env; 436 mpf = dbp->mpf; 437 root = NULL; 438 meta = NULL; 439 buf = NULL; 440 441 if (F_ISSET(dbp, DB_AM_INMEM)) { 442 /* Build the meta-data page. */ 443 pgno = PGNO_BASE_MD; 444 if ((ret = __memp_fget(mpf, &pgno, ip, txn, 445 DB_MPOOL_CREATE | DB_MPOOL_DIRTY, &meta)) != 0) 446 return (ret); 447 LSN_NOT_LOGGED(lsn); 448 __bam_init_meta(dbp, meta, PGNO_BASE_MD, &lsn); 449 meta->root = 1; 450 meta->dbmeta.last_pgno = 1; 451 if ((ret = 452 __db_log_page(dbp, txn, &lsn, pgno, (PAGE *)meta)) != 0) 453 goto err; 454 ret = __memp_fput(mpf, ip, meta, dbp->priority); 455 meta = NULL; 456 if (ret != 0) 457 goto err; 458 459 /* Build the root page. */ 460 pgno = 1; 461 if ((ret = __memp_fget(mpf, &pgno, 462 ip, txn, DB_MPOOL_CREATE, &root)) != 0) 463 goto err; 464 P_INIT(root, dbp->pgsize, 1, PGNO_INVALID, PGNO_INVALID, 465 LEAFLEVEL, dbp->type == DB_RECNO ? P_LRECNO : P_LBTREE); 466 LSN_NOT_LOGGED(root->lsn); 467 if ((ret = 468 __db_log_page(dbp, txn, &root->lsn, pgno, root)) != 0) 469 goto err; 470 ret = __memp_fput(mpf, ip, root, dbp->priority); 471 root = NULL; 472 if (ret != 0) 473 goto err; 474 } else { 475 memset(&pdbt, 0, sizeof(pdbt)); 476 477 /* Build the meta-data page. */ 478 pginfo.db_pagesize = dbp->pgsize; 479 pginfo.flags = 480 F_ISSET(dbp, (DB_AM_CHKSUM | DB_AM_ENCRYPT | DB_AM_SWAP)); 481 pginfo.type = dbp->type; 482 pdbt.data = &pginfo; 483 pdbt.size = sizeof(pginfo); 484 if ((ret = __os_calloc(env, 1, dbp->pgsize, &buf)) != 0) 485 return (ret); 486 meta = (BTMETA *)buf; 487 LSN_NOT_LOGGED(lsn); 488 __bam_init_meta(dbp, meta, PGNO_BASE_MD, &lsn); 489 meta->root = 1; 490 meta->dbmeta.last_pgno = 1; 491 if ((ret = __db_pgout( 492 dbp->dbenv, PGNO_BASE_MD, meta, &pdbt)) != 0) 493 goto err; 494 if ((ret = __fop_write(env, txn, name, DB_APP_DATA, fhp, 495 dbp->pgsize, 0, 0, buf, dbp->pgsize, 1, F_ISSET( 496 dbp, DB_AM_NOT_DURABLE) ? DB_LOG_NOT_DURABLE : 0)) != 0) 497 goto err; 498 meta = NULL; 499 500 /* Build the root page. */ 501#ifdef DIAGNOSTIC 502 memset(buf, CLEAR_BYTE, dbp->pgsize); 503#endif 504 root = (PAGE *)buf; 505 P_INIT(root, dbp->pgsize, 1, PGNO_INVALID, PGNO_INVALID, 506 LEAFLEVEL, dbp->type == DB_RECNO ? P_LRECNO : P_LBTREE); 507 LSN_NOT_LOGGED(root->lsn); 508 if ((ret = 509 __db_pgout(dbp->dbenv, root->pgno, root, &pdbt)) != 0) 510 goto err; 511 if ((ret = __fop_write(env, txn, name, DB_APP_DATA, fhp, 512 dbp->pgsize, 1, 0, buf, dbp->pgsize, 1, F_ISSET( 513 dbp, DB_AM_NOT_DURABLE) ? DB_LOG_NOT_DURABLE : 0)) != 0) 514 goto err; 515 root = NULL; 516 } 517 518err: if (buf != NULL) 519 __os_free(env, buf); 520 else { 521 if (meta != NULL && 522 (t_ret = __memp_fput(mpf, ip, 523 meta, dbp->priority)) != 0 && ret == 0) 524 ret = t_ret; 525 if (root != NULL && 526 (t_ret = __memp_fput(mpf, ip, 527 root, dbp->priority)) != 0 && ret == 0) 528 ret = t_ret; 529 } 530 return (ret); 531} 532 533/* 534 * __bam_new_subdb -- 535 * Create a metadata page and a root page for a new btree. 536 * 537 * PUBLIC: int __bam_new_subdb __P((DB *, DB *, DB_THREAD_INFO *, DB_TXN *)); 538 */ 539int 540__bam_new_subdb(mdbp, dbp, ip, txn) 541 DB *mdbp, *dbp; 542 DB_THREAD_INFO *ip; 543 DB_TXN *txn; 544{ 545 BTMETA *meta; 546 DBC *dbc; 547 DB_LOCK metalock; 548 DB_LSN lsn; 549 DB_MPOOLFILE *mpf; 550 ENV *env; 551 PAGE *root; 552 int ret, t_ret; 553 554 env = mdbp->env; 555 mpf = mdbp->mpf; 556 dbc = NULL; 557 meta = NULL; 558 root = NULL; 559 560 if ((ret = __db_cursor(mdbp, ip, txn, 561 &dbc, CDB_LOCKING(env) ? DB_WRITECURSOR : 0)) != 0) 562 return (ret); 563 564 /* Get, and optionally create the metadata page. */ 565 if ((ret = __db_lget(dbc, 566 0, dbp->meta_pgno, DB_LOCK_WRITE, 0, &metalock)) != 0) 567 goto err; 568 if ((ret = __memp_fget(mpf, &dbp->meta_pgno, 569 ip, txn, DB_MPOOL_CREATE, &meta)) != 0) 570 goto err; 571 572 /* Build meta-data page. */ 573 lsn = meta->dbmeta.lsn; 574 __bam_init_meta(dbp, meta, dbp->meta_pgno, &lsn); 575 if ((ret = __db_log_page(mdbp, 576 txn, &meta->dbmeta.lsn, dbp->meta_pgno, (PAGE *)meta)) != 0) 577 goto err; 578 579 /* Create and initialize a root page. */ 580 if ((ret = __db_new(dbc, 581 dbp->type == DB_RECNO ? P_LRECNO : P_LBTREE, &root)) != 0) 582 goto err; 583 root->level = LEAFLEVEL; 584 585 if (DBENV_LOGGING(env) && 586#if !defined(DEBUG_WOP) 587 txn != NULL && 588#endif 589 590 (ret = __bam_root_log(mdbp, txn, &meta->dbmeta.lsn, 0, 591 meta->dbmeta.pgno, root->pgno, &meta->dbmeta.lsn)) != 0) 592 goto err; 593 594 meta->root = root->pgno; 595 if ((ret = 596 __db_log_page(mdbp, txn, &root->lsn, root->pgno, root)) != 0) 597 goto err; 598 599 /* Release the metadata and root pages. */ 600 if ((ret = __memp_fput(mpf, ip, meta, dbc->priority)) != 0) 601 goto err; 602 meta = NULL; 603 if ((ret = __memp_fput(mpf, ip, root, dbc->priority)) != 0) 604 goto err; 605 root = NULL; 606err: 607 if (meta != NULL) 608 if ((t_ret = __memp_fput(mpf, ip, 609 meta, dbc->priority)) != 0 && ret == 0) 610 ret = t_ret; 611 if (root != NULL) 612 if ((t_ret = __memp_fput(mpf, ip, 613 root, dbc->priority)) != 0 && ret == 0) 614 ret = t_ret; 615 if ((t_ret = __LPUT(dbc, metalock)) != 0 && ret == 0) 616 ret = t_ret; 617 if (dbc != NULL) 618 if ((t_ret = __dbc_close(dbc)) != 0 && ret == 0) 619 ret = t_ret; 620 return (ret); 621} 622