All of lore.kernel.org
 help / color / mirror / Atom feed
* fsck.f2fs segmentation fault
@ 2019-01-05 17:04 Aravind R S
  2019-01-07  2:40 ` Chao Yu
  0 siblings, 1 reply; 11+ messages in thread
From: Aravind R S @ 2019-01-05 17:04 UTC (permalink / raw)
  To: linux-f2fs-devel

I use Arch Linux and the versions of the kernel and f2fs-tools
provided by that distro. I have an F2FS filesystem that seems to have
become corrupt and cannot be mounted, and running fsck.f2fs on it
results in a segmentation fault:

# fsck.f2fs /dev/sda2
Info: [/dev/sda2] Disk Model: Samsung SSD 840
Info: Segments per section = 1
Info: Sections per zone = 1
Info: sector size = 512
Info: total sectors = 234041344 (114278 MB)
Info: MKFS version
  ""
Info: FSCK version
  from "Linux version 4.19.1-arch1-1-ARCH (builduser@heftig-16768)
(gcc version 8.2.1 20180831 (GCC)) #1 SMP PREEMPT Sun Nov 4 16:49:26
UTC 2018"
    to "Linux version 4.20.0-arch1-1-ARCH (builduser@heftig-29859)
(gcc version 8.2.1 20181127 (GCC)) #1 SMP PREEMPT Mon Dec 24 03:00:40
UTC 2018"
[update_superblock: 513] Info: Done to update superblock
Info: superblock features = 0 :
Info: superblock encrypt level = 0, salt = 00000000000000000000000000000000
Info: total FS sectors = 234041344 (114278 MB)
Info: CKPT version = fb3d6
[1]    2643 segmentation fault  sudo fsck.f2fs /dev/sda2

---

# mount /dev/sda2 /mnt                                    :(
mount: /mnt: wrong fs type, bad option, bad superblock on /dev/sda2,
missing codepage or helper program, or other error.

---

Please let me know how I can help debug further.

Aravind

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

* Re: fsck.f2fs segmentation fault
  2019-01-05 17:04 fsck.f2fs segmentation fault Aravind R S
@ 2019-01-07  2:40 ` Chao Yu
  2019-01-07  4:20   ` Aravind R S
  0 siblings, 1 reply; 11+ messages in thread
From: Chao Yu @ 2019-01-07  2:40 UTC (permalink / raw)
  To: Aravind R S, linux-f2fs-devel

Hi Aravind,

On 2019/1/6 1:04, Aravind R S wrote:
> I use Arch Linux and the versions of the kernel and f2fs-tools
> provided by that distro. I have an F2FS filesystem that seems to have
> become corrupt and cannot be mounted, and running fsck.f2fs on it
> results in a segmentation fault:
> 
> # fsck.f2fs /dev/sda2
> Info: [/dev/sda2] Disk Model: Samsung SSD 840
> Info: Segments per section = 1
> Info: Sections per zone = 1
> Info: sector size = 512
> Info: total sectors = 234041344 (114278 MB)
> Info: MKFS version
>   ""
> Info: FSCK version
>   from "Linux version 4.19.1-arch1-1-ARCH (builduser@heftig-16768)
> (gcc version 8.2.1 20180831 (GCC)) #1 SMP PREEMPT Sun Nov 4 16:49:26
> UTC 2018"
>     to "Linux version 4.20.0-arch1-1-ARCH (builduser@heftig-29859)
> (gcc version 8.2.1 20181127 (GCC)) #1 SMP PREEMPT Mon Dec 24 03:00:40
> UTC 2018"
> [update_superblock: 513] Info: Done to update superblock
> Info: superblock features = 0 :
> Info: superblock encrypt level = 0, salt = 00000000000000000000000000000000
> Info: total FS sectors = 234041344 (114278 MB)
> Info: CKPT version = fb3d6
> [1]    2643 segmentation fault  sudo fsck.f2fs /dev/sda2

Could you give the detail position where triggers segment fault? gdb may help?

> 
> ---
> 
> # mount /dev/sda2 /mnt                                    :(
> mount: /mnt: wrong fs type, bad option, bad superblock on /dev/sda2,
> missing codepage or helper program, or other error.

Oh, I guess superblock may be broken, could you please dump sb/cp info via:

dump.f2fs -d 1 image_path

> 
> ---
> 
> Please let me know how I can help debug further.
> 
> Aravind
> 
> 
> _______________________________________________
> 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] 11+ messages in thread

* Re: fsck.f2fs segmentation fault
  2019-01-07  2:40 ` Chao Yu
@ 2019-01-07  4:20   ` Aravind R S
  2019-01-07  4:52     ` Aravind R S
  2019-01-08  2:27     ` Chao Yu
  0 siblings, 2 replies; 11+ messages in thread
From: Aravind R S @ 2019-01-07  4:20 UTC (permalink / raw)
  To: Chao Yu; +Cc: linux-f2fs-devel

Thanks! Here's the output of dump.f2fs:

# dump.f2fs -d 1 /dev/sda2                                              :(
Info: Debug level = 1
Info: [/dev/sda2] Disk Model: Samsung SSD 840
Info: Segments per section = 1
Info: Sections per zone = 1
Info: sector size = 512
Info: total sectors = 234041344 (114278 MB)
Info: MKFS version
  ""
Info: FSCK version
  from "Linux version 4.20.0-arch1-1-ARCH (builduser@heftig-29859)
(gcc version 8.2.1 20181127 (GCC)) #1 SMP PREEMPT Mon Dec 24 03:00:40
UTC 2018"
    to "Linux version 4.20.0-arch1-1-ARCH (builduser@heftig-29859)
(gcc version 8.2.1 20181127 (GCC)) #1 SMP PREEMPT Mon Dec 24 03:00:40
UTC 2018"
Info: superblock features = 0 :
Info: superblock encrypt level = 0, salt = 00000000000000000000000000000000

+--------------------------------------------------------+
| Super block                                            |
+--------------------------------------------------------+
magic                                 [0xf2f52010 : 4076150800]
major_ver                             [0x       1 : 1]
volum_name                            [root]
minor_ver                             [0x       2 : 2]
log_sectorsize                        [0x       9 : 9]
log_sectors_per_block                 [0x       3 : 3]
log_blocksize                         [0x       c : 12]
log_blocks_per_seg                    [0x       9 : 9]
segs_per_sec                          [0x       1 : 1]
secs_per_zone                         [0x       1 : 1]
checksum_offset                       [0x       0 : 0]
block_count                           [0x 1be6600 : 29255168]
section_count                         [0x    de48 : 56904]
segment_count                         [0x    df32 : 57138]
segment_count_ckpt                    [0x       2 : 2]
segment_count_sit                     [0x       6 : 6]
segment_count_nat                     [0x      72 : 114]
segment_count_ssa                     [0x      70 : 112]
segment_count_main                    [0x    de48 : 56904]
segment0_blkaddr                      [0x     100 : 256]
cp_blkaddr                            [0x     100 : 256]
sit_blkaddr                           [0x     500 : 1280]
nat_blkaddr                           [0x    1100 : 4352]
ssa_blkaddr                           [0x    f500 : 62720]
main_blkaddr                          [0x   1d500 : 120064]
root_ino                              [0x       3 : 3]
node_ino                              [0x       1 : 1]
meta_ino                              [0x       2 : 2]
cp_payload                            [0x       0 : 0]
crc                                   [0x       0 : 0]
version                       Linux version 4.20.0-arch1-1-ARCH
(builduser@heftig-29859) (gcc version 8.2.1 20181127 (GCC)) #1 SMP
PREEMPT Mon Dec 24 03:00:40 UTC 2018
Info: total FS sectors = 234041344 (114278 MB)
Info: CKPT version = fb3d6

+--------------------------------------------------------+
| Checkpoint                                             |
+--------------------------------------------------------+
checkpoint_ver                        [0x   fb3d6 : 1029078]
user_block_count                      [0x 1a5fc00 : 27655168]
valid_block_count                     [0x 13777de : 20412382]
rsvd_segment_count                    [0x      30 : 48]
overprov_segment_count                [0x     b4a : 2890]
free_segment_count                    [0x    2ce2 : 11490]
alloc_type[CURSEG_HOT_NODE]           [0x       0 : 0]
alloc_type[CURSEG_WARM_NODE]          [0x       0 : 0]
alloc_type[CURSEG_COLD_NODE]          [0x       0 : 0]
cur_node_segno[0]                     [0x    173b : 5947]
cur_node_segno[1]                     [0x    16d0 : 5840]
cur_node_segno[2]                     [0x     536 : 1334]
cur_node_blkoff[0]                    [0x     171 : 369]
cur_node_blkoff[1]                    [0x      e5 : 229]
cur_node_blkoff[2]                    [0x     146 : 326]
alloc_type[CURSEG_HOT_DATA]           [0x       0 : 0]
alloc_type[CURSEG_WARM_DATA]          [0x       0 : 0]
alloc_type[CURSEG_COLD_DATA]          [0x       0 : 0]
cur_data_segno[0]                     [0x    1741 : 5953]
cur_data_segno[1]                     [0x    8747 : 34631]
cur_data_segno[2]                     [0x    6440 : 25664]
cur_data_blkoff[0]                    [0x     1f7 : 503]
cur_data_blkoff[1]                    [0x     121 : 289]
cur_data_blkoff[2]                    [0x     15a : 346]
ckpt_flags                            [0x      42 : 66]
cp_pack_total_block_count             [0x       6 : 6]
cp_pack_start_sum                     [0x       2 : 2]
valid_node_count                      [0x  1bbdb5 : 1818037]
valid_inode_count                     [0x  1b819a : 1802650]
next_free_nid                         [0x  20f518 : 2159896]
sit_ver_bitmap_bytesize               [0x      c0 : 192]
nat_ver_bitmap_bytesize               [0x     e40 : 3648]
checksum_offset                       [0x     ffc : 4092]
elapsed_time                          [0x 70188bc : 117541052]
sit_nat_version_bitmap[0]             [0x      c5 : 197]


Info: checkpoint state = 42 :  crc orphan_inodes sudden-power-off

Done.

-----

And here's gdb output:

(gdb) r /dev/sda2
Starting program: /usr/bin/fsck.f2fs /dev/sda2
Info: [/dev/sda2] Disk Model: Samsung SSD 840
Info: Segments per section = 1
Info: Sections per zone = 1
Info: sector size = 512
Info: total sectors = 234041344 (114278 MB)
Info: MKFS version
  ""
Info: FSCK version
  from "Linux version 4.20.0-arch1-1-ARCH (builduser@heftig-29859)
(gcc version 8.2.1 20181127 (GCC)) #1 SMP PREEMPT Mon Dec 24 03:00:40
UTC 2018"
    to "Linux version 4.20.0-arch1-1-ARCH (builduser@heftig-29859)
(gcc version 8.2.1 20181127 (GCC)) #1 SMP PREEMPT Mon Dec 24 03:00:40
UTC 2018"
Info: superblock features = 0 :
Info: superblock encrypt level = 0, salt = 00000000000000000000000000000000
Info: total FS sectors = 234041344 (114278 MB)
Info: CKPT version = fb3d6

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7f97894 in f2fs_set_bit () from /usr/lib/libf2fs.so.6


Should I provide some additional arguments to get more information out of gdb?

Aravind

On Mon, Jan 7, 2019 at 10:41 AM Chao Yu <yuchao0@huawei.com> wrote:
>
> Hi Aravind,
>
> On 2019/1/6 1:04, Aravind R S wrote:
> > I use Arch Linux and the versions of the kernel and f2fs-tools
> > provided by that distro. I have an F2FS filesystem that seems to have
> > become corrupt and cannot be mounted, and running fsck.f2fs on it
> > results in a segmentation fault:
> >
> > # fsck.f2fs /dev/sda2
> > Info: [/dev/sda2] Disk Model: Samsung SSD 840
> > Info: Segments per section = 1
> > Info: Sections per zone = 1
> > Info: sector size = 512
> > Info: total sectors = 234041344 (114278 MB)
> > Info: MKFS version
> >   ""
> > Info: FSCK version
> >   from "Linux version 4.19.1-arch1-1-ARCH (builduser@heftig-16768)
> > (gcc version 8.2.1 20180831 (GCC)) #1 SMP PREEMPT Sun Nov 4 16:49:26
> > UTC 2018"
> >     to "Linux version 4.20.0-arch1-1-ARCH (builduser@heftig-29859)
> > (gcc version 8.2.1 20181127 (GCC)) #1 SMP PREEMPT Mon Dec 24 03:00:40
> > UTC 2018"
> > [update_superblock: 513] Info: Done to update superblock
> > Info: superblock features = 0 :
> > Info: superblock encrypt level = 0, salt = 00000000000000000000000000000000
> > Info: total FS sectors = 234041344 (114278 MB)
> > Info: CKPT version = fb3d6
> > [1]    2643 segmentation fault  sudo fsck.f2fs /dev/sda2
>
> Could you give the detail position where triggers segment fault? gdb may help?
>
> >
> > ---
> >
> > # mount /dev/sda2 /mnt                                    :(
> > mount: /mnt: wrong fs type, bad option, bad superblock on /dev/sda2,
> > missing codepage or helper program, or other error.
>
> Oh, I guess superblock may be broken, could you please dump sb/cp info via:
>
> dump.f2fs -d 1 image_path
>
> >
> > ---
> >
> > Please let me know how I can help debug further.
> >
> > Aravind
> >
> >
> > _______________________________________________
> > 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] 11+ messages in thread

* Re: fsck.f2fs segmentation fault
  2019-01-07  4:20   ` Aravind R S
@ 2019-01-07  4:52     ` Aravind R S
  2019-01-08  2:48       ` Chao Yu
  2019-01-08  2:27     ` Chao Yu
  1 sibling, 1 reply; 11+ messages in thread
From: Aravind R S @ 2019-01-07  4:52 UTC (permalink / raw)
  To: Chao Yu; +Cc: linux-f2fs-devel

Here's the backtrace where it segfaults. I don't have it compiled with
the debug symbols, but if you can point me to some instructions I'm
happy to try that.

(gdb) backtrace
#0  0x00007ffff7f97894 in f2fs_set_bit () from /usr/lib/libf2fs.so.6
#1  0x0000555555565206 in ?? ()
#2  0x0000555555568214 in ?? ()
#3  0x00005555555560be in ?? ()
#4  0x00007ffff7df5223 in __libc_start_main () from /usr/lib/libc.so.6
#5  0x000055555555695e in ?? ()


Aravind

On Mon, Jan 7, 2019 at 12:20 PM Aravind R S <aravindet@gmail.com> wrote:
>
> Thanks! Here's the output of dump.f2fs:
>
> # dump.f2fs -d 1 /dev/sda2                                              :(
> Info: Debug level = 1
> Info: [/dev/sda2] Disk Model: Samsung SSD 840
> Info: Segments per section = 1
> Info: Sections per zone = 1
> Info: sector size = 512
> Info: total sectors = 234041344 (114278 MB)
> Info: MKFS version
>   ""
> Info: FSCK version
>   from "Linux version 4.20.0-arch1-1-ARCH (builduser@heftig-29859)
> (gcc version 8.2.1 20181127 (GCC)) #1 SMP PREEMPT Mon Dec 24 03:00:40
> UTC 2018"
>     to "Linux version 4.20.0-arch1-1-ARCH (builduser@heftig-29859)
> (gcc version 8.2.1 20181127 (GCC)) #1 SMP PREEMPT Mon Dec 24 03:00:40
> UTC 2018"
> Info: superblock features = 0 :
> Info: superblock encrypt level = 0, salt = 00000000000000000000000000000000
>
> +--------------------------------------------------------+
> | Super block                                            |
> +--------------------------------------------------------+
> magic                                 [0xf2f52010 : 4076150800]
> major_ver                             [0x       1 : 1]
> volum_name                            [root]
> minor_ver                             [0x       2 : 2]
> log_sectorsize                        [0x       9 : 9]
> log_sectors_per_block                 [0x       3 : 3]
> log_blocksize                         [0x       c : 12]
> log_blocks_per_seg                    [0x       9 : 9]
> segs_per_sec                          [0x       1 : 1]
> secs_per_zone                         [0x       1 : 1]
> checksum_offset                       [0x       0 : 0]
> block_count                           [0x 1be6600 : 29255168]
> section_count                         [0x    de48 : 56904]
> segment_count                         [0x    df32 : 57138]
> segment_count_ckpt                    [0x       2 : 2]
> segment_count_sit                     [0x       6 : 6]
> segment_count_nat                     [0x      72 : 114]
> segment_count_ssa                     [0x      70 : 112]
> segment_count_main                    [0x    de48 : 56904]
> segment0_blkaddr                      [0x     100 : 256]
> cp_blkaddr                            [0x     100 : 256]
> sit_blkaddr                           [0x     500 : 1280]
> nat_blkaddr                           [0x    1100 : 4352]
> ssa_blkaddr                           [0x    f500 : 62720]
> main_blkaddr                          [0x   1d500 : 120064]
> root_ino                              [0x       3 : 3]
> node_ino                              [0x       1 : 1]
> meta_ino                              [0x       2 : 2]
> cp_payload                            [0x       0 : 0]
> crc                                   [0x       0 : 0]
> version                       Linux version 4.20.0-arch1-1-ARCH
> (builduser@heftig-29859) (gcc version 8.2.1 20181127 (GCC)) #1 SMP
> PREEMPT Mon Dec 24 03:00:40 UTC 2018
> Info: total FS sectors = 234041344 (114278 MB)
> Info: CKPT version = fb3d6
>
> +--------------------------------------------------------+
> | Checkpoint                                             |
> +--------------------------------------------------------+
> checkpoint_ver                        [0x   fb3d6 : 1029078]
> user_block_count                      [0x 1a5fc00 : 27655168]
> valid_block_count                     [0x 13777de : 20412382]
> rsvd_segment_count                    [0x      30 : 48]
> overprov_segment_count                [0x     b4a : 2890]
> free_segment_count                    [0x    2ce2 : 11490]
> alloc_type[CURSEG_HOT_NODE]           [0x       0 : 0]
> alloc_type[CURSEG_WARM_NODE]          [0x       0 : 0]
> alloc_type[CURSEG_COLD_NODE]          [0x       0 : 0]
> cur_node_segno[0]                     [0x    173b : 5947]
> cur_node_segno[1]                     [0x    16d0 : 5840]
> cur_node_segno[2]                     [0x     536 : 1334]
> cur_node_blkoff[0]                    [0x     171 : 369]
> cur_node_blkoff[1]                    [0x      e5 : 229]
> cur_node_blkoff[2]                    [0x     146 : 326]
> alloc_type[CURSEG_HOT_DATA]           [0x       0 : 0]
> alloc_type[CURSEG_WARM_DATA]          [0x       0 : 0]
> alloc_type[CURSEG_COLD_DATA]          [0x       0 : 0]
> cur_data_segno[0]                     [0x    1741 : 5953]
> cur_data_segno[1]                     [0x    8747 : 34631]
> cur_data_segno[2]                     [0x    6440 : 25664]
> cur_data_blkoff[0]                    [0x     1f7 : 503]
> cur_data_blkoff[1]                    [0x     121 : 289]
> cur_data_blkoff[2]                    [0x     15a : 346]
> ckpt_flags                            [0x      42 : 66]
> cp_pack_total_block_count             [0x       6 : 6]
> cp_pack_start_sum                     [0x       2 : 2]
> valid_node_count                      [0x  1bbdb5 : 1818037]
> valid_inode_count                     [0x  1b819a : 1802650]
> next_free_nid                         [0x  20f518 : 2159896]
> sit_ver_bitmap_bytesize               [0x      c0 : 192]
> nat_ver_bitmap_bytesize               [0x     e40 : 3648]
> checksum_offset                       [0x     ffc : 4092]
> elapsed_time                          [0x 70188bc : 117541052]
> sit_nat_version_bitmap[0]             [0x      c5 : 197]
>
>
> Info: checkpoint state = 42 :  crc orphan_inodes sudden-power-off
>
> Done.
>
> -----
>
> And here's gdb output:
>
> (gdb) r /dev/sda2
> Starting program: /usr/bin/fsck.f2fs /dev/sda2
> Info: [/dev/sda2] Disk Model: Samsung SSD 840
> Info: Segments per section = 1
> Info: Sections per zone = 1
> Info: sector size = 512
> Info: total sectors = 234041344 (114278 MB)
> Info: MKFS version
>   ""
> Info: FSCK version
>   from "Linux version 4.20.0-arch1-1-ARCH (builduser@heftig-29859)
> (gcc version 8.2.1 20181127 (GCC)) #1 SMP PREEMPT Mon Dec 24 03:00:40
> UTC 2018"
>     to "Linux version 4.20.0-arch1-1-ARCH (builduser@heftig-29859)
> (gcc version 8.2.1 20181127 (GCC)) #1 SMP PREEMPT Mon Dec 24 03:00:40
> UTC 2018"
> Info: superblock features = 0 :
> Info: superblock encrypt level = 0, salt = 00000000000000000000000000000000
> Info: total FS sectors = 234041344 (114278 MB)
> Info: CKPT version = fb3d6
>
> Program received signal SIGSEGV, Segmentation fault.
> 0x00007ffff7f97894 in f2fs_set_bit () from /usr/lib/libf2fs.so.6
>
>
> Should I provide some additional arguments to get more information out of gdb?
>
> Aravind
>
> On Mon, Jan 7, 2019 at 10:41 AM Chao Yu <yuchao0@huawei.com> wrote:
> >
> > Hi Aravind,
> >
> > On 2019/1/6 1:04, Aravind R S wrote:
> > > I use Arch Linux and the versions of the kernel and f2fs-tools
> > > provided by that distro. I have an F2FS filesystem that seems to have
> > > become corrupt and cannot be mounted, and running fsck.f2fs on it
> > > results in a segmentation fault:
> > >
> > > # fsck.f2fs /dev/sda2
> > > Info: [/dev/sda2] Disk Model: Samsung SSD 840
> > > Info: Segments per section = 1
> > > Info: Sections per zone = 1
> > > Info: sector size = 512
> > > Info: total sectors = 234041344 (114278 MB)
> > > Info: MKFS version
> > >   ""
> > > Info: FSCK version
> > >   from "Linux version 4.19.1-arch1-1-ARCH (builduser@heftig-16768)
> > > (gcc version 8.2.1 20180831 (GCC)) #1 SMP PREEMPT Sun Nov 4 16:49:26
> > > UTC 2018"
> > >     to "Linux version 4.20.0-arch1-1-ARCH (builduser@heftig-29859)
> > > (gcc version 8.2.1 20181127 (GCC)) #1 SMP PREEMPT Mon Dec 24 03:00:40
> > > UTC 2018"
> > > [update_superblock: 513] Info: Done to update superblock
> > > Info: superblock features = 0 :
> > > Info: superblock encrypt level = 0, salt = 00000000000000000000000000000000
> > > Info: total FS sectors = 234041344 (114278 MB)
> > > Info: CKPT version = fb3d6
> > > [1]    2643 segmentation fault  sudo fsck.f2fs /dev/sda2
> >
> > Could you give the detail position where triggers segment fault? gdb may help?
> >
> > >
> > > ---
> > >
> > > # mount /dev/sda2 /mnt                                    :(
> > > mount: /mnt: wrong fs type, bad option, bad superblock on /dev/sda2,
> > > missing codepage or helper program, or other error.
> >
> > Oh, I guess superblock may be broken, could you please dump sb/cp info via:
> >
> > dump.f2fs -d 1 image_path
> >
> > >
> > > ---
> > >
> > > Please let me know how I can help debug further.
> > >
> > > Aravind
> > >
> > >
> > > _______________________________________________
> > > 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] 11+ messages in thread

* Re: fsck.f2fs segmentation fault
  2019-01-07  4:20   ` Aravind R S
  2019-01-07  4:52     ` Aravind R S
@ 2019-01-08  2:27     ` Chao Yu
  1 sibling, 0 replies; 11+ messages in thread
