blob: dafeb16dc3b6a24e4c9cd982169f642b1d6404a2 [file] [log] [blame]
Elliott Hughes180edef2023-11-02 00:08:05 +00001/*
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 */
Ben Cheng655a7c02013-10-16 16:09:24 -07007#ifndef _MD_P_H
8#define _MD_P_H
9#include <linux/types.h>
Christopher Ferris38062f92014-07-09 15:33:25 -070010#include <asm/byteorder.h>
Christopher Ferris38062f92014-07-09 15:33:25 -070011#define MD_RESERVED_BYTES (64 * 1024)
Ben Cheng655a7c02013-10-16 16:09:24 -070012#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
Christopher Ferris38062f92014-07-09 15:33:25 -070015#define MD_SB_WORDS (MD_SB_BYTES / 4)
Ben Cheng655a7c02013-10-16 16:09:24 -070016#define MD_SB_SECTORS (MD_SB_BYTES / 512)
17#define MD_SB_GENERIC_OFFSET 0
18#define MD_SB_PERSONALITY_OFFSET 64
Christopher Ferris38062f92014-07-09 15:33:25 -070019#define MD_SB_DISKS_OFFSET 128
Ben Cheng655a7c02013-10-16 16:09:24 -070020#define MD_SB_DESCRIPTOR_OFFSET 992
21#define MD_SB_GENERIC_CONSTANT_WORDS 32
22#define MD_SB_GENERIC_STATE_WORDS 32
Christopher Ferris38062f92014-07-09 15:33:25 -070023#define MD_SB_GENERIC_WORDS (MD_SB_GENERIC_CONSTANT_WORDS + MD_SB_GENERIC_STATE_WORDS)
Ben Cheng655a7c02013-10-16 16:09:24 -070024#define MD_SB_PERSONALITY_WORDS 64
25#define MD_SB_DESCRIPTOR_WORDS 32
26#define MD_SB_DISKS 27
Tao Baod7db5942015-01-28 10:07:51 -080027#define MD_SB_DISKS_WORDS (MD_SB_DISKS * MD_SB_DESCRIPTOR_WORDS)
Ben Cheng655a7c02013-10-16 16:09:24 -070028#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
Christopher Ferris38062f92014-07-09 15:33:25 -070031#define MD_DISK_ACTIVE 1
Ben Cheng655a7c02013-10-16 16:09:24 -070032#define MD_DISK_SYNC 2
33#define MD_DISK_REMOVED 3
Christopher Ferris05d08e92016-02-04 13:16:38 -080034#define MD_DISK_CLUSTER_ADD 4
Christopher Ferris05d08e92016-02-04 13:16:38 -080035#define MD_DISK_CANDIDATE 5
Christopher Ferris48af7cb2017-02-21 12:35:09 -080036#define MD_DISK_FAILFAST 10
Christopher Ferris05d08e92016-02-04 13:16:38 -080037#define MD_DISK_WRITEMOSTLY 9
38#define MD_DISK_JOURNAL 18
Christopher Ferris48af7cb2017-02-21 12:35:09 -080039#define MD_DISK_ROLE_SPARE 0xffff
Christopher Ferris05d08e92016-02-04 13:16:38 -080040#define MD_DISK_ROLE_FAULTY 0xfffe
41#define MD_DISK_ROLE_JOURNAL 0xfffd
42#define MD_DISK_ROLE_MAX 0xff00
Christopher Ferris48af7cb2017-02-21 12:35:09 -080043typedef struct mdp_device_descriptor_s {
Tao Baod7db5942015-01-28 10:07:51 -080044 __u32 number;
45 __u32 major;
46 __u32 minor;
Christopher Ferris48af7cb2017-02-21 12:35:09 -080047 __u32 raid_disk;
Tao Baod7db5942015-01-28 10:07:51 -080048 __u32 state;
49 __u32 reserved[MD_SB_DESCRIPTOR_WORDS - 5];
Ben Cheng655a7c02013-10-16 16:09:24 -070050} mdp_disk_t;
Christopher Ferris48af7cb2017-02-21 12:35:09 -080051#define MD_SB_MAGIC 0xa92b4efc
Ben Cheng655a7c02013-10-16 16:09:24 -070052#define MD_SB_CLEAN 0
53#define MD_SB_ERRORS 1
Christopher Ferris05d08e92016-02-04 13:16:38 -080054#define MD_SB_CLUSTERED 5
Christopher Ferris48af7cb2017-02-21 12:35:09 -080055#define MD_SB_BITMAP_PRESENT 8
Christopher Ferris38062f92014-07-09 15:33:25 -070056typedef struct mdp_superblock_s {
Tao Baod7db5942015-01-28 10:07:51 -080057 __u32 md_magic;
58 __u32 major_version;
Christopher Ferris48af7cb2017-02-21 12:35:09 -080059 __u32 minor_version;
Tao Baod7db5942015-01-28 10:07:51 -080060 __u32 patch_version;
61 __u32 gvalid_words;
62 __u32 set_uuid0;
Christopher Ferris48af7cb2017-02-21 12:35:09 -080063 __u32 ctime;
Tao Baod7db5942015-01-28 10:07:51 -080064 __u32 level;
65 __u32 size;
66 __u32 nr_disks;
Christopher Ferris48af7cb2017-02-21 12:35:09 -080067 __u32 raid_disks;
Tao Baod7db5942015-01-28 10:07:51 -080068 __u32 md_minor;
69 __u32 not_persistent;
70 __u32 set_uuid1;
Christopher Ferris48af7cb2017-02-21 12:35:09 -080071 __u32 set_uuid2;
Tao Baod7db5942015-01-28 10:07:51 -080072 __u32 set_uuid3;
73 __u32 gstate_creserved[MD_SB_GENERIC_CONSTANT_WORDS - 16];
74 __u32 utime;
Christopher Ferris48af7cb2017-02-21 12:35:09 -080075 __u32 state;
Tao Baod7db5942015-01-28 10:07:51 -080076 __u32 active_disks;
77 __u32 working_disks;
78 __u32 failed_disks;
Christopher Ferris48af7cb2017-02-21 12:35:09 -080079 __u32 spare_disks;
Tao Baod7db5942015-01-28 10:07:51 -080080 __u32 sb_csum;
Elliott Hughes8cb52b02013-11-21 13:43:23 -080081#if defined(__BYTE_ORDER) ? __BYTE_ORDER == __BIG_ENDIAN : defined(__BIG_ENDIAN)
Tao Baod7db5942015-01-28 10:07:51 -080082 __u32 events_hi;
Christopher Ferris48af7cb2017-02-21 12:35:09 -080083 __u32 events_lo;
Tao Baod7db5942015-01-28 10:07:51 -080084 __u32 cp_events_hi;
85 __u32 cp_events_lo;
86#elif defined(__BYTE_ORDER)?__BYTE_ORDER==__LITTLE_ENDIAN:defined(__LITTLE_ENDIAN)
Christopher Ferris48af7cb2017-02-21 12:35:09 -080087 __u32 events_lo;
Tao Baod7db5942015-01-28 10:07:51 -080088 __u32 events_hi;
89 __u32 cp_events_lo;
90 __u32 cp_events_hi;
Christopher Ferris48af7cb2017-02-21 12:35:09 -080091#else
Christopher Ferris38062f92014-07-09 15:33:25 -070092#error unspecified endianness
Ben Cheng655a7c02013-10-16 16:09:24 -070093#endif
Tao Baod7db5942015-01-28 10:07:51 -080094 __u32 recovery_cp;
Christopher Ferris48af7cb2017-02-21 12:35:09 -080095 __u64 reshape_position;
Tao Baod7db5942015-01-28 10:07:51 -080096 __u32 new_level;
97 __u32 delta_disks;
98 __u32 new_layout;
Christopher Ferris48af7cb2017-02-21 12:35:09 -080099 __u32 new_chunk;
Tao Baod7db5942015-01-28 10:07:51 -0800100 __u32 gstate_sreserved[MD_SB_GENERIC_STATE_WORDS - 18];
101 __u32 layout;
102 __u32 chunk_size;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800103 __u32 root_pv;
Tao Baod7db5942015-01-28 10:07:51 -0800104 __u32 root_block;
105 __u32 pstate_reserved[MD_SB_PERSONALITY_WORDS - 4];
106 mdp_disk_t disks[MD_SB_DISKS];
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800107 __u32 reserved[MD_SB_RESERVED_WORDS];
Tao Baod7db5942015-01-28 10:07:51 -0800108 mdp_disk_t this_disk;
Ben Cheng655a7c02013-10-16 16:09:24 -0700109} mdp_super_t;
Tao Baod7db5942015-01-28 10:07:51 -0800110#define MD_SUPERBLOCK_1_TIME_SEC_MASK ((1ULL << 40) - 1)
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800111struct mdp_superblock_1 {
Tao Baod7db5942015-01-28 10:07:51 -0800112 __le32 magic;
113 __le32 major_version;
114 __le32 feature_map;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800115 __le32 pad0;
Tao Baod7db5942015-01-28 10:07:51 -0800116 __u8 set_uuid[16];
117 char set_name[32];
118 __le64 ctime;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800119 __le32 level;
Tao Baod7db5942015-01-28 10:07:51 -0800120 __le32 layout;
121 __le64 size;
122 __le32 chunksize;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800123 __le32 raid_disks;
Christopher Ferris525ce912017-07-26 13:12:53 -0700124 union {
125 __le32 bitmap_offset;
126 struct {
127 __le16 offset;
128 __le16 size;
129 } ppl;
130 };
Tao Baod7db5942015-01-28 10:07:51 -0800131 __le32 new_level;
132 __le64 reshape_position;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800133 __le32 delta_disks;
Tao Baod7db5942015-01-28 10:07:51 -0800134 __le32 new_layout;
135 __le32 new_chunk;
136 __le32 new_offset;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800137 __le64 data_offset;
Tao Baod7db5942015-01-28 10:07:51 -0800138 __le64 data_size;
139 __le64 super_offset;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800140 union {
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800141 __le64 recovery_offset;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800142 __le64 journal_tail;
143 };
144 __le32 dev_number;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800145 __le32 cnt_corrected_read;
Tao Baod7db5942015-01-28 10:07:51 -0800146 __u8 device_uuid[16];
147 __u8 devflags;
Ben Cheng655a7c02013-10-16 16:09:24 -0700148#define WriteMostly1 1
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800149#define FailFast1 2
150 __u8 bblog_shift;
Tao Baod7db5942015-01-28 10:07:51 -0800151 __le16 bblog_size;
152 __le32 bblog_offset;
153 __le64 utime;
Tao Baod7db5942015-01-28 10:07:51 -0800154 __le64 events;
155 __le64 resync_offset;
156 __le32 sb_csum;
157 __le32 max_dev;
Tao Baod7db5942015-01-28 10:07:51 -0800158 __u8 pad3[64 - 32];
Christopher Ferris7447a1c2022-10-04 18:24:44 -0700159 __le16 dev_roles[];
Ben Cheng655a7c02013-10-16 16:09:24 -0700160};
161#define MD_FEATURE_BITMAP_OFFSET 1
Christopher Ferris38062f92014-07-09 15:33:25 -0700162#define MD_FEATURE_RECOVERY_OFFSET 2
Ben Cheng655a7c02013-10-16 16:09:24 -0700163#define MD_FEATURE_RESHAPE_ACTIVE 4
164#define MD_FEATURE_BAD_BLOCKS 8
165#define MD_FEATURE_REPLACEMENT 16
Christopher Ferris38062f92014-07-09 15:33:25 -0700166#define MD_FEATURE_RESHAPE_BACKWARDS 32
Ben Cheng655a7c02013-10-16 16:09:24 -0700167#define MD_FEATURE_NEW_OFFSET 64
Christopher Ferris38062f92014-07-09 15:33:25 -0700168#define MD_FEATURE_RECOVERY_BITMAP 128
Christopher Ferris05d08e92016-02-04 13:16:38 -0800169#define MD_FEATURE_CLUSTERED 256
170#define MD_FEATURE_JOURNAL 512
Christopher Ferris525ce912017-07-26 13:12:53 -0700171#define MD_FEATURE_PPL 1024
Christopher Ferris1308ad32017-11-14 17:32:13 -0800172#define MD_FEATURE_MULTIPLE_PPLS 2048
Christopher Ferris9584fa42019-12-09 15:36:13 -0800173#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)
Christopher Ferris05d08e92016-02-04 13:16:38 -0800175struct r5l_payload_header {
176 __le16 type;
177 __le16 flags;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800178} __attribute__((__packed__));
179enum r5l_payload_type {
180 R5LOG_PAYLOAD_DATA = 0,
181 R5LOG_PAYLOAD_PARITY = 1,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800182 R5LOG_PAYLOAD_FLUSH = 2,
183};
184struct r5l_payload_data_parity {
185 struct r5l_payload_header header;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800186 __le32 size;
187 __le64 location;
188 __le32 checksum[];
189} __attribute__((__packed__));
Christopher Ferris05d08e92016-02-04 13:16:38 -0800190enum r5l_payload_data_parity_flag {
191 R5LOG_PAYLOAD_FLAG_DISCARD = 1,
192 R5LOG_PAYLOAD_FLAG_RESHAPED = 2,
193 R5LOG_PAYLOAD_FLAG_RESHAPING = 3,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800194};
195struct r5l_payload_flush {
196 struct r5l_payload_header header;
197 __le32 size;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800198 __le64 flush_stripes[];
199} __attribute__((__packed__));
200enum r5l_payload_flush_flag {
201 R5LOG_PAYLOAD_FLAG_FLUSH_STRIPE = 1,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800202};
203struct r5l_meta_block {
204 __le32 magic;
205 __le32 checksum;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800206 __u8 version;
207 __u8 __zero_pading_1;
208 __le16 __zero_pading_2;
209 __le32 meta_size;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800210 __le64 seq;
211 __le64 position;
212 struct r5l_payload_header payloads[];
213} __attribute__((__packed__));
Christopher Ferris05d08e92016-02-04 13:16:38 -0800214#define R5LOG_VERSION 0x1
215#define R5LOG_MAGIC 0x6433c509
Christopher Ferris525ce912017-07-26 13:12:53 -0700216struct 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))
227struct 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__));
Ben Cheng655a7c02013-10-16 16:09:24 -0700236#endif