All of lore.kernel.org
 help / color / mirror / Atom feed
* [f2fs-dev] f2fs.resize makes errors in FS
@ 2021-03-19 21:24 beroal
  2021-03-27 13:26 ` beroal
  0 siblings, 1 reply; 9+ messages in thread
From: beroal @ 2021-03-19 21:24 UTC (permalink / raw)
  To: linux-f2fs-devel

Hi. I am trying to use a new function to reduce the size of an F2FS file 
system. After resizing, `fsck.f2fs` gives a lot of errors. Here is a 
shell script that creates and resizes a dummy file system:

```
#!/bin/sh
set -e
F=/tmp/img
D=/dev/loop0
M=/root/mnt/temp
dd bs=1M count=256 if=/dev/zero "of=$F"
losetup "$D" "$F"
mkfs.f2fs "$D"
fsck.f2fs "$D"
mount "$D" "$M"
dd bs=1M count=64 
if=/mnt/data/external/misc/movie/Idiocracy.2006.WEB-DL.1080p-ylnian.mkv 
of="${M}/a.mkv"
umount "$M"
resize.f2fs -s -t 262144 "$D"
fsck.f2fs "$D"
losetup -d "$D"
```

```
+ set -e
+ F=/tmp/img
+ D=/dev/loop0
+ M=/root/mnt/temp
+ dd bs=1M count=256 if=/dev/zero of=/tmp/img
256+0 records in
256+0 records out
268435456 bytes (268 MB, 256 MiB) copied, 0.0867954 s, 3.1 GB/s
+ losetup /dev/loop0 /tmp/img
+ mkfs.f2fs /dev/loop0

     F2FS-tools: mkfs.f2fs Ver: 1.14.0 (2020-08-24)

Info: Disable heap-based policy
Info: Debug level = 0
Info: Trim is enabled
Info: Segments per section = 1
Info: Sections per zone = 1
Info: sector size = 512
Info: total sectors = 524288 (256 MB)
Info: zone aligned segment0 blkaddr: 512
Info: format version with
   "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC) 10.2.0, 
GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021 16:59:58 
+0000"
Info: [/dev/loop0] Discarding device
Info: This device doesn't support BLKSECDISCARD
Info: Discarded 256 MB
Info: Overprovision ratio = 15.000%
Info: Overprovision segments = 35 (GC reserved = 21)
Info: format successful
+ fsck.f2fs /dev/loop0
Info: Segments per section = 1
Info: Sections per zone = 1
Info: sector size = 512
Info: total sectors = 524288 (256 MB)
Info: MKFS version
   "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC) 10.2.0, 
GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021 16:59:58 
+0000"
Info: FSCK version
   from "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC) 
10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021 
16:59:58 +0000"
     to "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC) 
10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021 
16:59:58 +0000"
Info: superblock features = 0 :
Info: superblock encrypt level = 0, salt = 00000000000000000000000000000000
Info: total FS sectors = 524288 (256 MB)
Info: CKPT version = 8aa0d85
Info: Checked valid nat_bits in checkpoint
Info: checkpoint state = 185 :  trimmed nat_bits compacted_summary unmount

[FSCK] Unreachable nat entries                        [Ok..] [0x0]
[FSCK] SIT valid block bitmap checking                [Ok..]
[FSCK] Hard link checking for regular file            [Ok..] [0x0]
[FSCK] valid_block_count matching with CP             [Ok..] [0x2]
[FSCK] valid_node_count matching with CP (de lookup)  [Ok..] [0x1]
[FSCK] valid_node_count matching with CP (nat lookup) [Ok..] [0x1]
[FSCK] valid_inode_count matched with CP              [Ok..] [0x1]
[FSCK] free segment_count matched with CP             [Ok..] [0x72]
[FSCK] next block offset is free                      [Ok..]
[FSCK] fixing SIT types
[FSCK] other corrupted bugs                           [Ok..]

Done: 0.068899 secs
+ mount /dev/loop0 /root/mnt/temp
+ dd bs=1M count=64 
if=/mnt/data/external/misc/movie/Idiocracy.2006.WEB-DL.1080p-ylnian.mkv 
of=/root/mnt/temp/a.mkv
64+0 records in
64+0 records out
67108864 bytes (67 MB, 64 MiB) copied, 0.0286261 s, 2.3 GB/s
+ umount /root/mnt/temp
+ resize.f2fs -s -t 262144 /dev/loop0
Info: Segments per section = 1
Info: Sections per zone = 1
Info: sector size = 512
Info: total sectors = 524288 (256 MB)
Info: MKFS version
   "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC) 10.2.0, 
GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021 16:59:58 
+0000"
Info: FSCK version
   from "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC) 
10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021 
16:59:58 +0000"
     to "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC) 
10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021 
16:59:58 +0000"
Info: superblock features = 0 :
Info: superblock encrypt level = 0, salt = 00000000000000000000000000000000
Info: total FS sectors = 524288 (256 MB)
Info: CKPT version = 8aa0d89
Info: Duplicate valid checkpoint to mirror position 512 -> 1024
Info: Write valid nat_bits in checkpoint
[FIX] (move_one_curseg_info:2798)  --> Move curseg[0] 3 -> 37 after 8000

[FIX] (move_one_curseg_info:2798)  --> Move curseg[1] 3b -> 36 after 8000

[FIX] (move_one_curseg_info:2798)  --> Move curseg[2] 24 -> 35 after 8000

[FIX] (move_one_curseg_info:2798)  --> Move curseg[3] 0 -> 34 after 8000

[FIX] (move_one_curseg_info:2798)  --> Move curseg[4] 1 -> 33 after 8000

[FIX] (move_one_curseg_info:2798)  --> Move curseg[5] 2 -> 32 after 8000

Info: Write valid nat_bits in checkpoint
Try to do defragement: Done
[update_superblock: 695] Info: Done to update superblock
Info: Write valid nat_bits in checkpoint
[rebuild_checkpoint: 585] Info: Done to rebuild checkpoint blocks

Done: 0.065604 secs
+ fsck.f2fs /dev/loop0
Info: Segments per section = 1
Info: Sections per zone = 1
Info: sector size = 512
Info: total sectors = 524288 (256 MB)
Info: MKFS version
   "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC) 10.2.0, 
GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021 16:59:58 
+0000"
Info: FSCK version
   from "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC) 
10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021 
16:59:58 +0000"
     to "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC) 
10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021 
16:59:58 +0000"
Info: superblock features = 0 :
Info: superblock encrypt level = 0, salt = 00000000000000000000000000000000
Info: total FS sectors = 262144 (128 MB)
     Invalid CP CRC offset: 0
