All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 3/3] mkfs.f2fs: Fix the checkpoint version written to the footer of the root's inode
@ 2018-07-26 22:02 Sotirios-Efstathios Maneas
  2018-07-29  1:14 ` Jaegeuk Kim
  0 siblings, 1 reply; 2+ messages in thread
From: Sotirios-Efstathios Maneas @ 2018-07-26 22:02 UTC (permalink / raw)
  To: linux-f2fs-devel

Fix the checkpoint version written to the footer of the root's inode.

---
 mkfs/f2fs_format.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c
index d844563..fe3112e 100644
--- a/mkfs/f2fs_format.c
+++ b/mkfs/f2fs_format.c
@@ -28,6 +28,7 @@ extern struct f2fs_configuration c;
 struct f2fs_super_block raw_sb;
 struct f2fs_super_block *sb = &raw_sb;
 struct f2fs_checkpoint *cp;
+int f2fs_checkpoint_version;
 
 /* Return first segment number of each area */
 #define prev_zone(cur)		(c.cur_seg[cur] - c.segs_per_zone)
@@ -619,8 +620,7 @@ static int f2fs_write_check_point_pack(void)
 	}
 
 	/* 1. cp page 1 of checkpoint pack 1 */
-	srand(time(NULL));
-	cp->checkpoint_ver = cpu_to_le64(rand() | 0x1);
+	cp->checkpoint_ver = cpu_to_le64(f2fs_checkpoint_version);
 	set_cp(cur_node_segno[0], c.cur_seg[CURSEG_HOT_NODE]);
 	set_cp(cur_node_segno[1], c.cur_seg[CURSEG_WARM_NODE]);
 	set_cp(cur_node_segno[2], c.cur_seg[CURSEG_COLD_NODE]);
@@ -1061,9 +1061,12 @@ static int f2fs_write_root_inode(void)
 		return -1;
 	}
 
+	srand(time(NULL));
+	f2fs_checkpoint_version = rand() | 0x1;
+
 	raw_node->footer.nid = sb->root_ino;
 	raw_node->footer.ino = sb->root_ino;
-	raw_node->footer.cp_ver = cpu_to_le64(1);
+	raw_node->footer.cp_ver = cpu_to_le64(f2fs_checkpoint_version);
 	raw_node->footer.next_blkaddr = cpu_to_le32(
 			get_sb(main_blkaddr) +
 			c.cur_seg[CURSEG_HOT_NODE] *
-- 
2.7.4

Kind regards,
Stathis Maneas


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 3/3] mkfs.f2fs: Fix the checkpoint version written to the footer of the root's inode
  2018-07-26 22:02 [PATCH 3/3] mkfs.f2fs: Fix the checkpoint version written to the footer of the root's inode Sotirios-Efstathios Maneas
@ 2018-07-29  1:14 ` Jaegeuk Kim
  0 siblings, 0 replies; 2+ messages in thread
From: Jaegeuk Kim @ 2018-07-29  1:14 UTC (permalink / raw)
  To: Sotirios-Efstathios Maneas; +Cc: linux-f2fs-devel

On 07/26, Sotirios-Efstathios Maneas wrote:
> Fix the checkpoint version written to the footer of the root's inode.

What does this patch to fix?
The checkpoint_ver in footer is to detect the node is recoverable or not during
roll-forward recovery. So, root_inode doesn't require to have the exact version.

> 
> ---
>  mkfs/f2fs_format.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c
> index d844563..fe3112e 100644
> --- a/mkfs/f2fs_format.c
> +++ b/mkfs/f2fs_format.c
> @@ -28,6 +28,7 @@ extern struct f2fs_configuration c;
>  struct f2fs_super_block raw_sb;
>  struct f2fs_super_block *sb = &raw_sb;
>  struct f2fs_checkpoint *cp;
> +int f2fs_checkpoint_version;

This should be u64.

Thanks,

>  
>  /* Return first segment number of each area */
>  #define prev_zone(cur)		(c.cur_seg[cur] - c.segs_per_zone)
> @@ -619,8 +620,7 @@ static int f2fs_write_check_point_pack(void)
>  	}
>  
>  	/* 1. cp page 1 of checkpoint pack 1 */
> -	srand(time(NULL));
> -	cp->checkpoint_ver = cpu_to_le64(rand() | 0x1);
> +	cp->checkpoint_ver = cpu_to_le64(f2fs_checkpoint_version);
>  	set_cp(cur_node_segno[0], c.cur_seg[CURSEG_HOT_NODE]);
>  	set_cp(cur_node_segno[1], c.cur_seg[CURSEG_WARM_NODE]);
>  	set_cp(cur_node_segno[2], c.cur_seg[CURSEG_COLD_NODE]);
> @@ -1061,9 +1061,12 @@ static int f2fs_write_root_inode(void)
>  		return -1;
>  	}
>  
> +	srand(time(NULL));
> +	f2fs_checkpoint_version = rand() | 0x1;
> +
>  	raw_node->footer.nid = sb->root_ino;
>  	raw_node->footer.ino = sb->root_ino;
> -	raw_node->footer.cp_ver = cpu_to_le64(1);
> +	raw_node->footer.cp_ver = cpu_to_le64(f2fs_checkpoint_version);
>  	raw_node->footer.next_blkaddr = cpu_to_le32(
>  			get_sb(main_blkaddr) +
>  			c.cur_seg[CURSEG_HOT_NODE] *
> -- 
> 2.7.4
> 
> Kind regards,
> Stathis Maneas
> 
> 
> ------------------------------------------------------------------------------
> 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
> Linux-f2fs-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-07-29  1:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-26 22:02 [PATCH 3/3] mkfs.f2fs: Fix the checkpoint version written to the footer of the root's inode Sotirios-Efstathios Maneas
2018-07-29  1:14 ` Jaegeuk Kim

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.