catastrophic recovery required

Matthias Andree matthias.andree at gmx.de
Wed Feb 16 17:58:59 CET 2005


On Wed, 16 Feb 2005, Tom Anderson wrote:

> Nonetheless, is it possible to change the database page size to the 
> harddrive page size?  Can this be detected and configured automatically 
> during install?

It can be set before a database is created, but bogofilter does not
currently support this. DB_CONFIG cannot help here as it configures the
environment, not the database.

This patch should do (against CVS, perhaps apply with fuzz), largely
untested but doesn't break selftests. To use, run

env BF_PAGESIZE=512 bogoutil -n <nonspam.eml

or similar before the database exists, or pass that variable to bogoutil -l
after dumping and removing the database. 512 is the natural blocksize
of hard disk drives (some MO drives use 2048 instead).

Index: src/datastore_db.c
===================================================================
RCS file: /cvsroot/bogofilter/bogofilter/src/datastore_db.c,v
retrieving revision 1.167
diff -u -p -r1.167 datastore_db.c
--- src/datastore_db.c	16 Feb 2005 00:37:24 -0000	1.167
+++ src/datastore_db.c	16 Feb 2005 16:54:59 -0000
@@ -89,11 +89,28 @@ static int DB_OPEN(DB *db, const char *d
 	const char *db_file, DBTYPE type, u_int32_t flags, int mode)
 {
     int ret;
+    const char *ps;
 
 #if DB_AT_LEAST(4,1)
     flags |= dsm->dsm_auto_commit_flags();
 #endif
 
+    if ((ps = getenv("BF_PAGESIZE"))) {
+	u_int32_t s = atoi(ps);
+	if (((s - 1) ^ s) != (s * 2 - 1)) {
+	    fprintf(stderr, "BF_PAGESIZE must be a power of 2, ignoring\n");
+	} else if (s < 512 || s > 65536) {
+	    fprintf(stderr, "BF_PAGESIZE must be 512 ... 65536, ignoring\n");
+	} else {
+	    int r;
+
+	    if ((r = db->set_pagesize(db, s))) {
+		fprintf(stderr, "setting pagesize to %d failed: %s\n",
+			s, db_strerror(r));
+	    }
+	}
+    }
+
     ret = db->open(db,
 #if DB_AT_LEAST(4,1)
 	    0,	/* TXN handle - we use autocommit instead */

-- 
Matthias Andree



More information about the Bogofilter mailing list