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 <[email protected]>
---
 fsck/resize.c      | 3 +--
 include/f2fs_fs.h  | 3 +++
 mkfs/f2fs_format.c | 4 +---
 3 files changed, 5 insertions(+), 5 deletions(-)

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));
-- 
2.1.4


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

Reply via email to