diff mbox

[f2fs-dev,v2] resize.f2fs: fix max_nat_bitmap_size miscalculatation

Message ID 9047C53C18267742AB12E43B65C7F9F70BCB8BD4@dggemi505-mbs.china.huawei.com (mailing list archive)
State New, archived
Headers show

Commit Message

Gao Xiang Dec. 22, 2017, 4:20 a.m. UTC
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(-)

Comments

Chao Yu Jan. 2, 2018, 6:32 a.m. UTC | #1
On 2017/12/22 12:20, Gaoxiang (OS) wrote:
> 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>

Thanks,
diff mbox

Patch

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 @@  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 {
diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
index d8d199f..d429a6f 100644
--- a/include/f2fs_fs.h
+++ b/include/f2fs_fs.h
@@ -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
  */
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 @@  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));