resize.f2fs: fix max_nat_bitmap_size miscalculatation
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>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
diff --git a/fsck/resize.c b/fsck/resize.c
index 6c3eeab..143ad5d 100644
--- a/fsck/resize.c
+++ b/fsck/resize.c
@@ -60,8 +60,7 @@
* 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 {
diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
index 782c936..4739085 100644
--- a/include/f2fs_fs.h
+++ b/include/f2fs_fs.h
@@ -657,6 +657,9 @@
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
*/
diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c
index 583b17f..a130001 100644
--- a/mkfs/f2fs_format.c
+++ b/mkfs/f2fs_format.c
@@ -291,9 +291,7 @@
* 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));