xref: /spdk/lib/ftl/upgrade/ftl_sb_prev.h (revision f968b954a94944780711b6c2548cbe7aa1c77d81)
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 struct ftl_superblock_v5 {
107 	struct ftl_superblock_header	header;
108 
109 	struct spdk_uuid		uuid;
110 
111 	/* Current sequence number */
112 	uint64_t			seq_id;
113 
114 	/* Flag describing clean shutdown */
115 	uint64_t			clean;
116 
117 	/* Number of surfaced LBAs */
118 	uint64_t			lba_cnt;
119 
120 	/* Percentage of base device blocks not exposed to the user */
121 	uint64_t			overprovisioning;
122 
123 	/* Maximum IO depth per band relocate */
124 	uint64_t			max_reloc_qdepth;
125 
126 	/* Reserved field */
127 	uint8_t				reserved3[16];
128 
129 	/* Last L2P checkpoint +1 (i.e. min_seq_id, 0:no ckpt) */
130 	uint64_t			ckpt_seq_id;
131 
132 	struct ftl_superblock_gc_info	gc_info;
133 
134 	/* Points to the end of blob area */
135 	ftl_df_obj_id			blob_area_end;
136 
137 	/* NVC device name */
138 	char				nvc_dev_name[16];
139 
140 	/* NVC-stored MD layout tracking info */
141 	struct ftl_superblock_v5_md_blob_hdr	md_layout_nvc;
142 
143 	/* Base device name */
144 	char					base_dev_name[16];
145 
146 	/* Base dev-stored MD layout tracking info */
147 	struct ftl_superblock_v5_md_blob_hdr	md_layout_base;
148 
149 	/* FTL layout params */
150 	struct ftl_superblock_v5_md_blob_hdr	layout_params;
151 
152 	/* Start of the blob area */
153 	char blob_area[0];
154 } __attribute__((packed));
155 
156 SPDK_STATIC_ASSERT(offsetof(struct ftl_superblock_v5, header) == 0,
157 		   "Invalid placement of header");
158 
159 SPDK_STATIC_ASSERT(FTL_SUPERBLOCK_SIZE >= sizeof(struct ftl_superblock_v5),
160 		   "FTL SB metadata size is invalid");
161 
162 #endif /* FTL_SB_PREV_H */
163