#ifndef _JIO_JOURNALS_H #define _JIO_JOURNALS_H #include /* open() includes since journals_open() reuses open() flags */ #include #include #include #include "thunk.h" #include "upstream/journal-def.h" /* TODO: the journal buf stuff should be made private to journals.c */ #define JOURNAL_BUF_SIZE 8192 #define JOURNAL_BUF_CNT 8 typedef struct iou_t iou_t; typedef struct journals_t journals_t; typedef struct journal_t journal_t; typedef struct journal_buf_t journal_buf_t; struct journal_buf_t { journal_buf_t *lru_prev, *lru_next; uint64_t offset, length; unsigned valid:1; int idx; uint8_t data[JOURNAL_BUF_SIZE]; }; struct journal_t { char *name; int fd, idx; journal_buf_t *lru_head, *lru_tail; journal_buf_t bufs[JOURNAL_BUF_CNT]; }; THUNK_DECLARE(journals_open, iou_t *, iou, char **, machid, int, flags, journals_t **, journals, thunk_t *, closure); THUNK_DECLARE(journal_get_header, iou_t *, iou, journal_t **, journal, Header *, header, thunk_t *, closure); THUNK_DECLARE(journal_iter_next_object, iou_t *, iou, journal_t **, journal, Header *, header, uint64_t *, iter_offset, ObjectHeader *, iter_object_header, thunk_t *, closure); THUNK_DECLARE(journal_iter_objects, iou_t *, iou, journal_t **, journal, Header *, header, uint64_t *, iter_offset, ObjectHeader *, iter_object_header, thunk_t *, closure); THUNK_DECLARE(journal_get_hash_table, iou_t *, iou, journal_t **, journal, uint64_t *, hash_table_offset, uint64_t *, hash_table_size, HashItem **, res_hash_table, thunk_t *, closure); THUNK_DECLARE(journal_hash_table_iter_next_object, iou_t *, iou, journal_t **, journal, HashItem **, hash_table, uint64_t *, hash_table_size, uint64_t *, iter_bucket, uint64_t *, iter_offset, HashedObjectHeader *, iter_object_header, size_t, iter_object_size, thunk_t *, closure); THUNK_DECLARE(journal_hash_table_for_each, iou_t *, iou, journal_t **, journal, HashItem **, hash_table, uint64_t *, hash_table_size, uint64_t *, iter_bucket, uint64_t *, iter_offset, HashedObjectHeader *, iter_object_header, size_t, iter_object_size, thunk_t *, closure); THUNK_DECLARE(journal_get_object_header, iou_t *, iou, journal_t **, journal, uint64_t *, offset, ObjectHeader *, object_header, thunk_t *, closure); THUNK_DECLARE(journal_get_object, iou_t *, iou, journal_t **, journal, uint64_t *, offset, uint64_t *, size, Object **, object, thunk_t *, closure); THUNK_DECLARE(journal_get_object_full, iou_t *, iou, journal_t **, journal, uint64_t *, offset, ObjectHeader *, object_header, Object **, object, thunk_t *, closure); THUNK_DECLARE(journals_for_each, journals_t **, journals, journal_t **, journal_iter, thunk_t *, closure); const char * journal_object_type_str(ObjectType type); const char * journal_state_str(JournalState state); int journal_read(iou_t *iou, journal_t *journal, uint64_t offset, uint64_t length, void *dest, thunk_t *closure); #endif