ftl: Change metadata to use structure packing
Don't rely on compiler for metadata packing to 4KiB size and add reserved fields manually. For compatibility reasons against metadata relying on automatic padding the reserved fields are also added in-between existing fields as needed. Signed-off-by: Kozlowski Mateusz <mateusz.kozlowski@intel.com> Change-Id: I5e342d5bf5948c213d455590d09597ae120b3c62 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14307 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
c332181331
commit
920c1cca18
@ -64,6 +64,9 @@ struct ftl_band_md {
|
|||||||
/* nv_cache p2l md region associated with band */
|
/* nv_cache p2l md region associated with band */
|
||||||
enum ftl_layout_region_type p2l_md_region;
|
enum ftl_layout_region_type p2l_md_region;
|
||||||
|
|
||||||
|
/* Reserved */
|
||||||
|
uint8_t reserved[4];
|
||||||
|
|
||||||
/* Sequence ID when band was opened */
|
/* Sequence ID when band was opened */
|
||||||
uint64_t seq;
|
uint64_t seq;
|
||||||
|
|
||||||
@ -78,7 +81,10 @@ struct ftl_band_md {
|
|||||||
|
|
||||||
/* CRC32 checksum of the associated P2L map when band is in closed state */
|
/* CRC32 checksum of the associated P2L map when band is in closed state */
|
||||||
uint32_t p2l_map_checksum;
|
uint32_t p2l_map_checksum;
|
||||||
} __attribute__((aligned(FTL_BLOCK_SIZE)));
|
|
||||||
|
/* Reserved */
|
||||||
|
uint8_t reserved2[4028];
|
||||||
|
} __attribute__((packed));
|
||||||
|
|
||||||
SPDK_STATIC_ASSERT(sizeof(struct ftl_band_md) == FTL_BLOCK_SIZE, "Incorrect metadata size");
|
SPDK_STATIC_ASSERT(sizeof(struct ftl_band_md) == FTL_BLOCK_SIZE, "Incorrect metadata size");
|
||||||
|
|
||||||
|
@ -83,7 +83,10 @@ struct ftl_nv_cache_chunk_md {
|
|||||||
|
|
||||||
/* CRC32 checksum of the associated P2L map when chunk is in closed state */
|
/* CRC32 checksum of the associated P2L map when chunk is in closed state */
|
||||||
uint32_t p2l_map_checksum;
|
uint32_t p2l_map_checksum;
|
||||||
} __attribute__((aligned(FTL_BLOCK_SIZE)));
|
|
||||||
|
/* Reserved */
|
||||||
|
uint8_t reserved[4052];
|
||||||
|
} __attribute__((packed));
|
||||||
|
|
||||||
#define FTL_NV_CACHE_CHUNK_MD_SIZE sizeof(struct ftl_nv_cache_chunk_md)
|
#define FTL_NV_CACHE_CHUNK_MD_SIZE sizeof(struct ftl_nv_cache_chunk_md)
|
||||||
SPDK_STATIC_ASSERT(FTL_NV_CACHE_CHUNK_MD_SIZE == FTL_BLOCK_SIZE,
|
SPDK_STATIC_ASSERT(FTL_NV_CACHE_CHUNK_MD_SIZE == FTL_BLOCK_SIZE,
|
||||||
|
@ -33,13 +33,17 @@ struct ftl_superblock_gc_info {
|
|||||||
uint64_t band_phys_id;
|
uint64_t band_phys_id;
|
||||||
/* May be updating multiple fields at the same time, clearing/setting this marks the transaction */
|
/* May be updating multiple fields at the same time, clearing/setting this marks the transaction */
|
||||||
uint64_t is_valid;
|
uint64_t is_valid;
|
||||||
};
|
} __attribute__((packed));
|
||||||
|
SPDK_STATIC_ASSERT(sizeof(struct ftl_superblock_gc_info) == 32,
|
||||||
|
"ftl_superblock_gc_info incorrect size");
|
||||||
|
|
||||||
struct ftl_superblock_header {
|
struct ftl_superblock_header {
|
||||||
uint64_t magic;
|
uint64_t magic;
|
||||||
uint64_t crc;
|
uint64_t crc;
|
||||||
uint64_t version;
|
uint64_t version;
|
||||||
};
|
} __attribute__((packed));
|
||||||
|
SPDK_STATIC_ASSERT(sizeof(struct ftl_superblock_header) == 24,
|
||||||
|
"ftl_superblock_header incorrect size");
|
||||||
|
|
||||||
struct ftl_superblock_md_region {
|
struct ftl_superblock_md_region {
|
||||||
uint32_t type;
|
uint32_t type;
|
||||||
@ -47,7 +51,9 @@ struct ftl_superblock_md_region {
|
|||||||
uint64_t blk_offs;
|
uint64_t blk_offs;
|
||||||
uint64_t blk_sz;
|
uint64_t blk_sz;
|
||||||
ftl_df_obj_id df_next;
|
ftl_df_obj_id df_next;
|
||||||
};
|
} __attribute__((packed));
|
||||||
|
SPDK_STATIC_ASSERT(sizeof(struct ftl_superblock_md_region) == 32,
|
||||||
|
"ftl_superblock_md_region incorrect size");
|
||||||
|
|
||||||
struct ftl_superblock_shm {
|
struct ftl_superblock_shm {
|
||||||
/* SHM initialization completed */
|
/* SHM initialization completed */
|
||||||
|
@ -32,12 +32,8 @@ struct ftl_superblock {
|
|||||||
/* Maximum IO depth per band relocate */
|
/* Maximum IO depth per band relocate */
|
||||||
uint64_t max_reloc_qdepth;
|
uint64_t max_reloc_qdepth;
|
||||||
|
|
||||||
/* Reserved fields */
|
/* Reserved field */
|
||||||
uint64_t reserved;
|
uint8_t reserved3[16];
|
||||||
|
|
||||||
bool reserved3;
|
|
||||||
|
|
||||||
uint32_t reserved2;
|
|
||||||
|
|
||||||
/* Last L2P checkpoint +1 (i.e. min_seq_id, 0:no ckpt) */
|
/* Last L2P checkpoint +1 (i.e. min_seq_id, 0:no ckpt) */
|
||||||
uint64_t ckpt_seq_id;
|
uint64_t ckpt_seq_id;
|
||||||
@ -45,7 +41,7 @@ struct ftl_superblock {
|
|||||||
struct ftl_superblock_gc_info gc_info;
|
struct ftl_superblock_gc_info gc_info;
|
||||||
|
|
||||||
struct ftl_superblock_md_region md_layout_head;
|
struct ftl_superblock_md_region md_layout_head;
|
||||||
};
|
} __attribute__((packed));
|
||||||
|
|
||||||
SPDK_STATIC_ASSERT(offsetof(struct ftl_superblock, header) == 0,
|
SPDK_STATIC_ASSERT(offsetof(struct ftl_superblock, header) == 0,
|
||||||
"Invalid placement of header");
|
"Invalid placement of header");
|
||||||
|
Loading…
Reference in New Issue
Block a user