From d7e56fc96ff426665cf9b1e1b32f6fed64d0ed56 Mon Sep 17 00:00:00 2001 From: Sears Russell Date: Mon, 22 Oct 2007 20:50:00 +0000 Subject: [PATCH] Added more buffer manager flags (allow programs to bypass non_blocking). --- benchmarks/sequentialThroughput.c | 16 +++++++++-- src/stasis/transactional2.c | 48 +++++++++++++++++++------------ stasis/constants.h | 4 ++- 3 files changed, 46 insertions(+), 22 deletions(-) diff --git a/benchmarks/sequentialThroughput.c b/benchmarks/sequentialThroughput.c index 5763121..cdf9d94 100644 --- a/benchmarks/sequentialThroughput.c +++ b/benchmarks/sequentialThroughput.c @@ -46,9 +46,21 @@ int main(int argc, char ** argv) { } else if(!strcmp(argv[i], "--deprecatedFH")) { bufferManagerFileHandleType = BUFFER_MANAGER_FILE_HANDLE_DEPRECATED; legacyFH = 1; - } else if(!strcmp(argv[i], "--pfile")) { - bufferManagerNonBlockingSlowHandleType = IO_HANDLE_PFILE; + } else if(!strcmp(argv[i], "--nb")) { + bufferManagerFileHandleType = BUFFER_MANAGER_FILE_HANDLE_NON_BLOCKING; + legacyBM = 0; + legacyFH = 0; } else if(!strcmp(argv[i], "--file")) { + bufferManagerFileHandleType = BUFFER_MANAGER_FILE_HANDLE_FILE; + legacyBM = 0; + legacyFH = 0; + } else if(!strcmp(argv[i], "--pfile")) { + bufferManagerFileHandleType = BUFFER_MANAGER_FILE_HANDLE_PFILE; + legacyBM = 0; + legacyFH = 0; + } else if(!strcmp(argv[i], "--nb_pfile")) { + bufferManagerNonBlockingSlowHandleType = IO_HANDLE_PFILE; + } else if(!strcmp(argv[i], "--nb_file")) { bufferManagerNonBlockingSlowHandleType = IO_HANDLE_FILE; } else if(!strcmp(argv[i], "--mb")) { i++; diff --git a/src/stasis/transactional2.c b/src/stasis/transactional2.c index 4672197..0ca2707 100644 --- a/src/stasis/transactional2.c +++ b/src/stasis/transactional2.c @@ -136,27 +136,29 @@ int Tinit() { LogInit(loggerType); stasis_page_init(); +#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; + } switch(bufferManagerFileHandleType) { case BUFFER_MANAGER_FILE_HANDLE_NON_BLOCKING: { struct sf_args * slow_arg = malloc(sizeof(sf_args)); slow_arg->filename = STORE_FILE; -#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 - if(bufferManagerO_DIRECT) { -#ifdef HAVE_O_DIRECT - slow_arg->openMode = O_CREAT | O_RDWR | O_DIRECT; -#else - printf("Can't happen\n"); - abort(); -#endif - } else { - slow_arg->openMode = O_CREAT | O_RDWR; - } + slow_arg->openMode = openMode; slow_arg->filePerm = FILE_PERM; // Allow 4MB of outstanding writes. @@ -183,7 +185,17 @@ int Tinit() { //pageFile = stasis_handle(open_debug)(pageFile); pageHandleOpen(pageFile); } break; - case BUFFER_MANAGER_FILE_HANDLE_DEPRECATED: { + case BUFFER_MANAGER_FILE_HANDLE_FILE: { + stasis_handle_t * pageFile = + stasis_handle_open_file(0, STORE_FILE, openMode, FILE_PERM); + pageHandleOpen(pageFile); + } break; + case BUFFER_MANAGER_FILE_HANDLE_PFILE: { + stasis_handle_t * pageFile = + stasis_handle_open_pfile(0, STORE_FILE, openMode, FILE_PERM); + pageHandleOpen(pageFile); + } break; + case BUFFER_MANAGER_FILE_HANDLE_DEPRECATED: { printf("\nWarning: Using old I/O routines (with known bugs).\n"); openPageFile(); } break; @@ -193,8 +205,6 @@ int Tinit() { abort(); } } - //#else - //#endif // USE_PAGEFILE bufInit(bufferManagerType); DEBUG("Buffer manager type = %d\n", bufferManagerType); pageOperationsInit(); diff --git a/stasis/constants.h b/stasis/constants.h index 5598d0e..c05c07d 100644 --- a/stasis/constants.h +++ b/stasis/constants.h @@ -97,7 +97,9 @@ terms specified in this license. #define BUFFER_MANAGER_DEPRECATED_HASH 3 #define BUFFER_MANAGER_FILE_HANDLE_NON_BLOCKING 0 -#define BUFFER_MANAGER_FILE_HANDLE_DEPRECATED 1 +#define BUFFER_MANAGER_FILE_HANDLE_FILE 1 +#define BUFFER_MANAGER_FILE_HANDLE_PFILE 2 +#define BUFFER_MANAGER_FILE_HANDLE_DEPRECATED 3 #define IO_HANDLE_FILE 1 #define IO_HANDLE_PFILE 2