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
00015 #endif
00016
00017 #include "db_int.h"
00018 #include "dbinc/db_shash.h"
00019 #include "dbinc/log.h"
00020 #include "dbinc/mp.h"
00021
00022
00023
00024
00025
00026
00027
00028 int
00029 __memp_fset_pp(dbmfp, pgaddr, flags)
00030 DB_MPOOLFILE *dbmfp;
00031 void *pgaddr;
00032 u_int32_t flags;
00033 {
00034 DB_ENV *dbenv;
00035 DB_THREAD_INFO *ip;
00036 int ret;
00037
00038 dbenv = dbmfp->dbenv;
00039
00040 PANIC_CHECK(dbenv);
00041 MPF_ILLEGAL_BEFORE_OPEN(dbmfp, "DB_MPOOLFILE->set");
00042
00043
00044 if (flags == 0)
00045 return (__db_ferr(dbenv, "memp_fset", 1));
00046
00047 if ((ret = __db_fchk(dbenv, "memp_fset", flags,
00048 DB_MPOOL_CLEAN | DB_MPOOL_DIRTY | DB_MPOOL_DISCARD)) != 0)
00049 return (ret);
00050 if ((ret = __db_fcchk(dbenv, "memp_fset",
00051 flags, DB_MPOOL_CLEAN, DB_MPOOL_DIRTY)) != 0)
00052 return (ret);
00053
00054 if (LF_ISSET(DB_MPOOL_DIRTY) && F_ISSET(dbmfp, MP_READONLY)) {
00055 __db_err(dbenv, "%s: dirty flag set for readonly file page",
00056 __memp_fn(dbmfp));
00057 return (EACCES);
00058 }
00059
00060 ENV_ENTER(dbenv, ip);
00061 REPLICATION_WRAP(dbenv, (__memp_fset(dbmfp, pgaddr, flags)), ret);
00062 ENV_LEAVE(dbenv, ip);
00063 return (ret);
00064 }
00065
00066
00067
00068
00069
00070
00071
00072 int
00073 __memp_fset(dbmfp, pgaddr, flags)
00074 DB_MPOOLFILE *dbmfp;
00075 void *pgaddr;
00076 u_int32_t flags;
00077 {
00078 BH *bhp;
00079 DB_ENV *dbenv;
00080 DB_MPOOL *dbmp;
00081 DB_MPOOL_HASH *hp;
00082 MPOOL *c_mp;
00083 u_int32_t n_cache;
00084
00085 dbenv = dbmfp->dbenv;
00086 dbmp = dbenv->mp_handle;
00087
00088
00089 bhp = (BH *)((u_int8_t *)pgaddr - SSZA(BH, buf));
00090 n_cache = NCACHE(dbmp->reginfo[0].primary, bhp->mf_offset, bhp->pgno);
00091 c_mp = dbmp->reginfo[n_cache].primary;
00092 hp = R_ADDR(&dbmp->reginfo[n_cache], c_mp->htab);
00093 hp = &hp[NBUCKET(c_mp, bhp->mf_offset, bhp->pgno)];
00094
00095 MUTEX_LOCK(dbenv, hp->mtx_hash);
00096
00097
00098 if (LF_ISSET(DB_MPOOL_CLEAN) &&
00099 F_ISSET(bhp, BH_DIRTY) && !F_ISSET(bhp, BH_DIRTY_CREATE)) {
00100 DB_ASSERT(hp->hash_page_dirty != 0);
00101 --hp->hash_page_dirty;
00102 F_CLR(bhp, BH_DIRTY);
00103 }
00104 if (LF_ISSET(DB_MPOOL_DIRTY) && !F_ISSET(bhp, BH_DIRTY)) {
00105 ++hp->hash_page_dirty;
00106 F_SET(bhp, BH_DIRTY);
00107 }
00108 if (LF_ISSET(DB_MPOOL_DISCARD))
00109 F_SET(bhp, BH_DISCARD);
00110
00111 MUTEX_UNLOCK(dbenv, hp->mtx_hash);
00112 return (0);
00113 }