summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2010-10-20 16:38:46 +0300
committerPanu Matilainen <pmatilai@redhat.com>2010-10-20 16:53:00 +0300
commita916e399ab0734816f1e4567b34db0b55e9f5c7c (patch)
treed9d421d50c586c1d2ffd43f312017bd2887ce602
parentca36c2a12bcde1340da0421a788863f83aaccd08 (diff)
downloadlibrpm-tizen-a916e399ab0734816f1e4567b34db0b55e9f5c7c.tar.gz
librpm-tizen-a916e399ab0734816f1e4567b34db0b55e9f5c7c.tar.bz2
librpm-tizen-a916e399ab0734816f1e4567b34db0b55e9f5c7c.zip
Hardwire the fundamental BDB access method configuration inside rpm
- The different access methods have different capabilities and are not interchangeable in all situations. Currently we can use either hash and btree but this might not be always the case for all indexes. - We'll eventually want to force-switch the index types to our liking, but for now follow these simple rules: 1) For existing databases, we accept both btree and hash 2) For newly created databases, the main Packages database remains a hash, all indexes are btrees. - Rip out nearly all the rest of the remaining macro configuration.
-rw-r--r--lib/backend/db3.c21
-rw-r--r--lib/backend/dbconfig.c13
-rw-r--r--lib/backend/dbi.h1
-rw-r--r--macros.in32
4 files changed, 16 insertions, 51 deletions
diff --git a/lib/backend/db3.c b/lib/backend/db3.c
index ff458b5b3..1b3564c5d 100644
--- a/lib/backend/db3.c
+++ b/lib/backend/db3.c
@@ -513,6 +513,7 @@ int dbiOpen(rpmdb rdb, rpmTag rpmtag, dbiIndex * dbip, int flags)
int verifyonly = (flags & RPMDB_FLAG_VERIFYONLY);
DB * db = NULL;
+ DBTYPE dbtype = DB_UNKNOWN;
uint32_t oflags;
static int _lockdbfd = 0;
@@ -552,28 +553,32 @@ int dbiOpen(rpmdb rdb, rpmTag rpmtag, dbiIndex * dbip, int flags)
free(dbfs);
rc = (db->open)(db, NULL, dbi->dbi_file, NULL,
- dbi->dbi_dbtype, oflags, rdb->db_perms);
+ dbtype, oflags, rdb->db_perms);
/* Attempt to create if missing, discarding DB_RDONLY (!) */
if (rc == ENOENT) {
oflags |= DB_CREATE;
oflags &= ~DB_RDONLY;
+ dbtype = (dbiType(dbi) == DBI_PRIMARY) ? DB_HASH : DB_BTREE;
retry_open--;
} else {
retry_open = 0;
}
- if (rc == 0 && dbi->dbi_dbtype == DB_UNKNOWN) {
- DBTYPE dbi_dbtype = DB_UNKNOWN;
- xx = db->get_type(db, &dbi_dbtype);
- if (xx == 0)
- dbi->dbi_dbtype = dbi_dbtype;
- }
-
/* XXX return rc == errno without printing */
_printit = (rc > 0 ? 0 : _debug);
xx = cvtdberr(dbi, "db->open", rc, _printit);
+ /* Validate the index type is something we can support */
+ if ((rc == 0) && (dbtype == DB_UNKNOWN)) {
+ db->get_type(db, &dbtype);
+ if (dbtype != DB_HASH && dbtype != DB_BTREE) {
+ rpmlog(RPMLOG_ERR, _("invalid index type %x on %s/%s\n"),
+ dbtype, dbhome, dbi->dbi_file);
+ rc = 1;
+ }
+ }
+
if (rc != 0) {
db->close(db, 0);
db = NULL;
diff --git a/lib/backend/dbconfig.c b/lib/backend/dbconfig.c
index ef30581bf..2f336b7ec 100644
--- a/lib/backend/dbconfig.c
+++ b/lib/backend/dbconfig.c
@@ -65,13 +65,6 @@ static const struct poptOption rdbOptions[] = {
{ "nommap", 0,POPT_BIT_SET, &staticdbi.dbi_oflags, DB_NOMMAP,
NULL, NULL },
- { "btree", 0,POPT_ARG_VAL, &staticdbi.dbi_dbtype, DB_BTREE,
- NULL, NULL },
- { "hash", 0,POPT_ARG_VAL, &staticdbi.dbi_dbtype, DB_HASH,
- NULL, NULL },
- { "unknown", 0,POPT_ARG_VAL, &staticdbi.dbi_dbtype, DB_UNKNOWN,
- NULL, NULL },
-
{ "nodbsync", 0,POPT_ARG_NONE, &staticdbi.dbi_no_dbsync, 0,
NULL, NULL },
{ "lockdbfd", 0,POPT_ARG_NONE, &staticdbi.dbi_lockdbfd, 0,
@@ -88,10 +81,6 @@ dbiIndex dbiFree(dbiIndex dbi)
return dbi;
}
-/** @todo Set a reasonable "last gasp" default db config. */
-static const char * const dbi_config_default =
- "hash:cdb:verbose";
-
dbiIndex dbiNew(rpmdb rdb, rpmTag rpmtag)
{
dbiIndex dbi = xcalloc(1, sizeof(*dbi));
@@ -103,7 +92,7 @@ dbiIndex dbiNew(rpmdb rdb, rpmTag rpmtag)
dbOpts = _free(dbOpts);
dbOpts = rpmExpand("%{_dbi_config}", NULL);
if (!(dbOpts && *dbOpts && *dbOpts != '%')) {
- dbOpts = rpmExpand(dbi_config_default, NULL);
+ dbOpts = _free(dbOpts);
}
}
diff --git a/lib/backend/dbi.h b/lib/backend/dbi.h
index 793239743..f9b79491d 100644
--- a/lib/backend/dbi.h
+++ b/lib/backend/dbi.h
@@ -65,7 +65,6 @@ enum dbiFlags_e {
struct _dbiIndex {
const char * dbi_file; /*!< file component of path */
- DBTYPE dbi_dbtype; /*!< db index type */
int dbi_oflags; /*!< db->open flags */
int dbi_permit_dups; /*!< permit duplicate entries? */
int dbi_no_dbsync; /*!< don't call dbiSync */
diff --git a/macros.in b/macros.in
index 6a6078a7a..63ca234dd 100644
--- a/macros.in
+++ b/macros.in
@@ -517,9 +517,6 @@ print (t)\
# I believe that you will find pagesize=512 "best".
# 3) Adding nofsync increases speed, but risks total data loss. Fiddle shared
# and/or mp_size instead.
-# 4) btree is faster than hash, but would require some painful rpm release
-# engineering to convert everbody's databases to btree, not gonna happen
-# soon.
#
# token works? Berkeley db flag or value
#==================================================
@@ -528,10 +525,6 @@ print (t)\
# cachesize=1Mb DBENV->set_cachesize, DB->set_cachesize
#---------------------- DB->open bits:
# nommap ??? DB_NOMMAP
-#---------------------- DB->open types:
-# btree DB_BTREE
-# hash DB_HASH
-# unknown +++ DB_UNKNOWN
#----------------------- rpmdb specific configuration:
# lockdbfd (always on for Packages) Use fcntl(2) locking ?
# nofsync Disable fsync(2) call performed after db3 writes?
@@ -540,31 +533,10 @@ print (t)\
# Misc BDB tuning options
%__dbi_other mp_mmapsize=16Mb mp_size=1Mb
-#
-#--- Hash database configuration
-%__dbi_htconfig \
- hash \
- %{__dbi_other}\
-%{nil}
-
-%_dbi_htconfig %{__dbi_htconfig}
-
-#
-#--- Btree database configuration
-%__dbi_btconfig \
- btree \
- %{__dbi_other}\
-%{nil}
-
-%_dbi_btconfig %{__dbi_btconfig}
+%_dbi_config %{?__dbi_other}
# "Packages" should have shared/exclusive fcntl(2) lock using "lockdbfd".
-%_dbi_config_Packages %{_dbi_htconfig} lockdbfd
-
-%_dbi_config_Dirnames %{_dbi_btconfig}
-%_dbi_config_Installtid %{_dbi_btconfig}
-
-%_dbi_config %{_dbi_htconfig}
+%_dbi_config_Packages %{?_dbi_config} lockdbfd
# XXX legacy configuration.
# Choose db interface: