2007-11-22 21:11:21 +00:00
|
|
|
#include <assert.h>
|
2007-08-10 21:15:17 +00:00
|
|
|
#include <stdio.h>
|
2007-09-28 17:11:22 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
|
2007-11-21 21:41:57 +00:00
|
|
|
#include "yerror.h"
|
|
|
|
#include "log.h"
|
2007-08-10 21:15:17 +00:00
|
|
|
|
2007-10-19 17:05:10 +00:00
|
|
|
#define LOGGER_BUF_SIZE (1<<24)
|
2007-08-10 19:24:45 +00:00
|
|
|
struct tokulogger {
|
|
|
|
enum typ_tag tag;
|
|
|
|
char *directory;
|
2007-08-10 21:39:55 +00:00
|
|
|
int fd;
|
|
|
|
int n_in_file;
|
|
|
|
long long next_log_file_number;
|
2007-11-14 17:58:38 +00:00
|
|
|
LSN lsn;
|
2007-08-10 19:24:45 +00:00
|
|
|
char buf[LOGGER_BUF_SIZE];
|
|
|
|
int n_in_buf;
|
|
|
|
};
|
2007-08-10 21:15:17 +00:00
|
|
|
|
|
|
|
int tokulogger_find_next_unused_log_file(const char *directory, long long *result);
|
2007-11-23 18:27:50 +00:00
|
|
|
int tokulogger_find_logfiles (const char *directory, int *n_resultsp, char ***resultp);
|
2007-09-28 17:11:22 +00:00
|
|
|
|
2007-11-21 13:07:49 +00:00
|
|
|
enum lt_command {
|
2007-11-14 17:58:38 +00:00
|
|
|
LT_COMMIT = 'C',
|
|
|
|
LT_DELETE = 'D',
|
2007-11-19 23:47:44 +00:00
|
|
|
LT_FCREATE = 'F',
|
2007-11-21 13:07:49 +00:00
|
|
|
LT_FHEADER = 'H',
|
2007-11-14 17:58:38 +00:00
|
|
|
LT_INSERT_WITH_NO_OVERWRITE = 'I',
|
2007-11-21 19:06:32 +00:00
|
|
|
LT_NEWBRTNODE = 'N',
|
2007-11-20 21:20:05 +00:00
|
|
|
LT_FOPEN = 'O',
|
2007-11-14 17:58:38 +00:00
|
|
|
LT_CHECKPOINT = 'P',
|
2007-11-18 12:48:36 +00:00
|
|
|
LT_BLOCK_RENAME = 'R',
|
|
|
|
LT_UNLINK = 'U'
|
2007-11-14 17:58:38 +00:00
|
|
|
};
|
2007-09-28 17:11:22 +00:00
|
|
|
|
|
|
|
struct tokutxn {
|
|
|
|
u_int64_t txnid64;
|
|
|
|
TOKULOGGER logger;
|
2007-10-19 17:05:10 +00:00
|
|
|
TOKUTXN parent;
|
2007-09-28 17:11:22 +00:00
|
|
|
};
|
2007-11-22 07:13:08 +00:00
|
|
|
|
|
|
|
int tokulogger_finish (TOKULOGGER logger, struct wbuf *wbuf);
|
2007-11-22 18:45:22 +00:00
|
|
|
|
2007-11-23 17:16:26 +00:00
|
|
|
static inline int toku_logsizeof_u_int8_t (u_int32_t v __attribute__((__unused__))) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2007-11-22 18:45:22 +00:00
|
|
|
static inline int toku_logsizeof_u_int32_t (u_int32_t v __attribute__((__unused__))) {
|
|
|
|
return 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int toku_logsizeof_FILENUM (FILENUM v __attribute__((__unused__))) {
|
|
|
|
return 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int toku_logsizeof_DISKOFF (DISKOFF v __attribute__((__unused__))) {
|
|
|
|
return 8;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int toku_logsizeof_TXNID (TXNID txnid __attribute__((__unused__))) {
|
|
|
|
return 8;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int toku_logsizeof_BYTESTRING (BYTESTRING bs) {
|
2007-11-22 20:30:38 +00:00
|
|
|
return 4+bs.len;
|
2007-11-22 18:45:22 +00:00
|
|
|
}
|
|
|
|
|
2007-11-22 21:11:21 +00:00
|
|
|
static inline int toku_logsizeof_LOGGEDBRTHEADER (LOGGEDBRTHEADER bs) {
|
|
|
|
assert(bs.n_named_roots=0);
|
|
|
|
return 4+4+4+8+8+4+8;
|
|
|
|
}
|