diff options
author | Daniel Rosenberg <drosen@google.com> | 2023-08-28 18:05:33 -0700 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2023-09-07 14:20:09 -0700 |
commit | bb051c7b1634d49d3b00d4b2c96042c3d71e6db7 (patch) | |
tree | 7420db85335fc5749567d2c64c6783419f686662 | |
parent | 32f5a37782d95990f82a3699447f1518ab034abe (diff) | |
download | f2fs-tools-bb051c7b1634d49d3b00d4b2c96042c3d71e6db7.tar.gz |
f2fs-tools: Refactor SIT/NAT block structs
This converts f2fs_nat_block and f2fs_sit_block to be variable length
arrays. This does not change the way they are accessed, but removes a
misleading statment that these sizes are fixed, as opposed to deriving
from F2FS_BLKSIZE
Signed-off-by: Daniel Rosenberg <drosen@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
-rw-r--r-- | include/f2fs_fs.h | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h index cb100e7..0562aa1 100644 --- a/include/f2fs_fs.h +++ b/include/f2fs_fs.h @@ -1126,11 +1126,9 @@ struct f2fs_nat_entry { static_assert(sizeof(struct f2fs_nat_entry) == 9, ""); struct f2fs_nat_block { - struct f2fs_nat_entry entries[NAT_ENTRY_PER_BLOCK]; + struct f2fs_nat_entry entries[0]; /* NAT_ENTRY_PER_BLOCK */ }; -static_assert(sizeof(struct f2fs_nat_block) == F2FS_BLKSIZE - (F2FS_BLKSIZE % 9), ""); - /* * For SIT entries * @@ -1176,12 +1174,14 @@ struct f2fs_sit_entry { static_assert(sizeof(struct f2fs_sit_entry) == 74, ""); +/* + * On disk layout is: + * struct f2fs_sit_entry entries[SIT_ENTRY_PER_BLOCK]; + */ struct f2fs_sit_block { - struct f2fs_sit_entry entries[SIT_ENTRY_PER_BLOCK]; + struct f2fs_sit_entry entries[0]; }; -static_assert(sizeof(struct f2fs_sit_block) == F2FS_BLKSIZE - (F2FS_BLKSIZE % 74), ""); - /* * For segment summary * @@ -2002,6 +2002,14 @@ static inline void check_block_struct_sizes(void) /* Check Indirect Block Size */ assert(NIDS_PER_BLOCK * sizeof(__le32) + sizeof(struct node_footer) == F2FS_BLKSIZE); + + /* Check NAT Block Size */ + assert((NAT_ENTRY_PER_BLOCK + 1) * sizeof(struct f2fs_nat_entry) > F2FS_BLKSIZE); + assert(NAT_ENTRY_PER_BLOCK * sizeof(struct f2fs_nat_entry) <= F2FS_BLKSIZE); + + /* Check SIT Block Size */ + assert((SIT_ENTRY_PER_BLOCK + 1) * sizeof(struct f2fs_sit_entry) > F2FS_BLKSIZE); + assert(SIT_ENTRY_PER_BLOCK * sizeof(struct f2fs_sit_entry) <= F2FS_BLKSIZE); } #endif /*__F2FS_FS_H */ |