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