summaryrefslogtreecommitdiff
path: root/db/mp/mp_fmethod.c
diff options
context:
space:
mode:
Diffstat (limited to 'db/mp/mp_fmethod.c')
-rw-r--r--db/mp/mp_fmethod.c144
1 files changed, 46 insertions, 98 deletions
diff --git a/db/mp/mp_fmethod.c b/db/mp/mp_fmethod.c
index e27800c0d..76d160ee5 100644
--- a/db/mp/mp_fmethod.c
+++ b/db/mp/mp_fmethod.c
@@ -1,37 +1,18 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 1996-2004
- * Sleepycat Software. All rights reserved.
+ * Copyright (c) 1996-2006
+ * Oracle Corporation. All rights reserved.
*
- * $Id: mp_fmethod.c,v 11.142 2004/10/15 16:59:42 bostic Exp $
+ * $Id: mp_fmethod.c,v 12.13 2006/08/24 14:46:14 bostic Exp $
*/
#include "db_config.h"
-#ifndef NO_SYSTEM_INCLUDES
-#include <sys/types.h>
-
-#ifdef HAVE_RPC
-#include <rpc/rpc.h>
-#endif
-
-#include <string.h>
-#endif
-
-#ifdef HAVE_RPC
-#include "db_server.h"
-#endif
-
#include "db_int.h"
-#include "dbinc/db_shash.h"
#include "dbinc/log.h"
#include "dbinc/mp.h"
-#ifdef HAVE_RPC
-#include "dbinc_auto/rpc_client_ext.h"
-#endif
-
static int __memp_get_clear_len __P((DB_MPOOLFILE *, u_int32_t *));
static int __memp_get_lsn_offset __P((DB_MPOOLFILE *, int32_t *));
static int __memp_get_maxsize __P((DB_MPOOLFILE *, u_int32_t *, u_int32_t *));
@@ -52,7 +33,8 @@ __memp_fcreate_pp(dbenv, retp, flags)
DB_MPOOLFILE **retp;
u_int32_t flags;
{
- int rep_check, ret;
+ DB_THREAD_INFO *ip;
+ int ret;
PANIC_CHECK(dbenv);
@@ -60,12 +42,9 @@ __memp_fcreate_pp(dbenv, retp, flags)
if ((ret = __db_fchk(dbenv, "DB_ENV->memp_fcreate", flags, 0)) != 0)
return (ret);
- rep_check = IS_ENV_REPLICATED(dbenv) ? 1 : 0;
- if (rep_check)
- __env_rep_enter(dbenv);
- ret = __memp_fcreate(dbenv, retp);
- if (rep_check)
- __env_db_rep_exit(dbenv);
+ ENV_ENTER(dbenv, ip);
+ REPLICATION_WRAP(dbenv, (__memp_fcreate(dbenv, retp)), ret);
+ ENV_LEAVE(dbenv, ip);
return (ret);
}
@@ -92,57 +71,28 @@ __memp_fcreate(dbenv, retp)
dbmfp->dbenv = dbenv;
dbmfp->mfp = INVALID_ROFF;
-#ifdef HAVE_RPC
- if (F_ISSET(dbenv, DB_ENV_RPCCLIENT)) {
- dbmfp->get_clear_len = __dbcl_memp_get_clear_len;
- dbmfp->set_clear_len = __dbcl_memp_set_clear_len;
- dbmfp->get_fileid = __dbcl_memp_get_fileid;
- dbmfp->set_fileid = __dbcl_memp_set_fileid;
- dbmfp->get_flags = __dbcl_memp_get_flags;
- dbmfp->set_flags = __dbcl_memp_set_flags;
- dbmfp->get_ftype = __dbcl_memp_get_ftype;
- dbmfp->set_ftype = __dbcl_memp_set_ftype;
- dbmfp->get_lsn_offset = __dbcl_memp_get_lsn_offset;
- dbmfp->set_lsn_offset = __dbcl_memp_set_lsn_offset;
- dbmfp->get_maxsize = __dbcl_memp_get_maxsize;
- dbmfp->set_maxsize = __dbcl_memp_set_maxsize;
- dbmfp->get_pgcookie = __dbcl_memp_get_pgcookie;
- dbmfp->set_pgcookie = __dbcl_memp_set_pgcookie;
- dbmfp->get_priority = __dbcl_memp_get_priority;
- dbmfp->set_priority = __dbcl_memp_set_priority;
-
- dbmfp->get = __dbcl_memp_fget;
- dbmfp->open = __dbcl_memp_fopen;
- dbmfp->put = __dbcl_memp_fput;
- dbmfp->set = __dbcl_memp_fset;
- dbmfp->sync = __dbcl_memp_fsync;
- } else
-#endif
- {
- dbmfp->get_clear_len = __memp_get_clear_len;
- dbmfp->set_clear_len = __memp_set_clear_len;
- dbmfp->get_fileid = __memp_get_fileid;
- dbmfp->set_fileid = __memp_set_fileid;
- dbmfp->get_flags = __memp_get_flags;
- dbmfp->set_flags = __memp_set_flags;
- dbmfp->get_ftype = __memp_get_ftype;
- dbmfp->set_ftype = __memp_set_ftype;
- dbmfp->get_lsn_offset = __memp_get_lsn_offset;
- dbmfp->set_lsn_offset = __memp_set_lsn_offset;
- dbmfp->get_maxsize = __memp_get_maxsize;
- dbmfp->set_maxsize = __memp_set_maxsize;
- dbmfp->get_pgcookie = __memp_get_pgcookie;
- dbmfp->set_pgcookie = __memp_set_pgcookie;
- dbmfp->get_priority = __memp_get_priority;
- dbmfp->set_priority = __memp_set_priority;
-
- dbmfp->get = __memp_fget_pp;
- dbmfp->open = __memp_fopen_pp;
- dbmfp->put = __memp_fput_pp;
- dbmfp->set = __memp_fset_pp;
- dbmfp->sync = __memp_fsync_pp;
- }
dbmfp->close = __memp_fclose_pp;
+ dbmfp->get = __memp_fget_pp;
+ dbmfp->get_clear_len = __memp_get_clear_len;
+ dbmfp->get_fileid = __memp_get_fileid;
+ dbmfp->get_flags = __memp_get_flags;
+ dbmfp->get_ftype = __memp_get_ftype;
+ dbmfp->get_lsn_offset = __memp_get_lsn_offset;
+ dbmfp->get_maxsize = __memp_get_maxsize;
+ dbmfp->get_pgcookie = __memp_get_pgcookie;
+ dbmfp->get_priority = __memp_get_priority;
+ dbmfp->open = __memp_fopen_pp;
+ dbmfp->put = __memp_fput_pp;
+ dbmfp->set = __memp_fset_pp;
+ dbmfp->set_clear_len = __memp_set_clear_len;
+ dbmfp->set_fileid = __memp_set_fileid;
+ dbmfp->set_flags = __memp_set_flags;
+ dbmfp->set_ftype = __memp_set_ftype;
+ dbmfp->set_lsn_offset = __memp_set_lsn_offset;
+ dbmfp->set_maxsize = __memp_set_maxsize;
+ dbmfp->set_pgcookie = __memp_set_pgcookie;
+ dbmfp->set_priority = __memp_set_priority;
+ dbmfp->sync = __memp_fsync_pp;
*retp = dbmfp;
return (0);
@@ -190,7 +140,7 @@ __memp_get_fileid(dbmfp, fileid)
u_int8_t *fileid;
{
if (!F_ISSET(dbmfp, MP_FILEID_SET)) {
- __db_err(dbmfp->dbenv, "get_fileid: file ID not set");
+ __db_errx(dbmfp->dbenv, "get_fileid: file ID not set");
return (EINVAL);
}
@@ -365,7 +315,6 @@ __memp_get_maxsize(dbmfp, gbytesp, bytesp)
u_int32_t *gbytesp, *bytesp;
{
DB_ENV *dbenv;
- DB_MPOOL *dbmp;
MPOOLFILE *mfp;
if ((mfp = dbmfp->mfp) == NULL) {
@@ -373,15 +322,14 @@ __memp_get_maxsize(dbmfp, gbytesp, bytesp)
*bytesp = dbmfp->bytes;
} else {
dbenv = dbmfp->dbenv;
- dbmp = dbenv->mp_handle;
- R_LOCK(dbenv, dbmp->reginfo);
+ MUTEX_LOCK(dbenv, mfp->mutex);
*gbytesp = (u_int32_t)
(mfp->maxpgno / (GIGABYTE / mfp->stat.st_pagesize));
*bytesp = (u_int32_t)
((mfp->maxpgno % (GIGABYTE / mfp->stat.st_pagesize)) *
mfp->stat.st_pagesize);
- R_UNLOCK(dbenv, dbmp->reginfo);
+ MUTEX_UNLOCK(dbenv, mfp->mutex);
}
return (0);
@@ -397,7 +345,6 @@ __memp_set_maxsize(dbmfp, gbytes, bytes)
u_int32_t gbytes, bytes;
{
DB_ENV *dbenv;
- DB_MPOOL *dbmp;
MPOOLFILE *mfp;
if ((mfp = dbmfp->mfp) == NULL) {
@@ -405,15 +352,14 @@ __memp_set_maxsize(dbmfp, gbytes, bytes)
dbmfp->bytes = bytes;
} else {
dbenv = dbmfp->dbenv;
- dbmp = dbenv->mp_handle;
- R_LOCK(dbenv, dbmp->reginfo);
+ MUTEX_LOCK(dbenv, mfp->mutex);
mfp->maxpgno = (db_pgno_t)
(gbytes * (GIGABYTE / mfp->stat.st_pagesize));
mfp->maxpgno += (db_pgno_t)
((bytes + mfp->stat.st_pagesize - 1) /
mfp->stat.st_pagesize);
- R_UNLOCK(dbenv, dbmp->reginfo);
+ MPOOL_SYSTEM_UNLOCK(dbenv);
}
return (0);
@@ -494,7 +440,7 @@ __memp_get_priority(dbmfp, priorityp)
*priorityp = DB_PRIORITY_VERY_HIGH;
break;
default:
- __db_err(dbmfp->dbenv,
+ __db_errx(dbmfp->dbenv,
"DB_MPOOLFILE->get_priority: unknown priority value: %d",
dbmfp->priority);
return (EINVAL);
@@ -529,7 +475,7 @@ __memp_set_priority(dbmfp, priority)
dbmfp->priority = MPOOL_PRI_VERY_HIGH;
break;
default:
- __db_err(dbmfp->dbenv,
+ __db_errx(dbmfp->dbenv,
"DB_MPOOLFILE->set_priority: unknown priority value: %d",
priority);
return (EINVAL);
@@ -537,7 +483,7 @@ __memp_set_priority(dbmfp, priority)
/* Update the underlying file if we've already opened it. */
if (dbmfp->mfp != NULL)
- dbmfp->mfp->priority = priority;
+ dbmfp->mfp->priority = dbmfp->priority;
return (0);
}
@@ -549,22 +495,24 @@ __memp_set_priority(dbmfp, priority)
* !!!
* Undocumented interface: DB private.
*
- * PUBLIC: void __memp_last_pgno __P((DB_MPOOLFILE *, db_pgno_t *));
+ * PUBLIC: int __memp_last_pgno __P((DB_MPOOLFILE *, db_pgno_t *));
*/
-void
+int
__memp_last_pgno(dbmfp, pgnoaddr)
DB_MPOOLFILE *dbmfp;
db_pgno_t *pgnoaddr;
{
DB_ENV *dbenv;
- DB_MPOOL *dbmp;
+ MPOOLFILE *mfp;
dbenv = dbmfp->dbenv;
- dbmp = dbenv->mp_handle;
+ mfp = dbmfp->mfp;
- R_LOCK(dbenv, dbmp->reginfo);
- *pgnoaddr = dbmfp->mfp->last_pgno;
- R_UNLOCK(dbenv, dbmp->reginfo);
+ MUTEX_LOCK(dbenv, mfp->mutex);
+ *pgnoaddr = mfp->last_pgno;
+ MUTEX_UNLOCK(dbenv, mfp->mutex);
+
+ return (0);
}
/*