Add loadPageOfType() call. (Untested for now)

This commit is contained in:
Sears Russell 2009-07-07 21:33:49 +00:00
parent cf49c7dbf1
commit ade1dc896e
5 changed files with 25 additions and 26 deletions

View file

@ -139,7 +139,6 @@ compensated_function Page * __profile_loadPage(int xid, pageid_t pageid, char *
compensated_function void __profile_releasePage(Page * p) { compensated_function void __profile_releasePage(Page * p) {
pthread_mutex_lock(&profile_load_mutex); pthread_mutex_lock(&profile_load_mutex);
// int pageid = p->id;
int * pins = LH_ENTRY(find)(profile_load_pins_hash, &p, sizeof(void*)); int * pins = LH_ENTRY(find)(profile_load_pins_hash, &p, sizeof(void*));
assert(pins); assert(pins);
@ -163,7 +162,7 @@ compensated_function void __profile_releasePage(Page * p) {
#endif #endif
Page * (*loadPageImpl)(int xid, pageid_t pageid) = 0; Page * (*loadPageImpl)(int xid, pageid_t pageid, pagetype_t type) = 0;
Page * (*loadUninitPageImpl)(int xid, pageid_t pageid) = 0; Page * (*loadUninitPageImpl)(int xid, pageid_t pageid) = 0;
void (*releasePageImpl)(Page * p) = 0; void (*releasePageImpl)(Page * p) = 0;
void (*writeBackPage)(Page * p) = 0; void (*writeBackPage)(Page * p) = 0;
@ -173,19 +172,18 @@ void (*stasis_buffer_manager_close)() = 0;
void (*stasis_buffer_manager_simulate_crash)() = 0; void (*stasis_buffer_manager_simulate_crash)() = 0;
Page * loadPage(int xid, pageid_t pageid) { Page * loadPage(int xid, pageid_t pageid) {
try_ret(NULL) { // This lock is released at Tcommit()
// This lock is released at Tcommit() if(globalLockManager.readLockPage) { globalLockManager.readLockPage(xid, pageid); }
if(globalLockManager.readLockPage) { globalLockManager.readLockPage(xid, pageid); } return loadPageImpl(xid, pageid, UNKNOWN_TYPE_PAGE);
} end_ret(NULL);
return loadPageImpl(xid, pageid);
} }
Page * loadPageOfType(int xid, pageid_t pageid, pagetype_t type) {
if(globalLockManager.readLockPage) { globalLockManager.readLockPage(xid, pageid); }
return loadPageImpl(xid, pageid, type);
}
Page * loadUninitializedPage(int xid, pageid_t pageid) { Page * loadUninitializedPage(int xid, pageid_t pageid) {
try_ret(NULL) { // This lock is released at Tcommit()
// This lock is released at Tcommit() if(globalLockManager.readLockPage) { globalLockManager.readLockPage(xid, pageid); }
if(globalLockManager.readLockPage) { globalLockManager.readLockPage(xid, pageid); }
} end_ret(NULL);
return loadUninitPageImpl(xid, pageid); return loadUninitPageImpl(xid, pageid);

View file

@ -190,7 +190,7 @@ static void * writeBackWorker(void * ignored) {
return 0; return 0;
} }
static Page * bhLoadPageImpl_helper(int xid, const pageid_t pageid, int uninitialized) { static Page * bhLoadPageImpl_helper(int xid, const pageid_t pageid, int uninitialized, pagetype_t type) {
// Note: Calls to loadlatch in this function violate lock order, but // Note: Calls to loadlatch in this function violate lock order, but
// should be safe, since we make sure no one can have a writelock // should be safe, since we make sure no one can have a writelock
@ -283,7 +283,7 @@ static Page * bhLoadPageImpl_helper(int xid, const pageid_t pageid, int uninitia
memset(ret->memAddr,0,PAGE_SIZE); memset(ret->memAddr,0,PAGE_SIZE);
*stasis_page_lsn_ptr(ret) = ret->LSN; *stasis_page_lsn_ptr(ret) = ret->LSN;
ret->dirty = 0; ret->dirty = 0;
stasis_page_loaded(ret, UNKNOWN_TYPE_PAGE); stasis_page_loaded(ret, type);
} }
*pagePendingPtr(ret) = 0; *pagePendingPtr(ret) = 0;
// Would remove from lru, but getFreePage() guarantees that it isn't // Would remove from lru, but getFreePage() guarantees that it isn't
@ -306,11 +306,11 @@ static Page * bhLoadPageImpl_helper(int xid, const pageid_t pageid, int uninitia
return ret; return ret;
} }
static Page * bhLoadPageImpl(int xid, const pageid_t pageid) { static Page * bhLoadPageImpl(int xid, const pageid_t pageid, pagetype_t type) {
return bhLoadPageImpl_helper(xid,pageid,0); return bhLoadPageImpl_helper(xid,pageid,0, type);
} }
static Page * bhLoadUninitPageImpl(int xid, const pageid_t pageid) { static Page * bhLoadUninitPageImpl(int xid, const pageid_t pageid) {
return bhLoadPageImpl_helper(xid,pageid,1); // 1 means dont care about preimage of page. return bhLoadPageImpl_helper(xid,pageid,1,UNKNOWN_TYPE_PAGE); // 1 means dont care about preimage of page.
} }

View file

@ -21,7 +21,7 @@ static pthread_key_t lastPage;
#define RW 1 #define RW 1
static void bufManBufDeinit(); static void bufManBufDeinit();
static compensated_function Page *bufManLoadPage(int xid, pageid_t pageid); static compensated_function Page *bufManLoadPage(int xid, pageid_t pageid, pagetype_t type);
static compensated_function Page *bufManLoadUninitPage(int xid, pageid_t pageid); static compensated_function Page *bufManLoadUninitPage(int xid, pageid_t pageid);
static void bufManReleasePage (Page * p); static void bufManReleasePage (Page * p);
static void bufManSimulateBufferManagerCrash(); static void bufManSimulateBufferManagerCrash();
@ -130,7 +130,7 @@ static void bufManReleasePage (Page * p) {
} }
static Page* bufManGetPage(pageid_t pageid, int locktype, int uninitialized) { static Page* bufManGetPage(pageid_t pageid, int locktype, int uninitialized, pagetype_t type) {
Page * ret; Page * ret;
int spin = 0; int spin = 0;
@ -284,7 +284,7 @@ static Page* bufManGetPage(pageid_t pageid, int locktype, int uninitialized) {
*stasis_page_lsn_ptr(ret) = ret->LSN; *stasis_page_lsn_ptr(ret) = ret->LSN;
// XXX need mutex for this call? // XXX need mutex for this call?
stasis_page_loaded(ret, UNKNOWN_TYPE_PAGE); stasis_page_loaded(ret, type);
} }
writeunlock(ret->loadlatch); writeunlock(ret->loadlatch);
@ -327,7 +327,7 @@ static Page* bufManGetPage(pageid_t pageid, int locktype, int uninitialized) {
unlock(ret->loadlatch); unlock(ret->loadlatch);
printf("pageCache.c: Thrashing detected. Strongly consider increasing LLADD's buffer pool size!\n"); printf("pageCache.c: Thrashing detected. Strongly consider increasing LLADD's buffer pool size!\n");
fflush(NULL); fflush(NULL);
return bufManGetPage(pageid, locktype, uninitialized); return bufManGetPage(pageid, locktype, uninitialized, type);
} }
} }
@ -335,7 +335,7 @@ static Page* bufManGetPage(pageid_t pageid, int locktype, int uninitialized) {
} }
static compensated_function Page *bufManLoadPage(int xid, pageid_t pageid) { static compensated_function Page *bufManLoadPage(int xid, pageid_t pageid, pagetype_t type) {
Page * ret = pthread_getspecific(lastPage); Page * ret = pthread_getspecific(lastPage);
@ -353,7 +353,7 @@ static compensated_function Page *bufManLoadPage(int xid, pageid_t pageid) {
ret = 0; ret = 0;
} }
if(!ret) { if(!ret) {
ret = bufManGetPage(pageid, RO, 0); ret = bufManGetPage(pageid, RO, 0, type);
pthread_setspecific(lastPage, ret); pthread_setspecific(lastPage, ret);
} }
@ -384,7 +384,7 @@ static compensated_function Page *bufManLoadUninitPage(int xid, pageid_t pageid)
ret = 0; ret = 0;
} }
if(!ret) { if(!ret) {
ret = bufManGetPage(pageid, RO, 1); ret = bufManGetPage(pageid, RO, 1, UNKNOWN_TYPE_PAGE);
pthread_setspecific(lastPage, ret); pthread_setspecific(lastPage, ret);
} }

