/*
- $Id: cmd_dbd.c,v 1.20 2009-12-20 14:17:23 franklahm Exp $
+ $Id: cmd_dbd.c,v 1.21 2009-12-21 06:41:09 franklahm Exp $
Copyright (c) 2009 Frank Lahm <franklahm@gmail.com>
if (exclusive)
dbd_log( LOGDEBUG, "Finished recovery.");
- if (dbif_open(dbd, &db_param, rebuildindexes) < 0) {
+ if (dbif_open(dbd, NULL, rebuildindexes) < 0) {
dbif_close(dbd);
goto exit_failure;
}
/*
- $Id: cmd_dbd_scanvol.c,v 1.14 2009-12-10 17:40:25 franklahm Exp $
+ $Id: cmd_dbd_scanvol.c,v 1.15 2009-12-21 06:41:09 franklahm Exp $
Copyright (c) 2009 Frank Lahm <franklahm@gmail.com>
int cmd_dbd_scanvol(DBD *dbd_ref, struct volinfo *volinfo, dbd_flags_t flags)
{
int ret = 0;
+ struct db_param db_param = { 0 };
+
+ /* Set cachesize for in-memory rebuild db */
+ db_param.cachesize = 128 * 1024 * 1024; /* 128 MB */
/* Make it accessible for all funcs */
dbd = dbd_ref;
/* open/create rebuild dbd, copy rootinfo key */
if (NULL == (dbd_rebuild = dbif_init(NULL, NULL)))
return -1;
- if (0 != (dbif_open(dbd_rebuild, NULL, 0)))
+ if (0 != (dbif_open(dbd_rebuild, &db_param, 0)))
return -1;
if (0 != (dbif_copy_rootinfokey(dbd, dbd_rebuild)))
goto exit_cleanup;
/*
- * $Id: dbif.c,v 1.18 2009-12-20 16:04:21 franklahm Exp $
+ * $Id: dbif.c,v 1.19 2009-12-21 06:41:09 franklahm Exp $
*
* Copyright (C) Joerg Lenneis 2003
* Copyright (C) Frank Lahm 2009
}
/* --------------- */
-int dbif_open(DBD *dbd, struct db_param *dbp _U_, int reindex)
+int dbif_open(DBD *dbd, struct db_param *dbp, int reindex)
{
int ret, i, cwd;
u_int32_t count;
}
}
+ if ( ! dbd->db_env) { /* In memory db */
+ if ((ret = dbd->db_table[i].db->set_cachesize(dbd->db_table[i].db,
+ 0,
+ dbp->cachesize,
+ 4)) /* split in 4 memory chunks */
+ < 0) {
+ LOG(log_error, logtype_cnid, "error setting cachesize %u KB for database %s: %s",
+ dbp->cachesize / 1024, dbd->db_table[i].name, db_strerror(ret));
+ return -1;
+ }
+ }
+
if (dbd->db_table[i].db->open(dbd->db_table[i].db,
dbd->db_txn,
dbd->db_filename,
/*
- $Id: dbif.h,v 1.8 2009-09-03 08:35:15 franklahm Exp $
+ $Id: dbif.h,v 1.9 2009-12-21 06:41:09 franklahm Exp $
Copyright (C) Joerg Lenneis 2003
Copyright (C) Frank Lahm 2009
Pass NULL to create an in-memory db.
Note: the DBD type is NOT from BerkeleyDB ! We've defined it.
3. Call dbif_env_open to open an dbd environment if you called dbif_init
- with a filename.
- 4. Call dbif_open to finally open the CNID database itself
+ with a filename. Pass a db_param here for on-disk databases.
+ 4. Call dbif_open to finally open the CNID database itself. Pass db_param
+ here for in-memory database.
Querying the CNID database
--------------------------