((le32_to_cpu(ckp->free_segment_count) + 6 -
le32_to_cpu(ckp->overprov_segment_count)) *
f2fs_params.blks_per_seg));
- ckp->cp_pack_total_block_count = cpu_to_le32(5);
+ ckp->cp_pack_total_block_count = cpu_to_le32(8);
+ ckp->ckpt_flags |= CP_UMOUNT_FLAG;
ckp->cp_pack_start_sum = cpu_to_le32(1);
ckp->valid_node_count = cpu_to_le32(1);
ckp->valid_inode_count = cpu_to_le32(1);
}
/* 2. Prepare and write Segment summary for data blocks */
+ memset(sum, 0, sizeof(struct f2fs_summary_block));
SET_SUM_TYPE((&sum->footer), SUM_TYPE_DATA);
sum->entries[0].nid = super_block.root_ino;
/* 3. Fill segment summary for data block to zero. */
memset(sum, 0, sizeof(struct f2fs_summary_block));
+ SET_SUM_TYPE((&sum->footer), SUM_TYPE_DATA);
cp_seg_blk_offset += blk_size_bytes;
if (writetodisk(f2fs_params.fd, sum, cp_seg_blk_offset,
/* 4. Fill segment summary for data block to zero. */
memset(sum, 0, sizeof(struct f2fs_summary_block));
+ SET_SUM_TYPE((&sum->footer), SUM_TYPE_DATA);
/* inode sit for root */
sum->n_sits = cpu_to_le16(6);
return -1;
}
- /* 5. cp page2 */
- cp_seg_blk_offset += blk_size_bytes;
- if (writetodisk(f2fs_params.fd, ckp, cp_seg_blk_offset,
- F2FS_CP_BLOCK_SIZE) < 0) {
- printf("\n\tError: While writing the ckp to disk!!!\n");
- return -1;
- }
-
- /* 6. cp page 1 of check point pack 2
- * Initiatialize other checkpoint pack with version zero
- */
- ckp->checkpoint_ver = 0;
-
- crc = f2fs_cal_crc32(F2FS_SUPER_MAGIC, ckp,
- le32_to_cpu(ckp->checksum_offset));
- *((u_int32_t *)((unsigned char *)ckp +
- le32_to_cpu(ckp->checksum_offset))) = crc;
+ /* 5. Prepare and write Segment summary for node blocks */
+ memset(sum, 0, sizeof(struct f2fs_summary_block));
+ SET_SUM_TYPE((&sum->footer), SUM_TYPE_NODE);
- cp_seg_blk_offset = (le32_to_cpu(super_block.start_segment_checkpoint) +
- f2fs_params.blks_per_seg) *
- blk_size_bytes;
- if (writetodisk(f2fs_params.fd, ckp,
- cp_seg_blk_offset, F2FS_CP_BLOCK_SIZE) < 0) {
- printf("\n\tError: While writing the ckp to disk!!!\n");
- return -1;
- }
+ sum->entries[0].nid = super_block.root_ino;
+ sum->entries[0].ofs_in_node = 0;
- /* 7. */
- memset(sum, 0, sizeof(struct f2fs_summary_block));
- SET_SUM_TYPE((&sum->footer), SUM_TYPE_DATA);
cp_seg_blk_offset += blk_size_bytes;
if (writetodisk(f2fs_params.fd, sum, cp_seg_blk_offset,
sizeof(struct f2fs_summary_block)) < 0) {
return -1;
}
- /* 8. */
+ /* 6. Fill segment summary for data block to zero. */
memset(sum, 0, sizeof(struct f2fs_summary_block));
+ SET_SUM_TYPE((&sum->footer), SUM_TYPE_NODE);
+
cp_seg_blk_offset += blk_size_bytes;
if (writetodisk(f2fs_params.fd, sum, cp_seg_blk_offset,
sizeof(struct f2fs_summary_block)) < 0) {
return -1;
}
- /* 9. */
+ /* 7. Fill segment summary for data block to zero. */
memset(sum, 0, sizeof(struct f2fs_summary_block));
+ SET_SUM_TYPE((&sum->footer), SUM_TYPE_NODE);
cp_seg_blk_offset += blk_size_bytes;
if (writetodisk(f2fs_params.fd, sum, cp_seg_blk_offset,
sizeof(struct f2fs_summary_block)) < 0) {
return -1;
}
- /* 10. cp page 2 of check point pack 2 */
+ /* 8. cp page2 */
cp_seg_blk_offset += blk_size_bytes;
if (writetodisk(f2fs_params.fd, ckp, cp_seg_blk_offset,
F2FS_CP_BLOCK_SIZE) < 0) {
return -1;
}
+ /* 9. cp page 1 of check point pack 2
+ * Initiatialize other checkpoint pack with version zero
+ */
+ ckp->checkpoint_ver = 0;
+
+ crc = f2fs_cal_crc32(F2FS_SUPER_MAGIC, ckp,
+ le32_to_cpu(ckp->checksum_offset));
+ *((u_int32_t *)((unsigned char *)ckp +
+ le32_to_cpu(ckp->checksum_offset))) = crc;
+
+ cp_seg_blk_offset = (le32_to_cpu(super_block.start_segment_checkpoint) +
+ f2fs_params.blks_per_seg) *
+ blk_size_bytes;
+ if (writetodisk(f2fs_params.fd, ckp,
+ cp_seg_blk_offset, F2FS_CP_BLOCK_SIZE) < 0) {
+ printf("\n\tError: While writing the ckp to disk!!!\n");
+ return -1;
+ }
+
free(sum) ;
free(ckp) ;
return 0;