From: Chao Yu @ 2019-01-08  2:27 UTC (permalink / raw)
  To: Aravind R S; +Cc: linux-f2fs-devel

On 2019/1/7 12:20, Aravind R S wrote:
> Thanks! Here's the output of dump.f2fs:
> 
> # dump.f2fs -d 1 /dev/sda2                                              :(
> Info: Debug level = 1
> Info: [/dev/sda2] Disk Model: Samsung SSD 840
> Info: Segments per section = 1
> Info: Sections per zone = 1
> Info: sector size = 512
> Info: total sectors = 234041344 (114278 MB)
> Info: MKFS version
>   ""
> Info: FSCK version
>   from "Linux version 4.20.0-arch1-1-ARCH (builduser@heftig-29859)
> (gcc version 8.2.1 20181127 (GCC)) #1 SMP PREEMPT Mon Dec 24 03:00:40
> UTC 2018"
>     to "Linux version 4.20.0-arch1-1-ARCH (builduser@heftig-29859)
> (gcc version 8.2.1 20181127 (GCC)) #1 SMP PREEMPT Mon Dec 24 03:00:40
> UTC 2018"
> Info: superblock features = 0 :
> Info: superblock encrypt level = 0, salt = 00000000000000000000000000000000
> 
> +--------------------------------------------------------+
> | Super block                                            |
> +--------------------------------------------------------+
> magic                                 [0xf2f52010 : 4076150800]
> major_ver                             [0x       1 : 1]
> volum_name                            [root]
> minor_ver                             [0x       2 : 2]
> log_sectorsize                        [0x       9 : 9]
> log_sectors_per_block                 [0x       3 : 3]
> log_blocksize                         [0x       c : 12]
> log_blocks_per_seg                    [0x       9 : 9]
> segs_per_sec                          [0x       1 : 1]
> secs_per_zone                         [0x       1 : 1]
> checksum_offset                       [0x       0 : 0]
> block_count                           [0x 1be6600 : 29255168]
> section_count                         [0x    de48 : 56904]
> segment_count                         [0x    df32 : 57138]
> segment_count_ckpt                    [0x       2 : 2]
> segment_count_sit                     [0x       6 : 6]
> segment_count_nat                     [0x      72 : 114]
> segment_count_ssa                     [0x      70 : 112]
> segment_count_main                    [0x    de48 : 56904]
> segment0_blkaddr                      [0x     100 : 256]
> cp_blkaddr                            [0x     100 : 256]
> sit_blkaddr                           [0x     500 : 1280]
> nat_blkaddr                           [0x    1100 : 4352]
> ssa_blkaddr                           [0x    f500 : 62720]
> main_blkaddr                          [0x   1d500 : 120064]
> root_ino                              [0x       3 : 3]
> node_ino                              [0x       1 : 1]
> meta_ino                              [0x       2 : 2]
> cp_payload                            [0x       0 : 0]
> crc                                   [0x       0 : 0]
> version                       Linux version 4.20.0-arch1-1-ARCH
> (builduser@heftig-29859) (gcc version 8.2.1 20181127 (GCC)) #1 SMP
> PREEMPT Mon Dec 24 03:00:40 UTC 2018
> Info: total FS sectors = 234041344 (114278 MB)
> Info: CKPT version = fb3d6
> 
> +--------------------------------------------------------+
> | Checkpoint                                             |
> +--------------------------------------------------------+
> checkpoint_ver                        [0x   fb3d6 : 1029078]
> user_block_count                      [0x 1a5fc00 : 27655168]
> valid_block_count                     [0x 13777de : 20412382]
> rsvd_segment_count                    [0x      30 : 48]
> overprov_segment_count                [0x     b4a : 2890]
> free_segment_count                    [0x    2ce2 : 11490]
> alloc_type[CURSEG_HOT_NODE]           [0x       0 : 0]
> alloc_type[CURSEG_WARM_NODE]          [0x       0 : 0]
> alloc_type[CURSEG_COLD_NODE]          [0x       0 : 0]
> cur_node_segno[0]                     [0x    173b : 5947]
> cur_node_segno[1]                     [0x    16d0 : 5840]
> cur_node_segno[2]                     [0x     536 : 1334]
> cur_node_blkoff[0]                    [0x     171 : 369]
> cur_node_blkoff[1]                    [0x      e5 : 229]
> cur_node_blkoff[2]                    [0x     146 : 326]
> alloc_type[CURSEG_HOT_DATA]           [0x       0 : 0]
> alloc_type[CURSEG_WARM_DATA]          [0x       0 : 0]
> alloc_type[CURSEG_COLD_DATA]          [0x       0 : 0]
> cur_data_segno[0]                     [0x    1741 : 5953]
> cur_data_segno[1]                     [0x    8747 : 34631]
> cur_data_segno[2]                     [0x    6440 : 25664]
> cur_data_blkoff[0]                    [0x     1f7 : 503]
> cur_data_blkoff[1]                    [0x     121 : 289]
> cur_data_blkoff[2]                    [0x     15a : 346]
> ckpt_flags                            [0x      42 : 66]
> cp_pack_total_block_count             [0x       6 : 6]
> cp_pack_start_sum                     [0x       2 : 2]
> valid_node_count                      [0x  1bbdb5 : 1818037]
> valid_inode_count                     [0x  1b819a : 1802650]
> next_free_nid                         [0x  20f518 : 2159896]
> sit_ver_bitmap_bytesize               [0x      c0 : 192]
> nat_ver_bitmap_bytesize               [0x     e40 : 3648]
> checksum_offset                       [0x     ffc : 4092]
> elapsed_time                          [0x 70188bc : 117541052]
> sit_nat_version_bitmap[0]             [0x      c5 : 197]
> 
> 
> Info: checkpoint state = 42 :  crc orphan_inodes sudden-power-off
> 
> Done.
> 
> -----
> 
> And here's gdb output:
> 
> (gdb) r /dev/sda2
> Starting program: /usr/bin/fsck.f2fs /dev/sda2
> Info: [/dev/sda2] Disk Model: Samsung SSD 840
> Info: Segments per section = 1
> Info: Sections per zone = 1
> Info: sector size = 512
> Info: total sectors = 234041344 (114278 MB)
> Info: MKFS version
>   ""
> Info: FSCK version
>   from "Linux version 4.20.0-arch1-1-ARCH (builduser@heftig-29859)
> (gcc version 8.2.1 20181127 (GCC)) #1 SMP PREEMPT Mon Dec 24 03:00:40
> UTC 2018"
>     to "Linux version 4.20.0-arch1-1-ARCH (builduser@heftig-29859)
> (gcc version 8.2.1 20181127 (GCC)) #1 SMP PREEMPT Mon Dec 24 03:00:40
> UTC 2018"
> Info: superblock features = 0 :
> Info: superblock encrypt level = 0, salt = 00000000000000000000000000000000
> Info: total FS sectors = 234041344 (114278 MB)
> Info: CKPT version = fb3d6
> 
> Program received signal SIGSEGV, Segmentation fault.
> 0x00007ffff7f97894 in f2fs_set_bit () from /usr/lib/libf2fs.so.6
> 
> 
> Should I provide some additional arguments to get more information out of gdb?
> 
> Aravind
> 
> On Mon, Jan 7, 2019 at 10:41 AM Chao Yu <yuchao0@huawei.com> wrote:
>>
>> Hi Aravind,
>>
>> On 2019/1/6 1:04, Aravind R S wrote:
>>> I use Arch Linux and the versions of the kernel and f2fs-tools
>>> provided by that distro. I have an F2FS filesystem that seems to have
>>> become corrupt and cannot be mounted, and running fsck.f2fs on it
>>> results in a segmentation fault:
>>>
>>> # fsck.f2fs /dev/sda2
>>> Info: [/dev/sda2] Disk Model: Samsung SSD 840
>>> Info: Segments per section = 1
>>> Info: Sections per zone = 1
>>> Info: sector size = 512
>>> Info: total sectors = 234041344 (114278 MB)
>>> Info: MKFS version
>>>   ""
>>> Info: FSCK version
>>>   from "Linux version 4.19.1-arch1-1-ARCH (builduser@heftig-16768)
>>> (gcc version 8.2.1 20180831 (GCC)) #1 SMP PREEMPT Sun Nov 4 16:49:26
>>> UTC 2018"
>>>     to "Linux version 4.20.0-arch1-1-ARCH (builduser@heftig-29859)
>>> (gcc version 8.2.1 20181127 (GCC)) #1 SMP PREEMPT Mon Dec 24 03:00:40
>>> UTC 2018"
>>> [update_superblock: 513] Info: Done to update superblock
>>> Info: superblock features = 0 :
>>> Info: superblock encrypt level = 0, salt = 00000000000000000000000000000000
>>> Info: total FS sectors = 234041344 (114278 MB)
>>> Info: CKPT version = fb3d6
>>> [1]    2643 segmentation fault  sudo fsck.f2fs /dev/sda2
>>
>> Could you give the detail position where triggers segment fault? gdb may help?
>>
>>>
>>> ---
>>>
>>> # mount /dev/sda2 /mnt                                    :(
>>> mount: /mnt: wrong fs type, bad option, bad superblock on /dev/sda2,
>>> missing codepage or helper program, or other error.

I didn't see any obvious corruption in sp/cp...

Any kernel message printed during mount?

>>
>> Oh, I guess superblock may be broken, could you please dump sb/cp info via:
>>
>> dump.f2fs -d 1 image_path
>>
>>>
>>> ---
>>>
>>> Please let me know how I can help debug further.
>>>
>>> Aravind
>>>
>>>
>>> _______________________________________________
>>> 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] 11+ messages in thread

* Re: fsck.f2fs segmentation fault
  2019-01-07  4:52     ` Aravind R S
@ 2019-01-08  2:48       ` Chao Yu
       [not found]         ` <CAHZgRdA+HCwCU-iTVK5EmUt2rcP0=F3Z+mOu+xa7SF6-os+ANg@mail.gmail.com>
  0 siblings, 1 reply; 11+ messages in thread
From: Chao Yu @ 2019-01-08  2:48 UTC (permalink / raw)
  To: Aravind R S; +Cc: linux-f2fs-devel

On 2019/1/7 12:52, Aravind R S wrote:
> Here's the backtrace where it segfaults. I don't have it compiled with
> the debug symbols, but if you can point me to some instructions I'm
> happy to try that.
> 
> (gdb) backtrace
> #0  0x00007ffff7f97894 in f2fs_set_bit () from /usr/lib/libf2fs.so.6
> #1  0x0000555555565206 in ?? ()
> #2  0x0000555555568214 in ?? ()
> #3  0x00005555555560be in ?? ()
> #4  0x00007ffff7df5223 in __libc_start_main () from /usr/lib/libc.so.6
> #5  0x000055555555695e in ?? ()

I can't track source code with above call stack..

How about downloading tools source code from below git repo address, and
compile the source code, run gdb with compiled binary.

https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs-tools.git/


BTW, could you run fsck again with parameter '-d 3'? and let's check the
printed debug info.

Thanks,

> 
> 
> Aravind
> 
> On Mon, Jan 7, 2019 at 12:20 PM Aravind R S <aravindet@gmail.com> wrote:
>>
>> Thanks! Here's the output of dump.f2fs:
>>
>> # dump.f2fs -d 1 /dev/sda2                                              :(
>> Info: Debug level = 1
>> Info: [/dev/sda2] Disk Model: Samsung SSD 840
>> Info: Segments per section = 1
>> Info: Sections per zone = 1
>> Info: sector size = 512
>> Info: total sectors = 234041344 (114278 MB)
>> Info: MKFS version
>>   ""
>> Info: FSCK version
>>   from "Linux version 4.20.0-arch1-1-ARCH (builduser@heftig-29859)
>> (gcc version 8.2.1 20181127 (GCC)) #1 SMP PREEMPT Mon Dec 24 03:00:40
>> UTC 2018"
>>     to "Linux version 4.20.0-arch1-1-ARCH (builduser@heftig-29859)
>> (gcc version 8.2.1 20181127 (GCC)) #1 SMP PREEMPT Mon Dec 24 03:00:40
>> UTC 2018"
>> Info: superblock features = 0 :
>> Info: superblock encrypt level = 0, salt = 00000000000000000000000000000000
>>
>> +--------------------------------------------------------+
>> | Super block                                            |
>> +--------------------------------------------------------+
>> magic                                 [0xf2f52010 : 4076150800]
>> major_ver                             [0x       1 : 1]
>> volum_name                            [root]
>> minor_ver                             [0x       2 : 2]
>> log_sectorsize                        [0x       9 : 9]
>> log_sectors_per_block                 [0x       3 : 3]
>> log_blocksize                         [0x       c : 12]
>> log_blocks_per_seg                    [0x       9 : 9]
>> segs_per_sec                          [0x       1 : 1]
>> secs_per_zone                         [0x       1 : 1]
>> checksum_offset                       [0x       0 : 0]
>> block_count                           [0x 1be6600 : 29255168]
>> section_count                         [0x    de48 : 56904]
>> segment_count                         [0x    df32 : 57138]
>> segment_count_ckpt                    [0x       2 : 2]
>> segment_count_sit                     [0x       6 : 6]
>> segment_count_nat                     [0x      72 : 114]
>> segment_count_ssa                     [0x      70 : 112]
>> segment_count_main                    [0x    de48 : 56904]
>> segment0_blkaddr                      [0x     100 : 256]
>> cp_blkaddr                            [0x     100 : 256]
>> sit_blkaddr                           [0x     500 : 1280]
>> nat_blkaddr                           [0x    1100 : 4352]
>> ssa_blkaddr                           [0x    f500 : 62720]
>> main_blkaddr                          [0x   1d500 : 120064]
>> root_ino                              [0x       3 : 3]
>> node_ino                              [0x       1 : 1]
>> meta_ino                              [0x       2 : 2]
>> cp_payload                            [0x       0 : 0]
>> crc                                   [0x       0 : 0]
>> version                       Linux version 4.20.0-arch1-1-ARCH
>> (builduser@heftig-29859) (gcc version 8.2.1 20181127 (GCC)) #1 SMP
>> PREEMPT Mon Dec 24 03:00:40 UTC 2018
>> Info: total FS sectors = 234041344 (114278 MB)
>> Info: CKPT version = fb3d6
>>
>> +--------------------------------------------------------+
>> | Checkpoint                                             |
>> +--------------------------------------------------------+
>> checkpoint_ver                        [0x   fb3d6 : 1029078]
>> user_block_count                      [0x 1a5fc00 : 27655168]
>> valid_block_count                     [0x 13777de : 20412382]
>> rsvd_segment_count                    [0x      30 : 48]
>> overprov_segment_count                [0x     b4a : 2890]
>> free_segment_count                    [0x    2ce2 : 11490]
>> alloc_type[CURSEG_HOT_NODE]           [0x       0 : 0]
>> alloc_type[CURSEG_WARM_NODE]          [0x       0 : 0]
>> alloc_type[CURSEG_COLD_NODE]          [0x       0 : 0]
>> cur_node_segno[0]                     [0x    173b : 5947]
>> cur_node_segno[1]                     [0x    16d0 : 5840]
>> cur_node_segno[2]                     [0x     536 : 1334]
>> cur_node_blkoff[0]                    [0x     171 : 369]
>> cur_node_blkoff[1]                    [0x      e5 : 229]
>> cur_node_blkoff[2]                    [0x     146 : 326]
>> alloc_type[CURSEG_HOT_DATA]           [0x       0 : 0]
>> alloc_type[CURSEG_WARM_DATA]          [0x       0 : 0]
>> alloc_type[CURSEG_COLD_DATA]          [0x       0 : 0]
>> cur_data_segno[0]                     [0x    1741 : 5953]
>> cur_data_segno[1]                     [0x    8747 : 34631]
>> cur_data_segno[2]                     [0x    6440 : 25664]
>> cur_data_blkoff[0]                    [0x     1f7 : 503]
>> cur_data_blkoff[1]                    [0x     121 : 289]
>> cur_data_blkoff[2]                    [0x     15a : 346]
>> ckpt_flags                            [0x      42 : 66]
>> cp_pack_total_block_count             [0x       6 : 6]
>> cp_pack_start_sum                     [0x       2 : 2]
>> valid_node_count                      [0x  1bbdb5 : 1818037]
>> valid_inode_count                     [0x  1b819a : 1802650]
>> next_free_nid                         [0x  20f518 : 2159896]
>> sit_ver_bitmap_bytesize               [0x      c0 : 192]
>> nat_ver_bitmap_bytesize               [0x     e40 : 3648]
>> checksum_offset                       [0x     ffc : 4092]
>> elapsed_time                          [0x 70188bc : 117541052]
>> sit_nat_version_bitmap[0]             [0x      c5 : 197]
>>
>>
>> Info: checkpoint state = 42 :  crc orphan_inodes sudden-power-off
>>
>> Done.
>>
>> -----
>>
>> And here's gdb output:
>>
>> (gdb) r /dev/sda2
>> Starting program: /usr/bin/fsck.f2fs /dev/sda2
>> Info: [/dev/sda2] Disk Model: Samsung SSD 840
>> Info: Segments per section = 1
>> Info: Sections per zone = 1
>> Info: sector size = 512
>> Info: total sectors = 234041344 (114278 MB)
>> Info: MKFS version
>>   ""
>> Info: FSCK version
>>   from "Linux version 4.20.0-arch1-1-ARCH (builduser@heftig-29859)
>> (gcc version 8.2.1 20181127 (GCC)) #1 SMP PREEMPT Mon Dec 24 03:00:40
>> UTC 2018"
>>     to "Linux version 4.20.0-arch1-1-ARCH (builduser@heftig-29859)
>> (gcc version 8.2.1 20181127 (GCC)) #1 SMP PREEMPT Mon Dec 24 03:00:40
>> UTC 2018"
>> Info: superblock features = 0 :
>> Info: superblock encrypt level = 0, salt = 00000000000000000000000000000000
>> Info: total FS sectors = 234041344 (114278 MB)
>> Info: CKPT version = fb3d6
>>
>> Program received signal SIGSEGV, Segmentation fault.
>> 0x00007ffff7f97894 in f2fs_set_bit () from /usr/lib/libf2fs.so.6
>>
>>
>> Should I provide some additional arguments to get more information out of gdb?
>>
>> Aravind
>>
>> On Mon, Jan 7, 2019 at 10:41 AM Chao Yu <yuchao0@huawei.com> wrote:
>>>
>>> Hi Aravind,
>>>
>>> On 2019/1/6 1:04, Aravind R S wrote:
>>>> I use Arch Linux and the versions of the kernel and f2fs-tools
>>>> provided by that distro. I have an F2FS filesystem that seems to have
>>>> become corrupt and cannot be mounted, and running fsck.f2fs on it
>>>> results in a segmentation fault:
>>>>
>>>> # fsck.f2fs /dev/sda2
>>>> Info: [/dev/sda2] Disk Model: Samsung SSD 840
>>>> Info: Segments per section = 1
>>>> Info: Sections per zone = 1
>>>> Info: sector size = 512
>>>> Info: total sectors = 234041344 (114278 MB)
>>>> Info: MKFS version
>>>>   ""
>>>> Info: FSCK version
>>>>   from "Linux version 4.19.1-arch1-1-ARCH (builduser@heftig-16768)
>>>> (gcc version 8.2.1 20180831 (GCC)) #1 SMP PREEMPT Sun Nov 4 16:49:26
>>>> UTC 2018"
>>>>     to "Linux version 4.20.0-arch1-1-ARCH (builduser@heftig-29859)
>>>> (gcc version 8.2.1 20181127 (GCC)) #1 SMP PREEMPT Mon Dec 24 03:00:40
>>>> UTC 2018"
>>>> [update_superblock: 513] Info: Done to update superblock
>>>> Info: superblock features = 0 :
>>>> Info: superblock encrypt level = 0, salt = 00000000000000000000000000000000
>>>> Info: total FS sectors = 234041344 (114278 MB)
>>>> Info: CKPT version = fb3d6
>>>> [1]    2643 segmentation fault  sudo fsck.f2fs /dev/sda2
>>>
>>> Could you give the detail position where triggers segment fault? gdb may help?
>>>
>>>>
>>>> ---
>>>>
>>>> # mount /dev/sda2 /mnt                                    :(
>>>> mount: /mnt: wrong fs type, bad option, bad superblock on /dev/sda2,
>>>> missing codepage or helper program, or other error.
>>>
>>> Oh, I guess superblock may be broken, could you please dump sb/cp info via:
>>>
>>> dump.f2fs -d 1 image_path
>>>
>>>>
>>>> ---
>>>>
>>>> Please let me know how I can help debug further.
>>>>
>>>> Aravind
>>>>
>>>>
>>>> _______________________________________________
>>>> 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] 11+ messages in thread

* Re: fsck.f2fs segmentation fault
       [not found]         ` <CAHZgRdA+HCwCU-iTVK5EmUt2rcP0=F3Z+mOu+xa7SF6-os+ANg@mail.gmail.com>
@ 2019-01-09  2:19           ` Chao Yu
       [not found]           ` <CAHZgRdAvPn+ButJ=zv9tji8KsoZqVECg1MHRq-4xi-tPxWeExQ@mail.gmail.com>
  1 sibling, 0 replies; 11+ messages in thread
From: Chao Yu @ 2019-01-09  2:19 UTC (permalink / raw)
  To: Aravind R S; +Cc: linux-f2fs-devel

On 2019/1/8 20:05, Aravind R S wrote:
> fsck.f2fs -d 3 just prints the same output as dump.f2fs -d 1 before
> segfaulting.
> 
> I built f2fs tools from source (at tag v1.12.0) and was able to get this
> backtrace in gdb:
> 
> Program received signal SIGSEGV, Segmentation fault.
> 0x00007ffff7f8eb54 in f2fs_set_bit (nr=1041170432,
>     addr=0x7fffff621010 <error: Cannot access memory at address
> 0x7fffff621010>) at libf2fs.c:312
> 312        mask = 1 << (7 - (nr & 0x07));
> (gdb) where
> #0  0x00007ffff7f8eb54 in f2fs_set_bit (nr=1041170432,
>     addr=0x7fffff621010 <error: Cannot access memory at address
> 0x7fffff621010>) at libf2fs.c:312
> #1  0x00005555555648ad in f2fs_init_nid_bitmap (sbi=0x55555557db40 <gfsck>)
> at mount.c:1069

	for (i = 0; i < nats_in_cursum(journal); i++) {
		block_t addr;

		addr = le32_to_cpu(nat_in_journal(journal, i).block_addr);
		nid = le32_to_cpu(nid_in_journal(journal, i));
		if (addr != NULL_ADDR)
			f2fs_set_bit(nid, nm_i->nid_bitmap);

nid = 1041170432, however max size of nid_bitmap is 26557440 (114 * 512 *
455), result in f2fs_set_bit set the bit in wrong address.

Anyway, we need to check validity of nid from journal, and obsolete those
invalid ones.

Let me send one patch to fix this problem.

Thanks,

> #2  init_node_manager (sbi=sbi@entry=0x55555557db40 <gfsck>) at mount.c:1275
> #3  0x0000555555564900 in build_node_manager (sbi=sbi@entry=0x55555557db40
> <gfsck>) at mount.c:1285
> #4  0x0000555555567824 in f2fs_do_mount (sbi=0x55555557db40 <gfsck>) at
> mount.c:2597
> #5  0x00005555555565c5 in main (argc=<optimized out>, argv=<optimized out>)
> at main.c:770
> 
> 
> Aravind
> 
> 
> On Tue, Jan 8, 2019 at 10:48 AM Chao Yu <yuchao0@huawei.com
> <mailto:yuchao0@huawei.com>> wrote:
> 
>     On 2019/1/7 12:52, Aravind R S wrote:
>     > Here's the backtrace where it segfaults. I don't have it compiled with
>     > the debug symbols, but if you can point me to some instructions I'm
>     > happy to try that.
>     >
>     > (gdb) backtrace
>     > #0  0x00007ffff7f97894 in f2fs_set_bit () from /usr/lib/libf2fs.so.6
>     > #1  0x0000555555565206 in ?? ()
>     > #2  0x0000555555568214 in ?? ()
>     > #3  0x00005555555560be in ?? ()
>     > #4  0x00007ffff7df5223 in __libc_start_main () from /usr/lib/libc.so.6
>     > #5  0x000055555555695e in ?? ()
> 
>     I can't track source code with above call stack..
> 
>     How about downloading tools source code from below git repo address, and
>     compile the source code, run gdb with compiled binary.
> 
>     https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs-tools.git/
> 
> 
>     BTW, could you run fsck again with parameter '-d 3'? and let's check the
>     printed debug info.
> 
>     Thanks,
> 
>     >
>     >
>     > Aravind
>     >
>     > On Mon, Jan 7, 2019 at 12:20 PM Aravind R S <aravindet@gmail.com
>     <mailto:aravindet@gmail.com>> wrote:
>     >>
>     >> Thanks! Here's the output of dump.f2fs:
>     >>
>     >> # dump.f2fs -d 1 /dev/sda2                                         
>         :(
>     >> Info: Debug level = 1
>     >> Info: [/dev/sda2] Disk Model: Samsung SSD 840
>     >> Info: Segments per section = 1
>     >> Info: Sections per zone = 1
>     >> Info: sector size = 512
>     >> Info: total sectors = 234041344 (114278 MB)
>     >> Info: MKFS version
>     >>   ""
>     >> Info: FSCK version
>     >>   from "Linux version 4.20.0-arch1-1-ARCH (builduser@heftig-29859)
>     >> (gcc version 8.2.1 20181127 (GCC)) #1 SMP PREEMPT Mon Dec 24 03:00:40
>     >> UTC 2018"
>     >>     to "Linux version 4.20.0-arch1-1-ARCH (builduser@heftig-29859)
>     >> (gcc version 8.2.1 20181127 (GCC)) #1 SMP PREEMPT Mon Dec 24 03:00:40
>     >> UTC 2018"
>     >> Info: superblock features = 0 :
>     >> Info: superblock encrypt level = 0, salt =
>     00000000000000000000000000000000
>     >>
>     >> +--------------------------------------------------------+
>     >> | Super block                                            |
>     >> +--------------------------------------------------------+
>     >> magic                                 [0xf2f52010 : 4076150800]
>     >> major_ver                             [0x       1 : 1]
>     >> volum_name                            [root]
>     >> minor_ver                             [0x       2 : 2]
>     >> log_sectorsize                        [0x       9 : 9]
>     >> log_sectors_per_block                 [0x       3 : 3]
>     >> log_blocksize                         [0x       c : 12]
>     >> log_blocks_per_seg                    [0x       9 : 9]
>     >> segs_per_sec                          [0x       1 : 1]
>     >> secs_per_zone                         [0x       1 : 1]
>     >> checksum_offset                       [0x       0 : 0]
>     >> block_count                           [0x 1be6600 : 29255168]
>     >> section_count                         [0x    de48 : 56904]
>     >> segment_count                         [0x    df32 : 57138]
>     >> segment_count_ckpt                    [0x       2 : 2]
>     >> segment_count_sit                     [0x       6 : 6]
>     >> segment_count_nat                     [0x      72 : 114]
>     >> segment_count_ssa                     [0x      70 : 112]
>     >> segment_count_main                    [0x    de48 : 56904]
>     >> segment0_blkaddr                      [0x     100 : 256]
>     >> cp_blkaddr                            [0x     100 : 256]
>     >> sit_blkaddr                           [0x     500 : 1280]
>     >> nat_blkaddr                           [0x    1100 : 4352]
>     >> ssa_blkaddr                           [0x    f500 : 62720]
>     >> main_blkaddr                          [0x   1d500 : 120064]
>     >> root_ino                              [0x       3 : 3]
>     >> node_ino                              [0x       1 : 1]
>     >> meta_ino                              [0x       2 : 2]
>     >> cp_payload                            [0x       0 : 0]
>     >> crc                                   [0x       0 : 0]
>     >> version                       Linux version 4.20.0-arch1-1-ARCH
>     >> (builduser@heftig-29859) (gcc version 8.2.1 20181127 (GCC)) #1 SMP
>     >> PREEMPT Mon Dec 24 03:00:40 UTC 2018
>     >> Info: total FS sectors = 234041344 (114278 MB)
>     >> Info: CKPT version = fb3d6
>     >>
>     >> +--------------------------------------------------------+
>     >> | Checkpoint                                             |
>     >> +--------------------------------------------------------+
>     >> checkpoint_ver                        [0x   fb3d6 : 1029078]
>     >> user_block_count                      [0x 1a5fc00 : 27655168]
>     >> valid_block_count                     [0x 13777de : 20412382]
>     >> rsvd_segment_count                    [0x      30 : 48]
>     >> overprov_segment_count                [0x     b4a : 2890]
>     >> free_segment_count                    [0x    2ce2 : 11490]
>     >> alloc_type[CURSEG_HOT_NODE]           [0x       0 : 0]
>     >> alloc_type[CURSEG_WARM_NODE]          [0x       0 : 0]
>     >> alloc_type[CURSEG_COLD_NODE]          [0x       0 : 0]
>     >> cur_node_segno[0]                     [0x    173b : 5947]
>     >> cur_node_segno[1]                     [0x    16d0 : 5840]
>     >> cur_node_segno[2]                     [0x     536 : 1334]
>     >> cur_node_blkoff[0]                    [0x     171 : 369]
>     >> cur_node_blkoff[1]                    [0x      e5 : 229]
>     >> cur_node_blkoff[2]                    [0x     146 : 326]
>     >> alloc_type[CURSEG_HOT_DATA]           [0x       0 : 0]
>     >> alloc_type[CURSEG_WARM_DATA]          [0x       0 : 0]
>     >> alloc_type[CURSEG_COLD_DATA]          [0x       0 : 0]
>     >> cur_data_segno[0]                     [0x    1741 : 5953]
>     >> cur_data_segno[1]                     [0x    8747 : 34631]
>     >> cur_data_segno[2]                     [0x    6440 : 25664]
>     >> cur_data_blkoff[0]                    [0x     1f7 : 503]
>     >> cur_data_blkoff[1]                    [0x     121 : 289]
>     >> cur_data_blkoff[2]                    [0x     15a : 346]
>     >> ckpt_flags                            [0x      42 : 66]
>     >> cp_pack_total_block_count             [0x       6 : 6]
>     >> cp_pack_start_sum                     [0x       2 : 2]
>     >> valid_node_count                      [0x  1bbdb5 : 1818037]
>     >> valid_inode_count                     [0x  1b819a : 1802650]
>     >> next_free_nid                         [0x  20f518 : 2159896]
>     >> sit_ver_bitmap_bytesize               [0x      c0 : 192]
>     >> nat_ver_bitmap_bytesize               [0x     e40 : 3648]
>     >> checksum_offset                       [0x     ffc : 4092]
>     >> elapsed_time                          [0x 70188bc : 117541052]
>     >> sit_nat_version_bitmap[0]             [0x      c5 : 197]
>     >>
>     >>
>     >> Info: checkpoint state = 42 :  crc orphan_inodes sudden-power-off
>     >>
>     >> Done.
>     >>
>     >> -----
>     >>
>     >> And here's gdb output:
>     >>
>     >> (gdb) r /dev/sda2
>     >> Starting program: /usr/bin/fsck.f2fs /dev/sda2
>     >> Info: [/dev/sda2] Disk Model: Samsung SSD 840
>     >> Info: Segments per section = 1
>     >> Info: Sections per zone = 1
>     >> Info: sector size = 512
>     >> Info: total sectors = 234041344 (114278 MB)
>     >> Info: MKFS version
>     >>   ""
>     >> Info: FSCK version
>     >>   from "Linux version 4.20.0-arch1-1-ARCH (builduser@heftig-29859)
>     >> (gcc version 8.2.1 20181127 (GCC)) #1 SMP PREEMPT Mon Dec 24 03:00:40
>     >> UTC 2018"
>     >>     to "Linux version 4.20.0-arch1-1-ARCH (builduser@heftig-29859)
>     >> (gcc version 8.2.1 20181127 (GCC)) #1 SMP PREEMPT Mon Dec 24 03:00:40
>     >> UTC 2018"
>     >> Info: superblock features = 0 :
>     >> Info: superblock encrypt level = 0, salt =
>     00000000000000000000000000000000
>     >> Info: total FS sectors = 234041344 (114278 MB)
>     >> Info: CKPT version = fb3d6
>     >>
>     >> Program received signal SIGSEGV, Segmentation fault.
>     >> 0x00007ffff7f97894 in f2fs_set_bit () from /usr/lib/libf2fs.so.6
>     >>
>     >>
>     >> Should I provide some additional arguments to get more information
>     out of gdb?
>     >>
>     >> Aravind
>     >>
>     >> On Mon, Jan 7, 2019 at 10:41 AM Chao Yu <yuchao0@huawei.com
>     <mailto:yuchao0@huawei.com>> wrote:
>     >>>
>     >>> Hi Aravind,
>     >>>
>     >>> On 2019/1/6 1:04, Aravind R S wrote:
>     >>>> I use Arch Linux and the versions of the kernel and f2fs-tools
>     >>>> provided by that distro. I have an F2FS filesystem that seems to have
>     >>>> become corrupt and cannot be mounted, and running fsck.f2fs on it
>     >>>> results in a segmentation fault:
>     >>>>
>     >>>> # fsck.f2fs /dev/sda2
>     >>>> Info: [/dev/sda2] Disk Model: Samsung SSD 840
>     >>>> Info: Segments per section = 1
>     >>>> Info: Sections per zone = 1
>     >>>> Info: sector size = 512
>     >>>> Info: total sectors = 234041344 (114278 MB)
>     >>>> Info: MKFS version
>     >>>>   ""
>     >>>> Info: FSCK version
>     >>>>   from "Linux version 4.19.1-arch1-1-ARCH (builduser@heftig-16768)
>     >>>> (gcc version 8.2.1 20180831 (GCC)) #1 SMP PREEMPT Sun Nov 4 16:49:26
>     >>>> UTC 2018"
>     >>>>     to "Linux version 4.20.0-arch1-1-ARCH (builduser@heftig-29859)
>     >>>> (gcc version 8.2.1 20181127 (GCC)) #1 SMP PREEMPT Mon Dec 24 03:00:40
>     >>>> UTC 2018"
>     >>>> [update_superblock: 513] Info: Done to update superblock
>     >>>> Info: superblock features = 0 :
>     >>>> Info: superblock encrypt level = 0, salt =
>     00000000000000000000000000000000
>     >>>> Info: total FS sectors = 234041344 (114278 MB)
>     >>>> Info: CKPT version = fb3d6
>     >>>> [1]    2643 segmentation fault  sudo fsck.f2fs /dev/sda2
>     >>>
>     >>> Could you give the detail position where triggers segment fault?
>     gdb may help?
>     >>>
>     >>>>
>     >>>> ---
>     >>>>
>     >>>> # mount /dev/sda2 /mnt                                    :(
>     >>>> mount: /mnt: wrong fs type, bad option, bad superblock on /dev/sda2,
>     >>>> missing codepage or helper program, or other error.
>     >>>
>     >>> Oh, I guess superblock may be broken, could you please dump sb/cp
>     info via:
>     >>>
>     >>> dump.f2fs -d 1 image_path
>     >>>
>     >>>>
>     >>>> ---
>     >>>>
>     >>>> Please let me know how I can help debug further.
>     >>>>
>     >>>> Aravind
>     >>>>
>     >>>>
>     >>>> _______________________________________________
>     >>>> Linux-f2fs-devel mailing list
>     >>>> Linux-f2fs-devel@lists.sourceforge.net
>     <mailto: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] 11+ messages in thread

* Re: fsck.f2fs segmentation fault
       [not found]           ` <CAHZgRdAvPn+ButJ=zv9tji8KsoZqVECg1MHRq-4xi-tPxWeExQ@mail.gmail.com>
@ 2019-01-09  3:41             ` Chao Yu
       [not found]               ` <CAHZgRdCMxoAWf_tf9ae8e4TSBPCWE-fhSF8Ej_fCUh47auMUVA@mail.gmail.com>
  0 siblings, 1 reply; 11+ messages in thread
From: Chao Yu @ 2019-01-09  3:41 UTC (permalink / raw)
  To: Aravind R S; +Cc: linux-f2fs-devel

On 2019/1/9 8:44, Aravind R S wrote:
> Also, if it helps, after each failed mount there are two error lines added
> to the kernel logs:
> 
> [13845.849740] F2FS-fs (sda2): Failed to initialize F2FS segment manager
> [13845.936688] F2FS-fs (sda2): Failed to initialize F2FS segment manager
> 
> There are no messages at the other log levels (debug, info etc).
> 
> Also, I must mention that this filesystem was last written to some time
> ago, I believe under kernel 4.18.

I suspect nat/sit journal info are corrupted, could you apply below diff,
recompile/reinstall the f2fs ko, and retry the mount?

--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -3538,8 +3538,10 @@ static int restore_curseg_summaries(struct
f2fs_sb_info *sbi)

        /* sanity check for summary blocks */
        if (nats_in_cursum(nat_j) > NAT_JOURNAL_ENTRIES ||
-                       sits_in_cursum(sit_j) > SIT_JOURNAL_ENTRIES)
+                       sits_in_cursum(sit_j) > SIT_JOURNAL_ENTRIES) {
+               printk("nats:%u, sits:%u", nats_in_cursum(nat_j),
sits_in_cursum(sit_j));
                return -EINVAL;
+       }

        return 0;
 }


> 
> Aravind
> 
> 
> On Tue, Jan 8, 2019 at 8:05 PM Aravind R S <aravindet@gmail.com
> <mailto:aravindet@gmail.com>> wrote:
> 
>     fsck.f2fs -d 3 just prints the same output as dump.f2fs -d 1 before
>     segfaulting.
> 
>     I built f2fs tools from source (at tag v1.12.0) and was able to get
>     this backtrace in gdb:
> 
>     Program received signal SIGSEGV, Segmentation fault.
>     0x00007ffff7f8eb54 in f2fs_set_bit (nr=1041170432,
>         addr=0x7fffff621010 <error: Cannot access memory at address
>     0x7fffff621010>) at libf2fs.c:312
>     312        mask = 1 << (7 - (nr & 0x07));
>     (gdb) where
>     #0  0x00007ffff7f8eb54 in f2fs_set_bit (nr=1041170432,
>         addr=0x7fffff621010 <error: Cannot access memory at address
>     0x7fffff621010>) at libf2fs.c:312
>     #1  0x00005555555648ad in f2fs_init_nid_bitmap (sbi=0x55555557db40
>     <gfsck>) at mount.c:1069
>     #2  init_node_manager (sbi=sbi@entry=0x55555557db40 <gfsck>) at
>     mount.c:1275
>     #3  0x0000555555564900 in build_node_manager
>     (sbi=sbi@entry=0x55555557db40 <gfsck>) at mount.c:1285
>     #4  0x0000555555567824 in f2fs_do_mount (sbi=0x55555557db40 <gfsck>) at
>     mount.c:2597
>     #5  0x00005555555565c5 in main (argc=<optimized out>, argv=<optimized
>     out>) at main.c:770
> 
> 
>     Aravind
> 
> 
>     On Tue, Jan 8, 2019 at 10:48 AM Chao Yu <yuchao0@huawei.com
>     <mailto:yuchao0@huawei.com>> wrote:
> 
>         On 2019/1/7 12:52, Aravind R S wrote:
>         > Here's the backtrace where it segfaults. I don't have it compiled
>         with
>         > the debug symbols, but if you can point me to some instructions I'm
>         > happy to try that.
>         >
>         > (gdb) backtrace
>         > #0  0x00007ffff7f97894 in f2fs_set_bit () from /usr/lib/libf2fs.so.6
>         > #1  0x0000555555565206 in ?? ()
>         > #2  0x0000555555568214 in ?? ()
>         > #3  0x00005555555560be in ?? ()
>         > #4  0x00007ffff7df5223 in __libc_start_main () from
>         /usr/lib/libc.so.6
>         > #5  0x000055555555695e in ?? ()
> 
>         I can't track source code with above call stack..
> 
>         How about downloading tools source code from below git repo
>         address, and
>         compile the source code, run gdb with compiled binary.
> 
>         https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs-tools.git/
> 
> 
>         BTW, could you run fsck again with parameter '-d 3'? and let's
>         check the
>         printed debug info.
> 
>         Thanks,
> 
>         >
>         >
>         > Aravind
>         >
>         > On Mon, Jan 7, 2019 at 12:20 PM Aravind R S <aravindet@gmail.com
>         <mailto:aravindet@gmail.com>> wrote:
>         >>
>         >> Thanks! Here's the output of dump.f2fs:
>         >>
>         >> # dump.f2fs -d 1 /dev/sda2                                     
>                 :(
>         >> Info: Debug level = 1
>         >> Info: [/dev/sda2] Disk Model: Samsung SSD 840
>         >> Info: Segments per section = 1
>         >> Info: Sections per zone = 1
>         >> Info: sector size = 512
>         >> Info: total sectors = 234041344 (114278 MB)
>         >> Info: MKFS version
>         >>   ""
>         >> Info: FSCK version
>         >>   from "Linux version 4.20.0-arch1-1-ARCH (builduser@heftig-29859)
>         >> (gcc version 8.2.1 20181127 (GCC)) #1 SMP PREEMPT Mon Dec 24
>         03:00:40
>         >> UTC 2018"
>         >>     to "Linux version 4.20.0-arch1-1-ARCH (builduser@heftig-29859)
>         >> (gcc version 8.2.1 20181127 (GCC)) #1 SMP PREEMPT Mon Dec 24
>         03:00:40
>         >> UTC 2018"
>         >> Info: superblock features = 0 :
>         >> Info: superblock encrypt level = 0, salt =
>         00000000000000000000000000000000
>         >>
>         >> +--------------------------------------------------------+
>         >> | Super block                                            |
>         >> +--------------------------------------------------------+
>         >> magic                                 [0xf2f52010 : 4076150800]
>         >> major_ver                             [0x       1 : 1]
>         >> volum_name                            [root]
>         >> minor_ver                             [0x       2 : 2]
>         >> log_sectorsize                        [0x       9 : 9]
>         >> log_sectors_per_block                 [0x       3 : 3]
>         >> log_blocksize                         [0x       c : 12]
>         >> log_blocks_per_seg                    [0x       9 : 9]
>         >> segs_per_sec                          [0x       1 : 1]
>         >> secs_per_zone                         [0x       1 : 1]
>         >> checksum_offset                       [0x       0 : 0]
>         >> block_count                           [0x 1be6600 : 29255168]
>         >> section_count                         [0x    de48 : 56904]
>         >> segment_count                         [0x    df32 : 57138]
>         >> segment_count_ckpt                    [0x       2 : 2]
>         >> segment_count_sit                     [0x       6 : 6]
>         >> segment_count_nat                     [0x      72 : 114]
>         >> segment_count_ssa                     [0x      70 : 112]
>         >> segment_count_main                    [0x    de48 : 56904]
>         >> segment0_blkaddr                      [0x     100 : 256]
>         >> cp_blkaddr                            [0x     100 : 256]
>         >> sit_blkaddr                           [0x     500 : 1280]
>         >> nat_blkaddr                           [0x    1100 : 4352]
>         >> ssa_blkaddr                           [0x    f500 : 62720]
>         >> main_blkaddr                          [0x   1d500 : 120064]
>         >> root_ino                              [0x       3 : 3]
>         >> node_ino                              [0x       1 : 1]
>         >> meta_ino                              [0x       2 : 2]
>         >> cp_payload                            [0x       0 : 0]
>         >> crc                                   [0x       0 : 0]
>         >> version                       Linux version 4.20.0-arch1-1-ARCH
>         >> (builduser@heftig-29859) (gcc version 8.2.1 20181127 (GCC)) #1 SMP
>         >> PREEMPT Mon Dec 24 03:00:40 UTC 2018
>         >> Info: total FS sectors = 234041344 (114278 MB)
>         >> Info: CKPT version = fb3d6
>         >>
>         >> +--------------------------------------------------------+
>         >> | Checkpoint                                             |
>         >> +--------------------------------------------------------+
>         >> checkpoint_ver                        [0x   fb3d6 : 1029078]
>         >> user_block_count                      [0x 1a5fc00 : 27655168]
>         >> valid_block_count                     [0x 13777de : 20412382]
>         >> rsvd_segment_count                    [0x      30 : 48]
>         >> overprov_segment_count                [0x     b4a : 2890]
>         >> free_segment_count                    [0x    2ce2 : 11490]
>         >> alloc_type[CURSEG_HOT_NODE]           [0x       0 : 0]
>         >> alloc_type[CURSEG_WARM_NODE]          [0x       0 : 0]
>         >> alloc_type[CURSEG_COLD_NODE]          [0x       0 : 0]
>         >> cur_node_segno[0]                     [0x    173b : 5947]
>         >> cur_node_segno[1]                     [0x    16d0 : 5840]
>         >> cur_node_segno[2]                     [0x     536 : 1334]
>         >> cur_node_blkoff[0]                    [0x     171 : 369]
>         >> cur_node_blkoff[1]                    [0x      e5 : 229]
>         >> cur_node_blkoff[2]                    [0x     146 : 326]
>         >> alloc_type[CURSEG_HOT_DATA]           [0x       0 : 0]
>         >> alloc_type[CURSEG_WARM_DATA]          [0x       0 : 0]
>         >> alloc_type[CURSEG_COLD_DATA]          [0x       0 : 0]
>         >> cur_data_segno[0]                     [0x    1741 : 5953]
>         >> cur_data_segno[1]                     [0x    8747 : 34631]
>         >> cur_data_segno[2]                     [0x    6440 : 25664]
>         >> cur_data_blkoff[0]                    [0x     1f7 : 503]
>         >> cur_data_blkoff[1]                    [0x     121 : 289]
>         >> cur_data_blkoff[2]                    [0x     15a : 346]
>         >> ckpt_flags                            [0x      42 : 66]
>         >> cp_pack_total_block_count             [0x       6 : 6]
>         >> cp_pack_start_sum                     [0x       2 : 2]
>         >> valid_node_count                      [0x  1bbdb5 : 1818037]
>         >> valid_inode_count                     [0x  1b819a : 1802650]
>         >> next_free_nid                         [0x  20f518 : 2159896]
>         >> sit_ver_bitmap_bytesize               [0x      c0 : 192]
>         >> nat_ver_bitmap_bytesize               [0x     e40 : 3648]
>         >> checksum_offset                       [0x     ffc : 4092]
>         >> elapsed_time                          [0x 70188bc : 117541052]
>         >> sit_nat_version_bitmap[0]             [0x      c5 : 197]
>         >>
>         >>
>         >> Info: checkpoint state = 42 :  crc orphan_inodes sudden-power-off
>         >>
>         >> Done.
>         >>
>         >> -----
>         >>
>         >> And here's gdb output:
>         >>
>         >> (gdb) r /dev/sda2
>         >> Starting program: /usr/bin/fsck.f2fs /dev/sda2
>         >> Info: [/dev/sda2] Disk Model: Samsung SSD 840
>         >> Info: Segments per section = 1
>         >> Info: Sections per zone = 1
>         >> Info: sector size = 512
>         >> Info: total sectors = 234041344 (114278 MB)
>         >> Info: MKFS version
>         >>   ""
>         >> Info: FSCK version
>         >>   from "Linux version 4.20.0-arch1-1-ARCH (builduser@heftig-29859)
>         >> (gcc version 8.2.1 20181127 (GCC)) #1 SMP PREEMPT Mon Dec 24
>         03:00:40
>         >> UTC 2018"
>         >>     to "Linux version 4.20.0-arch1-1-ARCH (builduser@heftig-29859)
>         >> (gcc version 8.2.1 20181127 (GCC)) #1 SMP PREEMPT Mon Dec 24
>         03:00:40
>         >> UTC 2018"
>         >> Info: superblock features = 0 :
>         >> Info: superblock encrypt level = 0, salt =
>         00000000000000000000000000000000
>         >> Info: total FS sectors = 234041344 (114278 MB)
>         >> Info: CKPT version = fb3d6
>         >>
>         >> Program received signal SIGSEGV, Segmentation fault.
>         >> 0x00007ffff7f97894 in f2fs_set_bit () from /usr/lib/libf2fs.so.6
>         >>
>         >>
>         >> Should I provide some additional arguments to get more
>         information out of gdb?
>         >>
>         >> Aravind
>         >>
>         >> On Mon, Jan 7, 2019 at 10:41 AM Chao Yu <yuchao0@huawei.com
>         <mailto:yuchao0@huawei.com>> wrote:
>         >>>
>         >>> Hi Aravind,
>         >>>
>         >>> On 2019/1/6 1:04, Aravind R S wrote:
>         >>>> I use Arch Linux and the versions of the kernel and f2fs-tools
>         >>>> provided by that distro. I have an F2FS filesystem that seems
>         to have
>         >>>> become corrupt and cannot be mounted, and running fsck.f2fs on it
>         >>>> results in a segmentation fault:
>         >>>>
>         >>>> # fsck.f2fs /dev/sda2
>         >>>> Info: [/dev/sda2] Disk Model: Samsung SSD 840
>         >>>> Info: Segments per section = 1
>         >>>> Info: Sections per zone = 1
>         >>>> Info: sector size = 512
>         >>>> Info: total sectors = 234041344 (114278 MB)
>         >>>> Info: MKFS version
>         >>>>   ""
>         >>>> Info: FSCK version
>         >>>>   from "Linux version 4.19.1-arch1-1-ARCH (builduser@heftig-16768)
>         >>>> (gcc version 8.2.1 20180831 (GCC)) #1 SMP PREEMPT Sun Nov 4
>         16:49:26
>         >>>> UTC 2018"
>         >>>>     to "Linux version 4.20.0-arch1-1-ARCH (builduser@heftig-29859)
>         >>>> (gcc version 8.2.1 20181127 (GCC)) #1 SMP PREEMPT Mon Dec 24
>         03:00:40
>         >>>> UTC 2018"
>         >>>> [update_superblock: 513] Info: Done to update superblock
>         >>>> Info: superblock features = 0 :
>         >>>> Info: superblock encrypt level = 0, salt =
>         00000000000000000000000000000000
>         >>>> Info: total FS sectors = 234041344 (114278 MB)
>         >>>> Info: CKPT version = fb3d6
>         >>>> [1]    2643 segmentation fault  sudo fsck.f2fs /dev/sda2
>         >>>
>         >>> Could you give the detail position where triggers segment
>         fault? gdb may help?
>         >>>
>         >>>>
>         >>>> ---
>         >>>>
>         >>>> # mount /dev/sda2 /mnt                                    :(
>         >>>> mount: /mnt: wrong fs type, bad option, bad superblock on
>         /dev/sda2,
>         >>>> missing codepage or helper program, or other error.
>         >>>
>         >>> Oh, I guess superblock may be broken, could you please dump
>         sb/cp info via:
>         >>>
>         >>> dump.f2fs -d 1 image_path
>         >>>
>         >>>>
>         >>>> ---
>         >>>>
>         >>>> Please let me know how I can help debug further.
>         >>>>
>         >>>> Aravind
>         >>>>
>         >>>>
>         >>>> _______________________________________________
>         >>>> Linux-f2fs-devel mailing list
>         >>>> Linux-f2fs-devel@lists.sourceforge.net
>         <mailto: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] 11+ messages in thread

* Re: fsck.f2fs segmentation fault
       [not found]               ` <CAHZgRdCMxoAWf_tf9ae8e4TSBPCWE-fhSF8Ej_fCUh47auMUVA@mail.gmail.com>
@ 2019-01-11  3:50                 ` Chao Yu
       [not found]                   ` <CAHZgRdABH2Cz4pTLdJ0WFaLxaKvLN49asBF6j8mH32Qprgi1wA@mail.gmail.com>
  0 siblings, 1 reply; 11+ messages in thread
From: Chao Yu @ 2019-01-11  3:50 UTC (permalink / raw)
  To: Aravind R S; +Cc: linux-f2fs-devel

