Main Page | Class Hierarchy | Data Structures | Directories | File List | Data Fields | Related Pages

hash_meta.c

00001 /*-
00002  * See the file LICENSE for redistribution information.
00003  *
00004  * Copyright (c) 1999-2005
00005  *      Sleepycat Software.  All rights reserved.
00006  *
00007  * $Id: hash_meta.c,v 12.1 2005/06/16 20:22:52 bostic Exp $
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  * Acquire the meta-data page.
00025  *
00026  * PUBLIC: int __ham_get_meta __P((DBC *));
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  * Release the meta-data page.
00056  *
00057  * PUBLIC: int __ham_release_meta __P((DBC *));
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  * Mark the meta-data page dirty.
00080  *
00081  * PUBLIC: int __ham_dirty_meta __P((DBC *));
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 }

Generated on Sun Dec 25 12:14:29 2005 for Berkeley DB 4.4.16 by  doxygen 1.4.2