• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * This file is auto-generated. Modifications will be lost.
3  *
4  * See https://android.googlesource.com/platform/bionic/+/master/libc/kernel/
5  * for more information.
6  */
7 #ifndef _MD_P_H
8 #define _MD_P_H
9 #include <linux/types.h>
10 #include <asm/byteorder.h>
11 #define MD_RESERVED_BYTES (64 * 1024)
12 #define MD_RESERVED_SECTORS (MD_RESERVED_BYTES / 512)
13 #define MD_NEW_SIZE_SECTORS(x) ((x & ~(MD_RESERVED_SECTORS - 1)) - MD_RESERVED_SECTORS)
14 #define MD_SB_BYTES 4096
15 #define MD_SB_WORDS (MD_SB_BYTES / 4)
16 #define MD_SB_SECTORS (MD_SB_BYTES / 512)
17 #define MD_SB_GENERIC_OFFSET 0
18 #define MD_SB_PERSONALITY_OFFSET 64
19 #define MD_SB_DISKS_OFFSET 128
20 #define MD_SB_DESCRIPTOR_OFFSET 992
21 #define MD_SB_GENERIC_CONSTANT_WORDS 32
22 #define MD_SB_GENERIC_STATE_WORDS 32
23 #define MD_SB_GENERIC_WORDS (MD_SB_GENERIC_CONSTANT_WORDS + MD_SB_GENERIC_STATE_WORDS)
24 #define MD_SB_PERSONALITY_WORDS 64
25 #define MD_SB_DESCRIPTOR_WORDS 32
26 #define MD_SB_DISKS 27
27 #define MD_SB_DISKS_WORDS (MD_SB_DISKS * MD_SB_DESCRIPTOR_WORDS)
28 #define MD_SB_RESERVED_WORDS (1024 - MD_SB_GENERIC_WORDS - MD_SB_PERSONALITY_WORDS - MD_SB_DISKS_WORDS - MD_SB_DESCRIPTOR_WORDS)
29 #define MD_SB_EQUAL_WORDS (MD_SB_GENERIC_WORDS + MD_SB_PERSONALITY_WORDS + MD_SB_DISKS_WORDS)
30 #define MD_DISK_FAULTY 0
31 #define MD_DISK_ACTIVE 1
32 #define MD_DISK_SYNC 2
33 #define MD_DISK_REMOVED 3
34 #define MD_DISK_CLUSTER_ADD 4
35 #define MD_DISK_CANDIDATE 5
36 #define MD_DISK_FAILFAST 10
37 #define MD_DISK_WRITEMOSTLY 9
38 #define MD_DISK_JOURNAL 18
39 #define MD_DISK_ROLE_SPARE 0xffff
40 #define MD_DISK_ROLE_FAULTY 0xfffe
41 #define MD_DISK_ROLE_JOURNAL 0xfffd
42 #define MD_DISK_ROLE_MAX 0xff00
43 typedef struct mdp_device_descriptor_s {
44   __u32 number;
45   __u32 major;
46   __u32 minor;
47   __u32 raid_disk;
48   __u32 state;
49   __u32 reserved[MD_SB_DESCRIPTOR_WORDS - 5];
50 } mdp_disk_t;
51 #define MD_SB_MAGIC 0xa92b4efc
52 #define MD_SB_CLEAN 0
53 #define MD_SB_ERRORS 1
54 #define MD_SB_CLUSTERED 5
55 #define MD_SB_BITMAP_PRESENT 8
56 typedef struct mdp_superblock_s {
57   __u32 md_magic;
58   __u32 major_version;
59   __u32 minor_version;
60   __u32 patch_version;
61   __u32 gvalid_words;
62   __u32 set_uuid0;
63   __u32 ctime;
64   __u32 level;
65   __u32 size;
66   __u32 nr_disks;
67   __u32 raid_disks;
68   __u32 md_minor;
69   __u32 not_persistent;
70   __u32 set_uuid1;
71   __u32 set_uuid2;
72   __u32 set_uuid3;
73   __u32 gstate_creserved[MD_SB_GENERIC_CONSTANT_WORDS - 16];
74   __u32 utime;
75   __u32 state;
76   __u32 active_disks;
77   __u32 working_disks;
78   __u32 failed_disks;
79   __u32 spare_disks;
80   __u32 sb_csum;
81 #if defined(__BYTE_ORDER) ? __BYTE_ORDER == __BIG_ENDIAN : defined(__BIG_ENDIAN)
82   __u32 events_hi;
83   __u32 events_lo;
84   __u32 cp_events_hi;
85   __u32 cp_events_lo;
86 #elif defined(__BYTE_ORDER)?__BYTE_ORDER==__LITTLE_ENDIAN:defined(__LITTLE_ENDIAN)
87   __u32 events_lo;
88   __u32 events_hi;
89   __u32 cp_events_lo;
90   __u32 cp_events_hi;
91 #else
92 #error unspecified endianness
93 #endif
94   __u32 recovery_cp;
95   __u64 reshape_position;
96   __u32 new_level;
97   __u32 delta_disks;
98   __u32 new_layout;
99   __u32 new_chunk;
100   __u32 gstate_sreserved[MD_SB_GENERIC_STATE_WORDS - 18];
101   __u32 layout;
102   __u32 chunk_size;
103   __u32 root_pv;
104   __u32 root_block;
105   __u32 pstate_reserved[MD_SB_PERSONALITY_WORDS - 4];
106   mdp_disk_t disks[MD_SB_DISKS];
107   __u32 reserved[MD_SB_RESERVED_WORDS];
108   mdp_disk_t this_disk;
109 } mdp_super_t;
110 #define MD_SUPERBLOCK_1_TIME_SEC_MASK ((1ULL << 40) - 1)
111 struct mdp_superblock_1 {
112   __le32 magic;
113   __le32 major_version;
114   __le32 feature_map;
115   __le32 pad0;
116   __u8 set_uuid[16];
117   char set_name[32];
118   __le64 ctime;
119   __le32 level;
120   __le32 layout;
121   __le64 size;
122   __le32 chunksize;
123   __le32 raid_disks;
124   union {
125     __le32 bitmap_offset;
126     struct {
127       __le16 offset;
128       __le16 size;
129     } ppl;
130   };
131   __le32 new_level;
132   __le64 reshape_position;
133   __le32 delta_disks;
134   __le32 new_layout;
135   __le32 new_chunk;
136   __le32 new_offset;
137   __le64 data_offset;
138   __le64 data_size;
139   __le64 super_offset;
140   union {
141     __le64 recovery_offset;
142     __le64 journal_tail;
143   };
144   __le32 dev_number;
145   __le32 cnt_corrected_read;
146   __u8 device_uuid[16];
147   __u8 devflags;
148 #define WriteMostly1 1
149 #define FailFast1 2
150   __u8 bblog_shift;
151   __le16 bblog_size;
152   __le32 bblog_offset;
153   __le64 utime;
154   __le64 events;
155   __le64 resync_offset;
156   __le32 sb_csum;
157   __le32 max_dev;
158   __u8 pad3[64 - 32];
159   __le16 dev_roles[];
160 };
161 #define MD_FEATURE_BITMAP_OFFSET 1
162 #define MD_FEATURE_RECOVERY_OFFSET 2
163 #define MD_FEATURE_RESHAPE_ACTIVE 4
164 #define MD_FEATURE_BAD_BLOCKS 8
165 #define MD_FEATURE_REPLACEMENT 16
166 #define MD_FEATURE_RESHAPE_BACKWARDS 32
167 #define MD_FEATURE_NEW_OFFSET 64
168 #define MD_FEATURE_RECOVERY_BITMAP 128
169 #define MD_FEATURE_CLUSTERED 256
170 #define MD_FEATURE_JOURNAL 512
171 #define MD_FEATURE_PPL 1024
172 #define MD_FEATURE_MULTIPLE_PPLS 2048
173 #define MD_FEATURE_RAID0_LAYOUT 4096
174 #define MD_FEATURE_ALL (MD_FEATURE_BITMAP_OFFSET | MD_FEATURE_RECOVERY_OFFSET | MD_FEATURE_RESHAPE_ACTIVE | MD_FEATURE_BAD_BLOCKS | MD_FEATURE_REPLACEMENT | MD_FEATURE_RESHAPE_BACKWARDS | MD_FEATURE_NEW_OFFSET | MD_FEATURE_RECOVERY_BITMAP | MD_FEATURE_CLUSTERED | MD_FEATURE_JOURNAL | MD_FEATURE_PPL | MD_FEATURE_MULTIPLE_PPLS | MD_FEATURE_RAID0_LAYOUT)
175 struct r5l_payload_header {
176   __le16 type;
177   __le16 flags;
178 } __attribute__((__packed__));
179 enum r5l_payload_type {
180   R5LOG_PAYLOAD_DATA = 0,
181   R5LOG_PAYLOAD_PARITY = 1,
182   R5LOG_PAYLOAD_FLUSH = 2,
183 };
184 struct r5l_payload_data_parity {
185   struct r5l_payload_header header;
186   __le32 size;
187   __le64 location;
188   __le32 checksum[];
189 } __attribute__((__packed__));
190 enum r5l_payload_data_parity_flag {
191   R5LOG_PAYLOAD_FLAG_DISCARD = 1,
192   R5LOG_PAYLOAD_FLAG_RESHAPED = 2,
193   R5LOG_PAYLOAD_FLAG_RESHAPING = 3,
194 };
195 struct r5l_payload_flush {
196   struct r5l_payload_header header;
197   __le32 size;
198   __le64 flush_stripes[];
199 } __attribute__((__packed__));
200 enum r5l_payload_flush_flag {
201   R5LOG_PAYLOAD_FLAG_FLUSH_STRIPE = 1,
202 };
203 struct r5l_meta_block {
204   __le32 magic;
205   __le32 checksum;
206   __u8 version;
207   __u8 __zero_pading_1;
208   __le16 __zero_pading_2;
209   __le32 meta_size;
210   __le64 seq;
211   __le64 position;
212   struct r5l_payload_header payloads[];
213 } __attribute__((__packed__));
214 #define R5LOG_VERSION 0x1
215 #define R5LOG_MAGIC 0x6433c509
216 struct ppl_header_entry {
217   __le64 data_sector;
218   __le32 pp_size;
219   __le32 data_size;
220   __le32 parity_disk;
221   __le32 checksum;
222 } __attribute__((__packed__));
223 #define PPL_HEADER_SIZE 4096
224 #define PPL_HDR_RESERVED 512
225 #define PPL_HDR_ENTRY_SPACE (PPL_HEADER_SIZE - PPL_HDR_RESERVED - 4 * sizeof(__le32) - sizeof(__le64))
226 #define PPL_HDR_MAX_ENTRIES (PPL_HDR_ENTRY_SPACE / sizeof(struct ppl_header_entry))
227 struct ppl_header {
228   __u8 reserved[PPL_HDR_RESERVED];
229   __le32 signature;
230   __le32 padding;
231   __le64 generation;
232   __le32 entries_count;
233   __le32 checksum;
234   struct ppl_header_entry entries[PPL_HDR_MAX_ENTRIES];
235 } __attribute__((__packed__));
236 #endif
237