View file

@ -12,7 +12,7 @@ static Page ** pageMap;
static pageid_t pageCount; static pageid_t pageCount;
static pthread_mutex_t pageArray_mut = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t pageArray_mut = PTHREAD_MUTEX_INITIALIZER;
static Page * paLoadPage(int xid, pageid_t pageid) { static Page * paLoadPage(int xid, pageid_t pageid, pagetype_t type) {
pthread_mutex_lock(&pageArray_mut); pthread_mutex_lock(&pageArray_mut);
if(pageid >= pageCount) { if(pageid >= pageCount) {
@ -26,6 +26,7 @@ static Page * paLoadPage(int xid, pageid_t pageid) {
if(!pageMap[pageid]) { if(!pageMap[pageid]) {
pageMap[pageid] = malloc(sizeof(Page)); pageMap[pageid] = malloc(sizeof(Page));
pageMap[pageid]->id = pageid; pageMap[pageid]->id = pageid;
pageMap[pageid]->pageType = type;
pageMap[pageid]->LSN = 0; pageMap[pageid]->LSN = 0;
pageMap[pageid]->dirty = 0; pageMap[pageid]->dirty = 0;
pageMap[pageid]->next = 0; pageMap[pageid]->next = 0;

View file

@ -99,7 +99,7 @@ Page * loadUninitializedPage(int xid, pageid_t pageid);
This is the function pointer that stasis_buffer_manager_open sets in order to This is the function pointer that stasis_buffer_manager_open sets in order to
override loadPage. override loadPage.
*/ */
extern Page * (*loadPageImpl)(int xid, pageid_t pageid); extern Page * (*loadPageImpl)(int xid, pageid_t pageid, pagetype_t type);
extern Page * (*loadUninitPageImpl)(int xid, pageid_t pageid); extern Page * (*loadUninitPageImpl)(int xid, pageid_t pageid);
/** /**
loadPage aquires a lock when it is called, effectively pinning it loadPage aquires a lock when it is called, effectively pinning it