@@ -60,8 +60,7 @@ static int get_new_sb(struct f2fs_super_block *sb)
* It should be reserved minimum 1 segment for nat.
* When sit is too large, we should expand cp area. It requires more pages for cp.
*/
- if (max_sit_bitmap_size >
- (CHECKSUM_OFFSET - sizeof(struct f2fs_checkpoint) + 65)) {
+ if (max_sit_bitmap_size > MAX_SIT_BITMAP_SIZE_IN_CKPT) {
max_nat_bitmap_size = CHECKSUM_OFFSET - sizeof(struct f2fs_checkpoint) + 1;
set_sb(cp_payload, F2FS_BLK_ALIGN(max_sit_bitmap_size));
} else {
@@ -651,6 +651,9 @@ struct f2fs_checkpoint {
unsigned char sit_nat_version_bitmap[1];
} __attribute__((packed));
+#define MAX_SIT_BITMAP_SIZE_IN_CKPT \
+ (CHECKSUM_OFFSET - sizeof(struct f2fs_checkpoint) + 1 - 64)
+
/*
* For orphan inode management
*/
@@ -291,9 +291,7 @@ static int f2fs_prepare_super_block(void)
* When sit is too large, we should expand cp area. It requires more
* pages for cp.
*/
- if (max_sit_bitmap_size >
- (CHECKSUM_OFFSET -
- sizeof(struct f2fs_checkpoint) + 1 - 64)) {
+ if (max_sit_bitmap_size > MAX_SIT_BITMAP_SIZE_IN_CKPT) {
max_nat_bitmap_size = CHECKSUM_OFFSET -
sizeof(struct f2fs_checkpoint) + 1;
set_sb(cp_payload, F2FS_BLK_ALIGN(max_sit_bitmap_size));
For the same reason as "mkfs.f2fs: fix to calculate left space of checkpoint page correctly", this patch also fixes miscalculatation in resize.f2fs. Signed-off-by: Gao Xiang <gaoxiang25@huawei.com> --- fsck/resize.c | 3 +-- include/f2fs_fs.h | 3 +++ mkfs/f2fs_format.c | 4 +--- 3 files changed, 5 insertions(+), 5 deletions(-)