root / lab4 / .minix-src / include / sys / wapbl_replay.h @ 13
History | View | Annotate | Download (5.61 KB)
1 | 13 | up20180614 | /* $NetBSD: wapbl_replay.h,v 1.1 2008/11/24 16:05:21 joerg Exp $ */
|
---|---|---|---|
2 | |||
3 | /*-
|
||
4 | * Copyright (c) 2003,2008 The NetBSD Foundation, Inc.
|
||
5 | * All rights reserved.
|
||
6 | *
|
||
7 | * This code is derived from software contributed to The NetBSD Foundation
|
||
8 | * by Wasabi Systems, Inc.
|
||
9 | *
|
||
10 | * Redistribution and use in source and binary forms, with or without
|
||
11 | * modification, are permitted provided that the following conditions
|
||
12 | * are met:
|
||
13 | * 1. Redistributions of source code must retain the above copyright
|
||
14 | * notice, this list of conditions and the following disclaimer.
|
||
15 | * 2. Redistributions in binary form must reproduce the above copyright
|
||
16 | * notice, this list of conditions and the following disclaimer in the
|
||
17 | * documentation and/or other materials provided with the distribution.
|
||
18 | *
|
||
19 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||
20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||
29 | * POSSIBILITY OF SUCH DAMAGE.
|
||
30 | */
|
||
31 | |||
32 | #ifndef _SYS_WAPBL_REPLAY_H
|
||
33 | #define _SYS_WAPBL_REPLAY_H
|
||
34 | |||
35 | #include <sys/types.h> |
||
36 | |||
37 | /* The WAPBL journal layout.
|
||
38 | *
|
||
39 | * The journal consists of a header followed by a circular buffer
|
||
40 | * region. The circular data area is described by the header
|
||
41 | * wc_circ_off, wc_circ_size, wc_head and wc_tail fields as bytes
|
||
42 | * from the start of the journal header. New records are inserted
|
||
43 | * at wc_head and the oldest valid record can be found at wc_tail.
|
||
44 | * When ((wc_head == wc_tail) && (wc_head == 0)), the journal is empty.
|
||
45 | * The condition of ((wc_head == wc_tail) && (wc_head != 0))
|
||
46 | * indicates a full journal, although this condition is rare.
|
||
47 | *
|
||
48 | * The journal header as well as its records are marked by a 32bit
|
||
49 | * type tag and length for ease of parsing. Journal records are
|
||
50 | * padded so as to fall on journal device block boundaries.
|
||
51 | */
|
||
52 | |||
53 | /*
|
||
54 | * The following are the 4 record types used by the journal:
|
||
55 | * Each tag indicates journal data organized by one of the
|
||
56 | * structures used below.
|
||
57 | */
|
||
58 | enum {
|
||
59 | WAPBL_WC_HEADER = 0x5741424c, /* "WABL", struct wapbl_wc_header */ |
||
60 | WAPBL_WC_INODES, /* struct wapbl_wc_inodelist */
|
||
61 | WAPBL_WC_REVOCATIONS, /* struct wapbl_wc_blocklist */
|
||
62 | WAPBL_WC_BLOCKS, /* struct wapbl_wc_blocklist */
|
||
63 | }; |
||
64 | |||
65 | /* null entry (on disk) */
|
||
66 | /* This structure isn't used directly, but shares its header
|
||
67 | * layout with all the other log structures for the purpose
|
||
68 | * of reading a log structure and determining its type
|
||
69 | */
|
||
70 | struct wapbl_wc_null {
|
||
71 | uint32_t wc_type; /* WAPBL_WC_* */
|
||
72 | int32_t wc_len; |
||
73 | uint8_t wc_spare[0]; /* actually longer */ |
||
74 | }; |
||
75 | |||
76 | /* journal header (on-disk)
|
||
77 | * This record is found at the start of the
|
||
78 | * journal, but not within the circular buffer region. As well as
|
||
79 | * describing the journal parameters and matching filesystem, it
|
||
80 | * additionally serves as the atomic update record for journal
|
||
81 | * updates.
|
||
82 | */
|
||
83 | struct wapbl_wc_header {
|
||
84 | uint32_t wc_type; /* WAPBL_WC_HEADER log magic number */
|
||
85 | int32_t wc_len; /* length of this journal entry */
|
||
86 | uint32_t wc_checksum; |
||
87 | uint32_t wc_generation; |
||
88 | int32_t wc_fsid[2];
|
||
89 | uint64_t wc_time; |
||
90 | uint32_t wc_timensec; |
||
91 | uint32_t wc_version; |
||
92 | uint32_t wc_log_dev_bshift; |
||
93 | uint32_t wc_fs_dev_bshift; |
||
94 | int64_t wc_head; |
||
95 | int64_t wc_tail; |
||
96 | int64_t wc_circ_off; /* offset of of circ buffer region */
|
||
97 | int64_t wc_circ_size; /* size of circular buffer region */
|
||
98 | uint8_t wc_spare[0]; /* actually longer */ |
||
99 | }; |
||
100 | |||
101 | /* list of blocks (on disk)
|
||
102 | * This record is used to describe a set of filesystem blocks,
|
||
103 | * and is used with two type tags, WAPBL_WC_BLOCKS and
|
||
104 | * WAPBL_WC_REVOCATIONS.
|
||
105 | *
|
||
106 | * For WAPBL_WC_BLOCKS, a copy of each listed block can be found
|
||
107 | * starting at the next log device blocksize boundary. starting at
|
||
108 | * one log device block since the start of the record. This contains
|
||
109 | * the bulk of the filesystem journal data which is written using
|
||
110 | * these records before being written into the filesystem.
|
||
111 | *
|
||
112 | * The WAPBL_WC_REVOCATIONS record is used to indicate that any
|
||
113 | * previously listed blocks should not be written into the filesystem.
|
||
114 | * This is important so that deallocated and reallocated data blocks
|
||
115 | * do not get overwritten with stale data from the journal. The
|
||
116 | * revocation records do not contain a copy of any actual block data.
|
||
117 | */
|
||
118 | struct wapbl_wc_blocklist {
|
||
119 | uint32_t wc_type; /* WAPBL_WC_{REVOCATIONS,BLOCKS} */
|
||
120 | int32_t wc_len; |
||
121 | int32_t wc_blkcount; |
||
122 | int32_t wc_unused; |
||
123 | struct {
|
||
124 | int64_t wc_daddr; |
||
125 | int32_t wc_unused; |
||
126 | int32_t wc_dlen; |
||
127 | } wc_blocks[0]; /* actually longer */ |
||
128 | }; |
||
129 | |||
130 | /* list of inodes (on disk)
|
||
131 | * This record is used to describe the set of inodes which
|
||
132 | * may be allocated but are unlinked. Inodes end up listed here
|
||
133 | * while they are in the process of being initialized and
|
||
134 | * deinitialized. Inodes unlinked while in use by a process
|
||
135 | * will be listed here and the actual deletion must be completed
|
||
136 | * on journal replay.
|
||
137 | */
|
||
138 | struct wapbl_wc_inodelist {
|
||
139 | uint32_t wc_type; /* WAPBL_WC_INODES */
|
||
140 | int32_t wc_len; |
||
141 | int32_t wc_inocnt; |
||
142 | int32_t wc_clear; /* set if previously listed inodes
|
||
143 | hould be ignored */
|
||
144 | struct {
|
||
145 | uint32_t wc_inumber; |
||
146 | uint32_t wc_imode; |
||
147 | } wc_inodes[0]; /* actually longer */ |
||
148 | }; |
||
149 | |||
150 | #endif /* _SYS_WAPBL_REPLAY_H */ |