2 * See the file LICENSE for redistribution information.
4 * Copyright (c) 1998-2009 Oracle. All rights reserved.
12 #include "dbinc/db_page.h"
13 #include "dbinc/btree.h"
14 #include "dbinc/lock.h"
20 * PUBLIC: int __bam_reclaim __P((DB *, DB_THREAD_INFO *, DB_TXN *));
23 __bam_reclaim(dbp, ip, txn)
32 /* Acquire a cursor. */
33 if ((ret = __db_cursor(dbp, ip, txn, &dbc, 0)) != 0)
36 /* Write lock the metapage for deallocations. */
37 if ((ret = __db_lget(dbc,
38 0, PGNO_BASE_MD, DB_LOCK_WRITE, 0, &meta_lock)) != 0)
41 /* Avoid locking every page, we have the handle locked exclusive. */
42 F_SET(dbc, DBC_DONTLOCK);
44 /* Walk the tree, freeing pages. */
45 ret = __bam_traverse(dbc,
46 DB_LOCK_WRITE, dbc->internal->root, __db_reclaim_callback, NULL);
48 if ((t_ret = __TLPUT(dbc, meta_lock)) != 0 && ret == 0)
51 /* Discard the cursor. */
52 err: if ((t_ret = __dbc_close(dbc)) != 0 && ret == 0)
60 * Truncate a database.
62 * PUBLIC: int __bam_truncate __P((DBC *, u_int32_t *));
65 __bam_truncate(dbc, countp)
72 #ifdef HAVE_COMPRESSION
76 if (DB_IS_COMPRESSED(dbc->dbp) &&
77 (ret = __bam_compress_count(dbc, NULL, &comp_count)) != 0)
83 /* Walk the tree, freeing pages. */
84 ret = __bam_traverse(dbc,
85 DB_LOCK_WRITE, dbc->internal->root, __db_truncate_callback, &count);
87 #ifdef HAVE_COMPRESSION
88 if (DB_IS_COMPRESSED(dbc->dbp)) {