Whamcloud - gitweb
LUDOC 299 protocol: Spell-check document
[doc/protocol.git] / struct_llog_log_hdr.txt
1 LLOG Log Header
2 ^^^^^^^^^^^^^^^
3 [[struct-llog-log-hdr]]
4
5 [source,c]
6 ----
7 struct llog_log_hdr {
8         struct llog_rec_hdr     llh_hdr;
9         obd_time                llh_timestamp;
10         __u32                   llh_count;
11         __u32                   llh_bitmap_offset;
12         __u32                   llh_size;
13         __u32                   llh_flags;
14         __u32                   llh_cat_idx;
15         /* for a catalog the first plain slot is next to it */
16         struct obd_uuid         llh_tgtuuid;
17         __u32                   llh_reserved[LLOG_HEADER_SIZE/sizeof(__u32) - 23];
18         __u32                   llh_bitmap[LLOG_BITMAP_BYTES/sizeof(__u32)];
19         struct llog_rec_tail    llh_tail;
20 };
21 ----
22
23 The llog records start and end on a record size boundary, typically
24 8192 bytes, or as stored in 'llh_size', which allows some degree of
25 random access within the llog file, even with variable record sizes.
26 It is possible to interpolate the offset of an arbitrary record
27 within the file by estimating the byte offset of a particular record
28 index using 'llh_count' and the llog file size and aligning it to
29 the chunk boundary 'llh_size'.  The record index in the 'llog_rec_hdr'
30 of the first record in that chunk can be used to further refine the
31 estimate of the offset of the desired index down to a single chunk,
32 and then sequential access can be used to find the actual record.
33
34
35 Each llog file begins with an 'llog_log_hdr' that describes the llog
36 file itself, followed by a series of log records that are appended
37 sequentially to the file.  Each record, including the header itself,
38 begins with an 'llog_rec_hdr' and ends with an 'llog_rec_tail'.
39
40
41 The lgd_llh_flags are:
42
43 .LLog Flags
44 ****
45 [source,c]
46 ----
47 enum llog_flag {
48         LLOG_F_ZAP_WHEN_EMPTY   = 0x1,
49         LLOG_F_IS_CAT           = 0x2,
50         LLOG_F_IS_PLAIN         = 0x4,
51 };
52 ----
53 ****
54
55 .LLog Record Header
56 [[struct-llog-rec-hdr]]
57 ****
58 [source,c]
59 ----
60 struct llog_rec_hdr {
61         __u32   lrh_len;
62         __u32   lrh_index;
63         __u32   lrh_type;
64         __u32   lrh_id;
65 };
66 ----
67 ****
68
69 The 'llog_rec_hdr' is at the start of each llog record and describes
70 the log record.  'lrh_len' holds the record size in bytes, including
71 the header and tail.  'lrh_index' is the record index within the llog
72 file and is sequentially increasing for each subsequent record.  It
73 can be used to determine the offset within the llog file when searching
74 for an arbitrary record within the file. 'lrh_type' describes the type
75 of data stored in this record.
76
77 .LLog Operation Type
78 ****
79 [source,c]
80 ----
81 enum llog_op_type {
82         LLOG_PAD_MAGIC          = LLOG_OP_MAGIC | 0x00000,
83         OST_SZ_REC              = LLOG_OP_MAGIC | 0x00f00,
84         MDS_UNLINK64_REC        = LLOG_OP_MAGIC | 0x90000 | (MDS_REINT << 8) |
85                                   REINT_UNLINK,
86         MDS_SETATTR64_REC       = LLOG_OP_MAGIC | 0x90000 | (MDS_REINT << 8) |
87                                   REINT_SETATTR,
88         OBD_CFG_REC             = LLOG_OP_MAGIC | 0x20000,
89         LLOG_GEN_REC            = LLOG_OP_MAGIC | 0x40000,
90         CHANGELOG_REC           = LLOG_OP_MAGIC | 0x60000,
91         CHANGELOG_USER_REC      = LLOG_OP_MAGIC | 0x70000,
92         HSM_AGENT_REC           = LLOG_OP_MAGIC | 0x80000,
93         UPDATE_REC              = LLOG_OP_MAGIC | 0xa0000,
94         LLOG_HDR_MAGIC          = LLOG_OP_MAGIC | 0x45539,
95         LLOG_LOGID_MAGIC        = LLOG_OP_MAGIC | 0x4553b,
96 };
97 ----
98 ****
99
100 .LLog Record Tail
101 [[struct-llog-rec-tail]]
102 ****
103 [source,c]
104 ----
105 struct llog_rec_tail {
106         __u32   lrt_len;
107         __u32   lrt_index;
108 };
109 ----
110 ****
111
112 The 'llog_rec_tail' is at the end of each llog record.  The 'lrt_len'
113 and 'lrt_index' fields must be the same as 'lrh_len' and 'lrh_index'
114 in the header.  They can be used to verify record integrity, as well
115 as allowing processing the llog records in reverse order.
116