* db2/btree/bt_cursor.c: Likewise.
	* db2/common/db_region.db_c: Likewise.
	* db2/common/db_salloc.db_c: Likewise.
	* db2/db/db.c: Likewise.
	* db2/db/db_rec.c: Likewise.
	* db2/hash/hash.c: Likewise.
	* db2/hash/hash_page.c: Likewise.
	* db2/hash/hash_rec.c: Likewise.
	* db2/log/log_findckp.c: Likewise.
	* db2/log/log_get.c: Likewise.
	* db2/log/log_put.c: Likewise.
	* db2/mp/mp_fget.c: Likewise.
	* db2/mp/mp_fput.c: Likewise.
	* db2/mp/mp_region.c: Likewise.
This commit is contained in:
Ulrich Drepper 1998-09-07 11:07:34 +00:00
parent 88c9111883
commit 2c874db2dd
15 changed files with 84 additions and 40 deletions

View File

@ -2,6 +2,20 @@
* db2/common/db_apprec.c (__db_apprec): Add braces to make gcc * db2/common/db_apprec.c (__db_apprec): Add braces to make gcc
quiet. quiet.
* db2/btree/bt_cursor.c: Likewise.
* db2/common/db_region.db_c: Likewise.
* db2/common/db_salloc.db_c: Likewise.
* db2/db/db.c: Likewise.
* db2/db/db_rec.c: Likewise.
* db2/hash/hash.c: Likewise.
* db2/hash/hash_page.c: Likewise.
* db2/hash/hash_rec.c: Likewise.
* db2/log/log_findckp.c: Likewise.
* db2/log/log_get.c: Likewise.
* db2/log/log_put.c: Likewise.
* db2/mp/mp_fget.c: Likewise.
* db2/mp/mp_fput.c: Likewise.
* db2/mp/mp_region.c: Likewise.
1998-09-07 09:58 Ulrich Drepper <drepper@cygnus.com> 1998-09-07 09:58 Ulrich Drepper <drepper@cygnus.com>

View File

