mirror of
https://github.com/MariaDB/server.git
synced 2025-01-22 06:44:16 +01:00
imp toku_file_fsync in the port layer closes[t:1748]
git-svn-id: file:///svn/toku/tokudb@15805 c7de825b-a66e-492c-adef-691d508d4ae1
This commit is contained in:
parent
357ebc950d
commit
e8a671d611
5 changed files with 43 additions and 16 deletions
17
linux/file.c
17
linux/file.c
|
@ -82,3 +82,20 @@ again:
|
|||
return r;
|
||||
}
|
||||
|
||||
static int (*t_fsync)(int) = 0;
|
||||
|
||||
int
|
||||
toku_set_func_fsync(int (*fsync_function)(int)) {
|
||||
t_fsync = fsync_function;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
toku_file_fsync(int fd) {
|
||||
int r;
|
||||
if (t_fsync)
|
||||
r = t_fsync(fd);
|
||||
else
|
||||
r = fsync(fd);
|
||||
return r;
|
||||
}
|
||||
|
|
|
@ -2186,9 +2186,10 @@ void *toku_cachefile_get_userdata(CACHEFILE cf) {
|
|||
int
|
||||
toku_cachefile_fsync(CACHEFILE cf) {
|
||||
int r;
|
||||
|
||||
if (toku_cachefile_is_dev_null(cf)) r = 0; //Don't fsync /dev/null
|
||||
else r = fsync(cf->fd);
|
||||
if (toku_cachefile_is_dev_null(cf))
|
||||
r = 0; //Don't fsync /dev/null
|
||||
else
|
||||
r = toku_file_fsync(cf->fd);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,11 +10,6 @@ static const int log_format_version=TOKU_LOG_VERSION;
|
|||
static toku_pthread_mutex_t logger_mutex = TOKU_PTHREAD_MUTEX_INITIALIZER;
|
||||
static u_int32_t logger_lock_ctr = 0; // useful for debug at a live installation
|
||||
|
||||
static int toku_fsync(int UU(fd)) {
|
||||
return fsync(fd);
|
||||
}
|
||||
|
||||
static int (*toku_os_fsync_function)(int)=toku_fsync;
|
||||
static int open_logfile (TOKULOGGER logger);
|
||||
static int toku_logger_write_buffer (TOKULOGGER logger, int do_fsync);
|
||||
static int delete_logfile(TOKULOGGER logger, long long index);
|
||||
|
@ -170,7 +165,7 @@ static int write_it (int fd, const void *bufv, int nbytes) {
|
|||
static int close_and_open_logfile (TOKULOGGER logger) {
|
||||
int r;
|
||||
if (logger->write_log_files) {
|
||||
r = toku_os_fsync_function(logger->fd); if (r!=0) return errno;
|
||||
r = toku_file_fsync(logger->fd); if (r!=0) return errno;
|
||||
assert(logger->fsynced_lsn.lsn <= logger->written_lsn.lsn);
|
||||
logger->fsynced_lsn = logger->written_lsn;
|
||||
}
|
||||
|
@ -480,7 +475,7 @@ int toku_logger_maybe_fsync (TOKULOGGER logger, LSN lsn, int do_fsync)
|
|||
logger->fsynced_lsn = logger->outbuf.max_lsn_in_buf;
|
||||
} else {
|
||||
assert(logger->fsynced_lsn.lsn < logger->written_lsn.lsn); // the fsynced_lsn was less than lsn, but not less than the written lsn?
|
||||
r = toku_os_fsync_function(logger->fd);
|
||||
r = toku_file_fsync(logger->fd);
|
||||
if (r!=0) { r = errno; goto panic; }
|
||||
logger->fsynced_lsn = logger->written_lsn;
|
||||
}
|
||||
|
@ -532,7 +527,7 @@ toku_logger_write_buffer (TOKULOGGER logger, int do_fsync)
|
|||
r = close_and_open_logfile(logger); if (r!=0) goto panic;
|
||||
logger->fsynced_lsn = logger->outbuf.max_lsn_in_buf;
|
||||
} else if (do_fsync) {
|
||||
r = toku_os_fsync_function(logger->fd);
|
||||
r = toku_file_fsync(logger->fd);
|
||||
logger->fsynced_lsn = logger->outbuf.max_lsn_in_buf;
|
||||
} else {
|
||||
/* nothing */
|
||||
|
@ -947,11 +942,6 @@ int toku_txnid2txn (TOKULOGGER logger, TXNID txnid, TOKUTXN *result) {
|
|||
return rval;
|
||||
}
|
||||
|
||||
int toku_set_func_fsync (int (*fsync_function)(int)) {
|
||||
toku_os_fsync_function = fsync_function;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Find the earliest LSN in a log
|
||||
static int peek_at_log (TOKULOGGER logger, char* filename, LSN *first_lsn) {
|
||||
logger=logger;
|
||||
|
|
|
@ -121,6 +121,8 @@ void *os_realloc(void*,size_t);
|
|||
void os_free(void*);
|
||||
ssize_t toku_os_pwrite (int fd, const void *buf, size_t len, toku_off_t off);
|
||||
ssize_t toku_os_write (int fd, const void *buf, size_t len);
|
||||
int toku_file_fsync(int fd);
|
||||
int toku_get_fsync_times(void);
|
||||
|
||||
int toku_set_func_fsync (int (*fsync_function)(int));
|
||||
int toku_set_func_malloc (void *(*)(size_t));
|
||||
|
|
|
@ -108,3 +108,20 @@ toku_os_pwrite (int fd, const void *buf, size_t len, toku_off_t off)
|
|||
}
|
||||
}
|
||||
|
||||
static int (*t_fsync)(int) = 0;
|
||||
|
||||
int
|
||||
toku_set_func_fsync(int (*fsync_function)(int)) {
|
||||
t_fsync = fsync_function;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
toku_file_fsync(int fd) {
|
||||
int r;
|
||||
if (t_fsync)
|
||||
r = t_fsync(fd);
|
||||
else
|
||||
r = fsync(fd);
|
||||
return r;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue