Reworked intialization code, includes to isolate bufferManager

implementation from the rest of Stasis.
This commit is contained in:
Sears Russell 2007-03-03 01:52:03 +00:00
parent b3152261b4
commit 73788eb910
8 changed files with 43 additions and 44 deletions

View file

@ -43,10 +43,10 @@ terms specified in this license.
* @file
* Manages the page buffer
pageManager - Provides cached page handling, delegates to blob
bufferManager - Provides cached page handling, delegates to blob
manager when necessary. Doesn't implement an eviction policy.
That is left to a cacheManager. (Multiple cacheManagers could be
used with a single page manager.)
used with a single bufferManager.)
@todo Allow error checking!
@ -60,7 +60,7 @@ terms specified in this license.
Operations,
Predicates.
LLADD already has operations and transactions, and these can be
Stasis already has operations and transactions, and these can be
relatively unchanged. Predicates are read only operations that
return a set of tuples. Tread() is the simplest predicate.
Index scans provide a motivating example.
@ -90,27 +90,29 @@ BEGIN_C_DECLS
an abstraction barrier between page.h and the rest of the system.
If you need to muck with page internals, first consider the
implications that doing so has on locking. In particular, rwlatch
implications that doing so has on latching. In particular, rwlatch
is currently entirely handled in page.c.
*/
typedef struct Page_s Page_s;
typedef struct Page_s Page;
extern Page * (*loadPage)(int xid, int pageid);
extern void (*releasePage)(Page * p);
extern int (*bufInit)();
extern void (*bufDeinit)();
/**
* @param xid The transaction that is pinning the page (used by page-level locking implementations.)
* @param pageid ID of the page you want to load
* @return fully formed Page type
*/
compensated_function Page * loadPage(int xid, int pageid);
compensated_function Page * bufManLoadPage(int xid, int pageid);
/**
loadPage aquires a lock when it is called, effectively pinning it
in memory. releasePage releases this lock.
*/
void releasePage(Page * p);
//#define loadPage(xid, pageid) loadPage(xid, pageid); printf("%s %d: thread=%d loadPage(%d, %d)\n", __FILE__, __LINE__, pthread_self(), (xid), (pageid));
//#define releasePage(pageid) releasePage(pageid); printf("%s,%d: thread=%d releasePage()\n", __FILE__, __LINE__, pthread_self());
void bufManReleasePage(Page * p);
#ifdef PROFILE_LATCHES_WRITE_ONLY
#define loadPage(x,y) __profile_loadPage((x), (y), __FILE__, __LINE__)
@ -125,13 +127,16 @@ compensated_function Page * __profile_loadPage(int xid, int pageid, char * file,
* @return 0 on success
* @return error code on failure
*/
int bufInit();
int bufManBufInit();
/**
* will write out any dirty pages, assumes that there are no running
* transactions
*/
void bufDeinit();
void bufManBufDeinit();
void setBufferManager(int i);
END_C_DECLS

View file

@ -91,6 +91,8 @@ terms specified in this license.
/*#define MAX_BUFFER_SIZE 7 */
#endif
#define BUFFER_MANAGER_HASH 0
#define MAX_TRANSACTIONS 1000
/** Operation types */

View file

@ -18,14 +18,6 @@ void allocBlob(int xid, recordid rid) {
// printf("rid = {%d %d %d}\n", rid.page, rid.slot, rid.size);
}
void openBlobStore() {
}
void closeBlobStore() {
}
void readBlob(int xid, Page * p2, recordid rid, byte * buf) {
int chunk;
recordid rawRid = rid;

View file

@ -69,8 +69,6 @@ compensated_function recordid preAllocBlobFromPage(int xid, long page, long blob
*/
void allocBlob(int xid, recordid rid);
void openBlobStore();
void closeBlobStore();
END_C_DECLS

View file

@ -64,8 +64,6 @@ terms specified in this license.
#include <lladd/bufferPool.h>
#include <lladd/lockManager.h>
#include "page.h"
#include "blobManager.h"
#include <lladd/pageCache.h>
#include "pageFile.h"
@ -109,9 +107,10 @@ static Page * dummy_page;
pthread_key_t lastPage;
int bufInit() {
int bufManBufInit() {
bufferPoolInit();
pageInit();
openPageFile();
@ -126,8 +125,6 @@ int bufInit() {
pageFree(first, 0);
LH_ENTRY(insert)(activePages, &first->id, sizeof(int), first);
openBlobStore();
pageCacheInit(first);
int err = pthread_key_create(&lastPage, 0);
@ -141,9 +138,7 @@ int bufInit() {
return 0;
}
void bufDeinit() {
closeBlobStore();
void bufManBufDeinit() {
DEBUG("pageCacheDeinit()");
@ -163,7 +158,8 @@ void bufDeinit() {
pageCacheDeinit();
closePageFile();
pageDeInit();
bufferPoolDeInit();
#ifdef PIN_COUNT
if(pinCount != 0) {
printf("WARNING: At exit, %d pages were still pinned!\n", pinCount);
@ -176,14 +172,13 @@ void bufDeinit() {
testing.)
*/
void simulateBufferManagerCrash() {
closeBlobStore();
closePageFile();
#ifdef PIN_COUNT
pinCount = 0;
#endif
}
void releasePage (Page * p) {
void bufManReleasePage (Page * p) {
unlock(p->loadlatch);
#ifdef PIN_COUNT
pthread_mutex_lock(&pinCount_mutex);
@ -453,7 +448,7 @@ compensated_function void __profile_releasePage(Page * p) {
#endif
compensated_function Page *loadPage(int xid, int pageid) {
compensated_function Page *bufManLoadPage(int xid, int pageid) {
try_ret(NULL) {
if(globalLockManager.readLockPage) { globalLockManager.readLockPage(xid, pageid); }
@ -489,3 +484,16 @@ compensated_function Page *loadPage(int xid, int pageid) {
return ret;
}
Page * (*loadPage)(int xid, int pageid) = 0;
void (*releasePage)(Page * p) = 0;
int (*bufInit)() = 0;
void (*bufDeinit)() = 0;
void setBufferManager(int i ) {
if(i == BUFFER_MANAGER_HASH) {
releasePage = bufManReleasePage;
bufInit = bufManBufInit;
loadPage = bufManLoadPage;
bufDeinit = bufManBufDeinit;
}
}

View file

@ -122,12 +122,10 @@ lsn_t pageReadLSN(const Page * page) {
* all the functions dealing with pages.
*/
void pageInit() {
bufferPoolInit();
slottedPageInit();
}
void pageDeInit() {
bufferPoolDeInit();
void pageDeinit() {
slottedPageDeInit();
}

View file

@ -84,7 +84,6 @@ terms specified in this license.
/** @todo page.h includes things that it shouldn't, and page.h should eventually be an installed header. */
#include <lladd/transactional.h>
#include <lladd/bufferManager.h>
BEGIN_C_DECLS
@ -192,7 +191,7 @@ void pageInit();
/**
* releases all resources held by the page sub-system.
*/
void pageDeInit();
void pageDeinit();
/**
* assumes that the page is already loaded in memory. It takes as a

View file

@ -18,10 +18,7 @@
#include <lladd/bufferManager.h>
#include <lladd/lockManager.h>
/** @todo recovery2.c shouldn't include pageCache.h once refactoring is done. */
#include <lladd/pageCache.h>
/** @todo questionable include? */
#include "page.h"
#include "page.h" // Needed for pageReadLSN.
#include <lladd/transactional.h>