Info: CKPT version = 8aa0d8a
Info: Checked valid nat_bits in checkpoint
Info: checkpoint state = 181 :  trimmed nat_bits unmount
[ASSERT] (fsck_chk_curseg_info:2958)  --> Incorrect curseg [1]: segno 
[0x36] type(SIT) [0]
[ASSERT] (fsck_chk_curseg_info:2958)  --> Incorrect curseg [2]: segno 
[0x35] type(SIT) [0]
[ASSERT] (fsck_chk_curseg_info:2958)  --> Incorrect curseg [3]: segno 
[0x34] type(SIT) [0]
[ASSERT] (fsck_chk_curseg_info:2958)  --> Incorrect curseg [4]: segno 
[0x33] type(SIT) [0]
[ASSERT] (fsck_chk_curseg_info:2958)  --> Incorrect curseg [5]: segno 
[0x32] type(SIT) [0]
[ASSERT] (sanity_check_nid: 480)  --> SIT bitmap is 0x0. blk_addr[0x1002]
[ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. blk_addr[0x1601]
[ASSERT] (sanity_check_nid: 480)  --> SIT bitmap is 0x0. blk_addr[0x1211]
[ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. blk_addr[0x4a00]
[ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. blk_addr[0x4a01]
[ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. blk_addr[0x4a02]
[ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. blk_addr[0x4a03]
[ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. blk_addr[0x4a04]
[ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. blk_addr[0x4a05]
[ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. blk_addr[0x4a06]
[ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. blk_addr[0x4a07]
[ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. blk_addr[0x4a08]
[ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. blk_addr[0x4a09]
[ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. blk_addr[0x4a0a]
[ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. blk_addr[0x4a0b]
[ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. blk_addr[0x4a0c]
[ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. blk_addr[0x4a0d]
[ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. blk_addr[0x4a0e]
[ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. blk_addr[0x4a0f]
[ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. blk_addr[0x4a10]
[ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. blk_addr[0x4a11]
[ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. blk_addr[0x4a12]
[ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. blk_addr[0x4a13]
[ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. blk_addr[0x4a14]
[ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. blk_addr[0x4a15]
[ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. blk_addr[0x4a16]
[ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. blk_addr[0x4a17]
[ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. blk_addr[0x4a18]
[ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. blk_addr[0x4a19]
[ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. blk_addr[0x4a1a]
[ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. blk_addr[0x4a1b]
[ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. blk_addr[0x4a1c]
[ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. blk_addr[0x4a1d]
[ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. blk_addr[0x4a1e]
[ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. blk_addr[0x4a1f]
[ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. blk_addr[0x4a20]
[ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. blk_addr[0x4a21]
[ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. blk_addr[0x4a22]
[ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. blk_addr[0x4a23]
[ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. blk_addr[0x4a24]
[ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. blk_addr[0x4a25]
[ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. blk_addr[0x4a26]
[ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. blk_addr[0x4a27]
[ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. blk_addr[0x4a28]
[ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. blk_addr[0x4a29]
[ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. blk_addr[0x4a2a]
{{{skipped}}}
```

The whole output is huge.



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

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

* Re: [f2fs-dev] f2fs.resize makes errors in FS
  2021-03-19 21:24 [f2fs-dev] f2fs.resize makes errors in FS beroal
@ 2021-03-27 13:26 ` beroal
  2021-03-29  1:51   ` Chao Yu
  0 siblings, 1 reply; 9+ messages in thread
From: beroal @ 2021-03-27 13:26 UTC (permalink / raw)
  To: linux-f2fs-devel

Ping.

On 19.03.21 23:24, beroal wrote:
> Hi. I am trying to use a new function to reduce the size of an F2FS 
> file system. After resizing, `fsck.f2fs` gives a lot of errors. Here 
> is a shell script that creates and resizes a dummy file system:
>
> ```
> #!/bin/sh
> set -e
> F=/tmp/img
> D=/dev/loop0
> M=/root/mnt/temp
> dd bs=1M count=256 if=/dev/zero "of=$F"
> losetup "$D" "$F"
> mkfs.f2fs "$D"
> fsck.f2fs "$D"
> mount "$D" "$M"
> dd bs=1M count=64 
> if=/mnt/data/external/misc/movie/Idiocracy.2006.WEB-DL.1080p-ylnian.mkv 
> of="${M}/a.mkv"
> umount "$M"
> resize.f2fs -s -t 262144 "$D"
> fsck.f2fs "$D"
> losetup -d "$D"
> ```
>
> ```
> + set -e
> + F=/tmp/img
> + D=/dev/loop0
> + M=/root/mnt/temp
> + dd bs=1M count=256 if=/dev/zero of=/tmp/img
> 256+0 records in
> 256+0 records out
> 268435456 bytes (268 MB, 256 MiB) copied, 0.0867954 s, 3.1 GB/s
> + losetup /dev/loop0 /tmp/img
> + mkfs.f2fs /dev/loop0
>
>     F2FS-tools: mkfs.f2fs Ver: 1.14.0 (2020-08-24)
>
> Info: Disable heap-based policy
> Info: Debug level = 0
> Info: Trim is enabled
> Info: Segments per section = 1
> Info: Sections per zone = 1
> Info: sector size = 512
> Info: total sectors = 524288 (256 MB)
> Info: zone aligned segment0 blkaddr: 512
> Info: format version with
>   "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC) 10.2.0, 
> GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021 16:59:58 
> +0000"
> Info: [/dev/loop0] Discarding device
> Info: This device doesn't support BLKSECDISCARD
> Info: Discarded 256 MB
> Info: Overprovision ratio = 15.000%
> Info: Overprovision segments = 35 (GC reserved = 21)
> Info: format successful
> + fsck.f2fs /dev/loop0
> Info: Segments per section = 1
> Info: Sections per zone = 1
> Info: sector size = 512
> Info: total sectors = 524288 (256 MB)
> Info: MKFS version
>   "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC) 10.2.0, 
> GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021 16:59:58 
> +0000"
> Info: FSCK version
>   from "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC) 
> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021 
> 16:59:58 +0000"
>     to "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC) 
> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021 
> 16:59:58 +0000"
> Info: superblock features = 0 :
> Info: superblock encrypt level = 0, salt = 
> 00000000000000000000000000000000
> Info: total FS sectors = 524288 (256 MB)
> Info: CKPT version = 8aa0d85
> Info: Checked valid nat_bits in checkpoint
> Info: checkpoint state = 185 :  trimmed nat_bits compacted_summary 
> unmount
>
> [FSCK] Unreachable nat entries                        [Ok..] [0x0]
> [FSCK] SIT valid block bitmap checking                [Ok..]
> [FSCK] Hard link checking for regular file            [Ok..] [0x0]
> [FSCK] valid_block_count matching with CP             [Ok..] [0x2]
> [FSCK] valid_node_count matching with CP (de lookup)  [Ok..] [0x1]
> [FSCK] valid_node_count matching with CP (nat lookup) [Ok..] [0x1]
> [FSCK] valid_inode_count matched with CP              [Ok..] [0x1]
> [FSCK] free segment_count matched with CP             [Ok..] [0x72]
> [FSCK] next block offset is free                      [Ok..]
> [FSCK] fixing SIT types
> [FSCK] other corrupted bugs                           [Ok..]
>
> Done: 0.068899 secs
> + mount /dev/loop0 /root/mnt/temp
> + dd bs=1M count=64 
> if=/mnt/data/external/misc/movie/Idiocracy.2006.WEB-DL.1080p-ylnian.mkv 
> of=/root/mnt/temp/a.mkv
> 64+0 records in
> 64+0 records out
> 67108864 bytes (67 MB, 64 MiB) copied, 0.0286261 s, 2.3 GB/s
> + umount /root/mnt/temp
> + resize.f2fs -s -t 262144 /dev/loop0
> Info: Segments per section = 1
> Info: Sections per zone = 1
> Info: sector size = 512
> Info: total sectors = 524288 (256 MB)
> Info: MKFS version
>   "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC) 10.2.0, 
> GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021 16:59:58 
> +0000"
> Info: FSCK version
>   from "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC) 
> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021 
> 16:59:58 +0000"
>     to "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC) 
> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021 
> 16:59:58 +0000"
> Info: superblock features = 0 :
> Info: superblock encrypt level = 0, salt = 
> 00000000000000000000000000000000
> Info: total FS sectors = 524288 (256 MB)
> Info: CKPT version = 8aa0d89
> Info: Duplicate valid checkpoint to mirror position 512 -> 1024
> Info: Write valid nat_bits in checkpoint
> [FIX] (move_one_curseg_info:2798)  --> Move curseg[0] 3 -> 37 after 8000
>
> [FIX] (move_one_curseg_info:2798)  --> Move curseg[1] 3b -> 36 after 8000
>
> [FIX] (move_one_curseg_info:2798)  --> Move curseg[2] 24 -> 35 after 8000
>
> [FIX] (move_one_curseg_info:2798)  --> Move curseg[3] 0 -> 34 after 8000
>
> [FIX] (move_one_curseg_info:2798)  --> Move curseg[4] 1 -> 33 after 8000
>
> [FIX] (move_one_curseg_info:2798)  --> Move curseg[5] 2 -> 32 after 8000
>
> Info: Write valid nat_bits in checkpoint
> Try to do defragement: Done
> [update_superblock: 695] Info: Done to update superblock
> Info: Write valid nat_bits in checkpoint
> [rebuild_checkpoint: 585] Info: Done to rebuild checkpoint blocks
>
> Done: 0.065604 secs
> + fsck.f2fs /dev/loop0
> Info: Segments per section = 1
> Info: Sections per zone = 1
> Info: sector size = 512
> Info: total sectors = 524288 (256 MB)
> Info: MKFS version
>   "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC) 10.2.0, 
> GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021 16:59:58 
> +0000"
> Info: FSCK version
>   from "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC) 
> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021 
> 16:59:58 +0000"
>     to "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC) 
> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021 
> 16:59:58 +0000"
> Info: superblock features = 0 :
> Info: superblock encrypt level = 0, salt = 
> 00000000000000000000000000000000
> Info: total FS sectors = 262144 (128 MB)
>     Invalid CP CRC offset: 0
> Info: CKPT version = 8aa0d8a
> Info: Checked valid nat_bits in checkpoint
> Info: checkpoint state = 181 :  trimmed nat_bits unmount
> [ASSERT] (fsck_chk_curseg_info:2958)  --> Incorrect curseg [1]: segno 
> [0x36] type(SIT) [0]
> [ASSERT] (fsck_chk_curseg_info:2958)  --> Incorrect curseg [2]: segno 
> [0x35] type(SIT) [0]
> [ASSERT] (fsck_chk_curseg_info:2958)  --> Incorrect curseg [3]: segno 
> [0x34] type(SIT) [0]
> [ASSERT] (fsck_chk_curseg_info:2958)  --> Incorrect curseg [4]: segno 
> [0x33] type(SIT) [0]
> [ASSERT] (fsck_chk_curseg_info:2958)  --> Incorrect curseg [5]: segno 
> [0x32] type(SIT) [0]
> [ASSERT] (sanity_check_nid: 480)  --> SIT bitmap is 0x0. blk_addr[0x1002]
> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. 
> blk_addr[0x1601]
> [ASSERT] (sanity_check_nid: 480)  --> SIT bitmap is 0x0. blk_addr[0x1211]
> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. 
> blk_addr[0x4a00]
> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. 
> blk_addr[0x4a01]
> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. 
> blk_addr[0x4a02]
> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. 
> blk_addr[0x4a03]
> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. 
> blk_addr[0x4a04]
> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. 
> blk_addr[0x4a05]
> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. 
> blk_addr[0x4a06]
> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. 
> blk_addr[0x4a07]
> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. 
> blk_addr[0x4a08]
> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. 
> blk_addr[0x4a09]
> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. 
> blk_addr[0x4a0a]
> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. 
> blk_addr[0x4a0b]
> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. 
> blk_addr[0x4a0c]
> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. 
> blk_addr[0x4a0d]
> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. 
> blk_addr[0x4a0e]
> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. 
> blk_addr[0x4a0f]
> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. 
> blk_addr[0x4a10]
> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. 
> blk_addr[0x4a11]
> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. 
> blk_addr[0x4a12]
> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. 
> blk_addr[0x4a13]
> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. 
> blk_addr[0x4a14]
> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. 
> blk_addr[0x4a15]
> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. 
> blk_addr[0x4a16]
> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. 
> blk_addr[0x4a17]
> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. 
> blk_addr[0x4a18]
> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. 
> blk_addr[0x4a19]
> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. 
> blk_addr[0x4a1a]
> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. 
> blk_addr[0x4a1b]
> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. 
> blk_addr[0x4a1c]
> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. 
> blk_addr[0x4a1d]
> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. 
> blk_addr[0x4a1e]
> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. 
> blk_addr[0x4a1f]
> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. 
> blk_addr[0x4a20]
> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. 
> blk_addr[0x4a21]
> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. 
> blk_addr[0x4a22]
> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. 
> blk_addr[0x4a23]
> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. 
> blk_addr[0x4a24]
> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. 
> blk_addr[0x4a25]
> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. 
> blk_addr[0x4a26]
> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. 
> blk_addr[0x4a27]
> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. 
> blk_addr[0x4a28]
> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. 
> blk_addr[0x4a29]
> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0. 
> blk_addr[0x4a2a]
> {{{skipped}}}
> ```
>
> The whole output is huge.
>
>
>
> _______________________________________________
> Linux-f2fs-devel mailing list
> Linux-f2fs-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

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

* Re: [f2fs-dev] f2fs.resize makes errors in FS
  2021-03-27 13:26 ` beroal
@ 2021-03-29  1:51   ` Chao Yu
  2021-04-02  7:23     ` Chao Yu
  0 siblings, 1 reply; 9+ messages in thread
From: Chao Yu @ 2021-03-29  1:51 UTC (permalink / raw)
  To: beroal, linux-f2fs-devel

Hello,

Sorry for the delay reply.

I can reproduce this bug now, but I haven't enough time for debuging, will
check this soon.

On 2021/3/27 21:26, beroal wrote:
> Ping.
> 
> On 19.03.21 23:24, beroal wrote:
>> Hi. I am trying to use a new function to reduce the size of an F2FS
>> file system. After resizing, `fsck.f2fs` gives a lot of errors. Here
>> is a shell script that creates and resizes a dummy file system:
>>
>> ```
>> #!/bin/sh
>> set -e
>> F=/tmp/img
>> D=/dev/loop0
>> M=/root/mnt/temp
>> dd bs=1M count=256 if=/dev/zero "of=$F"
>> losetup "$D" "$F"
>> mkfs.f2fs "$D"
>> fsck.f2fs "$D"
>> mount "$D" "$M"
>> dd bs=1M count=64
>> if=/mnt/data/external/misc/movie/Idiocracy.2006.WEB-DL.1080p-ylnian.mkv
>> of="${M}/a.mkv"
>> umount "$M"
>> resize.f2fs -s -t 262144 "$D"
>> fsck.f2fs "$D"
>> losetup -d "$D"
>> ```
>>
>> ```
>> + set -e
>> + F=/tmp/img
>> + D=/dev/loop0
>> + M=/root/mnt/temp
>> + dd bs=1M count=256 if=/dev/zero of=/tmp/img
>> 256+0 records in
>> 256+0 records out
>> 268435456 bytes (268 MB, 256 MiB) copied, 0.0867954 s, 3.1 GB/s
>> + losetup /dev/loop0 /tmp/img
>> + mkfs.f2fs /dev/loop0
>>
>>      F2FS-tools: mkfs.f2fs Ver: 1.14.0 (2020-08-24)
>>
>> Info: Disable heap-based policy
>> Info: Debug level = 0
>> Info: Trim is enabled
>> Info: Segments per section = 1
>> Info: Sections per zone = 1
>> Info: sector size = 512
>> Info: total sectors = 524288 (256 MB)
>> Info: zone aligned segment0 blkaddr: 512
>> Info: format version with
>>    "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC) 10.2.0,
>> GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021 16:59:58
>> +0000"
>> Info: [/dev/loop0] Discarding device
>> Info: This device doesn't support BLKSECDISCARD
>> Info: Discarded 256 MB
>> Info: Overprovision ratio = 15.000%
>> Info: Overprovision segments = 35 (GC reserved = 21)
>> Info: format successful
>> + fsck.f2fs /dev/loop0
>> Info: Segments per section = 1
>> Info: Sections per zone = 1
>> Info: sector size = 512
>> Info: total sectors = 524288 (256 MB)
>> Info: MKFS version
>>    "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC) 10.2.0,
>> GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021 16:59:58
>> +0000"
>> Info: FSCK version
>>    from "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC)
>> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021
>> 16:59:58 +0000"
>>      to "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC)
>> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021
>> 16:59:58 +0000"
>> Info: superblock features = 0 :
>> Info: superblock encrypt level = 0, salt =
>> 00000000000000000000000000000000
>> Info: total FS sectors = 524288 (256 MB)
>> Info: CKPT version = 8aa0d85
>> Info: Checked valid nat_bits in checkpoint
>> Info: checkpoint state = 185 :  trimmed nat_bits compacted_summary
>> unmount
>>
>> [FSCK] Unreachable nat entries                        [Ok..] [0x0]
>> [FSCK] SIT valid block bitmap checking                [Ok..]
>> [FSCK] Hard link checking for regular file            [Ok..] [0x0]
>> [FSCK] valid_block_count matching with CP             [Ok..] [0x2]
>> [FSCK] valid_node_count matching with CP (de lookup)  [Ok..] [0x1]
>> [FSCK] valid_node_count matching with CP (nat lookup) [Ok..] [0x1]
>> [FSCK] valid_inode_count matched with CP              [Ok..] [0x1]
>> [FSCK] free segment_count matched with CP             [Ok..] [0x72]
>> [FSCK] next block offset is free                      [Ok..]
>> [FSCK] fixing SIT types
>> [FSCK] other corrupted bugs                           [Ok..]
>>
>> Done: 0.068899 secs
>> + mount /dev/loop0 /root/mnt/temp
>> + dd bs=1M count=64
>> if=/mnt/data/external/misc/movie/Idiocracy.2006.WEB-DL.1080p-ylnian.mkv
>> of=/root/mnt/temp/a.mkv
>> 64+0 records in
>> 64+0 records out
>> 67108864 bytes (67 MB, 64 MiB) copied, 0.0286261 s, 2.3 GB/s
>> + umount /root/mnt/temp
>> + resize.f2fs -s -t 262144 /dev/loop0
>> Info: Segments per section = 1
>> Info: Sections per zone = 1
>> Info: sector size = 512
>> Info: total sectors = 524288 (256 MB)
>> Info: MKFS version
>>    "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC) 10.2.0,
>> GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021 16:59:58
>> +0000"
>> Info: FSCK version
>>    from "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC)
>> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021
>> 16:59:58 +0000"
>>      to "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC)
>> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021
>> 16:59:58 +0000"
>> Info: superblock features = 0 :
>> Info: superblock encrypt level = 0, salt =
>> 00000000000000000000000000000000
>> Info: total FS sectors = 524288 (256 MB)
>> Info: CKPT version = 8aa0d89
>> Info: Duplicate valid checkpoint to mirror position 512 -> 1024
>> Info: Write valid nat_bits in checkpoint
>> [FIX] (move_one_curseg_info:2798)  --> Move curseg[0] 3 -> 37 after 8000
>>
>> [FIX] (move_one_curseg_info:2798)  --> Move curseg[1] 3b -> 36 after 8000
>>
>> [FIX] (move_one_curseg_info:2798)  --> Move curseg[2] 24 -> 35 after 8000
>>
>> [FIX] (move_one_curseg_info:2798)  --> Move curseg[3] 0 -> 34 after 8000
>>
>> [FIX] (move_one_curseg_info:2798)  --> Move curseg[4] 1 -> 33 after 8000
>>
>> [FIX] (move_one_curseg_info:2798)  --> Move curseg[5] 2 -> 32 after 8000
>>
>> Info: Write valid nat_bits in checkpoint
>> Try to do defragement: Done
>> [update_superblock: 695] Info: Done to update superblock
>> Info: Write valid nat_bits in checkpoint
>> [rebuild_checkpoint: 585] Info: Done to rebuild checkpoint blocks
>>
>> Done: 0.065604 secs
>> + fsck.f2fs /dev/loop0
>> Info: Segments per section = 1
>> Info: Sections per zone = 1
>> Info: sector size = 512
>> Info: total sectors = 524288 (256 MB)
>> Info: MKFS version
>>    "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC) 10.2.0,
>> GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021 16:59:58
>> +0000"
>> Info: FSCK version
>>    from "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC)
>> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021
>> 16:59:58 +0000"
>>      to "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC)
>> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021
>> 16:59:58 +0000"
>> Info: superblock features = 0 :
>> Info: superblock encrypt level = 0, salt =
>> 00000000000000000000000000000000
>> Info: total FS sectors = 262144 (128 MB)
>>      Invalid CP CRC offset: 0
>> Info: CKPT version = 8aa0d8a
>> Info: Checked valid nat_bits in checkpoint
>> Info: checkpoint state = 181 :  trimmed nat_bits unmount
>> [ASSERT] (fsck_chk_curseg_info:2958)  --> Incorrect curseg [1]: segno
>> [0x36] type(SIT) [0]
>> [ASSERT] (fsck_chk_curseg_info:2958)  --> Incorrect curseg [2]: segno
>> [0x35] type(SIT) [0]
>> [ASSERT] (fsck_chk_curseg_info:2958)  --> Incorrect curseg [3]: segno
>> [0x34] type(SIT) [0]
>> [ASSERT] (fsck_chk_curseg_info:2958)  --> Incorrect curseg [4]: segno
>> [0x33] type(SIT) [0]
>> [ASSERT] (fsck_chk_curseg_info:2958)  --> Incorrect curseg [5]: segno
>> [0x32] type(SIT) [0]
>> [ASSERT] (sanity_check_nid: 480)  --> SIT bitmap is 0x0. blk_addr[0x1002]
>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>> blk_addr[0x1601]
>> [ASSERT] (sanity_check_nid: 480)  --> SIT bitmap is 0x0. blk_addr[0x1211]
>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>> blk_addr[0x4a00]
>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>> blk_addr[0x4a01]
>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>> blk_addr[0x4a02]
>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>> blk_addr[0x4a03]
>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>> blk_addr[0x4a04]
>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>> blk_addr[0x4a05]
>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>> blk_addr[0x4a06]
>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>> blk_addr[0x4a07]
>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>> blk_addr[0x4a08]
>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>> blk_addr[0x4a09]
>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>> blk_addr[0x4a0a]
>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>> blk_addr[0x4a0b]
>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>> blk_addr[0x4a0c]
>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>> blk_addr[0x4a0d]
>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>> blk_addr[0x4a0e]
>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>> blk_addr[0x4a0f]
>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>> blk_addr[0x4a10]
>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>> blk_addr[0x4a11]
>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>> blk_addr[0x4a12]
>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>> blk_addr[0x4a13]
>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>> blk_addr[0x4a14]
>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>> blk_addr[0x4a15]
>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>> blk_addr[0x4a16]
>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>> blk_addr[0x4a17]
>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>> blk_addr[0x4a18]
>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>> blk_addr[0x4a19]
>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>> blk_addr[0x4a1a]
>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>> blk_addr[0x4a1b]
>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>> blk_addr[0x4a1c]
>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>> blk_addr[0x4a1d]
>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>> blk_addr[0x4a1e]
>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>> blk_addr[0x4a1f]
>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>> blk_addr[0x4a20]
>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>> blk_addr[0x4a21]
>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>> blk_addr[0x4a22]
>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>> blk_addr[0x4a23]
>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>> blk_addr[0x4a24]
>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>> blk_addr[0x4a25]
>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>> blk_addr[0x4a26]
>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>> blk_addr[0x4a27]
>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>> blk_addr[0x4a28]
>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>> blk_addr[0x4a29]
>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>> blk_addr[0x4a2a]
>> {{{skipped}}}
>> ```
>>
>> The whole output is huge.
>>
>>
>>
>> _______________________________________________
>> Linux-f2fs-devel mailing list
>> Linux-f2fs-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
> 
> 
> _______________________________________________
> Linux-f2fs-devel mailing list
> Linux-f2fs-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
> 


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

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

* Re: [f2fs-dev] f2fs.resize makes errors in FS
  2021-03-29  1:51   ` Chao Yu
@ 2021-04-02  7:23     ` Chao Yu
  2021-04-02  9:28       ` beroal
  0 siblings, 1 reply; 9+ messages in thread
From: Chao Yu @ 2021-04-02  7:23 UTC (permalink / raw)
  To: beroal, linux-f2fs-devel

Hi beroal,

I  figured out a patch, could you please check with it?

[PATCH] resize.f2fs: fix wrong sit/nat bitmap during rebuild_checkpoint()

On 2021/3/29 9:51, Chao Yu wrote:
> Hello,
> 
> Sorry for the delay reply.
> 
> I can reproduce this bug now, but I haven't enough time for debuging, will
> check this soon.
> 
> On 2021/3/27 21:26, beroal wrote:
>> Ping.
>>
>> On 19.03.21 23:24, beroal wrote:
>>> Hi. I am trying to use a new function to reduce the size of an F2FS
>>> file system. After resizing, `fsck.f2fs` gives a lot of errors. Here
>>> is a shell script that creates and resizes a dummy file system:
>>>
>>> ```
>>> #!/bin/sh
>>> set -e
>>> F=/tmp/img
>>> D=/dev/loop0
>>> M=/root/mnt/temp
>>> dd bs=1M count=256 if=/dev/zero "of=$F"
>>> losetup "$D" "$F"
>>> mkfs.f2fs "$D"
>>> fsck.f2fs "$D"
>>> mount "$D" "$M"
>>> dd bs=1M count=64
>>> if=/mnt/data/external/misc/movie/Idiocracy.2006.WEB-DL.1080p-ylnian.mkv
>>> of="${M}/a.mkv"
>>> umount "$M"
>>> resize.f2fs -s -t 262144 "$D"
>>> fsck.f2fs "$D"
>>> losetup -d "$D"
>>> ```
>>>
>>> ```
>>> + set -e
>>> + F=/tmp/img
>>> + D=/dev/loop0
>>> + M=/root/mnt/temp
>>> + dd bs=1M count=256 if=/dev/zero of=/tmp/img
>>> 256+0 records in
>>> 256+0 records out
>>> 268435456 bytes (268 MB, 256 MiB) copied, 0.0867954 s, 3.1 GB/s
>>> + losetup /dev/loop0 /tmp/img
>>> + mkfs.f2fs /dev/loop0
>>>
>>>       F2FS-tools: mkfs.f2fs Ver: 1.14.0 (2020-08-24)
>>>
>>> Info: Disable heap-based policy
>>> Info: Debug level = 0
>>> Info: Trim is enabled
>>> Info: Segments per section = 1
>>> Info: Sections per zone = 1
>>> Info: sector size = 512
>>> Info: total sectors = 524288 (256 MB)
>>> Info: zone aligned segment0 blkaddr: 512
>>> Info: format version with
>>>     "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC) 10.2.0,
>>> GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021 16:59:58
>>> +0000"
>>> Info: [/dev/loop0] Discarding device
>>> Info: This device doesn't support BLKSECDISCARD
>>> Info: Discarded 256 MB
>>> Info: Overprovision ratio = 15.000%
>>> Info: Overprovision segments = 35 (GC reserved = 21)
>>> Info: format successful
>>> + fsck.f2fs /dev/loop0
>>> Info: Segments per section = 1
>>> Info: Sections per zone = 1
>>> Info: sector size = 512
>>> Info: total sectors = 524288 (256 MB)
>>> Info: MKFS version
>>>     "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC) 10.2.0,
>>> GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021 16:59:58
>>> +0000"
>>> Info: FSCK version
>>>     from "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC)
>>> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021
>>> 16:59:58 +0000"
>>>       to "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC)
>>> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021
>>> 16:59:58 +0000"
>>> Info: superblock features = 0 :
>>> Info: superblock encrypt level = 0, salt =
>>> 00000000000000000000000000000000
>>> Info: total FS sectors = 524288 (256 MB)
>>> Info: CKPT version = 8aa0d85
>>> Info: Checked valid nat_bits in checkpoint
>>> Info: checkpoint state = 185 :  trimmed nat_bits compacted_summary
>>> unmount
>>>
>>> [FSCK] Unreachable nat entries                        [Ok..] [0x0]
>>> [FSCK] SIT valid block bitmap checking                [Ok..]
>>> [FSCK] Hard link checking for regular file            [Ok..] [0x0]
>>> [FSCK] valid_block_count matching with CP             [Ok..] [0x2]
>>> [FSCK] valid_node_count matching with CP (de lookup)  [Ok..] [0x1]
>>> [FSCK] valid_node_count matching with CP (nat lookup) [Ok..] [0x1]
>>> [FSCK] valid_inode_count matched with CP              [Ok..] [0x1]
>>> [FSCK] free segment_count matched with CP             [Ok..] [0x72]
>>> [FSCK] next block offset is free                      [Ok..]
>>> [FSCK] fixing SIT types
>>> [FSCK] other corrupted bugs                           [Ok..]
>>>
>>> Done: 0.068899 secs
>>> + mount /dev/loop0 /root/mnt/temp
>>> + dd bs=1M count=64
>>> if=/mnt/data/external/misc/movie/Idiocracy.2006.WEB-DL.1080p-ylnian.mkv
>>> of=/root/mnt/temp/a.mkv
>>> 64+0 records in
>>> 64+0 records out
>>> 67108864 bytes (67 MB, 64 MiB) copied, 0.0286261 s, 2.3 GB/s
>>> + umount /root/mnt/temp
>>> + resize.f2fs -s -t 262144 /dev/loop0
>>> Info: Segments per section = 1
>>> Info: Sections per zone = 1
>>> Info: sector size = 512
>>> Info: total sectors = 524288 (256 MB)
>>> Info: MKFS version
>>>     "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC) 10.2.0,
>>> GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021 16:59:58
>>> +0000"
>>> Info: FSCK version
>>>     from "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC)
>>> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021
>>> 16:59:58 +0000"
>>>       to "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC)
>>> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021
>>> 16:59:58 +0000"
>>> Info: superblock features = 0 :
>>> Info: superblock encrypt level = 0, salt =
>>> 00000000000000000000000000000000
>>> Info: total FS sectors = 524288 (256 MB)
>>> Info: CKPT version = 8aa0d89
>>> Info: Duplicate valid checkpoint to mirror position 512 -> 1024
>>> Info: Write valid nat_bits in checkpoint
>>> [FIX] (move_one_curseg_info:2798)  --> Move curseg[0] 3 -> 37 after 8000
>>>
>>> [FIX] (move_one_curseg_info:2798)  --> Move curseg[1] 3b -> 36 after 8000
>>>
>>> [FIX] (move_one_curseg_info:2798)  --> Move curseg[2] 24 -> 35 after 8000
>>>
>>> [FIX] (move_one_curseg_info:2798)  --> Move curseg[3] 0 -> 34 after 8000
>>>
>>> [FIX] (move_one_curseg_info:2798)  --> Move curseg[4] 1 -> 33 after 8000
>>>
>>> [FIX] (move_one_curseg_info:2798)  --> Move curseg[5] 2 -> 32 after 8000
>>>
>>> Info: Write valid nat_bits in checkpoint
>>> Try to do defragement: Done
>>> [update_superblock: 695] Info: Done to update superblock
>>> Info: Write valid nat_bits in checkpoint
>>> [rebuild_checkpoint: 585] Info: Done to rebuild checkpoint blocks
>>>
>>> Done: 0.065604 secs
>>> + fsck.f2fs /dev/loop0
>>> Info: Segments per section = 1
>>> Info: Sections per zone = 1
>>> Info: sector size = 512
>>> Info: total sectors = 524288 (256 MB)
>>> Info: MKFS version
>>>     "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC) 10.2.0,
>>> GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021 16:59:58
>>> +0000"
>>> Info: FSCK version
>>>     from "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC)
>>> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021
>>> 16:59:58 +0000"
>>>       to "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC)
>>> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021
>>> 16:59:58 +0000"
>>> Info: superblock features = 0 :
>>> Info: superblock encrypt level = 0, salt =
>>> 00000000000000000000000000000000
>>> Info: total FS sectors = 262144 (128 MB)
>>>       Invalid CP CRC offset: 0
>>> Info: CKPT version = 8aa0d8a
>>> Info: Checked valid nat_bits in checkpoint
>>> Info: checkpoint state = 181 :  trimmed nat_bits unmount
>>> [ASSERT] (fsck_chk_curseg_info:2958)  --> Incorrect curseg [1]: segno
>>> [0x36] type(SIT) [0]
>>> [ASSERT] (fsck_chk_curseg_info:2958)  --> Incorrect curseg [2]: segno
>>> [0x35] type(SIT) [0]
>>> [ASSERT] (fsck_chk_curseg_info:2958)  --> Incorrect curseg [3]: segno
>>> [0x34] type(SIT) [0]
>>> [ASSERT] (fsck_chk_curseg_info:2958)  --> Incorrect curseg [4]: segno
>>> [0x33] type(SIT) [0]
>>> [ASSERT] (fsck_chk_curseg_info:2958)  --> Incorrect curseg [5]: segno
>>> [0x32] type(SIT) [0]
>>> [ASSERT] (sanity_check_nid: 480)  --> SIT bitmap is 0x0. blk_addr[0x1002]
>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>> blk_addr[0x1601]
>>> [ASSERT] (sanity_check_nid: 480)  --> SIT bitmap is 0x0. blk_addr[0x1211]
>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>> blk_addr[0x4a00]
>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>> blk_addr[0x4a01]
>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>> blk_addr[0x4a02]
>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>> blk_addr[0x4a03]
>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>> blk_addr[0x4a04]
>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>> blk_addr[0x4a05]
>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>> blk_addr[0x4a06]
>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>> blk_addr[0x4a07]
>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>> blk_addr[0x4a08]
>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>> blk_addr[0x4a09]
>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>> blk_addr[0x4a0a]
>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>> blk_addr[0x4a0b]
>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>> blk_addr[0x4a0c]
>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>> blk_addr[0x4a0d]
>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>> blk_addr[0x4a0e]
>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>> blk_addr[0x4a0f]
>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>> blk_addr[0x4a10]
>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>> blk_addr[0x4a11]
>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>> blk_addr[0x4a12]
>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>> blk_addr[0x4a13]
>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>> blk_addr[0x4a14]
>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>> blk_addr[0x4a15]
>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>> blk_addr[0x4a16]
>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>> blk_addr[0x4a17]
>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>> blk_addr[0x4a18]
>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>> blk_addr[0x4a19]
>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>> blk_addr[0x4a1a]
>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>> blk_addr[0x4a1b]
>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>> blk_addr[0x4a1c]
>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>> blk_addr[0x4a1d]
>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>> blk_addr[0x4a1e]
>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>> blk_addr[0x4a1f]
>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>> blk_addr[0x4a20]
>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>> blk_addr[0x4a21]
>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>> blk_addr[0x4a22]
>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>> blk_addr[0x4a23]
>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>> blk_addr[0x4a24]
>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>> blk_addr[0x4a25]
>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>> blk_addr[0x4a26]
>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>> blk_addr[0x4a27]
>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>> blk_addr[0x4a28]
>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>> blk_addr[0x4a29]
>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>> blk_addr[0x4a2a]
>>> {{{skipped}}}
>>> ```
>>>
>>> The whole output is huge.
>>>
>>>
>>>
>>> _______________________________________________
>>> Linux-f2fs-devel mailing list
>>> Linux-f2fs-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
>>
>>
>> _______________________________________________
>> Linux-f2fs-devel mailing list
>> Linux-f2fs-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
>>
> 
> 
> _______________________________________________
> Linux-f2fs-devel mailing list
> Linux-f2fs-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
> 


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

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

* Re: [f2fs-dev] f2fs.resize makes errors in FS
  2021-04-02  7:23     ` Chao Yu
@ 2021-04-02  9:28       ` beroal
  2021-04-02 10:30         ` Chao Yu
  2021-04-06  1:44         ` Chao Yu
  0 siblings, 2 replies; 9+ messages in thread
From: beroal @ 2021-04-02  9:28 UTC (permalink / raw)
  To: Chao Yu, linux-f2fs-devel

I can't mount the resulting file system.

```
+ set -e
+ F=/tmp/img
+ D=/dev/loop0
+ M=/root/mnt/temp
+ dd bs=1M count=256 if=/dev/zero of=/tmp/img
256+0 records in
256+0 records out
268435456 bytes (268 MB, 256 MiB) copied, 0,0937109 s, 2,9 GB/s
+ losetup /dev/loop0 /tmp/img
+ mkfs.f2fs /dev/loop0

     F2FS-tools: mkfs.f2fs Ver: 1.14.0 (2020-08-24)

Info: Disable heap-based policy
Info: Debug level = 0
Info: Trim is enabled
Info: Segments per section = 1
Info: Sections per zone = 1
Info: sector size = 512
Info: total sectors = 524288 (256 MB)
Info: zone aligned segment0 blkaddr: 512
Info: format version with
   "Linux version 5.11.10-arch1-1 (linux@archlinux) (gcc (GCC) 10.2.0, 
GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Fri, 26 Mar 2021 00:11:29 
+0000"
Info: [/dev/loop0] Discarding device
Info: This device doesn't support BLKSECDISCARD
Info: Discarded 256 MB
Info: Overprovision ratio = 15.000%
Info: Overprovision segments = 35 (GC reserved = 21)
Info: format successful
+ fsck.f2fs /dev/loop0
Info: Segments per section = 1
Info: Sections per zone = 1
Info: sector size = 512
Info: total sectors = 524288 (256 MB)
Info: MKFS version
   "Linux version 5.11.10-arch1-1 (linux@archlinux) (gcc (GCC) 10.2.0, 
GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Fri, 26 Mar 2021 00:11:29 
+0000"
Info: FSCK version
   from "Linux version 5.11.10-arch1-1 (linux@archlinux) (gcc (GCC) 
10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Fri, 26 Mar 2021 
00:11:29 +0000"
     to "Linux version 5.11.10-arch1-1 (linux@archlinux) (gcc (GCC) 
10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Fri, 26 Mar 2021 
00:11:29 +0000"
Info: superblock features = 0 :
Info: superblock encrypt level = 0, salt = 00000000000000000000000000000000
Info: total FS sectors = 524288 (256 MB)
Info: CKPT version = 6c224cab
Info: Checked valid nat_bits in checkpoint
Info: checkpoint state = 185 :  trimmed nat_bits compacted_summary unmount

[FSCK] Unreachable nat entries                        [Ok..] [0x0]
[FSCK] SIT valid block bitmap checking                [Ok..]
[FSCK] Hard link checking for regular file            [Ok..] [0x0]
[FSCK] valid_block_count matching with CP             [Ok..] [0x2]
[FSCK] valid_node_count matching with CP (de lookup)  [Ok..] [0x1]
[FSCK] valid_node_count matching with CP (nat lookup) [Ok..] [0x1]
[FSCK] valid_inode_count matched with CP              [Ok..] [0x1]
[FSCK] free segment_count matched with CP             [Ok..] [0x72]
[FSCK] next block offset is free                      [Ok..]
[FSCK] fixing SIT types
[FSCK] other corrupted bugs                           [Ok..]

Done: 0.048995 secs
+ mount /dev/loop0 /root/mnt/temp
+ dd bs=1M count=64 
if=/mnt/data/external/misc/movie/Idiocracy.2006.WEB-DL.1080p-ylnian.mkv 
of=/root/mnt/temp/a.mkv
64+0 records in
64+0 records out
67108864 bytes (67 MB, 64 MiB) copied, 0,0266206 s, 2,5 GB/s
+ umount /root/mnt/temp
+ resize.f2fs -s -t 262144 /dev/loop0
Info: Segments per section = 1
Info: Sections per zone = 1
Info: sector size = 512
Info: total sectors = 524288 (256 MB)
Info: MKFS version
   "Linux version 5.11.10-arch1-1 (linux@archlinux) (gcc (GCC) 10.2.0, 
GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Fri, 26 Mar 2021 00:11:29 
+0000"
Info: FSCK version
   from "Linux version 5.11.10-arch1-1 (linux@archlinux) (gcc (GCC) 
10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Fri, 26 Mar 2021 
00:11:29 +0000"
     to "Linux version 5.11.10-arch1-1 (linux@archlinux) (gcc (GCC) 
10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Fri, 26 Mar 2021 
00:11:29 +0000"
Info: superblock features = 0 :
Info: superblock encrypt level = 0, salt = 00000000000000000000000000000000
Info: total FS sectors = 524288 (256 MB)
Info: CKPT version = 6c224caf
Info: Duplicate valid checkpoint to mirror position 512 -> 1024
Info: Write valid nat_bits in checkpoint
[FIX] (move_one_curseg_info:2798)  --> Move curseg[0] 3 -> 37 after 8000

[FIX] (move_one_curseg_info:2798)  --> Move curseg[1] 3b -> 36 after 8000

[FIX] (move_one_curseg_info:2798)  --> Move curseg[2] 24 -> 35 after 8000

[FIX] (move_one_curseg_info:2798)  --> Move curseg[3] 0 -> 34 after 8000

[FIX] (move_one_curseg_info:2798)  --> Move curseg[4] 1 -> 33 after 8000

[FIX] (move_one_curseg_info:2798)  --> Move curseg[5] 2 -> 32 after 8000

Info: Write valid nat_bits in checkpoint
Try to do defragement: Done
[update_superblock: 695] Info: Done to update superblock
Info: Write valid nat_bits in checkpoint
[rebuild_checkpoint: 590] Info: Done to rebuild checkpoint blocks

Done: 0.058891 secs
+ fsck.f2fs /dev/loop0
Info: Segments per section = 1
Info: Sections per zone = 1
Info: sector size = 512
Info: total sectors = 524288 (256 MB)
Info: MKFS version
   "Linux version 5.11.10-arch1-1 (linux@archlinux) (gcc (GCC) 10.2.0, 
GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Fri, 26 Mar 2021 00:11:29 
+0000"
Info: FSCK version
   from "Linux version 5.11.10-arch1-1 (linux@archlinux) (gcc (GCC) 
10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Fri, 26 Mar 2021 
00:11:29 +0000"
     to "Linux version 5.11.10-arch1-1 (linux@archlinux) (gcc (GCC) 
10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Fri, 26 Mar 2021 
00:11:29 +0000"
Info: superblock features = 0 :
Info: superblock encrypt level = 0, salt = 00000000000000000000000000000000
Info: total FS sectors = 262144 (128 MB)
     Invalid CP CRC offset: 0
Info: CKPT version = 6c224cb0
Info: Checked valid nat_bits in checkpoint
Info: checkpoint state = 181 :  trimmed nat_bits unmount

[FSCK] Unreachable nat entries                        [Ok..] [0x0]
[FSCK] SIT valid block bitmap checking                [Ok..]
[FSCK] Hard link checking for regular file            [Ok..] [0x0]
[FSCK] valid_block_count matching with CP             [Ok..] [0x4014]
[FSCK] valid_node_count matching with CP (de lookup)  [Ok..] [0x13]
[FSCK] valid_node_count matching with CP (nat lookup) [Ok..] [0x13]
[FSCK] valid_inode_count matched with CP              [Ok..] [0x2]
[FSCK] free segment_count matched with CP             [Ok..] [0xe]
[FSCK] next block offset is free                      [Ok..]
[FSCK] fixing SIT types
[FSCK] other corrupted bugs                           [Ok..]

Done: 0.115494 secs
+ set +e
+ mount /dev/loop0 /root/mnt/temp
Apr 02 12:25:11 beroal kernel: F2FS-fs (loop0): invalid crc_offset: 0
Apr 02 12:25:11 beroal kernel: F2FS-fs (loop0): Wrong valid_user_blocks: 
16404, user_block_count: 13312
Apr 02 12:25:11 beroal kernel: F2FS-fs (loop0): Failed to get valid F2FS 
checkpoint
mount: /root/mnt/temp: mount(2) system call failed: Structure needs 
cleaning.
+ umount /root/mnt/temp
umount: /root/mnt/temp: not mounted.
+ set -e
+ losetup -d /dev/loop0
```

(I inserted messages from the kernel log.)

On 02.04.21 10:23, Chao Yu wrote:
> Hi beroal,
>
> I  figured out a patch, could you please check with it?
>
> [PATCH] resize.f2fs: fix wrong sit/nat bitmap during rebuild_checkpoint()
>
> On 2021/3/29 9:51, Chao Yu wrote:
>> Hello,
>>
>> Sorry for the delay reply.
>>
>> I can reproduce this bug now, but I haven't enough time for debuging, 
>> will
>> check this soon.
>>
>> On 2021/3/27 21:26, beroal wrote:
>>> Ping.
>>>
>>> On 19.03.21 23:24, beroal wrote:
>>>> Hi. I am trying to use a new function to reduce the size of an F2FS
>>>> file system. After resizing, `fsck.f2fs` gives a lot of errors. Here
>>>> is a shell script that creates and resizes a dummy file system:
>>>>
>>>> ```
>>>> #!/bin/sh
>>>> set -e
>>>> F=/tmp/img
>>>> D=/dev/loop0
>>>> M=/root/mnt/temp
>>>> dd bs=1M count=256 if=/dev/zero "of=$F"
>>>> losetup "$D" "$F"
>>>> mkfs.f2fs "$D"
>>>> fsck.f2fs "$D"
>>>> mount "$D" "$M"
>>>> dd bs=1M count=64
>>>> if=/mnt/data/external/misc/movie/Idiocracy.2006.WEB-DL.1080p-ylnian.mkv 
>>>>
>>>> of="${M}/a.mkv"
>>>> umount "$M"
>>>> resize.f2fs -s -t 262144 "$D"
>>>> fsck.f2fs "$D"
>>>> losetup -d "$D"
>>>> ```
>>>>
>>>> ```
>>>> + set -e
>>>> + F=/tmp/img
>>>> + D=/dev/loop0
>>>> + M=/root/mnt/temp
>>>> + dd bs=1M count=256 if=/dev/zero of=/tmp/img
>>>> 256+0 records in
>>>> 256+0 records out
>>>> 268435456 bytes (268 MB, 256 MiB) copied, 0.0867954 s, 3.1 GB/s
>>>> + losetup /dev/loop0 /tmp/img
>>>> + mkfs.f2fs /dev/loop0
>>>>
>>>>       F2FS-tools: mkfs.f2fs Ver: 1.14.0 (2020-08-24)
>>>>
>>>> Info: Disable heap-based policy
>>>> Info: Debug level = 0
>>>> Info: Trim is enabled
>>>> Info: Segments per section = 1
>>>> Info: Sections per zone = 1
>>>> Info: sector size = 512
>>>> Info: total sectors = 524288 (256 MB)
>>>> Info: zone aligned segment0 blkaddr: 512
>>>> Info: format version with
>>>>     "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC) 10.2.0,
>>>> GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021 16:59:58
>>>> +0000"
>>>> Info: [/dev/loop0] Discarding device
>>>> Info: This device doesn't support BLKSECDISCARD
>>>> Info: Discarded 256 MB
>>>> Info: Overprovision ratio = 15.000%
>>>> Info: Overprovision segments = 35 (GC reserved = 21)
>>>> Info: format successful
>>>> + fsck.f2fs /dev/loop0
>>>> Info: Segments per section = 1
>>>> Info: Sections per zone = 1
>>>> Info: sector size = 512
>>>> Info: total sectors = 524288 (256 MB)
>>>> Info: MKFS version
>>>>     "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC) 10.2.0,
>>>> GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021 16:59:58
>>>> +0000"
>>>> Info: FSCK version
>>>>     from "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC)
>>>> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021
>>>> 16:59:58 +0000"
>>>>       to "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC)
>>>> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021
>>>> 16:59:58 +0000"
>>>> Info: superblock features = 0 :
>>>> Info: superblock encrypt level = 0, salt =
>>>> 00000000000000000000000000000000
>>>> Info: total FS sectors = 524288 (256 MB)
>>>> Info: CKPT version = 8aa0d85
>>>> Info: Checked valid nat_bits in checkpoint
>>>> Info: checkpoint state = 185 :  trimmed nat_bits compacted_summary
>>>> unmount
>>>>
>>>> [FSCK] Unreachable nat entries                        [Ok..] [0x0]
>>>> [FSCK] SIT valid block bitmap checking                [Ok..]
>>>> [FSCK] Hard link checking for regular file            [Ok..] [0x0]
>>>> [FSCK] valid_block_count matching with CP             [Ok..] [0x2]
>>>> [FSCK] valid_node_count matching with CP (de lookup)  [Ok..] [0x1]
>>>> [FSCK] valid_node_count matching with CP (nat lookup) [Ok..] [0x1]
>>>> [FSCK] valid_inode_count matched with CP              [Ok..] [0x1]
>>>> [FSCK] free segment_count matched with CP             [Ok..] [0x72]
>>>> [FSCK] next block offset is free                      [Ok..]
>>>> [FSCK] fixing SIT types
>>>> [FSCK] other corrupted bugs                           [Ok..]
>>>>
>>>> Done: 0.068899 secs
>>>> + mount /dev/loop0 /root/mnt/temp
>>>> + dd bs=1M count=64
>>>> if=/mnt/data/external/misc/movie/Idiocracy.2006.WEB-DL.1080p-ylnian.mkv 
>>>>
>>>> of=/root/mnt/temp/a.mkv
>>>> 64+0 records in
>>>> 64+0 records out
>>>> 67108864 bytes (67 MB, 64 MiB) copied, 0.0286261 s, 2.3 GB/s
>>>> + umount /root/mnt/temp
>>>> + resize.f2fs -s -t 262144 /dev/loop0
>>>> Info: Segments per section = 1
>>>> Info: Sections per zone = 1
>>>> Info: sector size = 512
>>>> Info: total sectors = 524288 (256 MB)
>>>> Info: MKFS version
>>>>     "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC) 10.2.0,
>>>> GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021 16:59:58
>>>> +0000"
>>>> Info: FSCK version
>>>>     from "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC)
>>>> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021
>>>> 16:59:58 +0000"
>>>>       to "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC)
>>>> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021
>>>> 16:59:58 +0000"
>>>> Info: superblock features = 0 :
>>>> Info: superblock encrypt level = 0, salt =
>>>> 00000000000000000000000000000000
>>>> Info: total FS sectors = 524288 (256 MB)
>>>> Info: CKPT version = 8aa0d89
>>>> Info: Duplicate valid checkpoint to mirror position 512 -> 1024
>>>> Info: Write valid nat_bits in checkpoint
>>>> [FIX] (move_one_curseg_info:2798)  --> Move curseg[0] 3 -> 37 after 
>>>> 8000
>>>>
>>>> [FIX] (move_one_curseg_info:2798)  --> Move curseg[1] 3b -> 36 
>>>> after 8000
>>>>
>>>> [FIX] (move_one_curseg_info:2798)  --> Move curseg[2] 24 -> 35 
>>>> after 8000
>>>>
>>>> [FIX] (move_one_curseg_info:2798)  --> Move curseg[3] 0 -> 34 after 
>>>> 8000
>>>>
>>>> [FIX] (move_one_curseg_info:2798)  --> Move curseg[4] 1 -> 33 after 
>>>> 8000
>>>>
>>>> [FIX] (move_one_curseg_info:2798)  --> Move curseg[5] 2 -> 32 after 
>>>> 8000
>>>>
>>>> Info: Write valid nat_bits in checkpoint
>>>> Try to do defragement: Done
>>>> [update_superblock: 695] Info: Done to update superblock
>>>> Info: Write valid nat_bits in checkpoint
>>>> [rebuild_checkpoint: 585] Info: Done to rebuild checkpoint blocks
>>>>
>>>> Done: 0.065604 secs
>>>> + fsck.f2fs /dev/loop0
>>>> Info: Segments per section = 1
>>>> Info: Sections per zone = 1
>>>> Info: sector size = 512
>>>> Info: total sectors = 524288 (256 MB)
>>>> Info: MKFS version
>>>>     "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC) 10.2.0,
>>>> GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021 16:59:58
>>>> +0000"
>>>> Info: FSCK version
>>>>     from "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC)
>>>> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021
>>>> 16:59:58 +0000"
>>>>       to "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC)
>>>> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021
>>>> 16:59:58 +0000"
>>>> Info: superblock features = 0 :
>>>> Info: superblock encrypt level = 0, salt =
>>>> 00000000000000000000000000000000
>>>> Info: total FS sectors = 262144 (128 MB)
>>>>       Invalid CP CRC offset: 0
>>>> Info: CKPT version = 8aa0d8a
>>>> Info: Checked valid nat_bits in checkpoint
>>>> Info: checkpoint state = 181 :  trimmed nat_bits unmount
>>>> [ASSERT] (fsck_chk_curseg_info:2958)  --> Incorrect curseg [1]: segno
>>>> [0x36] type(SIT) [0]
>>>> [ASSERT] (fsck_chk_curseg_info:2958)  --> Incorrect curseg [2]: segno
>>>> [0x35] type(SIT) [0]
>>>> [ASSERT] (fsck_chk_curseg_info:2958)  --> Incorrect curseg [3]: segno
>>>> [0x34] type(SIT) [0]
>>>> [ASSERT] (fsck_chk_curseg_info:2958)  --> Incorrect curseg [4]: segno
>>>> [0x33] type(SIT) [0]
>>>> [ASSERT] (fsck_chk_curseg_info:2958)  --> Incorrect curseg [5]: segno
>>>> [0x32] type(SIT) [0]
>>>> [ASSERT] (sanity_check_nid: 480)  --> SIT bitmap is 0x0. 
>>>> blk_addr[0x1002]
>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>> blk_addr[0x1601]
>>>> [ASSERT] (sanity_check_nid: 480)  --> SIT bitmap is 0x0. 
>>>> blk_addr[0x1211]
>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>> blk_addr[0x4a00]
>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>> blk_addr[0x4a01]
>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>> blk_addr[0x4a02]
>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>> blk_addr[0x4a03]
>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>> blk_addr[0x4a04]
>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>> blk_addr[0x4a05]
>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>> blk_addr[0x4a06]
>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>> blk_addr[0x4a07]
>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>> blk_addr[0x4a08]
>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>> blk_addr[0x4a09]
>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>> blk_addr[0x4a0a]
>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>> blk_addr[0x4a0b]
>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>> blk_addr[0x4a0c]
>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>> blk_addr[0x4a0d]
>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>> blk_addr[0x4a0e]
>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>> blk_addr[0x4a0f]
>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>> blk_addr[0x4a10]
>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>> blk_addr[0x4a11]
>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>> blk_addr[0x4a12]
>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>> blk_addr[0x4a13]
>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>> blk_addr[0x4a14]
>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>> blk_addr[0x4a15]
>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>> blk_addr[0x4a16]
>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>> blk_addr[0x4a17]
>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>> blk_addr[0x4a18]
>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>> blk_addr[0x4a19]
>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>> blk_addr[0x4a1a]
>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>> blk_addr[0x4a1b]
>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>> blk_addr[0x4a1c]
>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>> blk_addr[0x4a1d]
>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>> blk_addr[0x4a1e]
>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>> blk_addr[0x4a1f]
>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>> blk_addr[0x4a20]
>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>> blk_addr[0x4a21]
>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>> blk_addr[0x4a22]
>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>> blk_addr[0x4a23]
>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>> blk_addr[0x4a24]
>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>> blk_addr[0x4a25]
>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>> blk_addr[0x4a26]
>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>> blk_addr[0x4a27]
>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>> blk_addr[0x4a28]
>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>> blk_addr[0x4a29]
>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>> blk_addr[0x4a2a]
>>>> {{{skipped}}}
>>>> ```
>>>>
>>>> The whole output is huge.
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> Linux-f2fs-devel mailing list
>>>> Linux-f2fs-devel@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
>>>
>>>
>>> _______________________________________________
>>> Linux-f2fs-devel mailing list
>>> Linux-f2fs-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
>>>
>>
>>
>> _______________________________________________
>> Linux-f2fs-devel mailing list
>> Linux-f2fs-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
>>
>


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

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

* Re: [f2fs-dev] f2fs.resize makes errors in FS
  2021-04-02  9:28       ` beroal
@ 2021-04-02 10:30         ` Chao Yu
  2021-04-06  1:44         ` Chao Yu
  1 sibling, 0 replies; 9+ messages in thread
From: Chao Yu @ 2021-04-02 10:30 UTC (permalink / raw)
  To: beroal, linux-f2fs-devel

On 2021/4/2 17:28, beroal wrote:
> I can't mount the resulting file system.
> 
> ```
> + set -e
> + F=/tmp/img
> + D=/dev/loop0
> + M=/root/mnt/temp
> + dd bs=1M count=256 if=/dev/zero of=/tmp/img
> 256+0 records in
> 256+0 records out
> 268435456 bytes (268 MB, 256 MiB) copied, 0,0937109 s, 2,9 GB/s
> + losetup /dev/loop0 /tmp/img
> + mkfs.f2fs /dev/loop0
> 
>       F2FS-tools: mkfs.f2fs Ver: 1.14.0 (2020-08-24)
> 
> Info: Disable heap-based policy
> Info: Debug level = 0
> Info: Trim is enabled
> Info: Segments per section = 1
> Info: Sections per zone = 1
> Info: sector size = 512
> Info: total sectors = 524288 (256 MB)
> Info: zone aligned segment0 blkaddr: 512
> Info: format version with
>     "Linux version 5.11.10-arch1-1 (linux@archlinux) (gcc (GCC) 10.2.0,
> GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Fri, 26 Mar 2021 00:11:29
> +0000"
> Info: [/dev/loop0] Discarding device
> Info: This device doesn't support BLKSECDISCARD
> Info: Discarded 256 MB
> Info: Overprovision ratio = 15.000%
> Info: Overprovision segments = 35 (GC reserved = 21)
> Info: format successful
> + fsck.f2fs /dev/loop0
> Info: Segments per section = 1
> Info: Sections per zone = 1
> Info: sector size = 512
> Info: total sectors = 524288 (256 MB)
> Info: MKFS version
>     "Linux version 5.11.10-arch1-1 (linux@archlinux) (gcc (GCC) 10.2.0,
> GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Fri, 26 Mar 2021 00:11:29
> +0000"
> Info: FSCK version
>     from "Linux version 5.11.10-arch1-1 (linux@archlinux) (gcc (GCC)
> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Fri, 26 Mar 2021
> 00:11:29 +0000"
>       to "Linux version 5.11.10-arch1-1 (linux@archlinux) (gcc (GCC)
> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Fri, 26 Mar 2021
> 00:11:29 +0000"
> Info: superblock features = 0 :
> Info: superblock encrypt level = 0, salt = 00000000000000000000000000000000
> Info: total FS sectors = 524288 (256 MB)
> Info: CKPT version = 6c224cab
> Info: Checked valid nat_bits in checkpoint
> Info: checkpoint state = 185 :  trimmed nat_bits compacted_summary unmount
> 
> [FSCK] Unreachable nat entries                        [Ok..] [0x0]
> [FSCK] SIT valid block bitmap checking                [Ok..]
> [FSCK] Hard link checking for regular file            [Ok..] [0x0]
> [FSCK] valid_block_count matching with CP             [Ok..] [0x2]
> [FSCK] valid_node_count matching with CP (de lookup)  [Ok..] [0x1]
> [FSCK] valid_node_count matching with CP (nat lookup) [Ok..] [0x1]
> [FSCK] valid_inode_count matched with CP              [Ok..] [0x1]
> [FSCK] free segment_count matched with CP             [Ok..] [0x72]
> [FSCK] next block offset is free                      [Ok..]
> [FSCK] fixing SIT types
> [FSCK] other corrupted bugs                           [Ok..]
> 
> Done: 0.048995 secs
> + mount /dev/loop0 /root/mnt/temp
> + dd bs=1M count=64
> if=/mnt/data/external/misc/movie/Idiocracy.2006.WEB-DL.1080p-ylnian.mkv
> of=/root/mnt/temp/a.mkv
> 64+0 records in
> 64+0 records out
> 67108864 bytes (67 MB, 64 MiB) copied, 0,0266206 s, 2,5 GB/s
> + umount /root/mnt/temp
> + resize.f2fs -s -t 262144 /dev/loop0
> Info: Segments per section = 1
> Info: Sections per zone = 1
> Info: sector size = 512
> Info: total sectors = 524288 (256 MB)
> Info: MKFS version
>     "Linux version 5.11.10-arch1-1 (linux@archlinux) (gcc (GCC) 10.2.0,
> GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Fri, 26 Mar 2021 00:11:29
> +0000"
> Info: FSCK version
>     from "Linux version 5.11.10-arch1-1 (linux@archlinux) (gcc (GCC)
> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Fri, 26 Mar 2021
> 00:11:29 +0000"
>       to "Linux version 5.11.10-arch1-1 (linux@archlinux) (gcc (GCC)
> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Fri, 26 Mar 2021
> 00:11:29 +0000"
> Info: superblock features = 0 :
> Info: superblock encrypt level = 0, salt = 00000000000000000000000000000000
> Info: total FS sectors = 524288 (256 MB)
> Info: CKPT version = 6c224caf
> Info: Duplicate valid checkpoint to mirror position 512 -> 1024
> Info: Write valid nat_bits in checkpoint
> [FIX] (move_one_curseg_info:2798)  --> Move curseg[0] 3 -> 37 after 8000
> 
> [FIX] (move_one_curseg_info:2798)  --> Move curseg[1] 3b -> 36 after 8000
> 
> [FIX] (move_one_curseg_info:2798)  --> Move curseg[2] 24 -> 35 after 8000
> 
> [FIX] (move_one_curseg_info:2798)  --> Move curseg[3] 0 -> 34 after 8000
> 
> [FIX] (move_one_curseg_info:2798)  --> Move curseg[4] 1 -> 33 after 8000
> 
> [FIX] (move_one_curseg_info:2798)  --> Move curseg[5] 2 -> 32 after 8000
> 
> Info: Write valid nat_bits in checkpoint
> Try to do defragement: Done
> [update_superblock: 695] Info: Done to update superblock
> Info: Write valid nat_bits in checkpoint
> [rebuild_checkpoint: 590] Info: Done to rebuild checkpoint blocks
> 
> Done: 0.058891 secs
> + fsck.f2fs /dev/loop0
> Info: Segments per section = 1
> Info: Sections per zone = 1
> Info: sector size = 512
> Info: total sectors = 524288 (256 MB)
> Info: MKFS version
>     "Linux version 5.11.10-arch1-1 (linux@archlinux) (gcc (GCC) 10.2.0,
> GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Fri, 26 Mar 2021 00:11:29
> +0000"
> Info: FSCK version
>     from "Linux version 5.11.10-arch1-1 (linux@archlinux) (gcc (GCC)
> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Fri, 26 Mar 2021
> 00:11:29 +0000"
>       to "Linux version 5.11.10-arch1-1 (linux@archlinux) (gcc (GCC)
> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Fri, 26 Mar 2021
> 00:11:29 +0000"
> Info: superblock features = 0 :
> Info: superblock encrypt level = 0, salt = 00000000000000000000000000000000
> Info: total FS sectors = 262144 (128 MB)
>       Invalid CP CRC offset: 0
> Info: CKPT version = 6c224cb0
> Info: Checked valid nat_bits in checkpoint
> Info: checkpoint state = 181 :  trimmed nat_bits unmount
> 
> [FSCK] Unreachable nat entries                        [Ok..] [0x0]
> [FSCK] SIT valid block bitmap checking                [Ok..]
> [FSCK] Hard link checking for regular file            [Ok..] [0x0]
> [FSCK] valid_block_count matching with CP             [Ok..] [0x4014]
> [FSCK] valid_node_count matching with CP (de lookup)  [Ok..] [0x13]
> [FSCK] valid_node_count matching with CP (nat lookup) [Ok..] [0x13]
> [FSCK] valid_inode_count matched with CP              [Ok..] [0x2]
> [FSCK] free segment_count matched with CP             [Ok..] [0xe]
> [FSCK] next block offset is free                      [Ok..]
> [FSCK] fixing SIT types
> [FSCK] other corrupted bugs                           [Ok..]
> 
> Done: 0.115494 secs
> + set +e
> + mount /dev/loop0 /root/mnt/temp
> Apr 02 12:25:11 beroal kernel: F2FS-fs (loop0): invalid crc_offset: 0
> Apr 02 12:25:11 beroal kernel: F2FS-fs (loop0): Wrong valid_user_blocks:
> 16404, user_block_count: 13312

Oh, current valid user block count exceeds total block count user can use,
I should add a check condition in resize for that, later then resize will
fail on your testcase.

You can dd smaller file (less than 52MB), and try the testcase again.

Let me handle out-of-space case soon in v2.

Thanks,

> Apr 02 12:25:11 beroal kernel: F2FS-fs (loop0): Failed to get valid F2FS
> checkpoint
> mount: /root/mnt/temp: mount(2) system call failed: Structure needs
> cleaning.
> + umount /root/mnt/temp
> umount: /root/mnt/temp: not mounted.
> + set -e
> + losetup -d /dev/loop0
> ```
> 
> (I inserted messages from the kernel log.)
> 
> On 02.04.21 10:23, Chao Yu wrote:
>> Hi beroal,
>>
>> I  figured out a patch, could you please check with it?
>>
>> [PATCH] resize.f2fs: fix wrong sit/nat bitmap during rebuild_checkpoint()
>>
>> On 2021/3/29 9:51, Chao Yu wrote:
>>> Hello,
>>>
>>> Sorry for the delay reply.
>>>
>>> I can reproduce this bug now, but I haven't enough time for debuging,
>>> will
>>> check this soon.
>>>
>>> On 2021/3/27 21:26, beroal wrote:
>>>> Ping.
>>>>
>>>> On 19.03.21 23:24, beroal wrote:
>>>>> Hi. I am trying to use a new function to reduce the size of an F2FS
>>>>> file system. After resizing, `fsck.f2fs` gives a lot of errors. Here
>>>>> is a shell script that creates and resizes a dummy file system:
>>>>>
>>>>> ```
>>>>> #!/bin/sh
>>>>> set -e
>>>>> F=/tmp/img
>>>>> D=/dev/loop0
>>>>> M=/root/mnt/temp
>>>>> dd bs=1M count=256 if=/dev/zero "of=$F"
>>>>> losetup "$D" "$F"
>>>>> mkfs.f2fs "$D"
>>>>> fsck.f2fs "$D"
>>>>> mount "$D" "$M"
>>>>> dd bs=1M count=64
>>>>> if=/mnt/data/external/misc/movie/Idiocracy.2006.WEB-DL.1080p-ylnian.mkv
>>>>>
>>>>> of="${M}/a.mkv"
>>>>> umount "$M"
>>>>> resize.f2fs -s -t 262144 "$D"
>>>>> fsck.f2fs "$D"
>>>>> losetup -d "$D"
>>>>> ```
>>>>>
>>>>> ```
>>>>> + set -e
>>>>> + F=/tmp/img
>>>>> + D=/dev/loop0
>>>>> + M=/root/mnt/temp
>>>>> + dd bs=1M count=256 if=/dev/zero of=/tmp/img
>>>>> 256+0 records in
>>>>> 256+0 records out
>>>>> 268435456 bytes (268 MB, 256 MiB) copied, 0.0867954 s, 3.1 GB/s
>>>>> + losetup /dev/loop0 /tmp/img
>>>>> + mkfs.f2fs /dev/loop0
>>>>>
>>>>>        F2FS-tools: mkfs.f2fs Ver: 1.14.0 (2020-08-24)
>>>>>
>>>>> Info: Disable heap-based policy
>>>>> Info: Debug level = 0
>>>>> Info: Trim is enabled
>>>>> Info: Segments per section = 1
>>>>> Info: Sections per zone = 1
>>>>> Info: sector size = 512
>>>>> Info: total sectors = 524288 (256 MB)
>>>>> Info: zone aligned segment0 blkaddr: 512
>>>>> Info: format version with
>>>>>      "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC) 10.2.0,
>>>>> GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021 16:59:58
>>>>> +0000"
>>>>> Info: [/dev/loop0] Discarding device
>>>>> Info: This device doesn't support BLKSECDISCARD
>>>>> Info: Discarded 256 MB
>>>>> Info: Overprovision ratio = 15.000%
>>>>> Info: Overprovision segments = 35 (GC reserved = 21)
>>>>> Info: format successful
>>>>> + fsck.f2fs /dev/loop0
>>>>> Info: Segments per section = 1
>>>>> Info: Sections per zone = 1
>>>>> Info: sector size = 512
>>>>> Info: total sectors = 524288 (256 MB)
>>>>> Info: MKFS version
>>>>>      "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC) 10.2.0,
>>>>> GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021 16:59:58
>>>>> +0000"
>>>>> Info: FSCK version
>>>>>      from "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC)
>>>>> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021
>>>>> 16:59:58 +0000"
>>>>>        to "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC)
>>>>> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021
>>>>> 16:59:58 +0000"
>>>>> Info: superblock features = 0 :
>>>>> Info: superblock encrypt level = 0, salt =
>>>>> 00000000000000000000000000000000
>>>>> Info: total FS sectors = 524288 (256 MB)
>>>>> Info: CKPT version = 8aa0d85
>>>>> Info: Checked valid nat_bits in checkpoint
>>>>> Info: checkpoint state = 185 :  trimmed nat_bits compacted_summary
>>>>> unmount
>>>>>
>>>>> [FSCK] Unreachable nat entries                        [Ok..] [0x0]
>>>>> [FSCK] SIT valid block bitmap checking                [Ok..]
>>>>> [FSCK] Hard link checking for regular file            [Ok..] [0x0]
>>>>> [FSCK] valid_block_count matching with CP             [Ok..] [0x2]
>>>>> [FSCK] valid_node_count matching with CP (de lookup)  [Ok..] [0x1]
>>>>> [FSCK] valid_node_count matching with CP (nat lookup) [Ok..] [0x1]
>>>>> [FSCK] valid_inode_count matched with CP              [Ok..] [0x1]
>>>>> [FSCK] free segment_count matched with CP             [Ok..] [0x72]
>>>>> [FSCK] next block offset is free                      [Ok..]
>>>>> [FSCK] fixing SIT types
>>>>> [FSCK] other corrupted bugs                           [Ok..]
>>>>>
>>>>> Done: 0.068899 secs
>>>>> + mount /dev/loop0 /root/mnt/temp
>>>>> + dd bs=1M count=64
>>>>> if=/mnt/data/external/misc/movie/Idiocracy.2006.WEB-DL.1080p-ylnian.mkv
>>>>>
>>>>> of=/root/mnt/temp/a.mkv
>>>>> 64+0 records in
>>>>> 64+0 records out
>>>>> 67108864 bytes (67 MB, 64 MiB) copied, 0.0286261 s, 2.3 GB/s
>>>>> + umount /root/mnt/temp
>>>>> + resize.f2fs -s -t 262144 /dev/loop0
>>>>> Info: Segments per section = 1
>>>>> Info: Sections per zone = 1
>>>>> Info: sector size = 512
>>>>> Info: total sectors = 524288 (256 MB)
>>>>> Info: MKFS version
>>>>>      "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC) 10.2.0,
>>>>> GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021 16:59:58
>>>>> +0000"
>>>>> Info: FSCK version
>>>>>      from "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC)
>>>>> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021
>>>>> 16:59:58 +0000"
>>>>>        to "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC)
>>>>> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021
>>>>> 16:59:58 +0000"
>>>>> Info: superblock features = 0 :
>>>>> Info: superblock encrypt level = 0, salt =
>>>>> 00000000000000000000000000000000
>>>>> Info: total FS sectors = 524288 (256 MB)
>>>>> Info: CKPT version = 8aa0d89
>>>>> Info: Duplicate valid checkpoint to mirror position 512 -> 1024
>>>>> Info: Write valid nat_bits in checkpoint
>>>>> [FIX] (move_one_curseg_info:2798)  --> Move curseg[0] 3 -> 37 after
>>>>> 8000
>>>>>
>>>>> [FIX] (move_one_curseg_info:2798)  --> Move curseg[1] 3b -> 36
>>>>> after 8000
>>>>>
>>>>> [FIX] (move_one_curseg_info:2798)  --> Move curseg[2] 24 -> 35
>>>>> after 8000
>>>>>
>>>>> [FIX] (move_one_curseg_info:2798)  --> Move curseg[3] 0 -> 34 after
>>>>> 8000
>>>>>
>>>>> [FIX] (move_one_curseg_info:2798)  --> Move curseg[4] 1 -> 33 after
>>>>> 8000
>>>>>
>>>>> [FIX] (move_one_curseg_info:2798)  --> Move curseg[5] 2 -> 32 after
>>>>> 8000
>>>>>
>>>>> Info: Write valid nat_bits in checkpoint
>>>>> Try to do defragement: Done
>>>>> [update_superblock: 695] Info: Done to update superblock
>>>>> Info: Write valid nat_bits in checkpoint
>>>>> [rebuild_checkpoint: 585] Info: Done to rebuild checkpoint blocks
>>>>>
>>>>> Done: 0.065604 secs
>>>>> + fsck.f2fs /dev/loop0
>>>>> Info: Segments per section = 1
>>>>> Info: Sections per zone = 1
>>>>> Info: sector size = 512
>>>>> Info: total sectors = 524288 (256 MB)
>>>>> Info: MKFS version
>>>>>      "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC) 10.2.0,
>>>>> GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021 16:59:58
>>>>> +0000"
>>>>> Info: FSCK version
>>>>>      from "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC)
>>>>> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021
>>>>> 16:59:58 +0000"
>>>>>        to "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC)
>>>>> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021
>>>>> 16:59:58 +0000"
>>>>> Info: superblock features = 0 :
>>>>> Info: superblock encrypt level = 0, salt =
>>>>> 00000000000000000000000000000000
>>>>> Info: total FS sectors = 262144 (128 MB)
>>>>>        Invalid CP CRC offset: 0
>>>>> Info: CKPT version = 8aa0d8a
>>>>> Info: Checked valid nat_bits in checkpoint
>>>>> Info: checkpoint state = 181 :  trimmed nat_bits unmount
>>>>> [ASSERT] (fsck_chk_curseg_info:2958)  --> Incorrect curseg [1]: segno
>>>>> [0x36] type(SIT) [0]
>>>>> [ASSERT] (fsck_chk_curseg_info:2958)  --> Incorrect curseg [2]: segno
>>>>> [0x35] type(SIT) [0]
>>>>> [ASSERT] (fsck_chk_curseg_info:2958)  --> Incorrect curseg [3]: segno
>>>>> [0x34] type(SIT) [0]
>>>>> [ASSERT] (fsck_chk_curseg_info:2958)  --> Incorrect curseg [4]: segno
>>>>> [0x33] type(SIT) [0]
>>>>> [ASSERT] (fsck_chk_curseg_info:2958)  --> Incorrect curseg [5]: segno
>>>>> [0x32] type(SIT) [0]
>>>>> [ASSERT] (sanity_check_nid: 480)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x1002]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x1601]
>>>>> [ASSERT] (sanity_check_nid: 480)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x1211]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a00]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a01]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a02]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a03]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a04]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a05]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a06]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a07]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a08]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a09]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a0a]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a0b]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a0c]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a0d]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a0e]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a0f]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a10]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a11]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a12]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a13]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a14]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a15]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a16]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a17]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a18]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a19]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a1a]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a1b]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a1c]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a1d]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a1e]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a1f]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a20]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a21]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a22]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a23]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a24]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a25]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a26]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a27]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a28]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a29]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a2a]
>>>>> {{{skipped}}}
>>>>> ```
>>>>>
>>>>> The whole output is huge.
>>>>>
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Linux-f2fs-devel mailing list
>>>>> Linux-f2fs-devel@lists.sourceforge.net
>>>>> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
>>>>
>>>>
>>>> _______________________________________________
>>>> Linux-f2fs-devel mailing list
>>>> Linux-f2fs-devel@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
>>>>
>>>
>>>
>>> _______________________________________________
>>> Linux-f2fs-devel mailing list
>>> Linux-f2fs-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
>>>
>>
> .
> 


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

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

* Re: [f2fs-dev] f2fs.resize makes errors in FS
  2021-04-02  9:28       ` beroal
  2021-04-02 10:30         ` Chao Yu
@ 2021-04-06  1:44         ` Chao Yu
  2021-04-12 15:40           ` beroal
  1 sibling, 1 reply; 9+ messages in thread
From: Chao Yu @ 2021-04-06  1:44 UTC (permalink / raw)
  To: beroal, linux-f2fs-devel

Hi beroal,

Could you please apply below patch based on last fix patch and
do the test again?

[PATCH] resize.f2fs: fix to check free space before shrink

On 2021/4/2 17:28, beroal wrote:
> I can't mount the resulting file system.
> 
> ```
> + set -e
> + F=/tmp/img
> + D=/dev/loop0
> + M=/root/mnt/temp
> + dd bs=1M count=256 if=/dev/zero of=/tmp/img
> 256+0 records in
> 256+0 records out
> 268435456 bytes (268 MB, 256 MiB) copied, 0,0937109 s, 2,9 GB/s
> + losetup /dev/loop0 /tmp/img
> + mkfs.f2fs /dev/loop0
> 
>       F2FS-tools: mkfs.f2fs Ver: 1.14.0 (2020-08-24)
> 
> Info: Disable heap-based policy
> Info: Debug level = 0
> Info: Trim is enabled
> Info: Segments per section = 1
> Info: Sections per zone = 1
> Info: sector size = 512
> Info: total sectors = 524288 (256 MB)
> Info: zone aligned segment0 blkaddr: 512
> Info: format version with
>     "Linux version 5.11.10-arch1-1 (linux@archlinux) (gcc (GCC) 10.2.0,
> GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Fri, 26 Mar 2021 00:11:29
> +0000"
> Info: [/dev/loop0] Discarding device
> Info: This device doesn't support BLKSECDISCARD
> Info: Discarded 256 MB
> Info: Overprovision ratio = 15.000%
> Info: Overprovision segments = 35 (GC reserved = 21)
> Info: format successful
> + fsck.f2fs /dev/loop0
> Info: Segments per section = 1
> Info: Sections per zone = 1
> Info: sector size = 512
> Info: total sectors = 524288 (256 MB)
> Info: MKFS version
>     "Linux version 5.11.10-arch1-1 (linux@archlinux) (gcc (GCC) 10.2.0,
> GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Fri, 26 Mar 2021 00:11:29
> +0000"
> Info: FSCK version
>     from "Linux version 5.11.10-arch1-1 (linux@archlinux) (gcc (GCC)
> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Fri, 26 Mar 2021
> 00:11:29 +0000"
>       to "Linux version 5.11.10-arch1-1 (linux@archlinux) (gcc (GCC)
> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Fri, 26 Mar 2021
> 00:11:29 +0000"
> Info: superblock features = 0 :
> Info: superblock encrypt level = 0, salt = 00000000000000000000000000000000
> Info: total FS sectors = 524288 (256 MB)
> Info: CKPT version = 6c224cab
> Info: Checked valid nat_bits in checkpoint
> Info: checkpoint state = 185 :  trimmed nat_bits compacted_summary unmount
> 
> [FSCK] Unreachable nat entries                        [Ok..] [0x0]
> [FSCK] SIT valid block bitmap checking                [Ok..]
> [FSCK] Hard link checking for regular file            [Ok..] [0x0]
> [FSCK] valid_block_count matching with CP             [Ok..] [0x2]
> [FSCK] valid_node_count matching with CP (de lookup)  [Ok..] [0x1]
> [FSCK] valid_node_count matching with CP (nat lookup) [Ok..] [0x1]
> [FSCK] valid_inode_count matched with CP              [Ok..] [0x1]
> [FSCK] free segment_count matched with CP             [Ok..] [0x72]
> [FSCK] next block offset is free                      [Ok..]
> [FSCK] fixing SIT types
> [FSCK] other corrupted bugs                           [Ok..]
> 
> Done: 0.048995 secs
> + mount /dev/loop0 /root/mnt/temp
> + dd bs=1M count=64
> if=/mnt/data/external/misc/movie/Idiocracy.2006.WEB-DL.1080p-ylnian.mkv
> of=/root/mnt/temp/a.mkv
> 64+0 records in
> 64+0 records out
> 67108864 bytes (67 MB, 64 MiB) copied, 0,0266206 s, 2,5 GB/s
> + umount /root/mnt/temp
> + resize.f2fs -s -t 262144 /dev/loop0
> Info: Segments per section = 1
> Info: Sections per zone = 1
> Info: sector size = 512
> Info: total sectors = 524288 (256 MB)
> Info: MKFS version
>     "Linux version 5.11.10-arch1-1 (linux@archlinux) (gcc (GCC) 10.2.0,
> GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Fri, 26 Mar 2021 00:11:29
> +0000"
> Info: FSCK version
>     from "Linux version 5.11.10-arch1-1 (linux@archlinux) (gcc (GCC)
> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Fri, 26 Mar 2021
> 00:11:29 +0000"
>       to "Linux version 5.11.10-arch1-1 (linux@archlinux) (gcc (GCC)
> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Fri, 26 Mar 2021
> 00:11:29 +0000"
> Info: superblock features = 0 :
> Info: superblock encrypt level = 0, salt = 00000000000000000000000000000000
> Info: total FS sectors = 524288 (256 MB)
> Info: CKPT version = 6c224caf
> Info: Duplicate valid checkpoint to mirror position 512 -> 1024
> Info: Write valid nat_bits in checkpoint
> [FIX] (move_one_curseg_info:2798)  --> Move curseg[0] 3 -> 37 after 8000
> 
> [FIX] (move_one_curseg_info:2798)  --> Move curseg[1] 3b -> 36 after 8000
> 
> [FIX] (move_one_curseg_info:2798)  --> Move curseg[2] 24 -> 35 after 8000
> 
> [FIX] (move_one_curseg_info:2798)  --> Move curseg[3] 0 -> 34 after 8000
> 
> [FIX] (move_one_curseg_info:2798)  --> Move curseg[4] 1 -> 33 after 8000
> 
> [FIX] (move_one_curseg_info:2798)  --> Move curseg[5] 2 -> 32 after 8000
> 
> Info: Write valid nat_bits in checkpoint
> Try to do defragement: Done
> [update_superblock: 695] Info: Done to update superblock
> Info: Write valid nat_bits in checkpoint
> [rebuild_checkpoint: 590] Info: Done to rebuild checkpoint blocks
> 
> Done: 0.058891 secs
> + fsck.f2fs /dev/loop0
> Info: Segments per section = 1
> Info: Sections per zone = 1
> Info: sector size = 512
> Info: total sectors = 524288 (256 MB)
> Info: MKFS version
>     "Linux version 5.11.10-arch1-1 (linux@archlinux) (gcc (GCC) 10.2.0,
> GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Fri, 26 Mar 2021 00:11:29
> +0000"
> Info: FSCK version
>     from "Linux version 5.11.10-arch1-1 (linux@archlinux) (gcc (GCC)
> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Fri, 26 Mar 2021
> 00:11:29 +0000"
>       to "Linux version 5.11.10-arch1-1 (linux@archlinux) (gcc (GCC)
> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Fri, 26 Mar 2021
> 00:11:29 +0000"
> Info: superblock features = 0 :
> Info: superblock encrypt level = 0, salt = 00000000000000000000000000000000
> Info: total FS sectors = 262144 (128 MB)
>       Invalid CP CRC offset: 0
> Info: CKPT version = 6c224cb0
> Info: Checked valid nat_bits in checkpoint
> Info: checkpoint state = 181 :  trimmed nat_bits unmount
> 
> [FSCK] Unreachable nat entries                        [Ok..] [0x0]
> [FSCK] SIT valid block bitmap checking                [Ok..]
> [FSCK] Hard link checking for regular file            [Ok..] [0x0]
> [FSCK] valid_block_count matching with CP             [Ok..] [0x4014]
> [FSCK] valid_node_count matching with CP (de lookup)  [Ok..] [0x13]
> [FSCK] valid_node_count matching with CP (nat lookup) [Ok..] [0x13]
> [FSCK] valid_inode_count matched with CP              [Ok..] [0x2]
> [FSCK] free segment_count matched with CP             [Ok..] [0xe]
> [FSCK] next block offset is free                      [Ok..]
> [FSCK] fixing SIT types
> [FSCK] other corrupted bugs                           [Ok..]
> 
> Done: 0.115494 secs
> + set +e
> + mount /dev/loop0 /root/mnt/temp
> Apr 02 12:25:11 beroal kernel: F2FS-fs (loop0): invalid crc_offset: 0
> Apr 02 12:25:11 beroal kernel: F2FS-fs (loop0): Wrong valid_user_blocks:
> 16404, user_block_count: 13312
> Apr 02 12:25:11 beroal kernel: F2FS-fs (loop0): Failed to get valid F2FS
> checkpoint
> mount: /root/mnt/temp: mount(2) system call failed: Structure needs
> cleaning.
> + umount /root/mnt/temp
> umount: /root/mnt/temp: not mounted.
> + set -e
> + losetup -d /dev/loop0
> ```
> 
> (I inserted messages from the kernel log.)
> 
> On 02.04.21 10:23, Chao Yu wrote:
>> Hi beroal,
>>
>> I  figured out a patch, could you please check with it?
>>
>> [PATCH] resize.f2fs: fix wrong sit/nat bitmap during rebuild_checkpoint()
>>
>> On 2021/3/29 9:51, Chao Yu wrote:
>>> Hello,
>>>
>>> Sorry for the delay reply.
>>>
>>> I can reproduce this bug now, but I haven't enough time for debuging,
>>> will
>>> check this soon.
>>>
>>> On 2021/3/27 21:26, beroal wrote:
>>>> Ping.
>>>>
>>>> On 19.03.21 23:24, beroal wrote:
>>>>> Hi. I am trying to use a new function to reduce the size of an F2FS
>>>>> file system. After resizing, `fsck.f2fs` gives a lot of errors. Here
>>>>> is a shell script that creates and resizes a dummy file system:
>>>>>
>>>>> ```
>>>>> #!/bin/sh
>>>>> set -e
>>>>> F=/tmp/img
>>>>> D=/dev/loop0
>>>>> M=/root/mnt/temp
>>>>> dd bs=1M count=256 if=/dev/zero "of=$F"
>>>>> losetup "$D" "$F"
>>>>> mkfs.f2fs "$D"
>>>>> fsck.f2fs "$D"
>>>>> mount "$D" "$M"
>>>>> dd bs=1M count=64
>>>>> if=/mnt/data/external/misc/movie/Idiocracy.2006.WEB-DL.1080p-ylnian.mkv
>>>>>
>>>>> of="${M}/a.mkv"
>>>>> umount "$M"
>>>>> resize.f2fs -s -t 262144 "$D"
>>>>> fsck.f2fs "$D"
>>>>> losetup -d "$D"
>>>>> ```
>>>>>
>>>>> ```
>>>>> + set -e
>>>>> + F=/tmp/img
>>>>> + D=/dev/loop0
>>>>> + M=/root/mnt/temp
>>>>> + dd bs=1M count=256 if=/dev/zero of=/tmp/img
>>>>> 256+0 records in
>>>>> 256+0 records out
>>>>> 268435456 bytes (268 MB, 256 MiB) copied, 0.0867954 s, 3.1 GB/s
>>>>> + losetup /dev/loop0 /tmp/img
>>>>> + mkfs.f2fs /dev/loop0
>>>>>
>>>>>        F2FS-tools: mkfs.f2fs Ver: 1.14.0 (2020-08-24)
>>>>>
>>>>> Info: Disable heap-based policy
>>>>> Info: Debug level = 0
>>>>> Info: Trim is enabled
>>>>> Info: Segments per section = 1
>>>>> Info: Sections per zone = 1
>>>>> Info: sector size = 512
>>>>> Info: total sectors = 524288 (256 MB)
>>>>> Info: zone aligned segment0 blkaddr: 512
>>>>> Info: format version with
>>>>>      "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC) 10.2.0,
>>>>> GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021 16:59:58
>>>>> +0000"
>>>>> Info: [/dev/loop0] Discarding device
>>>>> Info: This device doesn't support BLKSECDISCARD
>>>>> Info: Discarded 256 MB
>>>>> Info: Overprovision ratio = 15.000%
>>>>> Info: Overprovision segments = 35 (GC reserved = 21)
>>>>> Info: format successful
>>>>> + fsck.f2fs /dev/loop0
>>>>> Info: Segments per section = 1
>>>>> Info: Sections per zone = 1
>>>>> Info: sector size = 512
>>>>> Info: total sectors = 524288 (256 MB)
>>>>> Info: MKFS version
>>>>>      "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC) 10.2.0,
>>>>> GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021 16:59:58
>>>>> +0000"
>>>>> Info: FSCK version
>>>>>      from "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC)
>>>>> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021
>>>>> 16:59:58 +0000"
>>>>>        to "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC)
>>>>> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021
>>>>> 16:59:58 +0000"
>>>>> Info: superblock features = 0 :
>>>>> Info: superblock encrypt level = 0, salt =
>>>>> 00000000000000000000000000000000
>>>>> Info: total FS sectors = 524288 (256 MB)
>>>>> Info: CKPT version = 8aa0d85
>>>>> Info: Checked valid nat_bits in checkpoint
>>>>> Info: checkpoint state = 185 :  trimmed nat_bits compacted_summary
>>>>> unmount
>>>>>
>>>>> [FSCK] Unreachable nat entries                        [Ok..] [0x0]
>>>>> [FSCK] SIT valid block bitmap checking                [Ok..]
>>>>> [FSCK] Hard link checking for regular file            [Ok..] [0x0]
>>>>> [FSCK] valid_block_count matching with CP             [Ok..] [0x2]
>>>>> [FSCK] valid_node_count matching with CP (de lookup)  [Ok..] [0x1]
>>>>> [FSCK] valid_node_count matching with CP (nat lookup) [Ok..] [0x1]
>>>>> [FSCK] valid_inode_count matched with CP              [Ok..] [0x1]
>>>>> [FSCK] free segment_count matched with CP             [Ok..] [0x72]
>>>>> [FSCK] next block offset is free                      [Ok..]
>>>>> [FSCK] fixing SIT types
>>>>> [FSCK] other corrupted bugs                           [Ok..]
>>>>>
>>>>> Done: 0.068899 secs
>>>>> + mount /dev/loop0 /root/mnt/temp
>>>>> + dd bs=1M count=64
>>>>> if=/mnt/data/external/misc/movie/Idiocracy.2006.WEB-DL.1080p-ylnian.mkv
>>>>>
>>>>> of=/root/mnt/temp/a.mkv
>>>>> 64+0 records in
>>>>> 64+0 records out
>>>>> 67108864 bytes (67 MB, 64 MiB) copied, 0.0286261 s, 2.3 GB/s
>>>>> + umount /root/mnt/temp
>>>>> + resize.f2fs -s -t 262144 /dev/loop0
>>>>> Info: Segments per section = 1
>>>>> Info: Sections per zone = 1
>>>>> Info: sector size = 512
>>>>> Info: total sectors = 524288 (256 MB)
>>>>> Info: MKFS version
>>>>>      "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC) 10.2.0,
>>>>> GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021 16:59:58
>>>>> +0000"
>>>>> Info: FSCK version
>>>>>      from "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC)
>>>>> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021
>>>>> 16:59:58 +0000"
>>>>>        to "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC)
>>>>> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021
>>>>> 16:59:58 +0000"
>>>>> Info: superblock features = 0 :
>>>>> Info: superblock encrypt level = 0, salt =
>>>>> 00000000000000000000000000000000
>>>>> Info: total FS sectors = 524288 (256 MB)
>>>>> Info: CKPT version = 8aa0d89
>>>>> Info: Duplicate valid checkpoint to mirror position 512 -> 1024
>>>>> Info: Write valid nat_bits in checkpoint
>>>>> [FIX] (move_one_curseg_info:2798)  --> Move curseg[0] 3 -> 37 after
>>>>> 8000
>>>>>
>>>>> [FIX] (move_one_curseg_info:2798)  --> Move curseg[1] 3b -> 36
>>>>> after 8000
>>>>>
>>>>> [FIX] (move_one_curseg_info:2798)  --> Move curseg[2] 24 -> 35
>>>>> after 8000
>>>>>
>>>>> [FIX] (move_one_curseg_info:2798)  --> Move curseg[3] 0 -> 34 after
>>>>> 8000
>>>>>
>>>>> [FIX] (move_one_curseg_info:2798)  --> Move curseg[4] 1 -> 33 after
>>>>> 8000
>>>>>
>>>>> [FIX] (move_one_curseg_info:2798)  --> Move curseg[5] 2 -> 32 after
>>>>> 8000
>>>>>
>>>>> Info: Write valid nat_bits in checkpoint
>>>>> Try to do defragement: Done
>>>>> [update_superblock: 695] Info: Done to update superblock
>>>>> Info: Write valid nat_bits in checkpoint
>>>>> [rebuild_checkpoint: 585] Info: Done to rebuild checkpoint blocks
>>>>>
>>>>> Done: 0.065604 secs
>>>>> + fsck.f2fs /dev/loop0
>>>>> Info: Segments per section = 1
>>>>> Info: Sections per zone = 1
>>>>> Info: sector size = 512
>>>>> Info: total sectors = 524288 (256 MB)
>>>>> Info: MKFS version
>>>>>      "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC) 10.2.0,
>>>>> GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021 16:59:58
>>>>> +0000"
>>>>> Info: FSCK version
>>>>>      from "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC)
>>>>> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021
>>>>> 16:59:58 +0000"
>>>>>        to "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC)
>>>>> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021
>>>>> 16:59:58 +0000"
>>>>> Info: superblock features = 0 :
>>>>> Info: superblock encrypt level = 0, salt =
>>>>> 00000000000000000000000000000000
>>>>> Info: total FS sectors = 262144 (128 MB)
>>>>>        Invalid CP CRC offset: 0
>>>>> Info: CKPT version = 8aa0d8a
>>>>> Info: Checked valid nat_bits in checkpoint
>>>>> Info: checkpoint state = 181 :  trimmed nat_bits unmount
>>>>> [ASSERT] (fsck_chk_curseg_info:2958)  --> Incorrect curseg [1]: segno
>>>>> [0x36] type(SIT) [0]
>>>>> [ASSERT] (fsck_chk_curseg_info:2958)  --> Incorrect curseg [2]: segno
>>>>> [0x35] type(SIT) [0]
>>>>> [ASSERT] (fsck_chk_curseg_info:2958)  --> Incorrect curseg [3]: segno
>>>>> [0x34] type(SIT) [0]
>>>>> [ASSERT] (fsck_chk_curseg_info:2958)  --> Incorrect curseg [4]: segno
>>>>> [0x33] type(SIT) [0]
>>>>> [ASSERT] (fsck_chk_curseg_info:2958)  --> Incorrect curseg [5]: segno
>>>>> [0x32] type(SIT) [0]
>>>>> [ASSERT] (sanity_check_nid: 480)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x1002]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x1601]
>>>>> [ASSERT] (sanity_check_nid: 480)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x1211]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a00]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a01]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a02]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a03]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a04]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a05]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a06]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a07]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a08]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a09]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a0a]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a0b]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a0c]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a0d]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a0e]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a0f]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a10]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a11]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a12]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a13]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a14]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a15]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a16]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a17]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a18]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a19]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a1a]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a1b]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a1c]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a1d]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a1e]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a1f]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a20]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a21]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a22]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a23]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a24]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a25]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a26]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a27]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a28]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a29]
>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>> blk_addr[0x4a2a]
>>>>> {{{skipped}}}
>>>>> ```
>>>>>
>>>>> The whole output is huge.
>>>>>
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Linux-f2fs-devel mailing list
>>>>> Linux-f2fs-devel@lists.sourceforge.net
>>>>> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
>>>>
>>>>
>>>> _______________________________________________
>>>> Linux-f2fs-devel mailing list
>>>> Linux-f2fs-devel@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
>>>>
>>>
>>>
>>> _______________________________________________
>>> Linux-f2fs-devel mailing list
>>> Linux-f2fs-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
>>>
>>
> .
> 


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

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

* Re: [f2fs-dev] f2fs.resize makes errors in FS
  2021-04-06  1:44         ` Chao Yu
@ 2021-04-12 15:40           ` beroal
  2021-04-13  1:25             ` Chao Yu
  0 siblings, 1 reply; 9+ messages in thread
From: beroal @ 2021-04-12 15:40 UTC (permalink / raw)
  To: Chao Yu, linux-f2fs-devel

Hi. Sorry for the delay. The 1.14.0 version with the patches "fix wrong 
sit/nat bitmap during rebuild_checkpoint()" and "fix to check free space 
before shrink" completes my test case successfully.

On 06.04.21 04:44, Chao Yu wrote:
> Hi beroal,
>
> Could you please apply below patch based on last fix patch and
> do the test again?
>
> [PATCH] resize.f2fs: fix to check free space before shrink
>
> On 2021/4/2 17:28, beroal wrote:
>> I can't mount the resulting file system.
>>
>> ```
>> + set -e
>> + F=/tmp/img
>> + D=/dev/loop0
>> + M=/root/mnt/temp
>> + dd bs=1M count=256 if=/dev/zero of=/tmp/img
>> 256+0 records in
>> 256+0 records out
>> 268435456 bytes (268 MB, 256 MiB) copied, 0,0937109 s, 2,9 GB/s
>> + losetup /dev/loop0 /tmp/img
>> + mkfs.f2fs /dev/loop0
>>
>>       F2FS-tools: mkfs.f2fs Ver: 1.14.0 (2020-08-24)
>>
>> Info: Disable heap-based policy
>> Info: Debug level = 0
>> Info: Trim is enabled
>> Info: Segments per section = 1
>> Info: Sections per zone = 1
>> Info: sector size = 512
>> Info: total sectors = 524288 (256 MB)
>> Info: zone aligned segment0 blkaddr: 512
>> Info: format version with
>>     "Linux version 5.11.10-arch1-1 (linux@archlinux) (gcc (GCC) 10.2.0,
>> GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Fri, 26 Mar 2021 00:11:29
>> +0000"
>> Info: [/dev/loop0] Discarding device
>> Info: This device doesn't support BLKSECDISCARD
>> Info: Discarded 256 MB
>> Info: Overprovision ratio = 15.000%
>> Info: Overprovision segments = 35 (GC reserved = 21)
>> Info: format successful
>> + fsck.f2fs /dev/loop0
>> Info: Segments per section = 1
>> Info: Sections per zone = 1
>> Info: sector size = 512
>> Info: total sectors = 524288 (256 MB)
>> Info: MKFS version
>>     "Linux version 5.11.10-arch1-1 (linux@archlinux) (gcc (GCC) 10.2.0,
>> GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Fri, 26 Mar 2021 00:11:29
>> +0000"
>> Info: FSCK version
>>     from "Linux version 5.11.10-arch1-1 (linux@archlinux) (gcc (GCC)
>> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Fri, 26 Mar 2021
>> 00:11:29 +0000"
>>       to "Linux version 5.11.10-arch1-1 (linux@archlinux) (gcc (GCC)
>> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Fri, 26 Mar 2021
>> 00:11:29 +0000"
>> Info: superblock features = 0 :
>> Info: superblock encrypt level = 0, salt = 
>> 00000000000000000000000000000000
>> Info: total FS sectors = 524288 (256 MB)
>> Info: CKPT version = 6c224cab
>> Info: Checked valid nat_bits in checkpoint
>> Info: checkpoint state = 185 :  trimmed nat_bits compacted_summary 
>> unmount
>>
>> [FSCK] Unreachable nat entries                        [Ok..] [0x0]
>> [FSCK] SIT valid block bitmap checking                [Ok..]
>> [FSCK] Hard link checking for regular file            [Ok..] [0x0]
>> [FSCK] valid_block_count matching with CP             [Ok..] [0x2]
>> [FSCK] valid_node_count matching with CP (de lookup)  [Ok..] [0x1]
>> [FSCK] valid_node_count matching with CP (nat lookup) [Ok..] [0x1]
>> [FSCK] valid_inode_count matched with CP              [Ok..] [0x1]
>> [FSCK] free segment_count matched with CP             [Ok..] [0x72]
>> [FSCK] next block offset is free                      [Ok..]
>> [FSCK] fixing SIT types
>> [FSCK] other corrupted bugs                           [Ok..]
>>
>> Done: 0.048995 secs
>> + mount /dev/loop0 /root/mnt/temp
>> + dd bs=1M count=64
>> if=/mnt/data/external/misc/movie/Idiocracy.2006.WEB-DL.1080p-ylnian.mkv
>> of=/root/mnt/temp/a.mkv
>> 64+0 records in
>> 64+0 records out
>> 67108864 bytes (67 MB, 64 MiB) copied, 0,0266206 s, 2,5 GB/s
>> + umount /root/mnt/temp
>> + resize.f2fs -s -t 262144 /dev/loop0
>> Info: Segments per section = 1
>> Info: Sections per zone = 1
>> Info: sector size = 512
>> Info: total sectors = 524288 (256 MB)
>> Info: MKFS version
>>     "Linux version 5.11.10-arch1-1 (linux@archlinux) (gcc (GCC) 10.2.0,
>> GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Fri, 26 Mar 2021 00:11:29
>> +0000"
>> Info: FSCK version
>>     from "Linux version 5.11.10-arch1-1 (linux@archlinux) (gcc (GCC)
>> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Fri, 26 Mar 2021
>> 00:11:29 +0000"
>>       to "Linux version 5.11.10-arch1-1 (linux@archlinux) (gcc (GCC)
>> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Fri, 26 Mar 2021
>> 00:11:29 +0000"
>> Info: superblock features = 0 :
>> Info: superblock encrypt level = 0, salt = 
>> 00000000000000000000000000000000
>> Info: total FS sectors = 524288 (256 MB)
>> Info: CKPT version = 6c224caf
>> Info: Duplicate valid checkpoint to mirror position 512 -> 1024
>> Info: Write valid nat_bits in checkpoint
>> [FIX] (move_one_curseg_info:2798)  --> Move curseg[0] 3 -> 37 after 8000
>>
>> [FIX] (move_one_curseg_info:2798)  --> Move curseg[1] 3b -> 36 after 
>> 8000
>>
>> [FIX] (move_one_curseg_info:2798)  --> Move curseg[2] 24 -> 35 after 
>> 8000
>>
>> [FIX] (move_one_curseg_info:2798)  --> Move curseg[3] 0 -> 34 after 8000
>>
>> [FIX] (move_one_curseg_info:2798)  --> Move curseg[4] 1 -> 33 after 8000
>>
>> [FIX] (move_one_curseg_info:2798)  --> Move curseg[5] 2 -> 32 after 8000
>>
>> Info: Write valid nat_bits in checkpoint
>> Try to do defragement: Done
>> [update_superblock: 695] Info: Done to update superblock
>> Info: Write valid nat_bits in checkpoint
>> [rebuild_checkpoint: 590] Info: Done to rebuild checkpoint blocks
>>
>> Done: 0.058891 secs
>> + fsck.f2fs /dev/loop0
>> Info: Segments per section = 1
>> Info: Sections per zone = 1
>> Info: sector size = 512
>> Info: total sectors = 524288 (256 MB)
>> Info: MKFS version
>>     "Linux version 5.11.10-arch1-1 (linux@archlinux) (gcc (GCC) 10.2.0,
>> GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Fri, 26 Mar 2021 00:11:29
>> +0000"
>> Info: FSCK version
>>     from "Linux version 5.11.10-arch1-1 (linux@archlinux) (gcc (GCC)
>> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Fri, 26 Mar 2021
>> 00:11:29 +0000"
>>       to "Linux version 5.11.10-arch1-1 (linux@archlinux) (gcc (GCC)
>> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Fri, 26 Mar 2021
>> 00:11:29 +0000"
>> Info: superblock features = 0 :
>> Info: superblock encrypt level = 0, salt = 
>> 00000000000000000000000000000000
>> Info: total FS sectors = 262144 (128 MB)
>>       Invalid CP CRC offset: 0
>> Info: CKPT version = 6c224cb0
>> Info: Checked valid nat_bits in checkpoint
>> Info: checkpoint state = 181 :  trimmed nat_bits unmount
>>
>> [FSCK] Unreachable nat entries                        [Ok..] [0x0]
>> [FSCK] SIT valid block bitmap checking                [Ok..]
>> [FSCK] Hard link checking for regular file            [Ok..] [0x0]
>> [FSCK] valid_block_count matching with CP             [Ok..] [0x4014]
>> [FSCK] valid_node_count matching with CP (de lookup)  [Ok..] [0x13]
>> [FSCK] valid_node_count matching with CP (nat lookup) [Ok..] [0x13]
>> [FSCK] valid_inode_count matched with CP              [Ok..] [0x2]
>> [FSCK] free segment_count matched with CP             [Ok..] [0xe]
>> [FSCK] next block offset is free                      [Ok..]
>> [FSCK] fixing SIT types
>> [FSCK] other corrupted bugs                           [Ok..]
>>
>> Done: 0.115494 secs
>> + set +e
>> + mount /dev/loop0 /root/mnt/temp
>> Apr 02 12:25:11 beroal kernel: F2FS-fs (loop0): invalid crc_offset: 0
>> Apr 02 12:25:11 beroal kernel: F2FS-fs (loop0): Wrong valid_user_blocks:
>> 16404, user_block_count: 13312
>> Apr 02 12:25:11 beroal kernel: F2FS-fs (loop0): Failed to get valid F2FS
>> checkpoint
>> mount: /root/mnt/temp: mount(2) system call failed: Structure needs
>> cleaning.
>> + umount /root/mnt/temp
>> umount: /root/mnt/temp: not mounted.
>> + set -e
>> + losetup -d /dev/loop0
>> ```
>>
>> (I inserted messages from the kernel log.)
>>
>> On 02.04.21 10:23, Chao Yu wrote:
>>> Hi beroal,
>>>
>>> I  figured out a patch, could you please check with it?
>>>
>>> [PATCH] resize.f2fs: fix wrong sit/nat bitmap during 
>>> rebuild_checkpoint()
>>>
>>> On 2021/3/29 9:51, Chao Yu wrote:
>>>> Hello,
>>>>
>>>> Sorry for the delay reply.
>>>>
>>>> I can reproduce this bug now, but I haven't enough time for debuging,
>>>> will
>>>> check this soon.
>>>>
>>>> On 2021/3/27 21:26, beroal wrote:
>>>>> Ping.
>>>>>
>>>>> On 19.03.21 23:24, beroal wrote:
>>>>>> Hi. I am trying to use a new function to reduce the size of an F2FS
>>>>>> file system. After resizing, `fsck.f2fs` gives a lot of errors. Here
>>>>>> is a shell script that creates and resizes a dummy file system:
>>>>>>
>>>>>> ```
>>>>>> #!/bin/sh
>>>>>> set -e
>>>>>> F=/tmp/img
>>>>>> D=/dev/loop0
>>>>>> M=/root/mnt/temp
>>>>>> dd bs=1M count=256 if=/dev/zero "of=$F"
>>>>>> losetup "$D" "$F"
>>>>>> mkfs.f2fs "$D"
>>>>>> fsck.f2fs "$D"
>>>>>> mount "$D" "$M"
>>>>>> dd bs=1M count=64
>>>>>> if=/mnt/data/external/misc/movie/Idiocracy.2006.WEB-DL.1080p-ylnian.mkv 
>>>>>>
>>>>>>
>>>>>> of="${M}/a.mkv"
>>>>>> umount "$M"
>>>>>> resize.f2fs -s -t 262144 "$D"
>>>>>> fsck.f2fs "$D"
>>>>>> losetup -d "$D"
>>>>>> ```
>>>>>>
>>>>>> ```
>>>>>> + set -e
>>>>>> + F=/tmp/img
>>>>>> + D=/dev/loop0
>>>>>> + M=/root/mnt/temp
>>>>>> + dd bs=1M count=256 if=/dev/zero of=/tmp/img
>>>>>> 256+0 records in
>>>>>> 256+0 records out
>>>>>> 268435456 bytes (268 MB, 256 MiB) copied, 0.0867954 s, 3.1 GB/s
>>>>>> + losetup /dev/loop0 /tmp/img
>>>>>> + mkfs.f2fs /dev/loop0
>>>>>>
>>>>>>        F2FS-tools: mkfs.f2fs Ver: 1.14.0 (2020-08-24)
>>>>>>
>>>>>> Info: Disable heap-based policy
>>>>>> Info: Debug level = 0
>>>>>> Info: Trim is enabled
>>>>>> Info: Segments per section = 1
>>>>>> Info: Sections per zone = 1
>>>>>> Info: sector size = 512
>>>>>> Info: total sectors = 524288 (256 MB)
>>>>>> Info: zone aligned segment0 blkaddr: 512
>>>>>> Info: format version with
>>>>>>      "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc(GCC) 
>>>>>> 10.2.0,
>>>>>> GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021 
>>>>>> 16:59:58
>>>>>> +0000"
>>>>>> Info: [/dev/loop0] Discarding device
>>>>>> Info: This device doesn't support BLKSECDISCARD
>>>>>> Info: Discarded 256 MB
>>>>>> Info: Overprovision ratio = 15.000%
>>>>>> Info: Overprovision segments = 35 (GC reserved = 21)
>>>>>> Info: format successful
>>>>>> + fsck.f2fs /dev/loop0
>>>>>> Info: Segments per section = 1
>>>>>> Info: Sections per zone = 1
>>>>>> Info: sector size = 512
>>>>>> Info: total sectors = 524288 (256 MB)
>>>>>> Info: MKFS version
>>>>>>      "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc(GCC) 
>>>>>> 10.2.0,
>>>>>> GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021 
>>>>>> 16:59:58
>>>>>> +0000"
>>>>>> Info: FSCK version
>>>>>>      from "Linux version 5.11.7-arch1-1 (linux@archlinux)(gcc (GCC)
>>>>>> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 
>>>>>> 2021
>>>>>> 16:59:58 +0000"
>>>>>>        to "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC)
>>>>>> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 
>>>>>> 2021
>>>>>> 16:59:58 +0000"
>>>>>> Info: superblock features = 0 :
>>>>>> Info: superblock encrypt level = 0, salt =
>>>>>> 00000000000000000000000000000000
>>>>>> Info: total FS sectors = 524288 (256 MB)
>>>>>> Info: CKPT version = 8aa0d85
>>>>>> Info: Checked valid nat_bits in checkpoint
>>>>>> Info: checkpoint state = 185 :  trimmed nat_bits compacted_summary
>>>>>> unmount
>>>>>>
>>>>>> [FSCK] Unreachable nat entries [Ok..] [0x0]
>>>>>> [FSCK] SIT valid block bitmap checking [Ok..]
>>>>>> [FSCK] Hard link checking for regular file [Ok..] [0x0]
>>>>>> [FSCK] valid_block_count matching with CP [Ok..] [0x2]
>>>>>> [FSCK] valid_node_count matching with CP (de lookup) [Ok..] [0x1]
>>>>>> [FSCK] valid_node_count matching with CP (nat lookup) [Ok..] [0x1]
>>>>>> [FSCK] valid_inode_count matched with CP [Ok..] [0x1]
>>>>>> [FSCK] free segment_count matched with CP [Ok..] [0x72]
>>>>>> [FSCK] next block offset is free [Ok..]
>>>>>> [FSCK] fixing SIT types
>>>>>> [FSCK] other corrupted bugs [Ok..]
>>>>>>
>>>>>> Done: 0.068899 secs
>>>>>> + mount /dev/loop0 /root/mnt/temp
>>>>>> + dd bs=1M count=64
>>>>>> if=/mnt/data/external/misc/movie/Idiocracy.2006.WEB-DL.1080p-ylnian.mkv 
>>>>>>
>>>>>>
>>>>>> of=/root/mnt/temp/a.mkv
>>>>>> 64+0 records in
>>>>>> 64+0 records out
>>>>>> 67108864 bytes (67 MB, 64 MiB) copied, 0.0286261 s, 2.3 GB/s
>>>>>> + umount /root/mnt/temp
>>>>>> + resize.f2fs -s -t 262144 /dev/loop0
>>>>>> Info: Segments per section = 1
>>>>>> Info: Sections per zone = 1
>>>>>> Info: sector size = 512
>>>>>> Info: total sectors = 524288 (256 MB)
>>>>>> Info: MKFS version
>>>>>>      "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc(GCC) 
>>>>>> 10.2.0,
>>>>>> GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021 
>>>>>> 16:59:58
>>>>>> +0000"
>>>>>> Info: FSCK version
>>>>>>      from "Linux version 5.11.7-arch1-1 (linux@archlinux)(gcc (GCC)
>>>>>> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 
>>>>>> 2021
>>>>>> 16:59:58 +0000"
>>>>>>        to "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC)
>>>>>> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 
>>>>>> 2021
>>>>>> 16:59:58 +0000"
>>>>>> Info: superblock features = 0 :
>>>>>> Info: superblock encrypt level = 0, salt =
>>>>>> 00000000000000000000000000000000
>>>>>> Info: total FS sectors = 524288 (256 MB)
>>>>>> Info: CKPT version = 8aa0d89
>>>>>> Info: Duplicate valid checkpoint to mirror position 512 -> 1024
>>>>>> Info: Write valid nat_bits in checkpoint
>>>>>> [FIX] (move_one_curseg_info:2798)  --> Move curseg[0] 3 -> 37 after
>>>>>> 8000
>>>>>>
>>>>>> [FIX] (move_one_curseg_info:2798)  --> Move curseg[1] 3b -> 36
>>>>>> after 8000
>>>>>>
>>>>>> [FIX] (move_one_curseg_info:2798)  --> Move curseg[2] 24 -> 35
>>>>>> after 8000
>>>>>>
>>>>>> [FIX] (move_one_curseg_info:2798)  --> Move curseg[3] 0 -> 34 after
>>>>>> 8000
>>>>>>
>>>>>> [FIX] (move_one_curseg_info:2798)  --> Move curseg[4] 1 -> 33 after
>>>>>> 8000
>>>>>>
>>>>>> [FIX] (move_one_curseg_info:2798)  --> Move curseg[5] 2 -> 32 after
>>>>>> 8000
>>>>>>
>>>>>> Info: Write valid nat_bits in checkpoint
>>>>>> Try to do defragement: Done
>>>>>> [update_superblock: 695] Info: Done to update superblock
>>>>>> Info: Write valid nat_bits in checkpoint
>>>>>> [rebuild_checkpoint: 585] Info: Done to rebuild checkpoint blocks
>>>>>>
>>>>>> Done: 0.065604 secs
>>>>>> + fsck.f2fs /dev/loop0
>>>>>> Info: Segments per section = 1
>>>>>> Info: Sections per zone = 1
>>>>>> Info: sector size = 512
>>>>>> Info: total sectors = 524288 (256 MB)
>>>>>> Info: MKFS version
>>>>>>      "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc(GCC) 
>>>>>> 10.2.0,
>>>>>> GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021 
>>>>>> 16:59:58
>>>>>> +0000"
>>>>>> Info: FSCK version
>>>>>>      from "Linux version 5.11.7-arch1-1 (linux@archlinux)(gcc (GCC)
>>>>>> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 
>>>>>> 2021
>>>>>> 16:59:58 +0000"
>>>>>>        to "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC)
>>>>>> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 
>>>>>> 2021
>>>>>> 16:59:58 +0000"
>>>>>> Info: superblock features = 0 :
>>>>>> Info: superblock encrypt level = 0, salt =
>>>>>> 00000000000000000000000000000000
>>>>>> Info: total FS sectors = 262144 (128 MB)
>>>>>>        Invalid CP CRC offset: 0
>>>>>> Info: CKPT version = 8aa0d8a
>>>>>> Info: Checked valid nat_bits in checkpoint
>>>>>> Info: checkpoint state = 181 :  trimmed nat_bits unmount
>>>>>> [ASSERT] (fsck_chk_curseg_info:2958)  --> Incorrect curseg [1]: 
>>>>>> segno
>>>>>> [0x36] type(SIT) [0]
>>>>>> [ASSERT] (fsck_chk_curseg_info:2958)  --> Incorrect curseg [2]: 
>>>>>> segno
>>>>>> [0x35] type(SIT) [0]
>>>>>> [ASSERT] (fsck_chk_curseg_info:2958)  --> Incorrect curseg [3]: 
>>>>>> segno
>>>>>> [0x34] type(SIT) [0]
>>>>>> [ASSERT] (fsck_chk_curseg_info:2958)  --> Incorrect curseg [4]: 
>>>>>> segno
>>>>>> [0x33] type(SIT) [0]
>>>>>> [ASSERT] (fsck_chk_curseg_info:2958)  --> Incorrect curseg [5]: 
>>>>>> segno
>>>>>> [0x32] type(SIT) [0]
>>>>>> [ASSERT] (sanity_check_nid: 480)  --> SIT bitmap is 0x0.
>>>>>> blk_addr[0x1002]
>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>> blk_addr[0x1601]
>>>>>> [ASSERT] (sanity_check_nid: 480)  --> SIT bitmap is 0x0.
>>>>>> blk_addr[0x1211]
>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>> blk_addr[0x4a00]
>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>> blk_addr[0x4a01]
>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>> blk_addr[0x4a02]
>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>> blk_addr[0x4a03]
>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>> blk_addr[0x4a04]
>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>> blk_addr[0x4a05]
>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>> blk_addr[0x4a06]
>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>> blk_addr[0x4a07]
>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>> blk_addr[0x4a08]
>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>> blk_addr[0x4a09]
>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>> blk_addr[0x4a0a]
>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>> blk_addr[0x4a0b]
>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>> blk_addr[0x4a0c]
>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>> blk_addr[0x4a0d]
>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>> blk_addr[0x4a0e]
>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>> blk_addr[0x4a0f]
>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>> blk_addr[0x4a10]
>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>> blk_addr[0x4a11]
>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>> blk_addr[0x4a12]
>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>> blk_addr[0x4a13]
>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>> blk_addr[0x4a14]
>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>> blk_addr[0x4a15]
>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>> blk_addr[0x4a16]
>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>> blk_addr[0x4a17]
>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>> blk_addr[0x4a18]
>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>> blk_addr[0x4a19]
>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>> blk_addr[0x4a1a]
>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>> blk_addr[0x4a1b]
>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>> blk_addr[0x4a1c]
>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>> blk_addr[0x4a1d]
>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>> blk_addr[0x4a1e]
>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>> blk_addr[0x4a1f]
>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>> blk_addr[0x4a20]
>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>> blk_addr[0x4a21]
>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>> blk_addr[0x4a22]
>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>> blk_addr[0x4a23]
>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>> blk_addr[0x4a24]
>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>> blk_addr[0x4a25]
>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>> blk_addr[0x4a26]
>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>> blk_addr[0x4a27]
>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>> blk_addr[0x4a28]
>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>> blk_addr[0x4a29]
>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>> blk_addr[0x4a2a]
>>>>>> {{{skipped}}}
>>>>>> ```
>>>>>>
>>>>>> The whole output is huge.
>>>>>>
>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> Linux-f2fs-devel mailing list
>>>>>> Linux-f2fs-devel@lists.sourceforge.net
>>>>>> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Linux-f2fs-devel mailing list
>>>>> Linux-f2fs-devel@lists.sourceforge.net
>>>>> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
>>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> Linux-f2fs-devel mailing list
>>>> Linux-f2fs-devel@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
>>>>
>>>
>> .
>>
>


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

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

* Re: [f2fs-dev] f2fs.resize makes errors in FS
  2021-04-12 15:40           ` beroal
@ 2021-04-13  1:25             ` Chao Yu
  0 siblings, 0 replies; 9+ messages in thread
From: Chao Yu @ 2021-04-13  1:25 UTC (permalink / raw)
  To: beroal, jaegeuk; +Cc: linux-f2fs-devel

On 2021/4/12 23:40, beroal wrote:
> Hi. Sorry for the delay. The 1.14.0 version with the patches "fix wrong
> sit/nat bitmap during rebuild_checkpoint()" and "fix to check free space
> before shrink" completes my test case successfully.

Thanks for the test. ;)

Jaegeuk, could you please check these two patch?

Thanks,

> 
> On 06.04.21 04:44, Chao Yu wrote:
>> Hi beroal,
>>
>> Could you please apply below patch based on last fix patch and
>> do the test again?
>>
>> [PATCH] resize.f2fs: fix to check free space before shrink
>>
>> On 2021/4/2 17:28, beroal wrote:
>>> I can't mount the resulting file system.
>>>
>>> ```
>>> + set -e
>>> + F=/tmp/img
>>> + D=/dev/loop0
>>> + M=/root/mnt/temp
>>> + dd bs=1M count=256 if=/dev/zero of=/tmp/img
>>> 256+0 records in
>>> 256+0 records out
>>> 268435456 bytes (268 MB, 256 MiB) copied, 0,0937109 s, 2,9 GB/s
>>> + losetup /dev/loop0 /tmp/img
>>> + mkfs.f2fs /dev/loop0
>>>
>>>        F2FS-tools: mkfs.f2fs Ver: 1.14.0 (2020-08-24)
>>>
>>> Info: Disable heap-based policy
>>> Info: Debug level = 0
>>> Info: Trim is enabled
>>> Info: Segments per section = 1
>>> Info: Sections per zone = 1
>>> Info: sector size = 512
>>> Info: total sectors = 524288 (256 MB)
>>> Info: zone aligned segment0 blkaddr: 512
>>> Info: format version with
>>>      "Linux version 5.11.10-arch1-1 (linux@archlinux) (gcc (GCC) 10.2.0,
>>> GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Fri, 26 Mar 2021 00:11:29
>>> +0000"
>>> Info: [/dev/loop0] Discarding device
>>> Info: This device doesn't support BLKSECDISCARD
>>> Info: Discarded 256 MB
>>> Info: Overprovision ratio = 15.000%
>>> Info: Overprovision segments = 35 (GC reserved = 21)
>>> Info: format successful
>>> + fsck.f2fs /dev/loop0
>>> Info: Segments per section = 1
>>> Info: Sections per zone = 1
>>> Info: sector size = 512
>>> Info: total sectors = 524288 (256 MB)
>>> Info: MKFS version
>>>      "Linux version 5.11.10-arch1-1 (linux@archlinux) (gcc (GCC) 10.2.0,
>>> GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Fri, 26 Mar 2021 00:11:29
>>> +0000"
>>> Info: FSCK version
>>>      from "Linux version 5.11.10-arch1-1 (linux@archlinux) (gcc (GCC)
>>> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Fri, 26 Mar 2021
>>> 00:11:29 +0000"
>>>        to "Linux version 5.11.10-arch1-1 (linux@archlinux) (gcc (GCC)
>>> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Fri, 26 Mar 2021
>>> 00:11:29 +0000"
>>> Info: superblock features = 0 :
>>> Info: superblock encrypt level = 0, salt =
>>> 00000000000000000000000000000000
>>> Info: total FS sectors = 524288 (256 MB)
>>> Info: CKPT version = 6c224cab
>>> Info: Checked valid nat_bits in checkpoint
>>> Info: checkpoint state = 185 :  trimmed nat_bits compacted_summary
>>> unmount
>>>
>>> [FSCK] Unreachable nat entries                        [Ok..] [0x0]
>>> [FSCK] SIT valid block bitmap checking                [Ok..]
>>> [FSCK] Hard link checking for regular file            [Ok..] [0x0]
>>> [FSCK] valid_block_count matching with CP             [Ok..] [0x2]
>>> [FSCK] valid_node_count matching with CP (de lookup)  [Ok..] [0x1]
>>> [FSCK] valid_node_count matching with CP (nat lookup) [Ok..] [0x1]
>>> [FSCK] valid_inode_count matched with CP              [Ok..] [0x1]
>>> [FSCK] free segment_count matched with CP             [Ok..] [0x72]
>>> [FSCK] next block offset is free                      [Ok..]
>>> [FSCK] fixing SIT types
>>> [FSCK] other corrupted bugs                           [Ok..]
>>>
>>> Done: 0.048995 secs
>>> + mount /dev/loop0 /root/mnt/temp
>>> + dd bs=1M count=64
>>> if=/mnt/data/external/misc/movie/Idiocracy.2006.WEB-DL.1080p-ylnian.mkv
>>> of=/root/mnt/temp/a.mkv
>>> 64+0 records in
>>> 64+0 records out
>>> 67108864 bytes (67 MB, 64 MiB) copied, 0,0266206 s, 2,5 GB/s
>>> + umount /root/mnt/temp
>>> + resize.f2fs -s -t 262144 /dev/loop0
>>> Info: Segments per section = 1
>>> Info: Sections per zone = 1
>>> Info: sector size = 512
>>> Info: total sectors = 524288 (256 MB)
>>> Info: MKFS version
>>>      "Linux version 5.11.10-arch1-1 (linux@archlinux) (gcc (GCC) 10.2.0,
>>> GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Fri, 26 Mar 2021 00:11:29
>>> +0000"
>>> Info: FSCK version
>>>      from "Linux version 5.11.10-arch1-1 (linux@archlinux) (gcc (GCC)
>>> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Fri, 26 Mar 2021
>>> 00:11:29 +0000"
>>>        to "Linux version 5.11.10-arch1-1 (linux@archlinux) (gcc (GCC)
>>> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Fri, 26 Mar 2021
>>> 00:11:29 +0000"
>>> Info: superblock features = 0 :
>>> Info: superblock encrypt level = 0, salt =
>>> 00000000000000000000000000000000
>>> Info: total FS sectors = 524288 (256 MB)
>>> Info: CKPT version = 6c224caf
>>> Info: Duplicate valid checkpoint to mirror position 512 -> 1024
>>> Info: Write valid nat_bits in checkpoint
>>> [FIX] (move_one_curseg_info:2798)  --> Move curseg[0] 3 -> 37 after 8000
>>>
>>> [FIX] (move_one_curseg_info:2798)  --> Move curseg[1] 3b -> 36 after
>>> 8000
>>>
>>> [FIX] (move_one_curseg_info:2798)  --> Move curseg[2] 24 -> 35 after
>>> 8000
>>>
>>> [FIX] (move_one_curseg_info:2798)  --> Move curseg[3] 0 -> 34 after 8000
>>>
>>> [FIX] (move_one_curseg_info:2798)  --> Move curseg[4] 1 -> 33 after 8000
>>>
>>> [FIX] (move_one_curseg_info:2798)  --> Move curseg[5] 2 -> 32 after 8000
>>>
>>> Info: Write valid nat_bits in checkpoint
>>> Try to do defragement: Done
>>> [update_superblock: 695] Info: Done to update superblock
>>> Info: Write valid nat_bits in checkpoint
>>> [rebuild_checkpoint: 590] Info: Done to rebuild checkpoint blocks
>>>
>>> Done: 0.058891 secs
>>> + fsck.f2fs /dev/loop0
>>> Info: Segments per section = 1
>>> Info: Sections per zone = 1
>>> Info: sector size = 512
>>> Info: total sectors = 524288 (256 MB)
>>> Info: MKFS version
>>>      "Linux version 5.11.10-arch1-1 (linux@archlinux) (gcc (GCC) 10.2.0,
>>> GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Fri, 26 Mar 2021 00:11:29
>>> +0000"
>>> Info: FSCK version
>>>      from "Linux version 5.11.10-arch1-1 (linux@archlinux) (gcc (GCC)
>>> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Fri, 26 Mar 2021
>>> 00:11:29 +0000"
>>>        to "Linux version 5.11.10-arch1-1 (linux@archlinux) (gcc (GCC)
>>> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Fri, 26 Mar 2021
>>> 00:11:29 +0000"
>>> Info: superblock features = 0 :
>>> Info: superblock encrypt level = 0, salt =
>>> 00000000000000000000000000000000
>>> Info: total FS sectors = 262144 (128 MB)
>>>        Invalid CP CRC offset: 0
>>> Info: CKPT version = 6c224cb0
>>> Info: Checked valid nat_bits in checkpoint
>>> Info: checkpoint state = 181 :  trimmed nat_bits unmount
>>>
>>> [FSCK] Unreachable nat entries                        [Ok..] [0x0]
>>> [FSCK] SIT valid block bitmap checking                [Ok..]
>>> [FSCK] Hard link checking for regular file            [Ok..] [0x0]
>>> [FSCK] valid_block_count matching with CP             [Ok..] [0x4014]
>>> [FSCK] valid_node_count matching with CP (de lookup)  [Ok..] [0x13]
>>> [FSCK] valid_node_count matching with CP (nat lookup) [Ok..] [0x13]
>>> [FSCK] valid_inode_count matched with CP              [Ok..] [0x2]
>>> [FSCK] free segment_count matched with CP             [Ok..] [0xe]
>>> [FSCK] next block offset is free                      [Ok..]
>>> [FSCK] fixing SIT types
>>> [FSCK] other corrupted bugs                           [Ok..]
>>>
>>> Done: 0.115494 secs
>>> + set +e
>>> + mount /dev/loop0 /root/mnt/temp
>>> Apr 02 12:25:11 beroal kernel: F2FS-fs (loop0): invalid crc_offset: 0
>>> Apr 02 12:25:11 beroal kernel: F2FS-fs (loop0): Wrong valid_user_blocks:
>>> 16404, user_block_count: 13312
>>> Apr 02 12:25:11 beroal kernel: F2FS-fs (loop0): Failed to get valid F2FS
>>> checkpoint
>>> mount: /root/mnt/temp: mount(2) system call failed: Structure needs
>>> cleaning.
>>> + umount /root/mnt/temp
>>> umount: /root/mnt/temp: not mounted.
>>> + set -e
>>> + losetup -d /dev/loop0
>>> ```
>>>
>>> (I inserted messages from the kernel log.)
>>>
>>> On 02.04.21 10:23, Chao Yu wrote:
>>>> Hi beroal,
>>>>
>>>> I  figured out a patch, could you please check with it?
>>>>
>>>> [PATCH] resize.f2fs: fix wrong sit/nat bitmap during
>>>> rebuild_checkpoint()
>>>>
>>>> On 2021/3/29 9:51, Chao Yu wrote:
>>>>> Hello,
>>>>>
>>>>> Sorry for the delay reply.
>>>>>
>>>>> I can reproduce this bug now, but I haven't enough time for debuging,
>>>>> will
>>>>> check this soon.
>>>>>
>>>>> On 2021/3/27 21:26, beroal wrote:
>>>>>> Ping.
>>>>>>
>>>>>> On 19.03.21 23:24, beroal wrote:
>>>>>>> Hi. I am trying to use a new function to reduce the size of an F2FS
>>>>>>> file system. After resizing, `fsck.f2fs` gives a lot of errors. Here
>>>>>>> is a shell script that creates and resizes a dummy file system:
>>>>>>>
>>>>>>> ```
>>>>>>> #!/bin/sh
>>>>>>> set -e
>>>>>>> F=/tmp/img
>>>>>>> D=/dev/loop0
>>>>>>> M=/root/mnt/temp
>>>>>>> dd bs=1M count=256 if=/dev/zero "of=$F"
>>>>>>> losetup "$D" "$F"
>>>>>>> mkfs.f2fs "$D"
>>>>>>> fsck.f2fs "$D"
>>>>>>> mount "$D" "$M"
>>>>>>> dd bs=1M count=64
>>>>>>> if=/mnt/data/external/misc/movie/Idiocracy.2006.WEB-DL.1080p-ylnian.mkv
>>>>>>>
>>>>>>>
>>>>>>> of="${M}/a.mkv"
>>>>>>> umount "$M"
>>>>>>> resize.f2fs -s -t 262144 "$D"
>>>>>>> fsck.f2fs "$D"
>>>>>>> losetup -d "$D"
>>>>>>> ```
>>>>>>>
>>>>>>> ```
>>>>>>> + set -e
>>>>>>> + F=/tmp/img
>>>>>>> + D=/dev/loop0
>>>>>>> + M=/root/mnt/temp
>>>>>>> + dd bs=1M count=256 if=/dev/zero of=/tmp/img
>>>>>>> 256+0 records in
>>>>>>> 256+0 records out
>>>>>>> 268435456 bytes (268 MB, 256 MiB) copied, 0.0867954 s, 3.1 GB/s
>>>>>>> + losetup /dev/loop0 /tmp/img
>>>>>>> + mkfs.f2fs /dev/loop0
>>>>>>>
>>>>>>>         F2FS-tools: mkfs.f2fs Ver: 1.14.0 (2020-08-24)
>>>>>>>
>>>>>>> Info: Disable heap-based policy
>>>>>>> Info: Debug level = 0
>>>>>>> Info: Trim is enabled
>>>>>>> Info: Segments per section = 1
>>>>>>> Info: Sections per zone = 1
>>>>>>> Info: sector size = 512
>>>>>>> Info: total sectors = 524288 (256 MB)
>>>>>>> Info: zone aligned segment0 blkaddr: 512
>>>>>>> Info: format version with
>>>>>>>       "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc(GCC)
>>>>>>> 10.2.0,
>>>>>>> GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021
>>>>>>> 16:59:58
>>>>>>> +0000"
>>>>>>> Info: [/dev/loop0] Discarding device
>>>>>>> Info: This device doesn't support BLKSECDISCARD
>>>>>>> Info: Discarded 256 MB
>>>>>>> Info: Overprovision ratio = 15.000%
>>>>>>> Info: Overprovision segments = 35 (GC reserved = 21)
>>>>>>> Info: format successful
>>>>>>> + fsck.f2fs /dev/loop0
>>>>>>> Info: Segments per section = 1
>>>>>>> Info: Sections per zone = 1
>>>>>>> Info: sector size = 512
>>>>>>> Info: total sectors = 524288 (256 MB)
>>>>>>> Info: MKFS version
>>>>>>>       "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc(GCC)
>>>>>>> 10.2.0,
>>>>>>> GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021
>>>>>>> 16:59:58
>>>>>>> +0000"
>>>>>>> Info: FSCK version
>>>>>>>       from "Linux version 5.11.7-arch1-1 (linux@archlinux)(gcc (GCC)
>>>>>>> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar
>>>>>>> 2021
>>>>>>> 16:59:58 +0000"
>>>>>>>         to "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC)
>>>>>>> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar
>>>>>>> 2021
>>>>>>> 16:59:58 +0000"
>>>>>>> Info: superblock features = 0 :
>>>>>>> Info: superblock encrypt level = 0, salt =
>>>>>>> 00000000000000000000000000000000
>>>>>>> Info: total FS sectors = 524288 (256 MB)
>>>>>>> Info: CKPT version = 8aa0d85
>>>>>>> Info: Checked valid nat_bits in checkpoint
>>>>>>> Info: checkpoint state = 185 :  trimmed nat_bits compacted_summary
>>>>>>> unmount
>>>>>>>
>>>>>>> [FSCK] Unreachable nat entries [Ok..] [0x0]
>>>>>>> [FSCK] SIT valid block bitmap checking [Ok..]
>>>>>>> [FSCK] Hard link checking for regular file [Ok..] [0x0]
>>>>>>> [FSCK] valid_block_count matching with CP [Ok..] [0x2]
>>>>>>> [FSCK] valid_node_count matching with CP (de lookup) [Ok..] [0x1]
>>>>>>> [FSCK] valid_node_count matching with CP (nat lookup) [Ok..] [0x1]
>>>>>>> [FSCK] valid_inode_count matched with CP [Ok..] [0x1]
>>>>>>> [FSCK] free segment_count matched with CP [Ok..] [0x72]
>>>>>>> [FSCK] next block offset is free [Ok..]
>>>>>>> [FSCK] fixing SIT types
>>>>>>> [FSCK] other corrupted bugs [Ok..]
>>>>>>>
>>>>>>> Done: 0.068899 secs
>>>>>>> + mount /dev/loop0 /root/mnt/temp
>>>>>>> + dd bs=1M count=64
>>>>>>> if=/mnt/data/external/misc/movie/Idiocracy.2006.WEB-DL.1080p-ylnian.mkv
>>>>>>>
>>>>>>>
>>>>>>> of=/root/mnt/temp/a.mkv
>>>>>>> 64+0 records in
>>>>>>> 64+0 records out
>>>>>>> 67108864 bytes (67 MB, 64 MiB) copied, 0.0286261 s, 2.3 GB/s
>>>>>>> + umount /root/mnt/temp
>>>>>>> + resize.f2fs -s -t 262144 /dev/loop0
>>>>>>> Info: Segments per section = 1
>>>>>>> Info: Sections per zone = 1
>>>>>>> Info: sector size = 512
>>>>>>> Info: total sectors = 524288 (256 MB)
>>>>>>> Info: MKFS version
>>>>>>>       "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc(GCC)
>>>>>>> 10.2.0,
>>>>>>> GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021
>>>>>>> 16:59:58
>>>>>>> +0000"
>>>>>>> Info: FSCK version
>>>>>>>       from "Linux version 5.11.7-arch1-1 (linux@archlinux)(gcc (GCC)
>>>>>>> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar
>>>>>>> 2021
>>>>>>> 16:59:58 +0000"
>>>>>>>         to "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC)
>>>>>>> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar
>>>>>>> 2021
>>>>>>> 16:59:58 +0000"
>>>>>>> Info: superblock features = 0 :
>>>>>>> Info: superblock encrypt level = 0, salt =
>>>>>>> 00000000000000000000000000000000
>>>>>>> Info: total FS sectors = 524288 (256 MB)
>>>>>>> Info: CKPT version = 8aa0d89
>>>>>>> Info: Duplicate valid checkpoint to mirror position 512 -> 1024
>>>>>>> Info: Write valid nat_bits in checkpoint
>>>>>>> [FIX] (move_one_curseg_info:2798)  --> Move curseg[0] 3 -> 37 after
>>>>>>> 8000
>>>>>>>
>>>>>>> [FIX] (move_one_curseg_info:2798)  --> Move curseg[1] 3b -> 36
>>>>>>> after 8000
>>>>>>>
>>>>>>> [FIX] (move_one_curseg_info:2798)  --> Move curseg[2] 24 -> 35
>>>>>>> after 8000
>>>>>>>
>>>>>>> [FIX] (move_one_curseg_info:2798)  --> Move curseg[3] 0 -> 34 after
>>>>>>> 8000
>>>>>>>
>>>>>>> [FIX] (move_one_curseg_info:2798)  --> Move curseg[4] 1 -> 33 after
>>>>>>> 8000
>>>>>>>
>>>>>>> [FIX] (move_one_curseg_info:2798)  --> Move curseg[5] 2 -> 32 after
>>>>>>> 8000
>>>>>>>
>>>>>>> Info: Write valid nat_bits in checkpoint
>>>>>>> Try to do defragement: Done
>>>>>>> [update_superblock: 695] Info: Done to update superblock
>>>>>>> Info: Write valid nat_bits in checkpoint
>>>>>>> [rebuild_checkpoint: 585] Info: Done to rebuild checkpoint blocks
>>>>>>>
>>>>>>> Done: 0.065604 secs
>>>>>>> + fsck.f2fs /dev/loop0
>>>>>>> Info: Segments per section = 1
>>>>>>> Info: Sections per zone = 1
>>>>>>> Info: sector size = 512
>>>>>>> Info: total sectors = 524288 (256 MB)
>>>>>>> Info: MKFS version
>>>>>>>       "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc(GCC)
>>>>>>> 10.2.0,
>>>>>>> GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar 2021
>>>>>>> 16:59:58
>>>>>>> +0000"
>>>>>>> Info: FSCK version
>>>>>>>       from "Linux version 5.11.7-arch1-1 (linux@archlinux)(gcc (GCC)
>>>>>>> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar
>>>>>>> 2021
>>>>>>> 16:59:58 +0000"
>>>>>>>         to "Linux version 5.11.7-arch1-1 (linux@archlinux) (gcc (GCC)
>>>>>>> 10.2.0, GNU ld (GNU Binutils) 2.36.1) #1 SMP PREEMPT Wed, 17 Mar
>>>>>>> 2021
>>>>>>> 16:59:58 +0000"
>>>>>>> Info: superblock features = 0 :
>>>>>>> Info: superblock encrypt level = 0, salt =
>>>>>>> 00000000000000000000000000000000
>>>>>>> Info: total FS sectors = 262144 (128 MB)
>>>>>>>         Invalid CP CRC offset: 0
>>>>>>> Info: CKPT version = 8aa0d8a
>>>>>>> Info: Checked valid nat_bits in checkpoint
>>>>>>> Info: checkpoint state = 181 :  trimmed nat_bits unmount
>>>>>>> [ASSERT] (fsck_chk_curseg_info:2958)  --> Incorrect curseg [1]:
>>>>>>> segno
>>>>>>> [0x36] type(SIT) [0]
>>>>>>> [ASSERT] (fsck_chk_curseg_info:2958)  --> Incorrect curseg [2]:
>>>>>>> segno
>>>>>>> [0x35] type(SIT) [0]
>>>>>>> [ASSERT] (fsck_chk_curseg_info:2958)  --> Incorrect curseg [3]:
>>>>>>> segno
>>>>>>> [0x34] type(SIT) [0]
>>>>>>> [ASSERT] (fsck_chk_curseg_info:2958)  --> Incorrect curseg [4]:
>>>>>>> segno
>>>>>>> [0x33] type(SIT) [0]
>>>>>>> [ASSERT] (fsck_chk_curseg_info:2958)  --> Incorrect curseg [5]:
>>>>>>> segno
>>>>>>> [0x32] type(SIT) [0]
>>>>>>> [ASSERT] (sanity_check_nid: 480)  --> SIT bitmap is 0x0.
>>>>>>> blk_addr[0x1002]
>>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>>> blk_addr[0x1601]
>>>>>>> [ASSERT] (sanity_check_nid: 480)  --> SIT bitmap is 0x0.
>>>>>>> blk_addr[0x1211]
>>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>>> blk_addr[0x4a00]
>>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>>> blk_addr[0x4a01]
>>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>>> blk_addr[0x4a02]
>>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>>> blk_addr[0x4a03]
>>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>>> blk_addr[0x4a04]
>>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>>> blk_addr[0x4a05]
>>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>>> blk_addr[0x4a06]
>>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>>> blk_addr[0x4a07]
>>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>>> blk_addr[0x4a08]
>>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>>> blk_addr[0x4a09]
>>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>>> blk_addr[0x4a0a]
>>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>>> blk_addr[0x4a0b]
>>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>>> blk_addr[0x4a0c]
>>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>>> blk_addr[0x4a0d]
>>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>>> blk_addr[0x4a0e]
>>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>>> blk_addr[0x4a0f]
>>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>>> blk_addr[0x4a10]
>>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>>> blk_addr[0x4a11]
>>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>>> blk_addr[0x4a12]
>>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>>> blk_addr[0x4a13]
>>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>>> blk_addr[0x4a14]
>>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>>> blk_addr[0x4a15]
>>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>>> blk_addr[0x4a16]
>>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>>> blk_addr[0x4a17]
>>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>>> blk_addr[0x4a18]
>>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>>> blk_addr[0x4a19]
>>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>>> blk_addr[0x4a1a]
>>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>>> blk_addr[0x4a1b]
>>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>>> blk_addr[0x4a1c]
>>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>>> blk_addr[0x4a1d]
>>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>>> blk_addr[0x4a1e]
>>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>>> blk_addr[0x4a1f]
>>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>>> blk_addr[0x4a20]
>>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>>> blk_addr[0x4a21]
>>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>>> blk_addr[0x4a22]
>>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>>> blk_addr[0x4a23]
>>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>>> blk_addr[0x4a24]
>>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>>> blk_addr[0x4a25]
>>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>>> blk_addr[0x4a26]
>>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>>> blk_addr[0x4a27]
>>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>>> blk_addr[0x4a28]
>>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>>> blk_addr[0x4a29]
>>>>>>> [ASSERT] (fsck_chk_data_blk:1716)  --> SIT bitmap is 0x0.
>>>>>>> blk_addr[0x4a2a]
>>>>>>> {{{skipped}}}
>>>>>>> ```
>>>>>>>
>>>>>>> The whole output is huge.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> Linux-f2fs-devel mailing list
>>>>>>> Linux-f2fs-devel@lists.sourceforge.net
>>>>>>> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> Linux-f2fs-devel mailing list
>>>>>> Linux-f2fs-devel@lists.sourceforge.net
>>>>>> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
>>>>>>
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Linux-f2fs-devel mailing list
>>>>> Linux-f2fs-devel@lists.sourceforge.net
>>>>> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
>>>>>
>>>>
>>> .
>>>
>>
> .
> 


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

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

end of thread, other threads:[~2021-04-13  1:25 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-19 21:24 [f2fs-dev] f2fs.resize makes errors in FS beroal
2021-03-27 13:26 ` beroal
2021-03-29  1:51   ` Chao Yu
2021-04-02  7:23     ` Chao Yu
2021-04-02  9:28       ` beroal
2021-04-02 10:30         ` Chao Yu
2021-04-06  1:44         ` Chao Yu
2021-04-12 15:40           ` beroal
2021-04-13  1:25             ` Chao Yu

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.