1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright (C) 2022 Intel Corporation. 3 * All rights reserved. 4 */ 5 6 #ifndef FTL_SB_PREV_H 7 #define FTL_SB_PREV_H 8 9 #include "spdk/uuid.h" 10 #include "ftl_sb_common.h" 11 12 /** 13 * Magic number identifies FTL superblock 14 * 15 * This old (pre v3) version has a bug - it's generating the magic number off 16b numbers, but only utilizing 8b from each 16 */ 17 #define FTL_MAGIC_V2(a, b, c, d) \ 18 ((UINT64_C(a) << 24) | (UINT64_C(b) << 16) | (UINT64_C(c) << 8) | UINT64_C(d)) 19 20 #define FTL_SUPERBLOCK_MAGIC_V2 FTL_MAGIC_V2(0x1410, 0x1683, 0x1920, 0x1989) 21 22 #define FTL_SB_VERSION_0 0 23 #define FTL_SB_VERSION_1 1 24 #define FTL_SB_VERSION_2 2 25 #define FTL_SB_VERSION_3 3 26 #define FTL_SB_VERSION_4 4 27 28 struct ftl_superblock_v2 { 29 struct ftl_superblock_header header; 30 31 struct spdk_uuid uuid; 32 33 /* Current sequence number */ 34 uint64_t seq_id; 35 36 /* Flag describing clean shutdown */ 37 uint64_t clean; 38 39 /* Number of surfaced LBAs */ 40 uint64_t lba_cnt; 41 /* Number of reserved addresses not exposed to the user */ 42 size_t lba_rsvd; 43 44 /* Maximum IO depth per band relocate */ 45 size_t max_reloc_qdepth; 46 47 /* Maximum active band relocates */ 48 size_t max_active_relocs; 49 50 /* Use append instead of write */ 51 bool use_append; 52 53 /* Maximum supported number of IO channels */ 54 uint32_t max_io_channels; 55 56 /* Last L2P checkpoint +1 (i.e. min_seq_id, 0:no ckpt) */ 57 uint64_t ckpt_seq_id; 58 59 struct ftl_superblock_gc_info gc_info; 60 }; 61 62 63 SPDK_STATIC_ASSERT(offsetof(struct ftl_superblock_v2, header) == 0, 64 "Invalid placement of header"); 65 66 SPDK_STATIC_ASSERT(FTL_SUPERBLOCK_SIZE >= sizeof(struct ftl_superblock_v2), 67 "FTL SB metadata size is invalid"); 68 69 struct ftl_superblock_v3 { 70 struct ftl_superblock_header header; 71 72 struct spdk_uuid uuid; 73 74 /* Current sequence number */ 75 uint64_t seq_id; 76 77 /* Flag describing clean shutdown */ 78 uint64_t clean; 79 80 /* Number of surfaced LBAs */ 81 uint64_t lba_cnt; 82 83 /* Percentage of base device blocks not exposed to the user */ 84 uint64_t overprovisioning; 85 86 /* Maximum IO depth per band relocate */ 87 uint64_t max_reloc_qdepth; 88 89 /* Reserved field */ 90 uint8_t reserved3[16]; 91 92 /* Last L2P checkpoint +1 (i.e. min_seq_id, 0:no ckpt) */ 93 uint64_t ckpt_seq_id; 94 95 struct ftl_superblock_gc_info gc_info; 96 97 struct ftl_superblock_v3_md_region md_layout_head; 98 } __attribute__((packed)); 99 100 SPDK_STATIC_ASSERT(offsetof(struct ftl_superblock_v3, header) == 0, 101 "Invalid placement of header"); 102 103 SPDK_STATIC_ASSERT(FTL_SUPERBLOCK_SIZE >= sizeof(struct ftl_superblock_v3), 104 "FTL SB metadata size is invalid"); 105 106 #endif /* FTL_SB_PREV_H */ 107