blob: 0bc6756268b3a7215ac061713859be9c129cb3c6 [file] [log] [blame]
Ben Cheng655a7c02013-10-16 16:09:24 -07001/****************************************************************************
2 ****************************************************************************
3 ***
4 *** This header was automatically generated from a Linux kernel header
5 *** of the same name, to make information necessary for userspace to
6 *** call into the kernel available to libc. It contains only constants,
7 *** structures, and macros generated from the original header, and thus,
8 *** contains no copyrightable information.
9 ***
10 *** To edit the content of this header, modify the corresponding
11 *** source file (e.g. under external/kernel-headers/original/) then
12 *** run bionic/libc/kernel/tools/update_all.py
13 ***
14 *** Any manual change here will be lost the next time this script will
15 *** be run. You've been warned!
16 ***
17 ****************************************************************************
18 ****************************************************************************/
19#ifndef _MD_P_H
20#define _MD_P_H
21#include <linux/types.h>
Christopher Ferris38062f92014-07-09 15:33:25 -070022#include <asm/byteorder.h>
Christopher Ferris38062f92014-07-09 15:33:25 -070023#define MD_RESERVED_BYTES (64 * 1024)
Ben Cheng655a7c02013-10-16 16:09:24 -070024#define MD_RESERVED_SECTORS (MD_RESERVED_BYTES / 512)
25#define MD_NEW_SIZE_SECTORS(x) ((x & ~(MD_RESERVED_SECTORS - 1)) - MD_RESERVED_SECTORS)
26#define MD_SB_BYTES 4096
Christopher Ferris38062f92014-07-09 15:33:25 -070027#define MD_SB_WORDS (MD_SB_BYTES / 4)
Ben Cheng655a7c02013-10-16 16:09:24 -070028#define MD_SB_SECTORS (MD_SB_BYTES / 512)
29#define MD_SB_GENERIC_OFFSET 0
30#define MD_SB_PERSONALITY_OFFSET 64
Christopher Ferris38062f92014-07-09 15:33:25 -070031#define MD_SB_DISKS_OFFSET 128
Ben Cheng655a7c02013-10-16 16:09:24 -070032#define MD_SB_DESCRIPTOR_OFFSET 992
33#define MD_SB_GENERIC_CONSTANT_WORDS 32
34#define MD_SB_GENERIC_STATE_WORDS 32
Christopher Ferris38062f92014-07-09 15:33:25 -070035#define MD_SB_GENERIC_WORDS (MD_SB_GENERIC_CONSTANT_WORDS + MD_SB_GENERIC_STATE_WORDS)
Ben Cheng655a7c02013-10-16 16:09:24 -070036#define MD_SB_PERSONALITY_WORDS 64
37#define MD_SB_DESCRIPTOR_WORDS 32
38#define MD_SB_DISKS 27
Tao Baod7db5942015-01-28 10:07:51 -080039#define MD_SB_DISKS_WORDS (MD_SB_DISKS * MD_SB_DESCRIPTOR_WORDS)
Ben Cheng655a7c02013-10-16 16:09:24 -070040#define MD_SB_RESERVED_WORDS (1024 - MD_SB_GENERIC_WORDS - MD_SB_PERSONALITY_WORDS - MD_SB_DISKS_WORDS - MD_SB_DESCRIPTOR_WORDS)
41#define MD_SB_EQUAL_WORDS (MD_SB_GENERIC_WORDS + MD_SB_PERSONALITY_WORDS + MD_SB_DISKS_WORDS)
42#define MD_DISK_FAULTY 0
Christopher Ferris38062f92014-07-09 15:33:25 -070043#define MD_DISK_ACTIVE 1
Ben Cheng655a7c02013-10-16 16:09:24 -070044#define MD_DISK_SYNC 2
45#define MD_DISK_REMOVED 3
Christopher Ferris05d08e92016-02-04 13:16:38 -080046#define MD_DISK_CLUSTER_ADD 4
Christopher Ferris05d08e92016-02-04 13:16:38 -080047#define MD_DISK_CANDIDATE 5
Christopher Ferris48af7cb2017-02-21 12:35:09 -080048#define MD_DISK_FAILFAST 10
Christopher Ferris05d08e92016-02-04 13:16:38 -080049#define MD_DISK_WRITEMOSTLY 9
50#define MD_DISK_JOURNAL 18
Christopher Ferris48af7cb2017-02-21 12:35:09 -080051#define MD_DISK_ROLE_SPARE 0xffff
Christopher Ferris05d08e92016-02-04 13:16:38 -080052#define MD_DISK_ROLE_FAULTY 0xfffe
53#define MD_DISK_ROLE_JOURNAL 0xfffd
54#define MD_DISK_ROLE_MAX 0xff00
Christopher Ferris48af7cb2017-02-21 12:35:09 -080055typedef struct mdp_device_descriptor_s {
Tao Baod7db5942015-01-28 10:07:51 -080056 __u32 number;
57 __u32 major;
58 __u32 minor;
Christopher Ferris48af7cb2017-02-21 12:35:09 -080059 __u32 raid_disk;
Tao Baod7db5942015-01-28 10:07:51 -080060 __u32 state;
61 __u32 reserved[MD_SB_DESCRIPTOR_WORDS - 5];
Ben Cheng655a7c02013-10-16 16:09:24 -070062} mdp_disk_t;
Christopher Ferris48af7cb2017-02-21 12:35:09 -080063#define MD_SB_MAGIC 0xa92b4efc
Ben Cheng655a7c02013-10-16 16:09:24 -070064#define MD_SB_CLEAN 0
65#define MD_SB_ERRORS 1
Christopher Ferris05d08e92016-02-04 13:16:38 -080066#define MD_SB_CLUSTERED 5
Christopher Ferris48af7cb2017-02-21 12:35:09 -080067#define MD_SB_BITMAP_PRESENT 8
Christopher Ferris38062f92014-07-09 15:33:25 -070068typedef struct mdp_superblock_s {
Tao Baod7db5942015-01-28 10:07:51 -080069 __u32 md_magic;
70 __u32 major_version;
Christopher Ferris48af7cb2017-02-21 12:35:09 -080071 __u32 minor_version;
Tao Baod7db5942015-01-28 10:07:51 -080072 __u32 patch_version;
73 __u32 gvalid_words;
74 __u32 set_uuid0;
Christopher Ferris48af7cb2017-02-21 12:35:09 -080075 __u32 ctime;
Tao Baod7db5942015-01-28 10:07:51 -080076 __u32 level;
77 __u32 size;
78 __u32 nr_disks;
Christopher Ferris48af7cb2017-02-21 12:35:09 -080079 __u32 raid_disks;
Tao Baod7db5942015-01-28 10:07:51 -080080 __u32 md_minor;
81 __u32 not_persistent;
82 __u32 set_uuid1;
Christopher Ferris48af7cb2017-02-21 12:35:09 -080083 __u32 set_uuid2;
Tao Baod7db5942015-01-28 10:07:51 -080084 __u32 set_uuid3;
85 __u32 gstate_creserved[MD_SB_GENERIC_CONSTANT_WORDS - 16];
86 __u32 utime;
Christopher Ferris48af7cb2017-02-21 12:35:09 -080087 __u32 state;
Tao Baod7db5942015-01-28 10:07:51 -080088 __u32 active_disks;
89 __u32 working_disks;
90 __u32 failed_disks;
Christopher Ferris48af7cb2017-02-21 12:35:09 -080091 __u32 spare_disks;
Tao Baod7db5942015-01-28 10:07:51 -080092 __u32 sb_csum;
Elliott Hughes8cb52b02013-11-21 13:43:23 -080093#if defined(__BYTE_ORDER) ? __BYTE_ORDER == __BIG_ENDIAN : defined(__BIG_ENDIAN)
Tao Baod7db5942015-01-28 10:07:51 -080094 __u32 events_hi;
Christopher Ferris48af7cb2017-02-21 12:35:09 -080095 __u32 events_lo;
Tao Baod7db5942015-01-28 10:07:51 -080096 __u32 cp_events_hi;
97 __u32 cp_events_lo;
98#elif defined(__BYTE_ORDER)?__BYTE_ORDER==__LITTLE_ENDIAN:defined(__LITTLE_ENDIAN)
Christopher Ferris48af7cb2017-02-21 12:35:09 -080099 __u32 events_lo;
Tao Baod7db5942015-01-28 10:07:51 -0800100 __u32 events_hi;
101 __u32 cp_events_lo;
102 __u32 cp_events_hi;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800103#else
Christopher Ferris38062f92014-07-09 15:33:25 -0700104#error unspecified endianness
Ben Cheng655a7c02013-10-16 16:09:24 -0700105#endif
Tao Baod7db5942015-01-28 10:07:51 -0800106 __u32 recovery_cp;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800107 __u64 reshape_position;
Tao Baod7db5942015-01-28 10:07:51 -0800108 __u32 new_level;
109 __u32 delta_disks;
110 __u32 new_layout;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800111 __u32 new_chunk;
Tao Baod7db5942015-01-28 10:07:51 -0800112 __u32 gstate_sreserved[MD_SB_GENERIC_STATE_WORDS - 18];
113 __u32 layout;
114 __u32 chunk_size;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800115 __u32 root_pv;
Tao Baod7db5942015-01-28 10:07:51 -0800116 __u32 root_block;
117 __u32 pstate_reserved[MD_SB_PERSONALITY_WORDS - 4];
118 mdp_disk_t disks[MD_SB_DISKS];
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800119 __u32 reserved[MD_SB_RESERVED_WORDS];
Tao Baod7db5942015-01-28 10:07:51 -0800120 mdp_disk_t this_disk;
Ben Cheng655a7c02013-10-16 16:09:24 -0700121} mdp_super_t;
Tao Baod7db5942015-01-28 10:07:51 -0800122#define MD_SUPERBLOCK_1_TIME_SEC_MASK ((1ULL << 40) - 1)
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800123struct mdp_superblock_1 {
Tao Baod7db5942015-01-28 10:07:51 -0800124 __le32 magic;
125 __le32 major_version;
126 __le32 feature_map;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800127 __le32 pad0;
Tao Baod7db5942015-01-28 10:07:51 -0800128 __u8 set_uuid[16];
129 char set_name[32];
130 __le64 ctime;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800131 __le32 level;
Tao Baod7db5942015-01-28 10:07:51 -0800132 __le32 layout;
133 __le64 size;
134 __le32 chunksize;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800135 __le32 raid_disks;
Christopher Ferris525ce912017-07-26 13:12:53 -0700136 union {
137 __le32 bitmap_offset;
138 struct {
139 __le16 offset;
140 __le16 size;
141 } ppl;
142 };
Tao Baod7db5942015-01-28 10:07:51 -0800143 __le32 new_level;
144 __le64 reshape_position;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800145 __le32 delta_disks;
Tao Baod7db5942015-01-28 10:07:51 -0800146 __le32 new_layout;
147 __le32 new_chunk;
148 __le32 new_offset;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800149 __le64 data_offset;
Tao Baod7db5942015-01-28 10:07:51 -0800150 __le64 data_size;
151 __le64 super_offset;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800152 union {
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800153 __le64 recovery_offset;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800154 __le64 journal_tail;
155 };
156 __le32 dev_number;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800157 __le32 cnt_corrected_read;
Tao Baod7db5942015-01-28 10:07:51 -0800158 __u8 device_uuid[16];
159 __u8 devflags;
Ben Cheng655a7c02013-10-16 16:09:24 -0700160#define WriteMostly1 1
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800161#define FailFast1 2
162 __u8 bblog_shift;
Tao Baod7db5942015-01-28 10:07:51 -0800163 __le16 bblog_size;
164 __le32 bblog_offset;
165 __le64 utime;
Tao Baod7db5942015-01-28 10:07:51 -0800166 __le64 events;
167 __le64 resync_offset;
168 __le32 sb_csum;
169 __le32 max_dev;
Tao Baod7db5942015-01-28 10:07:51 -0800170 __u8 pad3[64 - 32];
171 __le16 dev_roles[0];
Ben Cheng655a7c02013-10-16 16:09:24 -0700172};
173#define MD_FEATURE_BITMAP_OFFSET 1
Christopher Ferris38062f92014-07-09 15:33:25 -0700174#define MD_FEATURE_RECOVERY_OFFSET 2
Ben Cheng655a7c02013-10-16 16:09:24 -0700175#define MD_FEATURE_RESHAPE_ACTIVE 4
176#define MD_FEATURE_BAD_BLOCKS 8
177#define MD_FEATURE_REPLACEMENT 16
Christopher Ferris38062f92014-07-09 15:33:25 -0700178#define MD_FEATURE_RESHAPE_BACKWARDS 32
Ben Cheng655a7c02013-10-16 16:09:24 -0700179#define MD_FEATURE_NEW_OFFSET 64
Christopher Ferris38062f92014-07-09 15:33:25 -0700180#define MD_FEATURE_RECOVERY_BITMAP 128
Christopher Ferris05d08e92016-02-04 13:16:38 -0800181#define MD_FEATURE_CLUSTERED 256
182#define MD_FEATURE_JOURNAL 512
Christopher Ferris525ce912017-07-26 13:12:53 -0700183#define MD_FEATURE_PPL 1024
Christopher Ferris1308ad32017-11-14 17:32:13 -0800184#define MD_FEATURE_MULTIPLE_PPLS 2048
185#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)
Christopher Ferris05d08e92016-02-04 13:16:38 -0800186struct r5l_payload_header {
187 __le16 type;
188 __le16 flags;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800189} __attribute__((__packed__));
190enum r5l_payload_type {
191 R5LOG_PAYLOAD_DATA = 0,
192 R5LOG_PAYLOAD_PARITY = 1,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800193 R5LOG_PAYLOAD_FLUSH = 2,
194};
195struct r5l_payload_data_parity {
196 struct r5l_payload_header header;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800197 __le32 size;
198 __le64 location;
199 __le32 checksum[];
200} __attribute__((__packed__));
Christopher Ferris05d08e92016-02-04 13:16:38 -0800201enum r5l_payload_data_parity_flag {
202 R5LOG_PAYLOAD_FLAG_DISCARD = 1,
203 R5LOG_PAYLOAD_FLAG_RESHAPED = 2,
204 R5LOG_PAYLOAD_FLAG_RESHAPING = 3,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800205};
206struct r5l_payload_flush {
207 struct r5l_payload_header header;
208 __le32 size;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800209 __le64 flush_stripes[];
210} __attribute__((__packed__));
211enum r5l_payload_flush_flag {
212 R5LOG_PAYLOAD_FLAG_FLUSH_STRIPE = 1,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800213};
214struct r5l_meta_block {
215 __le32 magic;
216 __le32 checksum;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800217 __u8 version;
218 __u8 __zero_pading_1;
219 __le16 __zero_pading_2;
220 __le32 meta_size;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800221 __le64 seq;
222 __le64 position;
223 struct r5l_payload_header payloads[];
224} __attribute__((__packed__));
Christopher Ferris05d08e92016-02-04 13:16:38 -0800225#define R5LOG_VERSION 0x1
226#define R5LOG_MAGIC 0x6433c509
Christopher Ferris525ce912017-07-26 13:12:53 -0700227struct ppl_header_entry {
228 __le64 data_sector;
229 __le32 pp_size;
230 __le32 data_size;
231 __le32 parity_disk;
232 __le32 checksum;
233} __attribute__((__packed__));
234#define PPL_HEADER_SIZE 4096
235#define PPL_HDR_RESERVED 512
236#define PPL_HDR_ENTRY_SPACE (PPL_HEADER_SIZE - PPL_HDR_RESERVED - 4 * sizeof(__le32) - sizeof(__le64))
237#define PPL_HDR_MAX_ENTRIES (PPL_HDR_ENTRY_SPACE / sizeof(struct ppl_header_entry))
238struct ppl_header {
239 __u8 reserved[PPL_HDR_RESERVED];
240 __le32 signature;
241 __le32 padding;
242 __le64 generation;
243 __le32 entries_count;
244 __le32 checksum;
245 struct ppl_header_entry entries[PPL_HDR_MAX_ENTRIES];
246} __attribute__((__packed__));
Ben Cheng655a7c02013-10-16 16:09:24 -0700247#endif