Commit 7f7555dc authored by Bradley C. Kuszmaul's avatar Bradley C. Kuszmaul

fopen dumps OK, brtheader fails. Addresses #11

git-svn-id: file:///svn/tokudb@719 c7de825b-a66e-492c-adef-691d508d4ae1
parent cc9aebfd
......@@ -34,4 +34,15 @@ typedef struct tokulogger *TOKULOGGER;
typedef struct tokutxn *TOKUTXN;
#define NULL_TXN ((TOKUTXN)0)
// The data that appears in the log to encode a brtheader. */
typedef struct loggedbrtheader {
u_int32_t size;
u_int32_t flags;
u_int32_t nodesize;
DISKOFF freelist;
DISKOFF unused_memory;
u_int32_t n_named_roots;
DISKOFF root;
} LOGGEDBRTHEADER;
#endif
#include <assert.h>
#include <stdio.h>
#include <sys/types.h>
......@@ -59,3 +60,7 @@ static inline int toku_logsizeof_BYTESTRING (BYTESTRING bs) {
return 4+bs.len;
}
static inline int toku_logsizeof_LOGGEDBRTHEADER (LOGGEDBRTHEADER bs) {
assert(bs.n_named_roots=0);
return 4+4+4+8+8+4+8;
}
......@@ -479,6 +479,19 @@ int toku_fread_BYTESTRING (FILE *f, BYTESTRING *bs, u_int32_t *crc, u_int32_t *l
return 0;
}
int toku_fread_LOGGEDBRTHEADER(FILE *f, LOGGEDBRTHEADER *v, u_int32_t *crc, u_int32_t *len) {
int r;
r = toku_fread_u_int32_t(f, &v->size, crc, len); if (r!=0) return r;
r = toku_fread_u_int32_t(f, &v->flags, crc, len); if (r!=0) return r;
r = toku_fread_u_int32_t(f, &v->nodesize, crc, len); if (r!=0) return r;
r = toku_fread_DISKOFF (f, &v->freelist, crc, len); if (r!=0) return r;
r = toku_fread_DISKOFF (f, &v->unused_memory, crc, len); if (r!=0) return r;
r = toku_fread_u_int32_t(f, &v->n_named_roots, crc, len); if (r!=0) return r;
assert(v->n_named_roots==0);
r = toku_fread_DISKOFF (f, &v->root, crc, len); if (r!=0) return r;
return 0;
}
int toku_logprint_LSN (FILE *outf, FILE *inf, const char *fieldname, u_int32_t *crc, u_int32_t *len) {
LSN v;
int r = toku_fread_LSN(inf, &v, crc, len);
......@@ -531,4 +544,11 @@ int toku_logprint_DISKOFF (FILE *outf, FILE *inf, const char *fieldname, u_int32
fprintf(outf, " %s=%lld", fieldname, v);
return 0;
}
int toku_logprint_MODE_T (FILE *outf, FILE *inf, u_int32_t *crc, u_int32_t *len);
int toku_logprint_LOGGEDBRTHEADER (FILE *outf, FILE *inf, const char *fieldname, u_int32_t *crc, u_int32_t *len) {
LOGGEDBRTHEADER v;
int r = toku_fread_LOGGEDBRTHEADER(inf, &v, crc, len);
if (r!=0) return r;
fprintf(outf, " %s={size=%d flags=%d nodesize=%d freelist=%lld unused_memory=%lld n_named_roots=%d", fieldname, v.size, v.flags, v.nodesize, v.freelist, v.unused_memory, v.n_named_roots);
return 0;
}
......@@ -36,14 +36,14 @@ int toku_fread_DISKOFF (FILE *f, DISKOFF *diskoff, u_int32_t *crc, u_int32_t *le
int toku_fread_TXNID (FILE *f, TXNID *txnid, u_int32_t *crc, u_int32_t *len);
// fills in the bs with malloced data.
int toku_fread_BYTESTRING (FILE *f, BYTESTRING *bs, u_int32_t *crc, u_int32_t *len);
int toku_logprint_LSN (FILE *outf, FILE *inf, const char *fieldname, u_int32_t *crc, u_int32_t *len);
int toku_logprint_TXNID (FILE *outf, FILE *inf, const char *fieldname, u_int32_t *crc, u_int32_t *len);
int toku_logprint_BYTESTRING (FILE *outf, FILE *inf, const char *fieldname, u_int32_t *crc, u_int32_t *len);
int toku_logprint_FILENUM (FILE *outf, FILE *inf, const char *fieldname, u_int32_t *crc, u_int32_t *len);
int toku_logprint_DISKOFF (FILE *outf, FILE *inf, const char *fieldname, u_int32_t *crc, u_int32_t *len);
int toku_logprint_u_int32_t (FILE *outf, FILE *inf, const char *fieldname, u_int32_t *crc, u_int32_t *len);
int toku_fread_LOGGEDBRTHEADER(FILE *f, LOGGEDBRTHEADER *v, u_int32_t *crc, u_int32_t *len);
int toku_logprint_LSN (FILE *outf, FILE *inf, const char *fieldname, u_int32_t *crc, u_int32_t *len);
int toku_logprint_TXNID (FILE *outf, FILE *inf, const char *fieldname, u_int32_t *crc, u_int32_t *len);
int toku_logprint_BYTESTRING (FILE *outf, FILE *inf, const char *fieldname, u_int32_t *crc, u_int32_t *len);
int toku_logprint_FILENUM (FILE *outf, FILE *inf, const char *fieldname, u_int32_t *crc, u_int32_t *len);
int toku_logprint_DISKOFF (FILE *outf, FILE *inf, const char *fieldname, u_int32_t *crc, u_int32_t *len);
int toku_logprint_u_int32_t (FILE *outf, FILE *inf, const char *fieldname, u_int32_t *crc, u_int32_t *len);
int toku_logprint_LOGGEDBRTHEADER (FILE *outf, FILE *inf, const char *fieldname, u_int32_t *crc, u_int32_t *len);
#endif
......@@ -30,16 +30,25 @@ struct logtype {
// In the fields, don't mention the command, the LSN, the CRC or the trailing LEN.
const struct logtype logtypes[] = {
{"fcreate", 'F', FA{{"TXNID", "txnid"},
{"BYTESTRING", "fname"},
{"u_int32_t", "mode"},
NULLFIELD}},
{"commit", 'C', FA{{"TXNID", "txnid"},NULLFIELD}},
{"delete", 'D', FA{{"FILENUM", "filenum"},
{"DISKOFF", "diskoff"},
{"BYTESTRING", "key"},
{"BYTESTRING", "data"},
NULLFIELD}},
{"commit", 'C', FA{{"TXNID", "txnid"},NULLFIELD}},
{"fcreate", 'F', FA{{"TXNID", "txnid"},
{"BYTESTRING", "fname"},
{"u_int32_t", "mode"},
NULLFIELD}},
{"fheader", 'H', FA{{"TXNID", "txnid"},
{"FILENUM", "filenum"},
{"LOGGEDBRTHEADER", "header"},
NULLFIELD}},
{"fopen", 'O', FA{{"TXNID", "txnid"},
{"BYTESTRING", "fname"},
{"FILENUM", "filenum"},
NULLFIELD}},
{0,0,FA{NULLFIELD}}
};
......
......@@ -113,4 +113,15 @@ static inline void wbuf_FILENUM (struct wbuf *w, FILENUM fileid) {
wbuf_int(w, fileid.fileid);
}
static inline void wbuf_LOGGEDBRTHEADER (struct wbuf *w, LOGGEDBRTHEADER h) {
wbuf_int(w, h.size);
wbuf_int(w, h.flags);
wbuf_int(w, h.nodesize);
wbuf_DISKOFF(w, h.freelist);
wbuf_DISKOFF(w, h.unused_memory);
wbuf_int(w, h.n_named_roots);
assert(h.n_named_roots==0);
wbuf_DISKOFF(w, h.root);
}
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment