diff --git a/src/stasis/bufferManager.c b/src/stasis/bufferManager.c index afbb299..de9b61c 100644 --- a/src/stasis/bufferManager.c +++ b/src/stasis/bufferManager.c @@ -139,7 +139,6 @@ compensated_function Page * __profile_loadPage(int xid, pageid_t pageid, char * compensated_function void __profile_releasePage(Page * p) { pthread_mutex_lock(&profile_load_mutex); - // int pageid = p->id; int * pins = LH_ENTRY(find)(profile_load_pins_hash, &p, sizeof(void*)); assert(pins); @@ -163,7 +162,7 @@ compensated_function void __profile_releasePage(Page * p) { #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; void (*releasePageImpl)(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; Page * loadPage(int xid, pageid_t pageid) { - try_ret(NULL) { - // This lock is released at Tcommit() - if(globalLockManager.readLockPage) { globalLockManager.readLockPage(xid, pageid); } - } end_ret(NULL); - - return loadPageImpl(xid, pageid); + // This lock is released at Tcommit() + if(globalLockManager.readLockPage) { globalLockManager.readLockPage(xid, pageid); } + return loadPageImpl(xid, pageid, UNKNOWN_TYPE_PAGE); } +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) { - try_ret(NULL) { - // This lock is released at Tcommit() - if(globalLockManager.readLockPage) { globalLockManager.readLockPage(xid, pageid); } - } end_ret(NULL); + // This lock is released at Tcommit() + if(globalLockManager.readLockPage) { globalLockManager.readLockPage(xid, pageid); } return loadUninitPageImpl(xid, pageid); diff --git a/src/stasis/bufferManager/bufferHash.c b/src/stasis/bufferManager/bufferHash.c index 4421459..b39179a 100644 --- a/src/stasis/bufferManager/bufferHash.c +++ b/src/stasis/bufferManager/bufferHash.c @@ -190,7 +190,7 @@ static void * writeBackWorker(void * ignored) { 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 // 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); *stasis_page_lsn_ptr(ret) = ret->LSN; ret->dirty = 0; - stasis_page_loaded(ret, UNKNOWN_TYPE_PAGE); + stasis_page_loaded(ret, type); } *pagePendingPtr(ret) = 0; // 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; } -static Page * bhLoadPageImpl(int xid, const pageid_t pageid) { - return bhLoadPageImpl_helper(xid,pageid,0); +static Page * bhLoadPageImpl(int xid, const pageid_t pageid, pagetype_t type) { + return bhLoadPageImpl_helper(xid,pageid,0, type); } 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. } diff --git a/src/stasis/bufferManager/legacy/legacyBufferManager.c b/src/stasis/bufferManager/legacy/legacyBufferManager.c index 70e0e2a..b89eb83 100644 --- a/src/stasis/bufferManager/legacy/legacyBufferManager.c +++ b/src/stasis/bufferManager/legacy/legacyBufferManager.c @@ -21,7 +21,7 @@ static pthread_key_t lastPage; #define RW 1 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 void bufManReleasePage (Page * p); 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; int spin = 0; @@ -284,7 +284,7 @@ static Page* bufManGetPage(pageid_t pageid, int locktype, int uninitialized) { *stasis_page_lsn_ptr(ret) = ret->LSN; // XXX need mutex for this call? - stasis_page_loaded(ret, UNKNOWN_TYPE_PAGE); + stasis_page_loaded(ret, type); } writeunlock(ret->loadlatch); @@ -327,7 +327,7 @@ static Page* bufManGetPage(pageid_t pageid, int locktype, int uninitialized) { unlock(ret->loadlatch); printf("pageCache.c: Thrashing detected. Strongly consider increasing LLADD's buffer pool size!\n"); 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); @@ -353,7 +353,7 @@ static compensated_function Page *bufManLoadPage(int xid, pageid_t pageid) { ret = 0; } if(!ret) { - ret = bufManGetPage(pageid, RO, 0); + ret = bufManGetPage(pageid, RO, 0, type); pthread_setspecific(lastPage, ret); } @@ -384,7 +384,7 @@ static compensated_function Page *bufManLoadUninitPage(int xid, pageid_t pageid) ret = 0; } if(!ret) { - ret = bufManGetPage(pageid, RO, 1); + ret = bufManGetPage(pageid, RO, 1, UNKNOWN_TYPE_PAGE); pthread_setspecific(lastPage, ret); } diff --git a/src/stasis/bufferManager/pageArray.c b/src/stasis/bufferManager/pageArray.c index 0334cc4..8d7c245 100644 --- a/src/stasis/bufferManager/pageArray.c +++ b/src/stasis/bufferManager/pageArray.c @@ -12,7 +12,7 @@ static Page ** pageMap; static pageid_t pageCount; 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); if(pageid >= pageCount) { @@ -26,6 +26,7 @@ static Page * paLoadPage(int xid, pageid_t pageid) { if(!pageMap[pageid]) { pageMap[pageid] = malloc(sizeof(Page)); pageMap[pageid]->id = pageid; + pageMap[pageid]->pageType = type; pageMap[pageid]->LSN = 0; pageMap[pageid]->dirty = 0; pageMap[pageid]->next = 0; diff --git a/stasis/bufferManager.h b/stasis/bufferManager.h index 9a36498..0c88e35 100644 --- a/stasis/bufferManager.h +++ b/stasis/bufferManager.h @@ -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 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); /** loadPage aquires a lock when it is called, effectively pinning it