00001
00002
00003
00004
00005
00006
00007 #include "config.h"
00008
00009 #ifndef lint
00010 static const char revid[] = "$Id: mp__fset_8c-source.html,v 1.1 2008/06/08 10:20:47 sebdiaz Exp $";
00011 #endif
00012
00013 #ifndef NO_SYSTEM_INCLUDES
00014 #include <sys/types.h>
00015
00016 #include <errno.h>
00017 #endif
00018
00019 #ifdef HAVE_RPC
00020 #include "db_server.h"
00021 #endif
00022
00023 #include "db_int.h"
00024 #include "db_shash.h"
00025 #include "mp.h"
00026
00027 #ifdef HAVE_RPC
00028 #include "gen_client_ext.h"
00029 #include "rpc_client_ext.h"
00030 #endif
00031
00032
00033
00034
00035
00036 int
00037 CDB_memp_fset(dbmfp, pgaddr, flags)
00038 DB_MPOOLFILE *dbmfp;
00039 void *pgaddr;
00040 u_int32_t flags;
00041 {
00042 BH *bhp;
00043 DB_ENV *dbenv;
00044 DB_MPOOL *dbmp;
00045 MPOOL *c_mp, *mp;
00046 int ret;
00047
00048 dbmp = dbmfp->dbmp;
00049 dbenv = dbmp->dbenv;
00050 mp = dbmp->reginfo[0].primary;
00051
00052 #ifdef HAVE_RPC
00053 if (F_ISSET(dbenv, DB_ENV_RPCCLIENT))
00054 return (__dbcl_memp_fset(dbmfp, pgaddr, flags));
00055 #endif
00056
00057 PANIC_CHECK(dbenv);
00058
00059
00060 if (flags == 0)
00061 return (CDB___db_ferr(dbenv, "CDB_memp_fset", 1));
00062
00063 if ((ret = CDB___db_fchk(dbenv, "CDB_memp_fset", flags,
00064 DB_MPOOL_DIRTY | DB_MPOOL_CLEAN | DB_MPOOL_DISCARD)) != 0)
00065 return (ret);
00066 if ((ret = CDB___db_fcchk(dbenv, "CDB_memp_fset",
00067 flags, DB_MPOOL_CLEAN, DB_MPOOL_DIRTY)) != 0)
00068 return (ret);
00069
00070 if (LF_ISSET(DB_MPOOL_DIRTY) && F_ISSET(dbmfp, MP_READONLY)) {
00071 CDB___db_err(dbenv, "%s: dirty flag set for readonly file page",
00072 CDB___memp_fn(dbmfp));
00073 return (EACCES);
00074 }
00075
00076
00077 bhp = (BH *)((u_int8_t *)pgaddr - SSZA(BH, buf));
00078
00079
00080 c_mp = BH_TO_CACHE(dbmp, bhp);
00081
00082 R_LOCK(dbenv, dbmp->reginfo);
00083
00084 if (LF_ISSET(DB_MPOOL_CLEAN) && F_ISSET(bhp, BH_DIRTY)) {
00085 ++c_mp->stat.st_page_clean;
00086 --c_mp->stat.st_page_dirty;
00087 F_CLR(bhp, BH_DIRTY);
00088 }
00089 if (LF_ISSET(DB_MPOOL_DIRTY) && !F_ISSET(bhp, BH_DIRTY)) {
00090 --c_mp->stat.st_page_clean;
00091 ++c_mp->stat.st_page_dirty;
00092 F_SET(bhp, BH_DIRTY);
00093 }
00094 if (LF_ISSET(DB_MPOOL_DISCARD))
00095 F_SET(bhp, BH_DISCARD);
00096
00097 R_UNLOCK(dbenv, dbmp->reginfo);
00098 return (0);
00099 }