On 2019/1/10 21:41, Aravind R S wrote:
> Hi,
> 
> I have this in my kernel logs now:
> 
> [ 5338.040024] nats:8781, sits:6
> [ 5338.040027] F2FS-fs (sda2): Failed to initialize F2FS segment manager
> [ 5338.128893] nats:8781, sits:6
> [ 5338.128895] F2FS-fs (sda2): Failed to initialize F2FS segment manager

Hi Aravind,

Oh, it seems nats:8781(total count of nat entries in journal) was
overflowed, result in loading invalid nat entries when building nat bitmap.

Could you try below patch? Notice that, it will be better to backup your
whole image before run patched fsck to avoid any data corruption risk.

[PATCH v2] fsck.f2fs: check validity of nat journal

Thanks,

> 
> Thanks,
> Aravind
> 
> 
> On Wed, Jan 9, 2019 at 11:41 AM Chao Yu <yuchao0@huawei.com> wrote:
> 
>> On 2019/1/9 8:44, Aravind R S wrote:
>>> Also, if it helps, after each failed mount there are two error lines
>> added
>>> to the kernel logs:
>>>
>>> [13845.849740] F2FS-fs (sda2): Failed to initialize F2FS segment manager
>>> [13845.936688] F2FS-fs (sda2): Failed to initialize F2FS segment manager
>>>
>>> There are no messages at the other log levels (debug, info etc).
>>>
>>> Also, I must mention that this filesystem was last written to some time
>>> ago, I believe under kernel 4.18.
>>
>> I suspect nat/sit journal info are corrupted, could you apply below diff,
>> recompile/reinstall the f2fs ko, and retry the mount?
>>
>> --- a/fs/f2fs/segment.c
>> +++ b/fs/f2fs/segment.c
>> @@ -3538,8 +3538,10 @@ static int restore_curseg_summaries(struct
>> f2fs_sb_info *sbi)
>>
>>         /* sanity check for summary blocks */
>>         if (nats_in_cursum(nat_j) > NAT_JOURNAL_ENTRIES ||
>> -                       sits_in_cursum(sit_j) > SIT_JOURNAL_ENTRIES)
>> +                       sits_in_cursum(sit_j) > SIT_JOURNAL_ENTRIES) {
>> +               printk("nats:%u, sits:%u", nats_in_cursum(nat_j),
>> sits_in_cursum(sit_j));
>>                 return -EINVAL;
>> +       }
>>
>>         return 0;
>>  }
>>
>>
>>>
>>> Aravind
>>>
>>>
>>> On Tue, Jan 8, 2019 at 8:05 PM Aravind R S <aravindet@gmail.com
>>> <mailto:aravindet@gmail.com>> wrote:
>>>
>>>     fsck.f2fs -d 3 just prints the same output as dump.f2fs -d 1 before
>>>     segfaulting.
>>>
>>>     I built f2fs tools from source (at tag v1.12.0) and was able to get
>>>     this backtrace in gdb:
>>>
>>>     Program received signal SIGSEGV, Segmentation fault.
>>>     0x00007ffff7f8eb54 in f2fs_set_bit (nr=1041170432,
>>>         addr=0x7fffff621010 <error: Cannot access memory at address
>>>     0x7fffff621010>) at libf2fs.c:312
>>>     312        mask = 1 << (7 - (nr & 0x07));
>>>     (gdb) where
>>>     #0  0x00007ffff7f8eb54 in f2fs_set_bit (nr=1041170432,
>>>         addr=0x7fffff621010 <error: Cannot access memory at address
>>>     0x7fffff621010>) at libf2fs.c:312
>>>     #1  0x00005555555648ad in f2fs_init_nid_bitmap (sbi=0x55555557db40
>>>     <gfsck>) at mount.c:1069
>>>     #2  init_node_manager (sbi=sbi@entry=0x55555557db40 <gfsck>) at
>>>     mount.c:1275
>>>     #3  0x0000555555564900 in build_node_manager
>>>     (sbi=sbi@entry=0x55555557db40 <gfsck>) at mount.c:1285
>>>     #4  0x0000555555567824 in f2fs_do_mount (sbi=0x55555557db40 <gfsck>)
>> at
>>>     mount.c:2597
>>>     #5  0x00005555555565c5 in main (argc=<optimized out>, argv=<optimized
>>>     out>) at main.c:770
>>>
>>>
>>>     Aravind
>>>
>>>
>>>     On Tue, Jan 8, 2019 at 10:48 AM Chao Yu <yuchao0@huawei.com
>>>     <mailto:yuchao0@huawei.com>> wrote:
>>>
>>>         On 2019/1/7 12:52, Aravind R S wrote:
>>>         > Here's the backtrace where it segfaults. I don't have it
>> compiled
>>>         with
>>>         > the debug symbols, but if you can point me to some
>> instructions I'm
>>>         > happy to try that.
>>>         >
>>>         > (gdb) backtrace
>>>         > #0  0x00007ffff7f97894 in f2fs_set_bit () from
>> /usr/lib/libf2fs.so.6
>>>         > #1  0x0000555555565206 in ?? ()
>>>         > #2  0x0000555555568214 in ?? ()
>>>         > #3  0x00005555555560be in ?? ()
>>>         > #4  0x00007ffff7df5223 in __libc_start_main () from
>>>         /usr/lib/libc.so.6
>>>         > #5  0x000055555555695e in ?? ()
>>>
>>>         I can't track source code with above call stack..
>>>
>>>         How about downloading tools source code from below git repo
>>>         address, and
>>>         compile the source code, run gdb with compiled binary.
>>>
>>>
>> https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs-tools.git/
>>>
>>>
>>>         BTW, could you run fsck again with parameter '-d 3'? and let's
>>>         check the
>>>         printed debug info.
>>>
>>>         Thanks,
>>>
>>>         >
>>>         >
>>>         > Aravind
>>>         >
>>>         > On Mon, Jan 7, 2019 at 12:20 PM Aravind R S <
>> aravindet@gmail.com
>>>         <mailto:aravindet@gmail.com>> wrote:
>>>         >>
>>>         >> Thanks! Here's the output of dump.f2fs:
>>>         >>
>>>         >> # dump.f2fs -d 1 /dev/sda2
>>
>>>                 :(
>>>         >> Info: Debug level = 1
>>>         >> Info: [/dev/sda2] Disk Model: Samsung SSD 840
>>>         >> Info: Segments per section = 1
>>>         >> Info: Sections per zone = 1
>>>         >> Info: sector size = 512
>>>         >> Info: total sectors = 234041344 (114278 MB)
>>>         >> Info: MKFS version
>>>         >>   ""
>>>         >> Info: FSCK version
>>>         >>   from "Linux version 4.20.0-arch1-1-ARCH
>> (builduser@heftig-29859)
>>>         >> (gcc version 8.2.1 20181127 (GCC)) #1 SMP PREEMPT Mon Dec 24
>>>         03:00:40
>>>         >> UTC 2018"
>>>         >>     to "Linux version 4.20.0-arch1-1-ARCH
>> (builduser@heftig-29859)
>>>         >> (gcc version 8.2.1 20181127 (GCC)) #1 SMP PREEMPT Mon Dec 24
>>>         03:00:40
>>>         >> UTC 2018"
>>>         >> Info: superblock features = 0 :
>>>         >> Info: superblock encrypt level = 0, salt =
>>>         00000000000000000000000000000000
>>>         >>
>>>         >> +--------------------------------------------------------+
>>>         >> | Super block                                            |
>>>         >> +--------------------------------------------------------+
>>>         >> magic                                 [0xf2f52010 :
>> 4076150800]
>>>         >> major_ver                             [0x       1 : 1]
>>>         >> volum_name                            [root]
>>>         >> minor_ver                             [0x       2 : 2]
>>>         >> log_sectorsize                        [0x       9 : 9]
>>>         >> log_sectors_per_block                 [0x       3 : 3]
>>>         >> log_blocksize                         [0x       c : 12]
>>>         >> log_blocks_per_seg                    [0x       9 : 9]
>>>         >> segs_per_sec                          [0x       1 : 1]
>>>         >> secs_per_zone                         [0x       1 : 1]
>>>         >> checksum_offset                       [0x       0 : 0]
>>>         >> block_count                           [0x 1be6600 : 29255168]
>>>         >> section_count                         [0x    de48 : 56904]
>>>         >> segment_count                         [0x    df32 : 57138]
>>>         >> segment_count_ckpt                    [0x       2 : 2]
>>>         >> segment_count_sit                     [0x       6 : 6]
>>>         >> segment_count_nat                     [0x      72 : 114]
>>>         >> segment_count_ssa                     [0x      70 : 112]
>>>         >> segment_count_main                    [0x    de48 : 56904]
>>>         >> segment0_blkaddr                      [0x     100 : 256]
>>>         >> cp_blkaddr                            [0x     100 : 256]
>>>         >> sit_blkaddr                           [0x     500 : 1280]
>>>         >> nat_blkaddr                           [0x    1100 : 4352]
>>>         >> ssa_blkaddr                           [0x    f500 : 62720]
>>>         >> main_blkaddr                          [0x   1d500 : 120064]
>>>         >> root_ino                              [0x       3 : 3]
>>>         >> node_ino                              [0x       1 : 1]
>>>         >> meta_ino                              [0x       2 : 2]
>>>         >> cp_payload                            [0x       0 : 0]
>>>         >> crc                                   [0x       0 : 0]
>>>         >> version                       Linux version
>> 4.20.0-arch1-1-ARCH
>>>         >> (builduser@heftig-29859) (gcc version 8.2.1 20181127 (GCC))
>> #1 SMP
>>>         >> PREEMPT Mon Dec 24 03:00:40 UTC 2018
>>>         >> Info: total FS sectors = 234041344 (114278 MB)
>>>         >> Info: CKPT version = fb3d6
>>>         >>
>>>         >> +--------------------------------------------------------+
>>>         >> | Checkpoint                                             |
>>>         >> +--------------------------------------------------------+
>>>         >> checkpoint_ver                        [0x   fb3d6 : 1029078]
>>>         >> user_block_count                      [0x 1a5fc00 : 27655168]
>>>         >> valid_block_count                     [0x 13777de : 20412382]
>>>         >> rsvd_segment_count                    [0x      30 : 48]
>>>         >> overprov_segment_count                [0x     b4a : 2890]
>>>         >> free_segment_count                    [0x    2ce2 : 11490]
>>>         >> alloc_type[CURSEG_HOT_NODE]           [0x       0 : 0]
>>>         >> alloc_type[CURSEG_WARM_NODE]          [0x       0 : 0]
>>>         >> alloc_type[CURSEG_COLD_NODE]          [0x       0 : 0]
>>>         >> cur_node_segno[0]                     [0x    173b : 5947]
>>>         >> cur_node_segno[1]                     [0x    16d0 : 5840]
>>>         >> cur_node_segno[2]                     [0x     536 : 1334]
>>>         >> cur_node_blkoff[0]                    [0x     171 : 369]
>>>         >> cur_node_blkoff[1]                    [0x      e5 : 229]
>>>         >> cur_node_blkoff[2]                    [0x     146 : 326]
>>>         >> alloc_type[CURSEG_HOT_DATA]           [0x       0 : 0]
>>>         >> alloc_type[CURSEG_WARM_DATA]          [0x       0 : 0]
>>>         >> alloc_type[CURSEG_COLD_DATA]          [0x       0 : 0]
>>>         >> cur_data_segno[0]                     [0x    1741 : 5953]
>>>         >> cur_data_segno[1]                     [0x    8747 : 34631]
>>>         >> cur_data_segno[2]                     [0x    6440 : 25664]
>>>         >> cur_data_blkoff[0]                    [0x     1f7 : 503]
>>>         >> cur_data_blkoff[1]                    [0x     121 : 289]
>>>         >> cur_data_blkoff[2]                    [0x     15a : 346]
>>>         >> ckpt_flags                            [0x      42 : 66]
>>>         >> cp_pack_total_block_count             [0x       6 : 6]
>>>         >> cp_pack_start_sum                     [0x       2 : 2]
>>>         >> valid_node_count                      [0x  1bbdb5 : 1818037]
>>>         >> valid_inode_count                     [0x  1b819a : 1802650]
>>>         >> next_free_nid                         [0x  20f518 : 2159896]
>>>         >> sit_ver_bitmap_bytesize               [0x      c0 : 192]
>>>         >> nat_ver_bitmap_bytesize               [0x     e40 : 3648]
>>>         >> checksum_offset                       [0x     ffc : 4092]
>>>         >> elapsed_time                          [0x 70188bc : 117541052]
>>>         >> sit_nat_version_bitmap[0]             [0x      c5 : 197]
>>>         >>
>>>         >>
>>>         >> Info: checkpoint state = 42 :  crc orphan_inodes
>> sudden-power-off
>>>         >>
>>>         >> Done.
>>>         >>
>>>         >> -----
>>>         >>
>>>         >> And here's gdb output:
>>>         >>
>>>         >> (gdb) r /dev/sda2
>>>         >> Starting program: /usr/bin/fsck.f2fs /dev/sda2
>>>         >> Info: [/dev/sda2] Disk Model: Samsung SSD 840
>>>         >> Info: Segments per section = 1
>>>         >> Info: Sections per zone = 1
>>>         >> Info: sector size = 512
>>>         >> Info: total sectors = 234041344 (114278 MB)
>>>         >> Info: MKFS version
>>>         >>   ""
>>>         >> Info: FSCK version
>>>         >>   from "Linux version 4.20.0-arch1-1-ARCH
>> (builduser@heftig-29859)
>>>         >> (gcc version 8.2.1 20181127 (GCC)) #1 SMP PREEMPT Mon Dec 24
>>>         03:00:40
>>>         >> UTC 2018"
>>>         >>     to "Linux version 4.20.0-arch1-1-ARCH
>> (builduser@heftig-29859)
>>>         >> (gcc version 8.2.1 20181127 (GCC)) #1 SMP PREEMPT Mon Dec 24
>>>         03:00:40
>>>         >> UTC 2018"
>>>         >> Info: superblock features = 0 :
>>>         >> Info: superblock encrypt level = 0, salt =
>>>         00000000000000000000000000000000
>>>         >> Info: total FS sectors = 234041344 (114278 MB)
>>>         >> Info: CKPT version = fb3d6
>>>         >>
>>>         >> Program received signal SIGSEGV, Segmentation fault.
>>>         >> 0x00007ffff7f97894 in f2fs_set_bit () from
>> /usr/lib/libf2fs.so.6
>>>         >>
>>>         >>
>>>         >> Should I provide some additional arguments to get more
>>>         information out of gdb?
>>>         >>
>>>         >> Aravind
>>>         >>
>>>         >> On Mon, Jan 7, 2019 at 10:41 AM Chao Yu <yuchao0@huawei.com
>>>         <mailto:yuchao0@huawei.com>> wrote:
>>>         >>>
>>>         >>> Hi Aravind,
>>>         >>>
>>>         >>> On 2019/1/6 1:04, Aravind R S wrote:
>>>         >>>> I use Arch Linux and the versions of the kernel and
>> f2fs-tools
>>>         >>>> provided by that distro. I have an F2FS filesystem that
>> seems
>>>         to have
>>>         >>>> become corrupt and cannot be mounted, and running fsck.f2fs
>> on it
>>>         >>>> results in a segmentation fault:
>>>         >>>>
>>>         >>>> # fsck.f2fs /dev/sda2
>>>         >>>> Info: [/dev/sda2] Disk Model: Samsung SSD 840
>>>         >>>> Info: Segments per section = 1
>>>         >>>> Info: Sections per zone = 1
>>>         >>>> Info: sector size = 512
>>>         >>>> Info: total sectors = 234041344 (114278 MB)
>>>         >>>> Info: MKFS version
>>>         >>>>   ""
>>>         >>>> Info: FSCK version
>>>         >>>>   from "Linux version 4.19.1-arch1-1-ARCH
>> (builduser@heftig-16768)
>>>         >>>> (gcc version 8.2.1 20180831 (GCC)) #1 SMP PREEMPT Sun Nov 4
>>>         16:49:26
>>>         >>>> UTC 2018"
>>>         >>>>     to "Linux version 4.20.0-arch1-1-ARCH
>> (builduser@heftig-29859)
>>>         >>>> (gcc version 8.2.1 20181127 (GCC)) #1 SMP PREEMPT Mon Dec 24
>>>         03:00:40
>>>         >>>> UTC 2018"
>>>         >>>> [update_superblock: 513] Info: Done to update superblock
>>>         >>>> Info: superblock features = 0 :
>>>         >>>> Info: superblock encrypt level = 0, salt =
>>>         00000000000000000000000000000000
>>>         >>>> Info: total FS sectors = 234041344 (114278 MB)
>>>         >>>> Info: CKPT version = fb3d6
>>>         >>>> [1]    2643 segmentation fault  sudo fsck.f2fs /dev/sda2
>>>         >>>
>>>         >>> Could you give the detail position where triggers segment
>>>         fault? gdb may help?
>>>         >>>
>>>         >>>>
>>>         >>>> ---
>>>         >>>>
>>>         >>>> # mount /dev/sda2 /mnt                                    :(
>>>         >>>> mount: /mnt: wrong fs type, bad option, bad superblock on
>>>         /dev/sda2,
>>>         >>>> missing codepage or helper program, or other error.
>>>         >>>
>>>         >>> Oh, I guess superblock may be broken, could you please dump
>>>         sb/cp info via:
>>>         >>>
>>>         >>> dump.f2fs -d 1 image_path
>>>         >>>
>>>         >>>>
>>>         >>>> ---
>>>         >>>>
>>>         >>>> Please let me know how I can help debug further.
>>>         >>>>
>>>         >>>> Aravind
>>>         >>>>
>>>         >>>>
>>>         >>>> _______________________________________________
>>>         >>>> Linux-f2fs-devel mailing list
>>>         >>>> Linux-f2fs-devel@lists.sourceforge.net
>>>         <mailto:Linux-f2fs-devel@lists.sourceforge.net>
>>>         >>>>
>> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
>>>         >>>>
>>>         >>>>
>>>         >>>
>>>         >
>>>         > .
>>>         >
>>>
>>
>>
> 

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

* Re: fsck.f2fs segmentation fault
       [not found]                   ` <CAHZgRdABH2Cz4pTLdJ0WFaLxaKvLN49asBF6j8mH32Qprgi1wA@mail.gmail.com>
@ 2019-01-14  1:33                     ` Chao Yu
       [not found]                       ` <CAHZgRdDzvERnwHx92z68r6wD6b2k-zTPck7Tx29ww016h3o6jw@mail.gmail.com>
  0 siblings, 1 reply; 11+ messages in thread
From: Chao Yu @ 2019-01-14  1:33 UTC (permalink / raw)
  To: Aravind R S; +Cc: linux-f2fs-devel

On 2019/1/12 18:46, Aravind R S wrote:
> I've compiled and run this:
> 
> It prints the errors as expected, but then segfaults somewhere else.

Could you try v3 I just sent?

Thanks,

> 
> Info: [/dev/sda2] Disk Model: Samsung SSD 840
> Info: Segments per section = 1
> Info: Sections per zone = 1
> Info: sector size = 512
> Info: total sectors = 234041344 (114278 MB)
> Info: MKFS version
>   ""
> Info: FSCK version
>   from "Linux version 4.20.0-arch1-1-ARCH (builduser@heftig-29859) (gcc
> version 8.2.1 20181127 (GCC)) #1 SMP PREEMPT Mon Dec 24 03:00:40 UTC 2018"
>     to "Linux version 4.20.0-arch1-1-ARCH (builduser@heftig-29859) (gcc
> version 8.2.1 20181127 (GCC)) #1 SMP PREEMPT Mon Dec 24 03:00:40 UTC 2018"
> Info: superblock features = 0 :
> Info: superblock encrypt level = 0, salt = 00000000000000000000000000000000
> Info: total FS sectors = 234041344 (114278 MB)
> Info: CKPT version = fb3d6
>     Error: f2fs_init_nid_bitmap truncate n_nats(8781) to
> NAT_JOURNAL_ENTRIES(38)
>     Error: f2fs_init_nid_bitmap: addr(2413690880) is invalid!!!
>     Error: f2fs_init_nid_bitmap: addr(3103804431) is invalid!!!
>     Error: f2fs_init_nid_bitmap: addr(26) is invalid!!!
>     Error: f2fs_init_nid_bitmap: addr(8435) is invalid!!!
>     Error: f2fs_init_nid_bitmap: nid(4093116417) is invalid!!!
>     Error: f2fs_init_nid_bitmap: addr(575256832) is invalid!!!
>     Error: f2fs_init_nid_bitmap: addr(2413690986) is invalid!!!
>     Error: f2fs_init_nid_bitmap: addr(3724565007) is invalid!!!
>     Error: f2fs_init_nid_bitmap: nid(251658383) is invalid!!!
>     Error: f2fs_init_nid_bitmap: addr(1343160320) is invalid!!!
>     Error: f2fs_init_nid_bitmap: addr(8777) is invalid!!!
>     Error: f2fs_init_nid_bitmap: nid(3015180397) is invalid!!!
>     Error: f2fs_init_nid_bitmap: nid(3724572416) is invalid!!!
>     Error: f2fs_init_nid_bitmap: addr(1478754304) is invalid!!!
>     Error: f2fs_init_nid_bitmap: addr(3775060736) is invalid!!!
>     Error: f2fs_init_nid_bitmap: addr(48037888) is invalid!!!
>     Error: f2fs_init_nid_bitmap: addr(3607101466) is invalid!!!
>     Error: f2fs_init_nid_bitmap: addr(6833) is invalid!!!
>     Error: f2fs_init_nid_bitmap: nid(1236861657) is invalid!!!
>     Error: f2fs_init_nid_bitmap: addr(447865090) is invalid!!!
>     Error: f2fs_init_nid_bitmap: addr(1236860989) is invalid!!!
>     Error: f2fs_init_nid_bitmap: addr(3774898688) is invalid!!!
>     Error: f2fs_init_nid_bitmap: addr(50724864) is invalid!!!
>     Error: f2fs_init_nid_bitmap: addr(1041170432) is invalid!!!
>     Error: f2fs_init_nid_bitmap: addr(8777) is invalid!!!
>     Error: f2fs_init_nid_bitmap: addr(10383) is invalid!!!
>     Error: f2fs_init_nid_bitmap: addr(447865090) is invalid!!!
>     Error: f2fs_init_nid_bitmap: addr(1236860997) is invalid!!!
>     Error: f2fs_init_nid_bitmap: addr(3724571904) is invalid!!!
>     Error: f2fs_init_nid_bitmap: addr(52232192) is invalid!!!
>     Error: f2fs_init_nid_bitmap: addr(2113929250) is invalid!!!
>     Error: f2fs_init_nid_bitmap: addr(251658383) is invalid!!!
>     Error: f2fs_init_nid_bitmap: addr(36830) is invalid!!!
>     Error: f2fs_init_nid_bitmap: addr(575256832) is invalid!!!
>     Error: f2fs_init_nid_bitmap: addr(3113156728) is invalid!!!
>     Error: f2fs_init_nid_bitmap: addr(2399142144) is invalid!!!
> 
> Program received signal SIGSEGV, Segmentation fault.
> 0x00005555555673de in build_nat_area_bitmap (sbi=<optimized out>) at
> mount.c:2469
> 2469            if (fsck->entries[nid].block_addr != 0x0) {
> (gdb) backtrace
> #0  0x00005555555673de in build_nat_area_bitmap (sbi=<optimized out>)
>     at mount.c:2469
> #1  0x000055555555d85c in fsck_init (sbi=0x55555557db40 <gfsck>) at fsck.c:1904
> #2  0x000055555555682a in do_fsck (sbi=0x55555557db40 <gfsck>) at main.c:578
> #3  main (argc=<optimized out>, argv=<optimized out>) at main.c:781
> 
> Thanks,
> Aravind
> 
> 
> On Fri, Jan 11, 2019 at 11:50 AM Chao Yu <yuchao0@huawei.com
> <mailto:yuchao0@huawei.com>> wrote:
> 
>     On 2019/1/10 21:41, Aravind R S wrote:
>     > Hi,
>     >
>     > I have this in my kernel logs now:
>     >
>     > [ 5338.040024] nats:8781, sits:6
>     > [ 5338.040027] F2FS-fs (sda2): Failed to initialize F2FS segment manager
>     > [ 5338.128893] nats:8781, sits:6
>     > [ 5338.128895] F2FS-fs (sda2): Failed to initialize F2FS segment manager
> 
>     Hi Aravind,
> 
>     Oh, it seems nats:8781(total count of nat entries in journal) was
>     overflowed, result in loading invalid nat entries when building nat bitmap.
> 
>     Could you try below patch? Notice that, it will be better to backup your
>     whole image before run patched fsck to avoid any data corruption risk.
> 
>     [PATCH v2] fsck.f2fs: check validity of nat journal
> 
>     Thanks,
> 
>     >
>     > Thanks,
>     > Aravind
>     >
>     >
>     > On Wed, Jan 9, 2019 at 11:41 AM Chao Yu <yuchao0@huawei.com
>     <mailto:yuchao0@huawei.com>> wrote:
>     >
>     >> On 2019/1/9 8:44, Aravind R S wrote:
>     >>> Also, if it helps, after each failed mount there are two error lines
>     >> added
>     >>> to the kernel logs:
>     >>>
>     >>> [13845.849740] F2FS-fs (sda2): Failed to initialize F2FS segment
>     manager
>     >>> [13845.936688] F2FS-fs (sda2): Failed to initialize F2FS segment
>     manager
>     >>>
>     >>> There are no messages at the other log levels (debug, info etc).
>     >>>
>     >>> Also, I must mention that this filesystem was last written to some time
>     >>> ago, I believe under kernel 4.18.
>     >>
>     >> I suspect nat/sit journal info are corrupted, could you apply below
>     diff,
>     >> recompile/reinstall the f2fs ko, and retry the mount?
>     >>
>     >> --- a/fs/f2fs/segment.c
>     >> +++ b/fs/f2fs/segment.c
>     >> @@ -3538,8 +3538,10 @@ static int restore_curseg_summaries(struct
>     >> f2fs_sb_info *sbi)
>     >>
>     >>         /* sanity check for summary blocks */
>     >>         if (nats_in_cursum(nat_j) > NAT_JOURNAL_ENTRIES ||
>     >> -                       sits_in_cursum(sit_j) > SIT_JOURNAL_ENTRIES)
>     >> +                       sits_in_cursum(sit_j) > SIT_JOURNAL_ENTRIES) {
>     >> +               printk("nats:%u, sits:%u", nats_in_cursum(nat_j),
>     >> sits_in_cursum(sit_j));
>     >>                 return -EINVAL;
>     >> +       }
>     >>
>     >>         return 0;
>     >>  }
>     >>
>     >>
>     >>>
>     >>> Aravind
>     >>>
>     >>>
>     >>> On Tue, Jan 8, 2019 at 8:05 PM Aravind R S <aravindet@gmail.com
>     <mailto:aravindet@gmail.com>
>     >>> <mailto:aravindet@gmail.com <mailto:aravindet@gmail.com>>> wrote:
>     >>>
>     >>>     fsck.f2fs -d 3 just prints the same output as dump.f2fs -d 1 before
>     >>>     segfaulting.
>     >>>
>     >>>     I built f2fs tools from source (at tag v1.12.0) and was able to get
>     >>>     this backtrace in gdb:
>     >>>
>     >>>     Program received signal SIGSEGV, Segmentation fault.
>     >>>     0x00007ffff7f8eb54 in f2fs_set_bit (nr=1041170432,
>     >>>         addr=0x7fffff621010 <error: Cannot access memory at address
>     >>>     0x7fffff621010>) at libf2fs.c:312
>     >>>     312        mask = 1 << (7 - (nr & 0x07));
>     >>>     (gdb) where
>     >>>     #0  0x00007ffff7f8eb54 in f2fs_set_bit (nr=1041170432,
>     >>>         addr=0x7fffff621010 <error: Cannot access memory at address
>     >>>     0x7fffff621010>) at libf2fs.c:312
>     >>>     #1  0x00005555555648ad in f2fs_init_nid_bitmap (sbi=0x55555557db40
>     >>>     <gfsck>) at mount.c:1069
>     >>>     #2  init_node_manager (sbi=sbi@entry=0x55555557db40 <gfsck>) at
>     >>>     mount.c:1275
>     >>>     #3  0x0000555555564900 in build_node_manager
>     >>>     (sbi=sbi@entry=0x55555557db40 <gfsck>) at mount.c:1285
>     >>>     #4  0x0000555555567824 in f2fs_do_mount (sbi=0x55555557db40
>     <gfsck>)
>     >> at
>     >>>     mount.c:2597
>     >>>     #5  0x00005555555565c5 in main (argc=<optimized out>,
>     argv=<optimized
>     >>>     out>) at main.c:770
>     >>>
>     >>>
>     >>>     Aravind
>     >>>
>     >>>
>     >>>     On Tue, Jan 8, 2019 at 10:48 AM Chao Yu <yuchao0@huawei.com
>     <mailto:yuchao0@huawei.com>
>     >>>     <mailto:yuchao0@huawei.com <mailto:yuchao0@huawei.com>>> wrote:
>     >>>
>     >>>         On 2019/1/7 12:52, Aravind R S wrote:
>     >>>         > Here's the backtrace where it segfaults. I don't have it
>     >> compiled
>     >>>         with
>     >>>         > the debug symbols, but if you can point me to some
>     >> instructions I'm
>     >>>         > happy to try that.
>     >>>         >
>     >>>         > (gdb) backtrace
>     >>>         > #0  0x00007ffff7f97894 in f2fs_set_bit () from
>     >> /usr/lib/libf2fs.so.6
>     >>>         > #1  0x0000555555565206 in ?? ()
>     >>>         > #2  0x0000555555568214 in ?? ()
>     >>>         > #3  0x00005555555560be in ?? ()
>     >>>         > #4  0x00007ffff7df5223 in __libc_start_main () from
>     >>>         /usr/lib/libc.so.6
>     >>>         > #5  0x000055555555695e in ?? ()
>     >>>
>     >>>         I can't track source code with above call stack..
>     >>>
>     >>>         How about downloading tools source code from below git repo
>     >>>         address, and
>     >>>         compile the source code, run gdb with compiled binary.
>     >>>
>     >>>
>     >> https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs-tools.git/
>     >>>
>     >>>
>     >>>         BTW, could you run fsck again with parameter '-d 3'? and let's
>     >>>         check the
>     >>>         printed debug info.
>     >>>
>     >>>         Thanks,
>     >>>
>     >>>         >
>     >>>         >
>     >>>         > Aravind
>     >>>         >
>     >>>         > On Mon, Jan 7, 2019 at 12:20 PM Aravind R S <
>     >> aravindet@gmail.com <mailto:aravindet@gmail.com>
>     >>>         <mailto:aravindet@gmail.com <mailto:aravindet@gmail.com>>>
>     wrote:
>     >>>         >>
>     >>>         >> Thanks! Here's the output of dump.f2fs:
>     >>>         >>
>     >>>         >> # dump.f2fs -d 1 /dev/sda2
>     >>
>     >>>                 :(
>     >>>         >> Info: Debug level = 1
>     >>>         >> Info: [/dev/sda2] Disk Model: Samsung SSD 840
>     >>>         >> Info: Segments per section = 1
>     >>>         >> Info: Sections per zone = 1
>     >>>         >> Info: sector size = 512
>     >>>         >> Info: total sectors = 234041344 (114278 MB)
>     >>>         >> Info: MKFS version
>     >>>         >>   ""
>     >>>         >> Info: FSCK version
>     >>>         >>   from "Linux version 4.20.0-arch1-1-ARCH
>     >> (builduser@heftig-29859)
>     >>>         >> (gcc version 8.2.1 20181127 (GCC)) #1 SMP PREEMPT Mon Dec 24
>     >>>         03:00:40
>     >>>         >> UTC 2018"
>     >>>         >>     to "Linux version 4.20.0-arch1-1-ARCH
>     >> (builduser@heftig-29859)
>     >>>         >> (gcc version 8.2.1 20181127 (GCC)) #1 SMP PREEMPT Mon Dec 24
>     >>>         03:00:40
>     >>>         >> UTC 2018"
>     >>>         >> Info: superblock features = 0 :
>     >>>         >> Info: superblock encrypt level = 0, salt =
>     >>>         00000000000000000000000000000000
>     >>>         >>
>     >>>         >> +--------------------------------------------------------+
>     >>>         >> | Super block                                            |
>     >>>         >> +--------------------------------------------------------+
>     >>>         >> magic                                 [0xf2f52010 :
>     >> 4076150800]
>     >>>         >> major_ver                             [0x       1 : 1]
>     >>>         >> volum_name                            [root]
>     >>>         >> minor_ver                             [0x       2 : 2]
>     >>>         >> log_sectorsize                        [0x       9 : 9]
>     >>>         >> log_sectors_per_block                 [0x       3 : 3]
>     >>>         >> log_blocksize                         [0x       c : 12]
>     >>>         >> log_blocks_per_seg                    [0x       9 : 9]
>     >>>         >> segs_per_sec                          [0x       1 : 1]
>     >>>         >> secs_per_zone                         [0x       1 : 1]
>     >>>         >> checksum_offset                       [0x       0 : 0]
>     >>>         >> block_count                           [0x 1be6600 :
>     29255168]
>     >>>         >> section_count                         [0x    de48 : 56904]
>     >>>         >> segment_count                         [0x    df32 : 57138]
>     >>>         >> segment_count_ckpt                    [0x       2 : 2]
>     >>>         >> segment_count_sit                     [0x       6 : 6]
>     >>>         >> segment_count_nat                     [0x      72 : 114]
>     >>>         >> segment_count_ssa                     [0x      70 : 112]
>     >>>         >> segment_count_main                    [0x    de48 : 56904]
>     >>>         >> segment0_blkaddr                      [0x     100 : 256]
>     >>>         >> cp_blkaddr                            [0x     100 : 256]
>     >>>         >> sit_blkaddr                           [0x     500 : 1280]
>     >>>         >> nat_blkaddr                           [0x    1100 : 4352]
>     >>>         >> ssa_blkaddr                           [0x    f500 : 62720]
>     >>>         >> main_blkaddr                          [0x   1d500 : 120064]
>     >>>         >> root_ino                              [0x       3 : 3]
>     >>>         >> node_ino                              [0x       1 : 1]
>     >>>         >> meta_ino                              [0x       2 : 2]
>     >>>         >> cp_payload                            [0x       0 : 0]
>     >>>         >> crc                                   [0x       0 : 0]
>     >>>         >> version                       Linux version
>     >> 4.20.0-arch1-1-ARCH
>     >>>         >> (builduser@heftig-29859) (gcc version 8.2.1 20181127 (GCC))
>     >> #1 SMP
>     >>>         >> PREEMPT Mon Dec 24 03:00:40 UTC 2018
>     >>>         >> Info: total FS sectors = 234041344 (114278 MB)
>     >>>         >> Info: CKPT version = fb3d6
>     >>>         >>
>     >>>         >> +--------------------------------------------------------+
>     >>>         >> | Checkpoint                                             |
>     >>>         >> +--------------------------------------------------------+
>     >>>         >> checkpoint_ver                        [0x   fb3d6 : 1029078]
>     >>>         >> user_block_count                      [0x 1a5fc00 :
>     27655168]
>     >>>         >> valid_block_count                     [0x 13777de :
>     20412382]
>     >>>         >> rsvd_segment_count                    [0x      30 : 48]
>     >>>         >> overprov_segment_count                [0x     b4a : 2890]
>     >>>         >> free_segment_count                    [0x    2ce2 : 11490]
>     >>>         >> alloc_type[CURSEG_HOT_NODE]           [0x       0 : 0]
>     >>>         >> alloc_type[CURSEG_WARM_NODE]          [0x       0 : 0]
>     >>>         >> alloc_type[CURSEG_COLD_NODE]          [0x       0 : 0]
>     >>>         >> cur_node_segno[0]                     [0x    173b : 5947]
>     >>>         >> cur_node_segno[1]                     [0x    16d0 : 5840]
>     >>>         >> cur_node_segno[2]                     [0x     536 : 1334]
>     >>>         >> cur_node_blkoff[0]                    [0x     171 : 369]
>     >>>         >> cur_node_blkoff[1]                    [0x      e5 : 229]
>     >>>         >> cur_node_blkoff[2]                    [0x     146 : 326]
>     >>>         >> alloc_type[CURSEG_HOT_DATA]           [0x       0 : 0]
>     >>>         >> alloc_type[CURSEG_WARM_DATA]          [0x       0 : 0]
>     >>>         >> alloc_type[CURSEG_COLD_DATA]          [0x       0 : 0]
>     >>>         >> cur_data_segno[0]                     [0x    1741 : 5953]
>     >>>         >> cur_data_segno[1]                     [0x    8747 : 34631]
>     >>>         >> cur_data_segno[2]                     [0x    6440 : 25664]
>     >>>         >> cur_data_blkoff[0]                    [0x     1f7 : 503]
>     >>>         >> cur_data_blkoff[1]                    [0x     121 : 289]
>     >>>         >> cur_data_blkoff[2]                    [0x     15a : 346]
>     >>>         >> ckpt_flags                            [0x      42 : 66]
>     >>>         >> cp_pack_total_block_count             [0x       6 : 6]
>     >>>         >> cp_pack_start_sum                     [0x       2 : 2]
>     >>>         >> valid_node_count                      [0x  1bbdb5 : 1818037]
>     >>>         >> valid_inode_count                     [0x  1b819a : 1802650]
>     >>>         >> next_free_nid                         [0x  20f518 : 2159896]
>     >>>         >> sit_ver_bitmap_bytesize               [0x      c0 : 192]
>     >>>         >> nat_ver_bitmap_bytesize               [0x     e40 : 3648]
>     >>>         >> checksum_offset                       [0x     ffc : 4092]
>     >>>         >> elapsed_time                          [0x 70188bc :
>     117541052]
>     >>>         >> sit_nat_version_bitmap[0]             [0x      c5 : 197]
>     >>>         >>
>     >>>         >>
>     >>>         >> Info: checkpoint state = 42 :  crc orphan_inodes
>     >> sudden-power-off
>     >>>         >>
>     >>>         >> Done.
>     >>>         >>
>     >>>         >> -----
>     >>>         >>
>     >>>         >> And here's gdb output:
>     >>>         >>
>     >>>         >> (gdb) r /dev/sda2
>     >>>         >> Starting program: /usr/bin/fsck.f2fs /dev/sda2
>     >>>         >> Info: [/dev/sda2] Disk Model: Samsung SSD 840
>     >>>         >> Info: Segments per section = 1
>     >>>         >> Info: Sections per zone = 1
>     >>>         >> Info: sector size = 512
>     >>>         >> Info: total sectors = 234041344 (114278 MB)
>     >>>         >> Info: MKFS version
>     >>>         >>   ""
>     >>>         >> Info: FSCK version
>     >>>         >>   from "Linux version 4.20.0-arch1-1-ARCH
>     >> (builduser@heftig-29859)
>     >>>         >> (gcc version 8.2.1 20181127 (GCC)) #1 SMP PREEMPT Mon Dec 24
>     >>>         03:00:40
>     >>>         >> UTC 2018"
>     >>>         >>     to "Linux version 4.20.0-arch1-1-ARCH
>     >> (builduser@heftig-29859)
>     >>>         >> (gcc version 8.2.1 20181127 (GCC)) #1 SMP PREEMPT Mon Dec 24
>     >>>         03:00:40
>     >>>         >> UTC 2018"
>     >>>         >> Info: superblock features = 0 :
>     >>>         >> Info: superblock encrypt level = 0, salt =
>     >>>         00000000000000000000000000000000
>     >>>         >> Info: total FS sectors = 234041344 (114278 MB)
>     >>>         >> Info: CKPT version = fb3d6
>     >>>         >>
>     >>>         >> Program received signal SIGSEGV, Segmentation fault.
>     >>>         >> 0x00007ffff7f97894 in f2fs_set_bit () from
>     >> /usr/lib/libf2fs.so.6
>     >>>         >>
>     >>>         >>
>     >>>         >> Should I provide some additional arguments to get more
>     >>>         information out of gdb?
>     >>>         >>
>     >>>         >> Aravind
>     >>>         >>
>     >>>         >> On Mon, Jan 7, 2019 at 10:41 AM Chao Yu
>     <yuchao0@huawei.com <mailto:yuchao0@huawei.com>
>     >>>         <mailto:yuchao0@huawei.com <mailto:yuchao0@huawei.com>>> wrote:
>     >>>         >>>
>     >>>         >>> Hi Aravind,
>     >>>         >>>
>     >>>         >>> On 2019/1/6 1:04, Aravind R S wrote:
>     >>>         >>>> I use Arch Linux and the versions of the kernel and
>     >> f2fs-tools
>     >>>         >>>> provided by that distro. I have an F2FS filesystem that
>     >> seems
>     >>>         to have
>     >>>         >>>> become corrupt and cannot be mounted, and running
>     fsck.f2fs
>     >> on it
>     >>>         >>>> results in a segmentation fault:
>     >>>         >>>>
>     >>>         >>>> # fsck.f2fs /dev/sda2
>     >>>         >>>> Info: [/dev/sda2] Disk Model: Samsung SSD 840
>     >>>         >>>> Info: Segments per section = 1
>     >>>         >>>> Info: Sections per zone = 1
>     >>>         >>>> Info: sector size = 512
>     >>>         >>>> Info: total sectors = 234041344 (114278 MB)
>     >>>         >>>> Info: MKFS version
>     >>>         >>>>   ""
>     >>>         >>>> Info: FSCK version
>     >>>         >>>>   from "Linux version 4.19.1-arch1-1-ARCH
>     >> (builduser@heftig-16768)
>     >>>         >>>> (gcc version 8.2.1 20180831 (GCC)) #1 SMP PREEMPT Sun
>     Nov 4
>     >>>         16:49:26
>     >>>         >>>> UTC 2018"
>     >>>         >>>>     to "Linux version 4.20.0-arch1-1-ARCH
>     >> (builduser@heftig-29859)
>     >>>         >>>> (gcc version 8.2.1 20181127 (GCC)) #1 SMP PREEMPT Mon
>     Dec 24
>     >>>         03:00:40
>     >>>         >>>> UTC 2018"
>     >>>         >>>> [update_superblock: 513] Info: Done to update superblock
>     >>>         >>>> Info: superblock features = 0 :
>     >>>         >>>> Info: superblock encrypt level = 0, salt =
>     >>>         00000000000000000000000000000000
>     >>>         >>>> Info: total FS sectors = 234041344 (114278 MB)
>     >>>         >>>> Info: CKPT version = fb3d6
>     >>>         >>>> [1]    2643 segmentation fault  sudo fsck.f2fs /dev/sda2
>     >>>         >>>
>     >>>         >>> Could you give the detail position where triggers segment
>     >>>         fault? gdb may help?
>     >>>         >>>
>     >>>         >>>>
>     >>>         >>>> ---
>     >>>         >>>>
>     >>>         >>>> # mount /dev/sda2 /mnt                               
>         :(
>     >>>         >>>> mount: /mnt: wrong fs type, bad option, bad superblock on
>     >>>         /dev/sda2,
>     >>>         >>>> missing codepage or helper program, or other error.
>     >>>         >>>
>     >>>         >>> Oh, I guess superblock may be broken, could you please dump
>     >>>         sb/cp info via:
>     >>>         >>>
>     >>>         >>> dump.f2fs -d 1 image_path
>     >>>         >>>
>     >>>         >>>>
>     >>>         >>>> ---
>     >>>         >>>>
>     >>>         >>>> Please let me know how I can help debug further.
>     >>>         >>>>
>     >>>         >>>> Aravind
>     >>>         >>>>
>     >>>         >>>>
>     >>>         >>>> _______________________________________________
>     >>>         >>>> Linux-f2fs-devel mailing list
>     >>>         >>>> Linux-f2fs-devel@lists.sourceforge.net
>     <mailto:Linux-f2fs-devel@lists.sourceforge.net>
>     >>>         <mailto:Linux-f2fs-devel@lists.sourceforge.net
>     <mailto: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] 11+ messages in thread

* Re: fsck.f2fs segmentation fault
       [not found]                       ` <CAHZgRdDzvERnwHx92z68r6wD6b2k-zTPck7Tx29ww016h3o6jw@mail.gmail.com>
@ 2019-03-01  7:44                         ` Chao Yu
  0 siblings, 0 replies; 11+ messages in thread
From: Chao Yu @ 2019-03-01  7:44 UTC (permalink / raw)
  To: Aravind R S; +Cc: linux-f2fs-devel

On 2019/2/28 20:24, Aravind R S wrote:
> Sorry for the late reply, I didn't have a Linux machine, so I could only
> try out your v3 fix today. It worked perfectly!
> 
> There is no more crash, and fsck.f2fs was able to proceed and repair my
> partition into a state where the stock kernel is able to mount it.
> 
> Thank you!

Glad to hear that, thanks for you feedback. :)

Thanks,

> 
> Aravind
> 
> 
> On Mon, Jan 14, 2019 at 9:34 AM Chao Yu <yuchao0@huawei.com
> <mailto:yuchao0@huawei.com>> wrote:
> 
>     On 2019/1/12 18:46, Aravind R S wrote:
>     > I've compiled and run this:
>     >
>     > It prints the errors as expected, but then segfaults somewhere else.
> 
>     Could you try v3 I just sent?
> 
>     Thanks,
> 
>     >
>     > Info: [/dev/sda2] Disk Model: Samsung SSD 840
>     > Info: Segments per section = 1
>     > Info: Sections per zone = 1
>     > Info: sector size = 512
>     > Info: total sectors = 234041344 (114278 MB)
>     > Info: MKFS version
>     >   ""
>     > Info: FSCK version
>     >   from "Linux version 4.20.0-arch1-1-ARCH (builduser@heftig-29859) (gcc
>     > version 8.2.1 20181127 (GCC)) #1 SMP PREEMPT Mon Dec 24 03:00:40 UTC
>     2018"
>     >     to "Linux version 4.20.0-arch1-1-ARCH (builduser@heftig-29859) (gcc
>     > version 8.2.1 20181127 (GCC)) #1 SMP PREEMPT Mon Dec 24 03:00:40 UTC
>     2018"
>     > Info: superblock features = 0 :
>     > Info: superblock encrypt level = 0, salt =
>     00000000000000000000000000000000
>     > Info: total FS sectors = 234041344 (114278 MB)
>     > Info: CKPT version = fb3d6
>     >     Error: f2fs_init_nid_bitmap truncate n_nats(8781) to
>     > NAT_JOURNAL_ENTRIES(38)
>     >     Error: f2fs_init_nid_bitmap: addr(2413690880) is invalid!!!
>     >     Error: f2fs_init_nid_bitmap: addr(3103804431) is invalid!!!
>     >     Error: f2fs_init_nid_bitmap: addr(26) is invalid!!!
>     >     Error: f2fs_init_nid_bitmap: addr(8435) is invalid!!!
>     >     Error: f2fs_init_nid_bitmap: nid(4093116417) is invalid!!!
>     >     Error: f2fs_init_nid_bitmap: addr(575256832) is invalid!!!
>     >     Error: f2fs_init_nid_bitmap: addr(2413690986) is invalid!!!
>     >     Error: f2fs_init_nid_bitmap: addr(3724565007) is invalid!!!
>     >     Error: f2fs_init_nid_bitmap: nid(251658383) is invalid!!!
>     >     Error: f2fs_init_nid_bitmap: addr(1343160320) is invalid!!!
>     >     Error: f2fs_init_nid_bitmap: addr(8777) is invalid!!!
>     >     Error: f2fs_init_nid_bitmap: nid(3015180397) is invalid!!!
>     >     Error: f2fs_init_nid_bitmap: nid(3724572416) is invalid!!!
>     >     Error: f2fs_init_nid_bitmap: addr(1478754304) is invalid!!!
>     >     Error: f2fs_init_nid_bitmap: addr(3775060736) is invalid!!!
>     >     Error: f2fs_init_nid_bitmap: addr(48037888) is invalid!!!
>     >     Error: f2fs_init_nid_bitmap: addr(3607101466) is invalid!!!
>     >     Error: f2fs_init_nid_bitmap: addr(6833) is invalid!!!
>     >     Error: f2fs_init_nid_bitmap: nid(1236861657) is invalid!!!
>     >     Error: f2fs_init_nid_bitmap: addr(447865090) is invalid!!!
>     >     Error: f2fs_init_nid_bitmap: addr(1236860989) is invalid!!!
>     >     Error: f2fs_init_nid_bitmap: addr(3774898688) is invalid!!!
>     >     Error: f2fs_init_nid_bitmap: addr(50724864) is invalid!!!
>     >     Error: f2fs_init_nid_bitmap: addr(1041170432) is invalid!!!
>     >     Error: f2fs_init_nid_bitmap: addr(8777) is invalid!!!
>     >     Error: f2fs_init_nid_bitmap: addr(10383) is invalid!!!
>     >     Error: f2fs_init_nid_bitmap: addr(447865090) is invalid!!!
>     >     Error: f2fs_init_nid_bitmap: addr(1236860997) is invalid!!!
>     >     Error: f2fs_init_nid_bitmap: addr(3724571904) is invalid!!!
>     >     Error: f2fs_init_nid_bitmap: addr(52232192) is invalid!!!
>     >     Error: f2fs_init_nid_bitmap: addr(2113929250) is invalid!!!
>     >     Error: f2fs_init_nid_bitmap: addr(251658383) is invalid!!!
>     >     Error: f2fs_init_nid_bitmap: addr(36830) is invalid!!!
>     >     Error: f2fs_init_nid_bitmap: addr(575256832) is invalid!!!
>     >     Error: f2fs_init_nid_bitmap: addr(3113156728) is invalid!!!
>     >     Error: f2fs_init_nid_bitmap: addr(2399142144) is invalid!!!
>     >
>     > Program received signal SIGSEGV, Segmentation fault.
>     > 0x00005555555673de in build_nat_area_bitmap (sbi=<optimized out>) at
>     > mount.c:2469
>     > 2469            if (fsck->entries[nid].block_addr != 0x0) {
>     > (gdb) backtrace
>     > #0  0x00005555555673de in build_nat_area_bitmap (sbi=<optimized out>)
>     >     at mount.c:2469
>     > #1  0x000055555555d85c in fsck_init (sbi=0x55555557db40 <gfsck>) at
>     fsck.c:1904
>     > #2  0x000055555555682a in do_fsck (sbi=0x55555557db40 <gfsck>) at
>     main.c:578
>     > #3  main (argc=<optimized out>, argv=<optimized out>) at main.c:781
>     >
>     > Thanks,
>     > Aravind
>     >
>     >
>     > On Fri, Jan 11, 2019 at 11:50 AM Chao Yu <yuchao0@huawei.com
>     <mailto:yuchao0@huawei.com>
>     > <mailto:yuchao0@huawei.com <mailto:yuchao0@huawei.com>>> wrote:
>     >
>     >     On 2019/1/10 21:41, Aravind R S wrote:
>     >     > Hi,
>     >     >
>     >     > I have this in my kernel logs now:
>     >     >
>     >     > [ 5338.040024] nats:8781, sits:6
>     >     > [ 5338.040027] F2FS-fs (sda2): Failed to initialize F2FS
>     segment manager
>     >     > [ 5338.128893] nats:8781, sits:6
>     >     > [ 5338.128895] F2FS-fs (sda2): Failed to initialize F2FS
>     segment manager
>     >
>     >     Hi Aravind,
>     >
>     >     Oh, it seems nats:8781(total count of nat entries in journal) was
>     >     overflowed, result in loading invalid nat entries when building
>     nat bitmap.
>     >
>     >     Could you try below patch? Notice that, it will be better to
>     backup your
>     >     whole image before run patched fsck to avoid any data corruption
>     risk.
>     >
>     >     [PATCH v2] fsck.f2fs: check validity of nat journal
>     >
>     >     Thanks,
>     >
>     >     >
>     >     > Thanks,
>     >     > Aravind
>     >     >
>     >     >
>     >     > On Wed, Jan 9, 2019 at 11:41 AM Chao Yu <yuchao0@huawei.com
>     <mailto:yuchao0@huawei.com>
>     >     <mailto:yuchao0@huawei.com <mailto:yuchao0@huawei.com>>> wrote:
>     >     >
>     >     >> On 2019/1/9 8:44, Aravind R S wrote:
>     >     >>> Also, if it helps, after each failed mount there are two
>     error lines
>     >     >> added
>     >     >>> to the kernel logs:
>     >     >>>
>     >     >>> [13845.849740] F2FS-fs (sda2): Failed to initialize F2FS segment
>     >     manager
>     >     >>> [13845.936688] F2FS-fs (sda2): Failed to initialize F2FS segment
>     >     manager
>     >     >>>
>     >     >>> There are no messages at the other log levels (debug, info etc).
>     >     >>>
>     >     >>> Also, I must mention that this filesystem was last written to
>     some time
>     >     >>> ago, I believe under kernel 4.18.
>     >     >>
>     >     >> I suspect nat/sit journal info are corrupted, could you apply
>     below
>     >     diff,
>     >     >> recompile/reinstall the f2fs ko, and retry the mount?
>     >     >>
>     >     >> --- a/fs/f2fs/segment.c
>     >     >> +++ b/fs/f2fs/segment.c
>     >     >> @@ -3538,8 +3538,10 @@ static int restore_curseg_summaries(struct
>     >     >> f2fs_sb_info *sbi)
>     >     >>
>     >     >>         /* sanity check for summary blocks */
>     >     >>         if (nats_in_cursum(nat_j) > NAT_JOURNAL_ENTRIES ||
>     >     >> -                       sits_in_cursum(sit_j) >
>     SIT_JOURNAL_ENTRIES)
>     >     >> +                       sits_in_cursum(sit_j) >
>     SIT_JOURNAL_ENTRIES) {
>     >     >> +               printk("nats:%u, sits:%u", nats_in_cursum(nat_j),
>     >     >> sits_in_cursum(sit_j));
>     >     >>                 return -EINVAL;
>     >     >> +       }
>     >     >>
>     >     >>         return 0;
>     >     >>  }
>     >     >>
>     >     >>
>     >     >>>
>     >     >>> Aravind
>     >     >>>
>     >     >>>
>     >     >>> On Tue, Jan 8, 2019 at 8:05 PM Aravind R S
>     <aravindet@gmail.com <mailto:aravindet@gmail.com>
>     >     <mailto:aravindet@gmail.com <mailto:aravindet@gmail.com>>
>     >     >>> <mailto:aravindet@gmail.com <mailto:aravindet@gmail.com>
>     <mailto:aravindet@gmail.com <mailto:aravindet@gmail.com>>>> wrote:
>     >     >>>
>     >     >>>     fsck.f2fs -d 3 just prints the same output as dump.f2fs
>     -d 1 before
>     >     >>>     segfaulting.
>     >     >>>
>     >     >>>     I built f2fs tools from source (at tag v1.12.0) and was
>     able to get
>     >     >>>     this backtrace in gdb:
>     >     >>>
>     >     >>>     Program received signal SIGSEGV, Segmentation fault.
>     >     >>>     0x00007ffff7f8eb54 in f2fs_set_bit (nr=1041170432,
>     >     >>>         addr=0x7fffff621010 <error: Cannot access memory at
>     address
>     >     >>>     0x7fffff621010>) at libf2fs.c:312
>     >     >>>     312        mask = 1 << (7 - (nr & 0x07));
>     >     >>>     (gdb) where
>     >     >>>     #0  0x00007ffff7f8eb54 in f2fs_set_bit (nr=1041170432,
>     >     >>>         addr=0x7fffff621010 <error: Cannot access memory at
>     address
>     >     >>>     0x7fffff621010>) at libf2fs.c:312
>     >     >>>     #1  0x00005555555648ad in f2fs_init_nid_bitmap
>     (sbi=0x55555557db40
>     >     >>>     <gfsck>) at mount.c:1069
>     >     >>>     #2  init_node_manager (sbi=sbi@entry=0x55555557db40
>     <gfsck>) at
>     >     >>>     mount.c:1275
>     >     >>>     #3  0x0000555555564900 in build_node_manager
>     >     >>>     (sbi=sbi@entry=0x55555557db40 <gfsck>) at mount.c:1285
>     >     >>>     #4  0x0000555555567824 in f2fs_do_mount (sbi=0x55555557db40
>     >     <gfsck>)
>     >     >> at
>     >     >>>     mount.c:2597
>     >     >>>     #5  0x00005555555565c5 in main (argc=<optimized out>,
>     >     argv=<optimized
>     >     >>>     out>) at main.c:770
>     >     >>>
>     >     >>>
>     >     >>>     Aravind
>     >     >>>
>     >     >>>
>     >     >>>     On Tue, Jan 8, 2019 at 10:48 AM Chao Yu
>     <yuchao0@huawei.com <mailto:yuchao0@huawei.com>
>     >     <mailto:yuchao0@huawei.com <mailto:yuchao0@huawei.com>>
>     >     >>>     <mailto:yuchao0@huawei.com <mailto:yuchao0@huawei.com>
>     <mailto:yuchao0@huawei.com <mailto:yuchao0@huawei.com>>>> wrote:
>     >     >>>
>     >     >>>         On 2019/1/7 12:52, Aravind R S wrote:
>     >     >>>         > Here's the backtrace where it segfaults. I don't
>     have it
>     >     >> compiled
>     >     >>>         with
>     >     >>>         > the debug symbols, but if you can point me to some
>     >     >> instructions I'm
>     >     >>>         > happy to try that.
>     >     >>>         >
>     >     >>>         > (gdb) backtrace
>     >     >>>         > #0  0x00007ffff7f97894 in f2fs_set_bit () from
>     >     >> /usr/lib/libf2fs.so.6
>     >     >>>         > #1  0x0000555555565206 in ?? ()
>     >     >>>         > #2  0x0000555555568214 in ?? ()
>     >     >>>         > #3  0x00005555555560be in ?? ()
>     >     >>>         > #4  0x00007ffff7df5223 in __libc_start_main () from
>     >     >>>         /usr/lib/libc.so.6
>     >     >>>         > #5  0x000055555555695e in ?? ()
>     >     >>>
>     >     >>>         I can't track source code with above call stack..
>     >     >>>
>     >     >>>         How about downloading tools source code from below
>     git repo
>     >     >>>         address, and
>     >     >>>         compile the source code, run gdb with compiled binary.
>     >     >>>
>     >     >>>
>     >     >>
>     https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs-tools.git/
>     >     >>>
>     >     >>>
>     >     >>>         BTW, could you run fsck again with parameter '-d 3'?
>     and let's
>     >     >>>         check the
>     >     >>>         printed debug info.
>     >     >>>
>     >     >>>         Thanks,
>     >     >>>
>     >     >>>         >
>     >     >>>         >
>     >     >>>         > Aravind
>     >     >>>         >
>     >     >>>         > On Mon, Jan 7, 2019 at 12:20 PM Aravind R S <
>     >     >> aravindet@gmail.com <mailto:aravindet@gmail.com>
>     <mailto:aravindet@gmail.com <mailto:aravindet@gmail.com>>
>     >     >>>         <mailto:aravindet@gmail.com
>     <mailto:aravindet@gmail.com> <mailto:aravindet@gmail.com
>     <mailto:aravindet@gmail.com>>>>
>     >     wrote:
>     >     >>>         >>
>     >     >>>         >> Thanks! Here's the output of dump.f2fs:
>     >     >>>         >>
>     >     >>>         >> # dump.f2fs -d 1 /dev/sda2
>     >     >>
>     >     >>>                 :(
>     >     >>>         >> Info: Debug level = 1
>     >     >>>         >> Info: [/dev/sda2] Disk Model: Samsung SSD 840
>     >     >>>         >> Info: Segments per section = 1
>     >     >>>         >> Info: Sections per zone = 1
>     >     >>>         >> Info: sector size = 512
>     >     >>>         >> Info: total sectors = 234041344 (114278 MB)
>     >     >>>         >> Info: MKFS version
>     >     >>>         >>   ""
>     >     >>>         >> Info: FSCK version
>     >     >>>         >>   from "Linux version 4.20.0-arch1-1-ARCH
>     >     >> (builduser@heftig-29859)
>     >     >>>         >> (gcc version 8.2.1 20181127 (GCC)) #1 SMP PREEMPT
>     Mon Dec 24
>     >     >>>         03:00:40
>     >     >>>         >> UTC 2018"
>     >     >>>         >>     to "Linux version 4.20.0-arch1-1-ARCH
>     >     >> (builduser@heftig-29859)
>     >     >>>         >> (gcc version 8.2.1 20181127 (GCC)) #1 SMP PREEMPT
>     Mon Dec 24
>     >     >>>         03:00:40
>     >     >>>         >> UTC 2018"
>     >     >>>         >> Info: superblock features = 0 :
>     >     >>>         >> Info: superblock encrypt level = 0, salt =
>     >     >>>         00000000000000000000000000000000
>     >     >>>         >>
>     >     >>>         >>
>     +--------------------------------------------------------+
>     >     >>>         >> | Super block                                     
>           |
>     >     >>>         >>
>     +--------------------------------------------------------+
>     >     >>>         >> magic                                 [0xf2f52010 :
>     >     >> 4076150800]
>     >     >>>         >> major_ver                             [0x       1 : 1]
>     >     >>>         >> volum_name                            [root]
>     >     >>>         >> minor_ver                             [0x       2 : 2]
>     >     >>>         >> log_sectorsize                        [0x       9 : 9]
>     >     >>>         >> log_sectors_per_block                 [0x       3 : 3]
>     >     >>>         >> log_blocksize                         [0x       c
>     : 12]
>     >     >>>         >> log_blocks_per_seg                    [0x       9 : 9]
>     >     >>>         >> segs_per_sec                          [0x       1 : 1]
>     >     >>>         >> secs_per_zone                         [0x       1 : 1]
>     >     >>>         >> checksum_offset                       [0x       0 : 0]
>     >     >>>         >> block_count                           [0x 1be6600 :
>     >     29255168]
>     >     >>>         >> section_count                         [0x    de48
>     : 56904]
>     >     >>>         >> segment_count                         [0x    df32
>     : 57138]
>     >     >>>         >> segment_count_ckpt                    [0x       2 : 2]
>     >     >>>         >> segment_count_sit                     [0x       6 : 6]
>     >     >>>         >> segment_count_nat                     [0x      72
>     : 114]
>     >     >>>         >> segment_count_ssa                     [0x      70
>     : 112]
>     >     >>>         >> segment_count_main                    [0x    de48
>     : 56904]
>     >     >>>         >> segment0_blkaddr                      [0x     100
>     : 256]
>     >     >>>         >> cp_blkaddr                            [0x     100
>     : 256]
>     >     >>>         >> sit_blkaddr                           [0x     500
>     : 1280]
>     >     >>>         >> nat_blkaddr                           [0x    1100
>     : 4352]
>     >     >>>         >> ssa_blkaddr                           [0x    f500
>     : 62720]
>     >     >>>         >> main_blkaddr                          [0x   1d500
>     : 120064]
>     >     >>>         >> root_ino                              [0x       3 : 3]
>     >     >>>         >> node_ino                              [0x       1 : 1]
>     >     >>>         >> meta_ino                              [0x       2 : 2]
>     >     >>>         >> cp_payload                            [0x       0 : 0]
>     >     >>>         >> crc                                   [0x       0 : 0]
>     >     >>>         >> version                       Linux version
>     >     >> 4.20.0-arch1-1-ARCH
>     >     >>>         >> (builduser@heftig-29859) (gcc version 8.2.1
>     20181127 (GCC))
>     >     >> #1 SMP
>     >     >>>         >> PREEMPT Mon Dec 24 03:00:40 UTC 2018
>     >     >>>         >> Info: total FS sectors = 234041344 (114278 MB)
>     >     >>>         >> Info: CKPT version = fb3d6
>     >     >>>         >>
>     >     >>>         >>
>     +--------------------------------------------------------+
>     >     >>>         >> | Checkpoint                                     
>            |
>     >     >>>         >>
>     +--------------------------------------------------------+
>     >     >>>         >> checkpoint_ver                        [0x   fb3d6
>     : 1029078]
>     >     >>>         >> user_block_count                      [0x 1a5fc00 :
>     >     27655168]
>     >     >>>         >> valid_block_count                     [0x 13777de :
>     >     20412382]
>     >     >>>         >> rsvd_segment_count                    [0x      30
>     : 48]
>     >     >>>         >> overprov_segment_count                [0x     b4a
>     : 2890]
>     >     >>>         >> free_segment_count                    [0x    2ce2
>     : 11490]
>     >     >>>         >> alloc_type[CURSEG_HOT_NODE]           [0x       0 : 0]
>     >     >>>         >> alloc_type[CURSEG_WARM_NODE]          [0x       0 : 0]
>     >     >>>         >> alloc_type[CURSEG_COLD_NODE]          [0x       0 : 0]
>     >     >>>         >> cur_node_segno[0]                     [0x    173b
>     : 5947]
>     >     >>>         >> cur_node_segno[1]                     [0x    16d0
>     : 5840]
>     >     >>>         >> cur_node_segno[2]                     [0x     536
>     : 1334]
>     >     >>>         >> cur_node_blkoff[0]                    [0x     171
>     : 369]
>     >     >>>         >> cur_node_blkoff[1]                    [0x      e5
>     : 229]
>     >     >>>         >> cur_node_blkoff[2]                    [0x     146
>     : 326]
>     >     >>>         >> alloc_type[CURSEG_HOT_DATA]           [0x       0 : 0]
>     >     >>>         >> alloc_type[CURSEG_WARM_DATA]          [0x       0 : 0]
>     >     >>>         >> alloc_type[CURSEG_COLD_DATA]          [0x       0 : 0]
>     >     >>>         >> cur_data_segno[0]                     [0x    1741
>     : 5953]
>     >     >>>         >> cur_data_segno[1]                     [0x    8747
>     : 34631]
>     >     >>>         >> cur_data_segno[2]                     [0x    6440
>     : 25664]
>     >     >>>         >> cur_data_blkoff[0]                    [0x     1f7
>     : 503]
>     >     >>>         >> cur_data_blkoff[1]                    [0x     121
>     : 289]
>     >     >>>         >> cur_data_blkoff[2]                    [0x     15a
>     : 346]
>     >     >>>         >> ckpt_flags                            [0x      42
>     : 66]
>     >     >>>         >> cp_pack_total_block_count             [0x       6 : 6]
>     >     >>>         >> cp_pack_start_sum                     [0x       2 : 2]
>     >     >>>         >> valid_node_count                      [0x  1bbdb5
>     : 1818037]
>     >     >>>         >> valid_inode_count                     [0x  1b819a
>     : 1802650]
>     >     >>>         >> next_free_nid                         [0x  20f518
>     : 2159896]
>     >     >>>         >> sit_ver_bitmap_bytesize               [0x      c0
>     : 192]
>     >     >>>         >> nat_ver_bitmap_bytesize               [0x     e40
>     : 3648]
>     >     >>>         >> checksum_offset                       [0x     ffc
>     : 4092]
>     >     >>>         >> elapsed_time                          [0x 70188bc :
>     >     117541052]
>     >     >>>         >> sit_nat_version_bitmap[0]             [0x      c5
>     : 197]
>     >     >>>         >>
>     >     >>>         >>
>     >     >>>         >> Info: checkpoint state = 42 :  crc orphan_inodes
>     >     >> sudden-power-off
>     >     >>>         >>
>     >     >>>         >> Done.
>     >     >>>         >>
>     >     >>>         >> -----
>     >     >>>         >>
>     >     >>>         >> And here's gdb output:
>     >     >>>         >>
>     >     >>>         >> (gdb) r /dev/sda2
>     >     >>>         >> Starting program: /usr/bin/fsck.f2fs /dev/sda2
>     >     >>>         >> Info: [/dev/sda2] Disk Model: Samsung SSD 840
>     >     >>>         >> Info: Segments per section = 1
>     >     >>>         >> Info: Sections per zone = 1
>     >     >>>         >> Info: sector size = 512
>     >     >>>         >> Info: total sectors = 234041344 (114278 MB)
>     >     >>>         >> Info: MKFS version
>     >     >>>         >>   ""
>     >     >>>         >> Info: FSCK version
>     >     >>>         >>   from "Linux version 4.20.0-arch1-1-ARCH
>     >     >> (builduser@heftig-29859)
>     >     >>>         >> (gcc version 8.2.1 20181127 (GCC)) #1 SMP PREEMPT
>     Mon Dec 24
>     >     >>>         03:00:40
>     >     >>>         >> UTC 2018"
>     >     >>>         >>     to "Linux version 4.20.0-arch1-1-ARCH
>     >     >> (builduser@heftig-29859)
>     >     >>>         >> (gcc version 8.2.1 20181127 (GCC)) #1 SMP PREEMPT
>     Mon Dec 24
>     >     >>>         03:00:40
>     >     >>>         >> UTC 2018"
>     >     >>>         >> Info: superblock features = 0 :
>     >     >>>         >> Info: superblock encrypt level = 0, salt =
>     >     >>>         00000000000000000000000000000000
>     >     >>>         >> Info: total FS sectors = 234041344 (114278 MB)
>     >     >>>         >> Info: CKPT version = fb3d6
>     >     >>>         >>
>     >     >>>         >> Program received signal SIGSEGV, Segmentation fault.
>     >     >>>         >> 0x00007ffff7f97894 in f2fs_set_bit () from
>     >     >> /usr/lib/libf2fs.so.6
>     >     >>>         >>
>     >     >>>         >>
>     >     >>>         >> Should I provide some additional arguments to get more
>     >     >>>         information out of gdb?
>     >     >>>         >>
>     >     >>>         >> Aravind
>     >     >>>         >>
>     >     >>>         >> On Mon, Jan 7, 2019 at 10:41 AM Chao Yu
>     >     <yuchao0@huawei.com <mailto:yuchao0@huawei.com>
>     <mailto:yuchao0@huawei.com <mailto:yuchao0@huawei.com>>
>     >     >>>         <mailto:yuchao0@huawei.com
>     <mailto:yuchao0@huawei.com> <mailto:yuchao0@huawei.com
>     <mailto:yuchao0@huawei.com>>>> wrote:
>     >     >>>         >>>
>     >     >>>         >>> Hi Aravind,
>     >     >>>         >>>
>     >     >>>         >>> On 2019/1/6 1:04, Aravind R S wrote:
>     >     >>>         >>>> I use Arch Linux and the versions of the kernel and
>     >     >> f2fs-tools
>     >     >>>         >>>> provided by that distro. I have an F2FS
>     filesystem that
>     >     >> seems
>     >     >>>         to have
>     >     >>>         >>>> become corrupt and cannot be mounted, and running
>     >     fsck.f2fs
>     >     >> on it
>     >     >>>         >>>> results in a segmentation fault:
>     >     >>>         >>>>
>     >     >>>         >>>> # fsck.f2fs /dev/sda2
>     >     >>>         >>>> Info: [/dev/sda2] Disk Model: Samsung SSD 840
>     >     >>>         >>>> Info: Segments per section = 1
>     >     >>>         >>>> Info: Sections per zone = 1
>     >     >>>         >>>> Info: sector size = 512
>     >     >>>         >>>> Info: total sectors = 234041344 (114278 MB)
>     >     >>>         >>>> Info: MKFS version
>     >     >>>         >>>>   ""
>     >     >>>         >>>> Info: FSCK version
>     >     >>>         >>>>   from "Linux version 4.19.1-arch1-1-ARCH
>     >     >> (builduser@heftig-16768)
>     >     >>>         >>>> (gcc version 8.2.1 20180831 (GCC)) #1 SMP
>     PREEMPT Sun
>     >     Nov 4
>     >     >>>         16:49:26
>     >     >>>         >>>> UTC 2018"
>     >     >>>         >>>>     to "Linux version 4.20.0-arch1-1-ARCH
>     >     >> (builduser@heftig-29859)
>     >     >>>         >>>> (gcc version 8.2.1 20181127 (GCC)) #1 SMP
>     PREEMPT Mon
>     >     Dec 24
>     >     >>>         03:00:40
>     >     >>>         >>>> UTC 2018"
>     >     >>>         >>>> [update_superblock: 513] Info: Done to update
>     superblock
>     >     >>>         >>>> Info: superblock features = 0 :
>     >     >>>         >>>> Info: superblock encrypt level = 0, salt =
>     >     >>>         00000000000000000000000000000000
>     >     >>>         >>>> Info: total FS sectors = 234041344 (114278 MB)
>     >     >>>         >>>> Info: CKPT version = fb3d6
>     >     >>>         >>>> [1]    2643 segmentation fault  sudo fsck.f2fs
>     /dev/sda2
>     >     >>>         >>>
>     >     >>>         >>> Could you give the detail position where triggers
>     segment
>     >     >>>         fault? gdb may help?
>     >     >>>         >>>
>     >     >>>         >>>>
>     >     >>>         >>>> ---
>     >     >>>         >>>>
>     >     >>>         >>>> # mount /dev/sda2 /mnt                         
>          
>     >         :(
>     >     >>>         >>>> mount: /mnt: wrong fs type, bad option, bad
>     superblock on
>     >     >>>         /dev/sda2,
>     >     >>>         >>>> missing codepage or helper program, or other error.
>     >     >>>         >>>
>     >     >>>         >>> Oh, I guess superblock may be broken, could you
>     please dump
>     >     >>>         sb/cp info via:
>     >     >>>         >>>
>     >     >>>         >>> dump.f2fs -d 1 image_path
>     >     >>>         >>>
>     >     >>>         >>>>
>     >     >>>         >>>> ---
>     >     >>>         >>>>
>     >     >>>         >>>> Please let me know how I can help debug further.
>     >     >>>         >>>>
>     >     >>>         >>>> Aravind
>     >     >>>         >>>>
>     >     >>>         >>>>
>     >     >>>         >>>> _______________________________________________
>     >     >>>         >>>> Linux-f2fs-devel mailing list
>     >     >>>         >>>> Linux-f2fs-devel@lists.sourceforge.net
>     <mailto:Linux-f2fs-devel@lists.sourceforge.net>
>     >     <mailto:Linux-f2fs-devel@lists.sourceforge.net
>     <mailto:Linux-f2fs-devel@lists.sourceforge.net>>
>     >     >>>         <mailto:Linux-f2fs-devel@lists.sourceforge.net
>     <mailto:Linux-f2fs-devel@lists.sourceforge.net>
>     >     <mailto:Linux-f2fs-devel@lists.sourceforge.net
>     <mailto: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] 11+ messages in thread

end of thread, other threads:[~2019-03-01  7:44 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-05 17:04 fsck.f2fs segmentation fault Aravind R S
2019-01-07  2:40 ` Chao Yu
2019-01-07  4:20   ` Aravind R S
2019-01-07  4:52     ` Aravind R S
2019-01-08  2:48       ` Chao Yu
     [not found]         ` <CAHZgRdA+HCwCU-iTVK5EmUt2rcP0=F3Z+mOu+xa7SF6-os+ANg@mail.gmail.com>
2019-01-09  2:19           ` Chao Yu
     [not found]           ` <CAHZgRdAvPn+ButJ=zv9tji8KsoZqVECg1MHRq-4xi-tPxWeExQ@mail.gmail.com>
2019-01-09  3:41             ` Chao Yu
     [not found]               ` <CAHZgRdCMxoAWf_tf9ae8e4TSBPCWE-fhSF8Ej_fCUh47auMUVA@mail.gmail.com>
2019-01-11  3:50                 ` Chao Yu
     [not found]                   ` <CAHZgRdABH2Cz4pTLdJ0WFaLxaKvLN49asBF6j8mH32Qprgi1wA@mail.gmail.com>
2019-01-14  1:33                     ` Chao Yu
     [not found]                       ` <CAHZgRdDzvERnwHx92z68r6wD6b2k-zTPck7Tx29ww016h3o6jw@mail.gmail.com>
2019-03-01  7:44                         ` Chao Yu
2019-01-08  2:27     ` 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.