@ -1070,13 +1070,14 @@ __bam_c_search(dbp, cp, key, flags, isrecno, exactp)
/* If it's a deleted record, go to the next or previous one. */ /* If it's a deleted record, go to the next or previous one. */
if (cp->dpgno != PGNO_INVALID && if (cp->dpgno != PGNO_INVALID &&
B_DISSET(GET_BKEYDATA(cp->page, cp->dindx)->type)) B_DISSET(GET_BKEYDATA(cp->page, cp->dindx)->type)) {
if (flags == S_KEYLAST) { if (flags == S_KEYLAST) {
if ((ret = __bam_c_prev(dbp, cp)) != 0) if ((ret = __bam_c_prev(dbp, cp)) != 0)
return (ret); return (ret);
} else } else
if ((ret = __bam_c_next(dbp, cp, 0)) != 0) if ((ret = __bam_c_next(dbp, cp, 0)) != 0)
return (ret); return (ret);
}
/* /*
* If we don't specify an exact match (the DB_KEYFIRST/DB_KEYLAST or * If we don't specify an exact match (the DB_KEYFIRST/DB_KEYLAST or
* DB_SET_RANGE flags were set) __bam_search() may return a deleted * DB_SET_RANGE flags were set) __bam_search() may return a deleted
@ -1467,7 +1468,7 @@ __bam_ca_split(dbp, ppgno, lpgno, rpgno, split_indx, cleft)
for (dbc = TAILQ_FIRST(&dbp->curs_queue); for (dbc = TAILQ_FIRST(&dbp->curs_queue);
dbc != NULL; dbc = TAILQ_NEXT(dbc, links)) { dbc != NULL; dbc = TAILQ_NEXT(dbc, links)) {
cp = (CURSOR *)dbc->internal; cp = (CURSOR *)dbc->internal;
if (cp->pgno == ppgno) if (cp->pgno == ppgno) {
if (cp->indx < split_indx) { if (cp->indx < split_indx) {
if (cleft) if (cleft)
cp->pgno = lpgno; cp->pgno = lpgno;
@ -1475,7 +1476,8 @@ __bam_ca_split(dbp, ppgno, lpgno, rpgno, split_indx, cleft)
cp->pgno = rpgno; cp->pgno = rpgno;
cp->indx -= split_indx; cp->indx -= split_indx;
} }
if (cp->dpgno == ppgno) }
if (cp->dpgno == ppgno) {
if (cp->dindx < split_indx) { if (cp->dindx < split_indx) {
if (cleft) if (cleft)
cp->dpgno = lpgno; cp->dpgno = lpgno;
@ -1483,6 +1485,7 @@ __bam_ca_split(dbp, ppgno, lpgno, rpgno, split_indx, cleft)
cp->dpgno = rpgno; cp->dpgno = rpgno;
cp->dindx -= split_indx; cp->dindx -= split_indx;
} }
}
} }
CURSOR_TEARDOWN(dbp); CURSOR_TEARDOWN(dbp);
} }

View File

@ -272,7 +272,7 @@ loop: infop->addr = NULL;
* obvious races in doing this, but it should eventually settle down * obvious races in doing this, but it should eventually settle down
* to a winner and then things should proceed normally. * to a winner and then things should proceed normally.
*/ */
if ((ret = __db_mapregion(infop->name, infop)) != 0) if ((ret = __db_mapregion(infop->name, infop)) != 0) {
if (ret == EAGAIN) { if (ret == EAGAIN) {
/* /*
* Pretend we created the region even if we didn't so * Pretend we created the region even if we didn't so
@ -283,7 +283,7 @@ loop: infop->addr = NULL;
goto retry; goto retry;
} else } else
goto err; goto err;
}
region_init: region_init:
/* /*
* Initialize the common region information. * Initialize the common region information.
@ -474,7 +474,7 @@ retry: /* Discard the region. */
* REGION_LASTDETACH flag, so that we do all necessary cleanup when * REGION_LASTDETACH flag, so that we do all necessary cleanup when
* the application closes the region. * the application closes the region.
*/ */
if (F_ISSET(infop, REGION_PRIVATE) && !F_ISSET(infop, REGION_MALLOC)) if (F_ISSET(infop, REGION_PRIVATE) && !F_ISSET(infop, REGION_MALLOC)) {
if (F_ISSET(infop, REGION_HOLDINGSYS)) if (F_ISSET(infop, REGION_HOLDINGSYS))
F_SET(infop, REGION_LASTDETACH); F_SET(infop, REGION_LASTDETACH);
else { else {
@ -484,7 +484,7 @@ retry: /* Discard the region. */
(void)__db_close(infop->fd); (void)__db_close(infop->fd);
(void)__db_unlink(infop->name); (void)__db_unlink(infop->name);
} }
}
return (ret); return (ret);
} }
@ -537,12 +537,13 @@ __db_rdetach(infop)
* what happened. * what happened.
*/ */
detach = 0; detach = 0;
if (F_ISSET(infop, REGION_LASTDETACH)) if (F_ISSET(infop, REGION_LASTDETACH)) {
if (rlp->refcnt == 0) { if (rlp->refcnt == 0) {
detach = 1; detach = 1;
rlp->valid = 0; rlp->valid = 0;
} else } else
ret = EBUSY; ret = EBUSY;
}
/* Release the lock. */ /* Release the lock. */
(void)__db_mutex_unlock(&rlp->lock, infop->fd); (void)__db_mutex_unlock(&rlp->lock, infop->fd);

View File

@ -222,11 +222,12 @@ __db_shalloc_free(regionp, ptr)
merged = 1; merged = 1;
} }
if (!merged) if (!merged) {
if (lastp == NULL) if (lastp == NULL)
SH_LIST_INSERT_HEAD(hp, newp, links, __data); SH_LIST_INSERT_HEAD(hp, newp, links, __data);
else else
SH_LIST_INSERT_AFTER(lastp, newp, links, __data); SH_LIST_INSERT_AFTER(lastp, newp, links, __data);
}
} }
/* /*

View File

@ -265,7 +265,7 @@ db_open(fname, type, flags, mode, dbenv, dbinfo, dbpp)
retry_cnt = 0; retry_cnt = 0;
open_retry: if (LF_ISSET(DB_CREATE)) { open_retry: if (LF_ISSET(DB_CREATE)) {
if ((ret = __db_open(real_name, flags | DB_EXCL, if ((ret = __db_open(real_name, flags | DB_EXCL,
OKFLAGS | DB_EXCL, mode, &fd)) != 0) OKFLAGS | DB_EXCL, mode, &fd)) != 0) {
if (ret == EEXIST) { if (ret == EEXIST) {
LF_CLR(DB_CREATE); LF_CLR(DB_CREATE);
goto open_retry; goto open_retry;
@ -274,6 +274,7 @@ open_retry: if (LF_ISSET(DB_CREATE)) {
"%s: %s", fname, strerror(ret)); "%s: %s", fname, strerror(ret));
goto err; goto err;
} }
}
} else } else
if ((ret = __db_open(real_name, if ((ret = __db_open(real_name,
flags, OKFLAGS, mode, &fd)) != 0) { flags, OKFLAGS, mode, &fd)) != 0) {
@ -551,7 +552,7 @@ empty: /*
* Store the file id in the locker structure -- we can get it from * Store the file id in the locker structure -- we can get it from
* there as necessary, and it saves having two copies. * there as necessary, and it saves having two copies.
*/ */
if (need_fileid) if (need_fileid) {
if (fname == NULL) { if (fname == NULL) {
memset(dbp->lock.fileid, 0, DB_FILE_ID_LEN); memset(dbp->lock.fileid, 0, DB_FILE_ID_LEN);
if (F_ISSET(dbp, DB_AM_LOCKING) && if (F_ISSET(dbp, DB_AM_LOCKING) &&
@ -562,6 +563,7 @@ empty: /*
if ((ret = __db_fileid(dbenv, if ((ret = __db_fileid(dbenv,
real_name, 1, dbp->lock.fileid)) != 0) real_name, 1, dbp->lock.fileid)) != 0)
goto err; goto err;
}
/* No further use for the real name. */ /* No further use for the real name. */
if (real_name != NULL) if (real_name != NULL)

View File

@ -89,11 +89,12 @@ __db_addrem_recover(logp, dbtp, lsnp, redo, info)
change = DB_MPOOL_DIRTY; change = DB_MPOOL_DIRTY;
} }
if (change) if (change) {
if (redo) if (redo)
LSN(pagep) = *lsnp; LSN(pagep) = *lsnp;
else else
LSN(pagep) = argp->pagelsn; LSN(pagep) = argp->pagelsn;
}
if ((ret = memp_fput(mpf, pagep, change)) == 0) if ((ret = memp_fput(mpf, pagep, change)) == 0)
*lsnp = argp->prev_lsn; *lsnp = argp->prev_lsn;
@ -249,7 +250,7 @@ __db_big_recover(logp, dbtp, lsnp, redo, info)
/* Now check the previous page. */ /* Now check the previous page. */
ppage: if (argp->prev_pgno != PGNO_INVALID) { ppage: if (argp->prev_pgno != PGNO_INVALID) {
change = 0; change = 0;
if ((ret = memp_fget(mpf, &argp->prev_pgno, 0, &pagep)) != 0) if ((ret = memp_fget(mpf, &argp->prev_pgno, 0, &pagep)) != 0) {
if (!redo) { if (!redo) {
/* /*
* We are undoing and the page doesn't exist. * We are undoing and the page doesn't exist.
@ -264,6 +265,7 @@ ppage: if (argp->prev_pgno != PGNO_INVALID) {
if ((ret = memp_fget(mpf, &argp->prev_pgno, if ((ret = memp_fget(mpf, &argp->prev_pgno,
DB_MPOOL_CREATE, &pagep)) != 0) DB_MPOOL_CREATE, &pagep)) != 0)
goto out; goto out;
}
cmp_n = log_compare(lsnp, &LSN(pagep)); cmp_n = log_compare(lsnp, &LSN(pagep));
cmp_p = log_compare(&LSN(pagep), &argp->prevlsn); cmp_p = log_compare(&LSN(pagep), &argp->prevlsn);
@ -289,7 +291,7 @@ ppage: if (argp->prev_pgno != PGNO_INVALID) {
/* Now check the next page. Can only be set on a delete. */ /* Now check the next page. Can only be set on a delete. */
npage: if (argp->next_pgno != PGNO_INVALID) { npage: if (argp->next_pgno != PGNO_INVALID) {
change = 0; change = 0;
if ((ret = memp_fget(mpf, &argp->next_pgno, 0, &pagep)) != 0) if ((ret = memp_fget(mpf, &argp->next_pgno, 0, &pagep)) != 0) {
if (!redo) { if (!redo) {
/* /*
* We are undoing and the page doesn't exist. * We are undoing and the page doesn't exist.
@ -304,6 +306,7 @@ npage: if (argp->next_pgno != PGNO_INVALID) {
if ((ret = memp_fget(mpf, &argp->next_pgno, if ((ret = memp_fget(mpf, &argp->next_pgno,
DB_MPOOL_CREATE, &pagep)) != 0) DB_MPOOL_CREATE, &pagep)) != 0)
goto out; goto out;
}
cmp_n = log_compare(lsnp, &LSN(pagep)); cmp_n = log_compare(lsnp, &LSN(pagep));
cmp_p = log_compare(&LSN(pagep), &argp->nextlsn); cmp_p = log_compare(&LSN(pagep), &argp->nextlsn);
@ -530,7 +533,7 @@ __db_addpage_recover(logp, dbtp, lsnp, redo, info)
if ((ret = memp_fput(mpf, pagep, change)) != 0) if ((ret = memp_fput(mpf, pagep, change)) != 0)
goto out; goto out;
if ((ret = memp_fget(mpf, &argp->nextpgno, 0, &pagep)) != 0) if ((ret = memp_fget(mpf, &argp->nextpgno, 0, &pagep)) != 0) {
if (!redo) { if (!redo) {
/* /*
* We are undoing and the page doesn't exist. That * We are undoing and the page doesn't exist. That
@ -544,6 +547,7 @@ __db_addpage_recover(logp, dbtp, lsnp, redo, info)
if ((ret = memp_fget(mpf, if ((ret = memp_fget(mpf,
&argp->nextpgno, DB_MPOOL_CREATE, &pagep)) != 0) &argp->nextpgno, DB_MPOOL_CREATE, &pagep)) != 0)
goto out; goto out;
}
change = 0; change = 0;
cmp_n = log_compare(lsnp, &LSN(pagep)); cmp_n = log_compare(lsnp, &LSN(pagep));

View File

@ -359,11 +359,12 @@ __ham_get(dbp, txn, key, data, flags)
hashp->hash_accesses++; hashp->hash_accesses++;
hcp = (HASH_CURSOR *)TAILQ_FIRST(&ldbp->curs_queue)->internal; hcp = (HASH_CURSOR *)TAILQ_FIRST(&ldbp->curs_queue)->internal;
if ((ret = __ham_lookup(hashp, hcp, key, 0, DB_LOCK_READ)) == 0) if ((ret = __ham_lookup(hashp, hcp, key, 0, DB_LOCK_READ)) == 0) {
if (F_ISSET(hcp, H_OK)) if (F_ISSET(hcp, H_OK))
ret = __ham_dup_return(hashp, hcp, data, DB_FIRST); ret = __ham_dup_return(hashp, hcp, data, DB_FIRST);
else /* Key was not found */ else /* Key was not found */
ret = DB_NOTFOUND; ret = DB_NOTFOUND;
}
if ((t_ret = __ham_item_done(hashp, hcp, 0)) != 0 && ret == 0) if ((t_ret = __ham_item_done(hashp, hcp, 0)) != 0 && ret == 0)
ret = t_ret; ret = t_ret;
@ -546,11 +547,12 @@ __ham_delete(dbp, txn, key, flags)
hcp = TAILQ_FIRST(&ldbp->curs_queue)->internal; hcp = TAILQ_FIRST(&ldbp->curs_queue)->internal;
hashp->hash_accesses++; hashp->hash_accesses++;
if ((ret = __ham_lookup(hashp, hcp, key, 0, DB_LOCK_WRITE)) == 0) if ((ret = __ham_lookup(hashp, hcp, key, 0, DB_LOCK_WRITE)) == 0) {
if (F_ISSET(hcp, H_OK)) if (F_ISSET(hcp, H_OK))
ret = __ham_del_pair(hashp, hcp, 1); ret = __ham_del_pair(hashp, hcp, 1);
else else
ret = DB_NOTFOUND; ret = DB_NOTFOUND;
}
if ((t_ret = __ham_item_done(hashp, hcp, ret == 0)) != 0 && ret == 0) if ((t_ret = __ham_item_done(hashp, hcp, ret == 0)) != 0 && ret == 0)
ret = t_ret; ret = t_ret;
@ -1109,7 +1111,7 @@ __ham_dup_return(hashp, hcp, val, flags)
* duplicate. In this case, we do initialization and then * duplicate. In this case, we do initialization and then
* let the normal duplicate code handle it. * let the normal duplicate code handle it.
*/ */
if (!F_ISSET(hcp, H_ISDUP)) if (!F_ISSET(hcp, H_ISDUP)) {
if (type == H_DUPLICATE) { if (type == H_DUPLICATE) {
F_SET(hcp, H_ISDUP); F_SET(hcp, H_ISDUP);
hcp->dup_tlen = LEN_HDATA(hcp->pagep, hcp->dup_tlen = LEN_HDATA(hcp->pagep,
@ -1148,13 +1150,13 @@ __ham_dup_return(hashp, hcp, val, flags)
hcp, pgno, 0, H_ISDUP)) != 0) hcp, pgno, 0, H_ISDUP)) != 0)
return (ret); return (ret);
} }
}
/* /*
* Now, everything is initialized, grab a duplicate if * Now, everything is initialized, grab a duplicate if
* necessary. * necessary.
*/ */
if (F_ISSET(hcp, H_ISDUP)) if (F_ISSET(hcp, H_ISDUP)) {
if (hcp->dpgno != PGNO_INVALID) { if (hcp->dpgno != PGNO_INVALID) {
pp = hcp->dpagep; pp = hcp->dpagep;
ndx = hcp->dndx; ndx = hcp->dndx;
@ -1170,7 +1172,7 @@ __ham_dup_return(hashp, hcp, val, flags)
tmp_val.doff = hcp->dup_off + sizeof(db_indx_t); tmp_val.doff = hcp->dup_off + sizeof(db_indx_t);
myval = &tmp_val; myval = &tmp_val;
} }
}
/* /*
* Finally, if we had a duplicate, pp, ndx, and myval should be * Finally, if we had a duplicate, pp, ndx, and myval should be
@ -1425,7 +1427,7 @@ __ham_c_update(hcp, chg_pgno, len, add, is_dup)
F_SET(lcp, H_DELETED); F_SET(lcp, H_DELETED);
/* Now adjust on-page information. */ /* Now adjust on-page information. */
if (lcp->dpgno == PGNO_INVALID) if (lcp->dpgno == PGNO_INVALID) {
if (add) { if (add) {
lcp->dup_tlen += len; lcp->dup_tlen += len;
if (lcp->dndx > hcp->dndx) if (lcp->dndx > hcp->dndx)
@ -1435,6 +1437,7 @@ __ham_c_update(hcp, chg_pgno, len, add, is_dup)
if (lcp->dndx > hcp->dndx) if (lcp->dndx > hcp->dndx)
lcp->dup_off -= len; lcp->dup_off -= len;
} }
}
} }
} }
DB_THREAD_UNLOCK(hp->dbp); DB_THREAD_UNLOCK(hp->dbp);

View File

@ -317,7 +317,7 @@ __ham_item_prev(hashp, cursorp, mode)
if (F_ISSET(cursorp, H_ISDUP)) { if (F_ISSET(cursorp, H_ISDUP)) {
if (cursorp->dpgno == PGNO_INVALID) { if (cursorp->dpgno == PGNO_INVALID) {
/* Duplicates are on-page. */ /* Duplicates are on-page. */
if (cursorp->dup_off != 0) if (cursorp->dup_off != 0) {
if ((ret = __ham_get_cpage(hashp, if ((ret = __ham_get_cpage(hashp,
cursorp, mode)) != 0) cursorp, mode)) != 0)
return (ret); return (ret);
@ -334,6 +334,7 @@ __ham_item_prev(hashp, cursorp, mode)
return (__ham_item(hashp, return (__ham_item(hashp,
cursorp, mode)); cursorp, mode));
} }
}
} else if (cursorp->dndx > 0) { /* Duplicates are off-page. */ } else if (cursorp->dndx > 0) { /* Duplicates are off-page. */
cursorp->dndx--; cursorp->dndx--;
return (__ham_item(hashp, cursorp, mode)); return (__ham_item(hashp, cursorp, mode));

View File

@ -93,7 +93,7 @@ __ham_insdel_recover(logp, dbtp, lsnp, redo, info)
REC_INTRO(__ham_insdel_read); REC_INTRO(__ham_insdel_read);
ret = memp_fget(mpf, &argp->pgno, 0, &pagep); ret = memp_fget(mpf, &argp->pgno, 0, &pagep);
if (ret != 0) if (ret != 0) {
if (!redo) { if (!redo) {
/* /*
* We are undoing and the page doesn't exist. That * We are undoing and the page doesn't exist. That
@ -107,7 +107,7 @@ __ham_insdel_recover(logp, dbtp, lsnp, redo, info)
} else if ((ret = memp_fget(mpf, &argp->pgno, } else if ((ret = memp_fget(mpf, &argp->pgno,
DB_MPOOL_CREATE, &pagep)) != 0) DB_MPOOL_CREATE, &pagep)) != 0)
goto out; goto out;
}
hashp = (HTAB *)file_dbp->internal; hashp = (HTAB *)file_dbp->internal;
GET_META(file_dbp, hashp); GET_META(file_dbp, hashp);
@ -199,7 +199,7 @@ __ham_newpage_recover(logp, dbtp, lsnp, redo, info)
REC_INTRO(__ham_newpage_read); REC_INTRO(__ham_newpage_read);
ret = memp_fget(mpf, &argp->new_pgno, 0, &pagep); ret = memp_fget(mpf, &argp->new_pgno, 0, &pagep);
if (ret != 0) if (ret != 0) {
if (!redo) { if (!redo) {
/* /*
* We are undoing and the page doesn't exist. That * We are undoing and the page doesn't exist. That
@ -212,6 +212,7 @@ __ham_newpage_recover(logp, dbtp, lsnp, redo, info)
} else if ((ret = memp_fget(mpf, &argp->new_pgno, } else if ((ret = memp_fget(mpf, &argp->new_pgno,
DB_MPOOL_CREATE, &pagep)) != 0) DB_MPOOL_CREATE, &pagep)) != 0)
goto out; goto out;
}
hashp = (HTAB *)file_dbp->internal; hashp = (HTAB *)file_dbp->internal;
GET_META(file_dbp, hashp); GET_META(file_dbp, hashp);
@ -255,7 +256,7 @@ __ham_newpage_recover(logp, dbtp, lsnp, redo, info)
ppage: if (argp->prev_pgno != PGNO_INVALID) { ppage: if (argp->prev_pgno != PGNO_INVALID) {
ret = memp_fget(mpf, &argp->prev_pgno, 0, &pagep); ret = memp_fget(mpf, &argp->prev_pgno, 0, &pagep);
if (ret != 0) if (ret != 0) {
if (!redo) { if (!redo) {
/* /*
* We are undoing and the page doesn't exist. * We are undoing and the page doesn't exist.
@ -269,6 +270,7 @@ ppage: if (argp->prev_pgno != PGNO_INVALID) {
memp_fget(mpf, &argp->prev_pgno, memp_fget(mpf, &argp->prev_pgno,
DB_MPOOL_CREATE, &pagep)) != 0) DB_MPOOL_CREATE, &pagep)) != 0)
goto out; goto out;
}
cmp_n = log_compare(lsnp, &LSN(pagep)); cmp_n = log_compare(lsnp, &LSN(pagep));
cmp_p = log_compare(&LSN(pagep), &argp->prevlsn); cmp_p = log_compare(&LSN(pagep), &argp->prevlsn);
@ -300,7 +302,7 @@ ppage: if (argp->prev_pgno != PGNO_INVALID) {
npage: if (argp->next_pgno != PGNO_INVALID) { npage: if (argp->next_pgno != PGNO_INVALID) {
ret = memp_fget(mpf, &argp->next_pgno, 0, &pagep); ret = memp_fget(mpf, &argp->next_pgno, 0, &pagep);
if (ret != 0) if (ret != 0) {
if (!redo) { if (!redo) {
/* /*
* We are undoing and the page doesn't exist. * We are undoing and the page doesn't exist.
@ -315,6 +317,7 @@ npage: if (argp->next_pgno != PGNO_INVALID) {
memp_fget(mpf, &argp->next_pgno, memp_fget(mpf, &argp->next_pgno,
DB_MPOOL_CREATE, &pagep)) != 0) DB_MPOOL_CREATE, &pagep)) != 0)
goto out; goto out;
}
cmp_n = log_compare(lsnp, &LSN(pagep)); cmp_n = log_compare(lsnp, &LSN(pagep));
cmp_p = log_compare(&LSN(pagep), &argp->nextlsn); cmp_p = log_compare(&LSN(pagep), &argp->nextlsn);
@ -384,7 +387,7 @@ __ham_replace_recover(logp, dbtp, lsnp, redo, info)
REC_INTRO(__ham_replace_read); REC_INTRO(__ham_replace_read);
ret = memp_fget(mpf, &argp->pgno, 0, &pagep); ret = memp_fget(mpf, &argp->pgno, 0, &pagep);
if (ret != 0) if (ret != 0) {
if (!redo) { if (!redo) {
/* /*
* We are undoing and the page doesn't exist. That * We are undoing and the page doesn't exist. That
@ -398,6 +401,7 @@ __ham_replace_recover(logp, dbtp, lsnp, redo, info)
} else if ((ret = memp_fget(mpf, &argp->pgno, } else if ((ret = memp_fget(mpf, &argp->pgno,
DB_MPOOL_CREATE, &pagep)) != 0) DB_MPOOL_CREATE, &pagep)) != 0)
goto out; goto out;
}
hashp = (HTAB *)file_dbp->internal; hashp = (HTAB *)file_dbp->internal;
GET_META(file_dbp, hashp); GET_META(file_dbp, hashp);
@ -518,7 +522,7 @@ __ham_newpgno_recover(logp, dbtp, lsnp, redo, info)
/* Now check the newly allocated/freed page. */ /* Now check the newly allocated/freed page. */
ret = memp_fget(mpf, &argp->pgno, 0, &pagep); ret = memp_fget(mpf, &argp->pgno, 0, &pagep);
if (ret != 0) if (ret != 0) {
if (!redo) { if (!redo) {
/* /*
* We are undoing and the page doesn't exist. That * We are undoing and the page doesn't exist. That
@ -532,6 +536,7 @@ __ham_newpgno_recover(logp, dbtp, lsnp, redo, info)
} else if ((ret = memp_fget(mpf, &argp->pgno, } else if ((ret = memp_fget(mpf, &argp->pgno,
DB_MPOOL_CREATE, &pagep)) != 0) DB_MPOOL_CREATE, &pagep)) != 0)
goto out; goto out;
}
cmp_n = log_compare(lsnp, &LSN(pagep)); cmp_n = log_compare(lsnp, &LSN(pagep));
cmp_p = log_compare(&LSN(pagep), &argp->pagelsn); cmp_p = log_compare(&LSN(pagep), &argp->pagelsn);
@ -672,7 +677,7 @@ __ham_splitdata_recover(logp, dbtp, lsnp, redo, info)
REC_INTRO(__ham_splitdata_read); REC_INTRO(__ham_splitdata_read);
ret = memp_fget(mpf, &argp->pgno, 0, &pagep); ret = memp_fget(mpf, &argp->pgno, 0, &pagep);
if (ret != 0) if (ret != 0) {
if (!redo) { if (!redo) {
/* /*
* We are undoing and the page doesn't exist. That * We are undoing and the page doesn't exist. That
@ -686,6 +691,7 @@ __ham_splitdata_recover(logp, dbtp, lsnp, redo, info)
} else if ((ret = memp_fget(mpf, &argp->pgno, } else if ((ret = memp_fget(mpf, &argp->pgno,
DB_MPOOL_CREATE, &pagep)) != 0) DB_MPOOL_CREATE, &pagep)) != 0)
goto out; goto out;
}
hashp = (HTAB *)file_dbp->internal; hashp = (HTAB *)file_dbp->internal;
GET_META(file_dbp, hashp); GET_META(file_dbp, hashp);
@ -850,7 +856,7 @@ __ham_copypage_recover(logp, dbtp, lsnp, redo, info)
/* This is the bucket page. */ /* This is the bucket page. */
ret = memp_fget(mpf, &argp->pgno, 0, &pagep); ret = memp_fget(mpf, &argp->pgno, 0, &pagep);
if (ret != 0) if (ret != 0) {
if (!redo) { if (!redo) {
/* /*
* We are undoing and the page doesn't exist. That * We are undoing and the page doesn't exist. That
@ -863,6 +869,7 @@ __ham_copypage_recover(logp, dbtp, lsnp, redo, info)
} else if ((ret = memp_fget(mpf, &argp->pgno, } else if ((ret = memp_fget(mpf, &argp->pgno,
DB_MPOOL_CREATE, &pagep)) != 0) DB_MPOOL_CREATE, &pagep)) != 0)
goto out; goto out;
}
cmp_n = log_compare(lsnp, &LSN(pagep)); cmp_n = log_compare(lsnp, &LSN(pagep));
cmp_p = log_compare(&LSN(pagep), &argp->pagelsn); cmp_p = log_compare(&LSN(pagep), &argp->pagelsn);
@ -884,7 +891,7 @@ __ham_copypage_recover(logp, dbtp, lsnp, redo, info)
/* Now fix up the "next" page. */ /* Now fix up the "next" page. */
donext: ret = memp_fget(mpf, &argp->next_pgno, 0, &pagep); donext: ret = memp_fget(mpf, &argp->next_pgno, 0, &pagep);
if (ret != 0) if (ret != 0) {
if (!redo) { if (!redo) {
/* /*
* We are undoing and the page doesn't exist. That * We are undoing and the page doesn't exist. That
@ -897,6 +904,7 @@ donext: ret = memp_fget(mpf, &argp->next_pgno, 0, &pagep);
} else if ((ret = memp_fget(mpf, &argp->next_pgno, } else if ((ret = memp_fget(mpf, &argp->next_pgno,
DB_MPOOL_CREATE, &pagep)) != 0) DB_MPOOL_CREATE, &pagep)) != 0)
goto out; goto out;
}
/* There is nothing to do in the REDO case; only UNDO. */ /* There is nothing to do in the REDO case; only UNDO. */
@ -916,7 +924,7 @@ do_nn: if (argp->nnext_pgno == PGNO_INVALID) {
} }
ret = memp_fget(mpf, &argp->nnext_pgno, 0, &pagep); ret = memp_fget(mpf, &argp->nnext_pgno, 0, &pagep);
if (ret != 0) if (ret != 0) {
if (!redo) { if (!redo) {
/* /*
* We are undoing and the page doesn't exist. That * We are undoing and the page doesn't exist. That
@ -930,6 +938,7 @@ do_nn: if (argp->nnext_pgno == PGNO_INVALID) {
} else if ((ret = memp_fget(mpf, &argp->nnext_pgno, } else if ((ret = memp_fget(mpf, &argp->nnext_pgno,
DB_MPOOL_CREATE, &pagep)) != 0) DB_MPOOL_CREATE, &pagep)) != 0)
goto out; goto out;
}
cmp_n = log_compare(lsnp, &LSN(pagep)); cmp_n = log_compare(lsnp, &LSN(pagep));
cmp_p = log_compare(&LSN(pagep), &argp->nnextlsn); cmp_p = log_compare(&LSN(pagep), &argp->nnextlsn);

View File

@ -70,11 +70,12 @@ __log_findckp(lp, lsnp)
if (F_ISSET(lp, DB_AM_THREAD)) if (F_ISSET(lp, DB_AM_THREAD))
F_SET(&data, DB_DBT_MALLOC); F_SET(&data, DB_DBT_MALLOC);
ZERO_LSN(ckp_lsn); ZERO_LSN(ckp_lsn);
if ((ret = log_get(lp, &last_ckp, &data, DB_CHECKPOINT)) != 0) if ((ret = log_get(lp, &last_ckp, &data, DB_CHECKPOINT)) != 0) {
if (ret == ENOENT) if (ret == ENOENT)
goto get_first; goto get_first;
else else
return (ret); return (ret);
}
next_lsn = last_ckp; next_lsn = last_ckp;
do { do {

View File

@ -329,12 +329,13 @@ corrupt:/*
ret = EIO; ret = EIO;
fail = "read"; fail = "read";
err1: if (!silent) err1: if (!silent) {
if (fail == NULL) if (fail == NULL)
__db_err(dblp->dbenv, "log_get: %s", strerror(ret)); __db_err(dblp->dbenv, "log_get: %s", strerror(ret));
else else
__db_err(dblp->dbenv, __db_err(dblp->dbenv,
"log_get: %s: %s", fail, strerror(ret)); "log_get: %s: %s", fail, strerror(ret));
}
err2: if (np != NULL) err2: if (np != NULL)
__db_free(np); __db_free(np);
if (tbuf != NULL) if (tbuf != NULL)

View File

@ -333,12 +333,13 @@ __log_flush(dblp, lsn)
* the record before the one beginning the current buffer is on disk. * the record before the one beginning the current buffer is on disk.
*/ */
lp->s_lsn = lp->f_lsn; lp->s_lsn = lp->f_lsn;
if (!current) if (!current) {
if (lp->s_lsn.offset == 0) { if (lp->s_lsn.offset == 0) {
--lp->s_lsn.file; --lp->s_lsn.file;
lp->s_lsn.offset = lp->persist.lg_max; lp->s_lsn.offset = lp->persist.lg_max;
} else } else
--lp->s_lsn.offset; --lp->s_lsn.offset;
}
return (0); return (0);
} }

View File

@ -139,7 +139,7 @@ memp_fget(dbmfp, pgnoaddr, flags, addrp)
* It would be possible to do so by reference counting the open * It would be possible to do so by reference counting the open
* pages from the mmap, but it's unclear to me that it's worth it. * pages from the mmap, but it's unclear to me that it's worth it.
*/ */
if (dbmfp->addr != NULL && F_ISSET(mfp, MP_CAN_MMAP)) if (dbmfp->addr != NULL && F_ISSET(mfp, MP_CAN_MMAP)) {
if (*pgnoaddr > mfp->orig_last_pgno) { if (*pgnoaddr > mfp->orig_last_pgno) {
/* /*
* !!! * !!!
@ -160,6 +160,7 @@ memp_fget(dbmfp, pgnoaddr, flags, addrp)
++mfp->stat.st_map; ++mfp->stat.st_map;
goto done; goto done;
} }
}
/* Search the hash chain for the page. */ /* Search the hash chain for the page. */
for (bhp = SH_TAILQ_FIRST(&dbmp->htab[bucket], __bh); for (bhp = SH_TAILQ_FIRST(&dbmp->htab[bucket], __bh);

View File

@ -125,7 +125,7 @@ memp_fput(dbmfp, pgaddr, flags)
* next time the memp_sync function runs we try writing it there, as * next time the memp_sync function runs we try writing it there, as
* the checkpoint application better be able to write all of the files. * the checkpoint application better be able to write all of the files.
*/ */
if (F_ISSET(bhp, BH_WRITE)) if (F_ISSET(bhp, BH_WRITE)) {
if (F_ISSET(bhp, BH_DIRTY)) { if (F_ISSET(bhp, BH_DIRTY)) {
if (__memp_bhwrite(dbmp, if (__memp_bhwrite(dbmp,
dbmfp->mfp, bhp, NULL, &wrote) != 0 || !wrote) dbmfp->mfp, bhp, NULL, &wrote) != 0 || !wrote)
@ -136,6 +136,7 @@ memp_fput(dbmfp, pgaddr, flags)
--dbmfp->mfp->lsn_cnt; --dbmfp->mfp->lsn_cnt;
--mp->lsn_cnt; --mp->lsn_cnt;
} }
}
/* Move the buffer to the head/tail of the LRU chain. */ /* Move the buffer to the head/tail of the LRU chain. */
SH_TAILQ_REMOVE(&mp->bhq, bhp, q, __bh); SH_TAILQ_REMOVE(&mp->bhq, bhp, q, __bh);

View File

@ -202,12 +202,13 @@ __memp_ropen(dbmp, path, cachesize, mode, is_private, flags)
* Up the user's cachesize by 25% to account for our overhead. * Up the user's cachesize by 25% to account for our overhead.
*/ */
defcache = 0; defcache = 0;
if (cachesize < DB_CACHESIZE_MIN) if (cachesize < DB_CACHESIZE_MIN) {
if (cachesize == 0) { if (cachesize == 0) {
defcache = 1; defcache = 1;
cachesize = DB_CACHESIZE_DEF; cachesize = DB_CACHESIZE_DEF;
} else } else
cachesize = DB_CACHESIZE_MIN; cachesize = DB_CACHESIZE_MIN;
}
rlen = cachesize + cachesize / 4; rlen = cachesize + cachesize / 4;
/* /*