100 lines
1.8 KiB
C
100 lines
1.8 KiB
C
/*-
|
|
* See the file LICENSE for redistribution information.
|
|
*
|
|
* Copyright (c) 1999,2008 Oracle. All rights reserved.
|
|
*
|
|
* $Id: hash_meta.c 63573 2008-05-23 21:43:21Z trent.nelson $
|
|
*/
|
|
|
|
#include "db_config.h"
|
|
|
|
#include "db_int.h"
|
|
#include "dbinc/db_page.h"
|
|
#include "dbinc/hash.h"
|
|
#include "dbinc/lock.h"
|
|
#include "dbinc/mp.h"
|
|
|
|
/*
|
|
* Acquire the meta-data page.
|
|
*
|
|
* PUBLIC: int __ham_get_meta __P((DBC *));
|
|
*/
|
|
int
|
|
__ham_get_meta(dbc)
|
|
DBC *dbc;
|
|
{
|
|
DB *dbp;
|
|
DB_MPOOLFILE *mpf;
|
|
HASH *hashp;
|
|
HASH_CURSOR *hcp;
|
|
int ret;
|
|
|
|
dbp = dbc->dbp;
|
|
mpf = dbp->mpf;
|
|
hashp = dbp->h_internal;
|
|
hcp = (HASH_CURSOR *)dbc->internal;
|
|
|
|
if ((ret = __db_lget(dbc, 0,
|
|
hashp->meta_pgno, DB_LOCK_READ, 0, &hcp->hlock)) != 0)
|
|
return (ret);
|
|
|
|
if ((ret = __memp_fget(mpf, &hashp->meta_pgno,
|
|
dbc->thread_info, dbc->txn, DB_MPOOL_CREATE, &hcp->hdr)) != 0)
|
|
(void)__LPUT(dbc, hcp->hlock);
|
|
|
|
return (ret);
|
|
}
|
|
|
|
/*
|
|
* Release the meta-data page.
|
|
*
|
|
* PUBLIC: int __ham_release_meta __P((DBC *));
|
|
*/
|
|
int
|
|
__ham_release_meta(dbc)
|
|
DBC *dbc;
|
|
{
|
|
DB_MPOOLFILE *mpf;
|
|
HASH_CURSOR *hcp;
|
|
int ret;
|
|
|
|
mpf = dbc->dbp->mpf;
|
|
hcp = (HASH_CURSOR *)dbc->internal;
|
|
|
|
if (hcp->hdr != NULL) {
|
|
if ((ret = __memp_fput(mpf,
|
|
dbc->thread_info, hcp->hdr, dbc->priority)) != 0)
|
|
return (ret);
|
|
hcp->hdr = NULL;
|
|
}
|
|
|
|
return (__TLPUT(dbc, hcp->hlock));
|
|
}
|
|
|
|
/*
|
|
* Mark the meta-data page dirty.
|
|
*
|
|
* PUBLIC: int __ham_dirty_meta __P((DBC *, u_int32_t));
|
|
*/
|
|
int
|
|
__ham_dirty_meta(dbc, flags)
|
|
DBC *dbc;
|
|
u_int32_t flags;
|
|
{
|
|
DB *dbp;
|
|
HASH *hashp;
|
|
HASH_CURSOR *hcp;
|
|
int ret;
|
|
|
|
dbp = dbc->dbp;
|
|
hashp = dbp->h_internal;
|
|
hcp = (HASH_CURSOR *)dbc->internal;
|
|
|
|
if ((ret = __db_lget(dbc, LCK_COUPLE,
|
|
hashp->meta_pgno, DB_LOCK_WRITE, 0, &hcp->hlock)) != 0)
|
|
return (ret);
|
|
|
|
return (__memp_dirty(dbp->mpf,
|
|
&hcp->hdr, dbc->thread_info, dbc->txn, dbc->priority, flags));
|
|
}
|