Skip to contentSkip to conversation

fsck.f2fs: fix to set CP_LARGE_NAT_BITMAP_FLAG

PATCH In review Chao Yu 2 participants 5 messages Apr 18, 2019 – Apr 19, 2019

lore
Share & tools
lore

Chao Yu

author
#0 lore raw

PATCH 1/1 fsck.f2fs: fix to set CP_LARGE_NAT_BITMAP_FLAG

During fixing checkpoint, if large_nat_bitmap feature is on, we need to set CP_LARGE_NAT_BITMAP_FLAG flag in checkpoint.

---
 fsck/fsck.c  | 2 ++
 fsck/mount.c | 2 ++
 2 files changed, 4 insertions(+)
fsck/fsck.c +2 -0
index a17555c..88ed4d7 100644
@@ -2038,6 +2038,8 @@ static void fix_checkpoint(struct f2fs_sb_info *sbi)
 		flags |= CP_TRIMMED_FLAG;
 	if (is_set_ckpt_flags(cp, CP_DISABLED_FLAG))
 		flags |= CP_DISABLED_FLAG;
+	if (is_set_ckpt_flags(cp, CP_LARGE_NAT_BITMAP_FLAG))
+		flags |= CP_LARGE_NAT_BITMAP_FLAG;
 
 	if (flags & CP_UMOUNT_FLAG)
 		cp_blocks = 8;
fsck/mount.c +2 -0
index aa64e93..20ecf07 100644
@@ -2365,6 +2365,8 @@ void write_checkpoint(struct f2fs_sb_info *sbi)
 		flags |= CP_TRIMMED_FLAG;
 	if (is_set_ckpt_flags(cp, CP_DISABLED_FLAG))
 		flags |= CP_DISABLED_FLAG;
+	if (is_set_ckpt_flags(cp, CP_LARGE_NAT_BITMAP_FLAG))
+		flags |= CP_LARGE_NAT_BITMAP_FLAG;
 
 	set_cp(free_segment_count, get_free_segments(sbi));
 	set_cp(valid_block_count, sbi->total_valid_block_count);
Signature · 1 line
2.18.0.rc1
#1 lore raw

Hi Chao,

The output appears to be similar to the one without this patch, however, it now actually mounts.

[ 2360.127787] F2FS-fs (loop1): Found nat_bits in checkpoint
[ 2360.189038] F2FS-fs (loop1): orphan cleanup on readonly fs
[ 2360.189284] F2FS-fs (loop1): recover fsync data on readonly fs
[ 2360.189297] F2FS-fs (loop1): Mounted with checkpoint version = 761bfa29

Go to here to look at the new fsck output:
http://arter97.com/f2fs/log_2.txt.xz
(previous one is now log_1.txt.xz)

However, something weird goes on.
Without even touching the image after first fsck run, the consecutive 2nd run prints out A LOT of messages:
http://arter97.com/f2fs/log_3.txt.xz

The image seems to mount normally after on both the 1st and the 2nd fsck run.

Thanks.

Quoted 45 lines · Chao Yu

During fixing checkpoint, if large_nat_bitmap feature is on, we need to set CP_LARGE_NAT_BITMAP_FLAG flag in checkpoint.

---
 fsck/fsck.c  | 2 ++
 fsck/mount.c | 2 ++
 2 files changed, 4 insertions(+)
fsck/fsck.c +2 -0
index a17555c..88ed4d7 100644
@@ -2038,6 +2038,8 @@ static void fix_checkpoint(struct f2fs_sb_info *sbi)
                flags |= CP_TRIMMED_FLAG;
        if (is_set_ckpt_flags(cp, CP_DISABLED_FLAG))
                flags |= CP_DISABLED_FLAG;
+       if (is_set_ckpt_flags(cp, CP_LARGE_NAT_BITMAP_FLAG))
+               flags |= CP_LARGE_NAT_BITMAP_FLAG;
 
        if (flags & CP_UMOUNT_FLAG)
                cp_blocks = 8;
fsck/mount.c +2 -1
index aa64e93..20ecf07 100644
@@ -2365,6 +2365,8 @@ void write_checkpoint(struct f2fs_sb_info *sbi)
                flags |= CP_TRIMMED_FLAG;
        if (is_set_ckpt_flags(cp, CP_DISABLED_FLAG))
                flags |= CP_DISABLED_FLAG;
