00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include "db_config.h"
00011
00012 #ifndef NO_SYSTEM_INCLUDES
00013 #include <sys/types.h>
00014 #endif
00015
00016 #include "db_int.h"
00017 #include "dbinc/db_page.h"
00018 #include "dbinc/db_shash.h"
00019 #include "dbinc/hash.h"
00020 #include "dbinc/lock.h"
00021 #include "dbinc/mp.h"
00022
00023
00024
00025
00026
00027
00028 int
00029 __ham_get_meta(dbc)
00030 DBC *dbc;
00031 {
00032 DB *dbp;
00033 DB_MPOOLFILE *mpf;
00034 HASH *hashp;
00035 HASH_CURSOR *hcp;
00036 int ret;
00037
00038 dbp = dbc->dbp;
00039 mpf = dbp->mpf;
00040 hashp = dbp->h_internal;
00041 hcp = (HASH_CURSOR *)dbc->internal;
00042
00043 if ((ret = __db_lget(dbc, 0,
00044 hashp->meta_pgno, DB_LOCK_READ, 0, &hcp->hlock)) != 0)
00045 return (ret);
00046
00047 if ((ret = __memp_fget(mpf,
00048 &hashp->meta_pgno, DB_MPOOL_CREATE, &(hcp->hdr))) != 0)
00049 (void)__LPUT(dbc, hcp->hlock);
00050
00051 return (ret);
00052 }
00053
00054
00055
00056
00057
00058
00059 int
00060 __ham_release_meta(dbc)
00061 DBC *dbc;
00062 {
00063 DB_MPOOLFILE *mpf;
00064 HASH_CURSOR *hcp;
00065
00066 mpf = dbc->dbp->mpf;
00067 hcp = (HASH_CURSOR *)dbc->internal;
00068
00069 if (hcp->hdr)
00070 (void)__memp_fput(mpf, hcp->hdr,
00071 F_ISSET(hcp, H_DIRTY) ? DB_MPOOL_DIRTY : 0);
00072 hcp->hdr = NULL;
00073 F_CLR(hcp, H_DIRTY);
00074
00075 return (__TLPUT(dbc, hcp->hlock));
00076 }
00077
00078
00079
00080
00081
00082
00083 int
00084 __ham_dirty_meta(dbc)
00085 DBC *dbc;
00086 {
00087 DB *dbp;
00088 HASH *hashp;
00089 HASH_CURSOR *hcp;
00090 int ret;
00091
00092 dbp = dbc->dbp;
00093 hashp = dbp->h_internal;
00094 hcp = (HASH_CURSOR *)dbc->internal;
00095
00096 ret = 0;
00097
00098 ret = __db_lget(dbc, LCK_COUPLE,
00099 hashp->meta_pgno, DB_LOCK_WRITE, 0, &hcp->hlock);
00100
00101 if (ret == 0)
00102 F_SET(hcp, H_DIRTY);
00103 return (ret);
00104 }