aboutsummaryrefslogtreecommitdiffstats
path: root/include/uapi/linux/raid
diff options
context:
space:
mode:
authorShaohua Li <shli@fb.com>2015-08-13 17:31:59 -0400
committerNeilBrown <neilb@suse.com>2015-10-24 02:16:19 -0400
commitf6bed0ef0a808164f51197de062e0450ce6c1f96 (patch)
tree9fc2ec276f40ef36eaa14e295f543595472b56a9 /include/uapi/linux/raid
parentb70abcb24711d1327a8a505ab3e931c24cbab0a7 (diff)
raid5: add basic stripe log
This introduces a simple log for raid5. Data/parity writing to raid array first writes to the log, then write to raid array disks. If crash happens, we can recovery data from the log. This can speed up raid resync and fix write hole issue. The log structure is pretty simple. Data/meta data is stored in block unit, which is 4k generally. It has only one type of meta data block. The meta data block can track 3 types of data, stripe data, stripe parity and flush block. MD superblock will point to the last valid meta data block. Each meta data block has checksum/seq number, so recovery can scan the log correctly. We store a checksum of stripe data/parity to the metadata block, so meta data and stripe data/parity can be written to log disk together. otherwise, meta data write must wait till stripe data/parity is finished. For stripe data, meta data block will record stripe data sector and size. Currently the size is always 4k. This meta data record can be made simpler if we just fix write hole (eg, we can record data of a stripe's different disks together), but this format can be extended to support caching in the future, which must record data address/size. For stripe parity, meta data block will record stripe sector. It's size should be 4k (for raid5) or 8k (for raid6). We always store p parity first. This format should work for caching too. flush block indicates a stripe is in raid array disks. Fixing write hole doesn't need this type of meta data, it's for caching extension. Signed-off-by: Shaohua Li <shli@fb.com> Signed-off-by: NeilBrown <neilb@suse.com>
Diffstat (limited to 'include/uapi/linux/raid')
-rw-r--r--include/uapi/linux/raid/md_p.h58
1 files changed, 58 insertions, 0 deletions
diff --git a/include/uapi/linux/raid/md_p.h b/include/uapi/linux/raid/md_p.h
index a5f54ff26c20..96e4196f9c79 100644
--- a/include/uapi/linux/raid/md_p.h
+++ b/include/uapi/linux/raid/md_p.h
@@ -324,4 +324,62 @@ struct mdp_superblock_1 {
324 |MD_FEATURE_CLUSTERED \ 324 |MD_FEATURE_CLUSTERED \
325 ) 325 )
326 326
327struct r5l_payload_header {
328 __le16 type;
329 __le16 flags;
330} __attribute__ ((__packed__));
331
332enum r5l_payload_type {
333 R5LOG_PAYLOAD_DATA = 0,
334 R5LOG_PAYLOAD_PARITY = 1,
335 R5LOG_PAYLOAD_FLUSH = 2,
336};
337
338struct r5l_payload_data_parity {
339 struct r5l_payload_header header;
340 __le32 size; /* sector. data/parity size. each 4k
341 * has a checksum */
342 __le64 location; /* sector. For data, it's raid sector. For
343 * parity, it's stripe sector */
344 __le32 checksum[];
345} __attribute__ ((__packed__));
346
347enum r5l_payload_data_parity_flag {
348 R5LOG_PAYLOAD_FLAG_DISCARD = 1, /* payload is discard */
349 /*
350 * RESHAPED/RESHAPING is only set when there is reshape activity. Note,
351 * both data/parity of a stripe should have the same flag set
352 *
353 * RESHAPED: reshape is running, and this stripe finished reshape
354 * RESHAPING: reshape is running, and this stripe isn't reshaped
355 */
356 R5LOG_PAYLOAD_FLAG_RESHAPED = 2,
357 R5LOG_PAYLOAD_FLAG_RESHAPING = 3,
358};
359
360struct r5l_payload_flush {
361 struct r5l_payload_header header;
362 __le32 size; /* flush_stripes size, bytes */
363 __le64 flush_stripes[];
364} __attribute__ ((__packed__));
365
366enum r5l_payload_flush_flag {
367 R5LOG_PAYLOAD_FLAG_FLUSH_STRIPE = 1, /* data represents whole stripe */
368};
369
370struct r5l_meta_block {
371 __le32 magic;
372 __le32 checksum;
373 __u8 version;
374 __u8 __zero_pading_1;
375 __le16 __zero_pading_2;
376 __le32 meta_size; /* whole size of the block */
377
378 __le64 seq;
379 __le64 position; /* sector, start from rdev->data_offset, current position */
380 struct r5l_payload_header payloads[];
381} __attribute__ ((__packed__));
382
383#define R5LOG_VERSION 0x1
384#define R5LOG_MAGIC 0x6433c509
327#endif 385#endif