.. | .. |
---|
141 | 141 | * Version 3: Cache device with new UUID format |
---|
142 | 142 | * Version 4: Backing device with data offset |
---|
143 | 143 | */ |
---|
144 | | -#define BCACHE_SB_VERSION_CDEV 0 |
---|
145 | | -#define BCACHE_SB_VERSION_BDEV 1 |
---|
146 | | -#define BCACHE_SB_VERSION_CDEV_WITH_UUID 3 |
---|
147 | | -#define BCACHE_SB_VERSION_BDEV_WITH_OFFSET 4 |
---|
148 | | -#define BCACHE_SB_MAX_VERSION 4 |
---|
| 144 | +#define BCACHE_SB_VERSION_CDEV 0 |
---|
| 145 | +#define BCACHE_SB_VERSION_BDEV 1 |
---|
| 146 | +#define BCACHE_SB_VERSION_CDEV_WITH_UUID 3 |
---|
| 147 | +#define BCACHE_SB_VERSION_BDEV_WITH_OFFSET 4 |
---|
| 148 | +#define BCACHE_SB_VERSION_CDEV_WITH_FEATURES 5 |
---|
| 149 | +#define BCACHE_SB_VERSION_BDEV_WITH_FEATURES 6 |
---|
| 150 | +#define BCACHE_SB_MAX_VERSION 6 |
---|
149 | 151 | |
---|
150 | 152 | #define SB_SECTOR 8 |
---|
| 153 | +#define SB_OFFSET (SB_SECTOR << SECTOR_SHIFT) |
---|
151 | 154 | #define SB_SIZE 4096 |
---|
152 | 155 | #define SB_LABEL_SIZE 32 |
---|
153 | 156 | #define SB_JOURNAL_BUCKETS 256U |
---|
.. | .. |
---|
156 | 159 | |
---|
157 | 160 | #define BDEV_DATA_START_DEFAULT 16 /* sectors */ |
---|
158 | 161 | |
---|
| 162 | +struct cache_sb_disk { |
---|
| 163 | + __le64 csum; |
---|
| 164 | + __le64 offset; /* sector where this sb was written */ |
---|
| 165 | + __le64 version; |
---|
| 166 | + |
---|
| 167 | + __u8 magic[16]; |
---|
| 168 | + |
---|
| 169 | + __u8 uuid[16]; |
---|
| 170 | + union { |
---|
| 171 | + __u8 set_uuid[16]; |
---|
| 172 | + __le64 set_magic; |
---|
| 173 | + }; |
---|
| 174 | + __u8 label[SB_LABEL_SIZE]; |
---|
| 175 | + |
---|
| 176 | + __le64 flags; |
---|
| 177 | + __le64 seq; |
---|
| 178 | + |
---|
| 179 | + __le64 feature_compat; |
---|
| 180 | + __le64 feature_incompat; |
---|
| 181 | + __le64 feature_ro_compat; |
---|
| 182 | + |
---|
| 183 | + __le64 pad[5]; |
---|
| 184 | + |
---|
| 185 | + union { |
---|
| 186 | + struct { |
---|
| 187 | + /* Cache devices */ |
---|
| 188 | + __le64 nbuckets; /* device size */ |
---|
| 189 | + |
---|
| 190 | + __le16 block_size; /* sectors */ |
---|
| 191 | + __le16 bucket_size; /* sectors */ |
---|
| 192 | + |
---|
| 193 | + __le16 nr_in_set; |
---|
| 194 | + __le16 nr_this_dev; |
---|
| 195 | + }; |
---|
| 196 | + struct { |
---|
| 197 | + /* Backing devices */ |
---|
| 198 | + __le64 data_offset; |
---|
| 199 | + |
---|
| 200 | + /* |
---|
| 201 | + * block_size from the cache device section is still used by |
---|
| 202 | + * backing devices, so don't add anything here until we fix |
---|
| 203 | + * things to not need it for backing devices anymore |
---|
| 204 | + */ |
---|
| 205 | + }; |
---|
| 206 | + }; |
---|
| 207 | + |
---|
| 208 | + __le32 last_mount; /* time overflow in y2106 */ |
---|
| 209 | + |
---|
| 210 | + __le16 first_bucket; |
---|
| 211 | + union { |
---|
| 212 | + __le16 njournal_buckets; |
---|
| 213 | + __le16 keys; |
---|
| 214 | + }; |
---|
| 215 | + __le64 d[SB_JOURNAL_BUCKETS]; /* journal buckets */ |
---|
| 216 | + __le16 obso_bucket_size_hi; /* obsoleted */ |
---|
| 217 | +}; |
---|
| 218 | + |
---|
| 219 | +/* |
---|
| 220 | + * This is for in-memory bcache super block. |
---|
| 221 | + * NOTE: cache_sb is NOT exactly mapping to cache_sb_disk, the member |
---|
| 222 | + * size, ordering and even whole struct size may be different |
---|
| 223 | + * from cache_sb_disk. |
---|
| 224 | + */ |
---|
159 | 225 | struct cache_sb { |
---|
160 | | - __u64 csum; |
---|
161 | 226 | __u64 offset; /* sector where this sb was written */ |
---|
162 | 227 | __u64 version; |
---|
163 | 228 | |
---|
.. | .. |
---|
172 | 237 | |
---|
173 | 238 | __u64 flags; |
---|
174 | 239 | __u64 seq; |
---|
175 | | - __u64 pad[8]; |
---|
| 240 | + |
---|
| 241 | + __u64 feature_compat; |
---|
| 242 | + __u64 feature_incompat; |
---|
| 243 | + __u64 feature_ro_compat; |
---|
176 | 244 | |
---|
177 | 245 | union { |
---|
178 | 246 | struct { |
---|
.. | .. |
---|
180 | 248 | __u64 nbuckets; /* device size */ |
---|
181 | 249 | |
---|
182 | 250 | __u16 block_size; /* sectors */ |
---|
183 | | - __u16 bucket_size; /* sectors */ |
---|
184 | | - |
---|
185 | 251 | __u16 nr_in_set; |
---|
186 | 252 | __u16 nr_this_dev; |
---|
| 253 | + __u32 bucket_size; /* sectors */ |
---|
187 | 254 | }; |
---|
188 | 255 | struct { |
---|
189 | 256 | /* Backing devices */ |
---|
.. | .. |
---|
210 | 277 | static inline _Bool SB_IS_BDEV(const struct cache_sb *sb) |
---|
211 | 278 | { |
---|
212 | 279 | return sb->version == BCACHE_SB_VERSION_BDEV |
---|
213 | | - || sb->version == BCACHE_SB_VERSION_BDEV_WITH_OFFSET; |
---|
| 280 | + || sb->version == BCACHE_SB_VERSION_BDEV_WITH_OFFSET |
---|
| 281 | + || sb->version == BCACHE_SB_VERSION_BDEV_WITH_FEATURES; |
---|
214 | 282 | } |
---|
215 | 283 | |
---|
216 | 284 | BITMASK(CACHE_SYNC, struct cache_sb, flags, 0, 1); |
---|