-
Notifications
You must be signed in to change notification settings - Fork 6
/
log-writes.h
71 lines (58 loc) · 1.53 KB
/
log-writes.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#ifndef _LOG_WRITES_H_
#define _LOG_WRITES_H_
#include <linux/types.h>
#include <linux/byteorder/little_endian.h>
extern int log_writes_verbose;
#define le64_to_cpu __le64_to_cpu
#define le32_to_cpu __le32_to_cpu
typedef __u64 u64;
typedef __u32 u32;
#define LOG_FLUSH_FLAG (1 << 0)
#define LOG_FUA_FLAG (1 << 1)
#define LOG_DISCARD_FLAG (1 << 2)
#define LOG_MARK_FLAG (1 << 3)
#define LOG_METADATA_FLAG (1 << 4)
#define WRITE_LOG_VERSION 1
#define WRITE_LOG_MAGIC 0x6a736677736872
/*
* Basic info about the log for userspace.
*/
struct log_write_super {
__le64 magic;
__le64 version;
__le64 nr_entries;
__le32 sectorsize;
};
/*
* sector - the sector we wrote.
* nr_sectors - the number of sectors we wrote.
* flags - flags for this log entry.
* data_len - the size of the data in this log entry, this is for private log
* entry stuff, the MARK data provided by userspace for example.
*/
struct log_write_entry {
__le64 sector;
__le64 nr_sectors;
__le64 flags;
__le64 data_len;
};
#define LOG_IGNORE_DISCARD (1 << 0)
#define LOG_DISCARD_NOT_SUPP (1 << 1)
struct log {
int logfd;
int replayfd;
unsigned long flags;
u64 sectorsize;
u64 nr_entries;
u64 cur_entry;
u64 max_zero_size;
off_t cur_pos;
};
struct log *log_open(char *logfile, char *replayfile);
int log_replay_next_entry(struct log *log, struct log_write_entry *entry,
int read_data);
int log_seek_entry(struct log *log, u64 entry_num);
int log_seek_next_entry(struct log *log, struct log_write_entry *entry,
int read_data);
void log_free(struct log *log);
#endif