00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include "db_config.h"
00011
00012 #ifndef NO_SYSTEM_INCLUDES
00013 #include <sys/types.h>
00014 #endif
00015
00016 #include "db_int.h"
00017 #include "dbinc/db_page.h"
00018 #include "dbinc/db_shash.h"
00019 #include "dbinc/db_am.h"
00020 #include "dbinc/mp.h"
00021
00022 static int __env_lsn_reset __P((DB_ENV *, const char *, int));
00023
00024
00025
00026
00027
00028
00029
00030 int
00031 __env_lsn_reset_pp(dbenv, name, flags)
00032 DB_ENV *dbenv;
00033 const char *name;
00034 u_int32_t flags;
00035 {
00036 DB_THREAD_INFO *ip;
00037 int handle_check, ret, t_ret;
00038
00039 PANIC_CHECK(dbenv);
00040 ENV_ILLEGAL_BEFORE_OPEN(dbenv, "DB_ENV->lsn_reset");
00041
00042
00043
00044
00045
00046
00047 if (flags != 0 && flags != DB_ENCRYPT)
00048 return (__db_ferr(dbenv, "DB_ENV->lsn_reset", 0));
00049
00050 ENV_ENTER(dbenv, ip);
00051
00052
00053 handle_check = IS_ENV_REPLICATED(dbenv);
00054 if (handle_check && (ret = __env_rep_enter(dbenv, 1)) != 0)
00055 goto err;
00056
00057 ret = __env_lsn_reset(dbenv, name, LF_ISSET(DB_ENCRYPT) ? 1 : 0);
00058
00059 if (handle_check && (t_ret = __env_db_rep_exit(dbenv)) != 0 && ret == 0)
00060 ret = t_ret;
00061
00062 err: ENV_LEAVE(dbenv, ip);
00063 return (ret);
00064 }
00065
00066
00067
00068
00069
00070 static int
00071 __env_lsn_reset(dbenv, name, encrypted)
00072 DB_ENV *dbenv;
00073 const char *name;
00074 int encrypted;
00075 {
00076 DB *dbp;
00077 DB_MPOOLFILE *mpf;
00078 PAGE *pagep;
00079 db_pgno_t pgno;
00080 int t_ret, ret;
00081
00082
00083 if ((ret = db_create(&dbp, dbenv, 0)) != 0)
00084 return (ret);
00085
00086
00087 if (encrypted && (ret = __db_set_flags(dbp, DB_ENCRYPT)) != 0)
00088 goto err;
00089
00090
00091
00092
00093
00094
00095
00096
00097 if ((ret = __db_open(dbp, NULL,
00098 name, NULL, DB_UNKNOWN, DB_RDWRMASTER, 0, PGNO_BASE_MD)) != 0)
00099 goto err;
00100
00101
00102 mpf = dbp->mpf;
00103 for (pgno = 0;
00104 (ret = __memp_fget(mpf, &pgno, 0, &pagep)) == 0; ++pgno) {
00105 LSN_NOT_LOGGED(pagep->lsn);
00106 if ((ret = __memp_fput(mpf, pagep, DB_MPOOL_DIRTY)) != 0)
00107 goto err;
00108 }
00109
00110 if (ret == DB_PAGE_NOTFOUND)
00111 ret = 0;
00112
00113 err: if ((t_ret = __db_close(dbp, NULL, 0)) != 0 && ret == 0)
00114 ret = t_ret;
00115 return (ret);
00116 }