+       if (is_set_ckpt_flags(cp, CP_LARGE_NAT_BITMAP_FLAG))
+               flags |= CP_LARGE_NAT_BITMAP_FLAG;
 
        set_cp(free_segment_count, get_free_segments(sbi));
        set_cp(valid_block_count, sbi->total_valid_block_count);
--

2.18.0.rc1

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

author
#2 lore raw

Hi Ju Hyung,

Quoted 14 lines · Ju Hyung Park

Hi Chao,

The output appears to be similar to the one without this patch, however, it now actually mounts.

[ 2360.127787] F2FS-fs (loop1): Found nat_bits in checkpoint
[ 2360.189038] F2FS-fs (loop1): orphan cleanup on readonly fs
[ 2360.189284] F2FS-fs (loop1): recover fsync data on readonly fs
[ 2360.189297] F2FS-fs (loop1): Mounted with checkpoint version = 761bfa29

Go to here to look at the new fsck output:
http://arter97.com/f2fs/log_2.txt.xz
(previous one is now log_1.txt.xz)

Quoted 6 lines

However, something weird goes on.
Without even touching the image after first fsck run, the consecutive 2nd run prints out A LOT of messages:
http://arter97.com/f2fs/log_3.txt.xz

The image seems to mount normally after on both the 1st and the 2nd fsck run.

Yes, this is because persistence of chksum in checkpoint will damage sit bitmap.

I've sent two patches, could you please try them?

Thanks

Quoted 51 lines

Thanks.

Quoted 41 lines · Chao Yu

During fixing checkpoint, if large_nat_bitmap feature is on, we need to set CP_LARGE_NAT_BITMAP_FLAG flag in checkpoint.

---
 fsck/fsck.c  | 2 ++
 fsck/mount.c | 2 ++
 2 files changed, 4 insertions(+)
fsck/fsck.c +2 -0
index a17555c..88ed4d7 100644
@@ -2038,6 +2038,8 @@ static void fix_checkpoint(struct f2fs_sb_info *sbi)
                flags |= CP_TRIMMED_FLAG;
        if (is_set_ckpt_flags(cp, CP_DISABLED_FLAG))
                flags |= CP_DISABLED_FLAG;
+       if (is_set_ckpt_flags(cp, CP_LARGE_NAT_BITMAP_FLAG))
+               flags |= CP_LARGE_NAT_BITMAP_FLAG;
 
        if (flags & CP_UMOUNT_FLAG)
                cp_blocks = 8;
fsck/mount.c +2 -1
index aa64e93..20ecf07 100644
@@ -2365,6 +2365,8 @@ void write_checkpoint(struct f2fs_sb_info *sbi)
                flags |= CP_TRIMMED_FLAG;
        if (is_set_ckpt_flags(cp, CP_DISABLED_FLAG))
                flags |= CP_DISABLED_FLAG;
+       if (is_set_ckpt_flags(cp, CP_LARGE_NAT_BITMAP_FLAG))
+               flags |= CP_LARGE_NAT_BITMAP_FLAG;
 
        set_cp(free_segment_count, get_free_segments(sbi));
        set_cp(valid_block_count, sbi->total_valid_block_count);
--

2.18.0.rc1

Quoted 4 lines

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

.

#3 lore raw

Hi Chao and Jaegeuk.

Quoted 3 lines · Chao Yu

I've sent two patches, could you please try them?

Thanks

Thanks for the patches.

So it seems like I need to reformat my f2fs partitions, please confirm if that's the case.
Also, if these patches break backward-compatibility, wouldn't it be better to rename the feature and mark the old one deprecated?

I would like to see Jaegeuk's review before mkfs'ing again.

Thanks.

author
#4 lore raw
Quoted 11 lines · Ju Hyung Park

Hi Chao and Jaegeuk.

Quoted 3 lines · Chao Yu

I've sent two patches, could you please try them?

Thanks

Thanks for the patches.

So it seems like I need to reformat my f2fs partitions, please confirm if that's the case.

I think you can try new fsck to check whether it can fix the corrupted image first?

Quoted 2 lines

Also, if these patches break backward-compatibility, wouldn't it be better to rename the feature and mark the old one deprecated?

Yeah, that would be one option, I agree and prefer to listen to Jaegeuk's point of view.

Quoted 6 lines

I would like to see Jaegeuk's review before mkfs'ing again.

Thanks.
.