refactored/created stasis_buffer_manager_open and stasis_handle_open
This commit is contained in:
parent
b5b414490a
commit
7b4cf40221
18 changed files with 272 additions and 248 deletions
|
@ -29,7 +29,7 @@ ADD_LIBRARY(stasis crc32.c redblack.c lhtable.c rw.c doubleLinkedList.c
|
||||||
operations/pageOrientedListNTA.c
|
operations/pageOrientedListNTA.c
|
||||||
operations/regions.c operations/lsmTree.c
|
operations/regions.c operations/lsmTree.c
|
||||||
io/rangeTracker.c io/memory.c io/file.c io/pfile.c
|
io/rangeTracker.c io/memory.c io/file.c io/pfile.c
|
||||||
io/non_blocking.c io/debug.c
|
io/non_blocking.c io/debug.c io/handle.c
|
||||||
bufferManager/pageArray.c
|
bufferManager/pageArray.c
|
||||||
bufferManager/bufferHash.c replacementPolicy/lru.c
|
bufferManager/bufferHash.c replacementPolicy/lru.c
|
||||||
replacementPolicy/lruFast.c)
|
replacementPolicy/lruFast.c)
|
||||||
|
|
|
@ -22,7 +22,7 @@ libstasis_la_SOURCES=crc32.c redblack.c lhtable.c rw.c doubleLinkedList.c common
|
||||||
operations/regions.c operations/lsmTree.c \
|
operations/regions.c operations/lsmTree.c \
|
||||||
operations/lsnFreeSet.c \
|
operations/lsnFreeSet.c \
|
||||||
io/rangeTracker.c io/memory.c io/file.c io/pfile.c io/non_blocking.c \
|
io/rangeTracker.c io/memory.c io/file.c io/pfile.c io/non_blocking.c \
|
||||||
io/debug.c \
|
io/debug.c io/handle.c \
|
||||||
bufferManager.c \
|
bufferManager.c \
|
||||||
bufferManager/pageArray.c \
|
bufferManager/pageArray.c \
|
||||||
bufferManager/bufferHash.c \
|
bufferManager/bufferHash.c \
|
||||||
|
|
|
@ -169,8 +169,8 @@ void (*releasePageImpl)(Page * p) = 0;
|
||||||
void (*writeBackPage)(Page * p) = 0;
|
void (*writeBackPage)(Page * p) = 0;
|
||||||
void (*forcePages)() = 0;
|
void (*forcePages)() = 0;
|
||||||
void (*forcePageRange)(pageid_t start, pageid_t stop) = 0;
|
void (*forcePageRange)(pageid_t start, pageid_t stop) = 0;
|
||||||
void (*bufDeinit)() = 0;
|
void (*stasis_buffer_manager_close)() = 0;
|
||||||
void (*simulateBufferManagerCrash)() = 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) {
|
try_ret(NULL) {
|
||||||
|
@ -195,7 +195,7 @@ void releasePage(Page * p) {
|
||||||
releasePageImpl(p);
|
releasePageImpl(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
int bufInit(int type) {
|
int stasis_buffer_manager_open(int type) {
|
||||||
bufferManagerType = type;
|
bufferManagerType = type;
|
||||||
static int lastType = 0;
|
static int lastType = 0;
|
||||||
if(type == BUFFER_MANAGER_REOPEN) {
|
if(type == BUFFER_MANAGER_REOPEN) {
|
||||||
|
@ -203,13 +203,13 @@ int bufInit(int type) {
|
||||||
}
|
}
|
||||||
lastType = type;
|
lastType = type;
|
||||||
if(type == BUFFER_MANAGER_DEPRECATED_HASH) {
|
if(type == BUFFER_MANAGER_DEPRECATED_HASH) {
|
||||||
bufManBufInit();
|
stasis_buffer_manager_deprecated_open();
|
||||||
return 0;
|
return 0;
|
||||||
} else if (type == BUFFER_MANAGER_MEM_ARRAY) {
|
} else if (type == BUFFER_MANAGER_MEM_ARRAY) {
|
||||||
paBufInit();
|
stasis_buffer_manager_mem_array_open();
|
||||||
return 0;
|
return 0;
|
||||||
} else if (type == BUFFER_MANAGER_HASH) {
|
} else if (type == BUFFER_MANAGER_HASH) {
|
||||||
bhBufInit();
|
stasis_buffer_manager_hash_open();
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
// XXX error handling
|
// XXX error handling
|
||||||
|
|
|
@ -376,7 +376,7 @@ static void bhSimulateBufferManagerCrash() {
|
||||||
stasis_buffer_pool_deinit(stasis_buffer_pool);
|
stasis_buffer_pool_deinit(stasis_buffer_pool);
|
||||||
}
|
}
|
||||||
|
|
||||||
void bhBufInit() {
|
void stasis_buffer_manager_hash_open() {
|
||||||
|
|
||||||
assert(!running);
|
assert(!running);
|
||||||
|
|
||||||
|
@ -390,8 +390,8 @@ void bhBufInit() {
|
||||||
writeBackPage = bhWriteBackPage;
|
writeBackPage = bhWriteBackPage;
|
||||||
forcePages = bhForcePages;
|
forcePages = bhForcePages;
|
||||||
forcePageRange = bhForcePageRange;
|
forcePageRange = bhForcePageRange;
|
||||||
bufDeinit = bhBufDeinit;
|
stasis_buffer_manager_close = bhBufDeinit;
|
||||||
simulateBufferManagerCrash = bhSimulateBufferManagerCrash;
|
stasis_buffer_manager_simulate_crash = bhSimulateBufferManagerCrash;
|
||||||
|
|
||||||
stasis_buffer_pool = stasis_buffer_pool_init();
|
stasis_buffer_pool = stasis_buffer_pool_init();
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ static void bufManSimulateBufferManagerCrash();
|
||||||
|
|
||||||
static stasis_buffer_pool_t * stasis_buffer_pool;
|
static stasis_buffer_pool_t * stasis_buffer_pool;
|
||||||
|
|
||||||
int bufManBufInit() {
|
int stasis_buffer_manager_deprecated_open() {
|
||||||
|
|
||||||
releasePageImpl = bufManReleasePage;
|
releasePageImpl = bufManReleasePage;
|
||||||
loadPageImpl = bufManLoadPage;
|
loadPageImpl = bufManLoadPage;
|
||||||
|
@ -35,8 +35,8 @@ int bufManBufInit() {
|
||||||
writeBackPage = pageWrite;
|
writeBackPage = pageWrite;
|
||||||
forcePages = forcePageFile;
|
forcePages = forcePageFile;
|
||||||
forcePageRange = forceRangePageFile;
|
forcePageRange = forceRangePageFile;
|
||||||
bufDeinit = bufManBufDeinit;
|
stasis_buffer_manager_close = bufManBufDeinit;
|
||||||
simulateBufferManagerCrash = bufManSimulateBufferManagerCrash;
|
stasis_buffer_manager_simulate_crash = bufManSimulateBufferManagerCrash;
|
||||||
|
|
||||||
stasis_buffer_pool = stasis_buffer_pool_init();
|
stasis_buffer_pool = stasis_buffer_pool_init();
|
||||||
|
|
||||||
|
|
|
@ -57,14 +57,14 @@ static void paBufDeinit() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void paBufInit () {
|
void stasis_buffer_manager_mem_array_open () {
|
||||||
|
|
||||||
releasePageImpl = paReleasePage;
|
releasePageImpl = paReleasePage;
|
||||||
loadPageImpl = paLoadPage;
|
loadPageImpl = paLoadPage;
|
||||||
writeBackPage = paWriteBackPage;
|
writeBackPage = paWriteBackPage;
|
||||||
forcePages = paForcePages;
|
forcePages = paForcePages;
|
||||||
bufDeinit = paBufDeinit;
|
stasis_buffer_manager_close = paBufDeinit;
|
||||||
simulateBufferManagerCrash = paBufDeinit;
|
stasis_buffer_manager_simulate_crash = paBufDeinit;
|
||||||
|
|
||||||
pageCount = 0;
|
pageCount = 0;
|
||||||
pageMap = 0;
|
pageMap = 0;
|
||||||
|
|
|
@ -573,7 +573,7 @@ struct stasis_handle_t file_func = {
|
||||||
.error = 0
|
.error = 0
|
||||||
};
|
};
|
||||||
|
|
||||||
stasis_handle_t * stasis_handle(open_file)(lsn_t start_offset, char * filename, int flags, int mode) {
|
stasis_handle_t * stasis_handle(open_file)(lsn_t start_offset, const char * filename, int flags, int mode) {
|
||||||
stasis_handle_t * ret = malloc(sizeof(stasis_handle_t));
|
stasis_handle_t * ret = malloc(sizeof(stasis_handle_t));
|
||||||
if(!ret) { return NULL; }
|
if(!ret) { return NULL; }
|
||||||
*ret = file_func;
|
*ret = file_func;
|
||||||
|
|
115
src/stasis/io/handle.c
Normal file
115
src/stasis/io/handle.c
Normal file
|
@ -0,0 +1,115 @@
|
||||||
|
/*
|
||||||
|
* handle.c
|
||||||
|
*
|
||||||
|
* Created on: May 7, 2009
|
||||||
|
* Author: sears
|
||||||
|
*/
|
||||||
|
#include <config.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
|
#include <stasis/io/handle.h>
|
||||||
|
|
||||||
|
|
||||||
|
// @todo this factory stuff doesn't really belong here...
|
||||||
|
static stasis_handle_t * fast_factory(lsn_t off, lsn_t len, void * ignored) {
|
||||||
|
stasis_handle_t * h = stasis_handle(open_memory)(off);
|
||||||
|
//h = stasis_handle(open_debug)(h);
|
||||||
|
stasis_write_buffer_t * w = h->append_buffer(h, len);
|
||||||
|
w->h->release_write_buffer(w);
|
||||||
|
return h;
|
||||||
|
}
|
||||||
|
typedef struct sf_args {
|
||||||
|
const char * filename;
|
||||||
|
int openMode;
|
||||||
|
int filePerm;
|
||||||
|
} sf_args;
|
||||||
|
static stasis_handle_t * slow_file_factory(void * argsP) {
|
||||||
|
sf_args * args = (sf_args*) argsP;
|
||||||
|
stasis_handle_t * h = stasis_handle(open_file)(0, args->filename, args->openMode, args->filePerm);
|
||||||
|
//h = stasis_handle(open_debug)(h);
|
||||||
|
return h;
|
||||||
|
}
|
||||||
|
static void slow_file_factory_close(void * argsP) {
|
||||||
|
// nop
|
||||||
|
}
|
||||||
|
static stasis_handle_t * slow_pfile_factory(void * argsP) {
|
||||||
|
stasis_handle_t * h = argsP;
|
||||||
|
return h;
|
||||||
|
}
|
||||||
|
static void slow_pfile_factory_close(void * argsP) {
|
||||||
|
stasis_handle_t * h = argsP;
|
||||||
|
h->close(h);
|
||||||
|
}
|
||||||
|
static int (*slow_close)(stasis_handle_t * h) = 0;
|
||||||
|
static stasis_handle_t * slow_pfile = 0;
|
||||||
|
static int nop_close(stasis_handle_t*h) { return 0; }
|
||||||
|
|
||||||
|
stasis_handle_t * stasis_handle(open)(const char * path) {
|
||||||
|
#ifndef HAVE_O_DIRECT
|
||||||
|
if(bufferManagerO_DIRECT) {
|
||||||
|
printf("O_DIRECT not supported by this build; switching to conventional buffered I/O.\n");
|
||||||
|
bufferManagerO_DIRECT = 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
int openMode;
|
||||||
|
if(bufferManagerO_DIRECT) {
|
||||||
|
#ifdef HAVE_O_DIRECT
|
||||||
|
openMode = O_CREAT | O_RDWR | O_DIRECT;
|
||||||
|
#else
|
||||||
|
printf("Can't happen\n");
|
||||||
|
abort();
|
||||||
|
#endif
|
||||||
|
} else {
|
||||||
|
openMode = O_CREAT | O_RDWR;
|
||||||
|
}
|
||||||
|
stasis_handle_t * ret;
|
||||||
|
/// @todo remove hardcoding of buffer manager implementations in transactional2.c
|
||||||
|
|
||||||
|
switch(bufferManagerFileHandleType) {
|
||||||
|
case BUFFER_MANAGER_FILE_HANDLE_NON_BLOCKING: {
|
||||||
|
struct sf_args * slow_arg = malloc(sizeof(sf_args));
|
||||||
|
slow_arg->filename = path;
|
||||||
|
|
||||||
|
slow_arg->openMode = openMode;
|
||||||
|
|
||||||
|
slow_arg->filePerm = FILE_PERM;
|
||||||
|
// Allow 4MB of outstanding writes.
|
||||||
|
// @todo Where / how should we open storefile?
|
||||||
|
int worker_thread_count = 4;
|
||||||
|
if(bufferManagerNonBlockingSlowHandleType == IO_HANDLE_PFILE) {
|
||||||
|
// printf("\nusing pread()/pwrite()\n");
|
||||||
|
slow_pfile = stasis_handle_open_pfile(0, slow_arg->filename, slow_arg->openMode, slow_arg->filePerm);
|
||||||
|
slow_close = slow_pfile->close;
|
||||||
|
slow_pfile->close = nop_close;
|
||||||
|
ret =
|
||||||
|
stasis_handle(open_non_blocking)(slow_pfile_factory, slow_pfile_factory_close, slow_pfile, 1, fast_factory,
|
||||||
|
NULL, worker_thread_count, PAGE_SIZE * 1024 , 1024);
|
||||||
|
|
||||||
|
} else if(bufferManagerNonBlockingSlowHandleType == IO_HANDLE_FILE) {
|
||||||
|
ret =
|
||||||
|
stasis_handle(open_non_blocking)(slow_file_factory, slow_file_factory_close, slow_arg, 0, fast_factory,
|
||||||
|
NULL, worker_thread_count, PAGE_SIZE * 1024, 1024);
|
||||||
|
} else {
|
||||||
|
printf("Unknown value for config option bufferManagerNonBlockingSlowHandleType\n");
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
case BUFFER_MANAGER_FILE_HANDLE_FILE: {
|
||||||
|
ret = stasis_handle_open_file(0, path, openMode, FILE_PERM);
|
||||||
|
} break;
|
||||||
|
case BUFFER_MANAGER_FILE_HANDLE_PFILE: {
|
||||||
|
ret = stasis_handle_open_pfile(0, path, openMode, FILE_PERM);
|
||||||
|
} break;
|
||||||
|
case BUFFER_MANAGER_FILE_HANDLE_DEPRECATED: {
|
||||||
|
assert(bufferManagerFileHandleType != BUFFER_MANAGER_FILE_HANDLE_DEPRECATED);
|
||||||
|
} break;
|
||||||
|
default: {
|
||||||
|
printf("\nUnknown buffer manager filehandle type: %d\n",
|
||||||
|
bufferManagerFileHandleType);
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
|
@ -145,6 +145,7 @@ typedef struct nbw_impl {
|
||||||
|
|
||||||
// Fields to manage slow handles
|
// Fields to manage slow handles
|
||||||
stasis_handle_t * (*slow_factory)(void * arg);
|
stasis_handle_t * (*slow_factory)(void * arg);
|
||||||
|
void (*slow_factory_close)(void * arg);
|
||||||
void * slow_factory_arg;
|
void * slow_factory_arg;
|
||||||
int slow_force_once;
|
int slow_force_once;
|
||||||
|
|
||||||
|
@ -362,6 +363,10 @@ static int nbw_close(stasis_handle_t * h) {
|
||||||
free(impl->all_slow_handles);
|
free(impl->all_slow_handles);
|
||||||
assert(impl->available_slow_handle_count == 0);
|
assert(impl->available_slow_handle_count == 0);
|
||||||
|
|
||||||
|
if(impl->slow_factory_close) {
|
||||||
|
impl->slow_factory_close(impl->slow_factory_arg);
|
||||||
|
}
|
||||||
|
|
||||||
free(h->impl);
|
free(h->impl);
|
||||||
free(h);
|
free(h);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -777,7 +782,9 @@ static void * nbw_worker(void * handle) {
|
||||||
}
|
}
|
||||||
|
|
||||||
stasis_handle_t * stasis_handle(open_non_blocking)
|
stasis_handle_t * stasis_handle(open_non_blocking)
|
||||||
(stasis_handle_t * (*slow_factory)(void * arg), void * slow_factory_arg,
|
(stasis_handle_t * (*slow_factory)(void * arg),
|
||||||
|
void (*slow_factory_close)(void * arg),
|
||||||
|
void * slow_factory_arg,
|
||||||
int slow_force_once,
|
int slow_force_once,
|
||||||
stasis_handle_t * (*fast_factory)(lsn_t, lsn_t, void *),
|
stasis_handle_t * (*fast_factory)(lsn_t, lsn_t, void *),
|
||||||
void * fast_factory_arg, int worker_thread_count, lsn_t buffer_size,
|
void * fast_factory_arg, int worker_thread_count, lsn_t buffer_size,
|
||||||
|
@ -789,6 +796,7 @@ stasis_handle_t * stasis_handle(open_non_blocking)
|
||||||
impl->end_pos = 0;
|
impl->end_pos = 0;
|
||||||
|
|
||||||
impl->slow_factory = slow_factory;
|
impl->slow_factory = slow_factory;
|
||||||
|
impl->slow_factory_close = slow_factory_close;
|
||||||
impl->slow_factory_arg = slow_factory_arg;
|
impl->slow_factory_arg = slow_factory_arg;
|
||||||
|
|
||||||
impl->slow_force_once = slow_force_once;
|
impl->slow_force_once = slow_force_once;
|
||||||
|
|
|
@ -442,7 +442,7 @@ struct stasis_handle_t pfile_func = {
|
||||||
};
|
};
|
||||||
|
|
||||||
stasis_handle_t *stasis_handle(open_pfile)(lsn_t start_offset,
|
stasis_handle_t *stasis_handle(open_pfile)(lsn_t start_offset,
|
||||||
char *filename,
|
const char *filename,
|
||||||
int flags, int mode) {
|
int flags, int mode) {
|
||||||
stasis_handle_t *ret = malloc(sizeof(stasis_handle_t));
|
stasis_handle_t *ret = malloc(sizeof(stasis_handle_t));
|
||||||
if (!ret) { return NULL; }
|
if (!ret) { return NULL; }
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "../page.h"
|
#include <stasis/page.h>
|
||||||
#include "header.h"
|
#include <stasis/page/header.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
/**
|
/**
|
||||||
@file header.c is dead code(?)
|
@file header.c is dead code(?)
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
|
|
||||||
#include <stasis/common.h>
|
#include <stasis/common.h>
|
||||||
#include <stasis/latches.h>
|
#include <stasis/latches.h>
|
||||||
|
@ -24,7 +21,7 @@
|
||||||
#include <stasis/truncation.h>
|
#include <stasis/truncation.h>
|
||||||
#include <stasis/io/handle.h>
|
#include <stasis/io/handle.h>
|
||||||
#include <stasis/blobManager.h> // XXX remove this, move Tread() to set.c
|
#include <stasis/blobManager.h> // XXX remove this, move Tread() to set.c
|
||||||
#include <stdio.h>
|
//#include <stdio.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
|
@ -53,33 +50,6 @@ void stasis_transaction_table_init() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// @todo this factory stuff doesn't really belong here...
|
|
||||||
static stasis_handle_t * fast_factory(lsn_t off, lsn_t len, void * ignored) {
|
|
||||||
stasis_handle_t * h = stasis_handle(open_memory)(off);
|
|
||||||
//h = stasis_handle(open_debug)(h);
|
|
||||||
stasis_write_buffer_t * w = h->append_buffer(h, len);
|
|
||||||
w->h->release_write_buffer(w);
|
|
||||||
return h;
|
|
||||||
}
|
|
||||||
typedef struct sf_args {
|
|
||||||
char * filename;
|
|
||||||
int openMode;
|
|
||||||
int filePerm;
|
|
||||||
} sf_args;
|
|
||||||
static stasis_handle_t * slow_file_factory(void * argsP) {
|
|
||||||
sf_args * args = (sf_args*) argsP;
|
|
||||||
stasis_handle_t * h = stasis_handle(open_file)(0, args->filename, args->openMode, args->filePerm);
|
|
||||||
//h = stasis_handle(open_debug)(h);
|
|
||||||
return h;
|
|
||||||
}
|
|
||||||
static stasis_handle_t * slow_pfile_factory(void * argsP) {
|
|
||||||
stasis_handle_t * h = argsP;
|
|
||||||
return h;
|
|
||||||
}
|
|
||||||
static int (*slow_close)(stasis_handle_t * h) = 0;
|
|
||||||
static stasis_handle_t * slow_pfile = 0;
|
|
||||||
static int nop_close(stasis_handle_t*h) { return 0; }
|
|
||||||
|
|
||||||
int Tinit() {
|
int Tinit() {
|
||||||
pthread_mutex_init(&stasis_transaction_table_mutex, NULL);
|
pthread_mutex_init(&stasis_transaction_table_mutex, NULL);
|
||||||
stasis_initted = 1;
|
stasis_initted = 1;
|
||||||
|
@ -101,81 +71,15 @@ int Tinit() {
|
||||||
}
|
}
|
||||||
stasis_page_init();
|
stasis_page_init();
|
||||||
|
|
||||||
#ifndef HAVE_O_DIRECT
|
if(bufferManagerFileHandleType == BUFFER_MANAGER_FILE_HANDLE_DEPRECATED) {
|
||||||
if(bufferManagerO_DIRECT) {
|
|
||||||
printf("O_DIRECT not supported by this build; switching to conventional buffered I/O.\n");
|
|
||||||
bufferManagerO_DIRECT = 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
int openMode;
|
|
||||||
if(bufferManagerO_DIRECT) {
|
|
||||||
#ifdef HAVE_O_DIRECT
|
|
||||||
openMode = O_CREAT | O_RDWR | O_DIRECT;
|
|
||||||
#else
|
|
||||||
printf("Can't happen\n");
|
|
||||||
abort();
|
|
||||||
#endif
|
|
||||||
} else {
|
|
||||||
openMode = O_CREAT | O_RDWR;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @todo remove hardcoding of buffer manager implementations in transactional2.c
|
|
||||||
|
|
||||||
switch(bufferManagerFileHandleType) {
|
|
||||||
case BUFFER_MANAGER_FILE_HANDLE_NON_BLOCKING: {
|
|
||||||
struct sf_args * slow_arg = malloc(sizeof(sf_args));
|
|
||||||
slow_arg->filename = stasis_store_file_name;
|
|
||||||
|
|
||||||
slow_arg->openMode = openMode;
|
|
||||||
|
|
||||||
slow_arg->filePerm = FILE_PERM;
|
|
||||||
// Allow 4MB of outstanding writes.
|
|
||||||
// @todo Where / how should we open storefile?
|
|
||||||
stasis_handle_t * pageFile;
|
|
||||||
int worker_thread_count = 4;
|
|
||||||
if(bufferManagerNonBlockingSlowHandleType == IO_HANDLE_PFILE) {
|
|
||||||
// printf("\nusing pread()/pwrite()\n");
|
|
||||||
slow_pfile = stasis_handle_open_pfile(0, slow_arg->filename, slow_arg->openMode, slow_arg->filePerm);
|
|
||||||
slow_close = slow_pfile->close;
|
|
||||||
slow_pfile->close = nop_close;
|
|
||||||
pageFile =
|
|
||||||
stasis_handle(open_non_blocking)(slow_pfile_factory, slow_pfile, 1, fast_factory,
|
|
||||||
NULL, worker_thread_count, PAGE_SIZE * 1024 , 1024);
|
|
||||||
|
|
||||||
} else if(bufferManagerNonBlockingSlowHandleType == IO_HANDLE_FILE) {
|
|
||||||
pageFile =
|
|
||||||
stasis_handle(open_non_blocking)(slow_file_factory, slow_arg, 0, fast_factory,
|
|
||||||
NULL, worker_thread_count, PAGE_SIZE * 1024, 1024);
|
|
||||||
} else {
|
|
||||||
printf("Unknown value for config option bufferManagerNonBlockingSlowHandleType\n");
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
//pageFile = stasis_handle(open_debug)(pageFile);
|
|
||||||
pageHandleOpen(pageFile);
|
|
||||||
} break;
|
|
||||||
case BUFFER_MANAGER_FILE_HANDLE_FILE: {
|
|
||||||
stasis_handle_t * pageFile =
|
|
||||||
stasis_handle_open_file(0, stasis_store_file_name,
|
|
||||||
openMode, FILE_PERM);
|
|
||||||
pageHandleOpen(pageFile);
|
|
||||||
} break;
|
|
||||||
case BUFFER_MANAGER_FILE_HANDLE_PFILE: {
|
|
||||||
stasis_handle_t * pageFile =
|
|
||||||
stasis_handle_open_pfile(0, stasis_store_file_name,
|
|
||||||
openMode, FILE_PERM);
|
|
||||||
pageHandleOpen(pageFile);
|
|
||||||
} break;
|
|
||||||
case BUFFER_MANAGER_FILE_HANDLE_DEPRECATED: {
|
|
||||||
printf("\nWarning: Using old I/O routines (with known bugs).\n");
|
printf("\nWarning: Using old I/O routines (with known bugs).\n");
|
||||||
openPageFile();
|
openPageFile();
|
||||||
} break;
|
} else {
|
||||||
default: {
|
stasis_handle_t * h = stasis_handle_open(stasis_store_file_name);
|
||||||
printf("\nUnknown buffer manager filehandle type: %d\n",
|
// XXX should not be global.
|
||||||
bufferManagerFileHandleType);
|
pageHandleOpen(h);
|
||||||
abort();
|
|
||||||
}
|
}
|
||||||
}
|
stasis_buffer_manager_open(bufferManagerType);
|
||||||
bufInit(bufferManagerType);
|
|
||||||
DEBUG("Buffer manager type = %d\n", bufferManagerType);
|
DEBUG("Buffer manager type = %d\n", bufferManagerType);
|
||||||
pageOperationsInit();
|
pageOperationsInit();
|
||||||
TallocInit();
|
TallocInit();
|
||||||
|
@ -441,14 +345,9 @@ int Tdeinit() {
|
||||||
stasis_truncation_deinit();
|
stasis_truncation_deinit();
|
||||||
TnaiveHashDeinit();
|
TnaiveHashDeinit();
|
||||||
TallocDeinit();
|
TallocDeinit();
|
||||||
bufDeinit();
|
stasis_buffer_manager_close();
|
||||||
DEBUG("Closing page file tdeinit\n");
|
DEBUG("Closing page file tdeinit\n");
|
||||||
closePageFile();
|
closePageFile();
|
||||||
if(slow_pfile) {
|
|
||||||
slow_close(slow_pfile);
|
|
||||||
slow_pfile = 0;
|
|
||||||
slow_close = 0;
|
|
||||||
}
|
|
||||||
stasis_page_deinit();
|
stasis_page_deinit();
|
||||||
stasis_log_file->close(stasis_log_file);
|
stasis_log_file->close(stasis_log_file);
|
||||||
dirtyPagesDeinit();
|
dirtyPagesDeinit();
|
||||||
|
@ -464,12 +363,8 @@ int TuncleanShutdown() {
|
||||||
stasis_suppress_unclean_shutdown_warnings = 1;
|
stasis_suppress_unclean_shutdown_warnings = 1;
|
||||||
stasis_truncation_deinit();
|
stasis_truncation_deinit();
|
||||||
TnaiveHashDeinit();
|
TnaiveHashDeinit();
|
||||||
simulateBufferManagerCrash();
|
stasis_buffer_manager_simulate_crash();
|
||||||
if(slow_pfile) {
|
// XXX: closePageFile?
|
||||||
slow_close(slow_pfile);
|
|
||||||
slow_pfile = 0;
|
|
||||||
slow_close = 0;
|
|
||||||
}
|
|
||||||
stasis_page_deinit();
|
stasis_page_deinit();
|
||||||
stasis_log_file->close(stasis_log_file);
|
stasis_log_file->close(stasis_log_file);
|
||||||
stasis_transaction_table_num_active = 0;
|
stasis_transaction_table_num_active = 0;
|
||||||
|
|
|
@ -99,7 +99,7 @@ Page * loadPage(int xid, pageid_t pageid);
|
||||||
Page * loadUninitializedPage(int xid, pageid_t pageid);
|
Page * loadUninitializedPage(int xid, pageid_t pageid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This is the function pointer that bufInit 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);
|
||||||
|
@ -111,7 +111,7 @@ extern Page * (*loadUninitPageImpl)(int xid, pageid_t pageid);
|
||||||
void releasePage(Page *p);
|
void releasePage(Page *p);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This is the function pointer that bufInit sets in order to
|
This is the function pointer that stasis_buffer_manager_open sets in order to
|
||||||
override releasePage.
|
override releasePage.
|
||||||
*/
|
*/
|
||||||
extern void (*releasePageImpl)(Page * p);
|
extern void (*releasePageImpl)(Page * p);
|
||||||
|
@ -146,14 +146,14 @@ extern void (*forcePages)();
|
||||||
This does not force page that have not been written to with pageWrite().
|
This does not force page that have not been written to with pageWrite().
|
||||||
*/
|
*/
|
||||||
extern void (*forcePageRange)(pageid_t start, pageid_t stop);
|
extern void (*forcePageRange)(pageid_t start, pageid_t stop);
|
||||||
extern void (*simulateBufferManagerCrash)();
|
extern void (*stasis_buffer_manager_simulate_crash)();
|
||||||
|
|
||||||
int bufInit(int type);
|
int stasis_buffer_manager_open(int type);
|
||||||
/**
|
/**
|
||||||
* will write out any dirty pages, assumes that there are no running
|
* will write out any dirty pages, assumes that there are no running
|
||||||
* transactions
|
* transactions
|
||||||
*/
|
*/
|
||||||
extern void (*bufDeinit)();
|
extern void (*stasis_buffer_manager_close)();
|
||||||
|
|
||||||
#ifdef PROFILE_LATCHES_WRITE_ONLY
|
#ifdef PROFILE_LATCHES_WRITE_ONLY
|
||||||
#define loadPage(x,y) __profile_loadPage((x), (y), __FILE__, __LINE__)
|
#define loadPage(x,y) __profile_loadPage((x), (y), __FILE__, __LINE__)
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
void bhBufInit();
|
void stasis_buffer_manager_hash_open();
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __STASIS_BUFFERMANAGER_LEGACY_LEGACYBUFFERMANAGER_H
|
#ifndef __STASIS_BUFFERMANAGER_LEGACY_LEGACYBUFFERMANAGER_H
|
||||||
#define __STASIS_BUFFERMANAGER_LEGACY_LEGACYBUFFERMANAGER_H
|
#define __STASIS_BUFFERMANAGER_LEGACY_LEGACYBUFFERMANAGER_H
|
||||||
int bufManBufInit();
|
int stasis_buffer_manager_deprecated_open();
|
||||||
#endif//__STASIS_BUFFERMANAGER_LEGACY_LEGACYBUFFERMANAGER_H
|
#endif//__STASIS_BUFFERMANAGER_LEGACY_LEGACYBUFFERMANAGER_H
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
void paBufInit();
|
void stasis_buffer_manager_mem_array_open();
|
||||||
|
|
|
@ -263,7 +263,7 @@ stasis_handle_t * stasis_handle(open_memory)(lsn_t start_offset);
|
||||||
@param perm The file permissions to be passed to open()
|
@param perm The file permissions to be passed to open()
|
||||||
*/
|
*/
|
||||||
stasis_handle_t * stasis_handle(open_file)
|
stasis_handle_t * stasis_handle(open_file)
|
||||||
(lsn_t start_offset, char * path, int flags, int perm);
|
(lsn_t start_offset, const char * path, int flags, int perm);
|
||||||
/**
|
/**
|
||||||
Open a handle that is backed by a file. This handle uses pread()
|
Open a handle that is backed by a file. This handle uses pread()
|
||||||
and pwrite(). It never holds a mutex while perfoming I/O.
|
and pwrite(). It never holds a mutex while perfoming I/O.
|
||||||
|
@ -278,7 +278,7 @@ stasis_handle_t * stasis_handle(open_file)
|
||||||
@param perm The file permissions to be passed to open()
|
@param perm The file permissions to be passed to open()
|
||||||
*/
|
*/
|
||||||
stasis_handle_t * stasis_handle(open_pfile)
|
stasis_handle_t * stasis_handle(open_pfile)
|
||||||
(lsn_t start_offset, char * path, int flags, int perm);
|
(lsn_t start_offset, const char * path, int flags, int perm);
|
||||||
/**
|
/**
|
||||||
Given a factory for creating "fast" and "slow" handles, provide a
|
Given a factory for creating "fast" and "slow" handles, provide a
|
||||||
handle that never makes callers wait for write requests to
|
handle that never makes callers wait for write requests to
|
||||||
|
@ -326,7 +326,9 @@ stasis_handle_t * stasis_handle(open_pfile)
|
||||||
before blocking.
|
before blocking.
|
||||||
*/
|
*/
|
||||||
stasis_handle_t * stasis_handle(open_non_blocking)
|
stasis_handle_t * stasis_handle(open_non_blocking)
|
||||||
(stasis_handle_t * (*slow_factory)(void * arg), void * slow_factory_arg,
|
(stasis_handle_t * (*slow_factory)(void * arg),
|
||||||
|
void (*slow_factory_close)(void * arg),
|
||||||
|
void * slow_factory_arg,
|
||||||
int slow_force_once,
|
int slow_force_once,
|
||||||
stasis_handle_t * (*fast_factory)(lsn_t off, lsn_t len, void * arg),
|
stasis_handle_t * (*fast_factory)(lsn_t off, lsn_t len, void * arg),
|
||||||
void * fast_factory_arg, int worker_thread_count, lsn_t buffer_size,
|
void * fast_factory_arg, int worker_thread_count, lsn_t buffer_size,
|
||||||
|
@ -341,5 +343,9 @@ stasis_handle_t * stasis_handle(open_verifying)(stasis_handle_t * h);
|
||||||
@param h All handle operations will be forwarded to h.
|
@param h All handle operations will be forwarded to h.
|
||||||
*/
|
*/
|
||||||
stasis_handle_t * stasis_handle(open_debug)(stasis_handle_t * h);
|
stasis_handle_t * stasis_handle(open_debug)(stasis_handle_t * h);
|
||||||
|
/**
|
||||||
|
* Open a Stasis file handle using default arguments.
|
||||||
|
*/
|
||||||
|
stasis_handle_t * stasis_handle(open)(const char * path);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -426,7 +426,7 @@ START_TEST(io_nonBlockingTest) {
|
||||||
FILE_PERM
|
FILE_PERM
|
||||||
};
|
};
|
||||||
|
|
||||||
h = stasis_handle(open_non_blocking)(slow_factory, &slow_args, 0,
|
h = stasis_handle(open_non_blocking)(slow_factory, 0, &slow_args, 0,
|
||||||
fast_factory, 0,
|
fast_factory, 0,
|
||||||
5, 1024*1024, 100);
|
5, 1024*1024, 100);
|
||||||
// h = stasis_handle(open_debug)(h);
|
// h = stasis_handle(open_debug)(h);
|
||||||
|
@ -435,7 +435,7 @@ START_TEST(io_nonBlockingTest) {
|
||||||
|
|
||||||
unlink("logfile.txt");
|
unlink("logfile.txt");
|
||||||
|
|
||||||
h = stasis_handle(open_non_blocking)(slow_factory, &slow_args, 0,
|
h = stasis_handle(open_non_blocking)(slow_factory, 0, &slow_args, 0,
|
||||||
fast_factory, 0,
|
fast_factory, 0,
|
||||||
5, 1024*1024, 100);
|
5, 1024*1024, 100);
|
||||||
//h = stasis_handle(open_debug)(h);
|
//h = stasis_handle(open_debug)(h);
|
||||||
|
@ -444,7 +444,7 @@ START_TEST(io_nonBlockingTest) {
|
||||||
|
|
||||||
unlink("logfile.txt");
|
unlink("logfile.txt");
|
||||||
|
|
||||||
h = stasis_handle(open_non_blocking)(slow_factory, &slow_args, 0,
|
h = stasis_handle(open_non_blocking)(slow_factory, 0, &slow_args, 0,
|
||||||
fast_factory, 0,
|
fast_factory, 0,
|
||||||
5, 1024 * 1024, 100);
|
5, 1024 * 1024, 100);
|
||||||
handle_concurrencytest(h);
|
handle_concurrencytest(h);
|
||||||
|
|
Loading…
Reference in a new issue