cp_payload is introduced for sit bitmap to support large volume, and it is
just after the block of f2fs_checkpoint + nat bitmap, so the first segment
should include F2FS_CP_PACKS + NR_CURSEG_TYPE + cp_payload + orphan blocks.
However, current max orphan inodes calculation don't consider cp_payload,
this patch fix it by reducing the number of cp_payload from total blocks of
the first segment when calculate max orphan inodes.
Signed-off-by: Wanpeng Li <wanpeng.li@linux.intel.com>
Reviewed-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
        }
 
        /*
-        * considering 512 blocks in a segment 8 blocks are needed for cp
-        * and log segment summaries. Remaining blocks are used to keep
-        * orphan entries with the limitation one reserved segment
-        * for cp pack we can have max 1020*504 orphan entries
+        * considering 512 blocks in a segment 8+cp_payload blocks are
+        * needed for cp and log segment summaries. Remaining blocks are
+        * used to keep orphan entries with the limitation one reserved
+        * segment for cp pack we can have max 1020*(504-cp_payload)
+        * orphan entries
         */
        sbi->max_orphans = (sbi->blocks_per_seg - F2FS_CP_PACKS -
-                       NR_CURSEG_TYPE) * F2FS_ORPHANS_PER_BLOCK;
+                       NR_CURSEG_TYPE - __cp_payload(sbi)) *
+                               F2FS_ORPHANS_PER_BLOCK;
 }
 
 int __init create_checkpoint_caches(void)